Final (?) de-widgetification
This commit is contained in:
@@ -22,16 +22,16 @@ namespace AyaNova.Util
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!!
|
||||
private const int DESIRED_SCHEMA_LEVEL = 1;
|
||||
|
||||
internal const long EXPECTED_COLUMN_COUNT = 1276;
|
||||
internal const long EXPECTED_INDEX_COUNT = 146;
|
||||
internal const long EXPECTED_CHECK_CONSTRAINTS = 517;
|
||||
internal const long EXPECTED_COLUMN_COUNT = 1262;
|
||||
internal const long EXPECTED_INDEX_COUNT = 144;
|
||||
internal const long EXPECTED_CHECK_CONSTRAINTS = 513;
|
||||
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 192;
|
||||
internal const long EXPECTED_VIEWS = 9;
|
||||
internal const long EXPECTED_ROUTINES = 2;
|
||||
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!!
|
||||
|
||||
///////////////////////////////////////////////////////////////// C1276:I146:CC517:FC192:V9:R2
|
||||
///////////////////////////////////////////////////////////////// C1262:I144:CC513:FC192:V9:R2
|
||||
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ BEGIN
|
||||
case ayatype
|
||||
when 0 then return 'LT:NoType';
|
||||
when 1 then return 'LT:Global';
|
||||
when 2 then aytable = 'awidget';
|
||||
when 2 then return 'LT:UNUSED';
|
||||
when 3 then aytable = 'auser';
|
||||
when 4 then return 'LT:ServerState';
|
||||
when 5 then return 'LT:License';
|
||||
@@ -494,15 +494,9 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
//Add user table
|
||||
await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, dbid TEXT, key TEXT NOT NULL)");
|
||||
|
||||
//Add widget table
|
||||
//id, TEXT, longtext, boolean, currency,
|
||||
await ExecQueryAsync("CREATE TABLE awidget (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL UNIQUE, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,"
|
||||
+ "startdate TIMESTAMP, enddate TIMESTAMP, dollaramount DECIMAL(38,18), active BOOL NOT NULL, usertype int4, count INTEGER,"
|
||||
+ "notes TEXT, userid BIGINT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY)");
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE afileattachment (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, "
|
||||
+ "attachtoobjectid BIGINT NOT NULL, attachtoatype INTEGER NOT NULL, "
|
||||
+ "storedfilename TEXT NOT NULL, displayfilename TEXT NOT NULL, contenttype TEXT, lastmodified TIMESTAMP NOT NULL, notes TEXT, exists BOOL NOT NULL, size BIGINT NOT NULL)");
|
||||
+ "attachtoobjectid BIGINT NOT NULL, attachtoatype INTEGER NOT NULL, "
|
||||
+ "storedfilename TEXT NOT NULL, displayfilename TEXT NOT NULL, contenttype TEXT, lastmodified TIMESTAMP NOT NULL, notes TEXT, exists BOOL NOT NULL, size BIGINT NOT NULL)");
|
||||
|
||||
//index required for ops that need to check if file already in db (delete, count refs etc)
|
||||
//LOOKAT: isn't this useless without the ID as well or is that not fetched?
|
||||
|
||||
@@ -402,8 +402,7 @@ namespace AyaNova.Util
|
||||
await EraseTableAsync("apm", conn);
|
||||
//---
|
||||
|
||||
await EraseTableAsync("afileattachment", conn);
|
||||
await EraseTableAsync("awidget", conn);
|
||||
await EraseTableAsync("afileattachment", conn);
|
||||
await EraseTableAsync("aevent", conn);
|
||||
await EraseTableAsync("adatalistsavedfilter", conn);
|
||||
await EraseTableAsync("adatalistcolumnview", conn);
|
||||
|
||||
@@ -114,49 +114,49 @@ namespace AyaNova.Util
|
||||
apiServerState.SetOpsOnly("Seeding database with sample data");
|
||||
|
||||
|
||||
// //WIDGET sample form customization
|
||||
// //CUSTOMER sample form customization
|
||||
// {
|
||||
|
||||
// var fc = new FormCustom()
|
||||
// {
|
||||
// FormKey = AyaType.Widget.ToString(),
|
||||
// FormKey = AyaType.Customer.ToString(),
|
||||
// Template = @"[
|
||||
// {
|
||||
// ""fld"": ""Notes"",
|
||||
// ""required"": true
|
||||
// },
|
||||
// {
|
||||
// ""fld"": ""WidgetCustom1"",
|
||||
// ""fld"": ""CustomerCustom1"",
|
||||
// ""required"": false,
|
||||
// ""type"": 1
|
||||
// },
|
||||
// {
|
||||
// ""fld"": ""WidgetCustom2"",
|
||||
// ""fld"": ""CustomerCustom2"",
|
||||
// ""required"": true,
|
||||
// ""type"": 4
|
||||
// },
|
||||
// {
|
||||
// ""fld"": ""WidgetCustom3"",
|
||||
// ""fld"": ""CustomerCustom3"",
|
||||
// ""required"": false,
|
||||
// ""type"": 5
|
||||
// },
|
||||
// {
|
||||
// ""fld"": ""WidgetCustom4"",
|
||||
// ""fld"": ""CustomerCustom4"",
|
||||
// ""required"": false,
|
||||
// ""type"": 6
|
||||
// },
|
||||
// {
|
||||
// ""fld"": ""WidgetCustom5"",
|
||||
// ""fld"": ""CustomerCustom5"",
|
||||
// ""required"": false,
|
||||
// ""type"": 8
|
||||
// },
|
||||
// {
|
||||
// ""fld"": ""WidgetCustom6"",
|
||||
// ""fld"": ""CustomerCustom6"",
|
||||
// ""required"": false,
|
||||
// ""type"": 2
|
||||
// },
|
||||
// {
|
||||
// ""fld"": ""WidgetCustom7"",
|
||||
// ""fld"": ""CustomerCustom7"",
|
||||
// ""required"": false,
|
||||
// ""type"": 3
|
||||
// }
|
||||
@@ -175,9 +175,9 @@ namespace AyaNova.Util
|
||||
// {
|
||||
// Name = "Name starts with generic",
|
||||
// UserId = 1,
|
||||
// ListKey = "TestWidgetDataList",
|
||||
// ListKey = "TestCustomerDataList",
|
||||
// Public = true,
|
||||
// ListView = @"[{""fld"": ""widgetname"",""filter"": {""any"":false,""items"": [{""op"": ""%-"",""value"": ""Generic""}]}}]"
|
||||
// ListView = @"[{""fld"": ""customername"",""filter"": {""any"":false,""items"": [{""op"": ""%-"",""value"": ""Generic""}]}}]"
|
||||
// };
|
||||
|
||||
// //Create and save to db
|
||||
@@ -188,9 +188,9 @@ namespace AyaNova.Util
|
||||
// {
|
||||
// Name = "Awesome (lots of fields)",
|
||||
// UserId = 1,
|
||||
// ListKey = "TestWidgetDataList",
|
||||
// ListKey = "TestCustomerDataList",
|
||||
// Public = true,
|
||||
// ListView = @"[{""fld"": ""widgetname"",""filter"": {""any"":false,""items"": [{""op"": ""%-"",""value"": ""Awesome""}]}},{""fld"":""widgetserial""},{""fld"":""widgetdollaramount""},{""fld"":""widgetusertype""},{""fld"":""widgetstartdate""},{""fld"":""widgetactive""},{""fld"":""username""},{""fld"":""widgettags""},{""fld"":""widgetcustom1""},{""fld"":""widgetcustom2""}]"
|
||||
// ListView = @"[{""fld"": ""customername"",""filter"": {""any"":false,""items"": [{""op"": ""%-"",""value"": ""Awesome""}]}},{""fld"":""customerserial""},{""fld"":""customerdollaramount""},{""fld"":""customerusertype""},{""fld"":""customerstartdate""},{""fld"":""customeractive""},{""fld"":""username""},{""fld"":""customertags""},{""fld"":""customercustom1""},{""fld"":""customercustom2""}]"
|
||||
// };
|
||||
|
||||
// //Create and save to db
|
||||
@@ -227,8 +227,7 @@ namespace AyaNova.Util
|
||||
//Generate owner and lead tech
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Inventory | AuthorizationRoles.OpsAdmin, UserType.Service);
|
||||
//Generate one office person / secretary
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.Service | AuthorizationRoles.Inventory | AuthorizationRoles.Accounting, UserType.NotService);
|
||||
// await SeedWidgetAsync(log, 3);//keeping this here for now but must remove later
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.Service | AuthorizationRoles.Inventory | AuthorizationRoles.Accounting, UserType.NotService);
|
||||
await SeedVendorAsync(log, 10);
|
||||
await SeedUnitModelAsync(log, 10);
|
||||
await SeedCustomerAsync(log, 25);
|
||||
@@ -287,7 +286,6 @@ namespace AyaNova.Util
|
||||
//1 accountant / bookkeeper
|
||||
await SeedUserAsync(log, 1, AuthorizationRoles.Accounting | AuthorizationRoles.BizAdminRestricted, UserType.NotService);
|
||||
|
||||
//await SeedWidgetAsync(log, 100);
|
||||
await SeedVendorAsync(log, 50);
|
||||
await SeedUnitModelAsync(log, 20);
|
||||
await SeedCustomerAsync(log, 500);
|
||||
@@ -356,7 +354,6 @@ namespace AyaNova.Util
|
||||
//5 accountant / bookkeeper
|
||||
await SeedUserAsync(log, 5, AuthorizationRoles.Accounting | AuthorizationRoles.BizAdminRestricted, UserType.NotService);
|
||||
|
||||
//await SeedWidgetAsync(log, 100);
|
||||
await SeedVendorAsync(log, 100);
|
||||
await SeedUnitModelAsync(log, 40);
|
||||
await SeedCustomerAsync(log, 1000);
|
||||
@@ -426,7 +423,6 @@ namespace AyaNova.Util
|
||||
//accountant / bookkeeper
|
||||
await SeedUserAsync(log, 20, AuthorizationRoles.Accounting | AuthorizationRoles.BizAdminRestricted, UserType.NotService);
|
||||
|
||||
//await SeedWidgetAsync(log, 100);
|
||||
await SeedVendorAsync(log, 500);
|
||||
await SeedUnitModelAsync(log, 200);
|
||||
await SeedCustomerAsync(log, 10000);
|
||||
@@ -1772,62 +1768,7 @@ namespace AyaNova.Util
|
||||
|
||||
}
|
||||
|
||||
#region WIDGET
|
||||
// //////////////////////////////////////////////////////
|
||||
// //Seed widget for testing
|
||||
// //
|
||||
// public async Task SeedWidgetAsync(ILogger log, int count)
|
||||
// {
|
||||
// //this is 4 times slower than doing it inside the loop below
|
||||
// //seems counterintuitive but maybe it's to do with the db context not being refreshed?
|
||||
|
||||
// //RANDOM ROLES
|
||||
// Array values = Enum.GetValues(typeof(UserType));
|
||||
// Random random = new Random();
|
||||
|
||||
// DateTime seedStartWindow = DateTime.Now.AddYears(-1).AddMonths(-6);
|
||||
// DateTime seedEndWindow = DateTime.Now.AddYears(1).AddMonths(6);
|
||||
// for (int x = 0; x < count; x++)
|
||||
// {
|
||||
// Widget o = new Widget();
|
||||
// o.Name = Uniquify(Fake.Commerce.ProductName());
|
||||
// o.Active = true;
|
||||
// DateTime dtSeed = Fake.Date.Between(seedStartWindow, seedEndWindow).ToUniversalTime();
|
||||
// o.StartDate = dtSeed;
|
||||
// o.EndDate = dtSeed.AddMinutes(60).ToUniversalTime();
|
||||
// o.DollarAmount = Convert.ToDecimal(Fake.Commerce.Price());
|
||||
|
||||
// //Random but valid enum
|
||||
// UserType randomUserType = (UserType)values.GetValue(random.Next(values.Length));
|
||||
// o.UserType = randomUserType;
|
||||
// o.Notes = Fake.Lorem.Sentence(null, 5);
|
||||
// o.Tags = RandomTags();
|
||||
// o.UserId = Fake.Random.Int(1, TotalSeededUsers);
|
||||
|
||||
// //RANDOM CUSTOM FIELD DATA
|
||||
// var c1 = DateUtil.UniversalISO8661Format(Fake.Date.Between(DateTime.Now.AddYears(-1), DateTime.Now.AddYears(1)));
|
||||
// var c2 = Fake.Lorem.Sentence(null, 5);
|
||||
// var c3 = Fake.Random.Int(1, 99999999);
|
||||
// var c4 = Fake.Random.Bool().ToString().ToLowerInvariant();
|
||||
// var c5 = Fake.Random.Decimal();
|
||||
// o.CustomFields = $@"{{c1:""{c1}"",c2:""{c2}"",c3:{c3},c4:{c4},c5:{c5}}}";
|
||||
|
||||
// //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);
|
||||
// var NewObject = await biz.CreateAsync(o);
|
||||
// if (NewObject == null)
|
||||
// {
|
||||
// log.LogError($"Seeder::SeedWidget error creating {o.Name}\r\n" + biz.GetErrorsAsString());
|
||||
// throw new System.Exception("Seeder::SeedWidget error creating widget\r\n" + biz.GetErrorsAsString());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public HashSet<string> HashCompanyNames = new HashSet<string>();
|
||||
|
||||
private int TotalSeededCustomers = 0;
|
||||
|
||||
Reference in New Issue
Block a user