This commit is contained in:
2020-04-28 18:53:00 +00:00
parent c239ae57f4
commit 27a6edca44
2 changed files with 70 additions and 58 deletions

View File

@@ -156,6 +156,13 @@ namespace AyaNova.PlugIn.V8
/// then zip it all up into a single archive file and then erase the temporary folder /// then zip it all up into a single archive file and then erase the temporary folder
/// </summary> /// </summary>
private async void DoExport() private async void DoExport()
{
//Show progress form
ProgressForm progress = new ProgressForm();
progress.Show();
progress.StartedImport();
progress.Append("Exporting data to AyaNova server @ " + util.ApiBaseUrl);
try
{ {
Map.Clear(); Map.Clear();
@@ -167,18 +174,13 @@ namespace AyaNova.PlugIn.V8
*/ */
//Show progress form
ProgressForm progress = new ProgressForm();
progress.Show();
progress.StartedImport();
progress.Append("Exporting data to AyaNova server @ " + util.ApiBaseUrl);
//Export in correct order: //Export in correct order:
//ERASE DB //ERASE DB
var a = await util.PostAsync("License/PermanentlyEraseAllData", "I understand"); var a = await util.PostAsync("License/PermanentlyEraseAllData", "\"I understand\"");
if (!a.HttpResponse.IsSuccessStatusCode) { MessageBox.Show("Error erasing database: \n" + a.HttpResponse.ReasonPhrase); return; } if (!a.HttpResponse.IsSuccessStatusCode) { MessageBox.Show("Error erasing database: \n" + a.HttpResponse.ReasonPhrase); return; }
//TAGS //TAGS
@@ -208,6 +210,12 @@ namespace AyaNova.PlugIn.V8
progress.Append("Export completed"); progress.Append("Export completed");
}
catch (Exception ex)
{
progress.Append("Export failed with error:");
progress.Append(ex.Message);
}
progress.FinishedImport(); progress.FinishedImport();
//----------------------------------- //-----------------------------------

View File

@@ -150,6 +150,10 @@ namespace AyaNova.PlugIn.V8
HttpResponseMessage response = await client.SendAsync(requestMessage); HttpResponseMessage response = await client.SendAsync(requestMessage);
var responseAsString = await response.Content.ReadAsStringAsync(); var responseAsString = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
throw new Exception(responseAsString + "\n" + response.ReasonPhrase);
}
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) }; return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
} }