From 92f97cbf8ed53c69498341dd7bf66ed99eef1927 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 28 Dec 2022 23:42:42 +0000 Subject: [PATCH] --- server/biz/GlobalBizSettingsBiz.cs | 117 ++++++++++++++++++++++++++++- server/models/License.cs | 2 +- todo.txt | 2 +- 3 files changed, 115 insertions(+), 6 deletions(-) diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index 1e38c19..6a265d5 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -297,8 +297,6 @@ namespace Sockeye.Biz }//end of all customers iteration - - #region CASES log.LogInformation("RFImport Cases"); //case projects to be tags @@ -329,8 +327,9 @@ namespace Sockeye.Biz 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); + 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 @@ -400,6 +399,116 @@ namespace Sockeye.Biz } } #endregion cases + + + #region LICENSES + log.LogInformation("RFImport Licenses"); + + { + res = await client.GetAsync($"{URL_ROCKFISH}api/license/list"); + responseText = await res.Content.ReadAsStringAsync(); + 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) + { + + res = await client.GetAsync($"{URL_ROCKFISH}api/license/{jLicenseListItem["id"].Value()}"); + responseText = await res.Content.ReadAsStringAsync(); + var jLicense = JObject.Parse(responseText); + + /* + {"regTo":"PDI Technologies","customerName":"PDI Technologies","dtcreated":1672261044,"email":"jberkel@pdisoftware.com","code":"na","fetched":true,"dtfetched":1672262347,"fetchFrom":null, + "key":"[KEY\n{\n \"Key\": {\n \"LicenseFormat\": \"8\",\n \"Id\": \"1672261044\",\n \"RegisteredTo\": \"PDI Technologies\",\n \"DBID\": \"R6U37uNUN2hSQideG6Gg+MqoQY8vuUeyHFI6Kv7VDsE=\",\n \"Perpetual\": true,\n \"LicenseExpiration\": \"5555-01-01T00:00:00\",\n \"MaintenanceExpiration\": \"2023-12-28T00:00:00\",\n \"Features\": [\n {\n \"Name\": \"ActiveInternalUsers\",\n \"Count\": 5\n }\n ]\n }\n}\nKEY]\n[SIGNATURE\nkzVs8GH0MSIfsR7ZYQ5x+5wdVDJqpfOYvTfBCx32Vs+zqP7h89uUKI17jTx5rMvkOYX40GyJt0pTWOzltljzf+MaoTzoSvTsSPkWtdVWv8ZGOXUUdaZhzMoTJGxTg0JHka/8S5tLkTiuct3x+voiLAKXuFCp9TSZo4+UnejB6U2Bp6MfdZxLtKVZ/1RLu/h4SnP8ZbczuwbQReB1z4k4IRwjh5GHnUUm6YqZg/04m1X9FEeKQZQfGZk/qZ788jONbLQb4CLnq0/ZmIteeocDDBz59TYaC9BHwHp73y8jyPfEugVfyH2AE0J8ZILiFiozYQ7meP5X4ZOmd1nhTA8MkA==\nSIGNATURE]\n" + } + */ + var l = new License(); + l.RegTo = jLicense["regTo"].Value(); + + //try to match customer; rockfish didn't track customer id in the license so this is a bit wishy washy + Customer cust = null; + cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.Name == jLicense["customerName"].Value()); + if (cust == null)//email? + cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress.Contains(jLicense["email"].Value())); + if (cust != null) + l.CustomerId = cust.Id; + l.DbId = jLicense["DBID"].Value(); + l.FetchCode = jLicense["DBID"].Value(); + if (l.FetchCode == "na") l.FetchCode = null; + l.FetchedOn = DateUtil.EpochToDateNullIsNull(jLicense["dtCreated"].Value()); + + + + + //------- + + l.Closed = DateUtil.EpochToDateNullIsNull(jLicenseListItem["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 (l.Closed != null) + { + l.Closed = ((DateTime)l.Closed).AddHours(16); + } + + //fuckery to try to insert a at least semi close date when created date is missing + DateTime? dtTemp = DateUtil.EpochToDateNullIsNull(jLicenseListItem["dtCreated"].Value()); + if (dtTemp == null) + { + dtTemp = dtTempCreated; + } + else + { + dtTempCreated = (DateTime)dtTemp; + } + l.Created = (DateTime)dtTemp; + l.Name = jLicenseListItem["title"].Value(); + l.Notes = jLicenseListItem["notes"].Value(); + + var ver = jLicenseListItem["releaseVersion"].Value(); + if (!string.IsNullOrWhiteSpace(ver)) + l.Notes += $"\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\nReleased on version:{ver}"; + + var releaseNotes = jLicenseListItem["releaseNotes"].Value(); + if (!string.IsNullOrWhiteSpace(releaseNotes)) + l.Notes += $"\nRelease notes:{releaseNotes}"; + + //Project name to tags + l.Tags.Add(CaseProjectList.FirstOrDefault(z => z.Id == jLicenseListItem["rfCaseProjectId"].Value()).Name.Replace("z_", "legacy-")); + + //priority to tags + l.Tags.Add($"{jLicenseListItem["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/{l.CaseId}/attachments"); + responseText = await res.Content.ReadAsStringAsync(); + var jAttachments = JObject.Parse(responseText); + if (jAttachments["attach"].Count() > 0) + { + l.Notes += "\n********\nRockfish attachments\n"; + foreach (JObject jAttachmentRecord in jAttachments["attach"]) + { + l.Notes += $"File: \"{jAttachmentRecord["name"].Value()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value()}\n"; + + } + l.Notes += "\n********\n"; + } + + GZCaseBiz biz = GZCaseBiz.GetBiz(ct); + await biz.CreateAsync(l); + + + + }// all licenses loop + + + } + #endregion licenses + + + + + } catch (Exception ex) { diff --git a/server/models/License.cs b/server/models/License.cs index ce7622e..72c0ff5 100644 --- a/server/models/License.cs +++ b/server/models/License.cs @@ -23,7 +23,7 @@ namespace Sockeye.Models public string Key { get; set; } public string FetchCode { get; set; } public string FetchEmail { get; set; } - public DateTime FetchedOn { get; set; } + public DateTime? FetchedOn { get; set; } public string DbId { get; set; } public DateTime LicenseExpire { get; set; } public DateTime MaintenanceExpire { get; set; } diff --git a/todo.txt b/todo.txt index 02fea3c..9130bb0 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,4 @@ -revert all sock naming back to ayanova standard + client - open / edit purchase import trial requests import licenses