public override void UpdateDatabaseAfterUpdateSchema() { var session = ((XPObjectSpace)ObjectSpace).Session; if (new QueryModelDifferenceObject(session).GetActiveModelDifference(ModelCombine, ApplicationHelper.Instance.Application) == null) { new ModelDifferenceObject(session).InitializeMembers(ModelCombine, ApplicationHelper.Instance.Application); var role = (XpandPermissionPolicyRole)ObjectSpace.GetRole(ModelCombine); role.CanEditModel = true; var permissionData = ObjectSpace.CreateObject <ModelCombineOperationPermissionPolicyData>(); permissionData.Difference = ModelCombine; role.Permissions.Add(permissionData); var user = ObjectSpace.GetUser(ModelCombine, "", role); var collection = (XPBaseCollection)((XafMemberInfo)XafTypesInfo.Instance.FindTypeInfo(role.GetType()).FindMember("Users")).GetValue(role); collection.BaseAdd(user); ObjectSpace.CommitChanges(); } var modelDifferenceObjects = new XpandXPCollection <ModelDifferenceObject>(session, o => o.PersistentApplication.Name == "FeatureCenter"); foreach (var modelDifferenceObject in modelDifferenceObjects) { modelDifferenceObject.PersistentApplication.Name = Path.GetFileNameWithoutExtension(modelDifferenceObject.PersistentApplication.ExecutableName); } ObjectSpace.CommitChanges(); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); this.AddDefaultSecurityObjects(); if (_userId != Guid.Empty) { ((PermissionPolicyUser)ObjectSpace.GetUser(_admin?"Admin":"User")).SetMemberValue("oid", _userId); } ObjectSpace.CommitChanges(); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (ObjectSpace.FindObject <Country>(null) == null) { var country = ObjectSpace.CreateObject <Country>(); country.Name = "USA"; var customer = ObjectSpace.CreateObject <Customer>(); customer.Name = "DevExpress"; customer.Country = country; customer = ObjectSpace.CreateObject <Customer>(); customer.Name = "Ray"; customer.Country = country; country = ObjectSpace.CreateObject <Country>(); country.Name = "Netherlands"; country.EUMember = true; customer = ObjectSpace.CreateObject <Customer>(); customer.Name = "Impactive"; customer.Country = country; customer = ObjectSpace.CreateObject <Customer>(); customer.Name = "Tolis"; customer.Country = country; var securitySystemRole = (SecuritySystemRole)ObjectSpace.GetRole("Admin"); securitySystemRole.IsAdministrative = true; var user = (SecuritySystemUser)ObjectSpace.GetUser("Admin"); user.Roles.Add(securitySystemRole); securitySystemRole = (SecuritySystemRole)ObjectSpace.GetRole("User"); securitySystemRole.SetTypePermissions(typeof(Customer), SecurityOperations.FullAccess, SecuritySystemModifier.Allow); securitySystemRole.SetTypePermissions(typeof(Country), SecurityOperations.FullAccess, SecuritySystemModifier.Allow); user = ObjectSpace.CreateObject <SecuritySystemUser>(); user.Roles.Add(securitySystemRole); ObjectSpace.CommitChanges(); } }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); if (ObjectSpace.FindObject <XpandPermissionPolicyRole>(null) == null) { var securitySystemRole = (XpandPermissionPolicyRole)ObjectSpace.GetRole("Admin"); securitySystemRole.IsAdministrative = true; var user = (XpandPermissionPolicyUser)ObjectSpace.GetUser("Admin"); user.Roles.Add(securitySystemRole); securitySystemRole = (XpandPermissionPolicyRole)ObjectSpace.GetRole("User"); var types = new[] { typeof(ActionsObject), typeof(ControllersObject) }; foreach (var type in types) { securitySystemRole.SetTypePermission(type, SecurityOperations.FullAccess, SecurityPermissionState.Allow); } user = ObjectSpace.CreateObject <XpandPermissionPolicyUser>(); user.Roles.Add(securitySystemRole); user = (XpandPermissionPolicyUser)ObjectSpace.GetUser("User"); user.Roles.Add(securitySystemRole); ObjectSpace.CommitChanges(); } }
void InitAdminSecurityData() { var securitySystemRole = ObjectSpace.GetAdminRole("Administrator"); ObjectSpace.GetUser("Admin", roles: (ISecurityRole)securitySystemRole); }