예제 #1
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();

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

            if (adminRole == null)
            {
                adminRole                  = ObjectSpace.CreateObject <SecuritySystemRole>();
                adminRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminRole.IsAdministrative = true;
            }

            SecuritySystemUser user =
                ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "Administrator"));

            if (user == null)
            {
                user          = ObjectSpace.CreateObject <SecuritySystemUser>();
                user.UserName = "******";
                user.SetPassword("");
                user.Roles.Add(adminRole);
            }
        }
예제 #2
0
 public static SecuritySystemUser GetCurrentUser(Session session)
 {
     if (SecuritySystem.CurrentUser != null)
     {
         SecuritySystemUser currentUser = session.GetObjectByKey <SecuritySystemUser>(
             session.GetKeyValue(SecuritySystem.CurrentUser));
         return(currentUser);
     }
     return(null);
 }
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            if (ObjectSpace.GetObjects <Issue>().Count == 0)
            {
                Issue issue1 = ObjectSpace.CreateObject <Issue>();
                issue1.Subject = "Processed issue";
                issue1.Active  = false;
                Issue issue2 = ObjectSpace.CreateObject <Issue>();
                issue2.Subject = "Active issue";
                issue2.Active  = true;
            }

            if (ObjectSpace.GetObjects <XpoWorkflowDefinition>().Count == 0)
            {
                XpoWorkflowDefinition definition = ObjectSpace.CreateObject <XpoWorkflowDefinition>();
                definition.Name             = "Create Task for active Issue";
                definition.Xaml             = GetXaml("WorkflowExample.Module.DatabaseUpdate.CreateTaskForActiveIssue.xml");
                definition.TargetObjectType = typeof(Issue);
                definition.AutoStartWhenObjectFitsCriteria = true;
                definition.Criteria = "[Active] = True";
                definition.IsActive = true;
            }
            SecuritySystemRole adminRole = ObjectSpace.FindObject <SecuritySystemRole>(
                new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName));

            if (adminRole == null)
            {
                adminRole                  = ObjectSpace.CreateObject <SecuritySystemRole>();
                adminRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminRole.IsAdministrative = true;
                adminRole.Save();
            }
            SecuritySystemUser adminUser = ObjectSpace.FindObject <SecuritySystemUser>(
                new BinaryOperator("UserName", "Administrator"));

            if (adminUser == null)
            {
                adminUser          = ObjectSpace.CreateObject <SecuritySystemUser>();
                adminUser.UserName = "******";
                adminUser.SetPassword("");
                adminUser.Roles.Add(adminRole);
            }
            SecuritySystemUser workflowServiceUser = ObjectSpace.FindObject <SecuritySystemUser>(
                new BinaryOperator("UserName", "WorkflowService"));

            if (workflowServiceUser == null)
            {
                workflowServiceUser          = ObjectSpace.CreateObject <SecuritySystemUser>();
                workflowServiceUser.UserName = "******";
                workflowServiceUser.SetPassword("");
                workflowServiceUser.Roles.Add(adminRole);
            }
            ObjectSpace.CommitChanges();
        }
예제 #4
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            SecuritySystemUser userAdmin = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "Admin"));

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <SecuritySystemUser>();
                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
            SecuritySystemRole adminRole = ObjectSpace.FindObject <SecuritySystemRole>(new BinaryOperator("Name", "Administrators"));

            if (adminRole == null)
            {
                adminRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                adminRole.Name = "Administrators";
            }
            adminRole.IsAdministrative = true;
            userAdmin.Roles.Add(adminRole);

            if (ObjectSpace.Database.Contains("DB1"))
            {
                SecuritySystemUser sampleUser1 = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "User1"));
                if (sampleUser1 == null)
                {
                    sampleUser1          = ObjectSpace.CreateObject <SecuritySystemUser>();
                    sampleUser1.UserName = "******";
                    sampleUser1.SetPassword("");
                }
                SecuritySystemRole defaultRole = CreateDefaultRole();
                sampleUser1.Roles.Add(defaultRole);
            }
            if (ObjectSpace.Database.Contains("DB2"))
            {
                SecuritySystemUser sampleUser2 = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "User2"));
                if (sampleUser2 == null)
                {
                    sampleUser2          = ObjectSpace.CreateObject <SecuritySystemUser>();
                    sampleUser2.UserName = "******";
                    sampleUser2.SetPassword("");
                }
                SecuritySystemRole defaultRole = CreateDefaultRole();
                sampleUser2.Roles.Add(defaultRole);
            }
            ObjectSpace.CommitChanges();
        }
예제 #5
0
        public void Run()
        {
            SecuritySystemRole adminRole = ObjectSpace.FindObject <SecuritySystemRole>(
                new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName));

            if (adminRole == null)
            {
                adminRole                  = ObjectSpace.CreateObject <SecuritySystemRole>();
                adminRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminRole.IsAdministrative = true;
                adminRole.Save();
            }
            SecuritySystemUser adminUser = ObjectSpace.FindObject <SecuritySystemUser>(
                new BinaryOperator("UserName", "admin"));

            if (adminUser == null)
            {
                adminUser          = ObjectSpace.CreateObject <SecuritySystemUser>();
                adminUser.UserName = "******";
                adminUser.SetPassword("");
                adminUser.Roles.Add(adminRole);
            }

            string        name      = "Bob";
            DomainObject1 theObject = ObjectSpace.FindObject <DomainObject1>(CriteriaOperator.Parse("Name=?", name));

            if (theObject == null)
            {
                theObject           = ObjectSpace.CreateObject <DomainObject1>();
                theObject.Name      = name;
                theObject.Amount    = 1000;
                theObject.Category1 = "Payments";
                theObject.Category2 = "Other Payments";
                theObject.TranDate  = new DateTime(2014, 5, 6);
            }
            name      = "Alice";
            theObject = ObjectSpace.FindObject <DomainObject1>(CriteriaOperator.Parse("Name=?", name));
            if (theObject == null)
            {
                theObject           = ObjectSpace.CreateObject <DomainObject1>();
                theObject.Name      = name;
                theObject.Amount    = 1000;
                theObject.Category1 = "Receipts";
                theObject.Category2 = "Other Receipts";
                theObject.TranDate  = new DateTime(2014, 5, 5);
            }
        }
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            string  name      = "MyName";
            Contact theObject = ObjectSpace.FindObject <Contact>(CriteriaOperator.Parse("FirstName=?", name));

            if (theObject == null)
            {
                theObject           = ObjectSpace.CreateObject <Contact>();
                theObject.FirstName = name;
            }
            SecuritySystemUser sampleUser = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "User"));

            if (sampleUser == null)
            {
                sampleUser          = ObjectSpace.CreateObject <SecuritySystemUser>();
                sampleUser.UserName = "******";
                sampleUser.SetPassword("");
            }
            SecuritySystemRole defaultRole = CreateDefaultRole();

            sampleUser.Roles.Add(defaultRole);

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

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <SecuritySystemUser>();
                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
            SecuritySystemRole adminRole = ObjectSpace.FindObject <SecuritySystemRole>(new BinaryOperator("Name", "Administrators"));

            if (adminRole == null)
            {
                adminRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                adminRole.Name = "Administrators";
            }
            adminRole.IsAdministrative = true;
            userAdmin.Roles.Add(adminRole);
            ObjectSpace.CommitChanges();
        }
예제 #7
0
파일: Updater.cs 프로젝트: xwagner2/eXpand
        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();
        }
예제 #8
0
 protected override void OnSaving()
 {
     if (!IsDeleted)
     {
         Kullanici currentUser = SecuritySystem.CurrentUser as Kullanici;
         if (this.Session.IsNewObject(this))
         {
             this.fOlusturmaTarihi = DateTime.Now;
             if (SecuritySystem.CurrentUser != null)
             {
                 this.fOlusturanKullanici = currentUser != null?this.Session.GetObjectByKey <SecuritySystemUser>(currentUser.Oid) : null;
             }
         }
         else
         {
             this.fGuncellemeTarihi = DateTime.Now;
             if (SecuritySystem.CurrentUser != null)
             {
                 this.fGüncelleyenKullanici = currentUser != null?this.Session.GetObjectByKey <SecuritySystemUser>(currentUser.Oid) : null;
             }
         }
     }
     base.OnSaving();
 }
