From c83ee4259a75a0e13cef20d2ea7161a143b16c37 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 25 Mar 2010 14:44:13 +0000 Subject: [PATCH] --- PROMS/DataLoader/Steps.cs | 49 ++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/PROMS/DataLoader/Steps.cs b/PROMS/DataLoader/Steps.cs index 4dfed10c..879cc6d3 100644 --- a/PROMS/DataLoader/Steps.cs +++ b/PROMS/DataLoader/Steps.cs @@ -11,13 +11,16 @@ using System.Xml; using System.IO; using System.Text; using VEPROMS.CSLA.Library; +using System.Text.RegularExpressions; namespace DataLoader { public partial class Loader { - private Item AddStep(OleDbConnection cn, string StepType, string Textm, string Recid, string stpseq, string structtype, Item FromItem, DateTime dts, string userid, bool conv_caret, string pth, DocVersion docver) + private Item AddStep(OleDbConnection cn, string StepType, string Textm, string Recid, string stpseq, string structtype, Item FromItem, DateTime dts, string userid, bool conv_caret, string pth, DocVersion docver, FormatInfo fmt) { + //if (ProcNumber + "|" + stpseq == "082-002CD|A=S") + // Console.WriteLine("here"); Content content = null; Item item = null; @@ -55,12 +58,16 @@ namespace DataLoader string newstptyp = null; bool ManualPagebreak = false; char cbittst = StepType.PadRight(2)[0]; - if (cbittst != ' ' && (cbittst & 0x80) > 1) + //Console.WriteLine(string.Format("AddStep() StepType {0} cbitst = {1} OR'd 0x80 = {2}",StepType,Convert.ToInt16(cbittst),(cbittst & 0x80))); + if (cbittst != ' ' && (cbittst & 0xFF80) > 1)//(cbittst & 0x80) > 1) { ManualPagebreak = true; //if (ci == null) ci = new ConfigInfo(null); ci.AddItem("Step", "ManualPagebreak", "True"); - newstptyp = StepType.Substring(1, 1); + if ((Convert.ToInt16(cbittst)) == 9508) //page break on HIGH5 step type (40) + newstptyp = "40"; + else + newstptyp = StepType.Substring(1, 1); } // Need the content record for the RO & transitions. @@ -94,6 +101,12 @@ namespace DataLoader stptext = MigrateTrans(cn, stptext, seqcvt, content, pth); stptext = stptext.TrimEnd(" ".ToCharArray()); } + string fixStpText = FixStepText(stptext); + if (fixStpText != stptext) + { + txtdirty = true; + stptext = fixStpText; + } if (txtdirty) { content.Text = stptext; @@ -119,6 +132,15 @@ namespace DataLoader } else item = Item.MakeItem(FromItem, content, content.DTS, content.UserID); + + // Remove styles that user entered but are automatically done via the format + string tstr = item.MyItemInfo.RemoveRtfStyles(content.Text,fmt); + if (tstr != content.Text) + { + item.MyContent.Text = tstr; + item.Save(); + } + if (migrationerrors != null) { foreach (string str in migrationerrors) @@ -251,6 +273,21 @@ namespace DataLoader return item; } + private Regex _ReplaceSpaceNewLine = new Regex(@"(?<=\\[^' \\?\r\n\t]*) (?=\r\n)"); + private Regex _ReplaceTokenSpaceToken = new Regex(@"(?<=\\[^' \\?\r\n\t]*) (?=\\)"); + private string FixStepText(string stepText) + { + stepText = stepText.Replace("\xF8", @"\'f8"); + stepText = stepText.Replace(@"\par ", "\r\n"); + stepText = _ReplaceTokenSpaceToken.Replace(stepText, ""); + //stepText = stepText.Replace(@"\v0 \", @"\v0\"); + //Change Token Order to match RTB output + stepText = stepText.Replace(@"\v0\b0", @"\b0\v0"); + stepText = stepText.Replace(@"\b0\ulnone", @"\ulnone\b0"); + stepText = _ReplaceSpaceNewLine.Replace(stepText, ""); + return stepText; + } + //private static bool AddContentDetail(Content content, int type, string strn) //{ // if (strn != null && strn.Trim() != "" ) @@ -297,7 +334,7 @@ namespace DataLoader } return retval; } - private Item MigrateStep(OleDbConnection cn, DataTable dt, DataRowView drv, Item FromItem, bool conv_caret, string pth, DocVersion docver) + private Item MigrateStep(OleDbConnection cn, DataTable dt, DataRowView drv, Item FromItem, bool conv_caret, string pth, DocVersion docver, FormatInfo fmt) { try { @@ -305,7 +342,7 @@ namespace DataLoader Item item = AddStep(cn, drv["Type"].ToString() , (drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString()) , drv["Recid"].ToString(), drv["CStep"].ToString() + drv["CSequence"].ToString(), "S", FromItem // was str - , GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString(), conv_caret, pth, docver); + , GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString(), conv_caret, pth, docver, fmt); //Content cont = Content.MakeContent(null,(drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString()),drv["Type"]+20000,null,null, // GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString()); //Item item = Item.MakeItem(FromItem, cont, cont.DTS, cont.UserID); @@ -358,7 +395,7 @@ namespace DataLoader , (drvs["textm"] == DBNull.Value ? drvs["Text"].ToString() : drvs["Textm"].ToString()) , drv["Recid"].ToString(), drvs["CStep"].ToString() + drvs["CSequence"].ToString() , GetStructType(drvs["sequence"].ToString()), FrItem - , GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString(), conv_caret, pth, docver); + , GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString(), conv_caret, pth, docver, fmt); if (FrType > 0 ) {