Replaced duplicate logic in GetChildren with MyItems Fixed logic to check for Sections = null
		
			
				
	
	
		
			159 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			159 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Text;
 | 
						|
using Csla;
 | 
						|
using Csla.Data;
 | 
						|
 | 
						|
namespace VEPROMS.CSLA.Library
 | 
						|
{
 | 
						|
	public partial class ContentPart
 | 
						|
	{
 | 
						|
		public override string ToString()
 | 
						|
		{
 | 
						|
			return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
 | 
						|
		}
 | 
						|
	}
 | 
						|
	public partial class ItemPart
 | 
						|
	{
 | 
						|
		public override string ToString()
 | 
						|
		{
 | 
						|
			return string.Format("{0} {1}", _MyContent.Number, MyContent.Text);
 | 
						|
		}
 | 
						|
	}
 | 
						|
	public partial class Part
 | 
						|
	{
 | 
						|
		public override string ToString()
 | 
						|
		{
 | 
						|
			return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
 | 
						|
		}
 | 
						|
	}
 | 
						|
	public partial class PartInfoList
 | 
						|
	{
 | 
						|
	  internal PartInfoList(SafeDataReader dr, ItemInfo itemInfo)
 | 
						|
	  {
 | 
						|
			AddPartInfo(dr,itemInfo);
 | 
						|
	  }
 | 
						|
		internal void AddPartInfo(SafeDataReader dr, ItemInfo itemInfo)
 | 
						|
		{
 | 
						|
			IsReadOnly = false;
 | 
						|
			this.Add(new PartInfo(dr, itemInfo));
 | 
						|
			IsReadOnly = true;
 | 
						|
		}
 | 
						|
		public PartInfo Find(E_FromType fromType)
 | 
						|
		{
 | 
						|
			foreach(PartInfo partInfo in this)
 | 
						|
			{
 | 
						|
				if ((E_FromType)partInfo.FromType == fromType)
 | 
						|
					return partInfo;
 | 
						|
			}
 | 
						|
			return null;
 | 
						|
		}
 | 
						|
		public PartInfo Find(ItemInfo itemInfo)
 | 
						|
		{
 | 
						|
			foreach (PartInfo partInfo in this)
 | 
						|
			{
 | 
						|
				if (partInfo.MyItem.ItemID == itemInfo.ItemID)
 | 
						|
					return partInfo;
 | 
						|
			}
 | 
						|
			return null;
 | 
						|
		}
 | 
						|
	}
 | 
						|
	public partial class PartInfo : IVEDrillDownReadOnly
 | 
						|
	{
 | 
						|
		internal PartInfo(SafeDataReader dr, ItemInfo itemInfo)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode());
 | 
						|
			try
 | 
						|
			{
 | 
						|
				ReadData(dr, itemInfo);
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.Constructor", ex);
 | 
						|
				throw new DbCslaException("PartInfo.Constructor", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private void ReadData(SafeDataReader dr, ItemInfo itemInfo)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode());
 | 
						|
			try
 | 
						|
			{
 | 
						|
				_ContentID = dr.GetInt32("pContentID");
 | 
						|
				_FromType = dr.GetInt32("FromType");
 | 
						|
				_ItemID = dr.GetInt32("ItemID");
 | 
						|
				_DTS = dr.GetDateTime("pDTS");
 | 
						|
				_UserID = dr.GetString("pUserID");
 | 
						|
				_MyItem = itemInfo;
 | 
						|
				_MyItems = new ItemInfoList(itemInfo);
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.ReadData", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				throw new DbCslaException("PartInfo.ReadData", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public E_FromType PartType
 | 
						|
		{ get { return (E_FromType)_FromType; } }
 | 
						|
		public E_FromTypes PartTypes
 | 
						|
		{ get { return (E_FromTypes)_FromType; } }
 | 
						|
		public override string ToString()
 | 
						|
		{
 | 
						|
			return string.Format("{0}", PartTypes);
 | 
						|
		}
 | 
						|
		//public string ToString(string str, System.IFormatProvider ifp)
 | 
						|
		//{
 | 
						|
		//  return ToString();
 | 
						|
		//}
 | 
						|
		#region IVEDrillDownReadOnly
 | 
						|
		public ItemInfoList _MyItems;
 | 
						|
		public ItemInfoList MyItems
 | 
						|
		{ get { return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType)); } }
 | 
						|
		public System.Collections.IList GetChildren()
 | 
						|
		{
 | 
						|
			//return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType));
 | 
						|
			return MyItems;
 | 
						|
		}
 | 
						|
		//public bool ChildrenAreLoaded
 | 
						|
		//{
 | 
						|
		//  get { return _MyItems == null; }
 | 
						|
		//}
 | 
						|
		public bool HasChildren
 | 
						|
		{
 | 
						|
			get { return this.MyContent.ContentPartCount > 0; }
 | 
						|
		}
 | 
						|
		public IVEDrillDownReadOnly ActiveParent
 | 
						|
		{
 | 
						|
			get
 | 
						|
			{
 | 
						|
				ContentInfo parentContent = MyContent;
 | 
						|
				if (parentContent == null || parentContent.ContentItemCount == 0) return null;
 | 
						|
				return parentContent.ContentItems[0];
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public FormatInfo ActiveFormat
 | 
						|
		{
 | 
						|
			get { return ActiveParent.ActiveFormat; }
 | 
						|
		}
 | 
						|
		public FormatInfo LocalFormat
 | 
						|
		{
 | 
						|
			get { return null; }
 | 
						|
		}
 | 
						|
		public ConfigDynamicTypeDescriptor MyConfig
 | 
						|
		{
 | 
						|
			get { return null; }
 | 
						|
		}
 | 
						|
		//public bool HasStandardSteps()
 | 
						|
		//{ return false; }
 | 
						|
		#endregion
 | 
						|
	}
 | 
						|
	public enum E_FromType : int
 | 
						|
	{
 | 
						|
		Procedure = 1, Section = 2, Caution = 3, Note = 4, RNO = 5, Step = 6, Table = 7
 | 
						|
	}
 | 
						|
	public enum E_FromTypes : int
 | 
						|
	{
 | 
						|
		Procedures = 1, Sections = 2, Cautions = 3, Notes = 4, RNOs = 5, Steps = 6, Tables = 7
 | 
						|
	}
 | 
						|
}
 |