Change Manager

This commit is contained in:
Rich 2011-08-01 20:18:58 +00:00
parent 14e3e15537
commit 1d910db31a
24 changed files with 12693 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,394 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void AnnotationAuditInfoEvent(object sender);
/// <summary>
/// AnnotationAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationAuditInfoConverter))]
public partial class AnnotationAuditInfo : ReadOnlyBase<AnnotationAuditInfo>, IDisposable
{
public event AnnotationAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<AnnotationAuditInfo> _CacheList = new List<AnnotationAuditInfo>();
protected static void AddToCache(AnnotationAuditInfo annotationAuditInfo)
{
if (!_CacheList.Contains(annotationAuditInfo)) _CacheList.Add(annotationAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(AnnotationAuditInfo annotationAuditInfo)
{
while (_CacheList.Contains(annotationAuditInfo)) _CacheList.Remove(annotationAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AnnotationAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move AnnotationAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
AnnotationAuditInfo tmp = _CacheList[0]; // Get the first AnnotationAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<AnnotationAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first AnnotationAuditInfo
}
}
internal static void AddList(AnnotationAuditInfoList lst)
{
foreach (AnnotationAuditInfo item in lst) AddToCache(item);
}
protected static AnnotationAuditInfo 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; }
}
protected AnnotationAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _AnnotationID;
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationID", true);
return _AnnotationID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID", true);
return _TypeID;
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText", true);
return _RtfText;
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText", true);
return _SearchText;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base AnnotationAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check AnnotationAuditInfo.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 AnnotationAuditInfo</returns>
protected override object GetIdValue()
{
return MyAnnotationAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _AnnotationAuditInfoUnique = 0;
private static int AnnotationAuditInfoUnique
{ get { return ++_AnnotationAuditInfoUnique; } }
private int _MyAnnotationAuditInfoUnique = AnnotationAuditInfoUnique;
public int MyAnnotationAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyAnnotationAuditInfoUnique; } }
protected AnnotationAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<AnnotationAuditInfo> listAnnotationAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listAnnotationAuditInfo.Contains(this)) listAnnotationAuditInfo.Remove(this); // Remove the item from the list
if (listAnnotationAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual AnnotationAudit Get()
{
return _Editable = AnnotationAudit.Get(_AuditID);
}
public static void Refresh(AnnotationAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(AnnotationAudit tmp)
{
_AnnotationID = tmp.AnnotationID;
_ItemID = tmp.ItemID;
_TypeID = tmp.TypeID;
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_AnnotationAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static AnnotationAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a AnnotationAudit");
try
{
AnnotationAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.Constructor", ex);
throw new DbCslaException("AnnotationAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_AnnotationID = dr.GetInt32("AnnotationID");
_ItemID = dr.GetInt32("ItemID");
_TypeID = dr.GetInt32("TypeID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.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 = "getAnnotationAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("AnnotationAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationAuditInfoExtension _AnnotationAuditInfoExtension = new AnnotationAuditInfoExtension();
[Serializable()]
partial class AnnotationAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationAuditInfo)
{
// Return the ToString value
return ((AnnotationAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// AnnotationAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationAuditInfoListConverter))]
public partial class AnnotationAuditInfoList : ReadOnlyListBase<AnnotationAuditInfoList, AnnotationAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<AnnotationAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (AnnotationAuditInfo tmp in this)
{
tmp.Changed += new AnnotationAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
public void Dispose()
{
foreach (AnnotationAuditInfo tmp in this)
{
tmp.Changed -= new AnnotationAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static AnnotationAuditInfoList _AnnotationAuditInfoList = null;
/// <summary>
/// Return a list of all AnnotationAuditInfo.
/// </summary>
public static AnnotationAuditInfoList Get()
{
try
{
if (_AnnotationAuditInfoList != null)
return _AnnotationAuditInfoList;
AnnotationAuditInfoList tmp = DataPortal.Fetch<AnnotationAuditInfoList>();
AnnotationAuditInfo.AddList(tmp);
tmp.AddEvents();
_AnnotationAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all AnnotationAuditInfo.
/// </summary>
public static void Reset()
{
_AnnotationAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static AnnotationAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<AnnotationAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
// }
//}
private AnnotationAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new AnnotationAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AnnotationAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
AnnotationAuditInfoListPropertyDescriptor pd = new AnnotationAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class AnnotationAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private AnnotationAuditInfo Item { get { return (AnnotationAuditInfo)_Item; } }
public AnnotationAuditInfoListPropertyDescriptor(AnnotationAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class AnnotationAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationAuditInfoList)
{
// Return department and department role separated by comma.
return ((AnnotationAuditInfoList)value).Items.Count.ToString() + " AnnotationAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,394 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ContentAuditInfoEvent(object sender);
/// <summary>
/// ContentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentAuditInfoConverter))]
public partial class ContentAuditInfo : ReadOnlyBase<ContentAuditInfo>, IDisposable
{
public event ContentAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<ContentAuditInfo> _CacheList = new List<ContentAuditInfo>();
protected static void AddToCache(ContentAuditInfo contentAuditInfo)
{
if (!_CacheList.Contains(contentAuditInfo)) _CacheList.Add(contentAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(ContentAuditInfo contentAuditInfo)
{
while (_CacheList.Contains(contentAuditInfo)) _CacheList.Remove(contentAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ContentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move ContentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
ContentAuditInfo tmp = _CacheList[0]; // Get the first ContentAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<ContentAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ContentAuditInfo
}
}
internal static void AddList(ContentAuditInfoList lst)
{
foreach (ContentAuditInfo item in lst) AddToCache(item);
}
protected static ContentAuditInfo 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; }
}
protected ContentAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Number", true);
return _Number;
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text", true);
return _Text;
}
}
private int? _Type;
public int? Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Type", true);
return _Type;
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID", true);
return _FormatID;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base ContentAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ContentAuditInfo.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 ContentAuditInfo</returns>
protected override object GetIdValue()
{
return MyContentAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _ContentAuditInfoUnique = 0;
private static int ContentAuditInfoUnique
{ get { return ++_ContentAuditInfoUnique; } }
private int _MyContentAuditInfoUnique = ContentAuditInfoUnique;
public int MyContentAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyContentAuditInfoUnique; } }
protected ContentAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<ContentAuditInfo> listContentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listContentAuditInfo.Contains(this)) listContentAuditInfo.Remove(this); // Remove the item from the list
if (listContentAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual ContentAudit Get()
{
return _Editable = ContentAudit.Get(_AuditID);
}
public static void Refresh(ContentAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ContentAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentAudit tmp)
{
_ContentID = tmp.ContentID;
_Number = tmp.Number;
_Text = tmp.Text;
_Type = tmp.Type;
_FormatID = tmp.FormatID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_ContentAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static ContentAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ContentAudit");
try
{
ContentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ContentAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ContentAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ContentAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.Constructor", ex);
throw new DbCslaException("ContentAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_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");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ContentAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.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 = "getContentAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("ContentAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ContentAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ContentAuditInfoExtension _ContentAuditInfoExtension = new ContentAuditInfoExtension();
[Serializable()]
partial class ContentAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ContentAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ContentAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentAuditInfo)
{
// Return the ToString value
return ((ContentAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentAuditInfoListConverter))]
public partial class ContentAuditInfoList : ReadOnlyListBase<ContentAuditInfoList, ContentAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<ContentAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (ContentAuditInfo tmp in this)
{
tmp.Changed += new ContentAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
public void Dispose()
{
foreach (ContentAuditInfo tmp in this)
{
tmp.Changed -= new ContentAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static ContentAuditInfoList _ContentAuditInfoList = null;
/// <summary>
/// Return a list of all ContentAuditInfo.
/// </summary>
public static ContentAuditInfoList Get()
{
try
{
if (_ContentAuditInfoList != null)
return _ContentAuditInfoList;
ContentAuditInfoList tmp = DataPortal.Fetch<ContentAuditInfoList>();
ContentAuditInfo.AddList(tmp);
tmp.AddEvents();
_ContentAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all ContentAuditInfo.
/// </summary>
public static void Reset()
{
_ContentAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static ContentAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<ContentAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on ContentAuditInfoList.Get", ex);
// }
//}
private ContentAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getContentAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ContentAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ContentAuditInfoListPropertyDescriptor pd = new ContentAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ContentAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private ContentAuditInfo Item { get { return (ContentAuditInfo)_Item; } }
public ContentAuditInfoListPropertyDescriptor(ContentAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ContentAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentAuditInfoList)
{
// Return department and department role separated by comma.
return ((ContentAuditInfoList)value).Items.Count.ToString() + " ContentAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,406 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void DocumentAuditInfoEvent(object sender);
/// <summary>
/// DocumentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentAuditInfoConverter))]
public partial class DocumentAuditInfo : ReadOnlyBase<DocumentAuditInfo>, IDisposable
{
public event DocumentAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<DocumentAuditInfo> _CacheList = new List<DocumentAuditInfo>();
protected static void AddToCache(DocumentAuditInfo documentAuditInfo)
{
if (!_CacheList.Contains(documentAuditInfo)) _CacheList.Add(documentAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(DocumentAuditInfo documentAuditInfo)
{
while (_CacheList.Contains(documentAuditInfo)) _CacheList.Remove(documentAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<DocumentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move DocumentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
DocumentAuditInfo tmp = _CacheList[0]; // Get the first DocumentAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<DocumentAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first DocumentAuditInfo
}
}
internal static void AddList(DocumentAuditInfoList lst)
{
foreach (DocumentAuditInfo item in lst) AddToCache(item);
}
protected static DocumentAuditInfo 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; }
}
protected DocumentAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _DocID;
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID", true);
return _DocID;
}
}
private string _LibTitle = string.Empty;
public string LibTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("LibTitle", true);
return _LibTitle;
}
}
private byte[] _DocContent;
public byte[] DocContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocContent", true);
return _DocContent;
}
}
private string _DocAscii = string.Empty;
public string DocAscii
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocAscii", true);
return _DocAscii;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private string _FileExtension = string.Empty;
public string FileExtension
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FileExtension", true);
return _FileExtension;
}
}
private byte[] _DocPdf;
public byte[] DocPdf
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocPdf", true);
return _DocPdf;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base DocumentAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check DocumentAuditInfo.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 DocumentAuditInfo</returns>
protected override object GetIdValue()
{
return MyDocumentAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _DocumentAuditInfoUnique = 0;
private static int DocumentAuditInfoUnique
{ get { return ++_DocumentAuditInfoUnique; } }
private int _MyDocumentAuditInfoUnique = DocumentAuditInfoUnique;
public int MyDocumentAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyDocumentAuditInfoUnique; } }
protected DocumentAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<DocumentAuditInfo> listDocumentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listDocumentAuditInfo.Contains(this)) listDocumentAuditInfo.Remove(this); // Remove the item from the list
if (listDocumentAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual DocumentAudit Get()
{
return _Editable = DocumentAudit.Get(_AuditID);
}
public static void Refresh(DocumentAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocumentAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(DocumentAudit tmp)
{
_DocID = tmp.DocID;
_LibTitle = tmp.LibTitle;
_DocContent = tmp.DocContent;
_DocAscii = tmp.DocAscii;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_FileExtension = tmp.FileExtension;
_DocPdf = tmp.DocPdf;
_DeleteStatus = tmp.DeleteStatus;
_DocumentAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static DocumentAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a DocumentAudit");
try
{
DocumentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocumentAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up DocumentAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DocumentAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.Constructor", ex);
throw new DbCslaException("DocumentAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_DocID = dr.GetInt32("DocID");
_LibTitle = dr.GetString("LibTitle");
_DocContent = (byte[])dr.GetValue("DocContent");
_DocAscii = dr.GetString("DocAscii");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_FileExtension = dr.GetString("FileExtension");
_DocPdf = (byte[])dr.GetValue("DocPdf");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.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 = "getDocumentAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("DocumentAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DocumentAuditInfoExtension _DocumentAuditInfoExtension = new DocumentAuditInfoExtension();
[Serializable()]
partial class DocumentAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DocumentAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DocumentAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentAuditInfo)
{
// Return the ToString value
return ((DocumentAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// DocumentAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentAuditInfoListConverter))]
public partial class DocumentAuditInfoList : ReadOnlyListBase<DocumentAuditInfoList, DocumentAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<DocumentAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (DocumentAuditInfo tmp in this)
{
tmp.Changed += new DocumentAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
public void Dispose()
{
foreach (DocumentAuditInfo tmp in this)
{
tmp.Changed -= new DocumentAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static DocumentAuditInfoList _DocumentAuditInfoList = null;
/// <summary>
/// Return a list of all DocumentAuditInfo.
/// </summary>
public static DocumentAuditInfoList Get()
{
try
{
if (_DocumentAuditInfoList != null)
return _DocumentAuditInfoList;
DocumentAuditInfoList tmp = DataPortal.Fetch<DocumentAuditInfoList>();
DocumentAuditInfo.AddList(tmp);
tmp.AddEvents();
_DocumentAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all DocumentAuditInfo.
/// </summary>
public static void Reset()
{
_DocumentAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static DocumentAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<DocumentAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on DocumentAuditInfoList.Get", ex);
// }
//}
private DocumentAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocumentAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new DocumentAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DocumentAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
DocumentAuditInfoListPropertyDescriptor pd = new DocumentAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class DocumentAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private DocumentAuditInfo Item { get { return (DocumentAuditInfo)_Item; } }
public DocumentAuditInfoListPropertyDescriptor(DocumentAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class DocumentAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentAuditInfoList)
{
// Return department and department role separated by comma.
return ((DocumentAuditInfoList)value).Items.Count.ToString() + " DocumentAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,902 @@
// ========================================================================
// 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>
/// EntryAudit Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(EntryAuditConverter))]
public partial class EntryAudit : BusinessBase<EntryAudit>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<EntryAudit> _RefreshEntryAudits = new List<EntryAudit>();
private void AddToRefreshList(List<EntryAudit> refreshEntryAudits)
{
if (IsDirty)
refreshEntryAudits.Add(this);
}
private void BuildRefreshList()
{
_RefreshEntryAudits = new List<EntryAudit>();
AddToRefreshList(_RefreshEntryAudits);
}
private void ProcessRefreshList()
{
foreach (EntryAudit tmp in _RefreshEntryAudits)
{
EntryAuditInfo.Refresh(tmp);
}
}
#endregion
#region Collection
private static List<EntryAudit> _CacheList = new List<EntryAudit>();
protected static void AddToCache(EntryAudit entryAudit)
{
if (!_CacheList.Contains(entryAudit)) _CacheList.Add(entryAudit); // In AddToCache
}
protected static void RemoveFromCache(EntryAudit entryAudit)
{
while (_CacheList.Contains(entryAudit)) _CacheList.Remove(entryAudit); // In RemoveFromCache
}
private static Dictionary<string, List<EntryAudit>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAudit>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move EntryAudit(s) from temporary _CacheList to _CacheByPrimaryKey
{
EntryAudit tmp = _CacheList[0]; // Get the first EntryAudit
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<EntryAudit>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first EntryAudit
}
}
protected static EntryAudit 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
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ContentID", true);
if (_ContentID != value)
{
_ContentID = value;
PropertyHasChanged();
}
}
}
private int _DocID;
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID", true);
return _DocID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DocID", true);
if (_DocID != value)
{
_DocID = 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 int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DeleteStatus", true);
if (_DeleteStatus != value)
{
_DeleteStatus = value;
PropertyHasChanged();
}
}
}
public override bool IsDirty
{
get { return base.IsDirty; }
}
public bool IsDirtyList(List<object> list)
{
return base.IsDirty;
}
public override bool IsValid
{
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
}
public bool IsValidList(List<object> list)
{
return (IsNew && !IsDirty) ? true : base.IsValid;
}
// CSLATODO: Replace base EntryAudit.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current EntryAudit</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check EntryAudit.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 EntryAudit</returns>
protected override object GetIdValue()
{
return MyEntryAuditUnique; // 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;
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.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 200));
//ValidationRules.AddDependantProperty("x", "y");
_EntryAuditExtension.AddValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_EntryAuditExtension.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(AuditID, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(DocID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(DeleteStatus, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DocID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
_EntryAuditExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
_EntryAuditExtension.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;
}
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 _EntryAuditUnique = 0;
protected static int EntryAuditUnique
{ get { return ++_EntryAuditUnique; } }
private int _MyEntryAuditUnique = EntryAuditUnique;
public int MyEntryAuditUnique // Absolutely Unique ID - Editable
{ get { return _MyEntryAuditUnique; } }
protected EntryAudit()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(AuditID.ToString()))
{
List<EntryAudit> listEntryAudit = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listEntryAudit.Contains(this)) listEntryAudit.Remove(this); // Remove the item from the list
if (listEntryAudit.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
}
public static EntryAudit New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a EntryAudit");
try
{
return DataPortal.Create<EntryAudit>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryAudit.New", ex);
}
}
public static EntryAudit New(int contentID, int docID, DateTime dts, string userID, int deleteStatus)
{
EntryAudit tmp = EntryAudit.New();
tmp.ContentID = contentID;
tmp.DocID = docID;
tmp.DTS = dts;
tmp.UserID = userID;
tmp.DeleteStatus = deleteStatus;
return tmp;
}
public static EntryAudit MakeEntryAudit(int contentID, int docID, DateTime dts, string userID, int deleteStatus)
{
EntryAudit tmp = EntryAudit.New(contentID, docID, dts, userID, deleteStatus);
if (tmp.IsSavable)
{
EntryAudit 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 EntryAudit Get(long auditID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a EntryAudit");
try
{
EntryAudit tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<EntryAudit>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up EntryAudit
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryAudit.Get", ex);
}
}
public static EntryAudit Get(SafeDataReader dr)
{
if (dr.Read()) return new EntryAudit(dr);
return null;
}
internal EntryAudit(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(long auditID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a EntryAudit");
try
{
DataPortal.Delete(new PKCriteria(auditID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryAudit.Delete", ex);
}
}
public override EntryAudit Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a EntryAudit");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a EntryAudit");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a EntryAudit");
try
{
BuildRefreshList();
EntryAudit entryAudit = base.Save();
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(entryAudit);//Refresh the item in AllList
ProcessRefreshList();
return entryAudit;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
_AuditID = NextAuditID;
// Database Defaults
// CSLATODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ContentID = dr.GetInt32("ContentID");
_DocID = dr.GetInt32("DocID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
MarkOld();
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.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 = "getEntryAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("EntryAudit.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.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("EntryAudit.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.DataPortal_Insert", ex);
}
finally
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addEntryAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@DocID", _DocID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
// Output Calculated Columns
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
param_AuditID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AuditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_AuditID = (long)cm.Parameters["@newAuditID"].Value;
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Add(SqlConnection cn, ref long auditID, int contentID, int docID, DateTime dts, string userID, int deleteStatus)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addEntryAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@DocID", docID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
// Output Calculated Columns
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
param_AuditID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AuditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
auditID = (long)cm.Parameters["@newAuditID"].Value;
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.Add", ex);
throw new DbCslaException("EntryAudit.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}] EntryAudit.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("EntryAudit.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}] EntryAudit.SQLUpdate", GetHashCode());
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateEntryAudit";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@AuditID", _AuditID);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@DocID", _DocID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
}
}
MarkOld();
// use the open connection to update child objects
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.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)
EntryAudit.Add(cn, ref _AuditID, _ContentID, _DocID, _DTS, _UserID, _DeleteStatus);
else
EntryAudit.Update(cn, ref _AuditID, _ContentID, _DocID, _DTS, _UserID, _DeleteStatus);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Update(SqlConnection cn, ref long auditID, int contentID, int docID, DateTime dts, string userID, int deleteStatus)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateEntryAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@AuditID", auditID);
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@DocID", docID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.Update", ex);
throw new DbCslaException("EntryAudit.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_AuditID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteEntryAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, long auditID)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteEntryAudit";
// Input PK Fields
cm.Parameters.AddWithValue("@AuditID", auditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.Remove", ex);
throw new DbCslaException("EntryAudit.Remove", ex);
}
}
#endregion
// Standard Default Code
#region extension
EntryAuditExtension _EntryAuditExtension = new EntryAuditExtension();
[Serializable()]
partial class EntryAuditExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
// 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 EntryAuditConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is EntryAudit)
{
// Return the ToString value
return ((EntryAudit)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create EntryAuditExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class EntryAudit
// {
// partial class EntryAuditExtension : extensionBase
// {
// // CSLATODO: Override automatic defaults
// 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 */);
// }
// }
// }
//}

View File

@ -0,0 +1,346 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void EntryAuditInfoEvent(object sender);
/// <summary>
/// EntryAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(EntryAuditInfoConverter))]
public partial class EntryAuditInfo : ReadOnlyBase<EntryAuditInfo>, IDisposable
{
public event EntryAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<EntryAuditInfo> _CacheList = new List<EntryAuditInfo>();
protected static void AddToCache(EntryAuditInfo entryAuditInfo)
{
if (!_CacheList.Contains(entryAuditInfo)) _CacheList.Add(entryAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(EntryAuditInfo entryAuditInfo)
{
while (_CacheList.Contains(entryAuditInfo)) _CacheList.Remove(entryAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<EntryAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move EntryAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
EntryAuditInfo tmp = _CacheList[0]; // Get the first EntryAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<EntryAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first EntryAuditInfo
}
}
internal static void AddList(EntryAuditInfoList lst)
{
foreach (EntryAuditInfo item in lst) AddToCache(item);
}
protected static EntryAuditInfo 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; }
}
protected EntryAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
}
private int _DocID;
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID", true);
return _DocID;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base EntryAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current EntryAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check EntryAuditInfo.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 EntryAuditInfo</returns>
protected override object GetIdValue()
{
return MyEntryAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _EntryAuditInfoUnique = 0;
private static int EntryAuditInfoUnique
{ get { return ++_EntryAuditInfoUnique; } }
private int _MyEntryAuditInfoUnique = EntryAuditInfoUnique;
public int MyEntryAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyEntryAuditInfoUnique; } }
protected EntryAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<EntryAuditInfo> listEntryAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listEntryAuditInfo.Contains(this)) listEntryAuditInfo.Remove(this); // Remove the item from the list
if (listEntryAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual EntryAudit Get()
{
return _Editable = EntryAudit.Get(_AuditID);
}
public static void Refresh(EntryAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (EntryAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(EntryAudit tmp)
{
_ContentID = tmp.ContentID;
_DocID = tmp.DocID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_EntryAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static EntryAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a EntryAudit");
try
{
EntryAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<EntryAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up EntryAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal EntryAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfo.Constructor", ex);
throw new DbCslaException("EntryAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ContentID = dr.GetInt32("ContentID");
_DocID = dr.GetInt32("DocID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.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 = "getEntryAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("EntryAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
EntryAuditInfoExtension _EntryAuditInfoExtension = new EntryAuditInfoExtension();
[Serializable()]
partial class EntryAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(EntryAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class EntryAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is EntryAuditInfo)
{
// Return the ToString value
return ((EntryAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// EntryAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(EntryAuditInfoListConverter))]
public partial class EntryAuditInfoList : ReadOnlyListBase<EntryAuditInfoList, EntryAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<EntryAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (EntryAuditInfo tmp in this)
{
tmp.Changed += new EntryAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
public void Dispose()
{
foreach (EntryAuditInfo tmp in this)
{
tmp.Changed -= new EntryAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static EntryAuditInfoList _EntryAuditInfoList = null;
/// <summary>
/// Return a list of all EntryAuditInfo.
/// </summary>
public static EntryAuditInfoList Get()
{
try
{
if (_EntryAuditInfoList != null)
return _EntryAuditInfoList;
EntryAuditInfoList tmp = DataPortal.Fetch<EntryAuditInfoList>();
EntryAuditInfo.AddList(tmp);
tmp.AddEvents();
_EntryAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all EntryAuditInfo.
/// </summary>
public static void Reset()
{
_EntryAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static EntryAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<EntryAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on EntryAuditInfoList.Get", ex);
// }
//}
private EntryAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getEntryAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new EntryAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("EntryAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
EntryAuditInfoListPropertyDescriptor pd = new EntryAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class EntryAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private EntryAuditInfo Item { get { return (EntryAuditInfo)_Item; } }
public EntryAuditInfoListPropertyDescriptor(EntryAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class EntryAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is EntryAuditInfoList)
{
// Return department and department role separated by comma.
return ((EntryAuditInfoList)value).Items.Count.ToString() + " EntryAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,370 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void GridAuditInfoEvent(object sender);
/// <summary>
/// GridAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GridAuditInfoConverter))]
public partial class GridAuditInfo : ReadOnlyBase<GridAuditInfo>, IDisposable
{
public event GridAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<GridAuditInfo> _CacheList = new List<GridAuditInfo>();
protected static void AddToCache(GridAuditInfo gridAuditInfo)
{
if (!_CacheList.Contains(gridAuditInfo)) _CacheList.Add(gridAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(GridAuditInfo gridAuditInfo)
{
while (_CacheList.Contains(gridAuditInfo)) _CacheList.Remove(gridAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<GridAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move GridAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
GridAuditInfo tmp = _CacheList[0]; // Get the first GridAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<GridAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first GridAuditInfo
}
}
internal static void AddList(GridAuditInfoList lst)
{
foreach (GridAuditInfo item in lst) AddToCache(item);
}
protected static GridAuditInfo 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; }
}
protected GridAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
}
private string _Data = string.Empty;
public string Data
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Data", true);
return _Data;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
private long _ContentAuditID;
public long ContentAuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentAuditID", true);
return _ContentAuditID;
}
}
// CSLATODO: Replace base GridAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GridAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check GridAuditInfo.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 GridAuditInfo</returns>
protected override object GetIdValue()
{
return MyGridAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _GridAuditInfoUnique = 0;
private static int GridAuditInfoUnique
{ get { return ++_GridAuditInfoUnique; } }
private int _MyGridAuditInfoUnique = GridAuditInfoUnique;
public int MyGridAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyGridAuditInfoUnique; } }
protected GridAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<GridAuditInfo> listGridAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listGridAuditInfo.Contains(this)) listGridAuditInfo.Remove(this); // Remove the item from the list
if (listGridAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual GridAudit Get()
{
return _Editable = GridAudit.Get(_AuditID);
}
public static void Refresh(GridAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (GridAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(GridAudit tmp)
{
_ContentID = tmp.ContentID;
_Data = tmp.Data;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_ContentAuditID = tmp.ContentAuditID;
_GridAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static GridAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a GridAudit");
try
{
GridAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<GridAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up GridAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on GridAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal GridAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfo.Constructor", ex);
throw new DbCslaException("GridAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ContentID = dr.GetInt32("ContentID");
_Data = dr.GetString("Data");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
_ContentAuditID = dr.GetInt64("ContentAuditID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("GridAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.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 = "getGridAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("GridAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("GridAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
GridAuditInfoExtension _GridAuditInfoExtension = new GridAuditInfoExtension();
[Serializable()]
partial class GridAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(GridAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class GridAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GridAuditInfo)
{
// Return the ToString value
return ((GridAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// GridAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GridAuditInfoListConverter))]
public partial class GridAuditInfoList : ReadOnlyListBase<GridAuditInfoList, GridAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<GridAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (GridAuditInfo tmp in this)
{
tmp.Changed += new GridAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
public void Dispose()
{
foreach (GridAuditInfo tmp in this)
{
tmp.Changed -= new GridAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static GridAuditInfoList _GridAuditInfoList = null;
/// <summary>
/// Return a list of all GridAuditInfo.
/// </summary>
public static GridAuditInfoList Get()
{
try
{
if (_GridAuditInfoList != null)
return _GridAuditInfoList;
GridAuditInfoList tmp = DataPortal.Fetch<GridAuditInfoList>();
GridAuditInfo.AddList(tmp);
tmp.AddEvents();
_GridAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on GridAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all GridAuditInfo.
/// </summary>
public static void Reset()
{
_GridAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static GridAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<GridAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on GridAuditInfoList.Get", ex);
// }
//}
private GridAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getGridAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new GridAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("GridAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
GridAuditInfoListPropertyDescriptor pd = new GridAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class GridAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private GridAuditInfo Item { get { return (GridAuditInfo)_Item; } }
public GridAuditInfoListPropertyDescriptor(GridAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class GridAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GridAuditInfoList)
{
// Return department and department role separated by comma.
return ((GridAuditInfoList)value).Items.Count.ToString() + " GridAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,382 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ImageAuditInfoEvent(object sender);
/// <summary>
/// ImageAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ImageAuditInfoConverter))]
public partial class ImageAuditInfo : ReadOnlyBase<ImageAuditInfo>, IDisposable
{
public event ImageAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<ImageAuditInfo> _CacheList = new List<ImageAuditInfo>();
protected static void AddToCache(ImageAuditInfo imageAuditInfo)
{
if (!_CacheList.Contains(imageAuditInfo)) _CacheList.Add(imageAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(ImageAuditInfo imageAuditInfo)
{
while (_CacheList.Contains(imageAuditInfo)) _CacheList.Remove(imageAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ImageAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ImageAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move ImageAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
ImageAuditInfo tmp = _CacheList[0]; // Get the first ImageAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<ImageAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ImageAuditInfo
}
}
internal static void AddList(ImageAuditInfoList lst)
{
foreach (ImageAuditInfo item in lst) AddToCache(item);
}
protected static ImageAuditInfo 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; }
}
protected ImageAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
}
private int _ImageType;
public int ImageType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ImageType", true);
return _ImageType;
}
}
private string _FileName = string.Empty;
public string FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FileName", true);
return _FileName;
}
}
private byte[] _Data;
public byte[] Data
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Data", true);
return _Data;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base ImageAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ImageAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ImageAuditInfo.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 ImageAuditInfo</returns>
protected override object GetIdValue()
{
return MyImageAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _ImageAuditInfoUnique = 0;
private static int ImageAuditInfoUnique
{ get { return ++_ImageAuditInfoUnique; } }
private int _MyImageAuditInfoUnique = ImageAuditInfoUnique;
public int MyImageAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyImageAuditInfoUnique; } }
protected ImageAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<ImageAuditInfo> listImageAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listImageAuditInfo.Contains(this)) listImageAuditInfo.Remove(this); // Remove the item from the list
if (listImageAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual ImageAudit Get()
{
return _Editable = ImageAudit.Get(_AuditID);
}
public static void Refresh(ImageAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ImageAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ImageAudit tmp)
{
_ContentID = tmp.ContentID;
_ImageType = tmp.ImageType;
_FileName = tmp.FileName;
_Data = tmp.Data;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_ImageAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static ImageAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ImageAudit");
try
{
ImageAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ImageAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ImageAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ImageAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ImageAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfo.Constructor", ex);
throw new DbCslaException("ImageAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ContentID = dr.GetInt32("ContentID");
_ImageType = dr.GetInt32("ImageType");
_FileName = dr.GetString("FileName");
_Data = (byte[])dr.GetValue("Data");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ImageAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.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 = "getImageAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("ImageAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ImageAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ImageAuditInfoExtension _ImageAuditInfoExtension = new ImageAuditInfoExtension();
[Serializable()]
partial class ImageAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ImageAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ImageAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ImageAuditInfo)
{
// Return the ToString value
return ((ImageAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ImageAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ImageAuditInfoListConverter))]
public partial class ImageAuditInfoList : ReadOnlyListBase<ImageAuditInfoList, ImageAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<ImageAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (ImageAuditInfo tmp in this)
{
tmp.Changed += new ImageAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
public void Dispose()
{
foreach (ImageAuditInfo tmp in this)
{
tmp.Changed -= new ImageAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static ImageAuditInfoList _ImageAuditInfoList = null;
/// <summary>
/// Return a list of all ImageAuditInfo.
/// </summary>
public static ImageAuditInfoList Get()
{
try
{
if (_ImageAuditInfoList != null)
return _ImageAuditInfoList;
ImageAuditInfoList tmp = DataPortal.Fetch<ImageAuditInfoList>();
ImageAuditInfo.AddList(tmp);
tmp.AddEvents();
_ImageAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ImageAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all ImageAuditInfo.
/// </summary>
public static void Reset()
{
_ImageAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static ImageAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<ImageAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on ImageAuditInfoList.Get", ex);
// }
//}
private ImageAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getImageAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ImageAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ImageAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ImageAuditInfoListPropertyDescriptor pd = new ImageAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ImageAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private ImageAuditInfo Item { get { return (ImageAuditInfo)_Item; } }
public ImageAuditInfoListPropertyDescriptor(ImageAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ImageAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ImageAuditInfoList)
{
// Return department and department role separated by comma.
return ((ImageAuditInfoList)value).Items.Count.ToString() + " ImageAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,940 @@
// ========================================================================
// 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>
/// ItemAudit Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemAuditConverter))]
public partial class ItemAudit : BusinessBase<ItemAudit>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<ItemAudit> _RefreshItemAudits = new List<ItemAudit>();
private void AddToRefreshList(List<ItemAudit> refreshItemAudits)
{
if (IsDirty)
refreshItemAudits.Add(this);
}
private void BuildRefreshList()
{
_RefreshItemAudits = new List<ItemAudit>();
AddToRefreshList(_RefreshItemAudits);
}
private void ProcessRefreshList()
{
foreach (ItemAudit tmp in _RefreshItemAudits)
{
ItemAuditInfo.Refresh(tmp);
}
}
#endregion
#region Collection
private static List<ItemAudit> _CacheList = new List<ItemAudit>();
protected static void AddToCache(ItemAudit itemAudit)
{
if (!_CacheList.Contains(itemAudit)) _CacheList.Add(itemAudit); // In AddToCache
}
protected static void RemoveFromCache(ItemAudit itemAudit)
{
while (_CacheList.Contains(itemAudit)) _CacheList.Remove(itemAudit); // In RemoveFromCache
}
private static Dictionary<string, List<ItemAudit>> _CacheByPrimaryKey = new Dictionary<string, List<ItemAudit>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move ItemAudit(s) from temporary _CacheList to _CacheByPrimaryKey
{
ItemAudit tmp = _CacheList[0]; // Get the first ItemAudit
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<ItemAudit>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ItemAudit
}
}
protected static ItemAudit 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
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ItemID", true);
if (_ItemID != value)
{
_ItemID = value;
PropertyHasChanged();
}
}
}
private int? _PreviousID;
public int? PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PreviousID", true);
return _PreviousID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("PreviousID", true);
if (_PreviousID != value)
{
_PreviousID = value;
PropertyHasChanged();
}
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ContentID", true);
if (_ContentID != value)
{
_ContentID = 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 int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DeleteStatus", true);
if (_DeleteStatus != value)
{
_DeleteStatus = value;
PropertyHasChanged();
}
}
}
public override bool IsDirty
{
get { return base.IsDirty; }
}
public bool IsDirtyList(List<object> list)
{
return base.IsDirty;
}
public override bool IsValid
{
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
}
public bool IsValidList(List<object> list)
{
return (IsNew && !IsDirty) ? true : base.IsValid;
}
// CSLATODO: Replace base ItemAudit.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemAudit</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ItemAudit.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 ItemAudit</returns>
protected override object GetIdValue()
{
return MyItemAuditUnique; // 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;
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.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 200));
//ValidationRules.AddDependantProperty("x", "y");
_ItemAuditExtension.AddValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_ItemAuditExtension.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(AuditID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(PreviousID, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(DeleteStatus, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(PreviousID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
_ItemAuditExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
_ItemAuditExtension.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;
}
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 _ItemAuditUnique = 0;
protected static int ItemAuditUnique
{ get { return ++_ItemAuditUnique; } }
private int _MyItemAuditUnique = ItemAuditUnique;
public int MyItemAuditUnique // Absolutely Unique ID - Editable
{ get { return _MyItemAuditUnique; } }
protected ItemAudit()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(AuditID.ToString()))
{
List<ItemAudit> listItemAudit = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listItemAudit.Contains(this)) listItemAudit.Remove(this); // Remove the item from the list
if (listItemAudit.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
}
public static ItemAudit New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ItemAudit");
try
{
return DataPortal.Create<ItemAudit>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemAudit.New", ex);
}
}
public static ItemAudit New(int itemID, int contentID, DateTime dts, string userID, int deleteStatus)
{
ItemAudit tmp = ItemAudit.New();
tmp.ItemID = itemID;
tmp.ContentID = contentID;
tmp.DTS = dts;
tmp.UserID = userID;
tmp.DeleteStatus = deleteStatus;
return tmp;
}
public static ItemAudit New(int itemID, int? previousID, int contentID, DateTime dts, string userID, int deleteStatus)
{
ItemAudit tmp = ItemAudit.New();
tmp.ItemID = itemID;
tmp.PreviousID = previousID;
tmp.ContentID = contentID;
tmp.DTS = dts;
tmp.UserID = userID;
tmp.DeleteStatus = deleteStatus;
return tmp;
}
public static ItemAudit MakeItemAudit(int itemID, int? previousID, int contentID, DateTime dts, string userID, int deleteStatus)
{
ItemAudit tmp = ItemAudit.New(itemID, previousID, contentID, dts, userID, deleteStatus);
if (tmp.IsSavable)
{
ItemAudit 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 ItemAudit Get(long auditID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ItemAudit");
try
{
ItemAudit tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ItemAudit>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ItemAudit
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemAudit.Get", ex);
}
}
public static ItemAudit Get(SafeDataReader dr)
{
if (dr.Read()) return new ItemAudit(dr);
return null;
}
internal ItemAudit(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(long auditID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ItemAudit");
try
{
DataPortal.Delete(new PKCriteria(auditID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemAudit.Delete", ex);
}
}
public override ItemAudit Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ItemAudit");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ItemAudit");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a ItemAudit");
try
{
BuildRefreshList();
ItemAudit itemAudit = base.Save();
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(itemAudit);//Refresh the item in AllList
ProcessRefreshList();
return itemAudit;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
_AuditID = NextAuditID;
// Database Defaults
// CSLATODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAudit.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
MarkOld();
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAudit.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemAudit.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAudit.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 = "getItemAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("ItemAudit.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemAudit.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("ItemAudit.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemAudit.DataPortal_Insert", ex);
}
finally
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAudit.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addItemAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", _ItemID);
cm.Parameters.AddWithValue("@PreviousID", _PreviousID);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
// Output Calculated Columns
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
param_AuditID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AuditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_AuditID = (long)cm.Parameters["@newAuditID"].Value;
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAudit.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAudit.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemAudit.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Add(SqlConnection cn, ref long auditID, int itemID, int? previousID, int contentID, DateTime dts, string userID, int deleteStatus)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAudit.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addItemAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", itemID);
cm.Parameters.AddWithValue("@PreviousID", previousID);
cm.Parameters.AddWithValue("@ContentID", contentID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
// Output Calculated Columns
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
param_AuditID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AuditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
auditID = (long)cm.Parameters["@newAuditID"].Value;
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAudit.Add", ex);
throw new DbCslaException("ItemAudit.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}] ItemAudit.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("ItemAudit.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}] ItemAudit.SQLUpdate", GetHashCode());
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateItemAudit";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@AuditID", _AuditID);
cm.Parameters.AddWithValue("@ItemID", _ItemID);
cm.Parameters.AddWithValue("@PreviousID", _PreviousID);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
}
}
MarkOld();
// use the open connection to update child objects
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAudit.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)
ItemAudit.Add(cn, ref _AuditID, _ItemID, _PreviousID, _ContentID, _DTS, _UserID, _DeleteStatus);
else
ItemAudit.Update(cn, ref _AuditID, _ItemID, _PreviousID, _ContentID, _DTS, _UserID, _DeleteStatus);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Update(SqlConnection cn, ref long auditID, int itemID, int? previousID, int contentID, DateTime dts, string userID, int deleteStatus)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAudit.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateItemAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@AuditID", auditID);
cm.Parameters.AddWithValue("@ItemID", itemID);
cm.Parameters.AddWithValue("@PreviousID", previousID);
cm.Parameters.AddWithValue("@ContentID", contentID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAudit.Update", ex);
throw new DbCslaException("ItemAudit.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_AuditID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAudit.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteItemAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAudit.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemAudit.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, long auditID)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAudit.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteItemAudit";
// Input PK Fields
cm.Parameters.AddWithValue("@AuditID", auditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAudit.Remove", ex);
throw new DbCslaException("ItemAudit.Remove", ex);
}
}
#endregion
// Standard Default Code
#region extension
ItemAuditExtension _ItemAuditExtension = new ItemAuditExtension();
[Serializable()]
partial class ItemAuditExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
// 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 ItemAuditConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemAudit)
{
// Return the ToString value
return ((ItemAudit)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ItemAuditExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ItemAudit
// {
// partial class ItemAuditExtension : extensionBase
// {
// // CSLATODO: Override automatic defaults
// 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 */);
// }
// }
// }
//}

View File

@ -0,0 +1,358 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ItemAuditInfoEvent(object sender);
/// <summary>
/// ItemAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemAuditInfoConverter))]
public partial class ItemAuditInfo : ReadOnlyBase<ItemAuditInfo>, IDisposable
{
public event ItemAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<ItemAuditInfo> _CacheList = new List<ItemAuditInfo>();
protected static void AddToCache(ItemAuditInfo itemAuditInfo)
{
if (!_CacheList.Contains(itemAuditInfo)) _CacheList.Add(itemAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(ItemAuditInfo itemAuditInfo)
{
while (_CacheList.Contains(itemAuditInfo)) _CacheList.Remove(itemAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ItemAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ItemAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move ItemAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
ItemAuditInfo tmp = _CacheList[0]; // Get the first ItemAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<ItemAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ItemAuditInfo
}
}
internal static void AddList(ItemAuditInfoList lst)
{
foreach (ItemAuditInfo item in lst) AddToCache(item);
}
protected static ItemAuditInfo 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; }
}
protected ItemAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
}
private int? _PreviousID;
public int? PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PreviousID", true);
return _PreviousID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base ItemAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ItemAuditInfo.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 ItemAuditInfo</returns>
protected override object GetIdValue()
{
return MyItemAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _ItemAuditInfoUnique = 0;
private static int ItemAuditInfoUnique
{ get { return ++_ItemAuditInfoUnique; } }
private int _MyItemAuditInfoUnique = ItemAuditInfoUnique;
public int MyItemAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyItemAuditInfoUnique; } }
protected ItemAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<ItemAuditInfo> listItemAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listItemAuditInfo.Contains(this)) listItemAuditInfo.Remove(this); // Remove the item from the list
if (listItemAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual ItemAudit Get()
{
return _Editable = ItemAudit.Get(_AuditID);
}
public static void Refresh(ItemAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ItemAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ItemAudit tmp)
{
_ItemID = tmp.ItemID;
_PreviousID = tmp.PreviousID;
_ContentID = tmp.ContentID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_ItemAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static ItemAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ItemAudit");
try
{
ItemAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ItemAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ItemAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ItemAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfo.Constructor", ex);
throw new DbCslaException("ItemAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.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 = "getItemAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("ItemAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ItemAuditInfoExtension _ItemAuditInfoExtension = new ItemAuditInfoExtension();
[Serializable()]
partial class ItemAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ItemAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ItemAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemAuditInfo)
{
// Return the ToString value
return ((ItemAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemAuditInfoListConverter))]
public partial class ItemAuditInfoList : ReadOnlyListBase<ItemAuditInfoList, ItemAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<ItemAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (ItemAuditInfo tmp in this)
{
tmp.Changed += new ItemAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
public void Dispose()
{
foreach (ItemAuditInfo tmp in this)
{
tmp.Changed -= new ItemAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static ItemAuditInfoList _ItemAuditInfoList = null;
/// <summary>
/// Return a list of all ItemAuditInfo.
/// </summary>
public static ItemAuditInfoList Get()
{
try
{
if (_ItemAuditInfoList != null)
return _ItemAuditInfoList;
ItemAuditInfoList tmp = DataPortal.Fetch<ItemAuditInfoList>();
ItemAuditInfo.AddList(tmp);
tmp.AddEvents();
_ItemAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all ItemAuditInfo.
/// </summary>
public static void Reset()
{
_ItemAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static ItemAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<ItemAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on ItemAuditInfoList.Get", ex);
// }
//}
private ItemAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getItemAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ItemAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ItemAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ItemAuditInfoListPropertyDescriptor pd = new ItemAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ItemAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private ItemAuditInfo Item { get { return (ItemAuditInfo)_Item; } }
public ItemAuditInfoListPropertyDescriptor(ItemAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ItemAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemAuditInfoList)
{
// Return department and department role separated by comma.
return ((ItemAuditInfoList)value).Items.Count.ToString() + " ItemAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,930 @@
// ========================================================================
// 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>
/// PartAudit Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(PartAuditConverter))]
public partial class PartAudit : BusinessBase<PartAudit>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<PartAudit> _RefreshPartAudits = new List<PartAudit>();
private void AddToRefreshList(List<PartAudit> refreshPartAudits)
{
if (IsDirty)
refreshPartAudits.Add(this);
}
private void BuildRefreshList()
{
_RefreshPartAudits = new List<PartAudit>();
AddToRefreshList(_RefreshPartAudits);
}
private void ProcessRefreshList()
{
foreach (PartAudit tmp in _RefreshPartAudits)
{
PartAuditInfo.Refresh(tmp);
}
}
#endregion
#region Collection
private static List<PartAudit> _CacheList = new List<PartAudit>();
protected static void AddToCache(PartAudit partAudit)
{
if (!_CacheList.Contains(partAudit)) _CacheList.Add(partAudit); // In AddToCache
}
protected static void RemoveFromCache(PartAudit partAudit)
{
while (_CacheList.Contains(partAudit)) _CacheList.Remove(partAudit); // In RemoveFromCache
}
private static Dictionary<string, List<PartAudit>> _CacheByPrimaryKey = new Dictionary<string, List<PartAudit>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move PartAudit(s) from temporary _CacheList to _CacheByPrimaryKey
{
PartAudit tmp = _CacheList[0]; // Get the first PartAudit
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<PartAudit>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first PartAudit
}
}
protected static PartAudit 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
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ContentID", true);
if (_ContentID != value)
{
_ContentID = value;
PropertyHasChanged();
}
}
}
private int _FromType;
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FromType", true);
return _FromType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("FromType", true);
if (_FromType != value)
{
_FromType = value;
PropertyHasChanged();
}
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ItemID", true);
if (_ItemID != value)
{
_ItemID = 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 int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DeleteStatus", true);
if (_DeleteStatus != value)
{
_DeleteStatus = value;
PropertyHasChanged();
}
}
}
public override bool IsDirty
{
get { return base.IsDirty; }
}
public bool IsDirtyList(List<object> list)
{
return base.IsDirty;
}
public override bool IsValid
{
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
}
public bool IsValidList(List<object> list)
{
return (IsNew && !IsDirty) ? true : base.IsValid;
}
// CSLATODO: Replace base PartAudit.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PartAudit</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check PartAudit.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 PartAudit</returns>
protected override object GetIdValue()
{
return MyPartAuditUnique; // 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;
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.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 200));
//ValidationRules.AddDependantProperty("x", "y");
_PartAuditExtension.AddValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_PartAuditExtension.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(AuditID, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(FromType, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(DeleteStatus, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FromType, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
_PartAuditExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
_PartAuditExtension.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;
}
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 _PartAuditUnique = 0;
protected static int PartAuditUnique
{ get { return ++_PartAuditUnique; } }
private int _MyPartAuditUnique = PartAuditUnique;
public int MyPartAuditUnique // Absolutely Unique ID - Editable
{ get { return _MyPartAuditUnique; } }
protected PartAudit()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(AuditID.ToString()))
{
List<PartAudit> listPartAudit = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listPartAudit.Contains(this)) listPartAudit.Remove(this); // Remove the item from the list
if (listPartAudit.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
}
public static PartAudit New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a PartAudit");
try
{
return DataPortal.Create<PartAudit>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on PartAudit.New", ex);
}
}
public static PartAudit New(int contentID, int fromType, int itemID, DateTime dts, string userID, int deleteStatus)
{
PartAudit tmp = PartAudit.New();
tmp.ContentID = contentID;
tmp.FromType = fromType;
tmp.ItemID = itemID;
tmp.DTS = dts;
tmp.UserID = userID;
tmp.DeleteStatus = deleteStatus;
return tmp;
}
public static PartAudit MakePartAudit(int contentID, int fromType, int itemID, DateTime dts, string userID, int deleteStatus)
{
PartAudit tmp = PartAudit.New(contentID, fromType, itemID, dts, userID, deleteStatus);
if (tmp.IsSavable)
{
PartAudit 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 PartAudit Get(long auditID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a PartAudit");
try
{
PartAudit tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<PartAudit>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up PartAudit
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on PartAudit.Get", ex);
}
}
public static PartAudit Get(SafeDataReader dr)
{
if (dr.Read()) return new PartAudit(dr);
return null;
}
internal PartAudit(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(long auditID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a PartAudit");
try
{
DataPortal.Delete(new PKCriteria(auditID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on PartAudit.Delete", ex);
}
}
public override PartAudit Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a PartAudit");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a PartAudit");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a PartAudit");
try
{
BuildRefreshList();
PartAudit partAudit = base.Save();
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(partAudit);//Refresh the item in AllList
ProcessRefreshList();
return partAudit;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
_AuditID = NextAuditID;
// Database Defaults
// CSLATODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAudit.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ContentID = dr.GetInt32("ContentID");
_FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
MarkOld();
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAudit.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartAudit.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAudit.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 = "getPartAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("PartAudit.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartAudit.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("PartAudit.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartAudit.DataPortal_Insert", ex);
}
finally
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAudit.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addPartAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@FromType", _FromType);
cm.Parameters.AddWithValue("@ItemID", _ItemID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
// Output Calculated Columns
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
param_AuditID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AuditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_AuditID = (long)cm.Parameters["@newAuditID"].Value;
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAudit.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAudit.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartAudit.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Add(SqlConnection cn, ref long auditID, int contentID, int fromType, int itemID, DateTime dts, string userID, int deleteStatus)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAudit.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addPartAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@FromType", fromType);
cm.Parameters.AddWithValue("@ItemID", itemID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
// Output Calculated Columns
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
param_AuditID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AuditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
auditID = (long)cm.Parameters["@newAuditID"].Value;
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAudit.Add", ex);
throw new DbCslaException("PartAudit.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}] PartAudit.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("PartAudit.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}] PartAudit.SQLUpdate", GetHashCode());
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updatePartAudit";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@AuditID", _AuditID);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@FromType", _FromType);
cm.Parameters.AddWithValue("@ItemID", _ItemID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
}
}
MarkOld();
// use the open connection to update child objects
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAudit.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)
PartAudit.Add(cn, ref _AuditID, _ContentID, _FromType, _ItemID, _DTS, _UserID, _DeleteStatus);
else
PartAudit.Update(cn, ref _AuditID, _ContentID, _FromType, _ItemID, _DTS, _UserID, _DeleteStatus);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Update(SqlConnection cn, ref long auditID, int contentID, int fromType, int itemID, DateTime dts, string userID, int deleteStatus)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAudit.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updatePartAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@AuditID", auditID);
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@FromType", fromType);
cm.Parameters.AddWithValue("@ItemID", itemID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAudit.Update", ex);
throw new DbCslaException("PartAudit.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_AuditID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAudit.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deletePartAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAudit.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartAudit.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, long auditID)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAudit.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deletePartAudit";
// Input PK Fields
cm.Parameters.AddWithValue("@AuditID", auditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAudit.Remove", ex);
throw new DbCslaException("PartAudit.Remove", ex);
}
}
#endregion
// Standard Default Code
#region extension
PartAuditExtension _PartAuditExtension = new PartAuditExtension();
[Serializable()]
partial class PartAuditExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
// 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 PartAuditConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is PartAudit)
{
// Return the ToString value
return ((PartAudit)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create PartAuditExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class PartAudit
// {
// partial class PartAuditExtension : extensionBase
// {
// // CSLATODO: Override automatic defaults
// 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 */);
// }
// }
// }
//}

View File

@ -0,0 +1,358 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void PartAuditInfoEvent(object sender);
/// <summary>
/// PartAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(PartAuditInfoConverter))]
public partial class PartAuditInfo : ReadOnlyBase<PartAuditInfo>, IDisposable
{
public event PartAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<PartAuditInfo> _CacheList = new List<PartAuditInfo>();
protected static void AddToCache(PartAuditInfo partAuditInfo)
{
if (!_CacheList.Contains(partAuditInfo)) _CacheList.Add(partAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(PartAuditInfo partAuditInfo)
{
while (_CacheList.Contains(partAuditInfo)) _CacheList.Remove(partAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<PartAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move PartAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
PartAuditInfo tmp = _CacheList[0]; // Get the first PartAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<PartAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first PartAuditInfo
}
}
internal static void AddList(PartAuditInfoList lst)
{
foreach (PartAuditInfo item in lst) AddToCache(item);
}
protected static PartAuditInfo 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; }
}
protected PartAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
}
private int _FromType;
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FromType", true);
return _FromType;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base PartAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PartAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check PartAuditInfo.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 PartAuditInfo</returns>
protected override object GetIdValue()
{
return MyPartAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _PartAuditInfoUnique = 0;
private static int PartAuditInfoUnique
{ get { return ++_PartAuditInfoUnique; } }
private int _MyPartAuditInfoUnique = PartAuditInfoUnique;
public int MyPartAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyPartAuditInfoUnique; } }
protected PartAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<PartAuditInfo> listPartAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listPartAuditInfo.Contains(this)) listPartAuditInfo.Remove(this); // Remove the item from the list
if (listPartAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual PartAudit Get()
{
return _Editable = PartAudit.Get(_AuditID);
}
public static void Refresh(PartAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(PartAudit tmp)
{
_ContentID = tmp.ContentID;
_FromType = tmp.FromType;
_ItemID = tmp.ItemID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_PartAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static PartAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a PartAudit");
try
{
PartAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<PartAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up PartAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on PartAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal PartAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfo.Constructor", ex);
throw new DbCslaException("PartAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ContentID = dr.GetInt32("ContentID");
_FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.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 = "getPartAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("PartAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
PartAuditInfoExtension _PartAuditInfoExtension = new PartAuditInfoExtension();
[Serializable()]
partial class PartAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(PartAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class PartAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is PartAuditInfo)
{
// Return the ToString value
return ((PartAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// PartAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(PartAuditInfoListConverter))]
public partial class PartAuditInfoList : ReadOnlyListBase<PartAuditInfoList, PartAuditInfo>, ICustomTypeDescriptor, IDisposable
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
internal new IList<PartAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (PartAuditInfo tmp in this)
{
tmp.Changed += new PartAuditInfoEvent(tmp_Changed);
}
}
void tmp_Changed(object sender)
{
for (int i = 0; i < Count; i++)
{
if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
}
}
public void Dispose()
{
foreach (PartAuditInfo tmp in this)
{
tmp.Changed -= new PartAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static PartAuditInfoList _PartAuditInfoList = null;
/// <summary>
/// Return a list of all PartAuditInfo.
/// </summary>
public static PartAuditInfoList Get()
{
try
{
if (_PartAuditInfoList != null)
return _PartAuditInfoList;
PartAuditInfoList tmp = DataPortal.Fetch<PartAuditInfoList>();
PartAuditInfo.AddList(tmp);
tmp.AddEvents();
_PartAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on PartAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all PartAuditInfo.
/// </summary>
public static void Reset()
{
_PartAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static PartAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<PartAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on PartAuditInfoList.Get", ex);
// }
//}
private PartAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getPartAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new PartAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("PartAuditInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
PartAuditInfoListPropertyDescriptor pd = new PartAuditInfoListPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class PartAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private PartAuditInfo Item { get { return (PartAuditInfo)_Item; } }
public PartAuditInfoListPropertyDescriptor(PartAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class PartAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is PartAuditInfoList)
{
// Return department and department role separated by comma.
return ((PartAuditInfoList)value).Items.Count.ToString() + " PartAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace