diff --git a/.vscode/launch.json b/.vscode/launch.json index db4b77d..8d51672 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/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index bb6fb09..41d1d3d 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -197,7 +197,7 @@ namespace Sockeye.Biz { //CREATE CUSTOMER Customer c = new Customer(); - c.Active=jCustomerListItem["active"].Value(); + c.Active = jCustomerListItem["active"].Value(); c.Name = CustomerName; c.Country = jSite["country"].Value(); c.Region = jSite["stateProvince"].Value(); @@ -305,7 +305,7 @@ namespace Sockeye.Biz responseText = await res.Content.ReadAsStringAsync(); var jaVendorNotificationList = JArray.Parse(responseText); - foreach (JObject jVendorNotificationItem in jaVendorNotificationList) + foreach (JObject jVendorNotificationItem in jaVendorNotificationList.Reverse()) { /*[] "{\n \"creation_date\": \"2022-12-28T20:20:24Z\",\n \ @@ -350,106 +350,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) - { + // } + // { + // 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 4443;"; - 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 4443;"; + // await ct.Database.OpenConnectionAsync(); + // await command.ExecuteNonQueryAsync(); + // await ct.Database.CloseConnectionAsync(); + // } + // } #endregion cases @@ -462,7 +462,7 @@ namespace Sockeye.Biz var jaLicenseList = 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 jLicenseListItem in jaLicenseList) + foreach (JObject jLicenseListItem in jaLicenseList.Reverse()) { res = await client.GetAsync($"{URL_ROCKFISH}api/license/{jLicenseListItem["id"].Value()}"); @@ -592,7 +592,8 @@ namespace Sockeye.Biz var jKey = JObject.Parse(keyNoWS); l.DbId = jKey["Key"]["DBID"].Value(); l.LicenseExpire = jKey["Key"]["LicenseExpiration"].Value().ToUniversalTime(); - if (jKey["Key"]["Perpetual"].Value()) + //if (jKey["Key"]["Perpetual"].Value()) + if ((bool?)jKey["Key"]["Perpetual"] ?? true) l.PGroup = ProductGroup.RavenPerpetual; else l.PGroup = ProductGroup.RavenSubscription; @@ -622,7 +623,7 @@ namespace Sockeye.Biz responseText = await res.Content.ReadAsStringAsync(); var jaTrialRequestList = JArray.Parse(responseText); - foreach (JObject jTrialRequestItem in jaTrialRequestList) + foreach (JObject jTrialRequestItem in jaTrialRequestList.Reverse()) { /* /api/trial/list @@ -669,16 +670,16 @@ namespace Sockeye.Biz } #endregion trial requests - + log.LogInformation("RockFish import succeeded"); } catch (Exception ex) { - var msg = "Error importing rockfish"; + var msg = "*** RockFish import FAILED ***"; log.LogError(ex, msg); } - log.LogInformation("FINISHED IMPORTING"); + //in the correct order retrieve every object and if it's not already present in sockeye, import it //this should be callable any time and it will just update so it can be test live in sync / parallel until ready to switch over //await Task.CompletedTask; diff --git a/server/util/AySchema.cs b/server/util/AySchema.cs index c72a60a..70e2d24 100644 --- a/server/util/AySchema.cs +++ b/server/util/AySchema.cs @@ -22,7 +22,7 @@ namespace Sockeye.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!! private const int DESIRED_SCHEMA_LEVEL = 17; - internal const long EXPECTED_COLUMN_COUNT = 502; + internal const long EXPECTED_COLUMN_COUNT = 503; internal const long EXPECTED_INDEX_COUNT = 74; internal const long EXPECTED_CHECK_CONSTRAINTS = 240; internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 32; @@ -31,7 +31,7 @@ namespace Sockeye.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!! - ///////////////////////////////////////// (C502:I74:CC240:FC32:V0:R2) + ///////////////////////////////////////// (C503:I74:CC240:FC32:V0:R2) /* MAXIMUM POSTGRES OBJECT NAME LENGTH: 63 CHARACTERS