コード例 #1
0
ファイル: Updater.cs プロジェクト: xblazor/eXpand
        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();
        }
コード例 #2
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (PermissionPolicyRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");

            var userRole = (PermissionPolicyRole)ObjectSpace.GetRole("User");

            userRole.CanEditModel = true;
            userRole.AddTypePermissionsRecursively <object>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);

            var user = (PermissionPolicyUser)userRole.GetUser("User");

            user.Roles.Add(defaultRole);

            if (ObjectSpace.IsNewObject(userRole))
            {
                var permissionData = ObjectSpace.CreateObject <AuditTrailOperationPermissionPolicyPolicyData>();
                permissionData.ObjectTypeData           = typeof(Employee);
                permissionData.ID                       = "audit_emplyee";
                permissionData.AuditTrailMembersContext = "Employee_Members";
                ((XpandPermissionPolicyRole)userRole).Permissions.Add(permissionData);
            }
            ObjectSpace.CommitChanges();
        }
コード例 #3
0
ファイル: Updater.cs プロジェクト: xwagner2/eXpand
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            ParseXpandModules();
            CreateSecurityObjects();
            CreateRegistrationEmailTemplates(ObjectSpace);

            if (VersionUpdateNeeded("13.2.9.28"))
            {
                var userRole = (XpandRole)ObjectSpace.GetRole("User");
                userRole.SetTypePermissions <XpandAuditDataItemPersistent>(SecurityOperations.ReadOnlyAccess, SecuritySystemModifier.Allow);
                ApproveAuditsActionPermission(userRole);
                userRole.SetTypePermissions <Document>(SecurityOperations.Create, SecuritySystemModifier.Allow);
                userRole.AddMemberAccessPermission <Document>("Name,Url,Author", SecurityOperations.ReadWriteAccess, "Creator Is Null");
            }
            if (VersionUpdateNeeded("13.2.9.32"))
            {
                var userRole = (XpandRole)ObjectSpace.GetRole("User");
                userRole.AddMemberAccessPermission <BusinessObjects.Module>("Installation", SecurityOperations.Write);
                var typeInfos = XafTypesInfo.Instance.PersistentTypes.Where(info => typeof(ModuleArtifact).IsAssignableFrom(info.Type));
                foreach (var typeInfo in typeInfos)
                {
                    userRole.AddMemberAccessPermission(typeInfo.Type, "Text,Author,Url", SecurityOperations.Write);
                }
            }
        }
コード例 #4
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (PermissionPolicyRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");

            var userRole = (PermissionPolicyRole)ObjectSpace.GetRole("User");
            var user     = (PermissionPolicyUser)userRole.GetUser("User");

            user.Roles.Add(defaultRole);
            user = (PermissionPolicyUser)userRole.GetUser("user2");
            user.Roles.Add(defaultRole);
            userRole.AddTypePermission <RoleModelObject>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);
            userRole.AddTypePermission <UserModelObject>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);
            userRole.AddTypePermission <ApplicationModelObject>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);


            var modelRole = (PermissionPolicyRole)ObjectSpace.GetDefaultModelRole("ModelRole");

            user.Roles.Add(modelRole);

            ObjectSpace.CommitChanges();
        }
コード例 #5
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (XpandPermissionPolicyRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");


            var userRole = (XpandPermissionPolicyRole)ObjectSpace.GetRole("User");
            var user     = (XpandPermissionPolicyUser)userRole.GetUser("User");

            user.Roles.Add(defaultRole);
            userRole.SetTypePermission <XpoStateMachine>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);
            userRole.SetTypePermission <XpoState>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);
            userRole.SetTypePermission <XpoTransition>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);
            userRole.SetTypePermission <PaymentTask>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);
            userRole.SetTypePermission <Status>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);

            CreateStatuses();
            ObjectSpace.CommitChanges();
            CreateStateMachines();
            ObjectSpace.CommitChanges();
        }
