This commit is contained in:
Kathy Ruffing 2010-09-21 18:29:58 +00:00
parent 3086c7ec5a
commit 7b685cf220
3 changed files with 75 additions and 67 deletions

View File

@ -67,7 +67,7 @@ namespace DataLoader
lTime = DateTime.Now.Ticks - lTime;
if (convertProcedures)
{
ShowMissingTransitions();
ShowMissingTransitions(docver);
//frmMain.Status = string.Format("{0}\r\nConversion completed in {1} seconds.", pth, TimeSpan.FromTicks(lTime).TotalSeconds);
TimeSpan ts = TimeSpan.FromTicks(lTime);
frmMain.Status = string.Format("{0}\r\nConversion completion time: {1:D2}:{2:D2}:{3:D2}.{4} ({5} Total Seconds)", pth, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds, ts.TotalSeconds);

View File

@ -211,10 +211,8 @@ namespace DataLoader
public static string ConvertDOSSuperAndSubScripts(string instr)
{
//string retval = Regex.Replace(instr, "[#](.*?)[#]", "\\super $1\\nosupersub ");// DOS Superscript
//retval = Regex.Replace(retval, "[~](.*?)[~]", "\\sub $1\\nosupersub ");// DOS Subscript
string retval = Regex.Replace(instr, "[#](.*?)[#]", "\\up3 $1\\up0 ");// DOS Superscript
retval = Regex.Replace(retval, "[~](.*?)[~]", "\\dn3 $1\\dn0 ");// DOS Subscript
string retval = Regex.Replace(instr, "[#](.*?)[#]", "\\up2 $1\\up0 ");// DOS Superscript
retval = Regex.Replace(retval, "[~](.*?)[~]", "\\dn2 $1\\dn0 ");// DOS Subscript
return retval;
}
private static string FixFortranNumber(Match match)
@ -228,8 +226,7 @@ namespace DataLoader
else // A number with a decimal point
sb.Append(match.Groups[2].Value + "." + match.Groups[3].Value + "x10");
// Add the exponent as superscript
//return sb.ToString() + "\\super " + match.Groups[4].Value + "\\nosupersub ";
return sb.ToString() + "\\up3 " + match.Groups[4].Value + "\\up0 ";
return sb.ToString() + "\\up2 " + match.Groups[4].Value + "\\up0 ";
}
//private static string ConvertFortranFormatToScienctificNotation(string str)
//{
@ -394,13 +391,13 @@ namespace DataLoader
s2 = s2.Replace("\xBB", "\\ulnone ");
//s2 = s2.Replace("\x255E", "\\super ");
//s2 = s2.Replace("\x255F", "\\nosupersub ");
s2 = s2.Replace("\x255E", "\\up3 ");
s2 = s2.Replace("\x255E", "\\up2 ");
s2 = s2.Replace("\x255F", "\\up0 ");
s2 = s2.Replace("\x2552", "\\b ");
s2 = s2.Replace("\x2553", "\\b0 ");
//s2 = s2.Replace("\x2564", "\\sub ");
//s2 = s2.Replace("\xAA", "\\nosupersub ");
s2 = s2.Replace("\x2564", "\\dn3 ");
s2 = s2.Replace("\x2564", "\\dn2 ");
s2 = s2.Replace("\xAA", "\\dn0 ");
s2 = s2.Replace("\x2593", "\\i ");
s2 = s2.Replace("\x258C", "\\i0 ");
@ -414,8 +411,8 @@ namespace DataLoader
s2 = Regex.Replace(s2, @"\x17([^\x17 ]*?)(?:[\x17]|(?= )|\Z)(.*?)", @"\ul $1\ulnone $2");
//s2 = Regex.Replace(s2, @"\x18([^\x18 ]*?)(?:[\x18]|(?= )|\Z)(.*?)", @"\super $1\nosupersub $2");
//s2 = Regex.Replace(s2, @"\x19([^\x19 ]*?)(?:[\x19]|(?= )|\Z)(.*?)", @"\sub $1\nosupersub $2");
s2 = Regex.Replace(s2, @"\x18([^\x18 ]*?)(?:[\x18]|(?= )|\Z)(.*?)", @"\up3 $1\up0 $2");
s2 = Regex.Replace(s2, @"\x19([^\x19 ]*?)(?:[\x19]|(?= )|\Z)(.*?)", @"\dn3 $1\dn0 $2");
s2 = Regex.Replace(s2, @"\x18([^\x18 ]*?)(?:[\x18]|(?= )|\Z)(.*?)", @"\up2 $1\up0 $2");
s2 = Regex.Replace(s2, @"\x19([^\x19 ]*?)(?:[\x19]|(?= )|\Z)(.*?)", @"\dn2 $1\dn0 $2");
s2 = Regex.Replace(s2, @"\x13([^\x13 ]*?)(?:[\x13]|(?= )|\Z)(.*?)", @"\b $1\b0 $2");
s2 = Reg2.Replace(s2, new MatchEvaluator(ReplaceChars));
@ -425,10 +422,8 @@ namespace DataLoader
s2 = s2.Replace(@"{", @"\{");
s2 = s2.Replace(@"}", @"\}");
s2 = s2.Replace("\n", @"\par "); // line break in tables
//s2 = s2.Replace(@"\nosupersub \super ", @"\super "); //jsj - 18MAR2010 - rbt.Save() seems to do this automatically
//s2 = s2.Replace(@"\nosupersub \sub ", @"\sub "); //jsj - 18MAR2010 - rbt.Save() seems to do this automatically
s2 = s2.Replace(@"\up0 \up3 ", @"\up3 "); //jsj - 18MAR2010 - rbt.Save() seems to do this automatically
s2 = s2.Replace(@"\dn0 \dn3 ", @"\dn3 "); //jsj - 18MAR2010 - rbt.Save() seems to do this automatically
s2 = s2.Replace(@"\up0 \up2 ", @"\up2 "); //jsj - 18MAR2010 - rbt.Save() seems to do this automatically
s2 = s2.Replace(@"\dn0 \dn2 ", @"\dn2 "); //jsj - 18MAR2010 - rbt.Save() seems to do this automatically
return s2;
}

