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
This commit is contained in:
Rich 2009-10-08 14:33:50 +00:00
parent 119c428ae4
commit 66f1c21425
2 changed files with 82 additions and 68 deletions

View File

@ -16,6 +16,8 @@ namespace VEPROMS.CSLA.Library
#region Item #region Item
public partial class Item : IVEDrillDown 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) public static void ShowAllocated(string title)
{ {
Console.WriteLine("{0} - {1} Items in the dictionary", title, _CacheByPrimaryKey.Count); Console.WriteLine("{0} - {1} Items in the dictionary", title, _CacheByPrimaryKey.Count);
@ -32,66 +34,67 @@ namespace VEPROMS.CSLA.Library
// TODO: Move to ItemInfo Extension // TODO: Move to ItemInfo Extension
#region IVEDrillDown #region IVEDrillDown
public System.Collections.IList GetChildren() //public System.Collections.IList GetChildren()
{ //{
return this.MyContent.ContentParts; // return this.MyContent.ContentParts;
} //}
public bool HasChildren //public bool HasChildren
{ //{
get { return this.MyContent.ContentPartCount > 0; } // get { return this.MyContent.ContentPartCount > 0; }
} //}
public Item MyProcedure //public Item MyProcedure
{ //{
get // get
{ // {
// Walk up active parents until the parent is not an item // // Walk up active parents until the parent is not an item
Item tmp = this; // Item tmp = this;
while (tmp.ActiveParent.GetType() != typeof(DocVersion)) tmp = (Item)tmp.ActiveParent; // while (tmp.ActiveParent.GetType() != typeof(DocVersion)) tmp = (Item)tmp.ActiveParent;
return tmp; // return tmp;
} // }
} private IVEDrillDown _ActiveParent = null; //}
public IVEDrillDown ActiveParent //private IVEDrillDown _ActiveParent = null;
{ //public IVEDrillDown ActiveParent
get //{
{ // get
if (_ActiveParent == null) // {
{ // if (_ActiveParent == null)
if (MyPrevious != null) // {
_ActiveParent = _MyPrevious.ActiveParent; // if (MyPrevious != null)
else // _ActiveParent = _MyPrevious.ActiveParent;
{ // else
if (ItemDocVersionCount > 0) // {
_ActiveParent = this.ItemDocVersions[0].MyDocVersion; // if (ItemDocVersionCount > 0)
else // _ActiveParent = this.ItemDocVersions[0].MyDocVersion;
{ // else
if (this.ItemParts == null || this.ItemPartCount == 0) // {
_ActiveParent = this; // if (this.ItemParts == null || this.ItemPartCount == 0)
else // _ActiveParent = this;
_ActiveParent = this.ItemParts[0].MyContent.ContentItems[0].MyItem; // else
} // _ActiveParent = this.ItemParts[0].MyContent.ContentItems[0].MyItem;
} // }
} // }
return _ActiveParent == this ? null : _ActiveParent; // }
} // return _ActiveParent == this ? null : _ActiveParent;
} // }
private Format _ActiveFormat = null;// Added to cache ActiveFormat //}
public Format ActiveFormat //private Format _ActiveFormat = null;// Added to cache ActiveFormat
{ //public Format ActiveFormat
get //{
{ // get
if (_ActiveFormat == null) // {
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat); // if (_ActiveFormat == null)
return _ActiveFormat; // _ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
} // return _ActiveFormat;
set // }
{ // set
_ActiveFormat = null; // Reset // {
} // _ActiveFormat = null; // Reset
} // }
public Format LocalFormat //}
{ //public Format LocalFormat
get { return MyContent.MyFormat; } //{
} // get { return MyContent.MyFormat; }
//}
public ConfigDynamicTypeDescriptor MyConfig public ConfigDynamicTypeDescriptor MyConfig
{ {
get { return null; } get { return null; }
@ -1286,11 +1289,18 @@ namespace VEPROMS.CSLA.Library
_ActiveParent = this.ItemDocVersions[0]; _ActiveParent = this.ItemDocVersions[0];
else else
{ {
ContentInfo parentContent = ParentContent; using (ContentInfo parentContent = ParentContent)
if (parentContent == null || parentContent.ContentItemCount == 0) {
_ActiveParent = this; if (parentContent == null || parentContent.ContentItemCount == 0)
else _ActiveParent = this;
_ActiveParent = parentContent.ContentItems[0]; 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) if (_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat); _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; return _ActiveFormat;
} }
//get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; } //get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
@ -1343,7 +1353,7 @@ namespace VEPROMS.CSLA.Library
public FormatInfo LocalFormat public FormatInfo LocalFormat
{ {
get { 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; } return MyContent.MyFormat; }
} }
private ConfigDynamicTypeDescriptor _MyConfig=null; private ConfigDynamicTypeDescriptor _MyConfig=null;
@ -1905,6 +1915,8 @@ namespace VEPROMS.CSLA.Library
[Serializable()] [Serializable()]
public partial class Procedure : Item 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) public new static Procedure Get(int itemID)
{ {
if (!CanGetObject()) if (!CanGetObject())
@ -2022,6 +2034,8 @@ namespace VEPROMS.CSLA.Library
[Serializable()] [Serializable()]
public partial class Section : Item 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) public new static Section Get(int itemID)
{ {
if (!CanGetObject()) if (!CanGetObject())

View File

@ -126,7 +126,7 @@ namespace VEPROMS.CSLA.Library
if (_MyDocStyleList == null) if (_MyDocStyleList == null)
{ {
_MyDocStyleList = new SortedList<string, int>(); _MyDocStyleList = new SortedList<string, int>();
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); _MyDocStyleList.Add(ds.Name,10000 + (int) ds.Index);
} }