From 1cc722cb67ed1463d02b5116e288d91ddc8bf7bb Mon Sep 17 00:00:00 2001 From: John Date: Wed, 12 Jun 2013 19:00:37 +0000 Subject: [PATCH] Fixed logic to handle a user (sub) format as the procedure set default format added more robust logic to handle outside transitions supporting logic to add an additional annotation when multiple possibilities for an outside transition is possible --- PROMS/DataLoader/CurSet.cs | 2 ++ PROMS/DataLoader/OutsideTransition.cs | 52 ++++++++++++++++++++++++--- PROMS/DataLoader/Transitions.cs | 2 +- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/PROMS/DataLoader/CurSet.cs b/PROMS/DataLoader/CurSet.cs index 8d6a1b80..efb380ad 100644 --- a/PROMS/DataLoader/CurSet.cs +++ b/PROMS/DataLoader/CurSet.cs @@ -107,6 +107,8 @@ namespace Utils cfg.Print_UserFormat = ReadTheString(br, 10); //tmpsbyte = br.ReadSByte(); //cfg.Print_Duplex = tmpsbyte == 0 ? true : false; + if (cfg.Print_UserFormat.Trim() != string.Empty) + DefaultPlantFmt += " " + cfg.Print_UserFormat; br.Close(); } catch(Exception e) diff --git a/PROMS/DataLoader/OutsideTransition.cs b/PROMS/DataLoader/OutsideTransition.cs index 5c861919..ec7b0227 100644 --- a/PROMS/DataLoader/OutsideTransition.cs +++ b/PROMS/DataLoader/OutsideTransition.cs @@ -30,8 +30,10 @@ namespace DataLoader _TranLookup = new Dictionary(); } - public ItemInfo GetItem(string key) + private List _MigrationErrors; + public ItemInfo GetItem(string key, List migrationErrors) { + _MigrationErrors = migrationErrors; if (!_TranLookup.ContainsKey(key)) _TranLookup.Add(key, Find(key)); return _TranLookup[key]; @@ -45,10 +47,10 @@ namespace DataLoader string proc = GetProc(setid, procid);// Get procedure number from XTPROCID return Find(path,proc);// Return ItemInfo based upon path and procedure number } - + private ItemInfo Find(string path, string proc) { - return OTLookup.Find(path, proc); + return OTLookup.Find(path, proc,_MigrationErrors); } private string GetProc(string setid, string procid) @@ -86,6 +88,14 @@ namespace DataLoader DataTable dt = ds.Tables[0]; dt.CaseSensitive = true; DataRow dr = dt.Rows[0]; // there should be only one entry! + // if there are more than one entry use the first legitimate entry + // for NSP we found multiple "FIRST RECORD"s in numerious XTSETID.DBF files + if (dt.Rows.Count > 1) + { + int irow = 0; + while (irow < dt.Rows.Count-1 && dt.Rows[irow]["PLANTTITLE"].ToString() == "FIRST RECORD") irow++; + dr = dt.Rows[irow]; + } string retval = dr["Path"].ToString(); da.Dispose(); ds.Dispose(); @@ -214,9 +224,12 @@ namespace DataLoader internal static class OTLookup { + public static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static Dictionary _Lookup = null; - public static ItemInfo Find(string path, string procnum) + static List _MigrationErrors; + public static ItemInfo Find(string path, string procnum, List migrationErrors) { + _MigrationErrors = migrationErrors; string key = string.Format(@"{0}\{1}",path,procnum); if (_Lookup == null) _Lookup = new Dictionary(); @@ -257,6 +270,26 @@ namespace DataLoader if (path.ToUpper().EndsWith("ABBYPROC")) return PartialMatch(path + ".prc"); } + // if we cannot find a match using two folders, simple use one + partial = GetPartial2(path); + if (partial != null) + { + DocVersionInfo match = null; + foreach (DocVersionInfo dvi in _DocVersions) + { + if (dvi.MyFolder.Title.ToUpper().EndsWith(partial.ToUpper())) + { + if (match == null) + match = dvi; + else + { + _MyLog.WarnFormat("Duplicate external paths found for path '{0}'", path); + _MigrationErrors.Add(string.Format("Duplicate external paths found for path '{0}'", path)); + } + + } + } + } return null; } private static string GetPartial(string path) @@ -270,6 +303,17 @@ namespace DataLoader else return null; } + private static string GetPartial2(string path) + { + //Console.WriteLine(string.Format("GetPartial path = {0}",path)); + if (path.Contains("\\")) + { + string[] parts = path.Split("\\".ToCharArray()); + return "\\" + parts[parts.Length - 1]; + } + else + return null; + } private static DocVersionInfo ExactMatch(string path) { foreach (DocVersionInfo dvi in _DocVersions) diff --git a/PROMS/DataLoader/Transitions.cs b/PROMS/DataLoader/Transitions.cs index 7beae8a3..9449a0b4 100644 --- a/PROMS/DataLoader/Transitions.cs +++ b/PROMS/DataLoader/Transitions.cs @@ -84,7 +84,7 @@ namespace DataLoader Item toItem2 = null; if (itype == 6) // Outside Transition { - ItemInfo tmp = _OutTran.GetItem(thekey); + ItemInfo tmp = _OutTran.GetItem(thekey, migrationErrors); if (tmp != null) toItem = tmp.Get(); else