From 66f1c2142508a1dd07b38f010aaf4d3af389c22e Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 8 Oct 2009 14:33:50 +0000 Subject: [PATCH] Added Item.MyItemInfo Changed ActiveParent object to return cached ItemInfo Added Section.MySectionInfo Added Procedure.MyProcedureInfo Removed debug printout Removed GetChildren from editable object Removed HasChildren from editable object Removed ActiveParent from editable object Removed ActiveFormat from editable object Removed LocalFormat from editable object Changed logic to use SectionInfo to retrieve FormatInfo --- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 148 ++++++++++-------- .../Extension/PropertyDescriptors.cs | 2 +- 2 files changed, 82 insertions(+), 68 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index f2640b78..26b548af 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -16,6 +16,8 @@ namespace VEPROMS.CSLA.Library #region Item public partial class Item : IVEDrillDown { + public ItemInfo MyItemInfo /* Return Info version of the current Item */ + { get { return ItemInfo.Get(ItemID); } } public static void ShowAllocated(string title) { Console.WriteLine("{0} - {1} Items in the dictionary", title, _CacheByPrimaryKey.Count); @@ -32,66 +34,67 @@ namespace VEPROMS.CSLA.Library // TODO: Move to ItemInfo Extension #region IVEDrillDown - public System.Collections.IList GetChildren() - { - return this.MyContent.ContentParts; - } - public bool HasChildren - { - get { return this.MyContent.ContentPartCount > 0; } - } - public Item MyProcedure - { - get - { - // Walk up active parents until the parent is not an item - Item tmp = this; - while (tmp.ActiveParent.GetType() != typeof(DocVersion)) tmp = (Item)tmp.ActiveParent; - return tmp; - } - } private IVEDrillDown _ActiveParent = null; - public IVEDrillDown ActiveParent - { - get - { - if (_ActiveParent == null) - { - if (MyPrevious != null) - _ActiveParent = _MyPrevious.ActiveParent; - else - { - if (ItemDocVersionCount > 0) - _ActiveParent = this.ItemDocVersions[0].MyDocVersion; - else - { - if (this.ItemParts == null || this.ItemPartCount == 0) - _ActiveParent = this; - else - _ActiveParent = this.ItemParts[0].MyContent.ContentItems[0].MyItem; - } - } - } - return _ActiveParent == this ? null : _ActiveParent; - } - } - private Format _ActiveFormat = null;// Added to cache ActiveFormat - public Format ActiveFormat - { - get - { - if (_ActiveFormat == null) - _ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat); - return _ActiveFormat; - } - set - { - _ActiveFormat = null; // Reset - } - } - public Format LocalFormat - { - get { return MyContent.MyFormat; } - } + //public System.Collections.IList GetChildren() + //{ + // return this.MyContent.ContentParts; + //} + //public bool HasChildren + //{ + // get { return this.MyContent.ContentPartCount > 0; } + //} + //public Item MyProcedure + //{ + // get + // { + // // Walk up active parents until the parent is not an item + // Item tmp = this; + // while (tmp.ActiveParent.GetType() != typeof(DocVersion)) tmp = (Item)tmp.ActiveParent; + // return tmp; + // } + //} + //private IVEDrillDown _ActiveParent = null; + //public IVEDrillDown ActiveParent + //{ + // get + // { + // if (_ActiveParent == null) + // { + // if (MyPrevious != null) + // _ActiveParent = _MyPrevious.ActiveParent; + // else + // { + // if (ItemDocVersionCount > 0) + // _ActiveParent = this.ItemDocVersions[0].MyDocVersion; + // else + // { + // if (this.ItemParts == null || this.ItemPartCount == 0) + // _ActiveParent = this; + // else + // _ActiveParent = this.ItemParts[0].MyContent.ContentItems[0].MyItem; + // } + // } + // } + // return _ActiveParent == this ? null : _ActiveParent; + // } + //} + //private Format _ActiveFormat = null;// Added to cache ActiveFormat + //public Format ActiveFormat + //{ + // get + // { + // if (_ActiveFormat == null) + // _ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat); + // return _ActiveFormat; + // } + // set + // { + // _ActiveFormat = null; // Reset + // } + //} + //public Format LocalFormat + //{ + // get { return MyContent.MyFormat; } + //} public ConfigDynamicTypeDescriptor MyConfig { get { return null; } @@ -1286,11 +1289,18 @@ namespace VEPROMS.CSLA.Library _ActiveParent = this.ItemDocVersions[0]; else { - ContentInfo parentContent = ParentContent; - if (parentContent == null || parentContent.ContentItemCount == 0) - _ActiveParent = this; - else - _ActiveParent = parentContent.ContentItems[0]; + using (ContentInfo parentContent = ParentContent) + { + if (parentContent == null || parentContent.ContentItemCount == 0) + _ActiveParent = this; + else + { + int itemID = 0; + using(ItemInfoList list = parentContent.ContentItems) + itemID = list[0].ItemID; + _ActiveParent = ItemInfo.Get(itemID); + } + } } } } @@ -1335,7 +1345,7 @@ namespace VEPROMS.CSLA.Library { if (_ActiveFormat == null) _ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat); - Console.WriteLine("Active {0}", (_ActiveFormat == null) ? "_ActiveFormat is null" : _ActiveFormat.Name); + //Console.WriteLine("Active {0}", (_ActiveFormat == null) ? "_ActiveFormat is null" : _ActiveFormat.Name); return _ActiveFormat; } //get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; } @@ -1343,7 +1353,7 @@ namespace VEPROMS.CSLA.Library public FormatInfo LocalFormat { get { - Console.WriteLine("Local {0}", (MyContent.MyFormat==null)?"MYformat is null": MyContent.MyFormat.Name); + //Console.WriteLine("Local {0}", (MyContent.MyFormat==null)?"MYformat is null": MyContent.MyFormat.Name); return MyContent.MyFormat; } } private ConfigDynamicTypeDescriptor _MyConfig=null; @@ -1905,6 +1915,8 @@ namespace VEPROMS.CSLA.Library [Serializable()] public partial class Procedure : Item { + public ProcedureInfo MyProcedureInfo /* Return Info version of the current Item */ + { get { return ProcedureInfo.Get(ItemID); } } public new static Procedure Get(int itemID) { if (!CanGetObject()) @@ -2022,6 +2034,8 @@ namespace VEPROMS.CSLA.Library [Serializable()] public partial class Section : Item { + public SectionInfo MySectionInfo /* Return Info version of the current Item */ + { get { return SectionInfo.Get(ItemID); } } public new static Section Get(int itemID) { if (!CanGetObject()) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/PropertyDescriptors.cs b/PROMS/VEPROMS.CSLA.Library/Extension/PropertyDescriptors.cs index a815e7a9..28540b21 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/PropertyDescriptors.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/PropertyDescriptors.cs @@ -126,7 +126,7 @@ namespace VEPROMS.CSLA.Library if (_MyDocStyleList == null) { _MyDocStyleList = new SortedList(); - foreach(DocStyle ds in _MySection.ActiveFormat.PlantFormat.DocStyles.DocStyleList) + foreach(DocStyle ds in _MySection.MySectionInfo.ActiveFormat.PlantFormat.DocStyles.DocStyleList) { _MyDocStyleList.Add(ds.Name,10000 + (int) ds.Index); }