diff --git a/PROMS/DataLoader/Loader.cs b/PROMS/DataLoader/Loader.cs index 5d9b6e32..96b47dd0 100644 --- a/PROMS/DataLoader/Loader.cs +++ b/PROMS/DataLoader/Loader.cs @@ -45,6 +45,7 @@ namespace DataLoader public Folder sysFolder; public AnnotationType CommentType; // this holds the annotationtype of comment for future use public AnnotationType MigrationErrorType; // this holds the annotationtype of Migration Error for future use + public AnnotationType VerificationRequiredType; // Using this to flag table to grid conversions public Document MissingDocument = null; // make a document if there is a missing rtf file // any missing will use this. private Content TransDummyCont; @@ -106,7 +107,8 @@ namespace DataLoader AnnotationType at = AnnotationType.MakeAnnotationType("Reference", null); at = AnnotationType.MakeAnnotationType("Action Items", null); - at = AnnotationType.MakeAnnotationType("Verification Required", null); + //at = AnnotationType.MakeAnnotationType("Verification Required", null); + VerificationRequiredType = AnnotationType.MakeAnnotationType("Verification Required", null); at = AnnotationType.MakeAnnotationType("Volian Comment", null); frmMain.Status = "Load veproms.ini"; diff --git a/PROMS/DataLoader/Steps.cs b/PROMS/DataLoader/Steps.cs index 5fdb791c..7bef8804 100644 --- a/PROMS/DataLoader/Steps.cs +++ b/PROMS/DataLoader/Steps.cs @@ -22,8 +22,6 @@ namespace DataLoader { //if (ProcNumber + "|" + stpseq == "082-002CD|A=S") // Console.WriteLine("here"); - //if (stpseq == "A;S#") - // Console.WriteLine("here"); Content content = null; Item item = null; @@ -76,11 +74,14 @@ namespace DataLoader // Before we save it, handle RO & Transitions tokens. int tokrt = Textm.IndexOf('\x15'); bool txtdirty = false; + bool bIsROTable = false; if (tokrt > -1) { txtdirty = true; stptext = MigrateRos(cn, stptext, seqcvt, content, docver, conv_caret); stptext = stptext.TrimEnd(" ".ToCharArray()); + // if this is a table RO, then save a flag in the config + bIsROTable = (Textm.Length == 1); } tokrt = Textm.IndexOf('\x3a6'); if (tokrt > -1) @@ -107,7 +108,7 @@ namespace DataLoader //string fixStpText = FixStepText(stptext,content.Type); string fixStpText = ""; if (IsATable(content.Type)) - fixStpText = ConvertTableToGrid(stptext,content,fmt); + fixStpText = ConvertTableToGrid(stptext, content, fmt, bIsROTable); else fixStpText = FixStepText(stptext); if (fixStpText != stptext) @@ -124,7 +125,7 @@ namespace DataLoader List migrationerrors = null; if (_ContentMigrationErrors.ContainsKey(content.ContentID)) migrationerrors = _ContentMigrationErrors[content.ContentID]; - content.Save(); + content = content.Save(); // check if already created thru new during transition migration... if (dicTrans_ItemIds.ContainsKey(ProcNumber + "|" + seqcvt)) { @@ -134,13 +135,22 @@ namespace DataLoader item.DTS = dts; item.UserID = userid; if (!item.IsSavable) ErrorRpt.ErrorReport(item); - item.Save(); + item = item.Save(); dicTrans_ItemIds.Remove(ProcNumber + "|" + seqcvt); dicTrans_MigrationErrors.Remove(ProcNumber + "|" + seqcvt); } else item = Item.MakeItem(FromItem, content, content.DTS, content.UserID); + // If we converted a Table to a Grid, then insert an Annotation to alert the user to verify it + if (IsATable(content.Type))//item.MyContent.MyGrid != null) + { + ItemAnnotation ia = item.ItemAnnotations.Add(VerificationRequiredType); + ia.SearchText = "Verify Table Conversion"; + ia.UserID = "Migration"; + item.Save(); + } + if (frType > 0) { parentItem.MyContent.ContentParts.Add(frType, item); @@ -305,23 +315,19 @@ namespace DataLoader return stepText; } - //private Font GridFont = new Font("Courier New", 10); - - //private Regex _RemoveComments = new Regex(@"\\v .*?\\v0 "); private Regex _RemoveComments = new Regex(@"\\v .*?\\v0( |$)"); - private string ConvertTableToGrid(string stepText, Content content, FormatInfo fmt) + private string ConvertTableToGrid(string stepText, Content content, FormatInfo fmt, bool isROTable) { string savethis = stepText; string strGrid = ""; VlnFlexGrid grd = new VlnFlexGrid(1, 1); - //VE_Font vefont = content.MyFormat.PlantFormat.FormatData.StepDataList.Table.Font; + grd.IsRoTable = isROTable; VE_Font vefont = fmt.PlantFormat.FormatData.StepDataList.Table.Font; Font GridFont = new Font(vefont.Family, (float)vefont.Size); grd.Font = GridFont; // this also changes the default Row Height "Rows.DefaultSize" stepText = FixStepText(stepText); stepText = stepText.Replace(@"\u8209?", "-"); - stepText = stepText.Replace(@"\u9474?", "|"); - stepText = stepText.Replace(@"\u8805?", "\xf2"); //greater than or equal + stepText = stepText.Replace(@"\u9474?", "\xB3"); // Vert Line graphic character stepText = stepText.Replace(@"\'b0", "\xB0"); stepText = stepText.Replace(@"\up2 ", "\x9566"); stepText = stepText.Replace(@"\up0 ", "\x9567"); @@ -329,18 +335,39 @@ namespace DataLoader stepText = stepText.Replace(@"\ul", "\xAB"); stepText = stepText.Replace(@"\{", "{"); stepText = stepText.Replace(@"\}", "}"); - //stepText = stepText.Replace("\\b0", "\x2553"); - //stepText = stepText.Replace("\\b", "\x2552"); stepText = stepText.Replace(@"\b0", "\xD6"); stepText = stepText.Replace(@"\b", "\xD5"); - //stepText = stepText.Replace(@"\u160?", "\xA0"); //hard space - stepText = stepText.Replace(@"\u160?", "\xFF"); //hard space xFF is used in 16-bit proms + stepText = stepText.Replace(@"\u160?", "\xA0"); //hard space stepText = stepText.Replace(@"\u916?", "\x7F"); // delta + stepText = stepText.Replace(@"\u8805?", "\xF2"); //greater than or equal + stepText = stepText.Replace(@"\u8804?", "\xF3"); // less than or equal + stepText = stepText.Replace(@"\u931?", "\xE4"); // sigma + stepText = stepText.Replace(@"\u947?", "\xE7"); // gamma + stepText = stepText.Replace(@"\u9604?", "\xFE"); // accum 2584 + stepText = stepText.Replace(@"\u9679?", "\x7"); // bullet 25CF + stepText = stepText.Replace(@"\u8776?", "\xF7"); // approx eq + stepText = stepText.Replace(@"\u8773?", "\xF0"); // similar eq 2245 + stepText = stepText.Replace(@"\u8730?", "\xFB"); // square root + stepText = stepText.Replace(@"\u961?", "\xE2"); // rho 3C1 + stepText = stepText.Replace(@"\u960?", "\xE3"); // pi + stepText = stepText.Replace(@"\u956?", "\xE6"); // micro + stepText = stepText.Replace(@"\u948?", "\xEB"); // lower case delta + stepText = stepText.Replace(@"\u963?", "\xE5"); // lower case sigma + stepText = stepText.Replace(@"\u274?", "\x90"); // energy, 112 + stepText = stepText.Replace(@"\u949?", "\xEE"); // epsilon + stepText = stepText.Replace(@"\u952?", "\xE9"); // theta, 3B8 + stepText = stepText.Replace(@"\u8857?", "\xEC"); // dot in oval, 2299 + stepText = stepText.Replace(@"\u964?", "\xA8"); // tau, 3C4 + stepText = stepText.Replace(@"\u9830?", "\xA9"); // diamond, 2666 + stepText = stepText.Replace(@"\u8593?", "\x18"); // Up Arrow - changes to \xff + stepText = stepText.Replace(@"\u8595?", "\x19"); // Down Arrow - changes to \xd6 + //Console.WriteLine("B4 Parse Orig Text: '{0}'", savethis); //Console.WriteLine("B4 Parse sym repl: '{0}'", stepText); - grd.ParseTableFromText(_RemoveComments.Replace(stepText, "")); - //grd.ParseTableFromText(_RemoveComments.Replace((stepText.Replace(@"\u8209?", "-")).Replace("\\'b0", "\xB0"), "")); - //grd.ParseTableFromText(_RemoveComments.Replace((stepText.Replace(@"\u8209?", "-")).Replace("\\par", "\n"), "")); + if (grd.IsRoTable) + grd.ParseTableFromText(_RemoveComments.Replace(stepText, "")); + else + grd.ParseTableFromText(stepText); grd.AutoSizeCols(); grd.AutoSizeRows(); grd.MakeRTFcells(); @@ -348,8 +375,9 @@ namespace DataLoader using (StringWriter sw = new StringWriter()) { grd.WriteXml(sw); - Console.WriteLine(sw.GetStringBuilder().ToString()); + //Console.WriteLine(sw.GetStringBuilder().ToString()); content.MyGrid.Data = sw.GetStringBuilder().ToString(); + strGrid = grd.GetSearchableText(); sw.Close(); } return strGrid; diff --git a/PROMS/DataLoader/TextConvert.cs b/PROMS/DataLoader/TextConvert.cs index 5840a5c1..ff4cc303 100644 --- a/PROMS/DataLoader/TextConvert.cs +++ b/PROMS/DataLoader/TextConvert.cs @@ -120,6 +120,20 @@ namespace DataLoader if (DoCaret) s2 = s2.Replace("^", @"\u916"); return ConvertText(s2); } + private static void ShowRawString(string str, string title) + { + Console.WriteLine("Raw Start --{0}:\n", title); + foreach (char c in str) + { + int ic = (int)c; + if (c != '\n' && (ic > 126 || ic < 32)) + Console.Write("<<{0:x4}>>", ic); + else + Console.Write(c); + } + Console.WriteLine("\n-- Raw End:{0}", title); + } + public static string ReplaceUnicode(string s2) { return ReplaceUnicode(s2, false); @@ -129,6 +143,7 @@ namespace DataLoader //char[] tmp; //tmp = s2.ToCharArray(); string orig = s2; + //ShowRawString(s2, "ReplaceUnicode"); s2 = s2.Replace("`", @"\'b0"); // convert backquote to degree - left over from DOS days. s2 = s2.Replace("\xa0",@"\u160?"); // hardspace s2 = s2.Replace("\xb0", @"\'b0"); // degree @@ -166,6 +181,8 @@ namespace DataLoader s2 = s2.Replace("\x2193", @"\u8595?"); s2 = s2.Replace("\x2207", @"\u8711?"); s2 = s2.Replace("\x2591", @"\'b0"); // Degree Symbol + s2 = s2.Replace("\xFF", @"\u8593?"); // Up Arrow + s2 = s2.Replace("\xD6", @"\u8595?"); // Down Arrow if (DoCaret) s2 = s2.Replace("^", @"\u916"); //s2 = s2.Replace("^", @"\u916"); diff --git a/PROMS/DataLoader/TransitionFixer.cs b/PROMS/DataLoader/TransitionFixer.cs index c5efae0e..008e444d 100644 --- a/PROMS/DataLoader/TransitionFixer.cs +++ b/PROMS/DataLoader/TransitionFixer.cs @@ -5,6 +5,9 @@ using Volian.Controls.Library; using VEPROMS.CSLA.Library; using System.Text.RegularExpressions; using Volian.Base.Library; +using Volian.Controls.Library; +using System.Xml; +using System.IO; namespace DataLoader { @@ -81,6 +84,11 @@ namespace DataLoader //MyStepRTB.ViewRTB = false; string originalText = item.MyContent.Text; string updatedText = item.MyContent.Text; + if (item.MyContent.MyGrid != null) + { + originalText = item.MyContent.MyGrid.Data; + updatedText = (item.MyContent.MyGrid.Data.Replace("<START]", ""); + } // Exclude items that are not connected (Dummy steps for invalid transition destinations) if (item.ItemDocVersionCount != 0 || item.MyPrevious != null || item.MyParent != null) { @@ -91,7 +99,10 @@ namespace DataLoader { try { - updatedText = FixTransitionText(updatedText, tran); + if (item.MyContent.MyGrid != null) + updatedText = FixTableTransitionText(updatedText, tran, item.MyContent.Get()); + else + updatedText = FixTransitionText(updatedText, tran); } catch (Exception ex) { @@ -100,10 +111,23 @@ namespace DataLoader } } if (updatedText.EndsWith(" ")) updatedText = updatedText.Substring(0, updatedText.Length - 1); - using (Content c = item.MyContent.Get()) + if (item.MyContent.MyGrid != null) { - c.Text = updatedText; - c.Save(); + using (Item itm = item.Get()) + { + updatedText = (updatedText.Replace("", "[END>"); + string sstring = AdjustSizeAndGetSearchString(updatedText, itm); + itm.MyContent.Text = sstring; + itm.Save(); + } + } + else + { + using (Content c = item.MyContent.Get()) + { + c.Text = updatedText; + c.Save(); + } } if (checkRTF) { @@ -154,5 +178,59 @@ namespace DataLoader Console.WriteLine("Transition not Found"); return Text; } + public string FixTableTransitionText(string Text, TransitionInfo tran, Content content) + { + string lookFor = string.Format(@"", tran.TranType, tran.TransitionID, "{1,2}"); + string transText = tran.ResolvePathTo(); + //Console.WriteLine(">>>>> FixTransitionText"); + //Console.WriteLine("Text = {0}", Text); + //Console.WriteLine("lookFor = {0}", lookFor); + //Console.WriteLine("TransText = {0}", transText); + Match m = Regex.Match(Text, lookFor); + if (m != null && m.Groups.Count > 1) + { + System.Text.RegularExpressions.Group g = m.Groups[1]; + if (g.ToString() != transText) + Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length); + } + else + Console.WriteLine("Transition not Found"); + + //VlnFlexGrid grd = new VlnFlexGrid(1, 1); + //XmlDocument xd = new XmlDocument(); + //xd.LoadXml(Text); + //grd.ReadXml(xd); + //grd.FixTableCellsHeightWidth(); // resize the column width/height + //using (StringWriter sw = new StringWriter()) + //{ + // grd.WriteXml(sw); + // //Console.WriteLine(sw.GetStringBuilder().ToString()); + // content.MyGrid.Data = sw.GetStringBuilder().ToString(); + // sw.Close(); + //} + return Text; + } + private string AdjustSizeAndGetSearchString(string strXML, Item itm) + { + string rstring = ""; + VlnFlexGrid grd = new VlnFlexGrid(1, 1); + XmlDocument xd = new XmlDocument(); + xd.LoadXml(strXML); + grd.ReadXml(xd); + //using (StringReader sr = new StringReader(strXML)) + //{ + // grd.ReadXml(sr); + // sr.Close(); + //} + grd.FixTableCellsHeightWidth(); // resize the column width/height + rstring = grd.GetSearchableText(); + using (StringWriter sw = new StringWriter()) + { + grd.WriteXml(sw); + itm.MyContent.MyGrid.Data = sw.GetStringBuilder().ToString(); + sw.Close(); + } + return rstring; + } } }