예제 #9
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;
            //}
            SecuritySystemUser sampleUser = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "User"));

            if (sampleUser == null)
            {
                sampleUser          = ObjectSpace.CreateObject <SecuritySystemUser>();
                sampleUser.UserName = "******";
                sampleUser.SetPassword("");
            }
            SecuritySystemRole defaultRole = CreateDefaultRole();

            sampleUser.Roles.Add(defaultRole);

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

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <SecuritySystemUser>();
                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
            SecuritySystemRole adminRole = ObjectSpace.FindObject <SecuritySystemRole>(new BinaryOperator("Name", "Administrators"));

            if (adminRole == null)
            {
                adminRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                adminRole.Name = "Administrators";

                // Seed demo data
                ObjectSpace.CreateObject <BusinessUnit>().Name = "RRHH";
                ObjectSpace.CreateObject <BusinessUnit>().Name = "IT";
                ObjectSpace.CreateObject <BusinessUnit>().Name = "COMERCIAL";

                ObjectSpace.CreateObject <Period>().Name = "2020";
                ObjectSpace.CreateObject <Period>().Name = "2018";

                ObjectSpace.CreateObject <ServiceType>().Name = "Pago de planilla";
                ObjectSpace.CreateObject <ServiceType>().Name = "Envio de SMS";

                ObjectSpace.CreateObject <ServiceLocation>().Name = "Central";
                ObjectSpace.CreateObject <ServiceLocation>().Name = "Local";

                Department sczDepartment = ObjectSpace.CreateObject <Department>();
                sczDepartment.Name = "Santa Cruz";

                ObjectSpace.CreateObject <Department>().Name = "La Paz";

                UserService sczUserService = ObjectSpace.CreateObject <UserService>();
                sczUserService.Department = sczDepartment;
                sczUserService.Agency     = "Norte";
                sczUserService.Count      = ">10000";

                ObjectSpace.CreateObject <AppService>().Name = "Cosim ERP";
            }

            adminRole.IsAdministrative = true;
            userAdmin.Roles.Add(adminRole);

            ObjectSpace.CommitChanges(); //This line persists created object(s).
        }
