diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 83a78d42..3671331e 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -449,7 +449,7 @@ namespace AyaNova { AyaNova.Core.License.Fetch(apiServerState, dbContext, _newLog); //NOTE: For unit testing make sure the time zone in util is set to the same figure as here to ensure list filter by date tests will work because server is on same page as user in terms of time - Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet, -7);//############################################################################################# + Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.MediumLocalServiceCompanyTrialDataSet, -7);//############################################################################################# } //TESTING #endif diff --git a/server/AyaNova/biz/ObjectFields.cs b/server/AyaNova/biz/ObjectFields.cs index 091c170a..01cc5788 100644 --- a/server/AyaNova/biz/ObjectFields.cs +++ b/server/AyaNova/biz/ObjectFields.cs @@ -168,7 +168,7 @@ namespace AyaNova.Biz l.Add(new ObjectField { Key = "WidgetNotes", PropertyName = "Notes", DataType = (int)AyaDataType.Text }); //More to do on this, maybe the datatype should be a LINK or something for UI purposes //circle back on this when there is enough infrastructure to test - l.Add(new ObjectField { Key = "User", PropertyName = "userid", DataType = (int)AyaDataType.NoType, AyObjectType = (int)AyaType.User }); + l.Add(new ObjectField { Key = "User", PropertyName = "userid", DataType = (int)AyaDataType.Text, AyObjectType = (int)AyaType.User }); l.Add(new ObjectField { Key = "Active", PropertyName = "Active", DataType = (int)AyaDataType.Bool, Hideable = false, SharedLTKey = true }); l.Add(new ObjectField { Key = "Tags", PropertyName = "Tags", DataType = (int)AyaDataType.Tags, SharedLTKey = true }); diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 0eeb05a4..fa1fe8ee 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -15,7 +15,7 @@ namespace AyaNova.Util public static class Seeder { public enum SeedLevel { SmallOneManShopTrialDataSet, MediumLocalServiceCompanyTrialDataSet, LargeCorporateMultiRegionalTrialDataSet, HugeForLoadTest }; - + public static int SeededUserCount = 0; ////////////////////////////////////////////////////// //Seed database for trial and testing purposes @@ -30,7 +30,7 @@ namespace AyaNova.Util public static void SeedDatabase(SeedLevel slevel, Guid JobId, Decimal timeZoneOffset) { bool LogJob = JobId != Guid.Empty; - + SeededUserCount = 0; ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("Seeder"); ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState)); @@ -79,7 +79,7 @@ namespace AyaNova.Util //WIDGET sample form customization { - + var fc = new FormCustom() { FormKey = ObjectFields.WIDGET_KEY, @@ -141,15 +141,28 @@ namespace AyaNova.Util { #region GenSmall //This is for a busy but one man shop with a single office person handling stuff back at the shop - + //PERF + LogStatus(JobId, LogJob, log, $"Seeding SMALL number of user(s)...."); + var watch = new Stopwatch(); + watch.Start(); //Generate owner and lead tech GenSeedUser(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.OpsAdminFull, UserType.Schedulable, timeZoneOffset); //Generate one office person / secretary GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable, timeZoneOffset); + //PERF + watch.Stop(); + LogStatus(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms"); + //100 widgets + watch = new Stopwatch(); + watch.Start(); GenSeedWidget(log, 100); + //PERF + watch.Stop(); + LogStatus(JobId, LogJob, log, $"100 Widgets seeded in {watch.ElapsedMilliseconds} ms"); + #endregion gensmall } break; @@ -158,7 +171,10 @@ namespace AyaNova.Util #region GenMedium //This is for a typical AyaNova medium busy shop //has one location, many techs and full staff for each department - + //PERF + LogStatus(JobId, LogJob, log, $"Seeding MEDIUM number of user(s)...."); + var watch = new Stopwatch(); + watch.Start(); //One IT administrator, can change ops but nothing else GenSeedUser(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NonSchedulable, timeZoneOffset); @@ -166,7 +182,7 @@ namespace AyaNova.Util GenSeedUser(log, 1, AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, timeZoneOffset); //One owner who doesn't control anything but views stuff - GenSeedUser(log, 1, AuthorizationRoles.BizAdminLimited | AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited | AuthorizationRoles.SalesLimited, UserType.NonSchedulable, timeZoneOffset); + GenSeedUser(log, 1, AuthorizationRoles.BizAdminLimited | AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited | AuthorizationRoles.SalesLimited, UserType.NonSchedulable, timeZoneOffset); //20 techs GenSeedUser(log, 20, AuthorizationRoles.TechFull | AuthorizationRoles.DispatchLimited, UserType.Schedulable, timeZoneOffset); @@ -178,7 +194,7 @@ namespace AyaNova.Util GenSeedUser(log, 3, AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); //2 Full sales people - GenSeedUser(log, 2, AuthorizationRoles.SalesFull, UserType.NonSchedulable, timeZoneOffset); + GenSeedUser(log, 2, AuthorizationRoles.SalesFull, UserType.NonSchedulable, timeZoneOffset); //1 dispatch manager GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryLimited, UserType.NonSchedulable, timeZoneOffset); @@ -194,9 +210,20 @@ namespace AyaNova.Util //10 limited client users GenSeedUser(log, 10, AuthorizationRoles.ClientLimited, UserType.Client, timeZoneOffset); + //PERF + watch.Stop(); + LogStatus(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms"); //500 widgets + LogStatus(JobId, LogJob, log, $"Seeding 500 Widgets...."); + watch = new Stopwatch(); + watch.Start(); + GenSeedWidget(log, 500); + //PERF + watch.Stop(); + LogStatus(JobId, LogJob, log, $"500 Widgets seeded in {watch.ElapsedMilliseconds} ms"); + #endregion genmedium } break; @@ -207,7 +234,7 @@ namespace AyaNova.Util //Each location has a full staff and corporate head office has an overarching staff member in charge of each location //PERF - LogStatus(JobId, LogJob, log, $"Seeding 279 user(s)...."); + LogStatus(JobId, LogJob, log, $"Seeding LARGE number of user(s)...."); var watch = new Stopwatch(); watch.Start(); @@ -261,7 +288,7 @@ namespace AyaNova.Util //PERF watch.Stop(); - LogStatus(JobId, LogJob, log, $"279 Users seeded in {watch.ElapsedMilliseconds} ms"); + LogStatus(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms"); //5000 widgets LogStatus(JobId, LogJob, log, $"Seeding 5,000 Widgets...."); @@ -283,7 +310,7 @@ namespace AyaNova.Util //It is acceptable for this seeding to take many hours as it would normally be used rarely //PERF - LogStatus(JobId, LogJob, log, $"Seeding 1,410 user(s)...."); + LogStatus(JobId, LogJob, log, $"Seeding HUGE number of user(s)...."); var watch = new Stopwatch(); watch.Start(); @@ -337,7 +364,7 @@ namespace AyaNova.Util //PERF watch.Stop(); - LogStatus(JobId, LogJob, log, $"1,410 Users seeded in {watch.ElapsedMilliseconds} ms"); + LogStatus(JobId, LogJob, log, $"{SeededUserCount} Users seeded in {watch.ElapsedMilliseconds} ms"); //20000 widgets LogStatus(JobId, LogJob, log, $"Seeding 20,000 Widgets...."); @@ -516,6 +543,8 @@ namespace AyaNova.Util throw new System.Exception("Seeder::GenSeedUser error creating user\r\n" + Biz.GetErrorsAsString()); } } + + SeededUserCount += count; } ////////////////////////////////////////////////////// @@ -547,6 +576,8 @@ namespace AyaNova.Util o.Notes = f.Lorem.Paragraphs(); o.Tags = RandomTags(f); + o.UserId=f.Random.Int(1, SeededUserCount); + //RANDOM CUSTOM FIELD DATA var c1 = DateUtil.UniversalISO8661Format(f.Date.Between(DateTime.Now.AddYears(-1), DateTime.Now.AddYears(1))); var c2 = f.Lorem.Paragraph();