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
|
// Modified
|
||||||
foreach (ReplaceStr origrepstr in OriginalPlantFormat.FormatData.SectData.ReplaceStrList)
|
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 ((ucfrepstr.ReplaceWith != origrepstr.ReplaceWith) && ucfrepstr.Flag != 0 && ucfrepstr.ReplaceWith != "")
|
||||||
if (((E_ReplaceFlags)ucfrepstr.Flag != origrepstr.Flag || ucfrepstr.ReplaceWith != origrepstr.ReplaceWith) && ucfrepstr.Flag != 0 && ucfrepstr.ReplaceWith != "")
|
|
||||||
{
|
{
|
||||||
ucfrepstr.State = 2;
|
ucfrepstr.State = 2;
|
||||||
retlist.Add(ucfrepstr);
|
retlist.Add(ucfrepstr);
|
||||||
@ -494,22 +494,50 @@ namespace VEPROMS
|
|||||||
if (!origstrList.Contains(ucfrepstr.ReplaceWord))
|
if (!origstrList.Contains(ucfrepstr.ReplaceWord))
|
||||||
{
|
{
|
||||||
// check for valid data, i.e. flag set & both replaceword & with not blank
|
// 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 != "")
|
if (ucfrepstr.Flag != 0 && ucfrepstr.ReplaceWith != null && ucfrepstr.ReplaceWith != "" && ucfrepstr.ReplaceWord != null && ucfrepstr.ReplaceWord != "")
|
||||||
{
|
{
|
||||||
ucfrepstr.State = 1;
|
ucfrepstr.State = 1;
|
||||||
retlist.Add(ucfrepstr);
|
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:
|
//Deleted:
|
||||||
List<string> ucfList = new List<string>(); // used to find 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 (FormatConfig.ReplaceStr ucfrepstr in MyFormatConfig.PlantFormat.FormatData.ReplaceStrData) ucfList.Add(ucfrepstr.ReplaceWord);
|
||||||
foreach (ReplaceStr origrepstr in OriginalPlantFormat.FormatData.SectData.ReplaceStrList)
|
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}")))
|
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
|
// make a deleted replacestr to save
|
||||||
FormatConfig.ReplaceStr del = new FormatConfig.ReplaceStr();
|
FormatConfig.ReplaceStr del = new FormatConfig.ReplaceStr();
|
||||||
@ -517,13 +545,22 @@ namespace VEPROMS
|
|||||||
del.Flag = (FormatConfig.E_ReplaceFlagsUCF)origrepstr.Flag;
|
del.Flag = (FormatConfig.E_ReplaceFlagsUCF)origrepstr.Flag;
|
||||||
del.ReplaceWord = origrepstr.ReplaceWord;
|
del.ReplaceWord = origrepstr.ReplaceWord;
|
||||||
del.ReplaceWith = origrepstr.ReplaceWith;
|
del.ReplaceWith = origrepstr.ReplaceWith;
|
||||||
//del.ReplaceWith = origrepstr.ReplaceWith;
|
|
||||||
retlist.Add(del);
|
retlist.Add(del);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return retlist;
|
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.
|
// The following uses the original format's ReplaceWords list and applies any changes made from the UCF ReplaceWords list.
|
||||||
private FormatConfig.ReplaceStrData GetMergedReplaceList()
|
private FormatConfig.ReplaceStrData GetMergedReplaceList()
|
||||||
{
|
{
|
||||||
@ -539,7 +576,7 @@ namespace VEPROMS
|
|||||||
// States for replacewords: 0 = no change, -1 deleted, 1 added, 2 modified
|
// States for replacewords: 0 = no change, -1 deleted, 1 added, 2 modified
|
||||||
foreach (FormatConfig.ReplaceStr ucfrepstr in MyFormatConfig.PlantFormat.FormatData.ReplaceStrData)
|
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;
|
if (ucfrepstr.State == -1) deleted = true;
|
||||||
else usethisone = ucfrepstr;
|
else usethisone = ucfrepstr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user