1598 lines
		
	
	
		
			53 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			1598 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>
 | |
| 	///	Folder Generated by MyGeneration using the CSLA Object Mapping template
 | |
| 	/// </summary>
 | |
| 	[Serializable()]
 | |
| 	[TypeConverter(typeof(FolderConverter))]
 | |
| 	public partial class Folder : BusinessBase<Folder>, IDisposable, IVEHasBrokenRules
 | |
| 	{
 | |
| 		#region Log4Net
 | |
| 		private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | |
| 		#endregion
 | |
| 		#region Refresh
 | |
| 		private List<Folder> _RefreshFolders = new List<Folder>();
 | |
| 		private List<FolderAssignment> _RefreshFolderAssignments = new List<FolderAssignment>();
 | |
| 		private List<FolderDocVersion> _RefreshFolderDocVersions = new List<FolderDocVersion>();
 | |
| 		private void AddToRefreshList(List<Folder> refreshFolders, List<FolderAssignment> refreshFolderAssignments, List<FolderDocVersion> refreshFolderDocVersions)
 | |
| 		{
 | |
| 			if (IsDirty)
 | |
| 				refreshFolders.Add(this);
 | |
| 			if (_FolderAssignments != null && _FolderAssignments.IsDirty)
 | |
| 			{
 | |
| 				foreach (FolderAssignment tmp in _FolderAssignments)
 | |
| 				{
 | |
| 					if (tmp.IsDirty) refreshFolderAssignments.Add(tmp);
 | |
| 				}
 | |
| 			}
 | |
| 			if (_FolderDocVersions != null && _FolderDocVersions.IsDirty)
 | |
| 			{
 | |
| 				foreach (FolderDocVersion tmp in _FolderDocVersions)
 | |
| 				{
 | |
| 					if (tmp.IsDirty) refreshFolderDocVersions.Add(tmp);
 | |
| 				}
 | |
| 			}
 | |
| 			if (_ChildFolders != null && _ChildFolders.IsDirty)
 | |
| 			{
 | |
| 				foreach (Folder tmp in _ChildFolders)
 | |
| 				{
 | |
| 					tmp.AddToRefreshList(refreshFolders, refreshFolderAssignments, refreshFolderDocVersions);
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private void ClearRefreshList()
 | |
| 		{
 | |
| 			_RefreshFolders = new List<Folder>();
 | |
| 			_RefreshFolderAssignments = new List<FolderAssignment>();
 | |
| 			_RefreshFolderDocVersions = new List<FolderDocVersion>();
 | |
| 		}
 | |
| 		private void BuildRefreshList()
 | |
| 		{
 | |
| 			ClearRefreshList();
 | |
| 			AddToRefreshList(_RefreshFolders, _RefreshFolderAssignments, _RefreshFolderDocVersions);
 | |
| 		}
 | |
| 		private void ProcessRefreshList()
 | |
| 		{
 | |
| 			foreach (Folder tmp in _RefreshFolders)
 | |
| 			{
 | |
| 				FolderInfo.Refresh(tmp);
 | |
| 				if (tmp._MyConnection != null) ConnectionInfo.Refresh(tmp._MyConnection);
 | |
| 				if (tmp._MyFormat != null) FormatInfo.Refresh(tmp._MyFormat);
 | |
| 			}
 | |
| 			foreach (FolderAssignment tmp in _RefreshFolderAssignments)
 | |
| 			{
 | |
| 				AssignmentInfo.Refresh(tmp);
 | |
| 			}
 | |
| 			foreach (FolderDocVersion tmp in _RefreshFolderDocVersions)
 | |
| 			{
 | |
| 				DocVersionInfo.Refresh(tmp);
 | |
| 			}
 | |
| 			ClearRefreshList();
 | |
| 		}
 | |
| 		#endregion
 | |
| 		#region Collection
 | |
| 		private static List<Folder> _CacheList = new List<Folder>();
 | |
| 		protected static void AddToCache(Folder folder)
 | |
| 		{
 | |
| 			if (!_CacheList.Contains(folder)) _CacheList.Add(folder); // In AddToCache
 | |
| 		}
 | |
| 		protected static void RemoveFromCache(Folder folder)
 | |
| 		{
 | |
| 			while (_CacheList.Contains(folder)) _CacheList.Remove(folder); // In RemoveFromCache
 | |
| 		}
 | |
| 		private static Dictionary<string, List<Folder>> _CacheByPrimaryKey = new Dictionary<string, List<Folder>>();
 | |
| 		private static Dictionary<string, List<Folder>> _CacheByParentID_Name = new Dictionary<string, List<Folder>>();
 | |
| 		private static void ConvertListToDictionary()
 | |
| 		{
 | |
| 			while (_CacheList.Count > 0) // Move Folder(s) from temporary _CacheList to _CacheByPrimaryKey
 | |
| 			{
 | |
| 				Folder tmp = _CacheList[0]; // Get the first Folder
 | |
| 				string pKey = tmp.FolderID.ToString();
 | |
| 				if (!_CacheByPrimaryKey.ContainsKey(pKey))
 | |
| 				{
 | |
| 					_CacheByPrimaryKey[pKey] = new List<Folder>(); // Add new list for PrimaryKey
 | |
| 					_CacheByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = new List<Folder>(); // Add new list for ParentID_Name
 | |
| 				}
 | |
| 				_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
 | |
| 				_CacheByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()].Add(tmp); // Unique Index
 | |
| 				_CacheList.RemoveAt(0); // Remove the first Folder
 | |
| 			}
 | |
| 		}
 | |
| 		protected static Folder GetCachedByPrimaryKey(int folderID)
 | |
| 		{
 | |
| 			ConvertListToDictionary();
 | |
| 			string key = folderID.ToString();
 | |
| 			if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
 | |
| 			return null;
 | |
| 		}
 | |
| 		protected static Folder GetCachedByParentID_Name(int parentID, string name)
 | |
| 		{
 | |
| 			ConvertListToDictionary();
 | |
| 			string key = parentID.ToString() + "_" + name.ToString();
 | |
| 			if (_CacheByParentID_Name.ContainsKey(key)) return _CacheByParentID_Name[key][0];
 | |
| 			return null;
 | |
| 		}
 | |
| 		#endregion
 | |
| 		#region Business Methods
 | |
| 		private string _ErrorMessage = string.Empty;
 | |
| 		public string ErrorMessage
 | |
| 		{
 | |
| 			get { return _ErrorMessage; }
 | |
| 		}
 | |
| 		private static int _nextFolderID = -1;
 | |
| 		public static int NextFolderID
 | |
| 		{
 | |
| 			get { return _nextFolderID--; }
 | |
| 		}
 | |
| 		private int _FolderID;
 | |
| 		[System.ComponentModel.DataObjectField(true, true)]
 | |
| 		public int FolderID
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("FolderID", true);
 | |
| 				return _FolderID;
 | |
| 			}
 | |
| 		}
 | |
| 		private int _ParentID;
 | |
| 		public int ParentID
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("ParentID", true);
 | |
| 				if (_MyParent != null) _ParentID = _MyParent.FolderID;
 | |
| 				return _ParentID;
 | |
| 			}
 | |
