diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 20138ced..c73eb983 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -628,16 +628,16 @@ namespace VEPROMS //B2019-140 Change bars do not get refreshed when approval is run. // Reset a Procedure and sub items in the cache + ProcedureInfo newproc = ItemInfo.ResetProcedure(pi.ItemID); //// Refresh the StepPanel for the current Procedure //// so change bars update //// on any open StepPanel - + //B2026-019 Attempt to prevent an Access Error by utilizing a different Refresh if a Procedure is Open DisplayTabItem dti = GetTabContainingProcedure(pi.ItemID); if (dti != null) { - _ = ItemInfo.ResetProcedure(pi.ItemID, true); if (!dti.MyStepTabPanel.MyStepPanel.ContainsFocus) dti.MyStepTabPanel.MyStepPanel.Focus(); @@ -646,13 +646,7 @@ namespace VEPROMS { eitm.ChangeBar = eitm.MyItemInfo.HasChangeBar; } - - dti.MyStepTabPanel.MyStepTabRibbon.RefreshProcedure(); } - else - { - _ = ItemInfo.ResetProcedure(pi.ItemID); - } } } } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index ca4b14bf..a2c4960e 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -3849,7 +3849,7 @@ namespace VEPROMS.CSLA.Library // When This occurs, it will cause a // "ThreadException ... Collection was modified; enumeration operation may not execute.” // ********************** - public static ProcedureInfo ResetProcedure(int procID, bool resetindisplaytab = false) + public static ProcedureInfo ResetProcedure(int procID) { // The following lines reload the procedure info cache ProcedureInfo newproc = ProcedureInfo.Get(procID, true); @@ -3867,30 +3867,27 @@ namespace VEPROMS.CSLA.Library ItemInfo newprocitem = Get(procID, true); newprocitem.RefreshConfig(); - if (!resetindisplaytab) - { - //Reload all the child/sub items + //Reload all the child/sub items #pragma warning disable S2971 // LINQ expressions should be simplified - need initial ToList to force enumeration - //otherwise will get a "Collection was modified; enumeration operation may not execute" error - List itemIDs = _CacheByPrimaryKey.Values.ToList().SelectMany(y => y).Where(t => t?.ActiveParent != null && (t.ActiveParent is ItemInfo) && t.MyProcedure.ItemID == procID).Select(x => (x.ActiveParent as ItemInfo).ItemID).Distinct().ToList(); + //otherwise will get a "Collection was modified; enumeration operation may not execute" error + List itemIDs = _CacheByPrimaryKey.SelectMany(kvp => kvp.Value).ToList().Where(t => t?.ActiveParent != null && (t.ActiveParent is ItemInfo) && t.MyProcedure.ItemID == procID).Select(x => (x.ActiveParent as ItemInfo).ItemID).Distinct().ToList(); #pragma warning restore S2971 // LINQ expressions should be simplified - for (int index = 0; index < itemIDs.Count; index++) - { - ResetParts(itemIDs[index]); - } - - //reset the procedure config for all items attached to current procedure -#pragma warning disable S2971 // LINQ expressions should be simplified - need initial ToList to force enumeration - //otherwise will get a "Collection was modified; enumeration operation may not execute" error - List pconfigrefresh_items = _CacheByPrimaryKey.Values.ToList().SelectMany(y => y).Where(t => t?.MyProcedure?.ItemID == procID).Distinct().ToList(); -#pragma warning restore S2971 // LINQ expressions should be simplified - for (int index = 0; index < pconfigrefresh_items.Count; index++) - { - pconfigrefresh_items[index].MyProcedure = newproc; - } - + for (int index = 0; index < itemIDs.Count; index++) + { + ResetParts(itemIDs[index]); } + //reset the procedure config for all items attached to current procedure +#pragma warning disable S2971 // LINQ expressions should be simplified - need initial ToList to force enumeration + //otherwise will get a "Collection was modified; enumeration operation may not execute" error + List pconfigrefresh_items = _CacheByPrimaryKey.SelectMany(kvp => kvp.Value).ToList().Where(t => t?.MyProcedure?.ItemID == procID).Distinct().ToList(); +#pragma warning restore S2971 // LINQ expressions should be simplified + for (int index = 0; index < pconfigrefresh_items.Count; index++) + { + pconfigrefresh_items[index].MyProcedure = newproc; + } + + //return the changed procedure info return newproc; }