From 66bf1783b50c8fecbe2248c0d492f4677147d297 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 19 Dec 2020 01:01:19 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 84 +++++++++++++++--------- source/Plugins/AyaNova.Plugin.V8/util.cs | 3 +- 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index ba7c490..a6c05ef 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -2169,15 +2169,18 @@ namespace AyaNova.PlugIn.V8 foreach (ScheduleMarkerListAllUsers.ScheduleMarkerListAllUsersInfo i in pl) { if (!progress.KeepGoing) return; - List tags = new List(); - tags.Add(ImportTag); + ScheduleMarker c = ScheduleMarker.GetItem(i.LT_O_ScheduleMarker.Value); - dynamic d = new JObject(); + //Many schedulemarkers may not have related records so allow for that!! if (c.IsFollowUp) { + List tags = new List(); + tags.Add(ImportTag); + dynamic d = new JObject(); + //It's a Review / followup tied to another object that should have already been migrated if (!Map.ContainsKey(c.FollowID)) { progress.Append("FollowUp target missing; skipping export: ID " +c.ID.ToString() + ",targetid "+c.FollowID.ToString() + ",type " + c.FollowType.ToString()); @@ -2186,6 +2189,7 @@ namespace AyaNova.PlugIn.V8 //export //FollowUps only ever apply to a single user in v7 so no need to split them out here it's just for one user + if (!Map.ContainsKey(c.SourceID)) { progress.Append("FollowUp User missing; skipping export: UserID " + c.SourceID.ToString()); continue; @@ -2223,47 +2227,63 @@ namespace AyaNova.PlugIn.V8 d.name = c.Name; d.notes = c.Notes; + d.userId = Map[c.SourceID]; + d.assignedByUserId = SafeGetUserMap(c.Creator); d.objectId = Map[c.FollowID]; d.objectType = util.RootObjectToAyaType(c.FollowType); - + SetTags(d, tags); + progress.Op("FollowUp " + c.ID.ToString()); + var rMainObject = await util.PostAsync("review", d.ToString()); + long RavenId = util.IdFromResponse(rMainObject); + AddMap(c.ID, RavenId); + await util.EventLog(util.AyaType.Review, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); } else { + //It's a Reminder schedulemarker + //ensure has dates + string sStartDate = util.DateToV8(c.StartDate); + string sStopDate = util.DateToV8(c.StopDate); + if (sStartDate == string.Empty || sStopDate == string.Empty) + { + progress.Append("FollowUp start or stop date missing; skipping export: ID " + c.ID.ToString() + ",targetid " + c.FollowID.ToString() + ",type " + c.FollowType.ToString()); + continue;//skip this schedulemarker entirely it's disqualified + } + + foreach (Guid gUserId in c.ScheduleableUsersMarkerAppliesTo) + { + List tags = new List(); + tags.Add(ImportTag); + dynamic d = new JObject(); + if (!Map.ContainsKey(gUserId)) + { + progress.Append("ScheduleMarker User missing; skipping export: UserID " + c.SourceID.ToString()); + continue; + } + + //completed is deprecated in v8 so to preserve that info tag the completed ones only + if (c.Completed) + tags.Add("completed.reminder"); + + d.name = c.Name; + d.notes = c.Notes; + d.userId = Map[gUserId]; + d.startDate = sStartDate; + d.stopDate = sStopDate; + SetTags(d, tags); + progress.Op("ScheduleMarker " + c.ID.ToString()); + var rMainObject = await util.PostAsync("review", d.ToString()); + long RavenId = util.IdFromResponse(rMainObject); + AddMap(c.ID, RavenId); + await util.EventLog(util.AyaType.Review, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); + } } - d.name = GetUniqueName(c.Name); - if (IsDuplicateMapItem(c.ID, c.Name, progress)) continue; - progress.Op(ObjectTypeName + " " + d.name); - d.active = c.Active; - d.notes = c.Notes; - d.dateStarted = util.DateToV8(c.DateStarted, true); - d.dateCompleted = util.DateToV8(c.DateCompleted, false); - d.accountNumber = c.AccountNumber; - d.projectOverseerId = SafeGetUserMap(c.ProjectOverseerID); - - Tagit(c.RegionID, tags); - SetTags(d, tags); - var rMainObject = await util.PostAsync("project", d.ToString()); - long RavenId = util.IdFromResponse(rMainObject); - AddMap(c.ID, RavenId); - - - //----- - bool repost = false; - d = rMainObject.ObjectResponse["data"]; - - - - //----- - - //Event log fixup - await util.EventLog(util.AyaType.Project, RavenId, SafeGetUserMap(c.Creator), SafeGetUserMap(c.Modifier), c.Created, c.Modified); - } } #endregion ScheduleMarkers diff --git a/source/Plugins/AyaNova.Plugin.V8/util.cs b/source/Plugins/AyaNova.Plugin.V8/util.cs index b071371..0a28f0f 100644 --- a/source/Plugins/AyaNova.Plugin.V8/util.cs +++ b/source/Plugins/AyaNova.Plugin.V8/util.cs @@ -438,7 +438,8 @@ namespace AyaNova.PlugIn.V8 throw new NotImplementedException("V8:util:RootObjectToAyaType -> type " + rot.ToString() + "," + specificWoType.ToString() + " is not coded yet"); } - + case biz.RootObjectTypes.Memo: + return AyaType.Memo; case biz.RootObjectTypes.Project: return AyaType.Project; case biz.RootObjectTypes.PurchaseOrder: