Пример #1
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            DashboardsModule.AddDashboardData <DashboardData>(ObjectSpace, "HRM", Resources.HRM);

            EmployeeRole adminEmployeeRole = ObjectSpace.FindObject <EmployeeRole>(new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName));

            if (adminEmployeeRole == null)
            {
                adminEmployeeRole                  = ObjectSpace.CreateObject <EmployeeRole>();
                adminEmployeeRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminEmployeeRole.IsAdministrative = true;
                adminEmployeeRole.Save();
            }
            NguoiDung adminEmployee = ObjectSpace.FindObject <NguoiDung>(new BinaryOperator("UserName", "Admin"));

            if (adminEmployee == null)
            {
                adminEmployee          = ObjectSpace.CreateObject <NguoiDung>();
                adminEmployee.UserName = "******";
                adminEmployee.SetPassword("");
                adminEmployee.EmployeeRoles.Add(adminEmployeeRole);
            }
            adminEmployeeRole.IsAdministrative = true;
            adminEmployee.EmployeeRoles.Add(adminEmployeeRole);
            ObjectSpace.CommitChanges();
        }
Пример #2
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            //string name = "MyName";
            //DomainObject1 theObject = ObjectSpace.FindObject<DomainObject1>(CriteriaOperator.Parse("Name=?", name));
            //if(theObject == null) {
            //    theObject = ObjectSpace.CreateObject<DomainObject1>();
            //    theObject.Name = name;
            //}
            EmployeeRole adminEmployeeRole = ObjectSpace.FindObject <EmployeeRole>(new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName));

            if (adminEmployeeRole == null)
            {
                adminEmployeeRole                  = ObjectSpace.CreateObject <EmployeeRole>();
                adminEmployeeRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminEmployeeRole.IsAdministrative = true;
                adminEmployeeRole.Save();
            }
            NguoiDung adminEmployee = ObjectSpace.FindObject <NguoiDung>(new BinaryOperator("UserName", "Admin"));

            if (adminEmployee == null)
            {
                adminEmployee          = ObjectSpace.CreateObject <NguoiDung>();
                adminEmployee.UserName = "******";
                adminEmployee.SetPassword("");
                adminEmployee.EmployeeRoles.Add(adminEmployeeRole);
            }
            adminEmployeeRole.IsAdministrative = true;
            adminEmployee.EmployeeRoles.Add(adminEmployeeRole);
            ObjectSpace.CommitChanges();
        }
Пример #3
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            //string name = "MyName";
            //DomainObject1 theObject = ObjectSpace.FindObject<DomainObject1>(CriteriaOperator.Parse("Name=?", name));
            //if(theObject == null) {
            //    theObject = ObjectSpace.CreateObject<DomainObject1>();
            //    theObject.Name = name;
            //}
            //PermissionPolicyUser sampleUser = ObjectSpace.FindObject<PermissionPolicyUser>(new BinaryOperator("UserName", "User"));
            //if(sampleUser == null) {
            //    sampleUser = ObjectSpace.CreateObject<PermissionPolicyUser>();
            //    sampleUser.UserName = "******";
            //    sampleUser.SetPassword("");
            //}
            //PermissionPolicyRole defaultRole = CreateDefaultRole();
            //sampleUser.Roles.Add(defaultRole);

            //PermissionPolicyUser userAdmin = ObjectSpace.FindObject<PermissionPolicyUser>(new BinaryOperator("UserName", "Admin"));
            //if(userAdmin == null) {
            //    userAdmin = ObjectSpace.CreateObject<PermissionPolicyUser>();
            //    userAdmin.UserName = "******";
            //    // Set a password if the standard authentication type is used
            //    userAdmin.SetPassword("");
            //}

            // If a role with the Administrators name doesn't exist in the database, create this role
            //         PermissionPolicyRole adminRole = ObjectSpace.FindObject<PermissionPolicyRole>(new BinaryOperator("Name", "Administrators"));
            //         if(adminRole == null) {
            //             adminRole = ObjectSpace.CreateObject<PermissionPolicyRole>();
            //             adminRole.Name = "Administrators";
            //         }
            //         adminRole.IsAdministrative = true;
            //userAdmin.Roles.Add(adminRole);
            //         ObjectSpace.CommitChanges(); //This line persists created object(s).
            //     }
            EmployeeRole adminEmployeeRole = ObjectSpace.FindObject <EmployeeRole>(new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName));

            if (adminEmployeeRole == null)
            {
                adminEmployeeRole                  = ObjectSpace.CreateObject <EmployeeRole>();
                adminEmployeeRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminEmployeeRole.IsAdministrative = true;
                adminEmployeeRole.Save();
            }
            NguoiDung adminEmployee = ObjectSpace.FindObject <NguoiDung>(new BinaryOperator("UserName", "Admin"));

            if (adminEmployee == null)
            {
                adminEmployee          = ObjectSpace.CreateObject <NguoiDung>();
                adminEmployee.UserName = "******";
                adminEmployee.SetPassword("");
                adminEmployee.EmployeeRoles.Add(adminEmployeeRole);
            }
            adminEmployeeRole.IsAdministrative = true;
            adminEmployee.EmployeeRoles.Add(adminEmployeeRole);
            ObjectSpace.CommitChanges();
        }