コード例 #6
0
ファイル: Updater.cs プロジェクト: xwagner2/eXpand
        private void CreateSecurityObjects()
        {
            var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

            if (ObjectSpace.IsNewObject(defaultRole))
            {
                var adminRole = ObjectSpace.GetAdminRole("Admin");
                var adminUser = (XpandUser)adminRole.GetUser("Admin", ConfigurationManager.AppSettings["AdminDefaultPass"]);
                adminUser.Email = "*****@*****.**";

                var anonymousRole = ObjectSpace.GetAnonymousRole("Anonymous");
                anonymousRole.GetAnonymousUser();

                var userRole  = (XpandRole)ObjectSpace.GetRole("User");
                var typeInfos = XafTypesInfo.Instance.PersistentTypes.Where(info => typeof(DocsBaseObject).IsAssignableFrom(info.Type));
                foreach (var typeInfo in typeInfos)
                {
                    userRole.EnsureTypePermissions(typeInfo.Type, SecurityOperations.ReadOnlyAccess);
                    userRole.Permissions.Add(IOActionPermission());
                    anonymousRole.Permissions.Add(IOActionPermission());
                    anonymousRole.EnsureTypePermissions(typeInfo.Type, SecurityOperations.ReadOnlyAccess);
                    if (typeof(ModuleArtifact).IsAssignableFrom(typeInfo.Type))
                    {
                        userRole.AddMemberAccessPermission(typeInfo.Type, "Text,Author,Url", SecurityOperations.Write, "Creator=CurrentUserId() or Text Is  Null");
                    }
                }
                var user = (SecuritySystemUser)userRole.GetUser("user");
                user.Roles.Add(defaultRole);
            }
        }
コード例 #7
0
ファイル: Updater.cs プロジェクト: xwagner2/eXpand
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");
            var adminUser = adminRole.GetUser("Admin");

            var userRole = ObjectSpace.GetRole("User");

            userRole.CanEditModel = true;
            userRole.SetTypePermissionsRecursively <object>(SecurityOperations.FullAccess, SecuritySystemModifier.Allow);

            var user = (SecuritySystemUser)userRole.GetUser("user");

            user.Roles.Add(defaultRole);

            if (ObjectSpace.FindObject <Customer>(null) == null)
            {
                var customer = ObjectSpace.CreateObject <Customer>();
                customer.FirstName = "Apostolis";
                customer.LastName  = "Bekiaris";
                customer.User      = user;
                customer           = ObjectSpace.CreateObject <Customer>();
                customer.FirstName = "FilteredApostolis";
                customer.LastName  = "FilteredBekiaris";
                customer.User      = (SecuritySystemUser)adminUser;
                var dashboardDefinition = ObjectSpace.CreateObject <DashboardDefinition>();
                dashboardDefinition.Name = "Filtered from model";
                dashboardDefinition.Xml  = GetXML();
            }

            ObjectSpace.CommitChanges();
        }
コード例 #8
0
ファイル: Updater.cs プロジェクト: tomimon/eXpand
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            if (ObjectSpace.FindObject <Customer>(null) == null)
            {
                var customer = ObjectSpace.CreateObject <Customer>();
                customer.FirstName = "Apostolis";
                customer.LastName  = "Bekiaris";
                customer.Email     = "apostolis.bekiaris at gmail";
                ObjectSpace.CommitChanges();

                customer           = ObjectSpace.CreateObject <Customer>();
                customer.FirstName = "Tolis";
                customer.LastName  = "Bek";
                customer.Email     = "apostolis.bekiaris at gmail";

                var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

                var adminRole = ObjectSpace.GetAdminRole("Admin");
                adminRole.GetUser("Admin");

                var userRole = ObjectSpace.GetRole("User");
                var user     = (SecuritySystemUser)userRole.GetUser("user");
                user.Roles.Add(defaultRole);
            }
        }
コード例 #9
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();

            if (ObjectSpace.FindObject <XpandPermissionPolicyRole>(null) == null)
            {
                var defaultRole = (XpandPermissionPolicyRole)ObjectSpace.GetDefaultRole();

                var adminRole = ObjectSpace.GetAdminRole("Admin");
                adminRole.GetUser("Admin");

                var userRole = ObjectSpace.GetRole("User");
                var user     = (XpandPermissionPolicyUser)userRole.GetUser("User");
                user.Roles.Add(defaultRole);
                var resourceStream = GetType().Assembly.GetManifestResourceStream(GetType(), "MasterData.xlsx");

                var excelImport     = ObjectSpace.CreateObject <ExcelImport>();
                var excelImportFile = new XpandFileData {
                    Content = resourceStream.ReadFully()
                };
                excelImport.File       = excelImportFile;
                excelImport.Name       = "Import Customers -Genders";
                excelImport.SheetName  = "Active_List";
                excelImport.Type       = typeof(Customer);
                excelImport.HeaderRows = 1;
                excelImport.Map();
            }

            var genderObject = ObjectSpace.CreateObject <GenderObject>();

            genderObject.Gender1 = "Male";
            genderObject         = ObjectSpace.CreateObject <GenderObject>();
            genderObject.Gender1 = "Female";
            ObjectSpace.CommitChanges();
        }
