Fixed Transition Format to support multiple level sub-sections
Fixed Transition Logic for Calvert
This commit is contained in:
parent
242514ae99
commit
d90e472f23
@ -401,6 +401,18 @@ namespace VEPROMS.CSLA.Library
|
||||
public bool _UsedRangeAncestor;
|
||||
private string _Token;
|
||||
public bool SectNumWithStepNum;
|
||||
private int _SectionNumberLength = 0;
|
||||
public int SectionNumberLength
|
||||
{
|
||||
get { return _SectionNumberLength; }
|
||||
set { _SectionNumberLength = value; }
|
||||
}
|
||||
private string _StepPrefix = "";
|
||||
public string StepPrefix
|
||||
{
|
||||
get { return _StepPrefix; }
|
||||
set { _StepPrefix = value; }
|
||||
}
|
||||
private List<int> _SectionsUsed = new List<int>();
|
||||
public List<int> SectionsUsed
|
||||
{
|
||||
@ -444,7 +456,10 @@ namespace VEPROMS.CSLA.Library
|
||||
str = str.Insert(indx, @"\u160?");
|
||||
}
|
||||
}
|
||||
return _Results.Append(str);
|
||||
if (_Results.ToString().ToUpper().EndsWith("STEP ") && str.ToUpper().StartsWith("STEP "))
|
||||
return _Results.Append(str.Substring(5).Trim(" :".ToCharArray()));
|
||||
else
|
||||
return _Results.Append(str.TrimEnd(" :".ToCharArray()));
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
@ -468,8 +483,10 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
else if (_TranType == 4 && _ToItem.MoreThanOneStepSection())
|
||||
{
|
||||
if (!HasText && Prefix != null && Prefix.ToUpper().StartsWith(", STEP"))
|
||||
if (!HasText && Prefix != null && Prefix.ToUpper().StartsWith(", STEP")
|
||||
&& _FromItem.ActiveFormat.Name.StartsWith("WEP"))
|
||||
{
|
||||
Console.WriteLine("Format,'{0}'", _FromItem.ActiveFormat.Name);
|
||||
_Prefix = null;
|
||||
return;
|
||||
}
|
||||
@ -491,11 +508,20 @@ namespace VEPROMS.CSLA.Library
|
||||
_Results.Append(Prefix.TrimStart(" ".ToCharArray())); // since no text in result, trim starting space.
|
||||
}
|
||||
}
|
||||
|
||||
public string OverridePrefix
|
||||
{
|
||||
set { _Prefix = value; }
|
||||
}
|
||||
internal void AppendStepPrefix()
|
||||
{
|
||||
string myPrefix = StepPrefix;
|
||||
StepPrefix = "";
|
||||
if (Length != SectionNumberLength) return;
|
||||
if (Length == 0) return;
|
||||
if (myPrefix == "") return;
|
||||
if (_Results.ToString().EndsWith(myPrefix)) return;
|
||||
Append(myPrefix);
|
||||
}
|
||||
}
|
||||
public static class TransitionText
|
||||
{
|
||||
@ -519,6 +545,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_AppendMethods.Add("{?.Sect Title}", AddOptionalTranGetSectionTitle);
|
||||
_AppendMethods.Add("{?.Sect Num}", AddOptionalTranGetSectionNum);
|
||||
_AppendMethods.Add("{Sect Num}", AddTranGetSectionNumber);
|
||||
_AppendMethods.Add("{Sect Num All}", AddTranGetAllSectionNumber);
|
||||
_AppendMethods.Add("{Sect Number}", AddTranGetSectionNumber); // WCN2, tran type 6
|
||||
_AppendMethods.Add("{Page Num}", AddPageNumber);
|
||||
_AppendMethods.Add("{Step Text}", AddStepText);
|
||||
@ -604,6 +631,12 @@ namespace VEPROMS.CSLA.Library
|
||||
//Invalid Transition Check
|
||||
if (tb._ToItem.ActiveParent == null || tb._RangeItem.ActiveParent == null)
|
||||
return "?";
|
||||
if (tb._TransFormat == "{Proc Num}, {Proc Title}, Step {First Step}" && tb._ToItem.IsSection &&
|
||||
tb._ToItem.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && tb._FromItem.MyProcedure.ItemID == tb._ToItem.MyProcedure.ItemID)
|
||||
{
|
||||
tb._TransFormat = @"{Sect Num}, \ul {Sect Title}\ulnone ";
|
||||
tb._TranType = 4;
|
||||
}
|
||||
int startIndex = 0;
|
||||
int index = -1;
|
||||
int rexIndex = -1;
|
||||
@ -612,7 +645,7 @@ namespace VEPROMS.CSLA.Library
|
||||
bool lastAdded = false;
|
||||
MatchCollection mc = Regex.Matches(tb._TransFormat, @"{(Proc Num|\?\.Proc Num|Proc Title|\?\.Proc Title|" +
|
||||
@"First Step|Step Number|Last Step|\.|Sect Hdr|\?\.Sect Hdr|Sect Title|\?\.Sect Title|\?\.Sect Num|Sect Num|" +
|
||||
@"Sect Number|Page Num|Step Text)}");
|
||||
@"Sect Number|Page Num|Step Text|Sect Num All)}");
|
||||
foreach (Match m in mc)
|
||||
{
|
||||
string tmppref = prefix;
|
||||
@ -656,7 +689,7 @@ namespace VEPROMS.CSLA.Library
|
||||
tb.Prefix = prefix;
|
||||
else // If not conditional, force the prefix to be updated
|
||||
tb.OverridePrefix = prefix;
|
||||
lastAdded = _AppendMethods[token](tb);
|
||||
lastAdded = _AppendMethods[token](tb);
|
||||
}
|
||||
else
|
||||
tb.Append("\\" + token.Substring(0, token.Length - 1) + "\\}");
|
||||
@ -665,7 +698,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (startIndex >= tb._TransFormat.Length) break;
|
||||
}
|
||||
if ((startIndex < tb._TransFormat.Length) && lastAdded) tb.Append(tb._TransFormat.Substring(startIndex, tb._TransFormat.Length - startIndex));
|
||||
string myReturn = Regex.Replace(tb.ToString(), @"([~`.]*)\.([~`.]*)", ".");
|
||||
string myReturn = Regex.Replace(tb.ToString(), @"\.+", ".");
|
||||
return myReturn;
|
||||
}
|
||||
|
||||
@ -901,13 +934,19 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
// Logic added for handling applicability. If the first item is not applicable, then the second item will effectively become
|
||||
// the first item but it's itempartcount will be zero
|
||||
if(tb._ToItem.ActiveParent is ItemInfo && (tb._ToItem.ActiveParent as ItemInfo).Steps[0].ItemID == tb._ToItem.ItemID)
|
||||
if (tb._ToItem.ActiveParent is ItemInfo && (tb._ToItem.ActiveParent as ItemInfo).Steps[0].ItemID == tb._ToItem.ItemID)
|
||||
{
|
||||
tb.AppendStepPrefix();
|
||||
tb.ReplaceToken(Tab(tb._ToItem, true));
|
||||
}
|
||||
else
|
||||
tb.Append("?");
|
||||
tb.Append("?");
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.AppendStepPrefix();
|
||||
tb.ReplaceToken(Tab(tb._ToItem, true));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if ((tb._ToItem.IsSection || tb._ToItem.IsProcedure) && ((tb._TransUI & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone))
|
||||
@ -1028,7 +1067,7 @@ namespace VEPROMS.CSLA.Library
|
||||
// if this is a step section & the default section, just return
|
||||
//if (TranGetSectionItem(itminfo).IsDefaultSection) return;
|
||||
StringBuilder retstr = new StringBuilder();
|
||||
retstr.Append(TranGetSectionNumber(tb._ToItem));
|
||||
retstr.Append(TranGetSectionNumber(tb,false));
|
||||
string txt;
|
||||
if(retstr.Length > 0)
|
||||
txt = TranGetSectionTitle(tb,tb._ToItem);
|
||||
@ -1058,7 +1097,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (tb.SectNumWithStepNum) return false;
|
||||
if (tb._ToItem.IsSection) return false;
|
||||
tb.AppendPrefix();
|
||||
string retstr = TranGetSectionNumber(tb._ToItem);
|
||||
string retstr = TranGetSectionNumber(tb,false);
|
||||
tb.ReplaceToken(retstr);
|
||||
return (retstr != null && retstr != "");
|
||||
}
|
||||
@ -1075,6 +1114,14 @@ namespace VEPROMS.CSLA.Library
|
||||
return false;
|
||||
}
|
||||
private static bool AddTranGetSectionNumber(TransitionBuilder tb)
|
||||
{
|
||||
return AddTranGetSectionNumber(tb, false);
|
||||
}
|
||||
private static bool AddTranGetAllSectionNumber(TransitionBuilder tb)
|
||||
{
|
||||
return AddTranGetSectionNumber(tb, true);
|
||||
}
|
||||
private static bool AddTranGetSectionNumber(TransitionBuilder tb, bool allLevels)
|
||||
{
|
||||
if (tb._TranType == 1 && tb._ToItem.ActiveSection.ItemID == tb._FromItem.ActiveSection.ItemID) return false;
|
||||
if (tb.SectNumWithStepNum) return false;
|
||||
@ -1087,8 +1134,8 @@ namespace VEPROMS.CSLA.Library
|
||||
return true;
|
||||
}
|
||||
if (tb.SectionsUsed.Contains(tb._ToItem.ItemID))
|
||||
return true;
|
||||
string retstr = TranGetSectionNumber(tb._ToItem);
|
||||
return false;
|
||||
string retstr = TranGetSectionNumber(tb,allLevels);
|
||||
tb.SectionsUsed.Add(tb._ToItem.ItemID);
|
||||
if (retstr != null && retstr != "")
|
||||
{
|
||||
@ -1129,6 +1176,8 @@ namespace VEPROMS.CSLA.Library
|
||||
private static ItemInfo TranGetSectionItem(ItemInfo itminfo)
|
||||
{
|
||||
ItemInfo tmpitm = itminfo;
|
||||
if(itminfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert)
|
||||
return tmpitm.IsSection ? tmpitm : (tmpitm.ActiveSection ?? tmpitm);
|
||||
while (tmpitm.MyContent.Type >= 20000) tmpitm = tmpitm.MyParent;
|
||||
return tmpitm;
|
||||
}
|
||||
@ -1141,6 +1190,70 @@ namespace VEPROMS.CSLA.Library
|
||||
str = Regex.Replace(str, @"\<ID\>", itminfo.MyDocVersion.DocVersionConfig.Unit_ID, RegexOptions.IgnoreCase);
|
||||
return (str);
|
||||
}
|
||||
private static string TranGetSectionNumber(TransitionBuilder tb, bool allLevels)
|
||||
{
|
||||
//if (tb._FromItem.MyContent.InList(5322)) Console.WriteLine("Here");
|
||||
string str1 = TranGetSectionNumber(tb._ToItem);
|
||||
if(!tb._ToItem.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) return str1;
|
||||
List<ItemInfo> FromSections = GetSections(tb._FromItem.ActiveSection);
|
||||
List<ItemInfo> ToSections = GetSections(tb._ToItem.ActiveSection);
|
||||
if (!allLevels && tb._FromItem.MyProcedure.ItemID == tb._ToItem.MyProcedure.ItemID && tb._FromItem.ActiveSection.ItemID != tb._ToItem.ItemID)
|
||||
{
|
||||
while (ToSections.Count > 1 && FromSections.Count > 1 && ToSections[0].ItemID == FromSections[0].ItemID)
|
||||
{
|
||||
ToSections.RemoveAt(0);
|
||||
FromSections.RemoveAt(0);
|
||||
if (ToSections.Count == 1 && ToSections[0].ItemID == tb._ToItem.ItemID)
|
||||
break;
|
||||
}
|
||||
}
|
||||
//string str = tmpitm.MyContent.Number;
|
||||
string str = BuildSectionPath(ToSections);
|
||||
str = Regex.Replace(str, @"\<U\>", tb._ToItem.MyDocVersion.DocVersionConfig.Unit_Number, RegexOptions.IgnoreCase);
|
||||
str = Regex.Replace(str, @"\<ID\>", tb._ToItem.MyDocVersion.DocVersionConfig.Unit_ID, RegexOptions.IgnoreCase);
|
||||
if(str != str1)
|
||||
Console.WriteLine("Difference In Strings: {0}\r\n{1}",str,str1);
|
||||
//if (!str.EndsWith(".") && tb._ToItem.ItemID != tb._ToItem.ActiveSection.ItemID)
|
||||
tb.StepPrefix = ".";
|
||||
tb.SectionNumberLength = str.Length;
|
||||
return (str);
|
||||
}
|
||||
private static string BuildSectionPath(List<ItemInfo> ToSections)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string lastPart="";
|
||||
string sep = "";
|
||||
foreach (ItemInfo si in ToSections)
|
||||
{
|
||||
string thisPart = si.MyContent.Number.Trim();
|
||||
if (lastPart.EndsWith(".0"))
|
||||
{
|
||||
if(thisPart.StartsWith( lastPart.Substring(0,lastPart.Length-1)))
|
||||
lastPart="";
|
||||
}
|
||||
if (si.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && thisPart == lastPart && IsRoman(lastPart))
|
||||
lastPart = "";
|
||||
sb.Append(sep + lastPart.TrimEnd(" .".ToCharArray()));
|
||||
if (sb.Length > 0) sep = ".";
|
||||
lastPart = thisPart;
|
||||
}
|
||||
sb.Append(sep + lastPart.TrimEnd(" ".ToCharArray()));
|
||||
return sb.ToString();
|
||||
}
|
||||
private static bool IsRoman(string number)
|
||||
{
|
||||
return Regex.IsMatch(number,@"[IVXLCDM]+\.?");
|
||||
}
|
||||
private static List<ItemInfo> GetSections(ItemInfo myItemInfo)
|
||||
{
|
||||
List<ItemInfo> retval = new List<ItemInfo>();
|
||||
while (myItemInfo != null && myItemInfo.IsSection)
|
||||
{
|
||||
retval.Insert(0, myItemInfo);
|
||||
myItemInfo = myItemInfo.ActiveParent as ItemInfo;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
private static string TranGetSectionTitle(TransitionBuilder tb, ItemInfo itminfo)
|
||||
{
|
||||
// LATER: Cap1stSectionTitle, CapFirstLetterOnly
|
||||
|
Loading…
x
Reference in New Issue
Block a user