Commit for development environment setup

This commit is contained in:
2023-06-19 16:12:33 -04:00
parent be72063a3c
commit bbce2ad0a6
2209 changed files with 1171775 additions and 625 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,210 @@
// ========================================================================
// 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.Diagnostics;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// Database Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public static partial class Database
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
public static void LogException(string s, Exception ex)
{
int i = 0;
Console.WriteLine("Error - {0}", s);
for (; ex != null; ex = ex.InnerException)
{
Console.WriteLine("{0}{1} - {2}", "".PadLeft(++i * 2), ex.GetType().ToString(), ex.Message);
}
}
private static bool _LoggingInfo = false; // By default don't log info
public static bool LoggingInfo
{
get { return _LoggingInfo; }
set { _LoggingInfo = value; }
}
static System.Diagnostics.Process _CurrentProcess = System.Diagnostics.Process.GetCurrentProcess();
public static void LogInfo(string s, int hashCode)
{
if (_LoggingInfo)
Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode));
}
public static void LogDebug(string s, int hashCode)
{
if (_LoggingInfo)
Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode));
}
private static string _ConnectionName = "VEPROMS";
public static string ConnectionName
{
get { return Database._ConnectionName; }
set { Database._ConnectionName = value; _VEPROMS_Connection = null; /* Reset Connection */ }
}
private static string _VEPROMS_Connection;
public static string VEPROMS_Connection
{
get
{
if (_VEPROMS_Connection != null) // Use Lazy Load
return _VEPROMS_Connection;
DateTime.Today.ToLongDateString();
// If DBConnection.XML exists, use the connection string from DBConnection.XML
string cnOverride = System.Windows.Forms.Application.StartupPath + @"\DBConnection.XML";
if (System.IO.File.Exists(cnOverride))
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load(cnOverride);
System.Xml.XmlNode xn = xd.SelectSingleNode("DBConnection/@string");
if (xn != null)
{
return _VEPROMS_Connection = xn.InnerText;
}
}
// Otherwise get the value from the ConfigurationManager
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings[ConnectionName];
if (cs == null)
{
throw new ApplicationException("Database.cs Could not find connection " + ConnectionName);
}
string constr = cs.ConnectionString;
if (constr.Contains("{MENU}"))
{
constr = ChooseDatabase(constr);
}
return _VEPROMS_Connection = constr;
}
}
private static string _SelectedDatabase;
public static string SelectedDatabase
{
get { return Database._SelectedDatabase; }
set { Database._SelectedDatabase = value; }
}
private static string ChooseDatabase(string constr)
{
string tmp = constr.Replace("{MENU}", "master");
SqlConnection cn = new SqlConnection(tmp);
cn.Open();
// SqlDataAdapter da = new SqlDataAdapter("select name from sysdatabases where name like 'VEP%' order by name", cn);
SqlDataAdapter da = new SqlDataAdapter("select name,case when object_id(name + '..Revisions') is not null then 'Approval' when object_id(name + '..ContentAudits') is not null then 'Change Manager' else 'Original' end functionality from sysdatabases where name like 'VEP%' order by name", cn);
DataSet ds = new DataSet();
da.Fill(ds);
cn.Close();
System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip();
cms.Items.Add("Choose Database");
System.Windows.Forms.ToolStripMenuItem tsmi = cms.Items[0] as System.Windows.Forms.ToolStripMenuItem;
tsmi.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaption);// System.Drawing.Color.Pink;
tsmi.ForeColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaptionText);
tsmi.Font = new System.Drawing.Font(tsmi.Font, System.Drawing.FontStyle.Bold);
foreach (DataRow dr in ds.Tables[0].Rows)
{
if(dr["functionality"].ToString() == "Approval")
cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
}
while (_SelectedDatabase == null)
{
cms.Show(new System.Drawing.Point((System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - cms.Width) / 2, (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - cms.Height) / 2));
System.Windows.Forms.Application.DoEvents();
}
return constr.Replace("{MENU}", _SelectedDatabase);
}
static void Database_Click(object sender, EventArgs e)
{
System.Windows.Forms.ToolStripMenuItem tsmi = sender as System.Windows.Forms.ToolStripMenuItem;
if (tsmi != null)
{
_SelectedDatabase = tsmi.Text;
}
}
public static SqlConnection VEPROMS_SqlConnection
{
get
{
string strConn = VEPROMS_Connection; // If failure - Fail (Don't try to catch)
// Attempt to make a connection
try
{
SqlConnection cn = new SqlConnection(strConn);
cn.Open();
return cn;
}
catch (SqlException exsql)
{
const string strAttachError = "An attempt to attach an auto-named database for file ";
if (exsql.Message.StartsWith(strAttachError))
{// Check to see if the file is missing
string sFile = exsql.Message.Substring(strAttachError.Length);
sFile = sFile.Substring(0, sFile.IndexOf(" failed"));
// "An attempt to attach an auto-named database for file <mdf file> failed"
if (strConn.ToLower().IndexOf("user instance=true") < 0)
{
throw new ApplicationException("Connection String missing attribute: User Instance=True");
}
if (System.IO.File.Exists(sFile))
{
throw new ApplicationException("Database file " + sFile + " Cannot be opened\r\n", exsql);
}
else
{
throw new FileNotFoundException("Database file " + sFile + " Not Found", exsql);
}
}
else
{
throw new ApplicationException("Failure on Connect", exsql);
}
}
catch (Exception ex)// Throw Application Exception on Failure
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection Error", ex);
throw new ApplicationException("Failure on Connect", ex);
}
}
}
public static void PurgeData()
{
try
{
SqlConnection cn = VEPROMS_SqlConnection;
SqlCommand cmd = new SqlCommand("purgedata", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Purge Error", ex);
throw new ApplicationException("Failure on Purge", ex);
}
}
}
public class DbCslaException : Exception
{
internal DbCslaException(string message, Exception innerException) : base(message, innerException) { ;}
internal DbCslaException(string message) : base(message) { ;}
internal DbCslaException() : base() { ;}
} // Class
} // Namespace

View File

@@ -0,0 +1,575 @@
// ========================================================================
// 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.Diagnostics;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// Database Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public static partial class Database
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
private static int _DefaultTimeout = 600; // 600 seconds, i.e. 10 minutes
public static int DefaultTimeout
{
get { return _DefaultTimeout; }
set { _DefaultTimeout = value; }
}
public static void LogException(string s, Exception ex)
{
int i = 0;
Console.WriteLine("Error - {0}", s);
for (; ex != null; ex = ex.InnerException)
{
Console.WriteLine("{0}{1} - {2}", "".PadLeft(++i * 2), ex.GetType().ToString(), ex.Message);
}
}
private static bool _LoggingInfo = false; // By default don't log info
public static bool LoggingInfo
{
get { return _LoggingInfo; }
set { _LoggingInfo = value; }
}
static System.Diagnostics.Process _CurrentProcess = System.Diagnostics.Process.GetCurrentProcess();
public static void LogInfo(string s, int hashCode)
{
if (_LoggingInfo)
Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode));
}
public static void LogDebug(string s, int hashCode)
{
if (_LoggingInfo)
Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode));
}
private static string _ConnectionName = "VEPROMS";
public static string ConnectionName
{
get { return Database._ConnectionName; }
set { Database._ConnectionName = value; _VEPROMS_Connection = null; /* Reset Connection */ }
}
private static string _VEPROMS_Connection;
public static string VEPROMS_Connection
{
get
{
if (_VEPROMS_Connection != null) // Use Lazy Load
return _VEPROMS_Connection;
DateTime.Today.ToLongDateString();
// If DBConnection.XML exists, use the connection string from DBConnection.XML
string cnOverride = System.Windows.Forms.Application.StartupPath + @"\DBConnection.XML";
if (System.IO.File.Exists(cnOverride))
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load(cnOverride);
System.Xml.XmlNode xn = xd.SelectSingleNode("DBConnection/@string");
// bug fix: B2013-079
// If we are using the DBConnection.xml file,
// Check to see if "{MENU}" is being used and if a database was specified (ex."VEPROMS.EXE \DB=VEPROMS_xxx")
// If both conditions are true, then call the ChooseDatabases() funtion which will return a valid connection string (we hope)
// otherwise use the connection string as it is in the DBConnection.xml
if (xn != null)
{
if (xn.InnerText.Contains("{MENU}") && SelectedDatabase != null && SelectedDatabase.Length > 0)
_VEPROMS_Connection = ChooseDatabase(xn.InnerText);
else
_VEPROMS_Connection = xn.InnerText;
return _VEPROMS_Connection;
}
}
// Otherwise get the value from the ConfigurationManager
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings[ConnectionName];
if (cs == null)
{
throw new ApplicationException("Database.cs Could not find connection " + ConnectionName);
}
string constr = cs.ConnectionString;
if (constr.Contains("{MENU}"))
{
constr = ChooseDatabase(constr);
}
return _VEPROMS_Connection = constr;
}
set { _VEPROMS_Connection = value; }
}
private static string _SelectedDatabase;
public static string SelectedDatabase
{
get { return Database._SelectedDatabase; }
set { Database._SelectedDatabase = value; }
}
private static string _LastDatabase="NoDefault";
public static string LastDatabase
{
get { return Database._LastDatabase; }
set { Database._LastDatabase = value; }
}
private static string ChooseDatabase(string constr)
{
if (_SelectedDatabase == null)
{
if (LastDatabase != "NoDefault" && LastDatabase != "")
{
if (System.Windows.Forms.MessageBox.Show("Open " + LastDatabase, "Reopen Last Database", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
SelectedDatabase = LastDatabase;
return constr.Replace("{MENU}", _SelectedDatabase);
}
}
System.Windows.Forms.ContextMenuStrip cms = BuildDatabaseMenu(constr);
while (_SelectedDatabase == null)
{
cms.Show(new System.Drawing.Point((System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - cms.Width) / 2, (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - cms.Height) / 2));
System.Windows.Forms.Application.DoEvents();
}
}
return constr.Replace("{MENU}", _SelectedDatabase);
}
private static System.Windows.Forms.ContextMenuStrip BuildDatabaseMenu(string constr)
{
string tmp = constr.Replace("{MENU}", "master");
SqlConnection cn = new SqlConnection(tmp);
cn.Open();
// SqlDataAdapter da = new SqlDataAdapter("select name from sysdatabases where name like 'VEP%' order by name", cn);
//SqlDataAdapter da = new SqlDataAdapter("select name, case when object_id('[' + name + ']..Items') is null then 'Not PROMS' when object_id('[' + name + ']..Revisions') is not null then 'Approval' when object_id('[' + name + ']..ContentAudits') is not null then 'Change Manager' else 'Original' end functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
SqlDataAdapter da = new SqlDataAdapter("select name, 'Approval' functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
da.SelectCommand.CommandTimeout = 300; // 300 sec timeout
DataSet ds = new DataSet();
try
{
da.Fill(ds);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.GetType().Name, ex.Message);
throw(new Exception("Cannot Load Data List",ex));
}
cn.Close();
System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip();
cms.Items.Add("Choose Database");
System.Windows.Forms.ToolStripMenuItem tsmi = cms.Items[0] as System.Windows.Forms.ToolStripMenuItem;
tsmi.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaption);// System.Drawing.Color.Pink;
tsmi.ForeColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaptionText);
tsmi.Font = new System.Drawing.Font(tsmi.Font, System.Drawing.FontStyle.Bold);
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["functionality"].ToString() == "Approval")
cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
}
return cms;
}
static void Database_Click(object sender, EventArgs e)
{
System.Windows.Forms.ToolStripMenuItem tsmi = sender as System.Windows.Forms.ToolStripMenuItem;
if (tsmi != null)
{
_SelectedDatabase = tsmi.Text;
}
}
public static SqlConnection VEPROMS_SqlConnection
{
get
{
string strConn = VEPROMS_Connection; // If failure - Fail (Don't try to catch)
// Attempt to make a connection
try
{
SqlConnection cn = new SqlConnection(strConn);
cn.Open();
return cn;
}
catch (SqlException exsql)
{
const string strAttachError = "An attempt to attach an auto-named database for file ";
if (exsql.Message.StartsWith(strAttachError))
{// Check to see if the file is missing
string sFile = exsql.Message.Substring(strAttachError.Length);
sFile = sFile.Substring(0, sFile.IndexOf(" failed"));
// "An attempt to attach an auto-named database for file <mdf file> failed"
if (strConn.ToLower().IndexOf("user instance=true") < 0)
{
throw new ApplicationException("Connection String missing attribute: User Instance=True");
}
if (System.IO.File.Exists(sFile))
{
throw new ApplicationException("Database file " + sFile + " Cannot be opened\r\n", exsql);
}
else
{
throw new FileNotFoundException("Database file " + sFile + " Not Found", exsql);
}
}
else
{
throw new ApplicationException("Failure on Connect", exsql);
}
}
catch (Exception ex)// Throw Application Exception on Failure
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Connection Error", ex);
throw new ApplicationException("Failure on Connect", ex);
}
}
}
public static void PurgeData()
{
try
{
//SqlConnection cn = VEPROMS_SqlConnection;
//SqlCommand cmd = new SqlCommand("purgedata", cn);
using (SqlConnection cn = VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("purgedata", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Purge Error", ex);
throw new ApplicationException("Failure on Purge", ex);
}
}
}
public class DbCslaException : Exception
{
internal DbCslaException(string message, Exception innerException) : base(message, innerException) { ;}
internal DbCslaException(string message) : base(message) { ;}
internal DbCslaException() : base() { ;}
} // Class
#region commandbase object jcb
[Serializable()]
public class PurgeDataCommand : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _RowsAffected;
public int RowsAffected
{
get { return _RowsAffected; }
set { _RowsAffected = value; }
}
#region Factory Methods
public static int Execute()
{
PurgeDataCommand cmd = new PurgeDataCommand();
cmd = DataPortal.Execute<PurgeDataCommand>(cmd);
return cmd.RowsAffected;
}
private PurgeDataCommand()
{ /* require use of factory methods */ }
#endregion
#region Server-Side code
protected override void DataPortal_Execute()
{
try
{
//SqlConnection cn = VEPROMS_SqlConnection;
//SqlCommand cmd = new SqlCommand("purgedata", cn);
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("purgedata", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
RowsAffected = cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Purge Error", ex);
throw new ApplicationException("Failure on Purge", ex);
}
}
#endregion
}
[Serializable()]
public class CanTransitionBeCreatedCommand : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private ProposedTransition _ProposedTransition;
public ProposedTransition ProposedTransition
{
get { return _ProposedTransition; }
set { _ProposedTransition = value; }
}
private int _FromID;
public int FromID
{
get { return _FromID; }
set { _FromID = value; }
}
private int _ToID;
public int ToID
{
get { return _ToID; }
set { _ToID = value; }
}
#region Factory Methods
public static ProposedTransition Execute(int fromID, int toID)
{
CanTransitionBeCreatedCommand cmd = new CanTransitionBeCreatedCommand();
cmd.FromID = fromID;
cmd.ToID = toID;
cmd = DataPortal.Execute<CanTransitionBeCreatedCommand>(cmd);
return cmd.ProposedTransition;
}
private CanTransitionBeCreatedCommand()
{ /* require use of factory methods */ }
#endregion
#region Server-Side code
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CanTransitionBeCreatedCommand.ReadData", GetHashCode());
try
{
_ProposedTransition = new ProposedTransition(dr.GetInt32("status"), dr.GetString("fromappl"), dr.GetString("toappl"), dr.GetString("fromstep"), dr.GetString("tostep"));
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("CanTransitionBeCreatedCommand.ReadData", ex);
}
}
protected override void DataPortal_Execute()
{
try
{
//SqlConnection cn = VEPROMS_SqlConnection;
//SqlCommand cmd = new SqlCommand("purgedata", cn);
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_CanTransitionBeCreated", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("fromItemID", _FromID);
cmd.Parameters.AddWithValue("toItemID", _ToID);
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("CanTransitionBeCreatedCommand Error", ex);
throw new ApplicationException("Failure on CanTransitionBeCreatedCommand", ex);
}
}
#endregion
}
[Serializable()]
public class WillTransitionsBeValidCommand : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private List<InvalidTransition> _InvalidTransitions;
public List<InvalidTransition> InvalidTransitions
{
get { return _InvalidTransitions; }
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private string _NewAppl;
public string NewAppl
{
get { return _NewAppl; }
set { _NewAppl = value; }
}
#region Factory Methods
public static List<InvalidTransition> Execute(int itemID, string newAppl)
{
WillTransitionsBeValidCommand cmd = new WillTransitionsBeValidCommand();
cmd.ItemID = itemID;
cmd.NewAppl = newAppl;
cmd = DataPortal.Execute<WillTransitionsBeValidCommand>(cmd);
return cmd.InvalidTransitions;
}
private WillTransitionsBeValidCommand()
{ /* require use of factory methods */ }
#endregion
#region Server-Side code
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.ReadData", GetHashCode());
try
{
do
{
_InvalidTransitions.Add(new InvalidTransition(dr.GetInt32("myitemid"), dr.GetString("srcappl"), dr.GetString("tgtappl"), dr.GetString("srcstep"), dr.GetString("tgtstep")));
} while (dr.Read());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("WillTransitionsBeValidCommand.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("WillTransitionsBeValidCommand.ReadData", ex);
}
}
protected override void DataPortal_Execute()
{
try
{
//SqlConnection cn = VEPROMS_SqlConnection;
//SqlCommand cmd = new SqlCommand("purgedata", cn);
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_WillTransitionsBeValid", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("ItemID", _ItemID);
cmd.Parameters.AddWithValue("NewAppl", _NewAppl);
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
{
_InvalidTransitions = new List<InvalidTransition>();
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("WillTransitionsBeValidCommand Error", ex);
throw new ApplicationException("Failure on WillTransitionsBeValidCommand", ex);
}
}
#endregion
}
[Serializable()]
public class InvalidTransition
{
private int _MyItemID;
public int MyItemID
{
get { return _MyItemID; }
set { _MyItemID = value; }
}
private string _SrcAppl;
public string SrcAppl
{
get { return _SrcAppl; }
set { _SrcAppl = value; }
}
private string _TgtAppl;
public string TgtAppl
{
get { return _TgtAppl; }
set { _TgtAppl = value; }
}
private string _SrcStep;
public string SrcStep
{
get { return _SrcStep; }
set { _SrcStep = value; }
}
private string _TgtStep;
public string TgtStep
{
get { return _TgtStep; }
set { _TgtStep = value; }
}
public InvalidTransition(int myItemID, string srcAppl, string tgtAppl, string srcStep, string tgtStep)
{
_MyItemID = myItemID;
_SrcAppl = srcAppl;
_TgtAppl = tgtAppl;
_SrcStep = srcStep;
_TgtStep = tgtStep;
}
}
[Serializable()]
public class ProposedTransition
{
private int _Status;
public int Status
{
get { return _Status; }
set { _Status = value; }
}
private string _FromAppl;
public string FromAppl
{
get { return _FromAppl; }
set { _FromAppl = value; }
}
private string _ToAppl;
public string ToAppl
{
get { return _ToAppl; }
set { _ToAppl = value; }
}
private string _FromStep;
public string FromStep
{
get { return _FromStep; }
set { _FromStep = value; }
}
private string _ToStep;
public string ToStep
{
get { return _ToStep; }
set { _ToStep = value; }
}
public ProposedTransition(int status, string fromAppl, string toAppl, string fromStep, string toStep)
{
_Status = status;
_FromAppl = fromAppl;
_ToAppl = toAppl;
_FromStep = fromStep;
_ToStep = toStep;
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,312 @@
// ========================================================================
// 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>
/// FigureInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FigureInfoListConverter))]
public partial class FigureInfoList : ReadOnlyListBase<FigureInfoList, FigureInfo>, 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<FigureInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (FigureInfo tmp in this)
{
tmp.Changed += new FigureInfoEvent(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 (FigureInfo tmp in this)
{
tmp.Changed -= new FigureInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static FigureInfoList _FigureInfoList = null;
/// <summary>
/// Return a list of all projects.
/// </summary>
public static FigureInfoList Get()
{
try
{
if (_FigureInfoList != null)
return _FigureInfoList;
FigureInfoList tmp = DataPortal.Fetch<FigureInfoList>();
FigureInfo.AddList(tmp);
tmp.AddEvents();
_FigureInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FigureInfoList.Get", ex);
}
}
// TODO: Add alternative gets -
//public static FigureInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<FigureInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on FigureInfoList.Get", ex);
// }
//}
public static FigureInfoList GetByROFstID(int rOFstID)
{
try
{
FigureInfoList tmp = DataPortal.Fetch<FigureInfoList>(new ROFstIDCriteria(rOFstID));
FigureInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FigureInfoList.GetByROFstID", ex);
}
}
public static FigureInfoList GetByImageID(int imageID)
{
try
{
FigureInfoList tmp = DataPortal.Fetch<FigureInfoList>(new ImageIDCriteria(imageID));
FigureInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FigureInfoList.GetByImageID", ex);
}
}
private FigureInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFigures";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FigureInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("FigureInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ROFstIDCriteria
{
public ROFstIDCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
private int _ROFstID;
public int ROFstID
{
get { return _ROFstID; }
set { _ROFstID = value; }
}
}
private void DataPortal_Fetch(ROFstIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfoList.DataPortal_FetchROFstID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFiguresByROFstID";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FigureInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfoList.DataPortal_FetchROFstID", ex);
throw new DbCslaException("FigureInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ImageIDCriteria
{
public ImageIDCriteria(int imageID)
{
_ImageID = imageID;
}
private int _ImageID;
public int ImageID
{
get { return _ImageID; }
set { _ImageID = value; }
}
}
private void DataPortal_Fetch(ImageIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfoList.DataPortal_FetchImageID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFiguresByImageID";
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FigureInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfoList.DataPortal_FetchImageID", ex);
throw new DbCslaException("FigureInfoList.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
FigureInfoListPropertyDescriptor pd = new FigureInfoListPropertyDescriptor(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 FigureInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private FigureInfo Item { get { return (FigureInfo)_Item; } }
public FigureInfoListPropertyDescriptor(FigureInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class FigureInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FigureInfoList)
{
// Return department and department role separated by comma.
return ((FigureInfoList)value).Items.Count.ToString() + " Figures";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,692 @@
// ========================================================================
// 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 ItemInfoEvent(object sender);
/// <summary>
/// ItemInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemInfoConverter))]
public partial class ItemInfo : ReadOnlyBase<ItemInfo>, IDisposable
{
public event ItemInfoEvent 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<ItemInfo> _CacheList = new List<ItemInfo>();
protected static void AddToCache(ItemInfo itemInfo)
{
if (!_CacheList.Contains(itemInfo)) _CacheList.Add(itemInfo); // In AddToCache
}
protected static void RemoveFromCache(ItemInfo itemInfo)
{
while (_CacheList.Contains(itemInfo)) _CacheList.Remove(itemInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ItemInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ItemInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move ItemInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
ItemInfo tmp = _CacheList[0]; // Get the first ItemInfo
string pKey = tmp.ItemID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<ItemInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ItemInfo
}
}
internal static void AddList(ItemInfoList lst)
{
foreach (ItemInfo item in lst) AddToCache(item);
}
protected static ItemInfo GetCachedByPrimaryKey(int itemID)
{
ConvertListToDictionary();
string key = itemID.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 Item _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ItemID;
[System.ComponentModel.DataObjectField(true, true)]
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);
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID;
}
}
private ItemInfo _MyPrevious;
public ItemInfo MyPrevious
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyPrevious", true);
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = ItemInfo.Get((int)_PreviousID);
return _MyPrevious;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
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 _ItemAnnotationCount = 0;
/// <summary>
/// Count of ItemAnnotations for this Item
/// </summary>
public int ItemAnnotationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemAnnotationCount", true);
if (_ItemAnnotationCount < 0)
_ItemAnnotationCount = ItemAnnotations.Count;
return _ItemAnnotationCount;
}
}
private AnnotationInfoList _ItemAnnotations = null;
[TypeConverter(typeof(AnnotationInfoListConverter))]
public AnnotationInfoList ItemAnnotations
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemAnnotations", true);
if (_ItemAnnotationCount < 0 || (_ItemAnnotationCount > 0 && _ItemAnnotations == null))
_ItemAnnotations = AnnotationInfoList.GetByItemID(_ItemID);
if (_ItemAnnotationCount < 0)
_ItemAnnotationCount = _ItemAnnotations.Count;
return _ItemAnnotations;
}
}
public void RefreshItemAnnotations()
{
_ItemAnnotationCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemAnnotationCount = -1; // This will cause the data to be requeried
}
private int _ItemDocVersionCount = 0;
/// <summary>
/// Count of ItemDocVersions for this Item
/// </summary>
public int ItemDocVersionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemDocVersionCount", true);
if (_ItemDocVersionCount < 0)
_ItemDocVersionCount = ItemDocVersions.Count;
return _ItemDocVersionCount;
}
}
private DocVersionInfoList _ItemDocVersions = null;
[TypeConverter(typeof(DocVersionInfoListConverter))]
public DocVersionInfoList ItemDocVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemDocVersions", true);
if (_ItemDocVersionCount < 0 || (_ItemDocVersionCount > 0 && _ItemDocVersions == null))
_ItemDocVersions = DocVersionInfoList.GetByItemID(_ItemID);
if (_ItemDocVersionCount < 0)
_ItemDocVersionCount = _ItemDocVersions.Count;
return _ItemDocVersions;
}
}
public void RefreshItemDocVersions()
{
_ItemDocVersionCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemDocVersionCount = -1; // This will cause the data to be requeried
}
private int _NextItemCount = 0;
/// <summary>
/// Count of NextItems for this Item
/// </summary>
public int NextItemCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("NextItemCount", true);
if (_NextItemCount < 0)
_NextItemCount = NextItems.Count;
return _NextItemCount;
}
}
private ItemInfoList _NextItems = null;
[TypeConverter(typeof(ItemInfoListConverter))]
public ItemInfoList NextItems
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("NextItems", true);
if (_NextItemCount < 0 || (_NextItemCount > 0 && _NextItems == null))
_NextItems = ItemInfoList.GetNext(_ItemID);
if (_NextItemCount < 0)
_NextItemCount = _NextItems.Count;
return _NextItems;
}
}
public void RefreshNextItems()
{
_NextItemCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._NextItemCount = -1; // This will cause the data to be requeried
}
private int _ItemPartCount = 0;
/// <summary>
/// Count of ItemParts for this Item
/// </summary>
public int ItemPartCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemPartCount", true);
if (_ItemPartCount < 0)
_ItemPartCount = ItemParts.Count;
return _ItemPartCount;
}
}
private PartInfoList _ItemParts = null;
[TypeConverter(typeof(PartInfoListConverter))]
public PartInfoList ItemParts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemParts", true);
if (_ItemPartCount < 0 || (_ItemPartCount > 0 && _ItemParts == null))
_ItemParts = PartInfoList.GetByItemID(_ItemID);
if (_ItemPartCount < 0)
_ItemPartCount = _ItemParts.Count;
return _ItemParts;
}
}
public void RefreshItemParts()
{
_ItemPartCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemPartCount = -1; // This will cause the data to be requeried
}
private int _ItemTransition_RangeIDCount = 0;
/// <summary>
/// Count of ItemTransitions_RangeID for this Item
/// </summary>
public int ItemTransition_RangeIDCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransition_RangeIDCount", true);
if (_ItemTransition_RangeIDCount < 0)
_ItemTransition_RangeIDCount = ItemTransitions_RangeID.Count;
return _ItemTransition_RangeIDCount;
}
}
private TransitionInfoList _ItemTransitions_RangeID = null;
[TypeConverter(typeof(TransitionInfoListConverter))]
public TransitionInfoList ItemTransitions_RangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransitions_RangeID", true);
if (_ItemTransition_RangeIDCount < 0 || (_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null))
_ItemTransitions_RangeID = TransitionInfoList.GetByRangeID(_ItemID);
if (_ItemTransition_RangeIDCount < 0)
_ItemTransition_RangeIDCount = _ItemTransitions_RangeID.Count;
return _ItemTransitions_RangeID;
}
}
public void RefreshItemTransitions_RangeID()
{
_ItemTransition_RangeIDCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemTransition_RangeIDCount = -1; // This will cause the data to be requeried
}
private int _ItemTransition_ToIDCount = 0;
/// <summary>
/// Count of ItemTransitions_ToID for this Item
/// </summary>
public int ItemTransition_ToIDCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransition_ToIDCount", true);
if (_ItemTransition_ToIDCount < 0)
_ItemTransition_ToIDCount = ItemTransitions_ToID.Count;
return _ItemTransition_ToIDCount;
}
}
private TransitionInfoList _ItemTransitions_ToID = null;
[TypeConverter(typeof(TransitionInfoListConverter))]
public TransitionInfoList ItemTransitions_ToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransitions_ToID", true);
if (_ItemTransition_ToIDCount < 0 || (_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null))
_ItemTransitions_ToID = TransitionInfoList.GetByToID(_ItemID);
if (_ItemTransition_ToIDCount < 0)
_ItemTransition_ToIDCount = _ItemTransitions_ToID.Count;
return _ItemTransitions_ToID;
}
}
public void RefreshItemTransitions_ToID()
{
_ItemTransition_ToIDCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemTransition_ToIDCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base ItemInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ItemInfo.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 ItemInfo</returns>
protected override object GetIdValue()
{
return MyItemInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _ItemInfoUnique = 0;
private static int ItemInfoUnique
{ get { return ++_ItemInfoUnique; } }
private int _MyItemInfoUnique = ItemInfoUnique;
public int MyItemInfoUnique // Absolutely Unique ID - Info
{ get { return _MyItemInfoUnique; } }
protected ItemInfo()
{/* require use of factory methods */
AddToCache(this);
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~ItemInfo()
{
_CountFinalized++;
}
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ItemID.ToString())) return;
List<ItemInfo> listItemInfo = _CacheByPrimaryKey[ItemID.ToString()]; // Get the list of items
while (listItemInfo.Contains(this)) listItemInfo.Remove(this); // Remove the item from the list
if (listItemInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ItemID.ToString()); // remove the list
if (_MyContent != null)
_MyContent = null;
if (_MyPrevious != null)
_MyPrevious = null;
//if (_ActiveFormat != null)
// _ActiveFormat = null;
//if (_ActiveParent != null)
// _ActiveParent = null;
//if (_ActiveSection != null)
// _ActiveSection = null;
//if (_MyDocVersion != null)
// _MyDocVersion = null;
//if (_ParentNoteOrCaution != null)
// _ParentNoteOrCaution = null;
}
public virtual Item Get()
{
return _Editable = Item.Get(_ItemID);
}
public static void Refresh(Item tmp)
{
string key = tmp.ItemID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ItemInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Item tmp)
{
if (_PreviousID != tmp.PreviousID)
{
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value
_PreviousID = tmp.PreviousID; // Update the value
}
_MyPrevious = null; // Reset list so that the next line gets a new list
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
//if (_ContentID != tmp.ContentID)
//{
if (MyContent != null) MyContent.RefreshContentItems(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
//}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentItems(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ItemInfoExtension.Refresh(this);
//RHM Removed 20090724 - Duplicates function of code above.
// - Dispose caused error when a new step was added.
// - Resequence of transitions did not work properly.
// if(_MyPrevious != null)
// {
// _MyPrevious.Dispose();// Dispose related value
// _MyPrevious = null;// Reset related value
// }
//RHM Removed 20090724 - Duplicates function of code above.
// - Dispose caused error when a new step was added.
// - Resequence of transitions did not work properly.
// if(_MyContent != null)
// {
// _MyContent.Dispose();// Dispose related value
// _MyContent = null;// Reset related value
// }
OnChange();// raise an event
}
public static void Refresh(ContentItem tmp)
{
string key = tmp.ItemID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ItemInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentItem tmp)
{
if (_PreviousID != tmp.PreviousID)
{
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value
_PreviousID = tmp.PreviousID; // Update the value
}
_MyPrevious = null; // Reset list so that the next line gets a new list
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ItemInfoExtension.Refresh(this);
//RHM Removed 20090724 - Duplicates function of code above.
// - Dispose caused error when a new step was added.
// - Resequence of transitions did not work properly.
// if(_MyPrevious != null)
// {
// _MyPrevious.Dispose();// Dispose related value
// _MyPrevious = null;// Reset related value
// }
//RHM Removed 20090724 - Duplicates function of code above.
// - Dispose caused error when a new step was added.
// - Resequence of transitions did not work properly.
// if(_MyContent != null)
// {
// _MyContent.Dispose();// Dispose related value
// _MyContent = null;// Reset related value
// }
OnChange();// raise an event
}
public static ItemInfo Get(int itemID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
ItemInfo tmp = GetCachedByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ItemInfo>(new PKCriteria(itemID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ItemInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ItemInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.Constructor", ex);
throw new DbCslaException("ItemInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
public PKCriteria(int itemID)
{
_ItemID = itemID;
}
}
protected void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.ReadData", GetHashCode());
try
{
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ItemAnnotationCount = dr.GetInt32("AnnotationCount");
_ItemDocVersionCount = dr.GetInt32("DocVersionCount");
_NextItemCount = dr.GetInt32("NextCount");
_ItemPartCount = dr.GetInt32("PartCount");
_ItemTransition_RangeIDCount = dr.GetInt32("Transition_RangeIDCount");
_ItemTransition_ToIDCount = dr.GetInt32("Transition_ToIDCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.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 = "getItem";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
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("ItemInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ItemInfoExtension _ItemInfoExtension = new ItemInfoExtension();
[Serializable()]
partial class ItemInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ItemInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ItemInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemInfo)
{
// Return the ToString value
return ((ItemInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,956 @@
// ========================================================================
// 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>
/// RevisionROCheck Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionROCheckConverter))]
public partial class RevisionROCheck : BusinessBase<RevisionROCheck>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<RevisionROCheck> _RefreshRevisionROChecks = new List<RevisionROCheck>();
private void AddToRefreshList(List<RevisionROCheck> refreshRevisionROChecks)
{
if (IsDirty)
refreshRevisionROChecks.Add(this);
}
private void BuildRefreshList()
{
_RefreshRevisionROChecks = new List<RevisionROCheck>();
AddToRefreshList(_RefreshRevisionROChecks);
}
private void ProcessRefreshList()
{
foreach (RevisionROCheck tmp in _RefreshRevisionROChecks)
{
RevisionROCheckInfo.Refresh(tmp);
}
}
#endregion
#region Collection
private static List<RevisionROCheck> _CacheList = new List<RevisionROCheck>();
protected static void AddToCache(RevisionROCheck revisionROCheck)
{
if (!_CacheList.Contains(revisionROCheck)) _CacheList.Add(revisionROCheck); // In AddToCache
}
protected static void RemoveFromCache(RevisionROCheck revisionROCheck)
{
while (_CacheList.Contains(revisionROCheck)) _CacheList.Remove(revisionROCheck); // In RemoveFromCache
}
private static Dictionary<string, List<RevisionROCheck>> _CacheByPrimaryKey = new Dictionary<string, List<RevisionROCheck>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move RevisionROCheck(s) from temporary _CacheList to _CacheByPrimaryKey
{
RevisionROCheck tmp = _CacheList[0]; // Get the first RevisionROCheck
string pKey = tmp.CheckID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<RevisionROCheck>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first RevisionROCheck
}
}
protected static RevisionROCheck GetCachedByPrimaryKey(int checkID)
{
ConvertListToDictionary();
string key = checkID.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 _nextCheckID = -1;
public static int NextCheckID
{
get { return _nextCheckID--; }
}
private int _CheckID;
[System.ComponentModel.DataObjectField(true, true)]
public int CheckID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("CheckID", true);
return _CheckID;
}
}
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 _ROID;
public int ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROID", true);
return _ROID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROID", true);
if (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private string _RODate = string.Empty;
public string RODate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODate", true);
return _RODate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("RODate", true);
if (value == null) value = string.Empty;
_RODate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_RODate != tmp.ToString())
{
_RODate = tmp.ToString();
// CSLATODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _ROValue = string.Empty;
public string ROValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROValue", true);
return _ROValue;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROValue", true);
if (value == null) value = string.Empty;
if (_ROValue != value)
{
_ROValue = 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 RevisionROCheck.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RevisionROCheck</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check RevisionROCheck.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 RevisionROCheck</returns>
protected override object GetIdValue()
{
return MyRevisionROCheckUnique; // 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<RevisionROCheck>(RODateValid, "RODate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ROValue", 1073741823));
//ValidationRules.AddDependantProperty("x", "y");
_RevisionROCheckExtension.AddValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_RevisionROCheckExtension.AddInstanceValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
private static bool RODateValid(RevisionROCheck target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._RODate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
//AuthorizationRules.AllowRead(CheckID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
//AuthorizationRules.AllowRead(RODate, "<Role(s)>");
//AuthorizationRules.AllowRead(ROValue, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RODate, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROValue, "<Role(s)>");
_RevisionROCheckExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
_RevisionROCheckExtension.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 _RevisionROCheckUnique = 0;
protected static int RevisionROCheckUnique
{ get { return ++_RevisionROCheckUnique; } }
private int _MyRevisionROCheckUnique = RevisionROCheckUnique;
public int MyRevisionROCheckUnique // Absolutely Unique ID - Editable
{ get { return _MyRevisionROCheckUnique; } }
protected RevisionROCheck()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(CheckID.ToString()))
{
List<RevisionROCheck> listRevisionROCheck = _CacheByPrimaryKey[CheckID.ToString()]; // Get the list of items
while (listRevisionROCheck.Contains(this)) listRevisionROCheck.Remove(this); // Remove the item from the list
if (listRevisionROCheck.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(CheckID.ToString()); // remove the list
}
}
public static RevisionROCheck New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a RevisionROCheck");
try
{
return DataPortal.Create<RevisionROCheck>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheck.New", ex);
}
}
public static RevisionROCheck New(int itemID, int roid)
{
RevisionROCheck tmp = RevisionROCheck.New();
tmp.ItemID = itemID;
tmp.ROID = roid;
return tmp;
}
public static RevisionROCheck New(int itemID, int roid, string rODate, string rOValue)
{
RevisionROCheck tmp = RevisionROCheck.New();
tmp.ItemID = itemID;
tmp.ROID = roid;
tmp.RODate = rODate;
tmp.ROValue = rOValue;
return tmp;
}
public static RevisionROCheck MakeRevisionROCheck(int itemID, int roid, string rODate, string rOValue)
{
RevisionROCheck tmp = RevisionROCheck.New(itemID, roid, rODate, rOValue);
if (tmp.IsSavable)
{
RevisionROCheck 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 RevisionROCheck Get(int checkID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a RevisionROCheck");
try
{
RevisionROCheck tmp = GetCachedByPrimaryKey(checkID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RevisionROCheck>(new PKCriteria(checkID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RevisionROCheck
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheck.Get", ex);
}
}
public static RevisionROCheck Get(SafeDataReader dr)
{
if (dr.Read()) return new RevisionROCheck(dr);
return null;
}
internal RevisionROCheck(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(int checkID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a RevisionROCheck");
try
{
DataPortal.Delete(new PKCriteria(checkID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheck.Delete", ex);
}
}
public override RevisionROCheck Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a RevisionROCheck");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a RevisionROCheck");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a RevisionROCheck");
try
{
BuildRefreshList();
RevisionROCheck revisionROCheck = base.Save();
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(revisionROCheck);//Refresh the item in AllList
ProcessRefreshList();
return revisionROCheck;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[Serializable()]
protected class PKCriteria
{
private int _CheckID;
public int CheckID
{ get { return _CheckID; } }
public PKCriteria(int checkID)
{
_CheckID = checkID;
}
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
_CheckID = NextCheckID;
// Database Defaults
// CSLATODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.ReadData", GetHashCode());
try
{
_CheckID = dr.GetInt32("CheckID");
_ItemID = dr.GetInt32("ItemID");
_ROID = dr.GetInt32("ROID");
_RODate = dr.GetSmartDate("RODate").Text;
_ROValue = dr.GetString("ROValue");
MarkOld();
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.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 = "getRevisionROCheck";
cm.Parameters.AddWithValue("@CheckID", criteria.CheckID);
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("RevisionROCheck.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.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("RevisionROCheck.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.DataPortal_Insert", ex);
}
finally
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.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 = "addRevisionROCheck";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", _ItemID);
cm.Parameters.AddWithValue("@ROID", _ROID);
cm.Parameters.AddWithValue("@RODate", new SmartDate(_RODate).DBValue);
cm.Parameters.AddWithValue("@ROValue", _ROValue);
// Output Calculated Columns
SqlParameter param_CheckID = new SqlParameter("@newCheckID", SqlDbType.Int);
param_CheckID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_CheckID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_CheckID = (int)cm.Parameters["@newCheckID"].Value;
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Add(SqlConnection cn, ref int checkID, int itemID, int roid, SmartDate rODate, string rOValue)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addRevisionROCheck";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", itemID);
cm.Parameters.AddWithValue("@ROID", roid);
cm.Parameters.AddWithValue("@RODate", rODate.DBValue);
cm.Parameters.AddWithValue("@ROValue", rOValue);
// Output Calculated Columns
SqlParameter param_CheckID = new SqlParameter("@newCheckID", SqlDbType.Int);
param_CheckID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_CheckID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
checkID = (int)cm.Parameters["@newCheckID"].Value;
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.Add", ex);
throw new DbCslaException("RevisionROCheck.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}] RevisionROCheck.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("RevisionROCheck.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}] RevisionROCheck.SQLUpdate", GetHashCode());
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateRevisionROCheck";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@CheckID", _CheckID);
cm.Parameters.AddWithValue("@ItemID", _ItemID);
cm.Parameters.AddWithValue("@ROID", _ROID);
cm.Parameters.AddWithValue("@RODate", new SmartDate(_RODate).DBValue);
cm.Parameters.AddWithValue("@ROValue", _ROValue);
// 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("RevisionROCheck.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)
RevisionROCheck.Add(cn, ref _CheckID, _ItemID, _ROID, new SmartDate(_RODate), _ROValue);
else
RevisionROCheck.Update(cn, ref _CheckID, _ItemID, _ROID, new SmartDate(_RODate), _ROValue);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Update(SqlConnection cn, ref int checkID, int itemID, int roid, SmartDate rODate, string rOValue)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateRevisionROCheck";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@CheckID", checkID);
cm.Parameters.AddWithValue("@ItemID", itemID);
cm.Parameters.AddWithValue("@ROID", roid);
cm.Parameters.AddWithValue("@RODate", rODate);
cm.Parameters.AddWithValue("@ROValue", rOValue);
// 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("RevisionROCheck.Update", ex);
throw new DbCslaException("RevisionROCheck.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_CheckID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteRevisionROCheck";
cm.Parameters.AddWithValue("@CheckID", criteria.CheckID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int checkID)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteRevisionROCheck";
// Input PK Fields
cm.Parameters.AddWithValue("@CheckID", checkID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.Remove", ex);
throw new DbCslaException("RevisionROCheck.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int checkID)
{
ExistsCommand result;
try
{
result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(checkID));
return result.Exists;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheck.Exists", ex);
}
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _CheckID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int checkID)
{
_CheckID = checkID;
}
protected override void DataPortal_Execute()
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.DataPortal_Execute", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsRevisionROCheck";
cm.Parameters.AddWithValue("@CheckID", _CheckID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.DataPortal_Execute", ex);
throw new DbCslaException("RevisionROCheck.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
RevisionROCheckExtension _RevisionROCheckExtension = new RevisionROCheckExtension();
[Serializable()]
partial class RevisionROCheckExtension : 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 RevisionROCheckConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionROCheck)
{
// Return the ToString value
return ((RevisionROCheck)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RevisionROCheckExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS_.CSLA.Library
//{
// public partial class RevisionROCheck
// {
// partial class RevisionROCheckExtension : 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,334 @@
// ========================================================================
// 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 RevisionROCheckInfoEvent(object sender);
/// <summary>
/// RevisionROCheckInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionROCheckInfoConverter))]
public partial class RevisionROCheckInfo : ReadOnlyBase<RevisionROCheckInfo>, IDisposable
{
public event RevisionROCheckInfoEvent 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<RevisionROCheckInfo> _CacheList = new List<RevisionROCheckInfo>();
protected static void AddToCache(RevisionROCheckInfo revisionROCheckInfo)
{
if (!_CacheList.Contains(revisionROCheckInfo)) _CacheList.Add(revisionROCheckInfo); // In AddToCache
}
protected static void RemoveFromCache(RevisionROCheckInfo revisionROCheckInfo)
{
while (_CacheList.Contains(revisionROCheckInfo)) _CacheList.Remove(revisionROCheckInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RevisionROCheckInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RevisionROCheckInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move RevisionROCheckInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
RevisionROCheckInfo tmp = _CacheList[0]; // Get the first RevisionROCheckInfo
string pKey = tmp.CheckID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<RevisionROCheckInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first RevisionROCheckInfo
}
}
internal static void AddList(RevisionROCheckInfoList lst)
{
foreach (RevisionROCheckInfo item in lst) AddToCache(item);
}
protected static RevisionROCheckInfo GetCachedByPrimaryKey(int checkID)
{
ConvertListToDictionary();
string key = checkID.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 RevisionROCheck _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _CheckID;
[System.ComponentModel.DataObjectField(true, true)]
public int CheckID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("CheckID", true);
return _CheckID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
}
private int _ROID;
public int ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROID", true);
return _ROID;
}
}
private string _RODate = string.Empty;
public string RODate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODate", true);
return _RODate;
}
}
private string _ROValue = string.Empty;
public string ROValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROValue", true);
return _ROValue;
}
}
// CSLATODO: Replace base RevisionROCheckInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RevisionROCheckInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check RevisionROCheckInfo.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 RevisionROCheckInfo</returns>
protected override object GetIdValue()
{
return MyRevisionROCheckInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _RevisionROCheckInfoUnique = 0;
private static int RevisionROCheckInfoUnique
{ get { return ++_RevisionROCheckInfoUnique; } }
private int _MyRevisionROCheckInfoUnique = RevisionROCheckInfoUnique;
public int MyRevisionROCheckInfoUnique // Absolutely Unique ID - Info
{ get { return _MyRevisionROCheckInfoUnique; } }
protected RevisionROCheckInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(CheckID.ToString())) return;
List<RevisionROCheckInfo> listRevisionROCheckInfo = _CacheByPrimaryKey[CheckID.ToString()]; // Get the list of items
while (listRevisionROCheckInfo.Contains(this)) listRevisionROCheckInfo.Remove(this); // Remove the item from the list
if (listRevisionROCheckInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(CheckID.ToString()); // remove the list
}
public virtual RevisionROCheck Get()
{
return _Editable = RevisionROCheck.Get(_CheckID);
}
public static void Refresh(RevisionROCheck tmp)
{
string key = tmp.CheckID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RevisionROCheckInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RevisionROCheck tmp)
{
_ItemID = tmp.ItemID;
_ROID = tmp.ROID;
_RODate = tmp.RODate;
_ROValue = tmp.ROValue;
_RevisionROCheckInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static RevisionROCheckInfo Get(int checkID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a RevisionROCheck");
try
{
RevisionROCheckInfo tmp = GetCachedByPrimaryKey(checkID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RevisionROCheckInfo>(new PKCriteria(checkID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RevisionROCheckInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheckInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RevisionROCheckInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheckInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheckInfo.Constructor", ex);
throw new DbCslaException("RevisionROCheckInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _CheckID;
public int CheckID
{ get { return _CheckID; } }
public PKCriteria(int checkID)
{
_CheckID = checkID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheckInfo.ReadData", GetHashCode());
try
{
_CheckID = dr.GetInt32("CheckID");
_ItemID = dr.GetInt32("ItemID");
_ROID = dr.GetInt32("ROID");
_RODate = dr.GetSmartDate("RODate").Text;
_ROValue = dr.GetString("ROValue");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheckInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheckInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheckInfo.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 = "getRevisionROCheck";
cm.Parameters.AddWithValue("@CheckID", criteria.CheckID);
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("RevisionROCheckInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheckInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RevisionROCheckInfoExtension _RevisionROCheckInfoExtension = new RevisionROCheckInfoExtension();
[Serializable()]
partial class RevisionROCheckInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RevisionROCheckInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RevisionROCheckInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionROCheckInfo)
{
// Return the ToString value
return ((RevisionROCheckInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace