This commit is contained in:
parent
9fab9a198f
commit
382a4d5583
@ -8,17 +8,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
private StringBuilder retstr;
|
private StringBuilder retstr;
|
||||||
private FormatData _MyFormatData = null;
|
private FormatData _MyFormatData = null;
|
||||||
|
private ItemInfo _MyFromItemInfo = null;
|
||||||
public string ResolvePathTo(FormatInfo fi, ItemInfo itminfo, ItemInfo toitem, ItemInfo rangeitem)
|
public string ResolvePathTo(FormatInfo fi, ItemInfo itminfo, ItemInfo toitem, ItemInfo rangeitem)
|
||||||
{
|
{
|
||||||
retstr = new StringBuilder();
|
retstr = new StringBuilder();
|
||||||
// get the format of the transition string based on this transition's index into the TransData part of
|
// get the format of the transition string based on this transition's index into the TransData part of
|
||||||
// format....
|
// format....
|
||||||
_MyFormatData = fi.PlantFormat.FormatData;
|
_MyFormatData = fi.PlantFormat.FormatData;
|
||||||
|
_MyFromItemInfo = itminfo;
|
||||||
string tranformat = _MyFormatData.TransData.TransTypeList[TranType].TransFormat;
|
string tranformat = _MyFormatData.TransData.TransTypeList[TranType].TransFormat;
|
||||||
E_TransUI etm = (E_TransUI)_MyFormatData.TransData.TransTypeList[TranType].TransUI;
|
E_TransUI etm = (E_TransUI)_MyFormatData.TransData.TransTypeList[TranType].TransUI;
|
||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
string nontoken = null;
|
string nontoken = null;
|
||||||
|
bool addedtxt = false;
|
||||||
while ((index = tranformat.IndexOf("{", startIndex))>-1)
|
while ((index = tranformat.IndexOf("{", startIndex))>-1)
|
||||||
{
|
{
|
||||||
if (index > startIndex) nontoken = tranformat.Substring(startIndex, index - startIndex);
|
if (index > startIndex) nontoken = tranformat.Substring(startIndex, index - startIndex);
|
||||||
@ -27,33 +30,52 @@ namespace VEPROMS.CSLA.Library
|
|||||||
switch (token)
|
switch (token)
|
||||||
{
|
{
|
||||||
case "{Proc Num}": // Coded for HLP
|
case "{Proc Num}": // Coded for HLP
|
||||||
AddTransitionProcNum(nontoken, toitem);
|
addedtxt = AddTransitionProcNum(addedtxt, nontoken, toitem);
|
||||||
|
break;
|
||||||
|
case "{?.Proc Num}":
|
||||||
|
addedtxt = AddOptionalTransitionProcNum(addedtxt, token, nontoken, toitem);
|
||||||
break;
|
break;
|
||||||
case "{Proc Title}": // Coded for HLP
|
case "{Proc Title}": // Coded for HLP
|
||||||
AddTransitionProcTitle(nontoken, toitem);
|
addedtxt = AddTransitionProcTitle(addedtxt, nontoken, toitem);
|
||||||
|
break;
|
||||||
|
case "{?.Proc Title}":
|
||||||
|
addedtxt = AddOptionalTransitionProcTitle(addedtxt, token, nontoken, toitem);
|
||||||
break;
|
break;
|
||||||
case "{First Step}": // TODO: For hlp: LowerCaseTranNumber - lower case substep numbers in transitions
|
case "{First Step}": // TODO: For hlp: LowerCaseTranNumber - lower case substep numbers in transitions
|
||||||
// If we're on a step put out the step number.
|
// If we're on a step put out the step number.
|
||||||
ItemInfo secitm = TranGetSectionItem(toitem);
|
ItemInfo secitm = TranGetSectionItem(toitem);
|
||||||
if ((!((etm & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone)) || toitem.MyContent.Type > 20000)
|
if ((!((etm & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone)) || toitem.MyContent.Type > 20000)
|
||||||
{
|
{
|
||||||
Append(nontoken, false);
|
if (addedtxt) Append(nontoken, false);
|
||||||
Append(toitem.Ordinal.ToString(), true);
|
Append(toitem.Ordinal.ToString(), true);
|
||||||
|
addedtxt = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "{Last Step}": // TODO: TStepNoFlag, i.e. include step number in range items.
|
case "{Last Step}": // TODO: TStepNoFlag, i.e. include step number in range items.
|
||||||
Append(nontoken, false);
|
if (addedtxt) Append(nontoken, false);
|
||||||
Append(rangeitem.Ordinal.ToString(), true);
|
Append(rangeitem.Ordinal.ToString(), true);
|
||||||
|
addedtxt = true;
|
||||||
break;
|
break;
|
||||||
case "{.}": // TODO: TStepNoFlag, i.e. include step number in range items.
|
case "{.}": // TODO: TStepNoFlag, i.e. include step number in range items.
|
||||||
Append(nontoken, false);
|
if (addedtxt) Append(nontoken, false);
|
||||||
Append("#", true); // TODO: Intermediate Range.
|
Append("#", true); // TODO: Intermediate Range.
|
||||||
|
addedtxt = true;
|
||||||
break;
|
break;
|
||||||
case "{Sect Hdr}":
|
case "{Sect Hdr}":
|
||||||
AddTranGetSectionHdr(nontoken, toitem);
|
addedtxt = AddTranGetSectionHdr(addedtxt, nontoken, toitem);
|
||||||
|
break;
|
||||||
|
case "{?.Sect Hdr}":
|
||||||
|
addedtxt = AddOptionalTranGetSectionHdr(addedtxt, token, nontoken, toitem);
|
||||||
break;
|
break;
|
||||||
case "{Sect Title}":
|
case "{Sect Title}":
|
||||||
AddTranGetSectionTitle(nontoken, toitem);
|
// output from 16-bit code looks like section header
|
||||||
|
addedtxt = AddTranGetSectionHdr(addedtxt, nontoken, toitem);
|
||||||
|
//AddTranGetSectionTitle(nontoken, toitem);
|
||||||
|
break;
|
||||||
|
case "{?.Sect Title}":
|
||||||
|
// output from 16-bit code looks like section header
|
||||||
|
addedtxt = AddOptionalTranGetSectionHdr(addedtxt, token, nontoken, toitem);
|
||||||
|
//AddOptionalTranGetSectionTitle(token, nontoken, toitem);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
startIndex = endtokn+1;
|
startIndex = endtokn+1;
|
||||||
@ -76,7 +98,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
retstr.Append(str);
|
retstr.Append(str);
|
||||||
}
|
}
|
||||||
private void AddTransitionProcTitle(string nontoken, ItemInfo toitem)
|
private bool AddTransitionProcTitle(bool addedtxt, string nontoken, ItemInfo toitem)
|
||||||
{
|
{
|
||||||
string parenstr = toitem.MyProcedure.MyContent.Text;
|
string parenstr = toitem.MyProcedure.MyContent.Text;
|
||||||
StringBuilder lretstr = new StringBuilder();
|
StringBuilder lretstr = new StringBuilder();
|
||||||
@ -90,25 +112,45 @@ namespace VEPROMS.CSLA.Library
|
|||||||
lretstr.Append(_MyFormatData.TransData.DelimiterForTransitionTitle);
|
lretstr.Append(_MyFormatData.TransData.DelimiterForTransitionTitle);
|
||||||
}
|
}
|
||||||
// LATER: if (DoSectionTransitions && GetSTepNO(TSeq1)) TransitionCat(AddCommaStep", Step"));
|
// LATER: if (DoSectionTransitions && GetSTepNO(TSeq1)) TransitionCat(AddCommaStep", Step"));
|
||||||
if (nontoken != null) Append(nontoken, false);
|
if (addedtxt) Append(nontoken, false);
|
||||||
Append(lretstr.ToString(), true);
|
Append(lretstr.ToString(), true);
|
||||||
|
if (lretstr.Length != 0) return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CapFirstLetterOnly(string retstr, int p)
|
private string CapFirstLetterOnly(string retstr, int p)
|
||||||
{
|
{
|
||||||
string lretstr = retstr;
|
string lretstr = retstr;
|
||||||
// LATER: write code to capitalize first letter (active plants)
|
// LATER: write code to capitalize first letter (active plants)
|
||||||
return lretstr;
|
return lretstr;
|
||||||
}
|
}
|
||||||
|
private bool AddOptionalTransitionProcTitle(bool addedtxt, string token, string nontoken, ItemInfo toitem)
|
||||||
|
{
|
||||||
|
// token is passed in for future use, i.e. if text is placed between "?" and "." to
|
||||||
|
// request other processing.
|
||||||
|
|
||||||
private void AddTransitionProcNum(string nontoken, ItemInfo toitem)
|
// for now the only test is to check if the toitem is in the current procedure.
|
||||||
|
if (_MyFromItemInfo.MyProcedure.ItemID == toitem.MyProcedure.ItemID) return addedtxt?true:false;
|
||||||
|
return AddTransitionProcTitle(addedtxt, nontoken, toitem);
|
||||||
|
}
|
||||||
|
private bool AddTransitionProcNum(bool addedtxt, string nontoken, ItemInfo toitem)
|
||||||
{
|
{
|
||||||
string retstr = toitem.MyProcedure.MyContent.Number;
|
string retstr = toitem.MyProcedure.MyContent.Number;
|
||||||
// LATER: start with UnitSpecific procedure number.
|
// LATER: start with UnitSpecific procedure number.
|
||||||
// LATER: Format Flag TruncateProcNmAfter1stSpace (dropped plants)
|
// LATER: Format Flag TruncateProcNmAfter1stSpace (dropped plants)
|
||||||
// LATER: Format Flag HardSpTranProcNumb (active plants)
|
// LATER: Format Flag HardSpTranProcNumb (active plants)
|
||||||
if (nontoken != null) Append(nontoken, false);
|
if (addedtxt) Append(nontoken, false);
|
||||||
Append(retstr, true);
|
Append(retstr, true);
|
||||||
|
if (retstr != null && retstr != "") return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private bool AddOptionalTransitionProcNum(bool addedtxt, string token, string nontoken, ItemInfo toitem)
|
||||||
|
{
|
||||||
|
// token is passed in for future use, i.e. if text is placed between "?" and "." to
|
||||||
|
// request other processing.
|
||||||
|
|
||||||
|
// for now the only test is to check if the toitem is in the current procedure.
|
||||||
|
if (_MyFromItemInfo.MyProcedure.ItemID == toitem.MyProcedure.ItemID) return addedtxt ? true : false;
|
||||||
|
return AddTransitionProcNum(addedtxt, nontoken, toitem);
|
||||||
}
|
}
|
||||||
// TODO: Section methods are not complete....
|
// TODO: Section methods are not complete....
|
||||||
private ItemInfo TranGetSectionItem(ItemInfo itminfo)
|
private ItemInfo TranGetSectionItem(ItemInfo itminfo)
|
||||||
@ -117,18 +159,36 @@ namespace VEPROMS.CSLA.Library
|
|||||||
while (tmpitm.MyContent.Type >= 20000) tmpitm = tmpitm.MyParent;
|
while (tmpitm.MyContent.Type >= 20000) tmpitm = tmpitm.MyParent;
|
||||||
return tmpitm;
|
return tmpitm;
|
||||||
}
|
}
|
||||||
private void AddTranGetSectionHdr(string nontoken, ItemInfo itminfo)
|
private bool AddTranGetSectionHdr(bool addedtxt, string nontoken, ItemInfo itminfo)
|
||||||
{
|
{
|
||||||
// if this is a step section & the default section, just return
|
// if this is a step section & the default section, just return
|
||||||
if (TranGetSectionItem(itminfo).IsDefaultSection) return;
|
//if (TranGetSectionItem(itminfo).IsDefaultSection) return;
|
||||||
StringBuilder retstr = new StringBuilder();
|
StringBuilder retstr = new StringBuilder();
|
||||||
retstr.Append(TranGetSectionNumber(itminfo));
|
retstr.Append(TranGetSectionNumber(itminfo));
|
||||||
string txt = TranGetSectionTitle(itminfo);
|
string txt = TranGetSectionTitle(itminfo);
|
||||||
if (retstr.Length>0 && txt.Length>0) retstr.Append(", ");
|
if (retstr.Length>0 && txt.Length>0) retstr.Append(", ");
|
||||||
retstr.Append(txt);
|
retstr.Append(txt);
|
||||||
Append(nontoken, false);
|
if (addedtxt) Append(nontoken, false);
|
||||||
Append(retstr.ToString(), true);
|
Append(retstr.ToString(), true);
|
||||||
|
if (retstr.Length != 0) return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
private bool AddOptionalTranGetSectionHdr(bool addedtxt, string token, string nontoken, ItemInfo toitem)
|
||||||
|
{
|
||||||
|
// token is passed in for future use, i.e. if text is placed between "?" and "." to
|
||||||
|
// request other processing.
|
||||||
|
|
||||||
|
// If in same procedure, the section header is put out if not in the same section.
|
||||||
|
// If in a different procedure, the section header is put out if the 'to' item is not the
|
||||||
|
// default (or start) section.
|
||||||
|
if (_MyFromItemInfo.MyProcedure.ItemID == toitem.MyProcedure.ItemID)
|
||||||
|
{
|
||||||
|
if (TranGetSectionItem(_MyFromItemInfo).ItemID == TranGetSectionItem(toitem).ItemID) return addedtxt ? true : false;
|
||||||
|
}
|
||||||
|
else if (TranGetSectionItem(toitem).IsDefaultSection) return addedtxt ? true : false;
|
||||||
|
return AddTranGetSectionHdr(addedtxt, nontoken, toitem);
|
||||||
|
}
|
||||||
|
|
||||||
private string TranGetSectionNumber(ItemInfo itminfo)
|
private string TranGetSectionNumber(ItemInfo itminfo)
|
||||||
{
|
{
|
||||||
ItemInfo tmpitm = TranGetSectionItem(itminfo);
|
ItemInfo tmpitm = TranGetSectionItem(itminfo);
|
||||||
@ -144,15 +204,30 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
private void AddTranGetSectionTitle(string nontoken, ItemInfo itminfo)
|
private bool AddOptionalTranGetSectionTitle(bool addedtxt, string token, string nontoken, ItemInfo toitem)
|
||||||
|
{
|
||||||
|
// token is passed in for future use, i.e. if text is placed between "?" and "." to
|
||||||
|
// request other processing.
|
||||||
|
|
||||||
|
// for now the only test is to check if the toitem is in the current section.
|
||||||
|
if (TranGetSectionItem(_MyFromItemInfo).ItemID == TranGetSectionItem(toitem).ItemID) return addedtxt ? true : false;
|
||||||
|
if (addedtxt) Append(nontoken, false);
|
||||||
|
string retstr = TranGetSectionTitle(toitem);
|
||||||
|
Append(retstr, true);
|
||||||
|
if (retstr != null && retstr != "") return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private bool AddTranGetSectionTitle(bool addedtxt, string nontoken, ItemInfo itminfo)
|
||||||
{
|
{
|
||||||
// LATER: Cap1stSectionTitle, CapFirstLetterOnly
|
// LATER: Cap1stSectionTitle, CapFirstLetterOnly
|
||||||
if (_MyFormatData.TransData.UseSecTitles)
|
if (_MyFormatData.TransData.UseSecTitles)
|
||||||
{
|
{
|
||||||
string txt = TranGetSectionTitle(itminfo);
|
string retstr = TranGetSectionTitle(itminfo);
|
||||||
if (txt.Length>0)Append(nontoken, false);
|
if (addedtxt)Append(nontoken, false);
|
||||||
Append(txt, true);
|
Append(retstr, true);
|
||||||
|
if (retstr != null && retstr != "") return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
public string PathTo
|
public string PathTo
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user