Added code to provide information regarding transitions that are being fixed using the Fix Transitions menu item.

Added code to fix transitions that involve Section, SubSections and Steps as part of the path to the transition and how this is rendered in the step's text.
This commit is contained in:
Rich 2014-10-22 00:55:04 +00:00
parent 6c564c8e4d
commit bf99440bde
3 changed files with 57 additions and 6 deletions

View File

@ -70,9 +70,16 @@ namespace DataLoader
public TimeSpan Process(bool checkRTF) public TimeSpan Process(bool checkRTF)
{ {
DateTime tstart = DateTime.Now; DateTime tstart = DateTime.Now;
ContentInfo.StaticContentInfoChange += new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
ProcessTransitions(checkRTF); ProcessTransitions(checkRTF);
ContentInfo.StaticContentInfoChange -= new StaticContentInfoEvent(ContentInfo_StaticContentInfoChange);
return DateTime.Now - tstart; return DateTime.Now - tstart;
} }
void ContentInfo_StaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
_MyLoader.AddInfo("Fixed Transition for {0}, changed from {1} to {2}", (sender as ContentInfo).ContentID, args.OldValue, args.NewValue);
}
private void ProcessTransitions(bool checkRTF) private void ProcessTransitions(bool checkRTF)
{ {
Status = "Getting List..."; Status = "Getting List...";
@ -102,11 +109,18 @@ namespace DataLoader
{ {
try try
{ {
using (Content c = item.MyContent.Get()) string oldtext = item.MyContent.Text;
{ item.MyContent.FixTransitionText(tran);
c.FixTransitionText(tran); string newtext = item.MyContent.Text;
c.Save(); if (newtext != oldtext)
} {
using (Content c = item.MyContent.Get())
{
c.FixTransitionText(tran);
c.Save();
}
}
if (item.NewTransToUnNumberedItem) if (item.NewTransToUnNumberedItem)
{ {
using (Item itm = item.Get()) using (Item itm = item.Get())

View File

@ -363,8 +363,35 @@ namespace VEPROMS.CSLA.Library
return retval; return retval;
} }
} }
public delegate void StaticContentInfoEvent(object sender, StaticContentInfoEventArgs args);
public class StaticContentInfoEventArgs
{
string _OldValue;
public string OldValue
{
get { return _OldValue; }
set { _OldValue = value; }
}
string _NewValue;
public string NewValue
{
get { return _NewValue; }
set { _NewValue = value; }
}
public StaticContentInfoEventArgs(string oldValue, string newValue)
{
_OldValue = oldValue;
_NewValue = newValue;
}
}
public partial class ContentInfo public partial class ContentInfo
{ {
public static event StaticContentInfoEvent StaticContentInfoChange;
private static void OnStaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
if (StaticContentInfoChange != null)
StaticContentInfoChange(sender, args);
}
public string MyContentMessage = string.Empty; public string MyContentMessage = string.Empty;
public string MyGridMessage = string.Empty; public string MyGridMessage = string.Empty;
public bool InList(params int[] IDs) public bool InList(params int[] IDs)
@ -414,6 +441,7 @@ namespace VEPROMS.CSLA.Library
if (gg != newvalue) if (gg != newvalue)
{ {
_Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength); _Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
OnStaticContentInfoChange(this, new StaticContentInfoEventArgs(gg, newvalue));
break; // Text has been processed break; // Text has been processed
} }
} }

View File

@ -401,6 +401,11 @@ namespace VEPROMS.CSLA.Library
public bool _UsedRangeAncestor; public bool _UsedRangeAncestor;
private string _Token; private string _Token;
public bool SectNumWithStepNum; public bool SectNumWithStepNum;
private List<int> _SectionsUsed = new List<int>();
public List<int> SectionsUsed
{
get { return _SectionsUsed; }
}
public string Token public string Token
{ {
get { return _Token; } get { return _Token; }
@ -660,7 +665,8 @@ namespace VEPROMS.CSLA.Library
if (startIndex >= tb._TransFormat.Length) break; if (startIndex >= tb._TransFormat.Length) break;
} }
if ((startIndex < tb._TransFormat.Length) && lastAdded) tb.Append(tb._TransFormat.Substring(startIndex, tb._TransFormat.Length - startIndex)); if ((startIndex < tb._TransFormat.Length) && lastAdded) tb.Append(tb._TransFormat.Substring(startIndex, tb._TransFormat.Length - startIndex));
return (tb.ToString()); string myReturn = Regex.Replace(tb.ToString(), @"([~`.]*)\.([~`.]*)", ".");
return myReturn;
} }
// TODO: For hlp: LowerCaseTranNumber - lower case substep numbers in transitions // TODO: For hlp: LowerCaseTranNumber - lower case substep numbers in transitions
@ -1079,7 +1085,10 @@ namespace VEPROMS.CSLA.Library
tb.Append(")"); tb.Append(")");
return true; return true;
} }
if (tb.SectionsUsed.Contains(tb._ToItem.ItemID))
return true;
string retstr = TranGetSectionNumber(tb._ToItem); string retstr = TranGetSectionNumber(tb._ToItem);
tb.SectionsUsed.Add(tb._ToItem.ItemID);
if (retstr != null && retstr != "") if (retstr != null && retstr != "")
{ {
int indx = retstr.IndexOf(' '); // 16 bit code only processes 1st occurance int indx = retstr.IndexOf(' '); // 16 bit code only processes 1st occurance