예제 #10
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            // Administrative role
            SecuritySystemRole adminRole = ObjectSpace.FindObject <SecuritySystemRole>(
                new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName));

            if (adminRole == null)
            {
                adminRole                  = ObjectSpace.CreateObject <SecuritySystemRole>();
                adminRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminRole.IsAdministrative = true;
            }
            // Administrator user
            SecuritySystemUser adminUser = ObjectSpace.FindObject <SecuritySystemUser>(
                new BinaryOperator("UserName", "Administrator"));

            if (adminUser == null)
            {
                adminUser          = ObjectSpace.CreateObject <SecuritySystemUser>();
                adminUser.UserName = "******";
                adminUser.SetPassword("");
                adminUser.Roles.Add(adminRole);
            }
            // A role whith type-level permissions
            SecuritySystemRole contactsManagerRole =
                ObjectSpace.FindObject <SecuritySystemRole>(
                    new BinaryOperator("Name", "Contacts Manager"));

            if (contactsManagerRole == null)
            {
                contactsManagerRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                contactsManagerRole.Name = "Contacts Manager";
                SecuritySystemTypePermissionObject contactTypePermission =
                    ObjectSpace.CreateObject <SecuritySystemTypePermissionObject>();
                contactTypePermission.TargetType    = typeof(Contact);
                contactTypePermission.AllowCreate   = true;
                contactTypePermission.AllowDelete   = true;
                contactTypePermission.AllowNavigate = true;
                contactTypePermission.AllowRead     = true;
                contactTypePermission.AllowWrite    = true;
                contactsManagerRole.TypePermissions.Add(contactTypePermission);
            }
            SecuritySystemUser userSam =
                ObjectSpace.FindObject <SecuritySystemUser>(
                    new BinaryOperator("UserName", "Sam"));

            if (userSam == null)
            {
                userSam          = ObjectSpace.CreateObject <SecuritySystemUser>();
                userSam.UserName = "******";
                userSam.SetPassword("");
                userSam.Roles.Add(contactsManagerRole);
            }
            // A role with object-level permissions
            SecuritySystemRole basicUserRole =
                ObjectSpace.FindObject <SecuritySystemRole>(
                    new BinaryOperator("Name", "Basic User"));

            if (basicUserRole == null)
            {
                basicUserRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                basicUserRole.Name = "Basic User";
                SecuritySystemTypePermissionObject userTypePermission =
                    ObjectSpace.CreateObject <SecuritySystemTypePermissionObject>();
                userTypePermission.TargetType = typeof(SecuritySystemUser);
                SecuritySystemObjectPermissionsObject currentUserObjectPermission =
                    ObjectSpace.CreateObject <SecuritySystemObjectPermissionsObject>();
                currentUserObjectPermission.Criteria      = "[Oid] = CurrentUserId()";
                currentUserObjectPermission.AllowNavigate = true;
                currentUserObjectPermission.AllowRead     = true;
                userTypePermission.ObjectPermissions.Add(currentUserObjectPermission);
                basicUserRole.TypePermissions.Add(userTypePermission);
            }
            SecuritySystemUser userJohn =
                ObjectSpace.FindObject <SecuritySystemUser>(
                    new BinaryOperator("UserName", "John"));

            if (userJohn == null)
            {
                userJohn          = ObjectSpace.CreateObject <SecuritySystemUser>();
                userJohn.UserName = "******";
                userJohn.SetPassword("");
                userJohn.Roles.Add(basicUserRole);
            }
            // A role with member-level permissions
            SecuritySystemRole contactViewerRole =
                ObjectSpace.FindObject <SecuritySystemRole>(
                    new BinaryOperator("Name", "Contact Viewer"));

            if (contactViewerRole == null)
            {
                contactViewerRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                contactViewerRole.Name = "Contact Viewer";
                SecuritySystemTypePermissionObject contactLimitedTypePermission =
                    ObjectSpace.CreateObject <SecuritySystemTypePermissionObject>();
                contactLimitedTypePermission.TargetType    = typeof(Contact);
                contactLimitedTypePermission.AllowNavigate = true;
                SecuritySystemMemberPermissionsObject contactMemberPermission =
                    ObjectSpace.CreateObject <SecuritySystemMemberPermissionsObject>();
                contactMemberPermission.Members   = "Name";
                contactMemberPermission.AllowRead = true;
                contactLimitedTypePermission.MemberPermissions.Add(contactMemberPermission);
                contactViewerRole.TypePermissions.Add(contactLimitedTypePermission);
            }
            SecuritySystemUser userBill =
                ObjectSpace.FindObject <SecuritySystemUser>(
                    new BinaryOperator("UserName", "Bill"));

            if (userBill == null)
            {
                userBill          = ObjectSpace.CreateObject <SecuritySystemUser>();
                userBill.UserName = "******";
                userBill.SetPassword("");
                userBill.Roles.Add(contactViewerRole);
            }
            // Contact objects are created for demo purposes
            Contact contactMary = ObjectSpace.FindObject <Contact>(
                new BinaryOperator("Name", "Mary Tellitson"));

            if (contactMary == null)
            {
                contactMary       = ObjectSpace.CreateObject <Contact>();
                contactMary.Name  = "Mary Tellitson";
                contactMary.Email = "*****@*****.**";
            }
            Contact contactJohn = ObjectSpace.FindObject <Contact>(
                new BinaryOperator("Name", "John Nilsen"));

            if (contactJohn == null)
            {
                contactJohn       = ObjectSpace.CreateObject <Contact>();
                contactJohn.Name  = "John Nilsen";
                contactJohn.Email = "*****@*****.**";
            }
            ObjectSpace.CommitChanges();
        }
