From a3af94e5014b212d9cdf406e9b19244dd2d85d8d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 20 Aug 2021 15:57:18 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 50 ++++++++++++++++++-------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 9a5f3c6..3cc816c 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -174,7 +174,7 @@ namespace AyaNova.PlugIn.V8 { if (V7ToV8IdMap.ContainsKey(v7id)) { - + //this is likely a coding issue so just throw throw new Exception("Error: AddMap - v7id already mapped previously, id is " + v7id.ToString()); } else V7ToV8IdMap.Add(v7id, v8id); @@ -184,7 +184,7 @@ namespace AyaNova.PlugIn.V8 private void Addv7v8WorkOrderItemStatusIdMap(Guid v7id, long v8id) { if (V7ToV8WorkOrderItemStatusIdMap.ContainsKey(v7id)) - throw new Exception("Error: V7ToV8WorkOrderItemStatusIdMap - v7id already mapped previously, id is " + v7id.ToString()); + throw new Exception("Error: V7ToV8WorkOrderItemStatusIdMap - v7id already mapped previously, id is " + v7id.ToString());//would be a coding issue else V7ToV8WorkOrderItemStatusIdMap.Add(v7id, v8id); } private long? Getv7v8WorkOrderItemStatusIdNullOk(Guid id) @@ -206,35 +206,34 @@ namespace AyaNova.PlugIn.V8 return false; } - private long Getv7v8IdMap(Guid id, string details) + + + private async System.Threading.Tasks.Task Getv7v8IdMap(Guid id, RootObjectTypes desiredType, bool allowPatch = true) { if (!V7ToV8IdMap.ContainsKey(id)) { - throw new Exception("Error: GetMap (source id: " + id.ToString() + ") [" + details + "] - v7 Id not previously exported, missing or corrupted source data, export can not complete until fixed"); + if (!allowPatch) + throw new Exception("Error: Getv7v8IdMap (source id: " + id.ToString() + " for type: " + desiredType.ToString() + ") was not found in v7 database and can't be substituted export can not complete until fixed"); + //not found, create a substitute record for it and put it in the map + await CreateSubstitute(id, desiredType); } return V7ToV8IdMap[id]; } - private long? Getv7v8IdMapNullOk(Guid id) + private async System.Threading.Tasks.Task Getv7v8IdMapNullOk(Guid id, RootObjectTypes desiredType, bool allowPatch = true) { if (id == Guid.Empty) return null; - - if (!V7ToV8IdMap.ContainsKey(id)) return null; - - return V7ToV8IdMap[id]; + return await Getv7v8IdMap(id, desiredType, allowPatch); } - private long SafeGetUserMap(Guid id) + private long XXSafeGetUserMap(Guid id) { if (!V7ToV8IdMap.ContainsKey(id)) return 1;//1=raven administrator account return V7ToV8IdMap[id]; } - - - private enum RavenUserType : int { Service = 1, @@ -264,7 +263,28 @@ namespace AyaNova.PlugIn.V8 private List Allv8WarehouseIds = new List(); //UNKNOWN / MISSING RECORD OBJECT STAND INs - private long UnknownV7PartId = 0;//used when there is no part id on a workorderitempart record + private long XUnknownV7PartId = 0;//used when there is no part id on a workorderitempart record + private string MissingDataNamePrefix = "zV8migrate_substitute";//append guid to ensure uniqueness + + + private async System.Threading.Tasks.Task CreateSubstitute(Guid id, RootObjectTypes desiredType) + { + //create the simplest possible version of this object desired + switch (desiredType) + { + case RootObjectTypes.Client: + { + + } + break; + default: + throw new Exception("Error: CreateSubstitute (source id: " + id.ToString() + " for type: " + desiredType.ToString() + ") THIS TYPE NOT CODED YET"); + } + } + + + + /// @@ -384,7 +404,7 @@ namespace AyaNova.PlugIn.V8 if (progress.KeepGoing) { - + goto End; }