This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user