コード例 #10
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (PermissionPolicyRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");
            var adminUser = adminRole.GetUser("Admin");

            var userRole = (IPermissionPolicyRole)ObjectSpace.GetRole("User");

            userRole.CanEditModel = true;

            var user = (PermissionPolicyUser)((ISecurityRole)userRole).GetUser("user");

            user.Roles.Add(defaultRole);

            if (ObjectSpace.FindObject <Customer>(null) == null)
            {
                var customer = ObjectSpace.CreateObject <Customer>();
                customer.FirstName = "Apostolis";
                customer.LastName  = "Bekiaris";
                customer.User      = user;
                customer           = ObjectSpace.CreateObject <Customer>();
                customer.FirstName = "FilteredApostolis";
                customer.LastName  = "FilteredBekiaris";
                customer.User      = (PermissionPolicyUser)adminUser;
                var dashboardDefinition = ObjectSpace.CreateObject <DashboardDefinition>();
                dashboardDefinition.Name = "Filtered from model";
                dashboardDefinition.Xml  = GetXML();
            }

            ObjectSpace.CommitChanges();
        }
コード例 #11
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();


            XpandPermissionPolicyRole userRole = (XpandPermissionPolicyRole)ObjectSpace.GetRole("User");

            userRole.SetTypePermission <OverallCustomizationAllowedObject>(SecurityOperations.FullAccess, SecurityPermissionState.Allow);
        }
コード例 #12
0
ファイル: Updater.cs プロジェクト: xwagner2/eXpand
        private void CreateSecurityObjects()
        {
            var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");

            var userRole = ObjectSpace.GetRole("User");
            var user     = (SecuritySystemUser)userRole.GetUser("user");

            user.Roles.Add(defaultRole);
        }
コード例 #13
0
        private void CreateSecurityObjects()
        {
            var defaultRole = (XpandPermissionPolicyRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");

            var userRole = ObjectSpace.GetRole("User");
            var user     = (XpandPermissionPolicyUser)userRole.GetUser("User");

            user.Roles.Add(defaultRole);
        }
コード例 #14
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");

            var userRole = ObjectSpace.GetRole("User");
            var user     = (SecuritySystemUser)userRole.GetUser("user");

            user.Roles.Add(defaultRole);
        }
コード例 #15
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (XpandPermissionPolicyRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");

            var userRole = ObjectSpace.GetRole("User");
            var user     = (XpandPermissionPolicyUser)userRole.GetUser("User");

            user.Roles.Add(defaultRole);
            user.Email = "*****@*****.**";
        }
コード例 #16
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            if (ObjectSpace.FindObject <XpandPermissionPolicyRole>(null) == null)
            {
                var defaultRole = (XpandPermissionPolicyRole)ObjectSpace.GetDefaultRole();

                var adminRole = ObjectSpace.GetAdminRole("Admin");
                adminRole.GetUser("Admin");

                var userRole = ObjectSpace.GetRole("User");
                var user     = (XpandPermissionPolicyUser)userRole.GetUser("User");
                user.Roles.Add(defaultRole);
            }
        }
コード例 #17
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (PermissionPolicyRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");

            var userRole = ObjectSpace.GetRole("User");
            var user     = (PermissionPolicyUser)userRole.GetUser("user");

            user.Roles.Add(defaultRole);

            ObjectSpace.CommitChanges();
        }
