From 13d9350fdf33475107e22d09d0f2dfc794264309 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 8 Dec 2014 20:25:37 +0000 Subject: [PATCH] Add error handler for PSI failures. Support appending to an existing Procedure Set --- PROMS/DataLoader/Procedures.cs | 68 +++++++++++++++++++--------------- PROMS/DataLoader/RoFst.cs | 22 +++++++---- 2 files changed, 53 insertions(+), 37 deletions(-) diff --git a/PROMS/DataLoader/Procedures.cs b/PROMS/DataLoader/Procedures.cs index c0583c45..002295ae 100644 --- a/PROMS/DataLoader/Procedures.cs +++ b/PROMS/DataLoader/Procedures.cs @@ -188,29 +188,36 @@ namespace DataLoader { DataRow drpsi = dt.Rows[0]; string psistr = drpsi["TEXTM"].ToString(); - if (psistr != null && psistr != "") - { - StringReader strrd = new StringReader(psistr); + try + { + if (psistr != null && psistr != "") + { + StringReader strrd = new StringReader(psistr); - string sLine; - if (ci == null) ci = new ConfigInfo(null); - while ((sLine = strrd.ReadLine()) != null) - { - int indx = sLine.IndexOf(' '); - string nm = null; - string vl = null; - if (indx < 0) - nm = sLine; - else - { - nm = sLine.Substring(0, indx); - string tmpPsi = sLine.Substring(indx + 1, sLine.Length - indx - 1); - if (tmpPsi.Length > 0) tmpPsi=TextConvert.ConvertText(tmpPsi); - vl = tmpPsi; - } - ci.AddItem("PSI", nm, vl == null ? null : vl); - } - } + string sLine; + if (ci == null) ci = new ConfigInfo(null); + while ((sLine = strrd.ReadLine()) != null) + { + int indx = sLine.IndexOf(' '); + string nm = null; + string vl = null; + if (indx < 0) + nm = sLine; + else + { + nm = sLine.Substring(0, indx); + string tmpPsi = sLine.Substring(indx + 1, sLine.Length - indx - 1); + if (tmpPsi.Length > 0) tmpPsi = TextConvert.ConvertText(tmpPsi); + vl = tmpPsi; + } + ci.AddItem("PSI", nm, vl == null ? null : vl); + } + } + } + catch(Exception ex) + { + log.Warn("Failure during PSI", ex); + } } dapsi.Dispose(); } @@ -329,7 +336,7 @@ namespace DataLoader // addpart = false; //} //FrType = 0; - Console.WriteLine("'before',{0},{1},{2},{3}", SectItm == null ? "" : SectItm.DisplayNumber, parentitem.DisplayNumber, level, dicSecCount.Count > 0 ? dicSecCount[level] : 0); + //Console.WriteLine("'before',{0},{1},{2},{3}", SectItm == null ? "" : SectItm.DisplayNumber, parentitem.DisplayNumber, level, dicSecCount.Count > 0 ? dicSecCount[level] : 0); dicSecParentItem[level] = SectItm; int subSecs = drw["Sequence"].ToString().PadRight(12, ' ')[5] - 48; if (level > 0) @@ -357,7 +364,7 @@ namespace DataLoader parentitem = itm; } } - Console.WriteLine("'after',{0},{1},{2},{3}", SectItm == null ? "" : SectItm.DisplayNumber, parentitem.DisplayNumber, level, dicSecCount.Count > 0 ? dicSecCount[level] : 0); + //Console.WriteLine("'after',{0},{1},{2},{3}", SectItm == null ? "" : SectItm.DisplayNumber, parentitem.DisplayNumber, level, dicSecCount.Count > 0 ? dicSecCount[level] : 0); } dv.Dispose(); //foreach (Item secItm in dicSecParentItem.Values) @@ -395,8 +402,8 @@ namespace DataLoader // to. However, if reset, the 'oldto' may not contain a reference // to a foldout, i.e. may contain 'junk' data. Only add the // reference to the dictionary if it's a foldout. - int fromStep = drt["FROMSEQUEN"].ToString()[1] - '0'; - int toStep = drt["TOSEQUENCE"].ToString()[1] - '0'; + int fromStep = TextConvert.ConvertSeq(drt["FROMSEQUEN"].ToString())[1] - '0'; + int toStep = TextConvert.ConvertSeq(drt["TOSEQUENCE"].ToString())[1] - '0'; string foldSeq = drt["OLDTO"].ToString().Substring(0, 2); if (foldSeq[1] == 'F') { @@ -512,8 +519,8 @@ namespace DataLoader } private Item MigrateProcedures(OleDbConnection cn, string pth, DocVersion docver, bool convertProcedures, FormatInfo activeFormat) { - - Item FirstItm = null; + + Item FirstItm = docver.MyItem;// null; // Loop through Set File for each Procedure try { @@ -521,6 +528,8 @@ namespace DataLoader DataSet ds = new DataSet(); da.Fill(ds); Item FrItm = null; + if (FirstItm != null) + FrItm = ItemInfo.Get(FirstItm.ItemID).LastSibling.Get(); frmMain.pbProcMaximum = ds.Tables[0].Rows.Count; frmMain.UpdateLabels(0, 0, 0); dicSetfileEntries = new Dictionary(); // used to check for duplicate SET file info - jsj 2/11/10 @@ -528,7 +537,8 @@ namespace DataLoader frmMain.ShowSections = convertProcedures; foreach (DataRow dr in ds.Tables[0].Rows) { - if (++i > frmMain.SkipProcedures) + i++; + if (i > frmMain.SkipProcedures && (frmMain.HowManyProcedures == 0|| i <= (frmMain.SkipProcedures + frmMain.HowManyProcedures) )) { if (OKtoProcessDBF(dr, pth)) // look for duplicate SET file info - jsj 2/11/10 { diff --git a/PROMS/DataLoader/RoFst.cs b/PROMS/DataLoader/RoFst.cs index 16a1d674..c78c99b7 100644 --- a/PROMS/DataLoader/RoFst.cs +++ b/PROMS/DataLoader/RoFst.cs @@ -90,18 +90,24 @@ namespace DataLoader rofst = ROFst.MakeROFst(rodb, ab, null, fi.LastWriteTimeUtc, "Migration"); } // Next hook the rofst to the docversion using the associations table. - DocVersionAssociation dva = docver.DocVersionAssociations.Add(rofst); - AssociationConfig assoc_cfg = new AssociationConfig(); - assoc_cfg.RODefaults_graphicsprefix = img_prefix; - assoc_cfg.RODefaults_setpointprefix = sp_prefix; - dva.Config = assoc_cfg.ToString(); - docver.Save(); + bool appending = false; + if (docver.DocVersionAssociationCount == 0) + { + DocVersionAssociation dva = docver.DocVersionAssociations.Add(rofst); + AssociationConfig assoc_cfg = new AssociationConfig(); + assoc_cfg.RODefaults_graphicsprefix = img_prefix; + assoc_cfg.RODefaults_setpointprefix = sp_prefix; + dva.Config = assoc_cfg.ToString(); + docver.Save(); + rofst.Dispose(); + } + else + appending = true; rofstinfo = ROFstInfo.Get(rofst.ROFstID); // refresh the info record! - rofst.Dispose(); // Now load any images in... type 8: // Intergrated Graphics RO type ROFSTLookup mylookup = rofstinfo.GetROFSTLookup(DocVersionInfo.Get(docver.VersionID)); - if (mylookup != null) + if (!appending && mylookup != null) { for (int i = 0; i < mylookup.myHdr.myDbs.Length; i++) {