|
|
|
@@ -3849,7 +3849,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
// When This occurs, it will cause a
|
|
|
|
// When This occurs, it will cause a
|
|
|
|
// "ThreadException ... Collection was modified; enumeration operation may not execute.”
|
|
|
|
// "ThreadException ... Collection was modified; enumeration operation may not execute.”
|
|
|
|
// **********************
|
|
|
|
// **********************
|
|
|
|
public static ProcedureInfo ResetProcedure(int procID)
|
|
|
|
public static ProcedureInfo ResetProcedure(int procID, bool resetindisplaytab = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// The following lines reload the procedure info cache
|
|
|
|
// The following lines reload the procedure info cache
|
|
|
|
ProcedureInfo newproc = ProcedureInfo.Get(procID, true);
|
|
|
|
ProcedureInfo newproc = ProcedureInfo.Get(procID, true);
|
|
|
|
@@ -3867,24 +3867,28 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
ItemInfo newprocitem = Get(procID, true);
|
|
|
|
ItemInfo newprocitem = Get(procID, true);
|
|
|
|
newprocitem.RefreshConfig();
|
|
|
|
newprocitem.RefreshConfig();
|
|
|
|
|
|
|
|
|
|
|
|
//Reload all the child/sub items
|
|
|
|
if (!resetindisplaytab)
|
|
|
|
#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<int> 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();
|
|
|
|
|
|
|
|
#pragma warning restore S2971 // LINQ expressions should be simplified
|
|
|
|
|
|
|
|
for (int index = 0; index < itemIDs.Count; index++)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ResetParts(itemIDs[index]);
|
|
|
|
//Reload all the child/sub items
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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
|
|
|
|
#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
|
|
|
|
//otherwise will get a "Collection was modified; enumeration operation may not execute" error
|
|
|
|
List<ItemInfo> pconfigrefresh_items = _CacheByPrimaryKey.Values.ToList().SelectMany(y => y).Where(t => t?.MyProcedure?.ItemID == procID).Distinct().ToList();
|
|
|
|
List<int> 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();
|
|
|
|
#pragma warning restore S2971 // LINQ expressions should be simplified
|
|
|
|
#pragma warning restore S2971 // LINQ expressions should be simplified
|
|
|
|
for (int index = 0; index < pconfigrefresh_items.Count; index++)
|
|
|
|
for (int index = 0; index < itemIDs.Count; index++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pconfigrefresh_items[index].MyProcedure = newproc;
|
|
|
|
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<ItemInfo> 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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//return the changed procedure info
|
|
|
|
//return the changed procedure info
|
|
|
|
|