| 		}
 | |
| 		private Folder _MyParent;
 | |
| 		public Folder MyParent
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("MyParent", true);
 | |
| 				if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID);
 | |
| 				return _MyParent;
 | |
| 			}
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			set
 | |
| 			{
 | |
| 				CanWriteProperty("MyParent", true);
 | |
| 				if (_MyParent != value)
 | |
| 				{
 | |
| 					_MyParent = value;
 | |
| 					_ParentID = value.FolderID;// Update underlying data field
 | |
| 					PropertyHasChanged();
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private int _DBID;
 | |
| 		public int DBID
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("DBID", true);
 | |
| 				if (_MyConnection != null) _DBID = _MyConnection.DBID;
 | |
| 				return _DBID;
 | |
| 			}
 | |
| 		}
 | |
| 		private Connection _MyConnection;
 | |
| 		public Connection MyConnection
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("MyConnection", true);
 | |
| 				if (_MyConnection == null && _DBID != 0) _MyConnection = Connection.Get(_DBID);
 | |
| 				return _MyConnection;
 | |
| 			}
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			set
 | |
| 			{
 | |
| 				CanWriteProperty("MyConnection", true);
 | |
| 				if (_MyConnection != value)
 | |
| 				{
 | |
| 					_MyConnection = value;
 | |
| 					_DBID = value.DBID;// Update underlying data field
 | |
| 					PropertyHasChanged();
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private string _Name = string.Empty;
 | |
| 		public string Name
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("Name", true);
 | |
| 				return _Name;
 | |
| 			}
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			set
 | |
| 			{
 | |
| 				CanWriteProperty("Name", true);
 | |
| 				if (value == null) value = string.Empty;
 | |
| 				if (_Name != value)
 | |
| 				{
 | |
| 					_Name = value;
 | |
| 					PropertyHasChanged();
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private string _Title = string.Empty;
 | |
| 		public string Title
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("Title", true);
 | |
| 				return _Title;
 | |
| 			}
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			set
 | |
| 			{
 | |
| 				CanWriteProperty("Title", true);
 | |
| 				if (value == null) value = string.Empty;
 | |
| 				if (_Title != value)
 | |
| 				{
 | |
| 					_Title = value;
 | |
| 					PropertyHasChanged();
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private string _ShortName = string.Empty;
 | |
| 		public string ShortName
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("ShortName", true);
 | |
| 				return _ShortName;
 | |
| 			}
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			set
 | |
| 			{
 | |
| 				CanWriteProperty("ShortName", true);
 | |
| 				if (value == null) value = string.Empty;
 | |
| 				if (_ShortName != value)
 | |
| 				{
 | |
| 					_ShortName = 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 double? _ManualOrder;
 | |
| 		public double? ManualOrder
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("ManualOrder", true);
 | |
| 				return _ManualOrder;
 | |
| 			}
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			set
 | |
| 			{
 | |
| 				CanWriteProperty("ManualOrder", true);
 | |
| 				if (_ManualOrder != value)
 | |
| 				{
 | |
| 					_ManualOrder = value;
 | |
| 					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 _UsrID = string.Empty;
 | |
| 		public string UsrID
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("UsrID", true);
 | |
| 				return _UsrID;
 | |
| 			}
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			set
 | |
| 			{
 | |
| 				CanWriteProperty("UsrID", true);
 | |
| 				if (value == null) value = string.Empty;
 | |
| 				if (_UsrID != value)
 | |
| 				{
 | |
| 					_UsrID = value;
 | |
| 					PropertyHasChanged();
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		private byte[] _LastChanged = new byte[8];//timestamp
 | |
| 		private int _FolderAssignmentCount = 0;
 | |
| 		/// <summary>
 | |
| 		/// Count of FolderAssignments for this Folder
 | |
| 		/// </summary>
 | |
| 		public int FolderAssignmentCount
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("FolderAssignmentCount", true);
 | |
| 				return _FolderAssignmentCount;
 | |
| 			}
 | |
| 		}
 | |
| 		private FolderAssignments _FolderAssignments = null;
 | |
| 		/// <summary>
 | |
| 		/// Related Field
 | |
| 		/// </summary>
 | |
| 		[TypeConverter(typeof(FolderAssignmentsConverter))]
 | |
| 		public FolderAssignments FolderAssignments
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("FolderAssignments", true);
 | |
| 				if (_FolderAssignmentCount < 0 || (_FolderAssignmentCount > 0 && _FolderAssignments == null))
 | |
| 					_FolderAssignments = FolderAssignments.GetByFolderID(FolderID);
 | |
| 				if (_FolderAssignmentCount < 0 )
 | |
| 					_FolderAssignmentCount = _FolderAssignments == null ? 0 : _FolderAssignments.Count;
 | |
| 				if (_FolderAssignments == null)
 | |
| 					_FolderAssignments = FolderAssignments.New();
 | |
| 				return _FolderAssignments;
 | |
| 			}
 | |
| 		}
 | |
| 		public void Reset_FolderAssignments()
 | |
| 		{
 | |
| 			_FolderAssignmentCount = -1;
 | |
| 		}
 | |
| 		private int _FolderDocVersionCount = 0;
 | |
| 		/// <summary>
 | |
| 		/// Count of FolderDocVersions for this Folder
 | |
| 		/// </summary>
 | |
| 		public int FolderDocVersionCount
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("FolderDocVersionCount", true);
 | |
| 				return _FolderDocVersionCount;
 | |
| 			}
 | |
| 		}
 | |
| 		private FolderDocVersions _FolderDocVersions = null;
 | |
| 		/// <summary>
 | |
| 		/// Related Field
 | |
| 		/// </summary>
 | |
| 		[TypeConverter(typeof(FolderDocVersionsConverter))]
 | |
| 		public FolderDocVersions FolderDocVersions
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("FolderDocVersions", true);
 | |
| 				if (_FolderDocVersionCount < 0 || (_FolderDocVersionCount > 0 && _FolderDocVersions == null))
 | |
| 					_FolderDocVersions = FolderDocVersions.GetByFolderID(FolderID);
 | |
| 				if (_FolderDocVersionCount < 0 )
 | |
| 					_FolderDocVersionCount = _FolderDocVersions == null ? 0 : _FolderDocVersions.Count;
 | |
| 				if (_FolderDocVersions == null)
 | |
| 					_FolderDocVersions = FolderDocVersions.New();
 | |
| 				return _FolderDocVersions;
 | |
| 			}
 | |
