This commit is contained in:
2018-08-30 23:20:20 +00:00
parent 747b9a3002
commit 687d558b37
6 changed files with 61 additions and 52 deletions

View File

@@ -19,9 +19,13 @@ CODING WORK
+++++++++++ +++++++++++
Overall plan for now: anything standing in the way of making the initial client shell UI needs to be done first, everything else can wait Overall plan for now: anything standing in the way of making the initial client shell UI needs to be done first, everything else can wait
- v7importusers
- Do a First test run of importing from v7 just to ensure it's fundamentally working
- Then continue on to flesh out the User import second pass stuff
- Then test
- Event log make sure can set the date and time to prior values for importing - Event log make sure can set the date and time to prior values for importing
- v7importusers
- User route and controller and biz object - User route and controller and biz object
- Check biz rules in v7 for anything that might be missed in RAVEN biz rules - Check biz rules in v7 for anything that might be missed in RAVEN biz rules
- v7import once have users imported then proper attribution in eventlog of creator,modifier, created,modified - v7import once have users imported then proper attribution in eventlog of creator,modifier, created,modified

View File

@@ -401,7 +401,7 @@ namespace AyaNova
if (TESTING_REFRESH_DB) if (TESTING_REFRESH_DB)
{ {
AyaNova.Core.License.Fetch(apiServerState, dbContext, _log); AyaNova.Core.License.Fetch(apiServerState, dbContext, _log);
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.LargeCorporateMultiRegionalTrialDataSet); Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet);
} }
//TESTING //TESTING
#endif #endif

View File

@@ -35,6 +35,7 @@ namespace AyaNova.Biz
u.Roles = AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull; u.Roles = AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull;
u.OwnerId = 1; u.OwnerId = 1;
u.LocaleId=ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;//Ensure primeLocales is called first u.LocaleId=ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;//Ensure primeLocales is called first
u.UserType=UserType.Administrator;
ct.User.Add(u); ct.User.Add(u);
ct.SaveChanges(); ct.SaveChanges();
} }

View File

@@ -13,7 +13,7 @@ namespace AyaNova.Models
public long OwnerId { get; set; } public long OwnerId { get; set; }
[Required] [Required]
public bool Active { get; set; } public bool Active { get; set; }
[Required] [Required, MaxLength(255)]
public string Name { get; set; } public string Name { get; set; }
[Required] [Required]
public string Login { get; set; } public string Login { get; set; }
@@ -30,6 +30,7 @@ namespace AyaNova.Models
[Required] [Required]
public UserType UserType { get; set; } public UserType UserType { get; set; }
[MaxLength(255)]
public string EmployeeNumber { get; set; } public string EmployeeNumber { get; set; }
public string Notes { get; set; } public string Notes { get; set; }
public long? ClientId { get; set; } public long? ClientId { get; set; }

View File

@@ -22,7 +22,7 @@ namespace AyaNova.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!! //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
private const int DESIRED_SCHEMA_LEVEL = 9; private const int DESIRED_SCHEMA_LEVEL = 9;
internal const long EXPECTED_COLUMN_COUNT = 70; internal const long EXPECTED_COLUMN_COUNT = 77;
internal const long EXPECTED_INDEX_COUNT = 15; internal const long EXPECTED_INDEX_COUNT = 15;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!! //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
@@ -141,7 +141,7 @@ namespace AyaNova.Util
//Add user table //Add user table
exec("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, active bool not null, name varchar(255) not null, " + exec("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, active bool not null, name varchar(255) not null, " +
"login text not null, password text not null, salt text not null, roles integer not null, localeid bigint not null REFERENCES alocale (id), " + "login text not null, password text not null, salt text not null, roles integer not null, localeid bigint not null REFERENCES alocale (id), " +
"dlkey text, dlkeyexpire timestamp)"); "dlkey text, dlkeyexpire timestamp, usertype integer not null, employeenumber varchar(255), notes text, clientid bigint, headofficeid bigint, subvendorid bigint)");
//Prime the db with the default MANAGER account //Prime the db with the default MANAGER account
AyaNova.Biz.PrimeData.PrimeManagerAccount(ct); AyaNova.Biz.PrimeData.PrimeManagerAccount(ct);

View File

