B2019-113: UCF showing replace words as changed when they were not
This commit is contained in:
parent
344f645b0c
commit
4f2c06df4b
@ -474,10 +474,10 @@ namespace VEPROMS
|
||||
// Modified
|
||||
foreach (ReplaceStr origrepstr in OriginalPlantFormat.FormatData.SectData.ReplaceStrList)
|
||||
{
|
||||
if (origrepstr.ReplaceWord.Replace("{Backspace}", "") == ucfrepstr.ReplaceWord.Replace("{Backspace}", ""))
|
||||
// B2019-113: consider replace word AND flags to determine if there was a modification
|
||||
if (origrepstr.ReplaceWord.Replace("{Backspace}", "") == ucfrepstr.ReplaceWord.Replace("{Backspace}", "") && (E_ReplaceFlags)ucfrepstr.Flag == origrepstr.Flag)
|
||||
{
|
||||
// if deleted or if anything is different, save it
|
||||
if (((E_ReplaceFlags)ucfrepstr.Flag != origrepstr.Flag || ucfrepstr.ReplaceWith != origrepstr.ReplaceWith) && ucfrepstr.Flag != 0 && ucfrepstr.ReplaceWith != "")
|
||||
if ((ucfrepstr.ReplaceWith != origrepstr.ReplaceWith) && ucfrepstr.Flag != 0 && ucfrepstr.ReplaceWith != "")
|
||||
{
|
||||
ucfrepstr.State = 2;
|
||||
retlist.Add(ucfrepstr);
|
||||
@ -494,36 +494,73 @@ namespace VEPROMS
|
||||
if (!origstrList.Contains(ucfrepstr.ReplaceWord))
|
||||
{
|
||||
// check for valid data, i.e. flag set & both replaceword & with not blank
|
||||
//if (ucfrepstr.Flag != 0 && ucfrepstr.ReplaceWith != null && ucfrepstr.ReplaceWith != "" && ucfrepstr.ReplaceWord != null && ucfrepstr.ReplaceWord != "")
|
||||
if (ucfrepstr.Flag != 0 && ucfrepstr.ReplaceWith != null && ucfrepstr.ReplaceWith != "" && ucfrepstr.ReplaceWord != null && ucfrepstr.ReplaceWord != "")
|
||||
{
|
||||
ucfrepstr.State = 1;
|
||||
retlist.Add(ucfrepstr);
|
||||
}
|
||||
}
|
||||
else // B2019-113: replace word is in the original list, see if this word was added with different flags
|
||||
{
|
||||
if (!RepWrdSameWordSameFlags(OriginalPlantFormat.FormatData.SectData.ReplaceStrList, ucfrepstr))
|
||||
{
|
||||
ucfrepstr.State = 1;
|
||||
retlist.Add(ucfrepstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Deleted:
|
||||
List<string> ucfList = new List<string>(); // used to find deleted
|
||||
foreach (FormatConfig.ReplaceStr ucfrepstr in MyFormatConfig.PlantFormat.FormatData.ReplaceStrData) ucfList.Add(ucfrepstr.ReplaceWord);
|
||||
foreach (ReplaceStr origrepstr in OriginalPlantFormat.FormatData.SectData.ReplaceStrList)
|
||||
{
|
||||
if (!ucfList.Contains(origrepstr.ReplaceWord))
|
||||
bool addtodeletelist = false;
|
||||
if (!ucfList.Contains(origrepstr.ReplaceWord) )
|
||||
{
|
||||
if (!((origrepstr.ReplaceWith.Contains("$1") && origrepstr.ReplaceWord.Contains("w*")) || origrepstr.ReplaceWith.Contains("{Backspace}")))
|
||||
{
|
||||
addtodeletelist = true;
|
||||
}
|
||||
}
|
||||
else // // B2019-113: for this ucf replaceword, see if its flag is in the original list
|
||||
{
|
||||
foreach (FormatConfig.ReplaceStr ucfrepstruct in MyFormatConfig.PlantFormat.FormatData.ReplaceStrData)
|
||||
{
|
||||
if (origrepstr.ReplaceWord.Replace("{Backspace}", "") == ucfrepstruct.ReplaceWord.Replace("{Backspace}", ""))
|
||||
{
|
||||
// only deleted if replace word AND flags match:
|
||||
if (!RepWrdSameWordSameFlags(OriginalPlantFormat.FormatData.SectData.ReplaceStrList, ucfrepstruct))
|
||||
{
|
||||
addtodeletelist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addtodeletelist)
|
||||
{
|
||||
// make a deleted replacestr to save
|
||||
FormatConfig.ReplaceStr del = new FormatConfig.ReplaceStr();
|
||||
del.State = -1;
|
||||
del.Flag = (FormatConfig.E_ReplaceFlagsUCF)origrepstr.Flag;
|
||||
del.ReplaceWord = origrepstr.ReplaceWord;
|
||||
del.ReplaceWith = origrepstr.ReplaceWith;
|
||||
//del.ReplaceWith = origrepstr.ReplaceWith;
|
||||
retlist.Add(del);
|
||||
}
|
||||
}
|
||||
}
|
||||
return retlist;
|
||||
}
|
||||
|
||||
private bool RepWrdSameWordSameFlags(ReplaceStrList replaceStrList, FormatConfig.ReplaceStr ucfrepstr)
|
||||
{
|
||||
// B2019-133: if the replace word is the same, see if the UCF flag is different. The Replace Word & the flags need to be the same for it to be a match.
|
||||
List<FormatConfig.E_ReplaceFlagsUCF> flags = new List<FormatConfig.E_ReplaceFlagsUCF>();
|
||||
foreach (ReplaceStr origrepstr in replaceStrList)
|
||||
{
|
||||
if (origrepstr.ReplaceWord.Replace("{Backspace}", "") == ucfrepstr.ReplaceWord.Replace("{Backspace}", "")) flags.Add(ucfrepstr.Flag);
|
||||
}
|
||||
return (flags.Contains(ucfrepstr.Flag));
|
||||
}
|
||||
// The following uses the original format's ReplaceWords list and applies any changes made from the UCF ReplaceWords list.
|
||||
private FormatConfig.ReplaceStrData GetMergedReplaceList()
|
||||
{
|
||||
@ -539,7 +576,7 @@ namespace VEPROMS
|
||||
// States for replacewords: 0 = no change, -1 deleted, 1 added, 2 modified
|
||||
foreach (FormatConfig.ReplaceStr ucfrepstr in MyFormatConfig.PlantFormat.FormatData.ReplaceStrData)
|
||||
{
|
||||
if (ucfrepstr.ReplaceWord == origrepstr.ReplaceWord)
|
||||
if (ucfrepstr.ReplaceWord == origrepstr.ReplaceWord && (E_ReplaceFlags)ucfrepstr.Flag == origrepstr.Flag)
|
||||
{
|
||||
if (ucfrepstr.State == -1) deleted = true;
|
||||
else usethisone = ucfrepstr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user