Storing Model Differences in the database
Xafari.ModelDifferencesDb module provides the feature to store Model Differences and User Model Differences in the database. It uses DevExpress controllers, to manage stored in the database Model Differences. To get extensive knowlege refer to the following topics:
- https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument113698
- https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument113697
To use Xafari storage, follow the steps described below.
- Add references to the Xafari and Xafari.ModelDifferencesDb libraries.
- Add Xafari.ModelDifferencesDb.XafariModelDifferencesDbModule to your platform-dependent Win (or Web) module.
- 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 AddContext(string) method (see Xafari.CustomizeModelDifferenceStoreParamsEventArgs section in Main Classes topic). For example, with it, you can specify «WEB» extension for web-module.
- c#
- VB
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");
}
Public Sub New()
InitializeComponent()
AddHandler ModelDifferenceStoreManager.Instance.BeforeChangeStoreFactory, AddressOf OnBeforeChangeStoreFactory
AddHandler ModelDifferenceStoreManager.Instance.AfterChangeStoreFactory, AddressOf OnAfterChangeStoreFactory
End Sub
Private Sub OnAfterChangeStoreFactory(ByVal sender As Object, ByVal e As ChangeStoreFactoryEventArgs)
If e.StoreFactory IsNot Nothing Then
AddHandler e.StoreFactory.CustomizeModelDifferenceStoreParams, AddressOf OnCustomizeParams
End If
End Sub
Private Sub OnBeforeChangeStoreFactory(ByVal sender As Object, ByVal e As ChangeStoreFactoryEventArgs)
If e.StoreFactory IsNot Nothing Then
RemoveHandler e.StoreFactory.CustomizeModelDifferenceStoreParams, AddressOf OnCustomizeParams
End If
End Sub
Private Sub OnCustomizeParams(ByVal sender As Object, ByVal e As ModelDifferenceStoreParamsEventArgs)
e.ExtendCode("WEB")
End Sub