@@ -70,10 +70,10 @@ namespace AyaNova.Util
//This is for a busy but one man shop with a single office person handling stuff back at the shop //This is for a busy but one man shop with a single office person handling stuff back at the shop
case SeedLevel.SmallOneManShopTrialDataSet: case SeedLevel.SmallOneManShopTrialDataSet:
//Generate owner and lead tech //Generate owner and lead tech
GenSeedUser(1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull); GenSeedUser(1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Schedulable);
//Generate one office person / secretary //Generate one office person / secretary
GenSeedUser(1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull); GenSeedUser(1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable);
//200 widgets //200 widgets
GenSeedWidget(200); GenSeedWidget(200);
@@ -84,37 +84,37 @@ namespace AyaNova.Util
case SeedLevel.MediumLocalServiceCompanyTrialDataSet: case SeedLevel.MediumLocalServiceCompanyTrialDataSet:
//One IT administrator, can change ops but nothing else //One IT administrator, can change ops but nothing else
GenSeedUser(1, AuthorizationRoles.OpsAdminFull); GenSeedUser(1, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable);
//One business administrator, can view ops issues //One business administrator, can view ops issues
GenSeedUser(1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited); GenSeedUser(1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
//One owner who doesn't control anything but views stuff //One owner who doesn't control anything but views stuff
GenSeedUser(1, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited); GenSeedUser(1, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
//20 techs //20 techs
GenSeedUser(20, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited); GenSeedUser(20, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
//2 subcontractors //2 subcontractors
GenSeedUser(2, AuthorizationRoles.SubContractorFull); GenSeedUser(2, AuthorizationRoles.SubContractorFull, UserType.Subcontractor);
//3 sales / generic office people people //3 sales / generic office people people
GenSeedUser(3, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited); GenSeedUser(3, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
//1 dispatch manager //1 dispatch manager
GenSeedUser(1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited); GenSeedUser(1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
//1 Inventory manager //1 Inventory manager
GenSeedUser(1, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited); GenSeedUser(1, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable);
//1 accountant / bookkeeper //1 accountant / bookkeeper
GenSeedUser(1, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited); GenSeedUser(1, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable);
//10 full on client users //10 full on client users
GenSeedUser(10, AuthorizationRoles.ClientLimited); GenSeedUser(10, AuthorizationRoles.ClientLimited, UserType.Client);
//10 limited client users //10 limited client users
GenSeedUser(10, AuthorizationRoles.ClientLimited); GenSeedUser(10, AuthorizationRoles.ClientLimited, UserType.Client);
//2000 widgets //2000 widgets
GenSeedWidget(2000); GenSeedWidget(2000);
@@ -124,49 +124,49 @@ namespace AyaNova.Util
//Each location has a full staff and corporate head office has an overarching staff member in charge of each location //Each location has a full staff and corporate head office has an overarching staff member in charge of each location
case SeedLevel.LargeCorporateMultiRegionalTrialDataSet: case SeedLevel.LargeCorporateMultiRegionalTrialDataSet:
//IT administrator, can change ops but nothing else //IT administrator, can change ops but nothing else
GenSeedUser(2, AuthorizationRoles.OpsAdminFull); GenSeedUser(2, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable);
//business administrator, can view ops issues //business administrator, can view ops issues
GenSeedUser(2, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited); GenSeedUser(2, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
//owner / upper management who doesn't control anything but views stuff //owner / upper management who doesn't control anything but views stuff
GenSeedUser(5, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited); GenSeedUser(5, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable);
//techs //techs
GenSeedUser(100, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited); GenSeedUser(100, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
//limited techs //limited techs
GenSeedUser(50, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited); GenSeedUser(50, AuthorizationRoles.TechLimited | AuthorizationRoles.DispatchLimited, UserType.Schedulable);
//20 subcontractors //20 subcontractors
GenSeedUser(20, AuthorizationRoles.SubContractorFull); GenSeedUser(20, AuthorizationRoles.SubContractorFull, UserType.Subcontractor);
//10 limited subcontractors //10 limited subcontractors
GenSeedUser(10, AuthorizationRoles.SubContractorLimited); GenSeedUser(10, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor);
//30 sales / generic office people people //30 sales / generic office people people
GenSeedUser(30, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited); GenSeedUser(30, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
//5 dispatch manager //5 dispatch manager
GenSeedUser(5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited); GenSeedUser(5, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
//5 Inventory manager //5 Inventory manager
GenSeedUser(5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited); GenSeedUser(5, AuthorizationRoles.InventoryFull | AuthorizationRoles.DispatchLimited, UserType.NonSchedulable);
//10 Inventory manager assistants //10 Inventory manager assistants
GenSeedUser(5, AuthorizationRoles.InventoryLimited); GenSeedUser(5, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable);
//5 accountant / bookkeeper //5 accountant / bookkeeper
GenSeedUser(5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited); GenSeedUser(5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable);
//100 full on client users //100 full on client users
GenSeedUser(100, AuthorizationRoles.ClientFull); GenSeedUser(100, AuthorizationRoles.ClientFull, UserType.Client);
//100 limited client users //100 limited client users
GenSeedUser(100, AuthorizationRoles.ClientLimited); GenSeedUser(100, AuthorizationRoles.ClientLimited, UserType.Client);
//20000 widgets //20000 widgets
GenSeedWidget(20000); GenSeedWidget(20000);
break; break;
} }
@@ -195,24 +195,24 @@ namespace AyaNova.Util
//TEST USERS //TEST USERS
//one of each role type //one of each role type
GenSeedUser(1, AuthorizationRoles.BizAdminLimited, "BizAdminLimited", "BizAdminLimited"); GenSeedUser(1, AuthorizationRoles.BizAdminLimited, UserType.NonSchedulable, "BizAdminLimited", "BizAdminLimited");
GenSeedUser(1, AuthorizationRoles.BizAdminFull, "BizAdminFull", "BizAdminFull"); GenSeedUser(1, AuthorizationRoles.BizAdminFull, UserType.NonSchedulable, "BizAdminFull", "BizAdminFull");
GenSeedUser(1, AuthorizationRoles.DispatchLimited, "DispatchLimited", "DispatchLimited"); GenSeedUser(1, AuthorizationRoles.DispatchLimited, UserType.NonSchedulable, "DispatchLimited", "DispatchLimited");
GenSeedUser(1, AuthorizationRoles.DispatchFull, "DispatchFull", "DispatchFull"); GenSeedUser(1, AuthorizationRoles.DispatchFull, UserType.NonSchedulable, "DispatchFull", "DispatchFull");
GenSeedUser(1, AuthorizationRoles.InventoryLimited, "InventoryLimited", "InventoryLimited"); GenSeedUser(1, AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, "InventoryLimited", "InventoryLimited");
GenSeedUser(1, AuthorizationRoles.InventoryFull, "InventoryFull", "InventoryFull"); GenSeedUser(1, AuthorizationRoles.InventoryFull, UserType.NonSchedulable, "InventoryFull", "InventoryFull");
GenSeedUser(1, AuthorizationRoles.AccountingFull, "Accounting", "Accounting"); GenSeedUser(1, AuthorizationRoles.AccountingFull, UserType.NonSchedulable, "Accounting", "Accounting");
GenSeedUser(1, AuthorizationRoles.TechLimited, "TechLimited", "TechLimited"); GenSeedUser(1, AuthorizationRoles.TechLimited, UserType.Schedulable, "TechLimited", "TechLimited");
GenSeedUser(1, AuthorizationRoles.TechFull, "TechFull", "TechFull"); GenSeedUser(1, AuthorizationRoles.TechFull, UserType.Schedulable, "TechFull", "TechFull");
GenSeedUser(1, AuthorizationRoles.SubContractorLimited, "SubContractorLimited", "SubContractorLimited"); GenSeedUser(1, AuthorizationRoles.SubContractorLimited, UserType.Subcontractor, "SubContractorLimited", "SubContractorLimited");
GenSeedUser(1, AuthorizationRoles.SubContractorFull, "SubContractorFull", "SubContractorFull"); GenSeedUser(1, AuthorizationRoles.SubContractorFull, UserType.Subcontractor, "SubContractorFull", "SubContractorFull");
GenSeedUser(1, AuthorizationRoles.ClientLimited, "ClientLimited", "ClientLimited"); GenSeedUser(1, AuthorizationRoles.ClientLimited, UserType.Client, "ClientLimited", "ClientLimited");
GenSeedUser(1, AuthorizationRoles.ClientFull, "ClientFull", "ClientFull"); GenSeedUser(1, AuthorizationRoles.ClientFull, UserType.Client, "ClientFull", "ClientFull");
GenSeedUser(1, AuthorizationRoles.OpsAdminLimited, "OpsAdminLimited", "OpsAdminLimited"); GenSeedUser(1, AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, "OpsAdminLimited", "OpsAdminLimited");
GenSeedUser(1, AuthorizationRoles.OpsAdminFull, "OpsAdminFull", "OpsAdminFull"); GenSeedUser(1, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable, "OpsAdminFull", "OpsAdminFull");
//PRIVACY TEST USER - this is used for a test to see if user info leaks into the logs //PRIVACY TEST USER - this is used for a test to see if user info leaks into the logs
GenSeedUser(1, AuthorizationRoles.OpsAdminLimited, "TEST_PRIVACY_USER_ACCOUNT", "TEST_PRIVACY_USER_ACCOUNT"); GenSeedUser(1, AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, "TEST_PRIVACY_USER_ACCOUNT", "TEST_PRIVACY_USER_ACCOUNT");
} }
@@ -224,7 +224,7 @@ namespace AyaNova.Util
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
//Seed user - default login / pw is first name //Seed user - default login / pw is first name
// //
public static void GenSeedUser(int count, AuthorizationRoles roles, string login = null, string password = null) public static void GenSeedUser(int count, AuthorizationRoles roles, UserType userType, string login = null, string password = null)
{ {
AyContext ct = ServiceProviderProvider.DBContext; AyContext ct = ServiceProviderProvider.DBContext;
@@ -247,12 +247,15 @@ namespace AyaNova.Util
u.Password = Hasher.hash(u.Salt, u.Login); u.Password = Hasher.hash(u.Salt, u.Login);
u.Roles = roles; u.Roles = roles;
u.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID; u.LocaleId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
u.UserType = userType;
//TODO: if usertype is subcontractor or client or headoffice it needs to set a corresponding user's parent org record id to go with it
ct.User.Add(u); ct.User.Add(u);
} }
//save to get id values //save to get id values
ct.SaveChanges(); ct.SaveChanges();
//Now that we have the ID values bulk add the event log entries //Now that we have the ID values bulk add the event log entries
//To save a db call iterate the local collection in the context, but... //To save a db call iterate the local collection in the context, but...
//can't modify the context in the foreach, even if it's another collection entirely, so need to save the id's in a temporary list //can't modify the context in the foreach, even if it's another collection entirely, so need to save the id's in a temporary list
List<long> ItemsAdded = new List<long>(); List<long> ItemsAdded = new List<long>();