public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); string temp = GeneralValues.hq; Company company = ObjectSpace.FindObject <Company>(CriteriaOperator.Parse("BoCode=?", temp)); if (company == null) { company = ObjectSpace.CreateObject <Company>(); company.BoCode = temp; company.BoName = temp; company.Save(); } temp = DocTypeCodes.SalesQuotation; DocType doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } temp = DocTypeCodes.SalesAgreement; doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } temp = DocTypeCodes.SalesOrder; doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } temp = DocTypeCodes.PurchaseQuotation; doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } temp = DocTypeCodes.PurchaseOrder; doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } temp = DocTypeCodes.PurchaseRequest; doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } temp = DocTypeCodes.PurchaseDelivery; doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } temp = DocTypeCodes.PurchaseReturn; doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } temp = DocTypeCodes.StockTransferRequest; doctype = ObjectSpace.FindObject <DocType>(new BinaryOperator("BoCode", temp)); if (doctype == null) { doctype = ObjectSpace.CreateObject <DocType>(); doctype.BoCode = temp; doctype.BoName = temp; doctype.Save(); } //SystemUsers sampleUser = ObjectSpace.FindObject<SystemUsers>(new BinaryOperator("UserName", "User")); //if(sampleUser == null) { // sampleUser = ObjectSpace.CreateObject<SystemUsers>(); // sampleUser.UserName = "******"; // sampleUser.SetPassword(""); // sampleUser.Company = company; // sampleUser.IsUpdater = true; // sampleUser.Employee.IsUpdater = true; // sampleUser.Employee.FullName = "User"; //} PermissionPolicyRole defaultRole = CreateDefaultRole(); //defaultRole.PermissionPolicy = SecurityPermissionPolicy.ReadOnlyAllByDefault; //sampleUser.Roles.Add(defaultRole); // 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; } SystemUsers userAdmin = ObjectSpace.FindObject <SystemUsers>(new BinaryOperator("UserName", "Admin")); if (userAdmin == null) { userAdmin = ObjectSpace.CreateObject <SystemUsers>(); userAdmin.UserName = "******"; // Set a password if the standard authentication type is used userAdmin.SetPassword(""); userAdmin.Company = company; userAdmin.Employee.FullName = "Admin"; userAdmin.Roles.Add(adminRole); userAdmin.Save(); } userAdmin = ObjectSpace.FindObject <SystemUsers>(new BinaryOperator("UserName", GeneralValues.FTAdmin)); if (userAdmin == null) { userAdmin = ObjectSpace.CreateObject <SystemUsers>(); userAdmin.UserName = GeneralValues.FTAdmin; // Set a password if the standard authentication type is used userAdmin.SetPassword(GeneralValues.FTAdminpwd); userAdmin.Company = company; userAdmin.Employee.FullName = GeneralValues.FTAdmin; userAdmin.Roles.Add(adminRole); userAdmin.Save(); } createportalroles(); ObjectSpace.CommitChanges(); //This line persists created object(s). }