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(); }
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); } }