From 007430be3dc613e7b5642c84abc720e5a9c3d913 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 8 Dec 2014 20:26:11 +0000 Subject: [PATCH] Use new command line parameters Fixed logic to skip steps which don't match the current section --- PROMS/DataLoader/Sections.cs | 52 +++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/PROMS/DataLoader/Sections.cs b/PROMS/DataLoader/Sections.cs index 6279f53b..aa24872f 100644 --- a/PROMS/DataLoader/Sections.cs +++ b/PROMS/DataLoader/Sections.cs @@ -297,12 +297,21 @@ namespace DataLoader private int GetDocStyleIndx(string dstyleindx, FormatInfo format, Item procitem, /* DocVersion docver,*/ string Number, string Title) { int docstyle = LookupOldToNew(dstyleindx); + DocStyle ds0 = null; foreach (DocStyle ds in format.PlantFormat.DocStyles.DocStyleList) { - if ((ds.OldToNew & docstyle)>0) return (int)ds.Index; + if (ds.Index == 0) ds0 = ds; + if ((ds.OldToNew & docstyle) > 0) + { + //frmMain.AddError("--->>>\"Good\"\t\"{0}\"\t\"{1}\"\t\"{2}\"\t\"{3}\"\t\"{4}\"\t\"{5}\"", + // procitem.DisplayNumber, (Number ?? "") == "" ? Title : Number, dstyleindx, format, docstyle, ds.Name); + return (int)ds.Index; + } } frmMain.AddError("Bad OldToNew Document Style {0}:{1} dStyleIndex = '{2}'\r\n{3} - Missing OldToNew {4}", procitem.DisplayNumber, (Number ?? "") == "" ? Title : Number, dstyleindx, format, docstyle); + //frmMain.AddError("--->>>\"Bad\"\t\"{0}\"\t\"{1}\"\t\"{2}\"\t\"{3}\"\t\"{4}\"\t\"{5}\"", + // procitem.DisplayNumber, (Number ?? "") == "" ? Title : Number, dstyleindx, format, docstyle, ds0.Name); return 0; // Default is Zero } //private FormatInfo GetFormat(Item procitem, DocVersion docver) @@ -684,22 +693,35 @@ namespace DataLoader Item FrItem = null; frmMain.pbStepMaximum = dt.Rows.Count-frmMain.pbSectMaximum; int type = 6; + bool sectionShowed = false; + int firstCharSection = (int)(dr["Step"].ToString()[0]); foreach (DataRowView drv in dv) { - FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth, docver, sectFormat, secitem, type); - if (hasFloatingFoldouts && (sequence[2] == 'x' || sequence[2] == 'X')) + int firstCharStep = (int)(drv[0].ToString()[0]); + if (firstCharSection != firstCharStep) { - if (FloatingFoldoutHLS == null) FloatingFoldoutHLS = new List(); - FloatingFoldoutHLS.Add(FrItem.ItemID); + if(!sectionShowed) + Console.WriteLine("'Section','{0}','{1}','{2}',{3}", procnum,num,dr["Step"].ToString(), (int)(dr["Step"].ToString()[0])); + sectionShowed = true; + Console.WriteLine("'Skipping Step','{0}','{1}','{2}',{3}", procnum,num,drv["Step"].ToString(), (int)(drv["Step"].ToString()[0])); + } + else + { + FrItem = MigrateStep(cn, dt, drv, FrItem, conv_caret, pth, docver, sectFormat, secitem, type); + if (hasFloatingFoldouts && (sequence[2] == 'x' || sequence[2] == 'X')) + { + if (FloatingFoldoutHLS == null) FloatingFoldoutHLS = new List(); + FloatingFoldoutHLS.Add(FrItem.ItemID); + } + type = 0; // Only add ContentPart for first child + //if (secitem.MyContent.ContentParts.Count == 0) + //{ + // // type 6 is step + // secitem.MyContent.ContentParts.Add(6, FrItem); + // if (!secitem.MyContent.IsSavable) ErrorRpt.ErrorReport(secitem.MyContent); + // secitem.MyContent.Save(); + //} } - type = 0; // Only add ContentPart for first child - //if (secitem.MyContent.ContentParts.Count == 0) - //{ - // // type 6 is step - // secitem.MyContent.ContentParts.Add(6, FrItem); - // if (!secitem.MyContent.IsSavable) ErrorRpt.ErrorReport(secitem.MyContent); - // secitem.MyContent.Save(); - //} } dv.Dispose(); } @@ -803,12 +825,12 @@ namespace DataLoader switch (ex.Message) { case "Index file not found.":// then delete inf file - fi = new FileInfo(frmMain.MySettings.ProcedureSetPath + "\\" + FileName + ".inf"); + fi = new FileInfo(frmMain.ProcedureSetPath + "\\" + FileName + ".inf"); fi.Delete(); LoadSection(ds, da, FileName);// Try Again break; case "External table is not in the expected format.": // then pad dbt file with 128 zeros. - fi = new FileInfo(frmMain.MySettings.ProcedureSetPath + "\\" + FileName + ".dbt"); + fi = new FileInfo(frmMain.ProcedureSetPath + "\\" + FileName + ".dbt"); FileStream fs = fi.OpenWrite(); fs.Position = fs.Length; byte[] buf = new byte[128];