This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
WebApplication.cs
122 lines (118 loc) · 6.83 KB
/
WebApplication.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.Web;
using System.Collections.Generic;
using DevExpress.ExpressApp.Xpo;
using DevExpress.ExpressApp.Security;
using DevExpress.ExpressApp.Security.ClientServer;
using E2371.Module;
namespace E2371.Web {
// For more typical usage scenarios, be sure to check out https://documentation.devexpress.com/eXpressAppFramework/DevExpressExpressAppWebWebApplicationMembersTopicAll.aspx
public partial class E2371AspNetApplication : WebApplication {
private DevExpress.ExpressApp.SystemModule.SystemModule module1;
private DevExpress.ExpressApp.Web.SystemModule.SystemAspNetModule module2;
private E2371.Module.E2371Module module3;
private E2371.Module.Web.E2371AspNetModule module4;
private DevExpress.ExpressApp.Security.SecurityModule securityModule1;
private DevExpress.ExpressApp.Security.SecurityStrategyComplex securityStrategyComplex1;
private DevExpress.ExpressApp.Validation.ValidationModule validationModule;
private DevExpress.ExpressApp.Validation.Web.ValidationAspNetModule validationAspNetModule;
#region Default XAF configuration options (https://www.devexpress.com/kb=T501418)
static E2371AspNetApplication() {
EnableMultipleBrowserTabsSupport = true;
DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridListEditor.AllowFilterControlHierarchy = true;
DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridListEditor.MaxFilterControlHierarchyDepth = 3;
DevExpress.ExpressApp.Web.Editors.ASPx.ASPxCriteriaPropertyEditor.AllowFilterControlHierarchyDefault = true;
DevExpress.ExpressApp.Web.Editors.ASPx.ASPxCriteriaPropertyEditor.MaxHierarchyDepthDefault = 3;
DevExpress.Persistent.Base.PasswordCryptographer.EnableRfc2898 = true;
DevExpress.Persistent.Base.PasswordCryptographer.SupportLegacySha512 = false;
}
private void InitializeDefaults() {
LinkNewObjectToParentImmediately = false;
OptimizedControllersCreation = true;
}
#endregion
public E2371AspNetApplication() {
InitializeComponent();
InitializeDefaults();
SetupAuthenticationHelper.Setup(this);
}
protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) {
args.ObjectSpaceProvider = new SecuredObjectSpaceProvider((SecurityStrategyComplex)Security, GetDataStoreProvider(args.ConnectionString, args.Connection), true);
args.ObjectSpaceProviders.Add(new NonPersistentObjectSpaceProvider(TypesInfo, null));
}
private IXpoDataStoreProvider GetDataStoreProvider(string connectionString, System.Data.IDbConnection connection) {
System.Web.HttpApplicationState application = (System.Web.HttpContext.Current != null) ? System.Web.HttpContext.Current.Application : null;
IXpoDataStoreProvider dataStoreProvider = null;
if(application != null && application["DataStoreProvider"] != null) {
dataStoreProvider = application["DataStoreProvider"] as IXpoDataStoreProvider;
}
else {
dataStoreProvider = XPObjectSpaceProvider.GetDataStoreProvider(connectionString, connection, true);
if(application != null) {
application["DataStoreProvider"] = dataStoreProvider;
}
}
return dataStoreProvider;
}
private void E2371AspNetApplication_DatabaseVersionMismatch(object sender, DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs e) {
#if EASYTEST
e.Updater.Update();
e.Handled = true;
#else
if(System.Diagnostics.Debugger.IsAttached) {
e.Updater.Update();
e.Handled = true;
}
else {
string message = "The application cannot connect to the specified database, " +
"because the database doesn't exist, its version is older " +
"than that of the application or its schema does not match " +
"the ORM data model structure. To avoid this error, use one " +
"of the solutions from the https://www.devexpress.com/kb=T367835 KB Article.";
if(e.CompatibilityError != null && e.CompatibilityError.Exception != null) {
message += "\r\n\r\nInner exception: " + e.CompatibilityError.Exception.Message;
}
throw new InvalidOperationException(message);
}
#endif
}
private void InitializeComponent() {
this.module1 = new DevExpress.ExpressApp.SystemModule.SystemModule();
this.module2 = new DevExpress.ExpressApp.Web.SystemModule.SystemAspNetModule();
this.module3 = new E2371.Module.E2371Module();
this.module4 = new E2371.Module.Web.E2371AspNetModule();
this.securityModule1 = new DevExpress.ExpressApp.Security.SecurityModule();
this.securityStrategyComplex1 = new DevExpress.ExpressApp.Security.SecurityStrategyComplex();
this.securityStrategyComplex1.SupportNavigationPermissionsForTypes = false;
this.validationModule = new DevExpress.ExpressApp.Validation.ValidationModule();
this.validationAspNetModule = new DevExpress.ExpressApp.Validation.Web.ValidationAspNetModule();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
//
// securityStrategyComplex1
//
this.securityStrategyComplex1.RoleType = typeof(DevExpress.Persistent.BaseImpl.PermissionPolicy.PermissionPolicyRole);
this.securityStrategyComplex1.UserType = typeof(Module.BusinessObjects.CustomPermissionPolicyUser);
//
// securityModule1
//
this.securityModule1.UserType = typeof(Module.BusinessObjects.CustomPermissionPolicyUser);
//
// E2371AspNetApplication
//
this.ApplicationName = "E2371";
this.CheckCompatibilityType = DevExpress.ExpressApp.CheckCompatibilityType.DatabaseSchema;
this.Modules.Add(this.module1);
this.Modules.Add(this.module2);
this.Modules.Add(this.module3);
this.Modules.Add(this.module4);
this.Modules.Add(this.securityModule1);
this.Security = this.securityStrategyComplex1;
this.Modules.Add(this.validationModule);
this.Modules.Add(this.validationAspNetModule);
this.DatabaseVersionMismatch += new System.EventHandler<DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs>(this.E2371AspNetApplication_DatabaseVersionMismatch);
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
}
}
}