1594 lines
		
	
	
		
			53 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			1594 lines
		
	
	
		
			53 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;
 | 
						|
using Csla.Validation;
 | 
						|
namespace VEPROMS.CSLA.Library
 | 
						|
{
 | 
						|
	/// <summary>
 | 
						|
	///	Content Generated by MyGeneration using the CSLA Object Mapping template
 | 
						|
	/// </summary>
 | 
						|
	[Serializable()]
 | 
						|
	[TypeConverter(typeof(ContentConverter))]
 | 
						|
	public partial class Content : BusinessBase<Content>, IDisposable, IVEHasBrokenRules
 | 
						|
	{
 | 
						|
		#region Log4Net
 | 
						|
		private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | 
						|
		#endregion
 | 
						|
		#region Refresh
 | 
						|
		private List<Content> _RefreshContents = new List<Content>();
 | 
						|
		private List<ContentDetail> _RefreshContentDetails = new List<ContentDetail>();
 | 
						|
		private List<ContentItem> _RefreshContentItems = new List<ContentItem>();
 | 
						|
		private List<ContentPart> _RefreshContentParts = new List<ContentPart>();
 | 
						|
		private List<ContentRoUsage> _RefreshContentRoUsages = new List<ContentRoUsage>();
 | 
						|
		private List<ContentTransition> _RefreshContentTransitions = new List<ContentTransition>();
 | 
						|
		private void AddToRefreshList(List<Content> refreshContents, List<ContentDetail> refreshContentDetails, List<ContentItem> refreshContentItems, List<ContentPart> refreshContentParts, List<ContentRoUsage> refreshContentRoUsages, List<ContentTransition> refreshContentTransitions)
 | 
						|
		{
 | 
						|
			if (IsDirty)
 | 
						|
				refreshContents.Add(this);
 | 
						|
			if (_ContentDetails != null && _ContentDetails.IsDirty)
 | 
						|
			{
 | 
						|
				foreach (ContentDetail tmp in _ContentDetails)
 | 
						|
				{
 | 
						|
					if (tmp.IsDirty) refreshContentDetails.Add(tmp);
 | 
						|
				}
 | 
						|
			}
 | 
						|
			if (_ContentItems != null && _ContentItems.IsDirty)
 | 
						|
			{
 | 
						|
				foreach (ContentItem tmp in _ContentItems)
 | 
						|
				{
 | 
						|
					if (tmp.IsDirty) refreshContentItems.Add(tmp);
 | 
						|
				}
 | 
						|
			}
 | 
						|
			if (_ContentParts != null && _ContentParts.IsDirty)
 | 
						|
			{
 | 
						|
				foreach (ContentPart tmp in _ContentParts)
 | 
						|
				{
 | 
						|
					if (tmp.IsDirty) refreshContentParts.Add(tmp);
 | 
						|
				}
 | 
						|
			}
 | 
						|
			if (_ContentRoUsages != null && _ContentRoUsages.IsDirty)
 | 
						|
			{
 | 
						|
				foreach (ContentRoUsage tmp in _ContentRoUsages)
 | 
						|
				{
 | 
						|
					if (tmp.IsDirty) refreshContentRoUsages.Add(tmp);
 | 
						|
				}
 | 
						|
			}
 | 
						|
			if (_ContentTransitions != null && _ContentTransitions.IsDirty)
 | 
						|
			{
 | 
						|
				foreach (ContentTransition tmp in _ContentTransitions)
 | 
						|
				{
 | 
						|
					if (tmp.IsDirty) refreshContentTransitions.Add(tmp);
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private void BuildRefreshList()
 | 
						|
		{
 | 
						|
			_RefreshContents = new List<Content>();
 | 
						|
			_RefreshContentDetails = new List<ContentDetail>();
 | 
						|
			_RefreshContentItems = new List<ContentItem>();
 | 
						|
			_RefreshContentParts = new List<ContentPart>();
 | 
						|
			_RefreshContentRoUsages = new List<ContentRoUsage>();
 | 
						|
			_RefreshContentTransitions = new List<ContentTransition>();
 | 
						|
			AddToRefreshList(_RefreshContents, _RefreshContentDetails, _RefreshContentItems, _RefreshContentParts, _RefreshContentRoUsages, _RefreshContentTransitions);
 | 
						|
		}
 | 
						|
		private void ProcessRefreshList()
 | 
						|
		{
 | 
						|
			foreach (Content tmp in _RefreshContents)
 | 
						|
			{
 | 
						|
				ContentInfo.Refresh(tmp);
 | 
						|
				if (tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat);
 | 
						|
			}
 | 
						|
			foreach (ContentDetail tmp in _RefreshContentDetails)
 | 
						|
			{
 | 
						|
				DetailInfo.Refresh(tmp);
 | 
						|
			}
 | 
						|
			foreach (ContentItem tmp in _RefreshContentItems)
 | 
						|
			{
 | 
						|
				ItemInfo.Refresh(tmp);
 | 
						|
			}
 | 
						|
			foreach (ContentPart tmp in _RefreshContentParts)
 | 
						|
			{
 | 
						|
				PartInfo.Refresh(this, tmp);
 | 
						|
			}
 | 
						|
			foreach (ContentRoUsage tmp in _RefreshContentRoUsages)
 | 
						|
			{
 | 
						|
				RoUsageInfo.Refresh(tmp);
 | 
						|
			}
 | 
						|
			foreach (ContentTransition tmp in _RefreshContentTransitions)
 | 
						|
			{
 | 
						|
				TransitionInfo.Refresh(tmp);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Collection
 | 
						|
		private static List<Content> _CacheList = new List<Content>();
 | 
						|
		protected static void AddToCache(Content content)
 | 
						|
		{
 | 
						|
			if (!_CacheList.Contains(content)) _CacheList.Add(content); // In AddToCache
 | 
						|
		}
 | 
						|
		protected static void RemoveFromCache(Content content)
 | 
						|
		{
 | 
						|
			while (_CacheList.Contains(content)) _CacheList.Remove(content); // In RemoveFromCache
 | 
						|
		}
 | 
						|
		private static Dictionary<string, List<Content>> _CacheByPrimaryKey = new Dictionary<string, List<Content>>();
 | 
						|
		private static void ConvertListToDictionary()
 | 
						|
		{
 | 
						|
			while (_CacheList.Count > 0) // Move Content(s) from temporary _CacheList to _CacheByPrimaryKey
 | 
						|
			{
 | 
						|
				Content tmp = _CacheList[0]; // Get the first Content
 | 
						|
				if (!tmp.Disposed)
 | 
						|
				{
 | 
						|
					string pKey = tmp.ContentID.ToString();
 | 
						|
					if (!_CacheByPrimaryKey.ContainsKey(pKey))
 | 
						|
					{
 | 
						|
						_CacheByPrimaryKey[pKey] = new List<Content>(); // Add new list for PrimaryKey
 | 
						|
					}
 | 
						|
					_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
 | 
						|
				}
 | 
						|
				_CacheList.RemoveAt(0); // Remove the first Content
 | 
						|
			}
 | 
						|
		}
 | 
						|
		protected static Content 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; }
 | 
						|
		}
 | 
						|
		private static int _nextContentID = -1;
 | 
						|
		public static int NextContentID
 | 
						|
		{
 | 
						|
			get { return _nextContentID--; }
 | 
						|
		}
 | 
						|
		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;
 | 
						|
			}
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			set
 | 
						|
			{
 | 
						|
				CanWriteProperty("Number", true);
 | 
						|
				if (value == null) value = string.Empty;
 | 
						|
				if (_Number != value)
 | 
						|
				{
 | 
						|
					_Number = value;
 | 
						|
					PropertyHasChanged();
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private string _Text = string.Empty;
 | 
						|
		public string Text
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("Text", true);
 | 
						|
				return _Text;
 | 
						|
			}
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			set
 | 
						|
			{
 | 
						|
				CanWriteProperty("Text", true);
 | 
						|
				if (value == null) value = string.Empty;
 | 
						|
				if (_Text != value)
 | 
						|
				{
 | 
						|
					_Text = value;
 | 
						|
					PropertyHasChanged();
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		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;
 | 
						|
			}
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			set
 | 
						|
			{
 | 
						|
				CanWriteProperty("Type", true);
 | 
						|
				if (_Type != value)
 | 
						|
				{
 | 
						|
					_Type = value;
 | 
						|
					PropertyHasChanged();
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		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 Format _MyFormat;
 | 
						|
		public Format MyFormat
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyFormat", true);
 | 
						|
				if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
 | 
						|
				return _MyFormat;
 | 
						|
			}
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			set
 | 
						|
			{
 | 
						|
				CanWriteProperty("MyFormat", true);
 | 
						|
				if ((_MyFormat == null ? _FormatID : (int?)_MyFormat.FormatID) != (value == null ? null : (int?)value.FormatID))
 | 
						|
				{
 | 
						|
					_MyFormat = value;
 | 
						|
					_FormatID = (value == null ? null : (int?)value.FormatID);
 | 
						|
					PropertyHasChanged();
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private string _Config = string.Empty;
 | 
						|
		public string Config
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("Config", true);
 | 
						|
				return _Config;
 | 
						|
			}
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			set
 | 
						|
			{
 | 
						|
				CanWriteProperty("Config", true);
 | 
						|
				if (value == null) value = string.Empty;
 | 
						|
				if (_Config != value)
 | 
						|
				{
 | 
						|
					_Config = value;
 | 
						|
					PropertyHasChanged();
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private DateTime _DTS = new DateTime();
 | 
						|
		public DateTime DTS
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("DTS", true);
 | 
						|
				return _DTS;
 | 
						|
			}
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			set
 | 
						|
			{
 | 
						|
				CanWriteProperty("DTS", true);
 | 
						|
				if (_DTS != value)
 | 
						|
				{
 | 
						|
					_DTS = value;
 | 
						|
					PropertyHasChanged();
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private string _UserID = string.Empty;
 | 
						|
		public string UserID
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("UserID", true);
 | 
						|
				return _UserID;
 | 
						|
			}
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			set
 | 
						|
			{
 | 
						|
				CanWriteProperty("UserID", true);
 | 
						|
				if (value == null) value = string.Empty;
 | 
						|
				if (_UserID != value)
 | 
						|
				{
 | 
						|
					_UserID = value;
 | 
						|
					PropertyHasChanged();
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private byte[] _LastChanged = new byte[8];//timestamp
 | 
						|
		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);
 | 
						|
				return _ContentDetailCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private ContentDetails _ContentDetails = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(ContentDetailsConverter))]
 | 
						|
		public ContentDetails ContentDetails
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentDetails", true);
 | 
						|
				if (_ContentDetailCount < 0 || (_ContentDetailCount > 0 && _ContentDetails == null))
 | 
						|
					_ContentDetails = ContentDetails.GetByContentID(ContentID);
 | 
						|
				if (_ContentDetailCount < 0 )
 | 
						|
					_ContentDetailCount = _ContentDetails == null ? 0 : _ContentDetails.Count;
 | 
						|
				if (_ContentDetails == null)
 | 
						|
					_ContentDetails = ContentDetails.New();
 | 
						|
				return _ContentDetails;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void Reset_ContentDetails()
 | 
						|
		{
 | 
						|
			_ContentDetailCount = -1;
 | 
						|
		}
 | 
						|
		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);
 | 
						|
				return _ContentEntryCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private Entry _MyEntry = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(EntryConverter))]
 | 
						|
		public Entry MyEntry
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyEntry", true);
 | 
						|
				if (_MyEntry == null) _MyEntry = Entry.New(this);
 | 
						|
				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 Grid _MyGrid = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(GridConverter))]
 | 
						|
		public Grid MyGrid
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyGrid", true);
 | 
						|
				if (_MyGrid == null) _MyGrid = Grid.New(this);
 | 
						|
				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 Image _MyImage = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(ImageConverter))]
 | 
						|
		public Image MyImage
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyImage", true);
 | 
						|
				if (_MyImage == null) _MyImage = Image.New(this);
 | 
						|
				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);
 | 
						|
				return _ContentItemCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private ContentItems _ContentItems = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(ContentItemsConverter))]
 | 
						|
		public ContentItems ContentItems
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentItems", true);
 | 
						|
				if (_ContentItemCount < 0 || (_ContentItemCount > 0 && _ContentItems == null))
 | 
						|
					_ContentItems = ContentItems.GetByContentID(ContentID);
 | 
						|
				if (_ContentItemCount < 0 )
 | 
						|
					_ContentItemCount = _ContentItems == null ? 0 : _ContentItems.Count;
 | 
						|
				if (_ContentItems == null)
 | 
						|
					_ContentItems = ContentItems.New();
 | 
						|
				return _ContentItems;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void Reset_ContentItems()
 | 
						|
		{
 | 
						|
			_ContentItemCount = -1;
 | 
						|
		}
 | 
						|
		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);
 | 
						|
				return _ContentPartCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private ContentParts _ContentParts = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(ContentPartsConverter))]
 | 
						|
		public ContentParts ContentParts
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentParts", true);
 | 
						|
				if (_ContentPartCount < 0 || (_ContentPartCount > 0 && _ContentParts == null))
 | 
						|
					_ContentParts = ContentParts.GetByContentID(ContentID);
 | 
						|
				if (_ContentPartCount < 0 )
 | 
						|
					_ContentPartCount = _ContentParts == null ? 0 : _ContentParts.Count;
 | 
						|
				if (_ContentParts == null)
 | 
						|
					_ContentParts = ContentParts.New();
 | 
						|
				return _ContentParts;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void Reset_ContentParts()
 | 
						|
		{
 | 
						|
			_ContentPartCount = -1;
 | 
						|
		}
 | 
						|
		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);
 | 
						|
				return _ContentRoUsageCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private ContentRoUsages _ContentRoUsages = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(ContentRoUsagesConverter))]
 | 
						|
		public ContentRoUsages ContentRoUsages
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentRoUsages", true);
 | 
						|
				if (_ContentRoUsageCount < 0 || (_ContentRoUsageCount > 0 && _ContentRoUsages == null))
 | 
						|
					_ContentRoUsages = ContentRoUsages.GetByContentID(ContentID);
 | 
						|
				if (_ContentRoUsageCount < 0 )
 | 
						|
					_ContentRoUsageCount = _ContentRoUsages == null ? 0 : _ContentRoUsages.Count;
 | 
						|
				if (_ContentRoUsages == null)
 | 
						|
					_ContentRoUsages = ContentRoUsages.New();
 | 
						|
				return _ContentRoUsages;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void Reset_ContentRoUsages()
 | 
						|
		{
 | 
						|
			_ContentRoUsageCount = -1;
 | 
						|
		}
 | 
						|
		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);
 | 
						|
				return _ContentTransitionCount;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private ContentTransitions _ContentTransitions = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(ContentTransitionsConverter))]
 | 
						|
		public ContentTransitions ContentTransitions
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("ContentTransitions", true);
 | 
						|
				if (_ContentTransitionCount < 0 || (_ContentTransitionCount > 0 && _ContentTransitions == null))
 | 
						|
					_ContentTransitions = ContentTransitions.GetByFromID(ContentID);
 | 
						|
				if (_ContentTransitionCount < 0 )
 | 
						|
					_ContentTransitionCount = _ContentTransitions == null ? 0 : _ContentTransitions.Count;
 | 
						|
				if (_ContentTransitions == null)
 | 
						|
					_ContentTransitions = ContentTransitions.New();
 | 
						|
				return _ContentTransitions;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public void Reset_ContentTransitions()
 | 
						|
		{
 | 
						|
			_ContentTransitionCount = -1;
 | 
						|
		}
 | 
						|
		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 ZContent _MyZContent = null;
 | 
						|
		/// <summary>
 | 
						|
		/// Related Field
 | 
						|
		/// </summary>
 | 
						|
		[TypeConverter(typeof(ZContentConverter))]
 | 
						|
		public ZContent MyZContent
 | 
						|
		{
 | 
						|
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | 
						|
			get
 | 
						|
			{
 | 
						|
				CanReadProperty("MyZContent", true);
 | 
						|
				if (_MyZContent == null) _MyZContent = ZContent.New(this);
 | 
						|
				return _MyZContent;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public override bool IsDirty
 | 
						|
		{
 | 
						|
			get 
 | 
						|
			{
 | 
						|
				if ( base.IsDirty ) 
 | 
						|
					return true;
 | 
						|
				return IsDirtyList(new List<object>());
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public bool IsDirtyList(List<object> list)
 | 
						|
		{
 | 
						|
			if (base.IsDirty || list.Contains(this))
 | 
						|
				return base.IsDirty;
 | 
						|
			list.Add(this);
 | 
						|
			return base.IsDirty || (_ContentDetails == null ? false : _ContentDetails.IsDirtyList(list)) || (_MyEntry == null ? false : _MyEntry.IsDirtyList(list)) || (_MyGrid == null ? false : _MyGrid.IsDirtyList(list)) || (_MyImage == null ? false : _MyImage.IsDirtyList(list)) || (_ContentItems == null ? false : _ContentItems.IsDirtyList(list)) || (_ContentParts == null ? false : _ContentParts.IsDirtyList(list)) || (_ContentRoUsages == null ? false : _ContentRoUsages.IsDirtyList(list)) || (_ContentTransitions == null ? false : _ContentTransitions.IsDirtyList(list)) || (_MyZContent == null ? false : _MyZContent.IsDirtyList(list)) || (_MyFormat == null ? false : _MyFormat.IsDirtyList(list));
 | 
						|
		}
 | 
						|
		public override bool IsValid
 | 
						|
		{
 | 
						|
			get { return IsValidList(new List<object>()); }
 | 
						|
		}
 | 
						|
		public bool IsValidList(List<object> list)
 | 
						|
		{
 | 
						|
			if(list.Contains(this))
 | 
						|
				return (IsNew && !IsDirty) ? true : base.IsValid;
 | 
						|
			list.Add(this);
 | 
						|
			return ((IsNew && !IsDirty) ? true : base.IsValid) && (_ContentDetails == null ? true : _ContentDetails.IsValidList(list)) && (_MyEntry == null ? true : _MyEntry.IsValidList(list)) && (_MyGrid == null ? true : _MyGrid.IsValidList(list)) && (_MyImage == null ? true : _MyImage.IsValidList(list)) && (_ContentItems == null ? true : _ContentItems.IsValidList(list)) && (_ContentParts == null ? true : _ContentParts.IsValidList(list)) && (_ContentRoUsages == null ? true : _ContentRoUsages.IsValidList(list)) && (_ContentTransitions == null ? true : _ContentTransitions.IsValidList(list)) && (_MyZContent == null ? true : _MyZContent.IsValidList(list)) && (_MyFormat == null ? true : _MyFormat.IsValidList(list));
 | 
						|
		}
 | 
						|
		// CSLATODO: Replace base Content.ToString function as necessary
 | 
						|
		/// <summary>
 | 
						|
		/// Overrides Base ToString
 | 
						|
		/// </summary>
 | 
						|
		/// <returns>A string representation of current Content</returns>
 | 
						|
		//public override string ToString()
 | 
						|
		//{
 | 
						|
		//  return base.ToString();
 | 
						|
		//}
 | 
						|
		// CSLATODO: Check Content.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 Content</returns>
 | 
						|
		protected override object GetIdValue()
 | 
						|
		{
 | 
						|
			return MyContentUnique; // Absolutely Unique ID
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region ValidationRules
 | 
						|
		[NonSerialized]
 | 
						|
		private bool _CheckingBrokenRules = false;
 | 
						|
		public IVEHasBrokenRules HasBrokenRules
 | 
						|
		{
 | 
						|
			get
 | 
						|
			{
 | 
						|
				if (_CheckingBrokenRules) return null;
 | 
						|
				if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
 | 
						|
				try
 | 
						|
				{
 | 
						|
					_CheckingBrokenRules = true;
 | 
						|
					IVEHasBrokenRules hasBrokenRules = null;
 | 
						|
					if (_ContentItems != null && (hasBrokenRules = _ContentItems.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_ContentDetails != null && (hasBrokenRules = _ContentDetails.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_MyEntry != null && (hasBrokenRules = _MyEntry.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_MyGrid != null && (hasBrokenRules = _MyGrid.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_MyImage != null && (hasBrokenRules = _MyImage.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_ContentParts != null && (hasBrokenRules = _ContentParts.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_ContentRoUsages != null && (hasBrokenRules = _ContentRoUsages.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_ContentTransitions != null && (hasBrokenRules = _ContentTransitions.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_MyZContent != null && (hasBrokenRules = _MyZContent.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
 | 
						|
					return hasBrokenRules;
 | 
						|
				}
 | 
						|
				finally
 | 
						|
				{
 | 
						|
					_CheckingBrokenRules = false;
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public BrokenRulesCollection BrokenRules
 | 
						|
		{
 | 
						|
			get
 | 
						|
			{
 | 
						|
				IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
 | 
						|
				if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
 | 
						|
				return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		protected override void AddBusinessRules()
 | 
						|
		{
 | 
						|
			ValidationRules.AddRule(
 | 
						|
				Csla.Validation.CommonRules.StringMaxLength,
 | 
						|
				new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 256));
 | 
						|
			ValidationRules.AddRule(
 | 
						|
				Csla.Validation.CommonRules.StringMaxLength,
 | 
						|
				new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
 | 
						|
			ValidationRules.AddRule(
 | 
						|
				Csla.Validation.CommonRules.StringMaxLength,
 | 
						|
				new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
 | 
						|
			ValidationRules.AddRule(
 | 
						|
				Csla.Validation.CommonRules.StringRequired, "UserID");
 | 
						|
			ValidationRules.AddRule(
 | 
						|
				Csla.Validation.CommonRules.StringMaxLength,
 | 
						|
				new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
 | 
						|
			//ValidationRules.AddDependantProperty("x", "y");
 | 
						|
			_ContentExtension.AddValidationRules(ValidationRules);
 | 
						|
			// CSLATODO:  Add other validation rules
 | 
						|
		}
 | 
						|
		protected override void AddInstanceBusinessRules()
 | 
						|
		{
 | 
						|
			_ContentExtension.AddInstanceValidationRules(ValidationRules);
 | 
						|
			// CSLATODO:  Add other validation rules
 | 
						|
		}
 | 
						|
		// Sample data comparison validation rule
 | 
						|
		//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
 | 
						|
		//{
 | 
						|
		//	if (_started > _ended)
 | 
						|
		//	{
 | 
						|
		//		e.Description = "Start date can't be after end date";
 | 
						|
		//		return false;
 | 
						|
		//	}
 | 
						|
		//	else
 | 
						|
		//		return true;
 | 
						|
		//}
 | 
						|
		#endregion
 | 
						|
		#region Authorization Rules
 | 
						|
		protected override void AddAuthorizationRules()
 | 
						|
		{
 | 
						|
			//CSLATODO: Who can read/write which fields
 | 
						|
			//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowRead(Number, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowRead(Text, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowRead(Type, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowRead(Config, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowWrite(Type, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowWrite(FormatID, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
 | 
						|
			//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
 | 
						|
			_ContentExtension.AddAuthorizationRules(AuthorizationRules);
 | 
						|
		}
 | 
						|
		protected override void AddInstanceAuthorizationRules()
 | 
						|
		{
 | 
						|
			//CSLATODO: Who can read/write which fields
 | 
						|
			_ContentExtension.AddInstanceAuthorizationRules(AuthorizationRules);
 | 
						|
		}
 | 
						|
		public static bool CanAddObject()
 | 
						|
		{
 | 
						|
			// CSLATODO: Can Add Authorization
 | 
						|
			//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
 | 
						|
			return true;
 | 
						|
		}
 | 
						|
		public static bool CanGetObject()
 | 
						|
		{
 | 
						|
			// CSLATODO: CanGet Authorization
 | 
						|
			return true;
 | 
						|
		}
 | 
						|
		public static bool CanDeleteObject()
 | 
						|
		{
 | 
						|
			// CSLATODO: CanDelete Authorization
 | 
						|
			//bool result = false;
 | 
						|
			//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
 | 
						|
			//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
 | 
						|
			//return result;
 | 
						|
			return true;
 | 
						|
		}
 | 
						|
		/// <summary>
 | 
						|
		/// determines if related records (Foreign Keys) will keep this Item from being deleted
 | 
						|
		/// </summary>
 | 
						|
		public bool CanDelete
 | 
						|
		{
 | 
						|
			get
 | 
						|
			{
 | 
						|
				// Check to make sure that there are not any related records
 | 
						|
				int usedByCount = 0;
 | 
						|
				usedByCount += _ContentDetailCount;
 | 
						|
				usedByCount += _ContentEntryCount;
 | 
						|
				usedByCount += _ContentGridCount;
 | 
						|
				usedByCount += _ContentImageCount;
 | 
						|
				usedByCount += _ContentItemCount;
 | 
						|
				usedByCount += _ContentPartCount;
 | 
						|
				usedByCount += _ContentRoUsageCount;
 | 
						|
				usedByCount += _ContentTransitionCount;
 | 
						|
				usedByCount += _ContentZContentCount;
 | 
						|
				return (usedByCount == 0);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public static bool CanEditObject()
 | 
						|
		{
 | 
						|
			// CSLATODO: CanEdit Authorization
 | 
						|
			//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
 | 
						|
			return true;
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Factory Methods
 | 
						|
		public int CurrentEditLevel
 | 
						|
		{ get { return EditLevel; } }
 | 
						|
		private static int _ContentUnique = 0;
 | 
						|
		protected static int ContentUnique
 | 
						|
		{ get { return ++_ContentUnique; } }
 | 
						|
		private int _MyContentUnique = ContentUnique;
 | 
						|
		public int MyContentUnique // Absolutely Unique ID - Editable
 | 
						|
		{ get { return _MyContentUnique; } }
 | 
						|
		protected Content()
 | 
						|
		{/* require use of factory methods */
 | 
						|
			AddToCache(this);
 | 
						|
		}
 | 
						|
		private bool _Disposed = false;
 | 
						|
 | 
						|
		public bool Disposed
 | 
						|
		{
 | 
						|
			get { return _Disposed; }
 | 
						|
			set { _Disposed = value; }
 | 
						|
		}
 | 
						|
		public void Dispose()
 | 
						|
		{
 | 
						|
			if (_MyGrid != null)
 | 
						|
			{
 | 
						|
				_MyGrid.Dispose();
 | 
						|
				_MyGrid = null;
 | 
						|
			}
 | 
						|
			Disposed = true;
 | 
						|
			RemoveFromDictionaries();
 | 
						|
		}
 | 
						|
		private void RemoveFromDictionaries()
 | 
						|
		{
 | 
						|
			RemoveFromCache(this);
 | 
						|
			if (_CacheByPrimaryKey.ContainsKey(ContentID.ToString()))
 | 
						|
			{
 | 
						|
				List<Content> listContent = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
 | 
						|
				while (listContent.Contains(this)) listContent.Remove(this); // Remove the item from the list
 | 
						|
				if (listContent.Count == 0) //If there are no items left in the list
 | 
						|
					_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public static Content New()
 | 
						|
		{
 | 
						|
			if (!CanAddObject())
 | 
						|
				throw new System.Security.SecurityException("User not authorized to add a Content");
 | 
						|
			try
 | 
						|
			{
 | 
						|
				return DataPortal.Create<Content>();
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				throw new DbCslaException("Error on Content.New", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public static Content New(string number, string text, int? type, Format myFormat, string config, DateTime dts, string userID)
 | 
						|
		{
 | 
						|
			Content tmp = Content.New();
 | 
						|
			tmp.Number = number;
 | 
						|
			tmp.Text = text;
 | 
						|
			tmp.Type = type;
 | 
						|
			tmp.MyFormat = myFormat;
 | 
						|
			tmp.Config = config;
 | 
						|
			tmp.DTS = dts;
 | 
						|
			tmp.UserID = userID;
 | 
						|
			return tmp;
 | 
						|
		}
 | 
						|
		public static Content MakeContent(string number, string text, int? type, Format myFormat, string config, DateTime dts, string userID)
 | 
						|
		{
 | 
						|
			Content tmp = Content.New(number, text, type, myFormat, config, dts, userID);
 | 
						|
			if (tmp.IsSavable)
 | 
						|
			{
 | 
						|
				Content tmp2 = tmp;
 | 
						|
				tmp = tmp2.Save();
 | 
						|
				tmp2.Dispose();
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
				Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
 | 
						|
				tmp._ErrorMessage = "Failed Validation:";
 | 
						|
				foreach (Csla.Validation.BrokenRule br in brc)
 | 
						|
				{
 | 
						|
					tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
 | 
						|
				}
 | 
						|
			}
 | 
						|
			return tmp;
 | 
						|
		}
 | 
						|
		public static Content New(string number, string text, int? type, Format myFormat, string config)
 | 
						|
		{
 | 
						|
			Content tmp = Content.New();
 | 
						|
			tmp.Number = number;
 | 
						|
			tmp.Text = text;
 | 
						|
			tmp.Type = type;
 | 
						|
			tmp.MyFormat = myFormat;
 | 
						|
			tmp.Config = config;
 | 
						|
			return tmp;
 | 
						|
		}
 | 
						|
		public static Content MakeContent(string number, string text, int? type, Format myFormat, string config)
 | 
						|
		{
 | 
						|
			Content tmp = Content.New(number, text, type, myFormat, config);
 | 
						|
			if (tmp.IsSavable)
 | 
						|
			{
 | 
						|
				Content tmp2 = tmp;
 | 
						|
				tmp = tmp2.Save();
 | 
						|
				tmp2.Dispose();
 | 
						|
			}
 | 
						|
			else
 | 
						|
			{
 | 
						|
				Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
 | 
						|
				tmp._ErrorMessage = "Failed Validation:";
 | 
						|
				foreach (Csla.Validation.BrokenRule br in brc)
 | 
						|
				{
 | 
						|
					tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
 | 
						|
				}
 | 
						|
			}
 | 
						|
			return tmp;
 | 
						|
		}
 | 
						|
		public static Content Get(int contentID)
 | 
						|
		{
 | 
						|
			if (!CanGetObject())
 | 
						|
				throw new System.Security.SecurityException("User not authorized to view a Content");
 | 
						|
			try
 | 
						|
			{
 | 
						|
				Content tmp = GetCachedByPrimaryKey(contentID);
 | 
						|
				if (tmp == null)
 | 
						|
				{
 | 
						|
					tmp = DataPortal.Fetch<Content>(new PKCriteria(contentID));
 | 
						|
					AddToCache(tmp);
 | 
						|
				}
 | 
						|
				if (tmp.ErrorMessage == "No Record Found") 
 | 
						|
				{
 | 
						|
					tmp.Dispose(); // Clean-up Content
 | 
						|
					tmp = null;
 | 
						|
				}
 | 
						|
				return tmp;
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				throw new DbCslaException("Error on Content.Get", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public static Content Get(SafeDataReader dr)
 | 
						|
		{
 | 
						|
			if (dr.Read()) return new Content(dr);
 | 
						|
			return null;
 | 
						|
		}
 | 
						|
		internal Content(SafeDataReader dr)
 | 
						|
		{
 | 
						|
			ReadData(dr);
 | 
						|
		}
 | 
						|
		public static void Delete(int contentID)
 | 
						|
		{
 | 
						|
			if (!CanDeleteObject())
 | 
						|
				throw new System.Security.SecurityException("User not authorized to remove a Content");
 | 
						|
			try
 | 
						|
			{
 | 
						|
				DataPortal.Delete(new PKCriteria(contentID));
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				throw new DbCslaException("Error on Content.Delete", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		public override Content Save()
 | 
						|
		{
 | 
						|
			if (IsDeleted && !CanDeleteObject())
 | 
						|
				throw new System.Security.SecurityException("User not authorized to remove a Content");
 | 
						|
			else if (IsNew && !CanAddObject())
 | 
						|
				throw new System.Security.SecurityException("User not authorized to add a Content");
 | 
						|
			else if (!CanEditObject())
 | 
						|
				throw new System.Security.SecurityException("User not authorized to update a Content");
 | 
						|
			try
 | 
						|
			{
 | 
						|
				BuildRefreshList();
 | 
						|
				Content content = base.Save();
 | 
						|
				RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
 | 
						|
				AddToCache(content);//Refresh the item in AllList
 | 
						|
				ProcessRefreshList();
 | 
						|
				return content;
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				throw new DbCslaException("Error on CSLA Save", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Data Access Portal
 | 
						|
		[Serializable()]
 | 
						|
		protected class PKCriteria
 | 
						|
		{
 | 
						|
			private int _ContentID;
 | 
						|
			public int ContentID
 | 
						|
			{ get { return _ContentID; } }
 | 
						|
			public PKCriteria(int contentID)
 | 
						|
			{
 | 
						|
				_ContentID = contentID;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
 | 
						|
		[RunLocal()]
 | 
						|
		private new void DataPortal_Create()
 | 
						|
		{
 | 
						|
			_ContentID = NextContentID;
 | 
						|
			// Database Defaults
 | 
						|
			_DTS = _ContentExtension.DefaultDTS;
 | 
						|
			_UserID = _ContentExtension.DefaultUserID;
 | 
						|
			// CSLATODO: Add any defaults that are necessary
 | 
						|
			ValidationRules.CheckRules();
 | 
						|
		}
 | 
						|
		private void ReadData(SafeDataReader dr)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.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");
 | 
						|
				dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
 | 
						|
				_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");
 | 
						|
				MarkOld();
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.ReadData", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				throw new DbCslaException("Content.ReadData", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		private void DataPortal_Fetch(PKCriteria criteria)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.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);
 | 
						|
						using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
 | 
						|
						{
 | 
						|
							if (!dr.Read())
 | 
						|
							{
 | 
						|
								_ErrorMessage = "No Record Found";
 | 
						|
								return;
 | 
						|
							}
 | 
						|
							ReadData(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_ContentDetails = ContentDetails.Get(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_MyEntry = Entry.Get(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_MyGrid = Grid.Get(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_MyImage = Image.Get(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_ContentItems = ContentItems.Get(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_ContentParts = ContentParts.Get(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_ContentRoUsages = ContentRoUsages.Get(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_ContentTransitions = ContentTransitions.Get(dr);
 | 
						|
							// load child objects
 | 
						|
							dr.NextResult();
 | 
						|
							_MyZContent = ZContent.Get(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("Content.DataPortal_Fetch", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				throw new DbCslaException("Content.DataPortal_Fetch", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		protected override void DataPortal_Insert()
 | 
						|
		{
 | 
						|
			try
 | 
						|
			{
 | 
						|
				using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | 
						|
				{
 | 
						|
					ApplicationContext.LocalContext["cn"] = cn;
 | 
						|
					SQLInsert();
 | 
						|
					// 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("Content.DataPortal_Insert", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				throw new DbCslaException("Content.DataPortal_Insert", ex);
 | 
						|
			}
 | 
						|
			finally
 | 
						|
			{
 | 
						|
				if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Insert", GetHashCode());
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		internal void SQLInsert()
 | 
						|
		{
 | 
						|
			if (!this.IsDirty) return;
 | 
						|
			try
 | 
						|
			{
 | 
						|
				if (_MyFormat != null) _MyFormat.Update();
 | 
						|
				SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
 | 
						|
				using (SqlCommand cm = cn.CreateCommand())
 | 
						|
				{
 | 
						|
					cm.CommandType = CommandType.StoredProcedure;
 | 
						|
					cm.CommandText = "addContent";
 | 
						|
					// Input All Fields - Except Calculated Columns
 | 
						|
					cm.Parameters.AddWithValue("@Number", _Number);
 | 
						|
					cm.Parameters.AddWithValue("@Text", _Text);
 | 
						|
					cm.Parameters.AddWithValue("@Type", _Type);
 | 
						|
					cm.Parameters.AddWithValue("@FormatID", FormatID);
 | 
						|
					cm.Parameters.AddWithValue("@Config", _Config);
 | 
						|
					if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
 | 
						|
					cm.Parameters.AddWithValue("@UserID", _UserID);
 | 
						|
					// Output Calculated Columns
 | 
						|
					SqlParameter param_ContentID = new SqlParameter("@newContentID", SqlDbType.Int);
 | 
						|
					param_ContentID.Direction = ParameterDirection.Output;
 | 
						|
					cm.Parameters.Add(param_ContentID);
 | 
						|
					SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
 | 
						|
					param_LastChanged.Direction = ParameterDirection.Output;
 | 
						|
					cm.Parameters.Add(param_LastChanged);
 | 
						|
					// CSLATODO: Define any additional output parameters
 | 
						|
					cm.ExecuteNonQuery();
 | 
						|
					// Save all values being returned from the Procedure
 | 
						|
					_ContentID = (int)cm.Parameters["@newContentID"].Value;
 | 
						|
					_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
 | 
						|
				}
 | 
						|
				MarkOld();
 | 
						|
				// update child objects
 | 
						|
				if (_ContentItems != null) _ContentItems.Update(this);
 | 
						|
				if (_ContentDetails != null) _ContentDetails.Update(this);
 | 
						|
				if (_MyEntry != null) _MyEntry.Update(this);
 | 
						|
				if (_MyGrid != null) _MyGrid.Update(this);
 | 
						|
				if (_MyImage != null) _MyImage.Update(this);
 | 
						|
				if (_ContentParts != null) _ContentParts.Update(this);
 | 
						|
				if (_ContentRoUsages != null) _ContentRoUsages.Update(this);
 | 
						|
				if (_ContentTransitions != null) _ContentTransitions.Update(this);
 | 
						|
				if (_MyZContent != null) _MyZContent.Update(this);
 | 
						|
				if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.SQLInsert", GetHashCode());
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.SQLInsert", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				throw new DbCslaException("Content.SQLInsert", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		public static byte[] Add(SqlConnection cn, ref int contentID, string number, string text, int? type, Format myFormat, string config, DateTime dts, string userID)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.Add", 0);
 | 
						|
			try
 | 
						|
			{
 | 
						|
				using (SqlCommand cm = cn.CreateCommand())
 | 
						|
				{
 | 
						|
					cm.CommandType = CommandType.StoredProcedure;
 | 
						|
					cm.CommandText = "addContent";
 | 
						|
					// Input All Fields - Except Calculated Columns
 | 
						|
					cm.Parameters.AddWithValue("@Number", number);
 | 
						|
					cm.Parameters.AddWithValue("@Text", text);
 | 
						|
					cm.Parameters.AddWithValue("@Type", type);
 | 
						|
					if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID);
 | 
						|
					cm.Parameters.AddWithValue("@Config", config);
 | 
						|
					if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
 | 
						|
					cm.Parameters.AddWithValue("@UserID", userID);
 | 
						|
					// Output Calculated Columns
 | 
						|
					SqlParameter param_ContentID = new SqlParameter("@newContentID", SqlDbType.Int);
 | 
						|
					param_ContentID.Direction = ParameterDirection.Output;
 | 
						|
					cm.Parameters.Add(param_ContentID);
 | 
						|
					SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
 | 
						|
					param_LastChanged.Direction = ParameterDirection.Output;
 | 
						|
					cm.Parameters.Add(param_LastChanged);
 | 
						|
					// CSLATODO: Define any additional output parameters
 | 
						|
					cm.ExecuteNonQuery();
 | 
						|
					// Save all values being returned from the Procedure
 | 
						|
					contentID = (int)cm.Parameters["@newContentID"].Value;
 | 
						|
					return (byte[])cm.Parameters["@newLastChanged"].Value;
 | 
						|
				}
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.Add", ex);
 | 
						|
				throw new DbCslaException("Content.Add", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		protected override void DataPortal_Update()
 | 
						|
		{
 | 
						|
			if (!IsDirty) return;	// If not dirty - nothing to do
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Update", GetHashCode());
 | 
						|
			try
 | 
						|
			{
 | 
						|
				using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | 
						|
				{
 | 
						|
					ApplicationContext.LocalContext["cn"] = cn;
 | 
						|
					SQLUpdate();
 | 
						|
					// 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("Content.DataPortal_Update", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		internal void SQLUpdate()
 | 
						|
		{
 | 
						|
			if (!IsDirty) return;	// If not dirty - nothing to do
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.SQLUpdate", GetHashCode());
 | 
						|
			try
 | 
						|
			{
 | 
						|
				if (_MyFormat != null) _MyFormat.Update();
 | 
						|
				SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
 | 
						|
				if (base.IsDirty)
 | 
						|
				{
 | 
						|
					using (SqlCommand cm = cn.CreateCommand())
 | 
						|
					{
 | 
						|
						cm.CommandType = CommandType.StoredProcedure;
 | 
						|
						cm.CommandText = "updateContent";
 | 
						|
						// All Fields including Calculated Fields
 | 
						|
						cm.Parameters.AddWithValue("@ContentID", _ContentID);
 | 
						|
						cm.Parameters.AddWithValue("@Number", _Number);
 | 
						|
						cm.Parameters.AddWithValue("@Text", _Text);
 | 
						|
						cm.Parameters.AddWithValue("@Type", _Type);
 | 
						|
						cm.Parameters.AddWithValue("@FormatID", FormatID);
 | 
						|
						cm.Parameters.AddWithValue("@Config", _Config);
 | 
						|
						if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
 | 
						|
						cm.Parameters.AddWithValue("@UserID", _UserID);
 | 
						|
						cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
 | 
						|
						// Output Calculated Columns
 | 
						|
						SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
 | 
						|
						param_LastChanged.Direction = ParameterDirection.Output;
 | 
						|
						cm.Parameters.Add(param_LastChanged);
 | 
						|
						// CSLATODO: Define any additional output parameters
 | 
						|
						cm.ExecuteNonQuery();
 | 
						|
						// Save all values being returned from the Procedure
 | 
						|
						_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
 | 
						|
					}
 | 
						|
				}
 | 
						|
				MarkOld();
 | 
						|
				// use the open connection to update child objects
 | 
						|
				if (_ContentItems != null) _ContentItems.Update(this);
 | 
						|
				if (_ContentDetails != null) _ContentDetails.Update(this);
 | 
						|
				if (_MyEntry != null) _MyEntry.Update(this);
 | 
						|
				if (_MyGrid != null) _MyGrid.Update(this);
 | 
						|
				if (_MyImage != null) _MyImage.Update(this);
 | 
						|
				if (_ContentParts != null) _ContentParts.Update(this);
 | 
						|
				if (_ContentRoUsages != null) _ContentRoUsages.Update(this);
 | 
						|
				if (_ContentTransitions != null) _ContentTransitions.Update(this);
 | 
						|
				if (_MyZContent != null) _MyZContent.Update(this);
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.SQLUpdate", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		internal void Update()
 | 
						|
		{
 | 
						|
			if (!this.IsDirty) return;
 | 
						|
			if (base.IsDirty)
 | 
						|
			{
 | 
						|
				SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
 | 
						|
				if (IsNew)
 | 
						|
					_LastChanged = Content.Add(cn, ref _ContentID, _Number, _Text, _Type, _MyFormat, _Config, _DTS, _UserID);
 | 
						|
				else
 | 
						|
					_LastChanged = Content.Update(cn, ref _ContentID, _Number, _Text, _Type, _FormatID, _Config, _DTS, _UserID, ref _LastChanged);
 | 
						|
				MarkOld();
 | 
						|
			}
 | 
						|
			if (_ContentItems != null) _ContentItems.Update(this);
 | 
						|
			if (_ContentDetails != null) _ContentDetails.Update(this);
 | 
						|
			if (_MyEntry != null) _MyEntry.Update(this);
 | 
						|
			if (_MyGrid != null) _MyGrid.Update(this);
 | 
						|
			if (_MyImage != null) _MyImage.Update(this);
 | 
						|
			if (_ContentParts != null) _ContentParts.Update(this);
 | 
						|
			if (_ContentRoUsages != null) _ContentRoUsages.Update(this);
 | 
						|
			if (_ContentTransitions != null) _ContentTransitions.Update(this);
 | 
						|
			if (_MyZContent != null) _MyZContent.Update(this);
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		public static byte[] Update(SqlConnection cn, ref int contentID, string number, string text, int? type, int? formatID, string config, DateTime dts, string userID, ref byte[] lastChanged)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.Update", 0);
 | 
						|
			try
 | 
						|
			{
 | 
						|
				using (SqlCommand cm = cn.CreateCommand())
 | 
						|
				{
 | 
						|
					cm.CommandType = CommandType.StoredProcedure;
 | 
						|
					cm.CommandText = "updateContent";
 | 
						|
					// Input All Fields - Except Calculated Columns
 | 
						|
					cm.Parameters.AddWithValue("@ContentID", contentID);
 | 
						|
					cm.Parameters.AddWithValue("@Number", number);
 | 
						|
					cm.Parameters.AddWithValue("@Text", text);
 | 
						|
					cm.Parameters.AddWithValue("@Type", type);
 | 
						|
					cm.Parameters.AddWithValue("@FormatID", formatID);
 | 
						|
					cm.Parameters.AddWithValue("@Config", config);
 | 
						|
					if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
 | 
						|
					cm.Parameters.AddWithValue("@UserID", userID);
 | 
						|
					cm.Parameters.AddWithValue("@LastChanged", lastChanged);
 | 
						|
					// Output Calculated Columns
 | 
						|
					SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
 | 
						|
					param_LastChanged.Direction = ParameterDirection.Output;
 | 
						|
					cm.Parameters.Add(param_LastChanged);
 | 
						|
					// CSLATODO: Define any additional output parameters
 | 
						|
					cm.ExecuteNonQuery();
 | 
						|
					// Save all values being returned from the Procedure
 | 
						|
					return (byte[])cm.Parameters["@newLastChanged"].Value;
 | 
						|
				}
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.Update", ex);
 | 
						|
				throw new DbCslaException("Content.Update", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		protected override void DataPortal_DeleteSelf()
 | 
						|
		{
 | 
						|
			DataPortal_Delete(new PKCriteria(_ContentID));
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		private void DataPortal_Delete(PKCriteria criteria)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Delete", GetHashCode());
 | 
						|
			try
 | 
						|
			{
 | 
						|
				using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | 
						|
				{
 | 
						|
					using (SqlCommand cm = cn.CreateCommand())
 | 
						|
					{
 | 
						|
						cm.CommandType = CommandType.StoredProcedure;
 | 
						|
						cm.CommandText = "deleteContent";
 | 
						|
						cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
 | 
						|
						cm.ExecuteNonQuery();
 | 
						|
					}
 | 
						|
				}
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Delete", ex);
 | 
						|
				_ErrorMessage = ex.Message;
 | 
						|
				throw new DbCslaException("Content.DataPortal_Delete", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Transactional(TransactionalTypes.TransactionScope)]
 | 
						|
		public static void Remove(SqlConnection cn, int contentID)
 | 
						|
		{
 | 
						|
			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.Remove", 0);
 | 
						|
			try
 | 
						|
			{
 | 
						|
				using (SqlCommand cm = cn.CreateCommand())
 | 
						|
				{
 | 
						|
					cm.CommandType = CommandType.StoredProcedure;
 | 
						|
					cm.CommandText = "deleteContent";
 | 
						|
					// Input PK Fields
 | 
						|
					cm.Parameters.AddWithValue("@ContentID", contentID);
 | 
						|
					// CSLATODO: Define any additional output parameters
 | 
						|
					cm.ExecuteNonQuery();
 | 
						|
				}
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.Remove", ex);
 | 
						|
				throw new DbCslaException("Content.Remove", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		#region Exists
 | 
						|
		public static bool Exists(int contentID)
 | 
						|
		{
 | 
						|
			ExistsCommand result;
 | 
						|
			try
 | 
						|
			{
 | 
						|
				result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(contentID));
 | 
						|
				return result.Exists;
 | 
						|
			}
 | 
						|
			catch (Exception ex)
 | 
						|
			{
 | 
						|
				throw new DbCslaException("Error on Content.Exists", ex);
 | 
						|
			}
 | 
						|
		}
 | 
						|
		[Serializable()]
 | 
						|
		private class ExistsCommand : CommandBase
 | 
						|
		{
 | 
						|
			private int _ContentID;
 | 
						|
			private bool _exists;
 | 
						|
			public bool Exists
 | 
						|
			{
 | 
						|
				get { return _exists; }
 | 
						|
			}
 | 
						|
			public ExistsCommand(int contentID)
 | 
						|
			{
 | 
						|
				_ContentID = contentID;
 | 
						|
			}
 | 
						|
			protected override void DataPortal_Execute()
 | 
						|
			{
 | 
						|
				if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Content.DataPortal_Execute", GetHashCode());
 | 
						|
				try
 | 
						|
				{
 | 
						|
					using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | 
						|
					{
 | 
						|
						cn.Open();
 | 
						|
						using (SqlCommand cm = cn.CreateCommand())
 | 
						|
						{
 | 
						|
							cm.CommandType = CommandType.StoredProcedure;
 | 
						|
							cm.CommandText = "existsContent";
 | 
						|
							cm.Parameters.AddWithValue("@ContentID", _ContentID);
 | 
						|
							int count = (int)cm.ExecuteScalar();
 | 
						|
							_exists = (count > 0);
 | 
						|
						}
 | 
						|
					}
 | 
						|
				}
 | 
						|
				catch (Exception ex)
 | 
						|
				{
 | 
						|
					if (_MyLog.IsErrorEnabled) _MyLog.Error("Content.DataPortal_Execute", ex);
 | 
						|
					throw new DbCslaException("Content.DataPortal_Execute", ex);
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
		// Standard Default Code
 | 
						|
		#region extension
 | 
						|
		ContentExtension _ContentExtension = new ContentExtension();
 | 
						|
		[Serializable()]
 | 
						|
		partial class ContentExtension : extensionBase
 | 
						|
		{
 | 
						|
		}
 | 
						|
		[Serializable()]
 | 
						|
		class extensionBase
 | 
						|
		{
 | 
						|
			// Default Values
 | 
						|
			public virtual DateTime DefaultDTS
 | 
						|
			{
 | 
						|
				get { return DateTime.Now; }
 | 
						|
			}
 | 
						|
			public virtual string DefaultUserID
 | 
						|
			{
 | 
						|
				get { return Environment.UserName.ToUpper(); }
 | 
						|
			}
 | 
						|
			// Authorization Rules
 | 
						|
			public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
 | 
						|
			{
 | 
						|
				// Needs to be overriden to add new authorization rules
 | 
						|
			}
 | 
						|
			// Instance Authorization Rules
 | 
						|
			public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
 | 
						|
			{
 | 
						|
				// Needs to be overriden to add new authorization rules
 | 
						|
			}
 | 
						|
			// Validation Rules
 | 
						|
			public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
 | 
						|
			{
 | 
						|
				// Needs to be overriden to add new validation rules
 | 
						|
			}
 | 
						|
			// InstanceValidation Rules
 | 
						|
			public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
 | 
						|
			{
 | 
						|
				// Needs to be overriden to add new validation rules
 | 
						|
			}
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
	} // Class
 | 
						|
	#region Converter
 | 
						|
	internal class ContentConverter : ExpandableObjectConverter
 | 
						|
	{
 | 
						|
		public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
 | 
						|
		{
 | 
						|
			if (destType == typeof(string) && value is Content)
 | 
						|
			{
 | 
						|
				// Return the ToString value
 | 
						|
				return ((Content)value).ToString();
 | 
						|
			}
 | 
						|
			return base.ConvertTo(context, culture, value, destType);
 | 
						|
		}
 | 
						|
	}
 | 
						|
	#endregion
 | 
						|
} // Namespace
 | 
						|
 | 
						|
 | 
						|
//// The following is a sample Extension File.  You can use it to create ContentExt.cs
 | 
						|
//using System;
 | 
						|
//using System.Collections.Generic;
 | 
						|
//using System.Text;
 | 
						|
//using Csla;
 | 
						|
 | 
						|
//namespace VEPROMS.CSLA.Library
 | 
						|
//{
 | 
						|
//  public partial class Content
 | 
						|
//  {
 | 
						|
//    partial class ContentExtension : extensionBase
 | 
						|
//    {
 | 
						|
//      // CSLATODO: Override automatic defaults
 | 
						|
//      public virtual DateTime DefaultDTS
 | 
						|
//      {
 | 
						|
//        get { return DateTime.Now; }
 | 
						|
//      }
 | 
						|
//      public virtual string DefaultUserID
 | 
						|
//      {
 | 
						|
//        get { return Environment.UserName.ToUpper(); }
 | 
						|
//      }
 | 
						|
//      public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
 | 
						|
//      {
 | 
						|
//        //rules.AllowRead(Dbid, "<Role(s)>");
 | 
						|
//      }
 | 
						|
//      public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
 | 
						|
//      {
 | 
						|
//        //rules.AllowInstanceRead(Dbid, "<Role(s)>");
 | 
						|
//      }
 | 
						|
//      public new void AddValidationRules(Csla.Validation.ValidationRules rules)
 | 
						|
//      {
 | 
						|
//        rules.AddRule(
 | 
						|
//          Csla.Validation.CommonRules.StringMaxLength,
 | 
						|
//          new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
 | 
						|
//      }
 | 
						|
//      public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
 | 
						|
//      {
 | 
						|
//        rules.AddInstanceRule(/* Instance Validation Rule */);
 | 
						|
//      }
 | 
						|
//    }
 | 
						|
//  }
 | 
						|
//}
 |