コード例 #18
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");


            var userRole = (XpandRole)ObjectSpace.GetRole("User");

            if (ObjectSpace.IsNewObject(userRole))
            {
                var permissionData = ObjectSpace.CreateObject <StateMachineTransitionOperationPermissionData>();
                permissionData.StateCaption     = "InProgress";
                permissionData.StateMachineName = "Test";
                permissionData.Modifier         = StateMachineTransitionModifier.Deny;
                userRole.Permissions.Add(permissionData);
            }

            userRole.SetTypePermissions <TestTask>(SecurityOperations.FullAccess, SecuritySystemModifier.Allow);
            userRole.SetTypePermissions <XpoStateMachine>(SecurityOperations.FullAccess, SecuritySystemModifier.Allow);
            userRole.SetTypePermissions <XpoState>(SecurityOperations.FullAccess, SecuritySystemModifier.Allow);
            userRole.SetTypePermissions <XpoTransition>(SecurityOperations.FullAccess, SecuritySystemModifier.Allow);
            var user = (SecuritySystemUser)userRole.GetUser("user");

            user.Roles.Add(defaultRole);

            var stateMachine = ObjectSpace.FindObject <XpoStateMachine>(CriteriaOperator.Parse("Name=?", "Test")) ??
                               ObjectSpace.CreateObject <XpoStateMachine>();

            stateMachine.Active            = true;
            stateMachine.Name              = "Test";
            stateMachine.TargetObjectType  = typeof(TestTask);
            stateMachine.StatePropertyName = new StringObject("Status");
            stateMachine.StartState        = GetXpoState(TaskStatus.NotStarted, stateMachine);
            foreach (var taskStatus in Enum.GetValues(typeof(TaskStatus)).Cast <TaskStatus>())
            {
                GetXpoState(taskStatus, stateMachine);
            }
            CreateTransition(TaskStatus.NotStarted, TaskStatus.InProgress);
            CreateTransition(TaskStatus.InProgress, TaskStatus.Completed);
            ObjectSpace.FindObject <XpoState>(CriteriaOperator.Parse("Caption=?", TaskStatus.Completed.ToString())).TargetObjectCriteria = IsCurrentUserInRoleOperator.OperatorName + "('Admin')";
            ObjectSpace.CommitChanges();
        }
コード例 #19
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (XpandRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");

            adminRole.GetUser("Admin");

            var userRole = ObjectSpace.GetRole("User");
            var user     = (SecuritySystemUser)userRole.GetUser("user");

            user.Roles.Add(defaultRole);

            var modelRole = ObjectSpace.GetDefaultModelRole("ModelRole");

            user.Roles.Add((XpandRole)modelRole);

            ObjectSpace.CommitChanges();
        }
コード例 #20
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (PermissionPolicyRole)ObjectSpace.GetDefaultRole();

            if (ObjectSpace.IsNewObject(defaultRole))
            {
                var emailTemplate = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Configure(EmailTemplateConfig.UserActivation, "http://*****:*****@Model.FullName";

                emailTemplate         = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Subject = "Project created";
                emailTemplate.Body    = "We created a new project (@Model.Name).";

                emailTemplate         = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Subject = "TaskStatusChanged";
                emailTemplate.Body    = "The Status of (@Model.Subject) changed to (@Model.Status)";

                emailTemplate         = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Subject = "email from action";
                emailTemplate.Body    = "Email send for the task with subject (@Model.Subject)";
            }
            var adminRole = ObjectSpace.GetAdminRole("Admin");
            var adminUser = (XpandPermissionPolicyUser)adminRole.GetUser("Admin");

            adminUser.Email = "*****@*****.**";

            var userRole = ObjectSpace.GetRole("User");
            var user     = (PermissionPolicyUser)userRole.GetUser("User");

            user.Roles.Add(defaultRole);

            ObjectSpace.CommitChanges();
        }
コード例 #21
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

            if (ObjectSpace.IsNewObject(defaultRole))
            {
                var emailTemplate = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Subject = "User activation";
                emailTemplate.Body    = string.Format("A new user @Model.User.UserName has been created. To activate the account please click the following link {0}@Model.User.Activation",
                                                      ((IModelRegistration)
                                                       ((IModelOptionsRegistration)CaptionHelper.ApplicationModel.Options).Registration).ActivationHost + "?ua=");

                emailTemplate         = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Subject = "pass forgotten";
                emailTemplate.Body    = "We created a temporary password (@Model.Password) for the UserName (@Model.User.UserName). Please login to reset it";

                emailTemplate         = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Subject = "New Customer";
                emailTemplate.Body    = "A new customer created with fullname @Model.FullName";

                emailTemplate         = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Subject = "Project created";
                emailTemplate.Body    = "We created a new project (@Model.Name).";

                emailTemplate         = ObjectSpace.CreateObject <EmailTemplate>();
                emailTemplate.Subject = "TaskStatusChanged";
                emailTemplate.Body    = "The Status of (@Model.Subject) changed to (@Model.Status)";
            }
            var adminRole = ObjectSpace.GetAdminRole("Admin");
            var adminUser = (User)adminRole.GetUser("Admin");

            adminUser.Email = "*****@*****.**";

            var userRole = ObjectSpace.GetRole("User");
            var user     = (SecuritySystemUser)userRole.GetUser("user");

            user.Roles.Add(defaultRole);

            ObjectSpace.CommitChanges();
        }
