diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs index e5cdcf04..4a55081d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs @@ -369,6 +369,13 @@ namespace VEPROMS.CSLA.Library { _Procedures = null; } + public static void ResetProcedures(int versionID) + { + string key = versionID.ToString(); + if (_CacheByPrimaryKey.ContainsKey(key)) + foreach (DocVersionInfo dvi in _CacheByPrimaryKey[key]) + dvi.ResetProcedures(); + } #region IVEReadOnlyItem public System.Collections.IList GetChildren() { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 9494afae..44509ecf 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -129,7 +129,7 @@ namespace VEPROMS.CSLA.Library children = (IList)parentInfoDV.GetChildren(); int numChild = children.Count; - if (this.MyPrevious == null) wasfirstchild = true; + if (this.PreviousID == null) wasfirstchild = true;//Use PreviousID rather than MyPrevious so the item is not cached Item origNextItem = null; // First, remove from this item from its list. To do this, get the current item's next point and redirect it's myprevious @@ -166,12 +166,15 @@ namespace VEPROMS.CSLA.Library Save(); } } - // RHM Moving Change - //else - //{ - // MyPrevious = null; - // Save(); - //} + else// RHM 2/20/2013 Moving Change + { + MyPrevious = null; + // Console.WriteLine(">Setting MyPrevious Null {0}", ItemID); + Save(); + // Console.WriteLine("'Moved','e{0}','u{1}','{2}',{3}", ItemID, _MyItemUnique, StringIt(_LastChanged), index); + ItemInfo.RefreshParent(this, parentInfo); + //Console.WriteLine("= ActiveFormat.PlantFormat.DocStyles.DocStyleList.Count) return ActiveFormat.PlantFormat.DocStyles.DocStyleList[0]; _MyDocStyle = ActiveFormat.PlantFormat.DocStyles.DocStyleList[subtyp]; - } - return _MyDocStyle; + } + return _MyDocStyle; } set { @@ -3023,6 +3133,19 @@ namespace VEPROMS.CSLA.Library { AddItem(itemInfo); } + public static ItemInfoList GetMoveItem(int? itemID, int index) + { + try + { + ItemInfoList tmp = DataPortal.Fetch(new MoveItemCriteria(itemID, index)); + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on ItemInfoList.GetChildren", ex); + } + } + public static ItemInfoList GetList(int? itemID,int type) { try @@ -3092,6 +3215,27 @@ namespace VEPROMS.CSLA.Library } } [Serializable()] + private class MoveItemCriteria + { + public MoveItemCriteria(int? itemID, int index) + { + _ItemID = itemID; + _Index = index; + } + private int? _ItemID; + public int? ItemID + { + get { return _ItemID; } + set { _ItemID = value; } + } + private int _Index; + public int Index + { + get { return _Index; } + set { _Index = value; } + } + } + [Serializable()] private class ItemListCriteria { public ItemListCriteria(int? itemID,int type) @@ -3134,6 +3278,52 @@ namespace VEPROMS.CSLA.Library set { _Type = value; } } } + private void DataPortal_Fetch(MoveItemCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "MoveItem"; + cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); + cm.Parameters.AddWithValue("@Index", criteria.Index); + cm.CommandTimeout = Database.DefaultTimeout; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + while (dr.Read()) + { + ItemInfo itemInfo = new ItemInfo(dr); + //switch ((E_FromType)criteria.Type) + //{ + // case E_FromType.Procedure: + // itemInfo = new ProcedureInfo(dr); + // break; + // case E_FromType.Section: + // itemInfo = new SectionInfo(dr); + // break; + // default: + // itemInfo = new StepInfo(dr); + // break; + //} + IsReadOnly = false; + this.Add(itemInfo); + IsReadOnly = true; + } + } + } + } + } + catch (Exception ex) + { + Database.LogException("ItemInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } private void DataPortal_Fetch(ItemListCriteria criteria) { this.RaiseListChangedEvents = false; @@ -3942,10 +4132,11 @@ namespace VEPROMS.CSLA.Library } public void MoveProcedure(IVEDrillDownReadOnly pInfo, int index) { - using (Item ii = Item.Get(this.ItemID)) - { - ii.MoveItem(pInfo, index); - } + MoveItem(pInfo, index); + //using (Item ii = Item.Get(this.ItemID)) + //{ + // ii.MoveItem(pInfo, index); + //} } public new Procedure Get() { @@ -4377,10 +4568,11 @@ namespace VEPROMS.CSLA.Library } public void MoveSection(IVEDrillDownReadOnly pInfo, int index) { - using (Item ii = Item.Get(this.ItemID)) - { - ii.MoveItem(pInfo, index); - } + MoveItem(pInfo, index); + //using (Item ii = Item.Get(this.ItemID)) + //{ + // ii.MoveItem(pInfo, index); + //} } public new Section Get() { @@ -4519,10 +4711,11 @@ namespace VEPROMS.CSLA.Library } public void MoveStep(IVEDrillDownReadOnly pInfo, int index) { - using (Item ii = Item.Get(this.ItemID)) - { - ii.MoveItem(pInfo, index); - } + MoveItem(pInfo, index); + //using (Item ii = Item.Get(this.ItemID)) + //{ + // ii.MoveItem(pInfo, index); + //} } public new Step Get() {