// ========================================================================
// 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
{
	/// 
	///	AnnotationAudit Generated by MyGeneration using the CSLA Object Mapping template
	/// 
	[Serializable()]
	[TypeConverter(typeof(AnnotationAuditConverter))]
	public partial class AnnotationAudit : BusinessBase, IDisposable, IVEHasBrokenRules
	{
		#region Log4Net
		private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
		#endregion
		#region Refresh
		private List _RefreshAnnotationAudits = new List();
		private void AddToRefreshList(List refreshAnnotationAudits)
		{
			if (IsDirty)
				refreshAnnotationAudits.Add(this);
		}
		private void ClearRefreshList()
		{
			_RefreshAnnotationAudits = new List();
		}
		private void BuildRefreshList()
		{
			ClearRefreshList();
			AddToRefreshList(_RefreshAnnotationAudits);
		}
		private void ProcessRefreshList()
		{
			foreach (AnnotationAudit tmp in _RefreshAnnotationAudits)
			{
				AnnotationAuditInfo.Refresh(tmp);
			}
			ClearRefreshList();
		}
		#endregion
		#region Collection
		private static List _CacheList = new List();
		protected static void AddToCache(AnnotationAudit annotationAudit)
		{
			if (!_CacheList.Contains(annotationAudit)) _CacheList.Add(annotationAudit); // In AddToCache
		}
		protected static void RemoveFromCache(AnnotationAudit annotationAudit)
		{
			while (_CacheList.Contains(annotationAudit)) _CacheList.Remove(annotationAudit); // In RemoveFromCache
		}
		private static Dictionary> _CacheByPrimaryKey = new Dictionary>();
		private static void ConvertListToDictionary()
		{
			while (_CacheList.Count > 0) // Move AnnotationAudit(s) from temporary _CacheList to _CacheByPrimaryKey
			{
				AnnotationAudit tmp = _CacheList[0]; // Get the first AnnotationAudit
				string pKey = tmp.AuditID.ToString();
				if (!_CacheByPrimaryKey.ContainsKey(pKey))
				{
					_CacheByPrimaryKey[pKey] = new List(); // Add new list for PrimaryKey
				}
				_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
				_CacheList.RemoveAt(0); // Remove the first AnnotationAudit
			}
		}
		protected static AnnotationAudit GetCachedByPrimaryKey(long auditID)
		{
			ConvertListToDictionary();
			string key = auditID.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 _nextAuditID = -1;
		public static int NextAuditID
		{
			get { return _nextAuditID--; }
		}
		private long _AuditID;
		[System.ComponentModel.DataObjectField(true, true)]
		public long AuditID
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _AuditID;
			}
		}
		private int _AnnotationID;
		public int AnnotationID
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _AnnotationID;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				if (_AnnotationID != value)
				{
					_AnnotationID = value;
					PropertyHasChanged();
				}
			}
		}
		private int _ItemID;
		public int ItemID
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _ItemID;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				if (_ItemID != value)
				{
					_ItemID = value;
					PropertyHasChanged();
				}
			}
		}
		private int _TypeID;
		public int TypeID
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _TypeID;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				if (_TypeID != value)
				{
					_TypeID = value;
					PropertyHasChanged();
				}
			}
		}
		private string _RtfText = string.Empty;
		public string RtfText
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _RtfText;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				if (value == null) value = string.Empty;
				if (_RtfText != value)
				{
					_RtfText = value;
					PropertyHasChanged();
				}
			}
		}
		private string _SearchText = string.Empty;
		public string SearchText
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _SearchText;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				if (value == null) value = string.Empty;
				if (_SearchText != value)
				{
					_SearchText = value;
					PropertyHasChanged();
				}
			}
		}
		private string _Config = string.Empty;
		public string Config
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _Config;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				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
			{
				return _DTS;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				if (_DTS != value)
				{
					_DTS = value;
					PropertyHasChanged();
				}
			}
		}
		private string _UserID = string.Empty;
		public string UserID
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _UserID;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				if (value == null) value = string.Empty;
				if (_UserID != value)
				{
					_UserID = value;
					PropertyHasChanged();
				}
			}
		}
		private int _DeleteStatus;
		public int DeleteStatus
		{
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			get
			{
				return _DeleteStatus;
			}
			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
			set
			{
				if (_DeleteStatus != value)
				{
					_DeleteStatus = value;
					PropertyHasChanged();
				}
			}
		}
		public override bool IsDirty
		{
			get { return base.IsDirty; }
		}
		public bool IsDirtyList(List