diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index d4efb7c..ddf2a83 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -35,7 +35,7 @@ namespace AyaNova.PlugIn.V8 public string PluginVersion { - get { return "7.6.1-alpha.122.D"; } + get { return "7.6.1-alpha.123"; } } public string About @@ -403,7 +403,7 @@ namespace AyaNova.PlugIn.V8 progress.Append("\n************\nExport failed with error:\n"); progress.Append(ex.Message); progress.Append("stack:\n" + ex.StackTrace); - + } finally { @@ -470,13 +470,45 @@ namespace AyaNova.PlugIn.V8 UsedUserNames.Clear(); } + /* + { + "memo": { + "concurrency": 0, + "customFields": "{}", + "fromId": 1, + "fromName": null, + "id": 0, + "name": "V8 Migrate - post migrate log and instructions", + "notes": "Hello, this is an automated memo from the v8 migrate utility.\n\nHelpful information:\n\nChanges in AyaNova 8 for users:\nhttp://localhost:7575/docs/ay-start-changes-from-v7/\n\nTechnical changes in AyaNova 8 for system administrators:\nhttp://localhost:7575/docs/ops-technical-changes-from-v7/\n\nImporting guide and recommended post import steps:\nhttp://localhost:7575/docs/ay-biz-admin-import-v7/\n\n\nLog:\n-----\nLOG FILE HERE\n----", + "replied": false, + "sent": "2021-08-19T17:03:39.190Z", + "tags": [], + "toId": 1, + "viewed": false, + "wiki": null + }, + "users": [ + 1 + ] + } + */ private async System.Threading.Tasks.Task PostExportLogToV8(ProgressForm progress) { try { - await util.PostAsync("memo", + dynamic d = new JObject(); + d.fromId = 1; + d.toId=1; + d.name = "V8 Migrate - post migrate log and instructions"; + d.notes = $"Hello, this is an automated memo from the v8 migrate utility.\n\nHelpful information:\n\nChanges in AyaNova 8 for users:\nhttp://localhost:7575/docs/ay-start-changes-from-v7/\n\nTechnical changes in AyaNova 8 for system administrators:\nhttp://localhost:7575/docs/ops-technical-changes-from-v7/\n\nImporting guide and recommended post import steps:\nhttp://localhost:7575/docs/ay-biz-admin-import-v7/\n\n\nLog:\n-----\nLOG FILE HERE\n----"; + d.replied = false; + d.sent = util.DateToV8(DateTime.UtcNow.ToString("o", System.Globalization.CultureInfo.InvariantCulture)); + d.viewed=false; + d.wiki=null; + + //await util.PostAsync("memo", } - catch(Exception ex) + catch (Exception ex) { progress.Append("Error attempting to post migrate log to v8 superuser memo:\n" + ex.Message); } @@ -3759,6 +3791,20 @@ namespace AyaNova.PlugIn.V8 break; } + /* vet this record and if it would fail this rule then preset as inactive and put a warning into the export log + //GenerateBefore MUST be less than Repeat Interval or bad things happen + //normalizing to dates makes this easier + var dtNow = DateTime.UtcNow; + var dtGenBefore = CalculateNewDateFromSpanAndUnit(dtNow, proposedObj.GenerateBeforeUnit, proposedObj.GenerateBeforeInterval); + var dtRepeat = CalculateNewDateFromSpanAndUnit(dtNow, proposedObj.RepeatUnit, proposedObj.RepeatInterval); + if (!(dtGenBefore < dtRepeat)) + { + //NOTE: this is directly tied to v8 migrate so do not change this without changing v8migrate pm export as well + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "GenerateBeforeInterval", await Translate("ErrorGenBeforeTooSmall")); + } + */ + + d.active = c.WorkorderPreventiveMaintenance.Active; d.nextServiceDate = util.DateToV8(c.WorkorderPreventiveMaintenance.NextServiceDate, true); d.repeatUnit = (int)c.WorkorderPreventiveMaintenance.GenerateSpanUnit; @@ -3767,6 +3813,8 @@ namespace AyaNova.PlugIn.V8 d.generateBeforeInterval = c.WorkorderPreventiveMaintenance.ThresholdSpan; d.stopGeneratingDate = util.DateToV8(c.WorkorderPreventiveMaintenance.StopGeneratingDate); + + var client = c.uiClient; if (client != null) { @@ -3789,7 +3837,7 @@ namespace AyaNova.PlugIn.V8 SetTags(d, tags); util.ApiResponse rMainObject = null; rMainObject = await util.PostAsync("pm", d.ToString()); - + long RavenId = util.IdFromResponse(rMainObject); Addv7v8IdMap(c.ID, RavenId);