C2025-022-Remove-UCF-2

This commit is contained in:
2025-08-28 15:24:28 -04:00
parent 525173bc9f
commit 8abe57552c
12 changed files with 116 additions and 767 deletions

View File

@@ -126,72 +126,76 @@ namespace VEPROMS.CSLA.Library
XmlNodeList nl = XmlDoc.SelectNodes(xpath);
return nl.Count > 0;
}
private FormatConfig.ReplaceStrData _UCFandOrigReplaceStrData = null;
// This will return a complete list of ReplaceWords, combining those in the original plant format
// with the ones added by the user via User Control of Format (UCF)
public FormatConfig.ReplaceStrData UCFandOrigReplaceStrData
{
get
{
if (_UCFandOrigReplaceStrData != null) return _UCFandOrigReplaceStrData;
_UCFandOrigReplaceStrData = GetMergedReplaceList(this);
return _UCFandOrigReplaceStrData;
}
}
private FormatConfig.ReplaceStrData GetMergedReplaceList(PlantFormat OriginalPlantFormat)
{
// need to compare the original format list with the list as it is stored for working with property grid.
FormatConfig.ReplaceStrData retlist = new FormatConfig.ReplaceStrData(); // merged list
List<string> inoriglist = new List<string>(); // use this list to find new items in formatconfig (see below)
foreach (ReplaceStr origrepstr in OriginalPlantFormat.FormatData.SectData.ReplaceStrList)
{
// In the format config list (UCF), find the 'ReplaceWord'. This is the 'key' for defining whether the
// replace word has been overwridden by UCF data. If it exists, use it:
FormatConfig.ReplaceStr usethisone = null;
bool deleted = false;
// States for replacewords: 0 = no change, -1 deleted, 1 added, 2 modified
if (FormatConfig != null)
{
foreach (FormatConfig.ReplaceStr ucfrepstr in FormatConfig.PlantFormat.FormatData.ReplaceStrData)
{
if (ucfrepstr.ReplaceWord == origrepstr.ReplaceWord)
{
if (ucfrepstr.State == -1) deleted = true;
else usethisone = ucfrepstr;
ucfrepstr.State = 2;
inoriglist.Add(origrepstr.ReplaceWord);
break;
}
}
}
if (!deleted && usethisone == null)
{
usethisone = new FormatConfig.ReplaceStr();
usethisone.Flag = (FormatConfig.E_ReplaceFlagsUCF)origrepstr.Flag;
usethisone.State = 0; // no change
usethisone.ReplaceWith = origrepstr.ReplaceWith;
usethisone.ReplaceWord = origrepstr.ReplaceWord;
}
if (!deleted) retlist.Add(usethisone);
}
// now add in any ucf only replacements, any that are not in the inoriglist
if (FormatConfig != null)
{
foreach (FormatConfig.ReplaceStr ucfrepstr in FormatConfig.PlantFormat.FormatData.ReplaceStrData)
{
if (!inoriglist.Contains(ucfrepstr.ReplaceWord))
{
FormatConfig.ReplaceStr newone = new FormatConfig.ReplaceStr();
newone.Flag = (FormatConfig.E_ReplaceFlagsUCF)ucfrepstr.Flag;
newone.State = 1;
newone.ReplaceWith = ucfrepstr.ReplaceWith;
newone.ReplaceWord = ucfrepstr.ReplaceWord;
retlist.Add(newone);
}
}
}
return (retlist);
}
//private FormatConfig.ReplaceStrData _UCFandOrigReplaceStrData = null;
//// This will return a complete list of ReplaceWords, combining those in the original plant format
//// with the ones added by the user via User Control of Format (UCF)
//public ReplaceStrData UCFandOrigReplaceStrData
//{
// get
// {
// if (_UCFandOrigReplaceStrData != null) return _UCFandOrigReplaceStrData;
// _UCFandOrigReplaceStrData = GetMergedReplaceList(this);
// return _UCFandOrigReplaceStrData;
// }
//}
//private FormatConfig.ReplaceStrData GetMergedReplaceList(PlantFormat OriginalPlantFormat)
//{
// need to compare the original format list with the list as it is stored for working with property grid.
// FormatConfig.ReplaceStrData retlist = new FormatConfig.ReplaceStrData(); // merged list
// List<string> inoriglist = new List<string>(); // use this list to find new items in formatconfig (see below)
// foreach (ReplaceStr origrepstr in OriginalPlantFormat.FormatData.SectData.ReplaceStrList)
// {
// In the format config list(UCF), find the 'ReplaceWord'.This is the 'key' for defining whether the
// replace word has been overwridden by UCF data.If it exists, use it:
// ReplaceStr usethisone = null;
// bool deleted = false;
// States for replacewords: 0 = no change, -1 deleted, 1 added, 2 modified
// if (FormatConfig != null)
// {
// foreach (ReplaceStr ucfrepstr in FormatConfig.PlantFormat.FormatData.ReplaceStrData)
// {
// if (ucfrepstr.ReplaceWord == origrepstr.ReplaceWord)
// {
// if (ucfrepstr.State == -1) deleted = true;
// else usethisone = ucfrepstr;
// ucfrepstr.State = 2;
// inoriglist.Add(origrepstr.ReplaceWord);
// break;
// }
// }
// }
// if (!deleted && usethisone == null)
// {
// usethisone = new ReplaceStr();
// usethisone.Flag = (E_ReplaceFlags)origrepstr.Flag;
// usethisone.State = 0; // no change
// usethisone.ReplaceWith = origrepstr.ReplaceWith;
// usethisone.ReplaceWord = origrepstr.ReplaceWord;
// }
// if (!deleted) retlist.Add(usethisone);
// }
// now add in any ucf only replacements, any that are not in the inoriglist
// if (FormatConfig != null)
// {
// foreach (ReplaceStr ucfrepstr in PlantFormat.FormatData.ReplaceStrData)
// {
// if (!inoriglist.Contains(ucfrepstr.ReplaceWord))
// {
// ReplaceStr newone = new ReplaceStr();
// newone.Flag = (E_ReplaceFlags)ucfrepstr.Flag;
// newone.State = 1;
// newone.ReplaceWith = ucfrepstr.ReplaceWith;
// newone.ReplaceWord = ucfrepstr.ReplaceWord;
// retlist.Add(newone);
// }
// }
// }
// return (retlist);
//}
//C2025-023 - Electronic Procedures - Modifications to PROMS
// EPFormatFiles contains which Electronic Procedure Format files apply to this main format file.