View File

@ -284,12 +284,12 @@ namespace DataLoader
da.Dispose();
return trtxt.ToString();
}
private void ShowMissingTransitions()
private void ShowMissingTransitions(DocVersion docver)
{
if (dicTrans_ItemIds.Keys.Count > 0)
if (dicTrans_ItemIds.Keys.Count > 0)
{
// see if any end in |A0, if so, point these to the procedure associated with it.
CleanupTransToNonExistentSectionA0();
CleanupTransToNonExistentSectionA0(docver);
foreach (string s in dicTrans_ItemIds.Keys)
{
//log.WarnFormat("{0} - {1}", s, dicTrans_ItemIds[s]);
@ -319,8 +319,10 @@ namespace DataLoader
log.Info("End of Missing Transitions");
}
private void CleanupTransToNonExistentSectionA0()
private void CleanupTransToNonExistentSectionA0(DocVersion docver)
{
List<string> RemoveFromDicTrans = new List<string>();
// see if any end in |A0, if so, point these to the procedure associated with it.
foreach (string s in dicTrans_ItemIds.Keys)
{
@ -328,59 +330,70 @@ namespace DataLoader
{
// make a list to store those that need changed because can't change data in
// a foreach:
RemoveFromDicTrans.Add(s);
Item item = dicTrans_ItemIds[s]; // to or range id.
//ItemInfo ii = ItemInfo.Get(item.ItemID);
//get the proc id that will become the new to or range id.
string procnum = s.Substring(0, s.IndexOf("|"));
DocVersionInfo dvi = DocVersionInfo.Get(docver.VersionID);
IList iprcs = dvi.GetChildren();
ItemInfo prc = null;
foreach (ItemInfo ii in iprcs)
{
if (ii.DisplayNumber == procnum)
{
prc = ii;
break;
}
}
// For each transition that points to the A0, make it point to the proc.
// First, find all of them by getting transitions with the A0 (dummy
// transition record). Then update the to or range id in the transition
// record & then update the content/from part.
List<int> transToChg = new List<int>();
List<int> transRgChg = new List<int>();
Item item = dicTrans_ItemIds[s];
ItemInfo ii = ItemInfo.Get(item.ItemID);
ItemInfo procItem = ii.MyProcedure as ItemInfo;
foreach (ItemTransition_ToID transid in item.ItemTransitions_ToID) transToChg.Add(transid.TransitionID);
foreach (ItemTransition_RangeID transid in item.ItemTransitions_RangeID) transRgChg.Add(transid.TransitionID);
//foreach (int transid in transToChg) UpdateTranDataForA0(procItem, transid, false);
//foreach (int transidr in transRgChg) UpdateTranDataForA0(procItem, transidr, true);
TransitionInfoList til = TransitionInfoList.GetByToID(item.ItemID);
foreach (TransitionInfo ti in til) UpdateTranDataForA0(prc, ti.TransitionID, false);
til = TransitionInfoList.GetByRangeID(item.ItemID);
foreach (TransitionInfo tir in til) UpdateTranDataForA0(prc, tir.TransitionID, true);
}
}
foreach (string str in RemoveFromDicTrans) dicTrans_ItemIds.Remove(str);
}
private static void UpdateTranDataForA0(ItemInfo procItem, int transid, bool isRange)
{
int type;
int oldto;
int oldrg;
int oldfrom;
using (Transition t = Transition.Get(transid))
{
type = t.TranType;
oldto = t.ToID;
oldrg = t.RangeID;
oldfrom = t.FromID;
if (!isRange)
{
t.MyItemToID = procItem.Get();
t.MyItemRangeID = procItem.Get();
}
else
t.MyItemRangeID = procItem.Get();
t.Save();
}
using (Content c = Content.Get(oldfrom))
{
string lookFor = (isRange || oldto != oldrg) ? string.Format(@"#Link:TransitionRange:{0} {1} {2} {3}", type, transid, oldto, oldrg) :
string.Format(@"#Link:Transition:{0} {1} {2}", type, transid, oldto);
string replaceWith = isRange ? string.Format(@"#Link:TransitionRange:{0} {1} {2} {3}", type, transid, oldto, procItem.ItemID) :
oldto != oldrg ? string.Format(@"#Link:TransitionRange:{0} {1} {2} {3}", type, transid, procItem.ItemID, oldrg) :
string.Format(@"#Link:Transition:{0} {1} {2}", type, transid, procItem.ItemID);
c.Text = c.Text.Replace(lookFor, replaceWith);
c.Save();
}
}
//private static void UpdateTranDataForA0(ItemInfo procItem, int transid, bool isRange)
//{
// int type;
// int oldto;
// int oldrg;
// int oldfrom;
// using (Transition t = Transition.Get(transid))
// {
// type = t.TranType;
// oldto = t.ToID;
// oldrg = t.RangeID;
// oldfrom = t.FromID;
// if (!isRange)
// t.MyItemToID = procItem;
// else
// t.MyItemRangeID = procItem;
// t.Save();
// }
// using (Content c = Content.Get(oldfrom))
// {
// string lookFor = isRange?string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:TransitionRange:{0} {1} {2} {3})\[END>", type, transid, oldto, oldrg):
// string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} {2}( [0-9]*)\[END>", type, transid, oldto);
// Console.WriteLine(">>>>> FixTransitionA0");
// Console.WriteLine("Text = {0}", c.Text);
// Console.WriteLine("lookFor = {0}", lookFor);
// string replaceWith = isRange?string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:TransitionRange:{0} {1} {2} {3}\[END>", type, transid, oldto, procItem.ItemID):
// string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} {2}( [0-9]*)\[END>", type, transid, procItem.ItemID);
// Console.WriteLine("replaceWith = {0}", replaceWith);
// Match m = Regex.Match(c.Text, lookFor);
// if (m != null && m.Groups.Count > 1)
// {
// System.Text.RegularExpressions.Group g = m.Groups[1];
// if (g.ToString() != replaceWith)
// c.Text = c.Text.Substring(0, g.Index) + replaceWith + c.Text.Substring(g.Index + g.Length);
// }
// else
// Console.WriteLine("Transition not Found");
// c.Save();
// }
//}
private void AddItemAnnotation(Item itm)
{