From 0bc17f3af65f20ffc8936cee057156b70691f03d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 4 Dec 2020 22:11:01 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- docs/8.0/ayanova/docs/ay-start-user-intro.md | 3 ++ server/AyaNova/util/Seeder.cs | 52 ++++++++++++++++++-- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6d395cd7..8fd97968 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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\\" }, diff --git a/docs/8.0/ayanova/docs/ay-start-user-intro.md b/docs/8.0/ayanova/docs/ay-start-user-intro.md index a3a1d149..fbaf817a 100644 --- a/docs/8.0/ayanova/docs/ay-start-user-intro.md +++ b/docs/8.0/ayanova/docs/ay-start-user-intro.md @@ -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 \ No newline at end of file diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 1e15e11a..69e6ce00 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -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); } } }