This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -54,7 +54,7 @@
|
||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
|
||||
"AYANOVA_SERVER_TEST_MODE": "true",
|
||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "huge",
|
||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
|
||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
|
||||
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"
|
||||
},
|
||||
|
||||
@@ -7,3 +7,6 @@ How to use this help manual
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
|
||||
|
||||
todo: Performance tips section, importance of disabling ad-blocker type extensions on AyaNova, not required since there are no ads and may slow down things considerably
|
||||
@@ -496,7 +496,7 @@ namespace AyaNova.Util
|
||||
}
|
||||
finally
|
||||
{
|
||||
//No matter what seeding is done
|
||||
//No matter what seeding is done
|
||||
ServerBootConfig.SEEDING = false;
|
||||
log.LogInformation($"Seeder: setting server state back to {wasServerState.ToString()}");
|
||||
apiServerState.SetState(wasServerState, wasReason);
|
||||
@@ -574,9 +574,49 @@ namespace AyaNova.Util
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.All, UserType.NotService, true, "es", "es", await TranslationBiz.TranslationNameToIdStaticAsync("es"), KnownUserTags);
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.All, UserType.NotService, true, "fr", "fr", await TranslationBiz.TranslationNameToIdStaticAsync("fr"), KnownUserTags);
|
||||
|
||||
//CUSTOMER / HO Users
|
||||
{
|
||||
//CUSTOMER / HO Users
|
||||
//seed a customer
|
||||
Customer o = new Customer();
|
||||
o.Name = "XYZ Accounting";
|
||||
|
||||
|
||||
o.Active = true;
|
||||
o.Notes = Fake.Company.CatchPhrase();
|
||||
o.Tags = RandomTags();
|
||||
|
||||
o.AccountNumber = Fake.Finance.Account();
|
||||
o.Latitude = (decimal)Fake.Address.Latitude();
|
||||
o.Longitude = (decimal)Fake.Address.Longitude();
|
||||
o.Address = Fake.Address.StreetAddress();
|
||||
o.City = Fake.Address.City();
|
||||
o.Region = Fake.Address.State();
|
||||
o.Country = Fake.Address.Country();
|
||||
|
||||
o.Phone1 = Fake.Phone.PhoneNumber();
|
||||
o.Phone2 = Fake.Phone.PhoneNumber();
|
||||
o.Phone3 = Fake.Phone.PhoneNumber();
|
||||
o.WebAddress = Fake.Internet.Url();
|
||||
o.EmailAddress = Fake.Internet.ExampleEmail();
|
||||
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
CustomerBiz biz = CustomerBiz.GetBiz(ct);
|
||||
var NewObject = await biz.CreateAsync(o);
|
||||
|
||||
if (NewObject == null)
|
||||
{
|
||||
var err = $"Seeder::SeedCustomer error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||
log.LogError(err);
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
//Known customer type users
|
||||
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.Customer, true, "CustomerFull", "CustomerFull", 0, KnownUserTags, null, NewObject.Id, null);
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.Customer, true, "CustomerLimited", "CustomerLimited", 0, KnownUserTags, null, NewObject.Id, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
@@ -671,7 +711,7 @@ namespace AyaNova.Util
|
||||
//this seems wrong to get a new context inside a loop but in testing is actually faster!?
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
UserBiz biz = UserBiz.GetBiz(ct);
|
||||
UserBiz biz = UserBiz.GetBiz(ct);
|
||||
var NewObject = await biz.CreateAsync(u);
|
||||
if (NewObject == null)
|
||||
{
|
||||
@@ -727,7 +767,7 @@ namespace AyaNova.Util
|
||||
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct);
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct);
|
||||
var NewObject = await biz.CreateAsync(o);
|
||||
if (NewObject == null)
|
||||
{
|
||||
@@ -797,7 +837,9 @@ namespace AyaNova.Util
|
||||
throw new System.Exception(err);
|
||||
}
|
||||
//Customer contacts
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.Customer, true, null, null, 0, null, null, NewObject.Id, null);
|
||||
//10% chance (0-9)
|
||||
if (Fake.Random.Number(9) == 4)
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.Customer, true, null, null, 0, null, null, NewObject.Id, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user