コード例 #22
0
        XpandRole InitVideoRentalSecurityData()
        {
            var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

            if (ObjectSpace.IsNewObject(defaultRole))
            {
                var employersRole = (SecuritySystemRole)ObjectSpace.GetRole("Employers");
                var dashboardRole = (SecuritySystemRole)ObjectSpace.GetRole("Dashboard View Role");

                var user          = (SecuritySystemUser)employersRole.GetUser("User");
                var dashboardUser = (SecuritySystemUser)dashboardRole.GetUser("DashboardUser");

                user.Roles.Add(defaultRole);
                dashboardUser.Roles.Add(defaultRole);
                dashboardUser.Roles.Add(dashboardRole);

                employersRole.CreateFullPermissionAttributes();
                return((XpandRole)employersRole);
            }
            return(null);
        }
コード例 #23
0
ファイル: Updater.cs プロジェクト: aois-dev/eXpand
        IPermissionPolicyRole InitVideoRentalSecurityData()
        {
            var defaultRole = (PermissionPolicyRole)ObjectSpace.GetDefaultRole();

            if (ObjectSpace.IsNewObject(defaultRole))
            {
                var employersRole = (IPermissionPolicyRole)ObjectSpace.GetRole("Employers");
                var dashboardRole = (PermissionPolicyRole)ObjectSpace.GetRole("Dashboard View Role");

                var user          = (PermissionPolicyUser)((ISecurityRole)employersRole).GetUser("User");
                var dashboardUser = (PermissionPolicyUser)dashboardRole.GetUser("DashboardUser");

                user.Roles.Add(defaultRole);
                dashboardUser.Roles.Add(defaultRole);
                dashboardUser.Roles.Add(dashboardRole);

                ((ISecurityRole)employersRole).AddNewFullPermissionAttributes();
                return(employersRole);
            }
            return(null);
        }
コード例 #24
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var defaultRole = (SecuritySystemRole)ObjectSpace.GetDefaultRole();

            var adminRole = ObjectSpace.GetAdminRole("Admin");
            var adminUser = adminRole.GetUser("Admin");

            var userRole = ObjectSpace.GetRole("User");

            userRole.CanEditModel = true;
            userRole.SetTypePermissionsRecursively <object>(SecurityOperations.FullAccess, SecuritySystemModifier.Allow);

            var user = (SecuritySystemUser)userRole.GetUser("user");

            user.Roles.Add(defaultRole);

            if (ObjectSpace.FindObject <Customer>(null) == null)
            {
                var customer = ObjectSpace.CreateObject <Customer>();
                customer.FirstName = "Apostolis";
                customer.LastName  = "Bekiaris";
                customer.User      = user;
                customer           = ObjectSpace.CreateObject <Customer>();
                customer.FirstName = "FilteredApostolis";
                customer.LastName  = "FilteredBekiaris";
                customer.User      = (SecuritySystemUser)adminUser;

                using (var stream = GetType().Assembly.GetManifestResourceStream(GetType(), "FilterDashboard.xml")){
                    var dashboardDefinition = ObjectSpace.CreateObject <DashboardDefinition>();
                    dashboardDefinition.Name = "Filtered from model";
                    Debug.Assert(stream != null, "stream != null");
                    dashboardDefinition.Xml = new StreamReader(stream).ReadToEnd();
                }
            }

            ObjectSpace.CommitChanges();
        }
コード例 #25
0
        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();
            }
        }
コード例 #26
0
        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();
            }
        }
コード例 #27
0
ファイル: Updater.cs プロジェクト: aois-dev/eXpand
        private void CreateDashboards(string dashboardName, int index, IEnumerable <Type> types)
        {
            UpdateStatus("CreateDashboard", "", $"Creating dashboard: {dashboardName}");
            var dashboard = ObjectSpace.FindObject <DashboardDefinition>(new BinaryOperator("Name", dashboardName));

            if (dashboard == null)
            {
                dashboard        = ObjectSpace.CreateObject <DashboardDefinition>();
                dashboard.Name   = dashboardName;
                dashboard.Xml    = GetDashboardLayout(dashboardName).XmlPrint();
                dashboard.Index  = index;
                dashboard.Active = true;
                foreach (var type in types)
                {
                    dashboard.DashboardTypes.Add(new TypeWrapper(type));
                }
            }
            var dashboardRole       = ObjectSpace.GetRole("Dashboard View Role");
            var dashboardCollection = (XPBaseCollection)
                                      ((XPBaseObject)dashboardRole).GetMemberValue(typeof(DashboardDefinition).Name + "s");

            ((XPBaseObject)dashboardRole).SetMemberValue("DashboardOperation", SecurityOperationsEnum.ReadOnlyAccess);
            dashboardCollection.BaseAdd(dashboard);
        }