From 1d760eab812b307422d1882e0f59e1757e004595 Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 10 Apr 2014 20:13:15 +0000 Subject: [PATCH] Fixed Cache for ItemInfo - This was causing steps to not be undated in the editor or the tree. Unique Key for ROFst Lookup --- .../Extension/ItemInsertExt.cs | 27 ++++++++++--------- .../Extension/ROFSTExt.cs | 3 ++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 8a9af52b..2fe2bc4b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -547,6 +547,7 @@ namespace VEPROMS.CSLA.Library else tmp = DataPortal.Fetch(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID)); } + AddToCache(tmp); return tmp; } public void UpdateTransitionText() @@ -1055,6 +1056,19 @@ namespace VEPROMS.CSLA.Library _MyPrevious = null; // Reset list so that the next line gets a new list if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value } + internal static ItemInfo CopyPasteReplaceItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType) + { + ItemInfo tmp = null; + if (itemInfo.GetType() == typeof(ProcedureInfo)) + tmp = DataPortal.Fetch(new ItemInfo.PastingPartCriteria(copyStartID, itemInfo.ItemID, ItemInfo.EAddpingPart.Replace, itemInfo.MyContent.Type, itemInfo.MyContent.Type, DateTime.Now, Volian.Base.Library.VlnSettings.UserID)); + else if (itemInfo.GetType() == typeof(SectionInfo)) + tmp = DataPortal.Fetch(new ItemInfo.PastingPartCriteria(copyStartID, itemInfo.ItemID, ItemInfo.EAddpingPart.Replace, itemInfo.MyContent.Type, itemInfo.MyContent.Type, DateTime.Now, Volian.Base.Library.VlnSettings.UserID)); + else + tmp = DataPortal.Fetch(new ItemInfo.PastingPartCriteria(copyStartID, itemInfo.ItemID, ItemInfo.EAddpingPart.Replace, itemInfo.MyContent.Type, itemInfo.MyContent.Type, DateTime.Now, Volian.Base.Library.VlnSettings.UserID)); + AddToCache(tmp); + return tmp; + } + } public partial class Item { @@ -1173,7 +1187,7 @@ namespace VEPROMS.CSLA.Library throw new System.Security.SecurityException("User not authorized to remove a Item"); try { - ItemInfo newItemInfo = CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type); + ItemInfo newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type); // Delete business objects, including remove from tree ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children using (Item item = Get(newItemInfo.ItemID)) ItemInfo.Refresh(item); @@ -1213,17 +1227,6 @@ namespace VEPROMS.CSLA.Library return itemInfo; } } - private static ItemInfo CopyPasteReplaceItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType) - { - ItemInfo tmp = null; - if (itemInfo.GetType() == typeof(ProcedureInfo)) - tmp = DataPortal.Fetch(new ItemInfo.PastingPartCriteria(copyStartID, itemInfo.ItemID, ItemInfo.EAddpingPart.Replace, itemInfo.MyContent.Type, itemInfo.MyContent.Type, DateTime.Now, Volian.Base.Library.VlnSettings.UserID)); - else if (itemInfo.GetType() == typeof(SectionInfo)) - tmp = DataPortal.Fetch(new ItemInfo.PastingPartCriteria(copyStartID, itemInfo.ItemID, ItemInfo.EAddpingPart.Replace, itemInfo.MyContent.Type, itemInfo.MyContent.Type, DateTime.Now, Volian.Base.Library.VlnSettings.UserID)); - else - tmp = DataPortal.Fetch(new ItemInfo.PastingPartCriteria(copyStartID, itemInfo.ItemID, ItemInfo.EAddpingPart.Replace, itemInfo.MyContent.Type, itemInfo.MyContent.Type, DateTime.Now, Volian.Base.Library.VlnSettings.UserID)); - return tmp; - } #endregion } } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs index b692b99c..a5750059 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs @@ -174,7 +174,8 @@ namespace VEPROMS.CSLA.Library public ROFSTLookup GetROFSTLookup(DocVersionInfo dvi) { //string key = string.Format("{0}.{1}",dvi.DocVersionAssociations[0].ROFstID,dvi.DocVersionConfig.SelectedSlave); - string key = string.Format("{0}.{1}.{2}", ROFstID, dvi.DocVersionConfig.MaxSlaveIndex, dvi.DocVersionConfig.SelectedSlave); if (!dicLookups.ContainsKey(key)) + string key = string.Format("{0}.{1}.{2}", ROFstID, dvi.DocVersionConfig.MaxSlaveIndex, dvi.DocVersionConfig.SelectedSlave); + if (!dicLookups.ContainsKey(key)) dicLookups.Add(key, new ROFSTLookup(this, dvi)); return dicLookups[key]; }