Hello Mikko,
Piece of documentation about XafariModelDifferencesDbModule you can read below:
Storing Model Differences in the database. Xafari.ModelDifferencesDb module
Xafari.ModelDifferencesDb module provides the feature to store Model Differences and User Model Differences in the database. To implement this feature, follow the steps described below.
• Add Xafari.Win. XafariWinModule to your platform-dependent Win-module (or add Xafari.Web.XafariWebModule to your platform-dependent Web-module). Add modules using the designer or in code directly.
• Add Xafari.ModelDifferencesDb.XafariModelDifferencesDbModule to your platform-dependent Win (or Web) module.
Note. It is very important to observe the described order. You should firstly add XafariWin(Web)Module, and only then add XafariModelDifferencesDbModule to your platform-dependent module. The fact that XafariWinModule (or XafariWebModule) creates its own instance of the Store Factory. The described initialisation order allows for XafariModelDifferencesDbModule correctly create its own instance of the StoreFactory.
• Set static fields of the Xafari.ModelDifferencesDb.XafariModelDifferencesDbModule class: EnableModelDifferencePermissionsCheck, StoreUserModelDifferencesInDb, StoreModelDifferencesInDb. Required values are described in class documentation.
• To work with the database, configure the ConnectionString in the application config-file.
If Win and Web applications will work together with a common database, then setting of the same user will also be used in conjunction. This is not always desirable because some settings of the Model differs for Win and Web. For example, various Property Editors may be used. In this case, to separate settings for different platforms, you can use the ExtendCode(string) method (see Xafari.CustomizeModelDifferenceStoreParamsEventArgs section). For example, with it, you can specify «WEB» extension for web-module.
public TestSolutionDiffsDbStoreAspNetModule()
{
InitializeComponent();
ModelDifferenceStoreManager.Instance.BeforeChangeStoreFactory +=
OnBeforeChangeStoreFactory;
ModelDifferenceStoreManager.Instance.AfterChangeStoreFactory +=
OnAfterChangeStoreFactory;
}
private void OnAfterChangeStoreFactory (object sender, ChangeStoreFactoryEventArgs e)
{
if (e.StoreFactory != null)
e.StoreFactory.CustomizeModelDifferenceStoreParams += OnCustomizeParams;
}
private void OnBeforeChangeStoreFactory (object sender, ChangeStoreFactoryEventArgs e)
{
if (e.StoreFactory != null)
e.StoreFactory.CustomizeModelDifferenceStoreParams -= OnCustomizeParams;
}
private void OnCustomizeParams (object sender, ModelDifferenceStoreParamsEventArgs e)
{
e.ExtendCode("WEB");
}
Code snippet.
Xafari. ModelDifferenceStoreParamsEventArgs
Xafari.ModelDifferenceStoreFactory class generates CustomizeModelDifferenceSoreParams и CustomizeUserModelDifferenceSoreParams events. ModelDifferenceStoreParamsEventArgs class is a parameter of this events. It exposes ExtendCode(string) method and Code property.
Application code reads (writes) Model Differences aspects using search key. ExtendCode method extends the search key by adding new segments. When searching, framework sorts segments in ascending order. Then segments are concatenated into a single string. The resulting string is the search key. Code property provides the key to search the aspect.
That is, for example, one user may have multiple different independent User Model Differences, if necessary.
I hope you find the information helpful.
Sasha
|