| 		}
 | |
| 		public void Reset_FolderDocVersions()
 | |
| 		{
 | |
| 			_FolderDocVersionCount = -1;
 | |
| 		}
 | |
| 		private int _ChildFolderCount = 0;
 | |
| 		/// <summary>
 | |
| 		/// Count of ChildFolders for this Folder
 | |
| 		/// </summary>
 | |
| 		public int ChildFolderCount
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("ChildFolderCount", true);
 | |
| 				return _ChildFolderCount;
 | |
| 			}
 | |
| 		}
 | |
| 		private ChildFolders _ChildFolders = null;
 | |
| 		/// <summary>
 | |
| 		/// Related Field
 | |
| 		/// </summary>
 | |
| 		[TypeConverter(typeof(ChildFoldersConverter))]
 | |
| 		public ChildFolders ChildFolders
 | |
| 		{
 | |
| 			[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
 | |
| 			get
 | |
| 			{
 | |
| 				CanReadProperty("ChildFolders", true);
 | |
| 				if (_ChildFolderCount < 0 || (_ChildFolderCount > 0 && _ChildFolders == null))
 | |
| 					_ChildFolders = ChildFolders.GetByParentID(FolderID);
 | |
| 				if (_ChildFolderCount < 0 )
 | |
| 					_ChildFolderCount = _ChildFolders == null ? 0 : _ChildFolders.Count;
 | |
| 				if (_ChildFolders == null)
 | |
| 					_ChildFolders = ChildFolders.New();
 | |
| 				return _ChildFolders;
 | |
| 			}
 | |
| 		}
 | |
| 		public void Reset_ChildFolders()
 | |
| 		{
 | |
| 			_ChildFolderCount = -1;
 | |
| 		}
 | |
| 		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 || (_FolderAssignments == null ? false : _FolderAssignments.IsDirtyList(list)) || (_FolderDocVersions == null ? false : _FolderDocVersions.IsDirtyList(list)) || (_ChildFolders == null ? false : _ChildFolders.IsDirtyList(list)) || (_MyConnection == null ? false : _MyConnection.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) && (_FolderAssignments == null ? true : _FolderAssignments.IsValidList(list)) && (_FolderDocVersions == null ? true : _FolderDocVersions.IsValidList(list)) && (_ChildFolders == null ? true : _ChildFolders.IsValidList(list)) && (_MyConnection == null ? true : _MyConnection.IsValidList(list)) && (_MyFormat == null ? true : _MyFormat.IsValidList(list));
 | |
| 		}
 | |
| 		// CSLATODO: Replace base Folder.ToString function as necessary
 | |
| 		/// <summary>
 | |
| 		/// Overrides Base ToString
 | |
| 		/// </summary>
 | |
| 		/// <returns>A string representation of current Folder</returns>
 | |
| 		//public override string ToString()
 | |
| 		//{
 | |
| 		//  return base.ToString();
 | |
| 		//}
 | |
| 		// CSLATODO: Check Folder.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 Folder</returns>
 | |
| 		protected override object GetIdValue()
 | |
