diff --git a/PROMS/DataLoader/ConfigInfo.cs b/PROMS/DataLoader/ConfigInfo.cs index 59fa4d05..73e17f7c 100644 --- a/PROMS/DataLoader/ConfigInfo.cs +++ b/PROMS/DataLoader/ConfigInfo.cs @@ -69,6 +69,12 @@ namespace DataLoader } return false; } + + public int ItemCount + { + get { return xmldoc.DocumentElement.ChildNodes.Count; } + } + public override string ToString() { if (xmldoc != null) return xmldoc.InnerXml; diff --git a/PROMS/DataLoader/Steps.cs b/PROMS/DataLoader/Steps.cs index 01996569..b3695564 100644 --- a/PROMS/DataLoader/Steps.cs +++ b/PROMS/DataLoader/Steps.cs @@ -22,16 +22,22 @@ namespace DataLoader Item item = null; frmMain.UpdateLabels(0, 0, 1); - ConfigInfo ci = null; + ConfigInfo ci = new ConfigInfo(null); string stptext = null; if (userid == null || userid == "") userid = "Migration"; int tok = -1; - char[] chrarr = { '\x1', '\x2', '\x3', '\x5' }; + //char[] chrarr = { '\x1', '\x2', '\x3', '\x5' }; + char[] chrarr = { '\x1', '\x2', '\x3' }; try { // the textm field has step text, but also may have other text stored // with it with a 'token' as a separator (see below). tok = Textm.IndexOfAny(chrarr); + + // This will find a continuous action flag without finding a hanging indent + if (tok == 0 && Textm[Textm.Length - 1] == '\x5') + tok = Textm.Length - 1; + if (tok < 0) stptext = TextConvert.ConvertText(Textm, conv_caret); else @@ -52,7 +58,7 @@ namespace DataLoader if (cbittst != ' ' && (cbittst & 0x80) > 1) { ManualPagebreak = true; - if (ci == null) ci = new ConfigInfo(null); + //if (ci == null) ci = new ConfigInfo(null); ci.AddItem("Step", "ManualPagebreak", "True"); newstptyp = StepType.Substring(1, 1); } @@ -148,7 +154,10 @@ namespace DataLoader // '\2' multiple change ids and/or change message // '\3' linked sequence // '\3\3'override tab - // '\5' continuous action summary flag + // '\5' continuous action summary flag (only if last char in string) + // This assumes that these tokens are stored in reverse order that + // they are processed. + bool recdirty = false; try @@ -159,56 +168,45 @@ namespace DataLoader string tkstring = Textm.Substring(tok); int nxttok = 0; - char chr = tkstring[nxttok]; - int typ = 0; - if (chr == '\x5') // Continuous Action Summary + if (tkstring[tkstring.Length - 1] == '\x5') // Continuous Action Summary { recdirty = true; - if (ci == null) ci = new ConfigInfo(null); + //if (ci == null) ci = new ConfigInfo(null); ci.AddItem("Step", "ContActSum", "True"); - tkstring = tkstring.Substring(0,nxttok); - nxttok = tkstring.IndexOfAny("\x3\x2\x1".ToCharArray()); - if (nxttok > -1) - chr = tkstring[nxttok]; + tkstring = tkstring.Substring(0, tkstring.Length - 1); // strip off Continuous Action Token } - if (chr == '\x3') //Linked Sequence or Step Override Tab (two '\x3') + + if ((nxttok = tkstring.IndexOf("\x3\x3")) > -1) // Enhanced Override Tab { - string strn = null; - typ = STP_LNK_SEQ; - if (((nxttok + 1) <= tkstring.Length) && tkstring[nxttok + 1] == '\x3') - { - typ = STP_OVR_TAB; - strn = tkstring.Substring(nxttok + 2); - } - else - strn = TextConvert.ConvertSeq(tkstring.Substring(nxttok + 1)); - if (strn != null && strn != "") - { - recdirty = true; - content.ContentDetails.Add(typ, strn); - } - tkstring = tkstring.Substring(0,nxttok); - nxttok = tkstring.IndexOfAny("\x2\x1".ToCharArray()); - if (nxttok > -1) - chr = tkstring[nxttok]; + Console.WriteLine("Override Tab: {0}", tkstring.Substring(nxttok + 1)); + ci.AddItem("Step", "OverrideTab", tkstring.Substring(nxttok + 2)); + recdirty = true; + //recdirty |= AddContentDetail(content, STP_OVR_TAB, tkstring.Substring(nxttok + 2)); + tkstring = tkstring.Substring(0, nxttok); } - if (chr == '\x2') // Multiple Change Ids + + if ((nxttok = tkstring.IndexOf("\x3")) > -1) //Linked Sequence { - typ = STP_MULT_CHGID; - string strn = tkstring.Substring(nxttok+1); - if (strn != null && strn != "") - { - recdirty = true; - content.ContentDetails.Add(typ, strn); - } - tkstring = tkstring.Substring(0,nxttok); - nxttok = 0; // tkstring.IndexOf('\x1'); - if ((tkstring != null) && (tkstring.Length > 0)) - chr = tkstring[nxttok]; + Console.WriteLine("Linked Seq: {0}", tkstring.Substring(nxttok + 1)); + ci.AddItem("Step", "LinkedSeq", TextConvert.ConvertSeq(tkstring.Substring(nxttok + 1))); + recdirty = true; + //recdirty |= AddContentDetail(content, STP_LNK_SEQ, TextConvert.ConvertSeq(tkstring.Substring(nxttok + 1))); + tkstring = tkstring.Substring(0, nxttok); } - if (chr == '\x1') // Comment + + if ((nxttok = tkstring.IndexOf("\x2")) > -1) // Multiple Change Ids + { + Console.WriteLine("Multiple Change ID: {0}", tkstring.Substring(nxttok + 1)); + ci.AddItem("Step", "MultipleChangeID", tkstring.Substring(nxttok + 1)); + recdirty = true; + //recdirty |= AddContentDetail(content, STP_MULT_CHGID, tkstring.Substring(nxttok + 1)); + tkstring = tkstring.Substring(0, nxttok); + } + + if ((nxttok = tkstring.IndexOf("\x1")) > -1) // Comment { // add the comment to annotation table. Set type to comment. + Console.WriteLine("Comment text: {0}", tkstring.Substring(nxttok + 1)); Annotation annot = Annotation.MakeAnnotation(item, CommentType, null, tkstring.Substring(nxttok + 1), null, dts, userid); } } @@ -219,7 +217,7 @@ namespace DataLoader { recdirty = true; string chkindx = Recid[0].ToString(); - if (ci == null) ci = new ConfigInfo(null); + //if (ci == null) ci = new ConfigInfo(null); ci.AddItem("Step", "CheckOffIndex", chkindx); } @@ -232,7 +230,7 @@ namespace DataLoader // if checkoffs or the continuous action summary flag, save the xml. if (recdirty) { - if (ci != null) content.Config = ci.ToString(); + if (ci.ItemCount != 0) content.Config = ci.ToString(); if (!content.IsSavable) ErrorRpt.ErrorReport(content); content.Save(); } @@ -246,6 +244,17 @@ namespace DataLoader } return item; } + + //private static bool AddContentDetail(Content content, int type, string strn) + //{ + // if (strn != null && strn.Trim() != "" ) + // { + // content.ContentDetails.Add(type, strn); + // return true; + // } + // return false; + //} + private string GetParent(string s) { string retval = "S";