Exemplo n.º 1
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();


            CreateSecurityDemoObjects();

            DevExpress.ExpressApp.Security.Strategy.SecuritySystemRole defaultRole       = CreateDefaultRole();
            DevExpress.ExpressApp.Security.Strategy.SecuritySystemRole administratorRole = CreateAdministratorRole();

            SecuritySystemUser userAdmin = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "Sam"));

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <SecuritySystemUser>();
                userAdmin.UserName = "******";
                userAdmin.IsActive = true;
                userAdmin.SetPassword("");
                userAdmin.Roles.Add(administratorRole);
            }

            DevExpress.ExpressApp.Security.Strategy.SecuritySystemRole securityDemoRole = CreateSecurityDemoRole();

            SecuritySystemUser userJohn = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "John"));

            if (userJohn == null)
            {
                userJohn          = ObjectSpace.CreateObject <SecuritySystemUser>();
                userJohn.UserName = "******";
                userJohn.IsActive = true;
                userJohn.Roles.Add(defaultRole);
                userJohn.Roles.Add(securityDemoRole);
                userJohn.Save();
            }

            ObjectSpace.CommitChanges();
        }