| 		{
 | |
| 			return MyFolderUnique; // 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 (_FolderAssignments != null && (hasBrokenRules = _FolderAssignments.HasBrokenRules) != null) return hasBrokenRules;
 | |
| 					if (_FolderDocVersions != null && (hasBrokenRules = _FolderDocVersions.HasBrokenRules) != null) return hasBrokenRules;
 | |
| 					if (_ChildFolders != null && (hasBrokenRules = _ChildFolders.HasBrokenRules) != null) return hasBrokenRules;
 | |
| 					if (_MyConnection != null && (hasBrokenRules = _MyConnection.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<Folder>(MyConnectionRequired, "MyConnection");
 | |
| 			ValidationRules.AddRule(
 | |
| 				Csla.Validation.CommonRules.StringRequired, "Name");
 | |
| 			ValidationRules.AddRule(
 | |
| 				Csla.Validation.CommonRules.StringMaxLength,
 | |
| 				new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
 | |
| 			ValidationRules.AddRule(
 | |
| 				Csla.Validation.CommonRules.StringMaxLength,
 | |
| 				new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
 | |
| 			ValidationRules.AddRule(
 | |
| 				Csla.Validation.CommonRules.StringRequired, "ShortName");
 | |
| 			ValidationRules.AddRule(
 | |
| 				Csla.Validation.CommonRules.StringMaxLength,
 | |
| 				new Csla.Validation.CommonRules.MaxLengthRuleArgs("ShortName", 20));
 | |
| 			ValidationRules.AddRule(
 | |
| 				Csla.Validation.CommonRules.StringMaxLength,
 | |
| 				new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
 | |
| 			ValidationRules.AddRule(
 | |
| 				Csla.Validation.CommonRules.StringRequired, "UsrID");
 | |
| 			ValidationRules.AddRule(
 | |
| 				Csla.Validation.CommonRules.StringMaxLength,
 | |
| 				new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
 | |
| 			//ValidationRules.AddDependantProperty("x", "y");
 | |
| 			_FolderExtension.AddValidationRules(ValidationRules);
 | |
| 			// CSLATODO:  Add other validation rules
 | |
| 		}
 | |
| 		protected override void AddInstanceBusinessRules()
 | |
| 		{
 | |
| 			_FolderExtension.AddInstanceValidationRules(ValidationRules);
 | |
| 			// CSLATODO:  Add other validation rules
 | |
| 		}
 | |
| 		private static bool MyConnectionRequired(Folder target, Csla.Validation.RuleArgs e)
 | |
| 		{
 | |
| 			if (target._DBID == 0 && target._MyConnection == null) // Required field missing
 | |
| 			{
 | |
| 				e.Description = "Required";
 | |
| 				return false;
 | |
| 			}
 | |
| 			return true;
 | |
| 		}
 | |
| 		// 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(FolderID, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(DBID, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(Name, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(Title, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(ShortName, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(ManualOrder, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(Config, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(DBID, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(ShortName, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(FormatID, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(ManualOrder, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
 | |
| 			//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
 | |
| 			_FolderExtension.AddAuthorizationRules(AuthorizationRules);
 | |
| 		}
 | |
| 		protected override void AddInstanceAuthorizationRules()
 | |
| 		{
 | |
| 			//CSLATODO: Who can read/write which fields
 | |
| 			_FolderExtension.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 += _FolderAssignmentCount;
 | |
| 				usedByCount += _FolderDocVersionCount;
 | |
| 				usedByCount += _ChildFolderCount;
 | |
| 				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 _FolderUnique = 0;
 | |
| 		protected static int FolderUnique
 | |
| 		{ get { return ++_FolderUnique; } }
 | |
| 		private int _MyFolderUnique = FolderUnique;
 | |
| 		public int MyFolderUnique // Absolutely Unique ID - Editable
 | |
| 		{ get { return _MyFolderUnique; } }
 | |
| 		protected Folder()
 | |
| 		{/* 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; } }
 | |
| 		~Folder()
 | |
| 		{
 | |
| 			_CountFinalized++;
 | |
| 		}
 | |
| 		public void Dispose()
 | |
| 		{
 | |
| 			if (_Disposed) return;
 | |
| 			_CountDisposed++;
 | |
| 			_Disposed = true;
 | |
| 			RemoveFromDictionaries();
 | |
| 		}
 | |
| 		private void RemoveFromDictionaries()
 | |
| 		{
 | |
| 			RemoveFromCache(this);
 | |
| 			if (_CacheByPrimaryKey.ContainsKey(FolderID.ToString()))
 | |
| 			{
 | |
| 				List<Folder> listFolder = _CacheByPrimaryKey[FolderID.ToString()]; // Get the list of items
 | |
| 				while (listFolder.Contains(this)) listFolder.Remove(this); // Remove the item from the list
 | |
| 				if (listFolder.Count == 0) //If there are no items left in the list
 | |
| 					_CacheByPrimaryKey.Remove(FolderID.ToString()); // remove the list
 | |
| 			}
 | |
| 			string myKey;
 | |
| 			myKey = null;
 | |
| 			foreach (string key in _CacheByParentID_Name.Keys)
 | |
| 				if (_CacheByParentID_Name[key].Contains(this))
 | |
| 					myKey = key;
 | |
| 			if (myKey != null)
 | |
| 			{
 | |
| 				List<Folder> listFolder = _CacheByParentID_Name[myKey]; // Get the list of items
 | |
| 				listFolder.Remove(this); // Remove the item from the list
 | |
| 				if (listFolder.Count == 0) //If there are no items left in the list
 | |
| 					_CacheByParentID_Name.Remove(myKey); // remove the list
 | |
| 			}
 | |
| 		}
 | |
| 		public static Folder New()
 | |
| 		{
 | |
| 			if (!CanAddObject())
 | |
| 				throw new System.Security.SecurityException("User not authorized to add a Folder");
 | |
| 			try
 | |
| 			{
 | |
| 				return DataPortal.Create<Folder>();
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				throw new DbCslaException("Error on Folder.New", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		public static Folder New(Folder myParent, string name, string shortName)
 | |
| 		{
 | |
| 			Folder tmp = Folder.New();
 | |
| 			tmp.MyParent = myParent;
 | |
| 			tmp.Name = name;
 | |
| 			tmp.ShortName = shortName;
 | |
| 			return tmp;
 | |
| 		}
 | |
| 		public static Folder New(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, double? manualOrder, string config, DateTime dts, string usrID)
 | |
| 		{
 | |
| 			Folder tmp = Folder.New();
 | |
| 			tmp.MyParent = myParent;
 | |
| 			tmp.MyConnection = myConnection;
 | |
| 			tmp.Name = name;
 | |
| 			tmp.Title = title;
 | |
| 			tmp.ShortName = shortName;
 | |
| 			tmp.MyFormat = myFormat;
 | |
| 			tmp.ManualOrder = manualOrder;
 | |
| 			tmp.Config = config;
 | |
| 			tmp.DTS = dts;
 | |
| 			tmp.UsrID = usrID;
 | |
| 			return tmp;
 | |
| 		}
 | |
| 		public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, double? manualOrder, string config, DateTime dts, string usrID)
 | |
| 		{
 | |
| 			Folder tmp = Folder.New(myParent, myConnection, name, title, shortName, myFormat, manualOrder, config, dts, usrID);
 | |
| 			if (tmp.IsSavable)
 | |
| 				tmp = tmp.Save();
 | |
| 			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 Folder New(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, double? manualOrder, string config)
 | |
| 		{
 | |
| 			Folder tmp = Folder.New();
 | |
| 			tmp.MyParent = myParent;
 | |
| 			tmp.MyConnection = myConnection;
 | |
| 			tmp.Name = name;
 | |
| 			tmp.Title = title;
 | |
| 			tmp.ShortName = shortName;
 | |
| 			tmp.MyFormat = myFormat;
 | |
| 			tmp.ManualOrder = manualOrder;
 | |
| 			tmp.Config = config;
 | |
| 			return tmp;
 | |
| 		}
 | |
| 		public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, double? manualOrder, string config)
 | |
| 		{
 | |
| 			Folder tmp = Folder.New(myParent, myConnection, name, title, shortName, myFormat, manualOrder, config);
 | |
| 			if (tmp.IsSavable)
 | |
| 				tmp = tmp.Save();
 | |
| 			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 Folder Get(int folderID)
 | |
| 		{
 | |
| 			if (!CanGetObject())
 | |
| 				throw new System.Security.SecurityException("User not authorized to view a Folder");
 | |
| 			try
 | |
| 			{
 | |
| 				Folder tmp = GetCachedByPrimaryKey(folderID);
 | |
| 				if (tmp == null)
 | |
| 				{
 | |
| 					tmp = DataPortal.Fetch<Folder>(new PKCriteria(folderID));
 | |
| 					AddToCache(tmp);
 | |
| 				}
 | |
| 				if (tmp.ErrorMessage == "No Record Found") 
 | |
| 				{
 | |
| 					tmp.Dispose(); // Clean-up Folder
 | |
| 					tmp = null;
 | |
| 				}
 | |
| 				return tmp;
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				throw new DbCslaException("Error on Folder.Get", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		public static Folder GetByParentID_Name(int parentID, string name)
 | |
| 		{
 | |
| 			if (!CanGetObject())
 | |
| 				throw new System.Security.SecurityException("User not authorized to view a Folder");
 | |
| 			try
 | |
| 			{
 | |
| 				Folder tmp = GetCachedByParentID_Name(parentID, name);
 | |
| 				if (tmp == null)
 | |
| 				{
 | |
| 					tmp = DataPortal.Fetch<Folder>(new ParentID_NameCriteria(parentID, name));
 | |
| 					AddToCache(tmp);
 | |
| 				}
 | |
| 				if (tmp.ErrorMessage == "No Record Found") 
 | |
| 				{
 | |
| 					tmp.Dispose(); // Clean-up Folder
 | |
| 					tmp = null;
 | |
| 				}
 | |
| 				return tmp;
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				throw new DbCslaException("Error on Folder.GetByParentID_Name", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		public static Folder Get(SafeDataReader dr, Folder parent)
 | |
| 		{
 | |
| 			if (dr.Read()) return new Folder(dr, parent);
 | |
| 			return null;
 | |
| 		}
 | |
| 		internal Folder(SafeDataReader dr)
 | |
| 		{
 | |
| 			ReadData(dr);
 | |
| 		}
 | |
| 		private Folder(SafeDataReader dr, Folder parent)
 | |
| 		{
 | |
| 			ReadData(dr);
 | |
| 			MarkAsChild();
 | |
| 		}
 | |
| 		internal Folder(SafeDataReader dr, int parentID)
 | |
| 		{
 | |
| 			ReadData(dr);
 | |
| 			MarkAsChild();
 | |
| 		}
 | |
| 		public static void Delete(int folderID)
 | |
| 		{
 | |
| 			if (!CanDeleteObject())
 | |
| 				throw new System.Security.SecurityException("User not authorized to remove a Folder");
 | |
| 			try
 | |
| 			{
 | |
| 				DataPortal.Delete(new PKCriteria(folderID));
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				throw new DbCslaException("Error on Folder.Delete", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		public override Folder Save()
 | |
| 		{
 | |
| 			if (IsDeleted && !CanDeleteObject())
 | |
| 				throw new System.Security.SecurityException("User not authorized to remove a Folder");
 | |
| 			else if (IsNew && !CanAddObject())
 | |
| 				throw new System.Security.SecurityException("User not authorized to add a Folder");
 | |
| 			else if (!CanEditObject())
 | |
| 				throw new System.Security.SecurityException("User not authorized to update a Folder");
 | |
| 			try
 | |
| 			{
 | |
| 				BuildRefreshList();
 | |
| 				Folder folder = base.Save();
 | |
| 				RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
 | |
| 				AddToCache(folder);//Refresh the item in AllList
 | |
| 				ProcessRefreshList();
 | |
| 				return folder;
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				throw new DbCslaException("Error on CSLA Save", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		#endregion
 | |
| 		#region Data Access Portal
 | |
| 		[Serializable()]
 | |
| 		protected class PKCriteria
 | |
| 		{
 | |
| 			private int _FolderID;
 | |
| 			public int FolderID
 | |
| 			{ get { return _FolderID; } }
 | |
| 			public PKCriteria(int folderID)
 | |
| 			{
 | |
| 				_FolderID = folderID;
 | |
| 			}
 | |
| 		}
 | |
| 		[Serializable()]
 | |
| 		private class ParentID_NameCriteria
 | |
| 		{
 | |
| 			private int _ParentID;
 | |
| 			public int ParentID
 | |
| 			{ get { return _ParentID; } }
 | |
| 			private string _Name;
 | |
| 			public string Name
 | |
| 			{ get { return _Name; } }
 | |
| 			public ParentID_NameCriteria(int parentID, string name)
 | |
| 			{
 | |
| 				_ParentID = parentID;
 | |
| 				_Name = name;
 | |
| 			}
 | |
| 		}
 | |
| 		// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
 | |
| 		[RunLocal()]
 | |
| 		private new void DataPortal_Create()
 | |
| 		{
 | |
| 			_FolderID = NextFolderID;
 | |
| 			// Database Defaults
 | |
| 			_ParentID = _FolderExtension.DefaultParentID;
 | |
| 			_DBID = _FolderExtension.DefaultDBID;
 | |
| 			_DTS = _FolderExtension.DefaultDTS;
 | |
| 			_UsrID = _FolderExtension.DefaultUsrID;
 | |
| 			// CSLATODO: Add any defaults that are necessary
 | |
| 			ValidationRules.CheckRules();
 | |
| 		}
 | |
| 		private void ReadData(SafeDataReader dr)
 | |
| 		{
 | |
| 			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.ReadData", GetHashCode());
 | |
| 			try
 | |
| 			{
 | |
| 				_FolderID = dr.GetInt32("FolderID");
 | |
| 				_ParentID = dr.GetInt32("ParentID");
 | |
| 				_DBID = dr.GetInt32("DBID");
 | |
| 				_Name = dr.GetString("Name");
 | |
| 				_Title = dr.GetString("Title");
 | |
| 				_ShortName = dr.GetString("ShortName");
 | |
| 				_FormatID = (int?)dr.GetValue("FormatID");
 | |
| 				_ManualOrder = (double?)dr.GetValue("ManualOrder");
 | |
| 				_Config = dr.GetString("Config");
 | |
| 				_DTS = dr.GetDateTime("DTS");
 | |
| 				_UsrID = dr.GetString("UsrID");
 | |
| 				dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
 | |
| 				_FolderAssignmentCount = dr.GetInt32("AssignmentCount");
 | |
| 				_FolderDocVersionCount = dr.GetInt32("DocVersionCount");
 | |
| 				_ChildFolderCount = dr.GetInt32("ChildCount");
 | |
| 				MarkOld();
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.ReadData", ex);
 | |
| 				_ErrorMessage = ex.Message;
 | |
| 				throw new DbCslaException("Folder.ReadData", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		private void DataPortal_Fetch(PKCriteria criteria)
 | |
| 		{
 | |
| 			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.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 = "getFolder";
 | |
| 						cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
 | |
| 						cm.CommandTimeout = Database.DefaultTimeout;
 | |
| 						using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
 | |
| 						{
 | |
| 							if (!dr.Read())
 | |
| 							{
 | |
| 								_ErrorMessage = "No Record Found";
 | |
| 								return;
 | |
| 							}
 | |
| 							ReadData(dr);
 | |
| 							// load child objects
 | |
| 							dr.NextResult();
 | |
| 							_FolderAssignments = FolderAssignments.Get(dr);
 | |
| 							// load child objects
 | |
| 							dr.NextResult();
 | |
| 							_FolderDocVersions = FolderDocVersions.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("Folder.DataPortal_Fetch", ex);
 | |
| 				_ErrorMessage = ex.Message;
 | |
| 				throw new DbCslaException("Folder.DataPortal_Fetch", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		private void DataPortal_Fetch(ParentID_NameCriteria criteria)
 | |
| 		{
 | |
| 			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.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 = "getFolderByParentID_Name";
 | |
| 						cm.Parameters.AddWithValue("@ParentID", criteria.ParentID);
 | |
| 						cm.Parameters.AddWithValue("@Name", criteria.Name);
 | |
| 						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("Folder.DataPortal_Fetch", ex);
 | |
| 				_ErrorMessage = ex.Message;
 | |
| 				throw new DbCslaException("Folder.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("Folder.DataPortal_Insert", ex);
 | |
| 				_ErrorMessage = ex.Message;
 | |
| 				throw new DbCslaException("Folder.DataPortal_Insert", ex);
 | |
| 			}
 | |
| 			finally
 | |
| 			{
 | |
| 				if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Insert", GetHashCode());
 | |
| 			}
 | |
| 		}
 | |
| 		[Transactional(TransactionalTypes.TransactionScope)]
 | |
| 		internal void SQLInsert()
 | |
| 		{
 | |
| 			if (!this.IsDirty) return;
 | |
| 			try
 | |
| 			{
 | |
| 				if (_MyConnection != null) _MyConnection.Update();
 | |
| 				if (_MyFormat != null) _MyFormat.Update();
 | |
| 				SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
 | |
| 				using (SqlCommand cm = cn.CreateCommand())
 | |
| 				{
 | |
| 					cm.CommandType = CommandType.StoredProcedure;
 | |
| 					cm.CommandText = "addFolder";
 | |
| 					// Input All Fields - Except Calculated Columns
 | |
| 					cm.Parameters.AddWithValue("@ParentID", ParentID);
 | |
| 					cm.Parameters.AddWithValue("@DBID", DBID);
 | |
| 					cm.Parameters.AddWithValue("@Name", _Name);
 | |
| 					cm.Parameters.AddWithValue("@Title", _Title);
 | |
| 					cm.Parameters.AddWithValue("@ShortName", _ShortName);
 | |
| 					cm.Parameters.AddWithValue("@FormatID", FormatID);
 | |
| 					cm.Parameters.AddWithValue("@ManualOrder", _ManualOrder);
 | |
| 					cm.Parameters.AddWithValue("@Config", _Config);
 | |
| 					if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
 | |
| 					cm.Parameters.AddWithValue("@UsrID", _UsrID);
 | |
| 					// Output Calculated Columns
 | |
| 					SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int);
 | |
| 					param_FolderID.Direction = ParameterDirection.Output;
 | |
| 					cm.Parameters.Add(param_FolderID);
 | |
| 					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
 | |
| 					_FolderID = (int)cm.Parameters["@newFolderID"].Value;
 | |
| 					_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
 | |
| 				}
 | |
| 				MarkOld();
 | |
| 				// update child objects
 | |
| 				if (_FolderAssignments != null) _FolderAssignments.Update(this);
 | |
| 				if (_FolderDocVersions != null) _FolderDocVersions.Update(this);
 | |
| 				if (_ChildFolders != null) _ChildFolders.Update(this);
 | |
| 				if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.SQLInsert", GetHashCode());
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.SQLInsert", ex);
 | |
| 				_ErrorMessage = ex.Message;
 | |
| 				throw new DbCslaException("Folder.SQLInsert", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		[Transactional(TransactionalTypes.TransactionScope)]
 | |
| 		public static byte[] Add(SqlConnection cn, ref int folderID, Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, double? manualOrder, string config, DateTime dts, string usrID)
 | |
| 		{
 | |
| 			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Add", 0);
 | |
| 			try
 | |
| 			{
 | |
| 				using (SqlCommand cm = cn.CreateCommand())
 | |
| 				{
 | |
| 					cm.CommandType = CommandType.StoredProcedure;
 | |
| 					cm.CommandText = "addFolder";
 | |
| 					// Input All Fields - Except Calculated Columns
 | |
| 					cm.Parameters.AddWithValue("@ParentID", myParent.FolderID);
 | |
| 					cm.Parameters.AddWithValue("@DBID", myConnection.DBID);
 | |
| 					cm.Parameters.AddWithValue("@Name", name);
 | |
| 					cm.Parameters.AddWithValue("@Title", title);
 | |
| 					cm.Parameters.AddWithValue("@ShortName", shortName);
 | |
| 					if (myFormat != null) cm.Parameters.AddWithValue("@FormatID", myFormat.FormatID);
 | |
| 					cm.Parameters.AddWithValue("@ManualOrder", manualOrder);
 | |
| 					cm.Parameters.AddWithValue("@Config", config);
 | |
| 					if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
 | |
| 					cm.Parameters.AddWithValue("@UsrID", usrID);
 | |
| 					// Output Calculated Columns
 | |
| 					SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int);
 | |
| 					param_FolderID.Direction = ParameterDirection.Output;
 | |
| 					cm.Parameters.Add(param_FolderID);
 | |
| 					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
 | |
| 					folderID = (int)cm.Parameters["@newFolderID"].Value;
 | |
| 					return (byte[])cm.Parameters["@newLastChanged"].Value;
 | |
| 				}
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.Add", ex);
 | |
| 				throw new DbCslaException("Folder.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}] Folder.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)
 | |
| 					if(!ex.Message.Contains("Cannot insert duplicate key row in object 'dbo.Folders' with unique index 'IX_UniqueChildFolders'"))
 | |
| 						_MyLog.Error("Folder.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}] Folder.SQLUpdate", GetHashCode());
 | |
| 			try
 | |
| 			{
 | |
| 				if (_MyConnection != null) _MyConnection.Update();
 | |
| 				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 = "updateFolder";
 | |
| 						// All Fields including Calculated Fields
 | |
| 						cm.Parameters.AddWithValue("@FolderID", _FolderID);
 | |
| 						cm.Parameters.AddWithValue("@ParentID", ParentID);
 | |
| 						cm.Parameters.AddWithValue("@DBID", DBID);
 | |
| 						cm.Parameters.AddWithValue("@Name", _Name);
 | |
| 						cm.Parameters.AddWithValue("@Title", _Title);
 | |
| 						cm.Parameters.AddWithValue("@ShortName", _ShortName);
 | |
| 						cm.Parameters.AddWithValue("@FormatID", FormatID);
 | |
| 						cm.Parameters.AddWithValue("@ManualOrder", _ManualOrder);
 | |
| 						cm.Parameters.AddWithValue("@Config", _Config);
 | |
| 						if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
 | |
| 						cm.Parameters.AddWithValue("@UsrID", _UsrID);
 | |
| 						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 (_FolderAssignments != null) _FolderAssignments.Update(this);
 | |
| 				if (_FolderDocVersions != null) _FolderDocVersions.Update(this);
 | |
| 				if (_ChildFolders != null) _ChildFolders.Update(this);
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				if (_MyLog.IsErrorEnabled)
 | |
| 					if(!ex.Message.Contains("Cannot insert duplicate key row in object 'dbo.Folders' with unique index 'IX_UniqueChildFolders'"))
 | |
| 						_MyLog.Error("Folder.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 = Folder.Add(cn, ref _FolderID, _MyParent, _MyConnection, _Name, _Title, _ShortName, _MyFormat, _ManualOrder, _Config, _DTS, _UsrID);
 | |
| 				else
 | |
| 					_LastChanged = Folder.Update(cn, ref _FolderID, _ParentID, _DBID, _Name, _Title, _ShortName, _FormatID, _ManualOrder, _Config, _DTS, _UsrID, ref _LastChanged);
 | |
| 				MarkOld();
 | |
| 			}
 | |
| 			if (_FolderAssignments != null) _FolderAssignments.Update(this);
 | |
| 			if (_FolderDocVersions != null) _FolderDocVersions.Update(this);
 | |
| 			if (_ChildFolders != null) _ChildFolders.Update(this);
 | |
| 		}
 | |
| 		internal void DeleteSelf(Folder folder)
 | |
| 		{
 | |
| 			// if we're not dirty then don't update the database
 | |
| 			if (!this.IsDirty) return;
 | |
| 			// if we're new then don't update the database
 | |
| 			if (this.IsNew) return;
 | |
| 			SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
 | |
| 			Folder.Remove(cn, _FolderID);
 | |
| 			MarkNew();
 | |
| 		}
 | |
| 		[Transactional(TransactionalTypes.TransactionScope)]
 | |
| 		public static byte[] Update(SqlConnection cn, ref int folderID, int parentID, int dbid, string name, string title, string shortName, int? formatID, double? manualOrder, string config, DateTime dts, string usrID, ref byte[] lastChanged)
 | |
| 		{
 | |
| 			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Update", 0);
 | |
| 			try
 | |
| 			{
 | |
| 				using (SqlCommand cm = cn.CreateCommand())
 | |
| 				{
 | |
| 					cm.CommandType = CommandType.StoredProcedure;
 | |
| 					cm.CommandText = "updateFolder";
 | |
| 					// Input All Fields - Except Calculated Columns
 | |
| 					cm.Parameters.AddWithValue("@FolderID", folderID);
 | |
| 					cm.Parameters.AddWithValue("@ParentID", parentID);
 | |
| 					cm.Parameters.AddWithValue("@DBID", dbid);
 | |
| 					cm.Parameters.AddWithValue("@Name", name);
 | |
| 					cm.Parameters.AddWithValue("@Title", title);
 | |
| 					cm.Parameters.AddWithValue("@ShortName", shortName);
 | |
| 					cm.Parameters.AddWithValue("@FormatID", formatID);
 | |
| 					cm.Parameters.AddWithValue("@ManualOrder", manualOrder);
 | |
| 					cm.Parameters.AddWithValue("@Config", config);
 | |
| 					if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
 | |
| 					cm.Parameters.AddWithValue("@UsrID", usrID);
 | |
| 					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("Folder.Update", ex);
 | |
| 				throw new DbCslaException("Folder.Update", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		[Transactional(TransactionalTypes.TransactionScope)]
 | |
| 		protected override void DataPortal_DeleteSelf()
 | |
| 		{
 | |
| 			DataPortal_Delete(new PKCriteria(_FolderID));
 | |
| 		}
 | |
| 		[Transactional(TransactionalTypes.TransactionScope)]
 | |
| 		private void DataPortal_Delete(PKCriteria criteria)
 | |
| 		{
 | |
| 			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Delete", GetHashCode());
 | |
| 			try
 | |
| 			{
 | |
| 				using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | |
| 				{
 | |
| 					using (SqlCommand cm = cn.CreateCommand())
 | |
| 					{
 | |
| 						cm.CommandType = CommandType.StoredProcedure;
 | |
| 						cm.CommandText = "deleteFolder";
 | |
| 						cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
 | |
| 						cm.ExecuteNonQuery();
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Delete", ex);
 | |
| 				_ErrorMessage = ex.Message;
 | |
| 				throw new DbCslaException("Folder.DataPortal_Delete", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		[Transactional(TransactionalTypes.TransactionScope)]
 | |
| 		public static void Remove(SqlConnection cn, int folderID)
 | |
| 		{
 | |
| 			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.Remove", 0);
 | |
| 			try
 | |
| 			{
 | |
| 				using (SqlCommand cm = cn.CreateCommand())
 | |
| 				{
 | |
| 					cm.CommandType = CommandType.StoredProcedure;
 | |
| 					cm.CommandText = "deleteFolder";
 | |
| 					// Input PK Fields
 | |
| 					cm.Parameters.AddWithValue("@FolderID", folderID);
 | |
| 					// CSLATODO: Define any additional output parameters
 | |
| 					cm.ExecuteNonQuery();
 | |
| 				}
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.Remove", ex);
 | |
| 				throw new DbCslaException("Folder.Remove", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		#endregion
 | |
| 		#region Exists
 | |
| 		public static bool Exists(int folderID)
 | |
| 		{
 | |
| 			ExistsCommand result;
 | |
| 			try
 | |
| 			{
 | |
| 				result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(folderID));
 | |
| 				return result.Exists;
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				throw new DbCslaException("Error on Folder.Exists", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		[Serializable()]
 | |
| 		private class ExistsCommand : CommandBase
 | |
| 		{
 | |
| 			private int _FolderID;
 | |
| 			private bool _exists;
 | |
| 			public bool Exists
 | |
| 			{
 | |
| 				get { return _exists; }
 | |
| 			}
 | |
| 			public ExistsCommand(int folderID)
 | |
| 			{
 | |
| 				_FolderID = folderID;
 | |
| 			}
 | |
| 			protected override void DataPortal_Execute()
 | |
| 			{
 | |
| 				if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Folder.DataPortal_Execute", GetHashCode());
 | |
| 				try
 | |
| 				{
 | |
| 					using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | |
| 					{
 | |
| 						cn.Open();
 | |
| 						using (SqlCommand cm = cn.CreateCommand())
 | |
| 						{
 | |
| 							cm.CommandType = CommandType.StoredProcedure;
 | |
| 							cm.CommandText = "existsFolder";
 | |
| 							cm.Parameters.AddWithValue("@FolderID", _FolderID);
 | |
| 							int count = (int)cm.ExecuteScalar();
 | |
| 							_exists = (count > 0);
 | |
| 						}
 | |
| 					}
 | |
| 				}
 | |
| 				catch (Exception ex)
 | |
| 				{
 | |
| 					if (_MyLog.IsErrorEnabled) _MyLog.Error("Folder.DataPortal_Execute", ex);
 | |
| 					throw new DbCslaException("Folder.DataPortal_Execute", ex);
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		#endregion
 | |
| 		// Standard Default Code
 | |
| 		#region extension
 | |
| 		FolderExtension _FolderExtension = new FolderExtension();
 | |
| 		[Serializable()]
 | |
| 		partial class FolderExtension : extensionBase
 | |
| 		{
 | |
| 		}
 | |
| 		[Serializable()]
 | |
| 		class extensionBase
 | |
| 		{
 | |
| 			// Default Values
 | |
| 			public virtual int DefaultParentID
 | |
| 			{
 | |
| 				get { return 1; }
 | |
| 			}
 | |
| 			public virtual int DefaultDBID
 | |
| 			{
 | |
| 				get { return 1; }
 | |
| 			}
 | |
| 			public virtual DateTime DefaultDTS
 | |
| 			{
 | |
| 				get { return DateTime.Now; }
 | |
| 			}
 | |
| 			public virtual string DefaultUsrID
 | |
| 			{
 | |
| 				get { return Volian.Base.Library.VlnSettings.UserID; }
 | |
| 			}
 | |
| 			// 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 FolderConverter : ExpandableObjectConverter
 | |
| 	{
 | |
| 		public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
 | |
| 		{
 | |
| 			if (destType == typeof(string) && value is Folder)
 | |
| 			{
 | |
| 				// Return the ToString value
 | |
| 				return ((Folder)value).ToString();
 | |
| 			}
 | |
| 			return base.ConvertTo(context, culture, value, destType);
 | |
| 		}
 | |
| 	}
 | |
| 	#endregion
 | |
| } // Namespace
 | |
| 
 | |
| 
 | |
| //// The following is a sample Extension File.  You can use it to create FolderExt.cs
 | |
| //using System;
 | |
| //using System.Collections.Generic;
 | |
| //using System.Text;
 | |
| //using Csla;
 | |
| 
 | |
| //namespace VEPROMS.CSLA.Library
 | |
| //{
 | |
| //  public partial class Folder
 | |
| //  {
 | |
| //    partial class FolderExtension : extensionBase
 | |
| //    {
 | |
| //      // CSLATODO: Override automatic defaults
 | |
| //      public virtual int DefaultParentID
 | |
| //      {
 | |
| //        get { return 1; }
 | |
| //      }
 | |
| //      public virtual int DefaultDBID
 | |
| //      {
 | |
| //        get { return 1; }
 | |
| //      }
 | |
| //      public virtual DateTime DefaultDTS
 | |
| //      {
 | |
| //        get { return DateTime.Now; }
 | |
| //      }
 | |
| //      public virtual string DefaultUsrID
 | |
| //      {
 | |
| //        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 */);
 | |
| //      }
 | |
| //    }
 | |
| //  }
 | |
| //}
 | 
