F2021-034 Handle applicability in Procedure Specific Information (PSI)

This commit is contained in:
Kathy Ruffing 2021-09-30 15:14:23 +00:00
parent c0d8d17a91
commit 6ce4b632ce

View File

@ -2145,14 +2145,7 @@ i = 0;
}
if (token.Contains(@"PS-"))
{
//Console.WriteLine("RefreshConfig {0} {1}", section.MyProcedure.ItemID, section.MyProcedure.MyItemInfoUnique);
//section.MyProcedure.RefreshConfig();
//ProcedureConfig procConfig = section.MyProcedure.MyConfig as ProcedureConfig;
//Console.WriteLine("> ProcConfig {0} {1}",procConfig,section.MyProcedure.MyItemInfoUnique);
//Console.WriteLine("> MyContent {0}", section.MyProcedure.MyContent.Config);
//section.MyProcedure.RefreshConfig();
ProcedureConfig procConfig = new ProcedureConfig(section.MyProcedure.MyContent.Config);
//Console.WriteLine("< ProcConfig {0}", procConfig);
if (procConfig != null)
{
int indx = token.IndexOf("-");
@ -2161,10 +2154,11 @@ i = 0;
if (qindx == -1)
{
val = procConfig.GetValue("PSI", token.Substring(4, token.Length - 5));
if(val.Contains("<u>")) // Replace <u> with the current unit number
// F2021-034: Resolve applicability unit tokens (not just '<u>')
if(val.ToUpper().Contains("<U>") || val.ToUpper().Contains("<U-")) // Replace token with the applicable unit information
{
string unbr3 = MySection.MyDocVersion.DocVersionConfig.Unit_Number;
val=val.Replace("<u>", unbr3??"");
string unbr3 = ResolveUnitApp(MySection.MyDocVersion, val);
val = unbr3 ?? "";
}
// MaxWidth is used to define width that the PSI text spans x-direction on page. If it is
// defined, see if the text is too wide for a single line (SplitTextMaxWidth). The
@ -2219,6 +2213,28 @@ i = 0;
}
return retval;
}
// F2021-034: Resolve applicability unit tokens (not just '<u>')
private string ResolveUnitApp(DocVersionInfo dvi, string str)
{
string tmp = str.ToUpper();
int sindx = tmp.IndexOf("<U");
int eindx = tmp.IndexOf(">", sindx + 1);
string reptmp = str.Substring(sindx, eindx - sindx+1);
tmp = reptmp.ToUpper();
if (reptmp != "" && dvi != null)
{
if (tmp == "<U>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Number);
else if (tmp == "<U-TEXT>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Text);
else if (tmp == "<U-NUMBER>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Number);
else if (tmp == "<U-NAME>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_Name);
else if (tmp == "<U-ID>") str = str.Replace(reptmp, dvi.DocVersionConfig.Unit_ID);
else if (tmp == "<U-OTHER TEXT>") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Text);
else if (tmp == "<U-OTHER NUMBER>") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Number);
else if (tmp == "<U-OTHER NAME>") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_Name);
else if (tmp == "<U-OTHER ID>") str = str.Replace(reptmp, dvi.DocVersionConfig.Other_Unit_ID);
}
return str;
}
// B2019-076: moved the following to DocVersionExt.cs to make it available to transitionext.cs code.
//private string GetInheritedSIValue(ProcedureInfo pi, string fieldName)
//{