예제 #11
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            UpdateAnalysisCriteriaColumn();

            SecuritySystemRole defaultRole = CreateDefaultRole();

            Position developerPosition = ObjectSpace.FindObject <Position>(CriteriaOperator.Parse("Title == 'Developer'"));

            if (developerPosition == null)
            {
                developerPosition       = ObjectSpace.CreateObject <Position>();
                developerPosition.Title = "Developer";
            }
            Position managerPosition = ObjectSpace.FindObject <Position>(CriteriaOperator.Parse("Title == 'Manager'"));

            if (managerPosition == null)
            {
                managerPosition       = ObjectSpace.CreateObject <Position>();
                managerPosition.Title = "Manager";
            }

            Department devDepartment = ObjectSpace.FindObject <Department>(CriteriaOperator.Parse("Title == 'Development Department'"));

            if (devDepartment == null)
            {
                devDepartment        = ObjectSpace.CreateObject <Department>();
                devDepartment.Title  = "Development Department";
                devDepartment.Office = "205";
                devDepartment.Positions.Add(developerPosition);
                devDepartment.Positions.Add(managerPosition);
            }

            Contact contactMary = ObjectSpace.FindObject <Contact>(CriteriaOperator.Parse("FirstName == 'Mary' && LastName == 'Tellitson'"));

            if (contactMary == null)
            {
                contactMary            = ObjectSpace.CreateObject <Contact>();
                contactMary.FirstName  = "Mary";
                contactMary.LastName   = "Tellitson";
                contactMary.Email      = "*****@*****.**";
                contactMary.Birthday   = new DateTime(1980, 11, 27);
                contactMary.Department = devDepartment;
                contactMary.Position   = managerPosition;
            }

            Contact contactJohn = ObjectSpace.FindObject <Contact>(CriteriaOperator.Parse("FirstName == 'John' && LastName == 'Nilsen'"));

            if (contactJohn == null)
            {
                contactJohn            = ObjectSpace.CreateObject <Contact>();
                contactJohn.FirstName  = "John";
                contactJohn.LastName   = "Nilsen";
                contactJohn.Email      = "*****@*****.**";
                contactJohn.Birthday   = new DateTime(1981, 10, 3);
                contactJohn.Department = devDepartment;
                contactJohn.Position   = developerPosition;
            }

            if (ObjectSpace.FindObject <DemoTask>(CriteriaOperator.Parse("Subject == 'Review reports'")) == null)
            {
                DemoTask task = ObjectSpace.CreateObject <DemoTask>();
                task.Subject       = "Review reports";
                task.AssignedTo    = contactJohn;
                task.StartDate     = DateTime.Parse("May 03, 2008");
                task.DueDate       = DateTime.Parse("September 06, 2008");
                task.Status        = DevExpress.Persistent.Base.General.TaskStatus.InProgress;
                task.Priority      = Priority.High;
                task.EstimatedWork = 60;
                task.Description   = "Analyse the reports and assign new tasks to employees.";
            }

            if (ObjectSpace.FindObject <DemoTask>(CriteriaOperator.Parse("Subject == 'Fix breakfast'")) == null)
            {
                DemoTask task = ObjectSpace.CreateObject <DemoTask>();
                task.Subject       = "Fix breakfast";
                task.AssignedTo    = contactMary;
                task.StartDate     = DateTime.Parse("May 03, 2008");
                task.DueDate       = DateTime.Parse("May 04, 2008");
                task.Status        = DevExpress.Persistent.Base.General.TaskStatus.Completed;
                task.Priority      = Priority.Low;
                task.EstimatedWork = 1;
                task.ActualWork    = 3;
                task.Description   = "The Development Department - by 9 a.m.\r\nThe R&QA Department - by 10 a.m.";
            }
            if (ObjectSpace.FindObject <DemoTask>(CriteriaOperator.Parse("Subject == 'Task1'")) == null)
            {
                DemoTask task = ObjectSpace.CreateObject <DemoTask>();
                task.Subject       = "Task1";
                task.AssignedTo    = contactJohn;
                task.StartDate     = DateTime.Parse("June 03, 2008");
                task.DueDate       = DateTime.Parse("June 06, 2008");
                task.Status        = DevExpress.Persistent.Base.General.TaskStatus.Completed;
                task.Priority      = Priority.High;
                task.EstimatedWork = 10;
                task.ActualWork    = 15;
                task.Description   = "A task designed specially to demonstrate the PivotChart module. Switch to the Reports navigation group to view the generated analysis.";
            }
            if (ObjectSpace.FindObject <DemoTask>(CriteriaOperator.Parse("Subject == 'Task2'")) == null)
            {
                DemoTask task = ObjectSpace.CreateObject <DemoTask>();
                task.Subject       = "Task2";
                task.AssignedTo    = contactJohn;
                task.StartDate     = DateTime.Parse("July 03, 2008");
                task.DueDate       = DateTime.Parse("July 06, 2008");
                task.Status        = DevExpress.Persistent.Base.General.TaskStatus.Completed;
                task.Priority      = Priority.Low;
                task.EstimatedWork = 8;
                task.ActualWork    = 16;
                task.Description   = "A task designed specially to demonstrate the PivotChart module. Switch to the Reports navigation group to view the generated analysis.";
            }
            UpdateStatus("CreateAnalysis", "", "Creating analysis reports in the database...");
            CreateDataToBeAnalysed();
            UpdateStatus("CreateSecurityData", "", "Creating users and roles in the database...");
            #region Create a User for the Simple Security Strategy
            //// If a simple user named 'Sam' doesn't exist in the database, create this simple user
            //SecuritySimpleUser adminUser = ObjectSpace.FindObject<SecuritySimpleUser>(new BinaryOperator("UserName", "Sam"));
            //if(adminUser == null) {
            //    adminUser = ObjectSpace.CreateObject<SecuritySimpleUser>();
            //    adminUser.UserName = "******";
            //}
            //// Make the user an administrator
            //adminUser.IsAdministrator = true;
            //// Set a password if the standard authentication type is used
            //adminUser.SetPassword("");
            #endregion

            #region Create Users for the Complex Security Strategy
            // If a user named 'Sam' doesn't exist in the database, create this user
            SecuritySystemUser user1 = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "Sam"));
            if (user1 == null)
            {
                user1          = ObjectSpace.CreateObject <SecuritySystemUser>();
                user1.UserName = "******";
                // Set a password if the standard authentication type is used
                user1.SetPassword("");
            }
            // If a user named 'John' doesn't exist in the database, create this user
            SecuritySystemUser user2 = ObjectSpace.FindObject <SecuritySystemUser>(new BinaryOperator("UserName", "John"));
            if (user2 == null)
            {
                user2          = ObjectSpace.CreateObject <SecuritySystemUser>();
                user2.UserName = "******";
                // Set a password if the standard authentication type is used
                user2.SetPassword("");
            }
            // If a role with the Administrators name doesn't exist in the database, create this role
            SecuritySystemRole adminRole = ObjectSpace.FindObject <SecuritySystemRole>(new BinaryOperator("Name", "Administrators"));
            if (adminRole == null)
            {
                adminRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                adminRole.Name = "Administrators";
            }
            adminRole.IsAdministrative = true;

            // If a role with the Users name doesn't exist in the database, create this role
            SecuritySystemRole userRole = ObjectSpace.FindObject <SecuritySystemRole>(new BinaryOperator("Name", "Users"));
            if (userRole == null)
            {
                userRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                userRole.Name = "Users";
            }

            userRole.SetTypePermissionsRecursively <object>(SecurityOperations.FullAccess, SecuritySystemModifier.Allow);
            userRole.SetTypePermissionsRecursively <SecuritySystemUser>(SecurityOperations.FullAccess, SecuritySystemModifier.Deny);
            userRole.SetTypePermissionsRecursively <SecuritySystemRole>(SecurityOperations.FullAccess, SecuritySystemModifier.Deny);

            // Add the Administrators role to the user1
            user1.Roles.Add(adminRole);
            // Add the Users role to the user2
            user2.Roles.Add(userRole);
            user2.Roles.Add(defaultRole);
            #endregion

            ObjectSpace.CommitChanges();
        }
