From e8033fe6d4d6032a02d582cb7f5bbca970fb07ea Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 27 Sep 2012 10:26:36 +0000 Subject: [PATCH] --- PROMS/DataLoader/Procedures.cs | 53 ++++++++++++++++++++++++++++++++++ PROMS/DataLoader/Sections.cs | 19 ++++++++++-- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/PROMS/DataLoader/Procedures.cs b/PROMS/DataLoader/Procedures.cs index 8c347dd0..fc48db5c 100644 --- a/PROMS/DataLoader/Procedures.cs +++ b/PROMS/DataLoader/Procedures.cs @@ -303,6 +303,59 @@ namespace DataLoader } } ds.Dispose(); + + // if there are any floating foldouts & associated steps, set config on steps for foldout association. + // the free the lists for the next procedure: + if (FoldoutStpSeq != null && FoldoutStpSeq.Count>0) + { + string cmd = "SELECT * FROM [tran] WHERE [FROMNUMBER]='" + ProcNumber.Replace("'", "''") + "' AND [TYPE] ='R'"; + OleDbDataAdapter da = new OleDbDataAdapter(cmd, cn); + // get transition records for this step. + ds = new DataSet(); + try + { + da.Fill(ds); + DataTable dtt = ds.Tables[0]; + dtt.CaseSensitive = true; + Dictionary stpFoldSeq = new Dictionary(); + foreach (DataRow drt in dtt.Rows) + { + // get from/to seq, subtract off '0' to get stepnumber. + int fromStep = drt["FROMSEQUEN"].ToString()[1] - '0'; + int toStep = drt["TOSEQUENCE"].ToString()[1] - '0'; + string foldSeq = drt["OLDTO"].ToString().Substring(0, 2); + for (int istp = fromStep; istp <= toStep; istp++) + stpFoldSeq.Add(istp, foldSeq); + } + ds.Dispose(); + da.Dispose(); + // now read in the HLS's and set their config to the appropriate foldout: + int cnt = 1; + foreach (int hlsItemId in FloatingFoldoutHLS) + { + using (Item itmF = Item.Get(hlsItemId)) + { + string fldstr = stpFoldSeq[cnt]; + int fldItemId = FoldoutStpSeq[fldstr]; + ConfigInfo ciFold = new ConfigInfo(itmF.MyContent.Config); + ciFold.AddItem("Step", "FloatingFoldout", fldItemId.ToString()); + itmF.MyContent.Config = ciFold.ToString(); + itmF.Save(); + } + } + } + catch (Exception ex) + { + frmMain.AddError(ex, "Error resolving Floating Foldout Data '{0}'", ProcNumber); + log.Error("Error resolving Floating Foldout Data"); + log.ErrorFormat("from number = {0}", ProcNumber); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + ds.Dispose(); + da.Dispose(); + } + } + if (FoldoutStpSeq!=null) FoldoutStpSeq.Clear(); + if (FloatingFoldoutHLS!=null) FloatingFoldoutHLS.Clear(); //Console.WriteLine("End MigrateProcedure number {0}", number); //Console.WriteLine("End MigrateProcedure Item Key {0} List {1}", Item.CacheCountPrimaryKey, Item.CacheCountList); //Console.WriteLine("End MigrateProcedure ItemInfo Key {0} List {1}", ItemInfo.CacheCountPrimaryKey, ItemInfo.CacheCountList); diff --git a/PROMS/DataLoader/Sections.cs b/PROMS/DataLoader/Sections.cs index 3a4583db..3ad121c6 100644 --- a/PROMS/DataLoader/Sections.cs +++ b/PROMS/DataLoader/Sections.cs @@ -394,7 +394,9 @@ namespace DataLoader get { return Loader._OverrideColor; } set { Loader._OverrideColor = value; } } - + private bool hasFloatingFoldouts = false; + private Dictionary FoldoutStpSeq = null; + private List FloatingFoldoutHLS = null; private Item MigrateSection(Item procitem, string procnum, OleDbConnection cn, DataRowView dr, DataTable dt, Item FromItem, bool hasSubSection, string pth, DocVersion docver, FormatInfo activeFormat,Content cont) { Int32 thesectid = 0; @@ -427,12 +429,14 @@ namespace DataLoader { ismulti = sectFormat.PlantFormat.FormatData.SectData.StepSectionData.UseMultiLineSectionTitle; conv_caret = sectFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta; + hasFloatingFoldouts = sectFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout; } if (fmt != null && fmt != "") if (fmt == docverFormat.Name) fmt = null; string title = SectTitle(cn, dr, ismulti, conv_caret); string init = dr["initials"].ToString().Trim(); string sequence = dr["CSequence"].ToString().PadRight(10); string step = dr["CStep"].ToString(); + int libDocid = 0; DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString()); @@ -563,6 +567,11 @@ namespace DataLoader //Console.WriteLine("After AddSection"); if (secitem == null) throw (new Exception("Null parameter in AddSection")); + if (hasFloatingFoldouts) + { + if (FoldoutStpSeq == null) FoldoutStpSeq = new Dictionary(); + if (step[1] == 'F') FoldoutStpSeq.Add(step, secitem.ItemID); + } if (cont != null) { // ContentsParts.Add can use 'fromtype', item - fromtype here = 2, section @@ -621,6 +630,11 @@ namespace DataLoader 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')) + { + if (FloatingFoldoutHLS == null) FloatingFoldoutHLS = new List(); + FloatingFoldoutHLS.Add(FrItem.ItemID); + } type = 0; // Only add ContentPart for first child //if (secitem.MyContent.ContentParts.Count == 0) //{ @@ -634,6 +648,7 @@ namespace DataLoader } return secitem; } + private void LoadSection(DataSet ds, OleDbDataAdapter da, string FileName) { try @@ -648,13 +663,13 @@ namespace DataLoader { drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString()); drw["CSequence"] = TextConvert.ConvertSeq(drw["Sequence"].ToString()); + } dt.Columns.Add("StepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CStep,2,1),'System.Char'),'System.Int32')-48"); dt.Columns.Add("Level", System.Type.GetType("System.Int32"), "Len(CSequence)"); dt.Columns.Add("SubStepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,Len(CSequence),1),'System.Char'),'System.Int32')-48"); dt.Columns.Add("locb", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,2,1),'System.Char'),'System.Int32')-48"); } - catch (Exception ex) { FileInfo fi;