This commit is contained in:
2021-08-30 20:19:40 +00:00
parent 279b10fb35
commit b9f7045093
2 changed files with 31 additions and 14 deletions

View File

@@ -412,6 +412,13 @@ namespace AyaNova.PlugIn.V8
//MIGRATE MODE
progress.Append("Setting v8 Server State to 'Migrate Mode'");
await util.PostAsync("server-state", "{\"serverState\":\"MigrateMode\"}");
//delay to allow migrate mode to take effect
//this is a result of pm's generating in a loop at server causing issues with erasure
//this delay should not need to be more time than it takes for a single PM to generate into a workorder
//as of this time it's the only slow thing affecting migrate mode settling in
progress.SubOp("Pausing 7 seconds to give server time to complete current jobs and settle into migrate mode");
await System.Threading.Tasks.Task.Delay(7000);
ResetUniqueUserNames();
ResetUniqueNames();
@@ -437,11 +444,7 @@ namespace AyaNova.PlugIn.V8
//ERASE DB
progress.Append("Erasing AyaNova 8 data");
//delay to allow migrate mode to take effect
//this is a result of pm's generating in a loop at server causing issues with erasure
//this delay should not need to be more time than it takes for a single PM to generate into a workorder
//as of this time it's the only slow thing affecting migrate mode settling in
await System.Threading.Tasks.Task.Delay(7000);
var a = await util.PostAsync("license/permanently-erase-all-data", "\"I understand\"");
@@ -542,15 +545,18 @@ namespace AyaNova.PlugIn.V8
if (ExceptionDuringMigrate != null)
{
progress.Append("ERROR, During operation: \r\n" + progress.LastOp + "\r\n" + progress.LastSubOp);
progress.Append("\r\n************\r\nExport failed with error:\r\n");
progress.Append("ERROR, During operation:");
progress.Append(progress.LastOp + ", " + progress.LastSubOp);
progress.Append("Export failed with error:");
progress.Append(ExceptionDuringMigrate.Message);
progress.Append("stack:\r\n" + ExceptionDuringMigrate.StackTrace);
progress.Append("StackTrace:" );
progress.Append(ExceptionDuringMigrate.StackTrace);
if (ExceptionDuringMigrate.InnerException != null)
{
progress.Append("\r\n************\r\nInner error:\r\n");
progress.Append("Inner error:");
progress.Append(ExceptionDuringMigrate.InnerException.Message);
progress.Append("inner stack:\r\n" + ExceptionDuringMigrate.InnerException.StackTrace);
progress.Append("Inner StackTrace:");
progress.Append(ExceptionDuringMigrate.InnerException.StackTrace);
}
}
progress.FinishedImport();//just enables close / cancel etc
@@ -558,10 +564,12 @@ namespace AyaNova.PlugIn.V8
progress.Op("Saving export log to v8 memo for SuperUser...");
await PostExportLogToV8(progress);
progress.Append("\r\n************\r\nLog and help links saved in v8 Memo to SuperUser account (Home->Memos)");
progress.Append("Log and help links saved in v8 Memo to SuperUser account (Home->Memos)");
progress.Append("###################################\r\n###################################\r\n\r\nExport completed");
progress.Append("###################################");
progress.Append("###################################");
progress.Append("Export completed");
progress.Op("");
progress.SubOp("");

View File

@@ -23,7 +23,8 @@ namespace AyaNova.PlugIn.V8
public const string API_BASE_ROUTE = "api/v8/";
private const int MAX_TRIES = 3;//max times to retry an api call before giving up
private const int API_RETRY_DELAY = 3000;//pause in ms before retrying api call
public static HttpClient client = new HttpClient();
private const int HTTPCLIENT_TIMEOUT_SECONDS = 300;//default for all ops, normally 100seconds but would kill large file uploads
public static HttpClient client = null;
//url once known to be good
internal static string ApiBaseUrl { get; set; }
internal static string JWT { get; set; }
@@ -41,6 +42,13 @@ namespace AyaNova.PlugIn.V8
#region INIT / AUTH
private static void InitClient()
{
if (client != null)
{
client.Dispose();
client = null;
}
client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(HTTPCLIENT_TIMEOUT_SECONDS);
//client.Timeout = new TimeSpan(0, 0, 45);
//client.BaseAddress = new Uri(ApiBaseUrl);
@@ -384,6 +392,7 @@ namespace AyaNova.PlugIn.V8
requestMessage.Content = formContent;
HttpResponseMessage response = null;
try
{
@@ -402,7 +411,7 @@ namespace AyaNova.PlugIn.V8
var responseAsString = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
throw new Exception("POST FORMDATA error, code: "+ (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase);
throw new Exception("POST FORMDATA error, code: " + (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase);
}
else
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };