This commit is contained in:
2021-08-19 18:15:03 +00:00
parent 70a85fdadd
commit fe4f624b3c
2 changed files with 60 additions and 11 deletions

View File

@@ -278,6 +278,7 @@ namespace AyaNova.PlugIn.V8
progress.StartedImport();
progress.Append("Exporting data to AyaNova server @ " + util.ApiBaseUrl);
progress.Append(util.PRE_RELEASE_VERSION_STRING);
Exception ExceptionDuringMigrate = null;
try
{
progress.Op("Preparing to export....");
@@ -396,21 +397,25 @@ namespace AyaNova.PlugIn.V8
//MIGRATE MODE
progress.Append("Setting v8 Server State to 'Open'");
await util.PostAsync("server-state", "{\"serverState\":\"Open\"}");
}
catch (Exception ex)
{
ExceptionDuringMigrate = ex;//can't await in a catch block so this is done this way so can send memo about error to v8
}
if (ExceptionDuringMigrate != null)
{
progress.Append("ERROR, During operation: \n" + progress.LastOp + "\n" + progress.LastSubOp);
progress.Append("\n************\nExport failed with error:\n");
progress.Append(ex.Message);
progress.Append("stack:\n" + ex.StackTrace);
}
finally
{
PostExportLogToV8(progress).Wait();
progress.FinishedImport();
progress.Append(ExceptionDuringMigrate.Message);
progress.Append("stack:\n" + ExceptionDuringMigrate.StackTrace);
}
progress.Op("Saving export log to v8 memo for SuperUser...");
await PostExportLogToV8(progress);
progress.Append("Log and help links saved in v8 Memo to SuperUser account (Home->Memos)");
progress.FinishedImport();
//-----------------------------------
//endof method
@@ -514,7 +519,7 @@ namespace AyaNova.PlugIn.V8
d.viewed = false;
d.wiki = null;
//await util.PostAsync("memo",
await util.PostAsync("memo", d.ToString());
}
catch (Exception ex)
{
@@ -3812,8 +3817,19 @@ namespace AyaNova.PlugIn.V8
}
*/
d.active = c.WorkorderPreventiveMaintenance.Active;
//sanity check to prevent runaway generations
DateTime dtNow = DateTime.UtcNow;
DateTime dtGenBefore = util.GetDateFromSpanAndUnit(dtNow, c.WorkorderPreventiveMaintenance.ThresholdSpanUnit, c.WorkorderPreventiveMaintenance.ThresholdSpan);
DateTime dtRepeat = util.GetDateFromSpanAndUnit(dtNow, c.WorkorderPreventiveMaintenance.GenerateSpanUnit, c.WorkorderPreventiveMaintenance.GenerateSpan);
if (!(dtGenBefore < dtRepeat) && c.WorkorderPreventiveMaintenance.Active == true)
{
//it's a runaway configuration, log and set inactive
d.active = false;
progress.Append("ACTION REQUIRED: PM " + c.WorkorderPreventiveMaintenance.PreventiveMaintenanceNumber.ToString()
+ " needs attention and will be set to inactive in v8. Edit in v8 and re-save to fix. (Generate before / Threshold span is too short)");
}
else
d.active = c.WorkorderPreventiveMaintenance.Active;
d.nextServiceDate = util.DateToV8(c.WorkorderPreventiveMaintenance.NextServiceDate, true);
d.repeatUnit = (int)c.WorkorderPreventiveMaintenance.GenerateSpanUnit;
d.generateBeforeUnit = (int)c.WorkorderPreventiveMaintenance.ThresholdSpanUnit;

View File

@@ -847,6 +847,39 @@ Locale Français is customized [signature: 804154061] exporting
}
}
public static DateTime GetDateFromSpanAndUnit(DateTime StartDate, GZTW.AyaNova.BLL.AyaUnitsOfTime unit, int multiple)
{
switch (unit)
{
case GZTW.AyaNova.BLL.AyaUnitsOfTime.Seconds:
return StartDate.AddSeconds(multiple);
case GZTW.AyaNova.BLL.AyaUnitsOfTime.Minutes:
return StartDate.AddMinutes(multiple);
case GZTW.AyaNova.BLL.AyaUnitsOfTime.Hours:
return StartDate.AddHours(multiple);
case GZTW.AyaNova.BLL.AyaUnitsOfTime.Days:
return StartDate.AddDays(multiple);
case GZTW.AyaNova.BLL.AyaUnitsOfTime.Weeks:
throw new System.NotSupportedException("GetDateFromSpanAndUnit: Weeks not supported");
case GZTW.AyaNova.BLL.AyaUnitsOfTime.Months:
return StartDate.AddMonths(multiple);
case GZTW.AyaNova.BLL.AyaUnitsOfTime.Years:
return StartDate.AddYears(multiple);
}
//fail safe:
return StartDate;
}
#endregion
}//eoc