This commit is contained in:
@@ -145,11 +145,8 @@ namespace Sockeye.Biz
|
||||
password = "b43698c255365ee739c05ba0d42855e96c2365c76bb2f9b9eb149cec7b52174c"
|
||||
}), Encoding.UTF8, "application/json");
|
||||
|
||||
|
||||
|
||||
var client = ServiceProviderProvider.HttpClientFactory.CreateClient();
|
||||
|
||||
|
||||
//AUTHENTICATE
|
||||
var res = await client.PostAsync($"{URL_ROCKFISH}authenticate?login=john&password=b43698c255365ee739c05ba0d42855e96c2365c76bb2f9b9eb149cec7b52174c", content);
|
||||
var responseText = await res.Content.ReadAsStringAsync();
|
||||
@@ -298,7 +295,6 @@ namespace Sockeye.Biz
|
||||
|
||||
#endregion customers
|
||||
|
||||
|
||||
#region VENDOR NOTIFICATIONS
|
||||
log.LogInformation("RFImport Vendor notifications");
|
||||
{
|
||||
@@ -344,119 +340,114 @@ namespace Sockeye.Biz
|
||||
p.VendorData += ",\n";
|
||||
p.VendorData += jVendorNotificationItem["data"].Value<string>();
|
||||
await ct.SaveChangesAsync();
|
||||
// var biz = PurchaseBiz.GetBiz(ct);
|
||||
// await biz.PutAsync(p);
|
||||
}
|
||||
|
||||
}// all vendor notifications loop
|
||||
|
||||
|
||||
}
|
||||
#endregion vendor notifications
|
||||
|
||||
|
||||
#region CASES
|
||||
|
||||
// log.LogInformation("RFImport Cases");
|
||||
// //case projects to be tags
|
||||
// List<NameIdItem> CaseProjectList = new List<NameIdItem>();
|
||||
// {
|
||||
// res = await client.GetAsync($"{URL_ROCKFISH}api/rfcaseproject");
|
||||
// responseText = await res.Content.ReadAsStringAsync();
|
||||
log.LogInformation("RFImport Cases");
|
||||
//case projects to be tags
|
||||
List<NameIdItem> CaseProjectList = new List<NameIdItem>();
|
||||
{
|
||||
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<string>(), Id = jRFCaseProject["id"].Value<long>() });
|
||||
var jaRFCaseProjectList = JArray.Parse(responseText);
|
||||
foreach (JObject jRFCaseProject in jaRFCaseProjectList)
|
||||
{
|
||||
CaseProjectList.Add(new NameIdItem() { Name = jRFCaseProject["name"].Value<string>(), Id = jRFCaseProject["id"].Value<long>() });
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// }
|
||||
// {
|
||||
// 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)
|
||||
{
|
||||
|
||||
// var g = new GZCase();
|
||||
// g.CaseId = jRFCase["id"].Value<long>();
|
||||
// g.Closed = DateUtil.EpochToDateNullIsNull(jRFCase["dtClosed"].Value<long?>());
|
||||
// //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<long>();
|
||||
g.Closed = DateUtil.EpochToDateNullIsNull(jRFCase["dtClosed"].Value<long?>());
|
||||
//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<long?>());
|
||||
// if (dtTemp == null)
|
||||
// {
|
||||
// dtTemp = dtTempCreated;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dtTempCreated = (DateTime)dtTemp;
|
||||
// }
|
||||
// g.Created = (DateTime)dtTemp;
|
||||
// g.Name = jRFCase["title"].Value<string>();
|
||||
// g.Notes = jRFCase["notes"].Value<string>();
|
||||
//fuckery to try to insert a at least semi close date when created date is missing
|
||||
DateTime? dtTemp = DateUtil.EpochToDateNullIsNull(jRFCase["dtCreated"].Value<long?>());
|
||||
if (dtTemp == null)
|
||||
{
|
||||
dtTemp = dtTempCreated;
|
||||
}
|
||||
else
|
||||
{
|
||||
dtTempCreated = (DateTime)dtTemp;
|
||||
}
|
||||
g.Created = (DateTime)dtTemp;
|
||||
g.Name = jRFCase["title"].Value<string>();
|
||||
g.Notes = jRFCase["notes"].Value<string>();
|
||||
|
||||
// var ver = jRFCase["releaseVersion"].Value<string>();
|
||||
// if (!string.IsNullOrWhiteSpace(ver))
|
||||
// g.Notes += $"\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\nReleased on version:{ver}";
|
||||
var ver = jRFCase["releaseVersion"].Value<string>();
|
||||
if (!string.IsNullOrWhiteSpace(ver))
|
||||
g.Notes += $"\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\nReleased on version:{ver}";
|
||||
|
||||
// var releaseNotes = jRFCase["releaseNotes"].Value<string>();
|
||||
// if (!string.IsNullOrWhiteSpace(releaseNotes))
|
||||
// g.Notes += $"\nRelease notes:{releaseNotes}";
|
||||
var releaseNotes = jRFCase["releaseNotes"].Value<string>();
|
||||
if (!string.IsNullOrWhiteSpace(releaseNotes))
|
||||
g.Notes += $"\nRelease notes:{releaseNotes}";
|
||||
|
||||
// //Project name to tags
|
||||
// g.Tags.Add(CaseProjectList.FirstOrDefault(z => z.Id == jRFCase["rfCaseProjectId"].Value<long>()).Name.Replace("z_", "legacy-"));
|
||||
//Project name to tags
|
||||
g.Tags.Add(CaseProjectList.FirstOrDefault(z => z.Id == jRFCase["rfCaseProjectId"].Value<long>()).Name.Replace("z_", "legacy-"));
|
||||
|
||||
// //priority to tags
|
||||
// g.Tags.Add($"{jRFCase["priority"].Value<long>()}-priority");
|
||||
//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 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<string>()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value<long>()}\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<string>()}\", rfcaseblob table id: {jAttachmentRecord["id"].Value<long>()}\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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user