809 lines
		
	
	
		
			26 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			809 lines
		
	
	
		
			26 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
// ========================================================================
 | 
						|
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.          
 | 
						|
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
 | 
						|
// ------------------------------------------------------------------------
 | 
						|
// $Workfile: $     $Revision: $                                           
 | 
						|
// $Author: $   $Date: $                                                   
 | 
						|
//                                                                         
 | 
						|
// $History: $                                                             
 | 
						|
// ========================================================================
 | 
						|
 | 
						|
using System;
 | 
						|
using System.Data;
 | 
						|
using System.Data.SqlClient;
 | 
						|
using Csla;
 | 
						|
using Csla.Data;
 | 
						|
using System.Configuration;
 | 
						|
using System.IO;
 | 
						|
using System.ComponentModel;
 | 
						|
using System.Collections.Generic;
 | 
						|
namespace VEPROMS.CSLA.Library
 | 
						|
{
 | 
						|
	public delegate void ContentInfoEvent(object sender);
 | 
						|
	/// <summary>
 | 
						|
	///	ContentInfo Generated by MyGeneration using the CSLA Object Mapping template
 | 
						|
	/// </summary>
 | 
						|
	[Serializable()]
 | 
						|
	[TypeConverter(typeof(ContentInfoConverter))]
 | 
						|
	public partial class ContentInfo : ReadOnlyBase<ContentInfo>, IDisposable
 | 
						|
	{
 | 
						|
		public static event ContentInfoEvent InfoChanged;
 | 
						|
		private void OnInfoChanged(ContentInfo contentInfo)
 | 
						|
		{
 | 
						|
			if (InfoChanged != null)
 | 
						|
				InfoChanged(this);
 | 
						|
		}
 | 
						|
		public event ContentInfoEvent Changed;
 | 
						|
		private void OnChange(ContentInfo contentInfo)
 | 
						|
		{
 | 
						|
			if (Changed != null)
 | 
						|
				Changed(this);
 | 
						|
			OnInfoChanged(this);
 | 
						|
		}
 | 
						|
		private void OnChange()
 | 
						|
		{
 | 
						|
			string key = ContentID.ToString();
 | 
						|
			if( _CacheByPrimaryKey.ContainsKey(key))
 | 
						|
			foreach (ContentInfo cont in _CacheByPrimaryKey[key])
 | 
						|
				cont.OnChange(cont);
 | 
						|
			else
 | 
						|
				OnChange(this);
 | 
						|
		}
 | 
						|
		#region Log4Net
 | 
						|
		private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | 
						|
		#endregion
 | 
						|
		#region Collection
 | 
						|
		private static List<ContentInfo> _CacheList = new List<ContentInfo>();
 | 
						|
		protected static void AddToCache(ContentInfo contentInfo)
 | 
						|
		{
 | 
						|
			if (!_CacheList.Contains(contentInfo)) _CacheList.Add(contentInfo); // In AddToCache
 | 
						|
		}
 | 
						|
		protected static void RemoveFromCache(ContentInfo contentInfo)
 | 
						|
		{
 | 
						|
			while (_CacheList.Contains(contentInfo)) _CacheList.Remove(contentInfo); // In RemoveFromCache
 | 
						|
		}
 | 
						|
		private static Dictionary<string, List<ContentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentInfo>>();
 | 
						|
		private static void ConvertListToDictionary()
 | 
						|
		{
 | 
						|
			while (_CacheList.Count > 0) // Move ContentInfo(s) from temporary _CacheList to _CacheByPrimaryKey
 | 
						|
			{
 | 
						|
				ContentInfo tmp = _CacheList[0]; // Get the first ContentInfo
 | 
						|
				string pKey = tmp.ContentID.ToString();
 | 
						|
				if (!_CacheByPrimaryKey.ContainsKey(pKey))
 | 
						|
				{
 | 
						|
					_CacheByPrimaryKey[pKey] = new List<ContentInfo>(); // Add new list for PrimaryKey
 | 
						|
				}
 | 
						|
				_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
 | 
						|
				_CacheList.RemoveAt(0); // Remove the first ContentInfo
 | 
						|
			}
 | 
						|
		}
 | 
						|
		internal static void AddList(ContentInfoList lst)
 | 
						|
		{
 | 
						|
			foreach (ContentInfo item in lst) AddToCache(item);
 | 
						|
		}
 | 
						|
		protected static ContentInfo GetCachedByPrimaryKey(int contentID)
 | 
						|
		{
 | 
						|
			ConvertListToDictionary();
 | 
						|
			string key = contentID.ToString();
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
 | 
						|
			return null;
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Business Methods
 | 
						|
		private string _ErrorMessage = string.Empty;
 | 
						|
		public string ErrorMessage
 | 
						|
		{
 | 
						|
			get { return _ErrorMessage; }
 | 
						|
		}
 | 
						|
		protected Content _Editable;
 | 
						|
		private IVEHasBrokenRules HasBrokenRules
 | 
						|
		{
 | 
						|
			get
 | 
						|
			{
 | 
						|
				IVEHasBrokenRules hasBrokenRules = null;
 | 
						|
				if (_Editable != null)
 | 
						|
					hasBrokenRules = _Editable.HasBrokenRules;
 | 
						|
				return hasBrokenRules;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private int _ContentID;
 | 
						|
		[System.ComponentModel.DataObjectField(true, true)]
 | 
						|
		public int ContentID
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentID", true);
 | 
						|
				return _ContentID;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private string _Number = string.Empty;
 | 
						|
		/// <summary>
 | 
						|
		/// Increased from 30 to 256 to support RTF symbols
 | 
						|
		/// </summary>
 | 
						|
		public string Number
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("Number", true);
 | 
						|
				return _Number;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private string _Text = string.Empty;
 | 
						|
		public string Text
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				if (_Disposed) throw new Exception("Cannot access disposed object");
 | 
						|
				CanReadProperty("Text", true);
 | 
						|
				return _Text;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private int? _Type;
 | 
						|
		/// <summary>
 | 
						|
		/// 0 - Procedure, 10000 - Section, 20000 Step
 | 
						|
		/// </summary>
 | 
						|
		public int? Type
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("Type", true);
 | 
						|
				return _Type;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private int? _FormatID;
 | 
						|
		public int? FormatID
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("FormatID", true);
 | 
						|
				if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
 | 
						|
				return _FormatID;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private FormatInfo _MyFormat;
 | 
						|
		public FormatInfo MyFormat
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyFormat", true);
 | 
						|
				if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID);
 | 
						|
				return _MyFormat;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private string _Config = string.Empty;
 | 
						|
		public string Config
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("Config", true);
 | 
						|
				return _Config;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private DateTime _DTS = new DateTime();
 | 
						|
		public DateTime DTS
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("DTS", true);
 | 
						|
				return _DTS;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private string _UserID = string.Empty;
 | 
						|
		public string UserID
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("UserID", true);
 | 
						|
				return _UserID;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private int _ContentDetailCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentDetails for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentDetailCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentDetailCount", true);
 | 
						|
				if (_ContentDetailCount < 0)
 | 
						|
					_ContentDetailCount = ContentDetails.Count;
 | 
						|
				return _ContentDetailCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private DetailInfoList _ContentDetails = null;
 | 
						|
		[TypeConverter(typeof(DetailInfoListConverter))]
 | 
						|
		public DetailInfoList ContentDetails
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentDetails", true);
 | 
						|
				if (_ContentDetailCount < 0 || (_ContentDetailCount > 0 && _ContentDetails == null))
 | 
						|
					_ContentDetails = DetailInfoList.GetByContentID(_ContentID);
 | 
						|
				if (_ContentDetailCount < 0)
 | 
						|
					_ContentDetailCount = _ContentDetails.Count;
 | 
						|
				return _ContentDetails;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void RefreshContentDetails()
 | 
						|
		{
 | 
						|
			_ContentDetailCount = -1;
 | 
						|
			ConvertListToDictionary();
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
 | 
						|
				foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
 | 
						|
					tmp._ContentDetailCount = -1; // This will cause the data to be requeried
 | 
						|
		}
 | 
						|
		private int _ContentEntryCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentEntries for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentEntryCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentEntryCount", true);
 | 
						|
				if (_ContentEntryCount < 0)
 | 
						|
				{
 | 
						|
					_MyEntry = EntryInfo.Get(_ContentID);
 | 
						|
					_ContentEntryCount = MyEntry == null ? 0 : 1;
 | 
						|
				}
 | 
						|
				return _ContentEntryCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private EntryInfo _MyEntry = null;
 | 
						|
		[TypeConverter(typeof(EntryInfoConverter))]
 | 
						|
		public EntryInfo MyEntry
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyEntry", true);
 | 
						|
				if (_ContentEntryCount != 0 && _MyEntry == null)
 | 
						|
				{
 | 
						|
					_MyEntry = EntryInfo.Get(_ContentID);
 | 
						|
					_ContentEntryCount = _MyEntry == null ? 0 : 1;
 | 
						|
				}
 | 
						|
				return _MyEntry;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private int _ContentGridCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentGrids for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentGridCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentGridCount", true);
 | 
						|
				return _ContentGridCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private GridInfo _MyGrid = null;
 | 
						|
		[TypeConverter(typeof(GridInfoConverter))]
 | 
						|
		public GridInfo MyGrid
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyGrid", true);
 | 
						|
				if (_ContentGridCount == -1 && _MyGrid != null)
 | 
						|
				{
 | 
						|
					_MyGrid = null;
 | 
						|
				}
 | 
						|
				if (_ContentGridCount != 0 && _MyGrid == null)
 | 
						|
				{
 | 
						|
					_MyGrid = GridInfo.Get(_ContentID);
 | 
						|
					_ContentGridCount = _MyGrid == null ? 0 : 1;
 | 
						|
				}
 | 
						|
				return _MyGrid;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private int _ContentImageCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentImages for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentImageCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentImageCount", true);
 | 
						|
				return _ContentImageCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private ImageInfo _MyImage = null;
 | 
						|
		[TypeConverter(typeof(ImageInfoConverter))]
 | 
						|
		public ImageInfo MyImage
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyImage", true);
 | 
						|
				if (_ContentImageCount != 0 && _MyImage == null)
 | 
						|
				{
 | 
						|
					_MyImage = ImageInfo.Get(_ContentID);
 | 
						|
					_ContentImageCount = _MyImage == null ? 0 : 1;
 | 
						|
				}
 | 
						|
				return _MyImage;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private int _ContentItemCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentItems for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentItemCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentItemCount", true);
 | 
						|
				if (_ContentItemCount < 0)
 | 
						|
					_ContentItemCount = ContentItems.Count;
 | 
						|
				return _ContentItemCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private ItemInfoList _ContentItems = null;
 | 
						|
		[TypeConverter(typeof(ItemInfoListConverter))]
 | 
						|
		public ItemInfoList ContentItems
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentItems", true);
 | 
						|
				if (_ContentItemCount < 0 || (_ContentItemCount > 0 && _ContentItems == null))
 | 
						|
					_ContentItems = ItemInfoList.GetByContentID(_ContentID);
 | 
						|
				if (_ContentItemCount < 0)
 | 
						|
					_ContentItemCount = _ContentItems.Count;
 | 
						|
				return _ContentItems;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void RefreshContentItems()
 | 
						|
		{
 | 
						|
			_ContentItemCount = -1;
 | 
						|
			ConvertListToDictionary();
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
 | 
						|
				foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
 | 
						|
					tmp._ContentItemCount = -1; // This will cause the data to be requeried
 | 
						|
		}
 | 
						|
		private int _ContentPartCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentParts for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentPartCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentPartCount", true);
 | 
						|
				if (_ContentPartCount < 0)
 | 
						|
					_ContentPartCount = ContentParts.Count;
 | 
						|
				return _ContentPartCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private PartInfoList _ContentParts = null;
 | 
						|
		[TypeConverter(typeof(PartInfoListConverter))]
 | 
						|
		public PartInfoList ContentParts
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentParts", true);
 | 
						|
				if (_ContentPartCount < 0 || (_ContentPartCount > 0 && _ContentParts == null))
 | 
						|
					_ContentParts = PartInfoList.GetByContentID(_ContentID);
 | 
						|
				if (_ContentPartCount < 0)
 | 
						|
					_ContentPartCount = _ContentParts.Count;
 | 
						|
				return _ContentParts;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void RefreshContentParts()
 | 
						|
		{
 | 
						|
			_ContentPartCount = -1;
 | 
						|
			ConvertListToDictionary();
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
 | 
						|
				foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
 | 
						|
					tmp._ContentPartCount = -1; // This will cause the data to be requeried
 | 
						|
		}
 | 
						|
		private int _ContentRoUsageCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentRoUsages for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentRoUsageCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentRoUsageCount", true);
 | 
						|
				if (_ContentRoUsageCount < 0)
 | 
						|
					_ContentRoUsageCount = ContentRoUsages.Count;
 | 
						|
				return _ContentRoUsageCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private RoUsageInfoList _ContentRoUsages = null;
 | 
						|
		[TypeConverter(typeof(RoUsageInfoListConverter))]
 | 
						|
		public RoUsageInfoList ContentRoUsages
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentRoUsages", true);
 | 
						|
				if (_ContentRoUsageCount < 0 || (_ContentRoUsageCount > 0 && _ContentRoUsages == null))
 | 
						|
					_ContentRoUsages = RoUsageInfoList.GetByContentID(_ContentID);
 | 
						|
				if (_ContentRoUsageCount < 0)
 | 
						|
					_ContentRoUsageCount = _ContentRoUsages.Count;
 | 
						|
				return _ContentRoUsages;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void RefreshContentRoUsages()
 | 
						|
		{
 | 
						|
			_ContentRoUsageCount = -1;
 | 
						|
			ConvertListToDictionary();
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
 | 
						|
				foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
 | 
						|
					tmp._ContentRoUsageCount = -1; // This will cause the data to be requeried
 | 
						|
		}
 | 
						|
		private int _ContentTransitionCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentTransitions for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentTransitionCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentTransitionCount", true);
 | 
						|
				if (_ContentTransitionCount < 0)
 | 
						|
					_ContentTransitionCount = ContentTransitions.Count;
 | 
						|
				return _ContentTransitionCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private TransitionInfoList _ContentTransitions = null;
 | 
						|
		[TypeConverter(typeof(TransitionInfoListConverter))]
 | 
						|
		public TransitionInfoList ContentTransitions
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentTransitions", true);
 | 
						|
				if (_ContentTransitionCount < 0 || (_ContentTransitionCount > 0 && _ContentTransitions == null))
 | 
						|
					_ContentTransitions = TransitionInfoList.GetByFromID(_ContentID);
 | 
						|
				if (_ContentTransitionCount < 0)
 | 
						|
					_ContentTransitionCount = _ContentTransitions.Count;
 | 
						|
				return _ContentTransitions;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void RefreshContentTransitions()
 | 
						|
		{
 | 
						|
			_ContentTransitionCount = -1;
 | 
						|
			ConvertListToDictionary();
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
 | 
						|
				foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
 | 
						|
					tmp._ContentTransitionCount = -1; // This will cause the data to be requeried
 | 
						|
		}
 | 
						|
		private int _ContentZContentCount = 0;
 | 
						|
		/// <summary>
 | 
						|
		/// Count of ContentZContents for this Content
 | 
						|
		/// </summary>
 | 
						|
		public int ContentZContentCount
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentZContentCount", true);
 | 
						|
				return _ContentZContentCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private ZContentInfo _MyZContent = null;
 | 
						|
		[TypeConverter(typeof(ZContentInfoConverter))]
 | 
						|
		public ZContentInfo MyZContent
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyZContent", true);
 | 
						|
				if (_ContentZContentCount != 0 && _MyZContent == null)
 | 
						|
				{
 | 
						|
					_MyZContent = ZContentInfo.Get(_ContentID);
 | 
						|
					_ContentZContentCount = _MyZContent == null ? 0 : 1;
 | 
						|
				}
 | 
						|
				return _MyZContent;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		// CSLATODO: Replace base ContentInfo.ToString function as necessary
 | 
						|
		/// <summary>
 | 
						|
		/// Overrides Base ToString
 | 
						|
		/// </summary>
 | 
						|
		/// <returns>A string representation of current ContentInfo</returns>
 | 
						|
		//public override string ToString()
 | 
						|
		//{
 | 
						|
		//  return base.ToString();
 | 
						|
		//}
 | 
						|
		// CSLATODO: Check ContentInfo.GetIdValue to assure that the ID returned is unique
 | 
						|
		/// <summary>
 | 
						|
		/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
 | 
						|
		/// </summary>
 | 
						|
		/// <returns>A Unique ID for the current ContentInfo</returns>
 | 
						|
		protected override object GetIdValue()
 | 
						|
		{
 | 
						|
			return MyContentInfoUnique; // Absolutely Unique ID
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Factory Methods
 | 
						|
		private static int _ContentInfoUnique = 0;
 | 
						|
		private static int ContentInfoUnique
 | 
						|
		{ get { return ++_ContentInfoUnique; } }
 | 
						|
		private int _MyContentInfoUnique = ContentInfoUnique;
 | 
						|
		public int MyContentInfoUnique // Absolutely Unique ID - Info
 | 
						|
		{ get { return _MyContentInfoUnique; } }
 | 
						|
		protected ContentInfo()
 | 
						|
		{/* require use of factory methods */
 | 
						|
			AddToCache(this);
 | 
						|
		}
 | 
						|
		private bool _Disposed = false;
 | 
						|
		private static int _CountCreated = 0;
 | 
						|
		private static int _CountDisposed = 0;
 | 
						|
		private static int _CountFinalized = 0;
 | 
						|
		private static int IncrementCountCreated
 | 
						|
		{ get { return ++_CountCreated; } }
 | 
						|
		private int _CountWhenCreated = IncrementCountCreated;
 | 
						|
		public static int CountCreated
 | 
						|
		{ get { return _CountCreated; } }
 | 
						|
		public static int CountNotDisposed
 | 
						|
		{ get { return _CountCreated - _CountDisposed; } }
 | 
						|
		public static int CountNotFinalized
 | 
						|
		{ get { return _CountCreated - _CountFinalized; } }
 | 
						|
		~ContentInfo()
 | 
						|
		{
 | 
						|
			_CountFinalized++;
 | 
						|
		}
 | 
						|
		public void Dispose()
 | 
						|
		{
 | 
						|
			if (_Disposed) return;
 | 
						|
			_CountDisposed++;
 | 
						|
			_Disposed = true;
 | 
						|
			RemoveFromCache(this);
 | 
						|
			if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
 | 
						|
			List<ContentInfo> listContentInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
 | 
						|
			while (listContentInfo.Contains(this)) listContentInfo.Remove(this); // Remove the item from the list
 | 
						|
			if (listContentInfo.Count == 0) // If there are no items left in the list
 | 
						|
				_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
 | 
						|
			if (_Editable != null)
 | 
						|
				_Editable = null;
 | 
						|
			if (_ContentItems != null)
 | 
						|
				_ContentItems = null;
 | 
						|
			_Text = null;
 | 
						|
			//if (_ContentParts != null)
 | 
						|
			//  _ContentParts = null;
 | 
						|
			//if (_ContentRoUsages != null)
 | 
						|
			//  _ContentRoUsages = null;
 | 
						|
			//if (_ContentTransitions != null)
 | 
						|
			//  _ContentTransitions = null;
 | 
						|
			//if (_MyEntry != null)
 | 
						|
			//  _MyEntry = null;
 | 
						|
			//if (_MyGrid != null)
 | 
						|
			//  _MyGrid = null;
 | 
						|
			//if (_MyImage != null)
 | 
						|
			//  _MyImage = null;
 | 
						|
			//if (_MyZContent != null)
 | 
						|
			//  _MyZContent = null;
 | 
						|
		}
 | 
						|
		public virtual Content Get()
 | 
						|
		{
 | 
						|
			return _Editable = Content.Get(_ContentID);
 | 
						|
		}
 | 
						|
		public static void Refresh(Content tmp)
 | 
						|
		{
 | 
						|
			string key = tmp.ContentID.ToString();
 | 
						|
			ConvertListToDictionary();
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(key))
 | 
						|
				foreach (ContentInfo tmpInfo in _CacheByPrimaryKey[key])
 | 
						|
				{
 | 
						|
					tmpInfo.RefreshFields(tmp);
 | 
						|
					// TODO: This needs to be handled in Generatedd Code.
 | 
						|
					if (tmp.LocalEntry != null && tmpInfo.MyEntry != null && tmp.MyEntry.MyDocument.DocID != tmpInfo.MyEntry.MyDocument.DocID)
 | 
						|
						EntryInfo.Refresh(tmp.MyEntry);
 | 
						|
				}
 | 
						|
		}
 | 
						|
		protected virtual void RefreshFields(Content tmp)
 | 
						|
		{
 | 
						|
			_Number = tmp.Number;
 | 
						|
			_Text = tmp.Text;
 | 
						|
			_Type = tmp.Type;
 | 
						|
			if (_FormatID != tmp.FormatID)
 | 
						|
			{
 | 
						|
				if (MyFormat != null) MyFormat.RefreshFormatContents(); // Update List for old value
 | 
						|
				_FormatID = tmp.FormatID; // Update the value
 | 
						|
			}
 | 
						|
			_MyFormat = null; // Reset list so that the next line gets a new list
 | 
						|
			if (MyFormat != null) MyFormat.RefreshFormatContents(); // Update List for new value
 | 
						|
			_Config = tmp.Config;
 | 
						|
			_DTS = tmp.DTS;
 | 
						|
			_UserID = tmp.UserID;
 | 
						|
			_ContentInfoExtension.Refresh(this);
 | 
						|
			_ContentEntryCount = -1;// Reset Count
 | 
						|
			_ContentGridCount = -1;// Reset Count
 | 
						|
			_ContentImageCount = -1;// Reset Count
 | 
						|
			_ContentZContentCount = -1;// Reset Count
 | 
						|
			OnChange(this);// raise an event only for this instance
 | 
						|
		}
 | 
						|
		public static void Refresh(FormatContent tmp)
 | 
						|
		{
 | 
						|
			string key = tmp.ContentID.ToString();
 | 
						|
			ConvertListToDictionary();
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(key))
 | 
						|
				foreach (ContentInfo tmpInfo in _CacheByPrimaryKey[key])
 | 
						|
					tmpInfo.RefreshFields(tmp);
 | 
						|
		}
 | 
						|
		protected virtual void RefreshFields(FormatContent tmp)
 | 
						|
		{
 | 
						|
			_Number = tmp.Number;
 | 
						|
			_Text = tmp.Text;
 | 
						|
			_Type = tmp.Type;
 | 
						|
			_Config = tmp.Config;
 | 
						|
			_DTS = tmp.DTS;
 | 
						|
			_UserID = tmp.UserID;
 | 
						|
			_ContentInfoExtension.Refresh(this);
 | 
						|
			_ContentEntryCount = -1;// Reset Count
 | 
						|
			_ContentGridCount = -1;// Reset Count
 | 
						|
			_ContentImageCount = -1;// Reset Count
 | 
						|
			_ContentZContentCount = -1;// Reset Count
 | 
						|
			OnChange(this);// raise an event only for this instance
 | 
						|
		}
 | 
						|
		public static ContentInfo Get(int contentID)
 | 
						|
		{
 | 
						|
			//if (!CanGetObject())
 | 
						|
			//  throw new System.Security.SecurityException("User not authorized to view a Content");
 | 
						|
			try
 | 
						|
			{
 | 
						|
				ContentInfo tmp = GetCachedByPrimaryKey(contentID);
 | 
						|
				if (tmp == null)
 | 
						|
				{
 | 
						|
					tmp = DataPortal.Fetch<ContentInfo>(new PKCriteria(contentID));
 | 
						|
					AddToCache(tmp);
 | 
						|
				}
 | 
						|
				if (tmp.ErrorMessage == "No Record Found")
 | 
						|
				{
 | 
						|
					tmp.Dispose(); // Clean-up ContentInfo
 | 
						|
					tmp = null;
 | 
						|
				}
 | 
						|
				return tmp;
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				throw new DbCslaException("Error on ContentInfo.Get", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Data Access Portal
 | 
						|
		internal ContentInfo(SafeDataReader dr)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
 | 
						|
			try
 | 
						|
			{
 | 
						|
				ReadData(dr);
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.Constructor", ex);
 | 
						|
				throw new DbCslaException("ContentInfo.Constructor", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Serializable()]
 | 
						|
		protected class PKCriteria
 | 
						|
		{
 | 
						|
			private int _ContentID;
 | 
						|
			public int ContentID
 | 
						|
			{ get { return _ContentID; } }
 | 
						|
			public PKCriteria(int contentID)
 | 
						|
			{
 | 
						|
				_ContentID = contentID;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private void ReadData(SafeDataReader dr)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.ReadData", GetHashCode());
 | 
						|
			try
 | 
						|
			{
 | 
						|
				_ContentID = dr.GetInt32("ContentID");
 | 
						|
				_Number = dr.GetString("Number");
 | 
						|
				_Text = dr.GetString("Text");
 | 
						|
				_Type = (int?)dr.GetValue("Type");
 | 
						|
				_FormatID = (int?)dr.GetValue("FormatID");
 | 
						|
				_Config = dr.GetString("Config");
 | 
						|
				_DTS = dr.GetDateTime("DTS");
 | 
						|
				_UserID = dr.GetString("UserID");
 | 
						|
				_ContentDetailCount = dr.GetInt32("DetailCount");
 | 
						|
				_ContentEntryCount = dr.GetInt32("EntryCount");
 | 
						|
				_ContentGridCount = dr.GetInt32("GridCount");
 | 
						|
				_ContentImageCount = dr.GetInt32("ImageCount");
 | 
						|
				_ContentItemCount = dr.GetInt32("ItemCount");
 | 
						|
				_ContentPartCount = dr.GetInt32("PartCount");
 | 
						|
				_ContentRoUsageCount = dr.GetInt32("RoUsageCount");
 | 
						|
				_ContentTransitionCount = dr.GetInt32("TransitionCount");
 | 
						|
				_ContentZContentCount = dr.GetInt32("ZContentCount");
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.ReadData", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				throw new DbCslaException("ContentInfo.ReadData", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private void DataPortal_Fetch(PKCriteria criteria)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.DataPortal_Fetch", GetHashCode());
 | 
						|
			try
 | 
						|
			{
 | 
						|
				using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | 
						|
				{
 | 
						|
					ApplicationContext.LocalContext["cn"] = cn;
 | 
						|
					using (SqlCommand cm = cn.CreateCommand())
 | 
						|
					{
 | 
						|
						cm.CommandType = CommandType.StoredProcedure;
 | 
						|
						cm.CommandText = "getContent";
 | 
						|
						cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
 | 
						|
						cm.CommandTimeout = Database.DefaultTimeout;
 | 
						|
						using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
 | 
						|
						{
 | 
						|
							if (!dr.Read())
 | 
						|
							{
 | 
						|
								_ErrorMessage = "No Record Found";
 | 
						|
								return;
 | 
						|
							}
 | 
						|
							ReadData(dr);
 | 
						|
						}
 | 
						|
					}
 | 
						|
					// removing of item only needed for local data portal
 | 
						|
					if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
 | 
						|
						ApplicationContext.LocalContext.Remove("cn");
 | 
						|
				}
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.DataPortal_Fetch", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				throw new DbCslaException("ContentInfo.DataPortal_Fetch", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		// Standard Refresh
 | 
						|
		#region extension
 | 
						|
		ContentInfoExtension _ContentInfoExtension = new ContentInfoExtension();
 | 
						|
		[Serializable()]
 | 
						|
		partial class ContentInfoExtension : extensionBase { }
 | 
						|
		[Serializable()]
 | 
						|
		class extensionBase
 | 
						|
		{
 | 
						|
			// Default Refresh
 | 
						|
			public virtual void Refresh(ContentInfo tmp) { }
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
	} // Class
 | 
						|
	#region Converter
 | 
						|
	internal class ContentInfoConverter : ExpandableObjectConverter
 | 
						|
	{
 | 
						|
		public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
 | 
						|
		{
 | 
						|
			if (destType == typeof(string) && value is ContentInfo)
 | 
						|
			{
 | 
						|
				// Return the ToString value
 | 
						|
				return ((ContentInfo)value).ToString();
 | 
						|
			}
 | 
						|
			return base.ConvertTo(context, culture, value, destType);
 | 
						|
		}
 | 
						|
	}
 | 
						|
	#endregion
 | 
						|
} // Namespace
 |