예제 #12
0
파일: Updater.cs 프로젝트: icpac/cap
        private void Usuarios()
        {
            SecuritySystemRole rolServs = ObjectSpace.FindObject <SecuritySystemRole>(new BinaryOperator("Name", "Servicios"));

            if (rolServs == null)
            {
                rolServs      = ObjectSpace.CreateObject <SecuritySystemRole>();
                rolServs.Name = "Servicios";
            }

            if (rolServs.FindTypePermissionObject <Cliente>() == null)
            {
                List <Type> tipos = new List <Type>();

                tipos.Clear();
                tipos.Add(typeof(Cliente));
                PermisosTipos(tipos, rolServs, true, true, true, true, true);
            }

            /*
             * SecuritySystemRole rolAlma = ObjectSpace.FindObject<SecuritySystemRole>(new BinaryOperator("Name", "Almacen"));
             *
             * if (rolAlma == null)
             * {
             *  List<Type> tipos = new List<Type>();
             *
             *
             *  rolAlma = ObjectSpace.CreateObject<SecuritySystemRole>();
             *  rolAlma.Name = "Almacen";
             *
             *  / *
             *  SecuritySystemTypePermissionObject userTypePermission =
             * ObjectSpace.CreateObject<SecuritySystemTypePermissionObject>();
             *  userTypePermission.TargetType = typeof(SecuritySystemUser);
             *
             *  SecuritySystemObjectPermissionsObject currentUserObjectPermission =
             * ObjectSpace.CreateObject<SecuritySystemObjectPermissionsObject>();
             *  currentUserObjectPermission.Criteria = "[Oid] = CurrentUserId()";
             *  currentUserObjectPermission.AllowNavigate = true;
             *  currentUserObjectPermission.AllowRead = true;
             *  userTypePermission.ObjectPermissions.Add(currentUserObjectPermission);* /
             *
             *  tipos.Clear();
             *  tipos.Add(typeof(MovimientoI));
             *  tipos.Add(typeof(Producto));
             *  tipos.Add(typeof(Marca));
             *  tipos.Add(typeof(Linea));
             *  tipos.Add(typeof(Unidad));
             *  tipos.Add(typeof(EsquemaImpuesto));
             *  tipos.Add(typeof(Moneda));
             *  tipos.Add(typeof(ConceptoMI));
             *  PermisosTipos(tipos, rolAlma, true, true, true, true, true);
             *
             *  tipos.Clear();
             *  tipos.Add(typeof(Cliente));
             *  tipos.Add(typeof(Proveedor));
             *  tipos.Add(typeof(Direccion));
             *  PermisosTipos(tipos, rolAlma, false, false, true, true, true);
             *
             *  tipos.Clear();
             *  tipos.Add(typeof(ExportaInvFis));
             *  PermisosTipos(tipos, rolAlma, true, false, true, true, true);
             *
             *  tipos.Clear();
             *  tipos.Add(typeof(MyFileData));
             *  tipos.Add(typeof(FileData));
             *  PermisosTipos(tipos, rolAlma, true, true, false, true, true);
             * }*/


            /*
             * SecuritySystemRole rolContab = ObjectSpace.FindObject<SecuritySystemRole>(new BinaryOperator("Name", "Contabilidad"));
             *
             * if (rolContab == null)
             * {
             *  List<Type> tipos = new List<Type>();
             *
             *
             *  rolContab = ObjectSpace.CreateObject<SecuritySystemRole>();
             *  rolContab.Name = "Contabilidad";
             *
             *  / *
             *  SecuritySystemTypePermissionObject userTypePermission =
             * ObjectSpace.CreateObject<SecuritySystemTypePermissionObject>();
             *  userTypePermission.TargetType = typeof(SecuritySystemUser);
             *
             *  SecuritySystemObjectPermissionsObject currentUserObjectPermission =
             * ObjectSpace.CreateObject<SecuritySystemObjectPermissionsObject>();
             *  currentUserObjectPermission.Criteria = "[Oid] = CurrentUserId()";
             *  currentUserObjectPermission.AllowNavigate = true;
             *  currentUserObjectPermission.AllowRead = true;
             *  userTypePermission.ObjectPermissions.Add(currentUserObjectPermission);* /
             *
             *  tipos.Clear();
             *  tipos.Add(typeof(Producto));
             *  tipos.Add(typeof(Cliente));
             *  tipos.Add(typeof(Documento));
             *  tipos.Add(typeof(DocumentoSalida));
             *
             *  PermisosTipos(tipos, rolContab, false, false, true, true, false);
             * }*/


            /*
             * SecuritySystemRole rolAdmin = ObjectSpace.FindObject<SecuritySystemRole>(new BinaryOperator("Name", "Admin"));
             *
             * if (rolAdmin == null)
             * {
             *  List<Type> tipos = new List<Type>();
             *
             *
             *  rolAdmin = ObjectSpace.CreateObject<SecuritySystemRole>();
             *  rolAdmin.Name = "Admin";
             *
             *  / *
             *  SecuritySystemTypePermissionObject userTypePermission =
             * ObjectSpace.CreateObject<SecuritySystemTypePermissionObject>();
             *  userTypePermission.TargetType = typeof(SecuritySystemUser);
             *
             *  SecuritySystemObjectPermissionsObject currentUserObjectPermission =
             * ObjectSpace.CreateObject<SecuritySystemObjectPermissionsObject>();
             *  currentUserObjectPermission.Criteria = "[Oid] = CurrentUserId()";
             *  currentUserObjectPermission.AllowNavigate = true;
             *  currentUserObjectPermission.AllowRead = true;
             *  userTypePermission.ObjectPermissions.Add(currentUserObjectPermission);* /
             *
             *  tipos.Clear();
             *  tipos.Add(typeof(Direccion));
             *  tipos.Add(typeof(Compania));
             *  tipos.Add(typeof(ItemFormaP));
             *  tipos.Add(typeof(Documento));
             *  PermisosTipos(tipos, rolAdmin, true, true, false, true, true);
             *
             *  tipos.Clear();
             *  tipos.Add(typeof(Clasificacion));
             *  tipos.Add(typeof(Cliente));
             *  tipos.Add(typeof(ConceptoCxc));
             *  tipos.Add(typeof(Cxc));
             *  tipos.Add(typeof(Vendedor));
             *  tipos.Add(typeof(Zona));
             *
             *  tipos.Add(typeof(LCap.Module.BusinessObjects.Empresa.Empresa));
             *  tipos.Add(typeof(Moneda));
             *  tipos.Add(typeof(POFolio));
             *  tipos.Add(typeof(POCertificado));
             *  tipos.Add(typeof(POCorreo));
             *  tipos.Add(typeof(POCompra));
             *  tipos.Add(typeof(Administracion));
             *
             *  tipos.Add(typeof(ConceptoMI));
             *  tipos.Add(typeof(Producto));
             *  tipos.Add(typeof(EsquemaImpuesto));
             *  tipos.Add(typeof(MovimientoI));
             *  tipos.Add(typeof(Linea));
             *  tipos.Add(typeof(Unidad));
             *  tipos.Add(typeof(Marca));
             *  tipos.Add(typeof(ExportaInvFis));
             *
             *  tipos.Add(typeof(Proveedor));
             *  tipos.Add(typeof(Cxp));
             *  tipos.Add(typeof(ConceptoCxp));
             *
             *  tipos.Add(typeof(DocumentoSalida));
             *
             *  tipos.Add(typeof(Analysis));
             *
             *  PermisosTipos(tipos, rolAdmin, true, true, true, true, true);
             * }*/

            SecuritySystemUser userR = ObjectSpace.FindObject <SecuritySystemUser>(
                new BinaryOperator("UserName", "root"));

            if (userR == null)
            {
                userR          = ObjectSpace.CreateObject <SecuritySystemUser>();
                userR.UserName = "******";
                // Set a password if the standard authentication type is used
                userR.SetPassword("");
            }

            /*
             * SecuritySystemUser userS = ObjectSpace.FindObject<SecuritySystemUser>(
             *      new BinaryOperator("UserName", "servicio"));
             *
             * if (userS == null)
             * {
             *  userS = ObjectSpace.CreateObject<SecuritySystemUser>();
             *  userS.UserName = "******";
             *  // userS.SetPassword("servicio");
             * }*/

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

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

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

            // ...
            // Add the "Administrators" Role to the user1
            userR.Roles.Add(RolAdmin());
            // userS.Roles.Add(rolServs);

            /*
             * userA.Roles.Add(rolAlma);
             * userCont.Roles.Add(rolContab);
             * userAdmin.Roles.Add(rolAdmin);*/
        }