diff --git a/.vscode/launch.json b/.vscode/launch.json index 8038f80..5258804 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -35,7 +35,7 @@ "SOCKEYE_DB_CONNECTION": "Server=localhost;Username=postgres;Password=sockeye;Database=sockeye;CommandTimeout=300;", "SOCKEYE_DATA_PATH": "c:\\temp\\sockeye", "SOCKEYE_USE_URLS": "http://*:7676;", - "SOCKEYE_PERMANENTLY_ERASE_DATABASE":"true", + //"SOCKEYE_PERMANENTLY_ERASE_DATABASE":"true", //"SOCKEYE_REPORT_RENDERING_TIMEOUT":"1", "SOCKEYE_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin" }, diff --git a/server/DataList/LicenseDataList.cs b/server/DataList/LicenseDataList.cs index 6149466..ffc4064 100644 --- a/server/DataList/LicenseDataList.cs +++ b/server/DataList/LicenseDataList.cs @@ -14,42 +14,10 @@ namespace Sockeye.DataList var RoleSet = BizRoles.GetRoleSet(DefaultListAType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - DefaultColumns = new List() { "licensecreated", "licenseactive", "licenseregto", "licensecustomer", "LicenseFetchedOn", "licensetags" }; + DefaultColumns = new List() { "licensecreated", "LicenseTrialMode", "licenseactive", "licenseregto", "licensecustomer", "LicenseFetchedOn", "notificationsent", "ProductGroup" }; DefaultSortBy = new Dictionary() { { "licensecreated", "-" } }; FieldDefinitions = new List(); - /* - "License": "License", - "LicenseCompanyName": "Company name", - "LicenseContactName": "Contact name", - "LicensedOptions": "Licensed options", - "LicenseEmail": "Email address", - "LicenseEmailVerficationHint": "(Address will be verified)", - "LicenseExpiration": "License expiration date", - "LicenseSerial": "License serial number", - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseList', 'Licenses' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseRegTo', 'Registered to' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseKey', 'License key' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchCode', 'Fetch code' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchEmail', 'Fetch email' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchedOn', 'Fetched date' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'en'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expire to' FROM atranslation t where t.baselanguage = 'en'"); - "CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created TIMESTAMPTZ NOT NULL, " - + "customerid BIGINT NOT NULL REFERENCES acustomer(id), regto TEXT NOT NULL, key TEXT NOT NULL, fetchcode TEXT, fetchemail TEXT, " - + "fetchedon TIMESTAMPTZ, dbid TEXT, licenseexpire TIMESTAMPTZ, maintenanceexpire TIMESTAMPTZ NOT NULL, " - + "wiki TEXT, tags VARCHAR(255) ARRAY )"); - */ - // FieldDefinitions.Add(new DataListFieldDefinition - // { - // TKey = "LicenseSerial", - // FieldKey = "licenseid", - // SockType = (int)SockType.License, - // UiFieldDataType = (int)UiFieldDataType.Integer, - // SqlIdColumnName = "alicense.id", - // SqlValueColumnName = "alicense.id", - // IsRowId = true - // }); FieldDefinitions.Add(new DataListFieldDefinition { @@ -62,7 +30,7 @@ namespace Sockeye.DataList IsRowId = true }); - FieldDefinitions.Add(new DataListFieldDefinition + FieldDefinitions.Add(new DataListFieldDefinition { TKey = "Active", FieldKey = "licenseactive", @@ -70,6 +38,22 @@ namespace Sockeye.DataList SqlValueColumnName = "alicense.active" }); + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "NotificationSent", + FieldKey = "notificationsent", + UiFieldDataType = (int)UiFieldDataType.Bool, + SqlValueColumnName = "alicense.notificationsent" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "LicenseTrialMode", + FieldKey = "LicenseTrialMode", + UiFieldDataType = (int)UiFieldDataType.Bool, + SqlValueColumnName = "alicense.trialmode" + }); + FieldDefinitions.Add(new DataListFieldDefinition { TKey = "LicenseRegTo", @@ -90,6 +74,16 @@ namespace Sockeye.DataList SqlValueColumnName = "acustomer.name" }); + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "ProductGroup", + FieldKey = "ProductGroup", + UiFieldDataType = (int)UiFieldDataType.Enum, + EnumType = Sockeye.Util.StringUtil.TrimTypeName(typeof(ProductGroup).ToString()), + SqlValueColumnName = "alicense.pgroup" + }); + + FieldDefinitions.Add(new DataListFieldDefinition { TKey = "Tags", diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index b13038f..7f70048 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -351,106 +351,106 @@ namespace Sockeye.Biz #region CASES - // log.LogInformation("RFImport Cases"); - // //case projects to be tags - // List CaseProjectList = new List(); - // { - // res = await client.GetAsync($"{URL_ROCKFISH}api/rfcaseproject"); - // responseText = await res.Content.ReadAsStringAsync(); + log.LogInformation("RFImport Cases"); + //case projects to be tags + List CaseProjectList = new List(); + { + res = await client.GetAsync($"{URL_ROCKFISH}api/rfcaseproject"); + responseText = await res.Content.ReadAsStringAsync(); - // var jaRFCaseProjectList = JArray.Parse(responseText); - // foreach (JObject jRFCaseProject in jaRFCaseProjectList) - // { - // CaseProjectList.Add(new NameIdItem() { Name = jRFCaseProject["name"].Value(), Id = jRFCaseProject["id"].Value() }); + var jaRFCaseProjectList = JArray.Parse(responseText); + foreach (JObject jRFCaseProject in jaRFCaseProjectList) + { + CaseProjectList.Add(new NameIdItem() { Name = jRFCaseProject["name"].Value(), Id = jRFCaseProject["id"].Value() }); - // } + } - // } - // { - // res = await client.GetAsync($"{URL_ROCKFISH}api/rfcase/list"); - // responseText = await res.Content.ReadAsStringAsync(); - // var jaRFCaseList = JArray.Parse(responseText); - // //some cases are missing the start date so substitute a close other case date (not critical but sb at least in the ballpark for list viewing purposes) - // DateTime dtTempCreated = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc); - // foreach (JObject jRFCase in jaRFCaseList.Reverse()) - // { + } + { + res = await client.GetAsync($"{URL_ROCKFISH}api/rfcase/list"); + responseText = await res.Content.ReadAsStringAsync(); + var jaRFCaseList = JArray.Parse(responseText); + //some cases are missing the start date so substitute a close other case date (not critical but sb at least in the ballpark for list viewing purposes) + DateTime dtTempCreated = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc); + foreach (JObject jRFCase in jaRFCaseList.Reverse()) + { - // var g = new GZCase(); - // g.CaseId = jRFCase["id"].Value(); - // g.Closed = DateUtil.EpochToDateNullIsNull(jRFCase["dtClosed"].Value()); - // //NOTE: closed in rockfish was the date at midnight in GMT - // //so to be in the same day as here need to add a few hours, let's say 8 am for each so add 8 hours - // if (g.Closed != null) - // { - // g.Closed = ((DateTime)g.Closed).AddHours(16); - // } + var g = new GZCase(); + g.CaseId = jRFCase["id"].Value(); + g.Closed = DateUtil.EpochToDateNullIsNull(jRFCase["dtClosed"].Value()); + //NOTE: closed in rockfish was the date at midnight in GMT + //so to be in the same day as here need to add a few hours, let's say 8 am for each so add 8 hours + if (g.Closed != null) + { + g.Closed = ((DateTime)g.Closed).AddHours(16); + } - // //fuckery to try to insert a at least semi close date when created date is missing - // DateTime? dtTemp = DateUtil.EpochToDateNullIsNull(jRFCase["dtCreated"].Value()); - // if (dtTemp == null) - // { - // dtTemp = dtTempCreated; - // } - // else - // { - // dtTempCreated = (DateTime)dtTemp; - // } - // g.Created = (DateTime)dtTemp; - // g.Name = jRFCase["title"].Value(); - // g.Notes = jRFCase["notes"].Value(); + //fuckery to try to insert a at least semi close date when created date is missing + DateTime? dtTemp = DateUtil.EpochToDateNullIsNull(jRFCase["dtCreated"].Value()); + if (dtTemp == null) + { + dtTemp = dtTempCreated; + } + else + { + dtTempCreated = (DateTime)dtTemp; + } + g.Created = (DateTime)dtTemp; + g.Name = jRFCase["title"].Value(); + g.Notes = jRFCase["notes"].Value(); - // var ver = jRFCase["releaseVersion"].Value(); - // if (!string.IsNullOrWhiteSpace(ver)) - // g.Notes += $"\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\nReleased on version:{ver}"; + var ver = jRFCase["releaseVersion"].Value(); + if (!string.IsNullOrWhiteSpace(ver)) + g.Notes += $"\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\nReleased on version:{ver}"; - // var releaseNotes = jRFCase["releaseNotes"].Value(); - // if (!string.IsNullOrWhiteSpace(releaseNotes)) - // g.Notes += $"\nRelease notes:{releaseNotes}"; + var releaseNotes = jRFCase["releaseNotes"].Value(); + if (!string.IsNullOrWhiteSpace(releaseNotes)) + g.Notes += $"\nRelease notes:{releaseNotes}"; - // //Project name to tags - // g.Tags.Add(CaseProjectList.FirstOrDefault(z => z.Id == jRFCase["rfCaseProjectId"].Value()).Name.Replace("z_", "legacy-")); + //Project name to tags + g.Tags.Add(CaseProjectList.FirstOrDefault(z => z.Id == jRFCase["rfCaseProjectId"].Value()).Name.Replace("z_", "legacy-")); - // //priority to tags - // g.Tags.Add($"{jRFCase["priority"].Value()}-priority"); + //priority to tags + g.Tags.Add($"{jRFCase["priority"].Value()}-priority"); - // //check for attachments and just add as a note, don't bother with actual transfer of attachment, there aren't a lot and most are way in the past and not required for anything - // //if needed in future can manually xfer it over from the rockfish.sqlite db directly using DB BRowser for sqlite which allows opening the blob from the rfcaseblob table and saving it - // res = await client.GetAsync($"{URL_ROCKFISH}api/rfcase/{g.CaseId}/attachments"); - // responseText = await res.Content.ReadAsStringAsync(); - // var jAttachments = JObject.Parse(responseText); - // if (jAttachments["attach"].Count() > 0) - // { - // g.Notes += "\n********\nRockfish attachments\n"; - // foreach (JObject jAttachmentRecord in jAttachments["attach"]) - // { - // g.Notes += $"File: \"{jAttachmentRecord["name"].Value()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value()}\n"; + //check for attachments and just add as a note, don't bother with actual transfer of attachment, there aren't a lot and most are way in the past and not required for anything + //if needed in future can manually xfer it over from the rockfish.sqlite db directly using DB BRowser for sqlite which allows opening the blob from the rfcaseblob table and saving it + res = await client.GetAsync($"{URL_ROCKFISH}api/rfcase/{g.CaseId}/attachments"); + responseText = await res.Content.ReadAsStringAsync(); + var jAttachments = JObject.Parse(responseText); + if (jAttachments["attach"].Count() > 0) + { + g.Notes += "\n********\nRockfish attachments\n"; + foreach (JObject jAttachmentRecord in jAttachments["attach"]) + { + g.Notes += $"File: \"{jAttachmentRecord["name"].Value()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value()}\n"; - // } - // g.Notes += "\n********\n"; - // } + } + g.Notes += "\n********\n"; + } - // GZCaseBiz biz = GZCaseBiz.GetBiz(ct); - // await biz.CreateAsync(g); + GZCaseBiz biz = GZCaseBiz.GetBiz(ct); + await biz.CreateAsync(g); - // //attachments example 86400000 - // // /api/rfcase/4360/attachments - // //{"dlkey":"ZFkAUpo1L0Gi3Q9aO5szkA","attach":[{"id":259,"name":"desired weight calcs.txt"}]} - // //{"dlkey":"iR6ncD70CkzkozyT0otA","attach":[]} + //attachments example 86400000 + // /api/rfcase/4360/attachments + //{"dlkey":"ZFkAUpo1L0Gi3Q9aO5szkA","attach":[{"id":259,"name":"desired weight calcs.txt"}]} + //{"dlkey":"iR6ncD70CkzkozyT0otA","attach":[]} - // }// all cases loop + }// all cases loop - // //Start next case with a new sequence caseid of 4444 - // using (var command = ct.Database.GetDbConnection().CreateCommand()) - // { - // command.CommandText = $"ALTER SEQUENCE agzcase_caseid_seq RESTART WITH 4444;"; - // await ct.Database.OpenConnectionAsync(); - // await command.ExecuteNonQueryAsync(); - // await ct.Database.CloseConnectionAsync(); - // } - // } + //Start next case with a new sequence caseid of 4444 + using (var command = ct.Database.GetDbConnection().CreateCommand()) + { + command.CommandText = $"ALTER SEQUENCE agzcase_caseid_seq RESTART WITH 4444;"; + await ct.Database.OpenConnectionAsync(); + await command.ExecuteNonQueryAsync(); + await ct.Database.CloseConnectionAsync(); + } + } #endregion cases diff --git a/server/util/AySchema.cs b/server/util/AySchema.cs index 919aeeb..2f256cd 100644 --- a/server/util/AySchema.cs +++ b/server/util/AySchema.cs @@ -925,6 +925,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expires' FROM atranslation t where t.baselanguage = 'en'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'en'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseTrialMode', 'Trial mode' FROM atranslation t where t.baselanguage = 'en'"); //spanish translations await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseList', 'Licenses' FROM atranslation t where t.baselanguage = 'es'"); @@ -936,6 +937,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expires' FROM atranslation t where t.baselanguage = 'es'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'es'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseTrialMode', 'Trial mode' FROM atranslation t where t.baselanguage = 'es'"); //french translations await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseList', 'Licenses' FROM atranslation t where t.baselanguage = 'fr'"); @@ -946,7 +948,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchedOn', 'Fetched date' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'fr'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expires' FROM atranslation t where t.baselanguage = 'fr'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'es'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'fr'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseTrialMode', 'Trial mode' FROM atranslation t where t.baselanguage = 'fr'"); //german translations await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseList', 'Licenses' FROM atranslation t where t.baselanguage = 'de'"); @@ -957,7 +960,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseFetchedOn', 'Fetched date' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseDBID', 'DBID' FROM atranslation t where t.baselanguage = 'de'"); await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseMaintenanceExpire', 'Maintenance expires' FROM atranslation t where t.baselanguage = 'de'"); - await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'es'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'NotificationSent', 'Notification sent' FROM atranslation t where t.baselanguage = 'de'"); + await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'LicenseTrialMode', 'Trial mode' FROM atranslation t where t.baselanguage = 'de'"); #endregion license