This commit is contained in:
2022-12-28 19:00:43 +00:00
parent d023b10e03
commit 93f1f198ed

View File

@@ -131,6 +131,7 @@ namespace Sockeye.Biz
public async Task ImportRockfish(AyContext ct, ILogger log)
{
log.LogInformation("Start import from rockfish, authenticating");
//Authenticate to rockfish
//string sUrl = $"{LICENSE_SERVER_URL_ROCKFISH}rvr";
string URL_ROCKFISH = "https://rockfish.ayanova.com/";
@@ -174,6 +175,7 @@ namespace Sockeye.Biz
res = await client.GetAsync($"{URL_ROCKFISH}api/customer/list");
responseText = await res.Content.ReadAsStringAsync();
var jaCustomerList = JArray.Parse(responseText);
log.LogInformation("RFImport customers");
foreach (JObject jCustomerListItem in jaCustomerList)
{
res = await client.GetAsync($"{URL_ROCKFISH}api/customer/{jCustomerListItem["id"].Value<long>()}");
@@ -298,6 +300,7 @@ namespace Sockeye.Biz
#region CASES
log.LogInformation("RFImport Cases");
//case projects to be tags
List<NameIdItem> CaseProjectList = new List<NameIdItem>();
{
@@ -353,30 +356,41 @@ namespace Sockeye.Biz
//priority to tags
g.Tags.Add($"{jRFCase["priority"].Value<long>()}-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 jaAttachments = JArray.Parse(responseText);
if (jaAttachments.Count() > 0)
{
g.Notes += "\n********\nRockfish attachments\n";
foreach (JObject jAttachmentRecord in jaAttachments["attach"])
{
g.Notes += $"FileName: \"{jAttachmentRecord["name"].Value<string>()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value<long>()}";
}
g.Notes += "\n********\n";
}
GZCaseBiz biz = GZCaseBiz.GetBiz(ct);
await biz.CreateAsync(g);
/*
{
"id": 4057,
"title": "sockeye:forking-case:Fork AyaNova to new RockFish replacement called \"Sockeye\"",
"rfCaseProjectId": 44,
"priority": 1,
"notes": "Replace RockFish with a new server app forked from AyaNova 8 called \"Sockeye\".\nWas going to try to put rockfish code into Ayanova itself but that's not practical too many differences in biz objects but the bones are similar and if I keep it close can help drive parallel development.\n\nTODO:\nfork RAVEN to sockeye, change AyaNova db name stuff to sockeye so can boot and work and replace db at any time\nstrip out licensing code right away to make life easier for the rest\n\nDetermine what overlaps and needs to be kept and what should go, document it fully here step by step\nAyaNova's expected routes and the mycommerce route called with sales data need to be replicated exactly so there is no loss\nWhat objects need to be added and accomodating future cases\n\nduplicate raven to sockeye then get stripping and set up in a parallel route on devops for testing etc.\n=-=-=-\n\n- Import from rockfish via api calls so can do it anytime and won't be a problem of dupes or anything",
"dtCreated": null,
"dtClosed": null,
"releaseVersion": "",
"releaseNotes": ""
}
*/
//attachments example
// /api/rfcase/4360/attachments
//{"dlkey":"ZFkAUpo1L0Gi3Q9aO5szkA","attach":[{"id":259,"name":"desired weight calcs.txt"}]}
}// 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();
}
}
#endregion cases