Object support for approval

changes to support approval process
changes to limit menu to appropriate version of code
changes to support consistency check report
This commit is contained in:
Rich 2012-01-23 13:51:04 +00:00
parent 42c8501927
commit 3153ffb024
25 changed files with 11132 additions and 6 deletions

View File

@ -277,6 +277,20 @@ namespace VEPROMS.CSLA.Library
tmp.ID = -1;
return tmp;
}
public string GetROTitle(string ROID)
{
StringBuilder sb = new StringBuilder();
rochild roc = GetRoChild12(ROID);
sb.Append(roc.title.Replace(roc.appid,"").Replace(roc.value,"").Trim());
do
{
string parent = ROID.Substring(0, 4) + string.Format("{0:X8}", roc.ParentID);
roc = GetRoChild12(parent);
if (roc.ID > 0)
sb.Insert(0, roc.title + " - ");
} while (roc.ID > 0);
return sb.ToString();
}
// The following Method is not correct. It needs to have a RO database id as well as an id. Without that,
// the first RO with a specific id will be found regardless of the RO Database id.
//public rochild GetRoChildFromID(int id)

View File

@ -637,6 +637,7 @@ namespace VEPROMS.CSLA.Library
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(annotation);//Refresh the item in AllList
ProcessRefreshList();
AnnotationInfo.StaticOnInfoChanged();
return annotation;
}
catch (Exception ex)

View File

@ -27,10 +27,23 @@ namespace VEPROMS.CSLA.Library
[TypeConverter(typeof(AnnotationInfoConverter))]
public partial class AnnotationInfo : ReadOnlyBase<AnnotationInfo>, IDisposable
{
public static event AnnotationInfoEvent InfoChanged;
internal void OnInfoChanged(AnnotationInfo annotationInfo)
{
if (InfoChanged != null)
InfoChanged(this);
}
internal static void StaticOnInfoChanged()
{
if (InfoChanged != null)
InfoChanged(null);
}
public event AnnotationInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
if (Changed != null)
Changed(this);
OnInfoChanged(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,476 @@
// ========================================================================
// 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 CheckInfoEvent(object sender);
/// <summary>
/// CheckInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(CheckInfoConverter))]
public partial class CheckInfo : ReadOnlyBase<CheckInfo>, IDisposable
{
public event CheckInfoEvent 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<CheckInfo> _CacheList = new List<CheckInfo>();
protected static void AddToCache(CheckInfo checkInfo)
{
if (!_CacheList.Contains(checkInfo)) _CacheList.Add(checkInfo); // In AddToCache
}
protected static void RemoveFromCache(CheckInfo checkInfo)
{
while (_CacheList.Contains(checkInfo)) _CacheList.Remove(checkInfo); // In RemoveFromCache
}
private static Dictionary<string, List<CheckInfo>> _CacheByPrimaryKey = new Dictionary<string, List<CheckInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move CheckInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
CheckInfo tmp = _CacheList[0]; // Get the first CheckInfo
string pKey = tmp.CheckID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<CheckInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first CheckInfo
}
}
internal static void AddList(CheckInfoList lst)
{
foreach (CheckInfo item in lst) AddToCache(item);
}
protected static CheckInfo 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 Check _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 _RevisionID;
public int RevisionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionID", true);
if (_MyRevision != null) _RevisionID = _MyRevision.RevisionID;
return _RevisionID;
}
}
private RevisionInfo _MyRevision;
public RevisionInfo MyRevision
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRevision", true);
if (_MyRevision == null && _RevisionID != 0) _MyRevision = RevisionInfo.Get(_RevisionID);
return _MyRevision;
}
}
private int _StageID;
public int StageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageID", true);
if (_MyStage != null) _StageID = _MyStage.StageID;
return _StageID;
}
}
private StageInfo _MyStage;
public StageInfo MyStage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyStage", true);
if (_MyStage == null && _StageID != 0) _MyStage = StageInfo.Get(_StageID);
return _MyStage;
}
}
private string _ConsistencyChecks = string.Empty;
public string ConsistencyChecks
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConsistencyChecks", true);
return _ConsistencyChecks;
}
}
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;
}
}
// CSLATODO: Replace base CheckInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current CheckInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check CheckInfo.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 CheckInfo</returns>
protected override object GetIdValue()
{
return MyCheckInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _CheckInfoUnique = 0;
private static int CheckInfoUnique
{ get { return ++_CheckInfoUnique; } }
private int _MyCheckInfoUnique = CheckInfoUnique;
public int MyCheckInfoUnique // Absolutely Unique ID - Info
{ get { return _MyCheckInfoUnique; } }
protected CheckInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(CheckID.ToString())) return;
List<CheckInfo> listCheckInfo = _CacheByPrimaryKey[CheckID.ToString()]; // Get the list of items
while (listCheckInfo.Contains(this)) listCheckInfo.Remove(this); // Remove the item from the list
if (listCheckInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(CheckID.ToString()); // remove the list
}
public virtual Check Get()
{
return _Editable = Check.Get(_CheckID);
}
public static void Refresh(Check tmp)
{
string key = tmp.CheckID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Check tmp)
{
if (_RevisionID != tmp.RevisionID)
{
if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for old value
_RevisionID = tmp.RevisionID; // Update the value
}
_MyRevision = null; // Reset list so that the next line gets a new list
if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for new value
if (_StageID != tmp.StageID)
{
if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for old value
_StageID = tmp.StageID; // Update the value
}
_MyStage = null; // Reset list so that the next line gets a new list
if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for new value
_ConsistencyChecks = tmp.ConsistencyChecks;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_CheckInfoExtension.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(_MyRevision != null)
// {
// _MyRevision.Dispose();// Dispose related value
// _MyRevision = 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(_MyStage != null)
// {
// _MyStage.Dispose();// Dispose related value
// _MyStage = null;// Reset related value
// }
OnChange();// raise an event
}
public static void Refresh(RevisionCheck tmp)
{
string key = tmp.CheckID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RevisionCheck tmp)
{
if (_StageID != tmp.StageID)
{
if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for old value
_StageID = tmp.StageID; // Update the value
}
_MyStage = null; // Reset list so that the next line gets a new list
if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for new value
_ConsistencyChecks = tmp.ConsistencyChecks;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_CheckInfoExtension.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(_MyRevision != null)
// {
// _MyRevision.Dispose();// Dispose related value
// _MyRevision = 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(_MyStage != null)
// {
// _MyStage.Dispose();// Dispose related value
// _MyStage = null;// Reset related value
// }
OnChange();// raise an event
}
public static void Refresh(StageCheck tmp)
{
string key = tmp.CheckID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(StageCheck tmp)
{
if (_RevisionID != tmp.RevisionID)
{
if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for old value
_RevisionID = tmp.RevisionID; // Update the value
}
_MyRevision = null; // Reset list so that the next line gets a new list
if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for new value
_ConsistencyChecks = tmp.ConsistencyChecks;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_CheckInfoExtension.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(_MyRevision != null)
// {
// _MyRevision.Dispose();// Dispose related value
// _MyRevision = 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(_MyStage != null)
// {
// _MyStage.Dispose();// Dispose related value
// _MyStage = null;// Reset related value
// }
OnChange();// raise an event
}
public static CheckInfo Get(int checkID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Check");
try
{
CheckInfo tmp = GetCachedByPrimaryKey(checkID);
if (tmp == null)
{
tmp = DataPortal.Fetch<CheckInfo>(new PKCriteria(checkID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up CheckInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CheckInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal CheckInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfo.Constructor", ex);
throw new DbCslaException("CheckInfo.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}] CheckInfo.ReadData", GetHashCode());
try
{
_CheckID = dr.GetInt32("CheckID");
_RevisionID = dr.GetInt32("RevisionID");
_StageID = dr.GetInt32("StageID");
_ConsistencyChecks = dr.GetString("ConsistencyChecks");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("CheckInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfo.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 = "getCheck";
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("CheckInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("CheckInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
CheckInfoExtension _CheckInfoExtension = new CheckInfoExtension();
[Serializable()]
partial class CheckInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(CheckInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class CheckInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is CheckInfo)
{
// Return the ToString value
return ((CheckInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,319 @@
// ========================================================================
// 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>
/// CheckInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(CheckInfoListConverter))]
public partial class CheckInfoList : ReadOnlyListBase<CheckInfoList, CheckInfo>, 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<CheckInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (CheckInfo tmp in this)
{
tmp.Changed += new CheckInfoEvent(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 (CheckInfo tmp in this)
{
tmp.Changed -= new CheckInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static CheckInfoList _CheckInfoList = null;
/// <summary>
/// Return a list of all CheckInfo.
/// </summary>
public static CheckInfoList Get()
{
try
{
if (_CheckInfoList != null)
return _CheckInfoList;
CheckInfoList tmp = DataPortal.Fetch<CheckInfoList>();
CheckInfo.AddList(tmp);
tmp.AddEvents();
_CheckInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CheckInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all CheckInfo.
/// </summary>
public static void Reset()
{
_CheckInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static CheckInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<CheckInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on CheckInfoList.Get", ex);
// }
//}
public static CheckInfoList GetByRevisionID(int revisionID)
{
try
{
CheckInfoList tmp = DataPortal.Fetch<CheckInfoList>(new RevisionIDCriteria(revisionID));
CheckInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CheckInfoList.GetByRevisionID", ex);
}
}
public static CheckInfoList GetByStageID(int stageID)
{
try
{
CheckInfoList tmp = DataPortal.Fetch<CheckInfoList>(new StageIDCriteria(stageID));
CheckInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CheckInfoList.GetByStageID", ex);
}
}
private CheckInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getChecks";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new CheckInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("CheckInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RevisionIDCriteria
{
public RevisionIDCriteria(int revisionID)
{
_RevisionID = revisionID;
}
private int _RevisionID;
public int RevisionID
{
get { return _RevisionID; }
set { _RevisionID = value; }
}
}
private void DataPortal_Fetch(RevisionIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfoList.DataPortal_FetchRevisionID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getChecksByRevisionID";
cm.Parameters.AddWithValue("@RevisionID", criteria.RevisionID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new CheckInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfoList.DataPortal_FetchRevisionID", ex);
throw new DbCslaException("CheckInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StageIDCriteria
{
public StageIDCriteria(int stageID)
{
_StageID = stageID;
}
private int _StageID;
public int StageID
{
get { return _StageID; }
set { _StageID = value; }
}
}
private void DataPortal_Fetch(StageIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfoList.DataPortal_FetchStageID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getChecksByStageID";
cm.Parameters.AddWithValue("@StageID", criteria.StageID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new CheckInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfoList.DataPortal_FetchStageID", ex);
throw new DbCslaException("CheckInfoList.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
CheckInfoListPropertyDescriptor pd = new CheckInfoListPropertyDescriptor(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 CheckInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private CheckInfo Item { get { return (CheckInfo)_Item; } }
public CheckInfoListPropertyDescriptor(CheckInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class CheckInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is CheckInfoList)
{
// Return department and department role separated by comma.
return ((CheckInfoList)value).Items.Count.ToString() + " Checks";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -37,10 +37,8 @@ namespace VEPROMS.CSLA.Library
private void OnChange(ContentInfo contentInfo)
{
if (Changed != null)
{
Changed(this);
OnInfoChanged(this);
}
OnInfoChanged(this);
}
private void OnChange()
{

View File

@ -107,7 +107,8 @@ namespace VEPROMS.CSLA.Library
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 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();
@ -119,7 +120,8 @@ namespace VEPROMS.CSLA.Library
tsmi.Font = new System.Drawing.Font(tsmi.Font, System.Drawing.FontStyle.Bold);
foreach (DataRow dr in ds.Tables[0].Rows)
{
cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
if(dr["functionality"].ToString() == "Approval")
cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
}
while (_SelectedDatabase == null)
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,554 @@
// ========================================================================
// 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>
/// RevisionCheck Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionCheckConverter))]
public partial class RevisionCheck : BusinessBase<RevisionCheck>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _CheckID;
[System.ComponentModel.DataObjectField(true, true)]
public int CheckID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("CheckID", true);
if (_MyCheck != null) _CheckID = _MyCheck.CheckID;
return _CheckID;
}
}
private Check _MyCheck;
[System.ComponentModel.DataObjectField(true, true)]
public Check MyCheck
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyCheck", true);
if (_MyCheck == null && _CheckID != 0) _MyCheck = Check.Get(_CheckID);
return _MyCheck;
}
}
private int _StageID;
public int StageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageID", true);
if (_MyStage != null) _StageID = _MyStage.StageID;
return _StageID;
}
}
private Stage _MyStage;
public Stage MyStage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyStage", true);
if (_MyStage == null && _StageID != 0) _MyStage = Stage.Get(_StageID);
return _MyStage;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyStage", true);
if (_MyStage != value)
{
_MyStage = value;
_StageID = value.StageID;// Update underlying data field
PropertyHasChanged();
}
}
}
private string _ConsistencyChecks = string.Empty;
public string ConsistencyChecks
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConsistencyChecks", true);
return _ConsistencyChecks;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ConsistencyChecks", true);
if (value == null) value = string.Empty;
if (_ConsistencyChecks != value)
{
_ConsistencyChecks = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Stage_Name = string.Empty;
public string Stage_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_Name", true);
return _Stage_Name;
}
}
private string _Stage_Description = string.Empty;
public string Stage_Description
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_Description", true);
return _Stage_Description;
}
}
private int _Stage_IsApproved;
public int Stage_IsApproved
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_IsApproved", true);
return _Stage_IsApproved;
}
}
private DateTime _Stage_DTS = new DateTime();
public DateTime Stage_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_DTS", true);
return _Stage_DTS;
}
}
private string _Stage_UserID = string.Empty;
public string Stage_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_UserID", true);
return _Stage_UserID;
}
}
// CSLATODO: Check RevisionCheck.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 RevisionCheck</returns>
protected override object GetIdValue()
{
return MyRevisionCheckUnique; // Absolutely Unique ID
}
// CSLATODO: Replace base RevisionCheck.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RevisionCheck</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get
{
if ( base.IsDirty )
return true;
return IsDirtyList(new List<object>());
}
}
public bool IsDirtyList(List<object> list)
{
if (base.IsDirty || list.Contains(this))
return base.IsDirty;
list.Add(this);
return base.IsDirty || (_MyStage == null ? false : _MyStage.IsDirtyList(list));
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> list)
{
if(list.Contains(this))
return (IsNew && !IsDirty) ? true : base.IsValid;
list.Add(this);
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyStage == null ? true : _MyStage.IsValidList(list));
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyStage != null && (hasBrokenRules = _MyStage.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<RevisionCheck>(MyStageRequired, "MyStage");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ConsistencyChecks", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// CSLATODO: Add other validation rules
}
private static bool MyStageRequired(RevisionCheck target, Csla.Validation.RuleArgs e)
{
if (target._StageID == 0 && target._MyStage == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
//AuthorizationRules.AllowRead(CheckID, "<Role(s)>");
//AuthorizationRules.AllowRead(StageID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StageID, "<Role(s)>");
//AuthorizationRules.AllowRead(ConsistencyChecks, "<Role(s)>");
//AuthorizationRules.AllowWrite(ConsistencyChecks, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
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 _RevisionCheckUnique = 0;
private static int RevisionCheckUnique
{ get { return ++_RevisionCheckUnique; } }
private int _MyRevisionCheckUnique = RevisionCheckUnique;
public int MyRevisionCheckUnique // Absolutely Unique ID - Editable FK
{ get { return _MyRevisionCheckUnique; } }
internal static RevisionCheck New(Stage myStage)
{
return new RevisionCheck(myStage);
}
internal static RevisionCheck Get(SafeDataReader dr)
{
return new RevisionCheck(dr);
}
public RevisionCheck()
{
MarkAsChild();
_CheckID = Check.NextCheckID;
_DTS = _RevisionCheckExtension.DefaultDTS;
_UserID = _RevisionCheckExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private RevisionCheck(Stage myStage)
{
MarkAsChild();
// CSLATODO: Add any initialization & defaults
_CheckID = Check.NextCheckID;
_DTS = _RevisionCheckExtension.DefaultDTS;
_UserID = _RevisionCheckExtension.DefaultUserID;
_MyStage = myStage;
ValidationRules.CheckRules();
}
internal RevisionCheck(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionCheck.FetchDR", GetHashCode());
try
{
_CheckID = dr.GetInt32("CheckID");
_StageID = dr.GetInt32("StageID");
_ConsistencyChecks = dr.GetString("ConsistencyChecks");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Stage_Name = dr.GetString("Stage_Name");
_Stage_Description = dr.GetString("Stage_Description");
_Stage_IsApproved = dr.GetInt32("Stage_IsApproved");
_Stage_DTS = dr.GetDateTime("Stage_DTS");
_Stage_UserID = dr.GetString("Stage_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionCheck.FetchDR", ex);
throw new DbCslaException("RevisionCheck.Fetch", ex);
}
MarkOld();
}
internal void Insert(Revision myRevision)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Check.Add(cn, ref _CheckID, myRevision, _MyStage, _ConsistencyChecks, _DTS, _UserID);
MarkOld();
}
internal void Update(Revision myRevision)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Check.Update(cn, ref _CheckID, myRevision.RevisionID, _StageID, _ConsistencyChecks, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Revision myRevision)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Check.Remove(cn, _CheckID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RevisionCheckExtension _RevisionCheckExtension = new RevisionCheckExtension();
[Serializable()]
partial class RevisionCheckExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class RevisionCheckConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionCheck)
{
// Return the ToString value
return ((RevisionCheck)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RevisionCheckExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class RevisionCheck
// {
// partial class RevisionCheckExtension : extensionBase
// {
// // CSLATODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@ -0,0 +1,322 @@
// ========================================================================
// 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>
/// RevisionChecks Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionChecksConverter))]
public partial class RevisionChecks : BusinessListBase<RevisionChecks, RevisionCheck>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public RevisionCheck this[Check myCheck]
{
get
{
foreach (RevisionCheck check in this)
if (check.CheckID == myCheck.CheckID)
return check;
return null;
}
}
public new System.Collections.Generic.IList<RevisionCheck> Items
{
get { return base.Items; }
}
public RevisionCheck GetItem(Check myCheck)
{
foreach (RevisionCheck check in this)
if (check.CheckID == myCheck.CheckID)
return check;
return null;
}
public RevisionCheck Add(Stage myStage) // One to Many
{
RevisionCheck check = RevisionCheck.New(myStage);
this.Add(check);
return check;
}
public void Remove(Check myCheck)
{
foreach (RevisionCheck check in this)
{
if (check.CheckID == myCheck.CheckID)
{
Remove(check);
break;
}
}
}
public bool Contains(Check myCheck)
{
foreach (RevisionCheck check in this)
if (check.CheckID == myCheck.CheckID)
return true;
return false;
}
public bool ContainsDeleted(Check myCheck)
{
foreach (RevisionCheck check in DeletedList)
if (check.CheckID == myCheck.CheckID)
return true;
return false;
}
public bool IsDirtyList(List<object> list)
{
// any non-new deletions make us dirty
foreach (RevisionCheck item in DeletedList)
if (!item.IsNew)
return true;
// run through all the child objects
// and if any are dirty then then
// collection is dirty
foreach (RevisionCheck child in this)
if (child.IsDirtyList(list))
return true;
return false;
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> list)
{
// run through all the child objects
// and if any are invalid then the
// collection is invalid
foreach (RevisionCheck child in this)
if (!child.IsValidList(list))
{
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
return false;
}
return true;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (RevisionCheck revisionCheck in this)
if ((hasBrokenRules = revisionCheck.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static RevisionChecks New()
{
return new RevisionChecks();
}
internal static RevisionChecks Get(SafeDataReader dr)
{
return new RevisionChecks(dr);
}
public static RevisionChecks GetByRevisionID(int revisionID)
{
try
{
return DataPortal.Fetch<RevisionChecks>(new RevisionIDCriteria(revisionID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionChecks.GetByRevisionID", ex);
}
}
private RevisionChecks()
{
MarkAsChild();
}
internal RevisionChecks(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(RevisionCheck.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RevisionIDCriteria
{
public RevisionIDCriteria(int revisionID)
{
_RevisionID = revisionID;
}
private int _RevisionID;
public int RevisionID
{
get { return _RevisionID; }
set { _RevisionID = value; }
}
}
private void DataPortal_Fetch(RevisionIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionChecks.DataPortal_FetchRevisionID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getChecksByRevisionID";
cm.Parameters.AddWithValue("@RevisionID", criteria.RevisionID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new RevisionCheck(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionChecks.DataPortal_FetchRevisionID", ex);
throw new DbCslaException("RevisionChecks.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Revision revision)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (RevisionCheck obj in DeletedList)
obj.DeleteSelf(revision);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (RevisionCheck obj in this)
{
if (obj.IsNew)
obj.Insert(revision);
else
obj.Update(revision);
}
}
finally
{
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
RevisionChecksPropertyDescriptor pd = new RevisionChecksPropertyDescriptor(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 RevisionChecksPropertyDescriptor : vlnListPropertyDescriptor
{
private RevisionCheck Item { get { return (RevisionCheck)_Item; } }
public RevisionChecksPropertyDescriptor(RevisionChecks collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class RevisionChecksConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionChecks)
{
// Return department and department role separated by comma.
return ((RevisionChecks)value).Items.Count.ToString() + " Checks";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,460 @@
// ========================================================================
// 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 RevisionInfoEvent(object sender);
/// <summary>
/// RevisionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionInfoConverter))]
public partial class RevisionInfo : ReadOnlyBase<RevisionInfo>, IDisposable
{
public event RevisionInfoEvent 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<RevisionInfo> _CacheList = new List<RevisionInfo>();
protected static void AddToCache(RevisionInfo revisionInfo)
{
if (!_CacheList.Contains(revisionInfo)) _CacheList.Add(revisionInfo); // In AddToCache
}
protected static void RemoveFromCache(RevisionInfo revisionInfo)
{
while (_CacheList.Contains(revisionInfo)) _CacheList.Remove(revisionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RevisionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RevisionInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move RevisionInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
RevisionInfo tmp = _CacheList[0]; // Get the first RevisionInfo
string pKey = tmp.RevisionID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<RevisionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first RevisionInfo
}
}
internal static void AddList(RevisionInfoList lst)
{
foreach (RevisionInfo item in lst) AddToCache(item);
}
protected static RevisionInfo GetCachedByPrimaryKey(int revisionID)
{
ConvertListToDictionary();
string key = revisionID.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 Revision _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _RevisionID;
[System.ComponentModel.DataObjectField(true, true)]
public int RevisionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionID", true);
return _RevisionID;
}
}
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 _RevisionNumber = string.Empty;
public string RevisionNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionNumber", true);
return _RevisionNumber;
}
}
private DateTime? _RevisionDate;
public DateTime? RevisionDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionDate", true);
return _RevisionDate;
}
}
private string _Notes = string.Empty;
public string Notes
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Notes", true);
return _Notes;
}
}
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 _RevisionCheckCount = 0;
/// <summary>
/// Count of RevisionChecks for this Revision
/// </summary>
public int RevisionCheckCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionCheckCount", true);
if (_RevisionCheckCount < 0)
_RevisionCheckCount = RevisionChecks.Count;
return _RevisionCheckCount;
}
}
private CheckInfoList _RevisionChecks = null;
[TypeConverter(typeof(CheckInfoListConverter))]
public CheckInfoList RevisionChecks
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionChecks", true);
if (_RevisionCheckCount < 0 || (_RevisionCheckCount > 0 && _RevisionChecks == null))
_RevisionChecks = CheckInfoList.GetByRevisionID(_RevisionID);
if (_RevisionCheckCount < 0)
_RevisionCheckCount = _RevisionChecks.Count;
return _RevisionChecks;
}
}
public void RefreshRevisionChecks()
{
_RevisionCheckCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RevisionID.ToString()))
foreach (RevisionInfo tmp in _CacheByPrimaryKey[_RevisionID.ToString()])
tmp._RevisionCheckCount = -1; // This will cause the data to be requeried
}
private int _RevisionVersionCount = 0;
/// <summary>
/// Count of RevisionVersions for this Revision
/// </summary>
public int RevisionVersionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionVersionCount", true);
if (_RevisionVersionCount < 0)
_RevisionVersionCount = RevisionVersions.Count;
return _RevisionVersionCount;
}
}
private VersionInfoList _RevisionVersions = null;
[TypeConverter(typeof(VersionInfoListConverter))]
public VersionInfoList RevisionVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionVersions", true);
if (_RevisionVersionCount < 0 || (_RevisionVersionCount > 0 && _RevisionVersions == null))
_RevisionVersions = VersionInfoList.GetByRevisionID(_RevisionID);
if (_RevisionVersionCount < 0)
_RevisionVersionCount = _RevisionVersions.Count;
return _RevisionVersions;
}
}
public void RefreshRevisionVersions()
{
_RevisionVersionCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RevisionID.ToString()))
foreach (RevisionInfo tmp in _CacheByPrimaryKey[_RevisionID.ToString()])
tmp._RevisionVersionCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base RevisionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RevisionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check RevisionInfo.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 RevisionInfo</returns>
protected override object GetIdValue()
{
return MyRevisionInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _RevisionInfoUnique = 0;
private static int RevisionInfoUnique
{ get { return ++_RevisionInfoUnique; } }
private int _MyRevisionInfoUnique = RevisionInfoUnique;
public int MyRevisionInfoUnique // Absolutely Unique ID - Info
{ get { return _MyRevisionInfoUnique; } }
protected RevisionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(RevisionID.ToString())) return;
List<RevisionInfo> listRevisionInfo = _CacheByPrimaryKey[RevisionID.ToString()]; // Get the list of items
while (listRevisionInfo.Contains(this)) listRevisionInfo.Remove(this); // Remove the item from the list
if (listRevisionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(RevisionID.ToString()); // remove the list
}
public virtual Revision Get()
{
return _Editable = Revision.Get(_RevisionID);
}
public static void Refresh(Revision tmp)
{
string key = tmp.RevisionID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RevisionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Revision tmp)
{
_ItemID = tmp.ItemID;
_TypeID = tmp.TypeID;
_RevisionNumber = tmp.RevisionNumber;
_RevisionDate = tmp.RevisionDate;
_Notes = tmp.Notes;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_RevisionInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static RevisionInfo Get(int revisionID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Revision");
try
{
RevisionInfo tmp = GetCachedByPrimaryKey(revisionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RevisionInfo>(new PKCriteria(revisionID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RevisionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RevisionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionInfo.Constructor", ex);
throw new DbCslaException("RevisionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _RevisionID;
public int RevisionID
{ get { return _RevisionID; } }
public PKCriteria(int revisionID)
{
_RevisionID = revisionID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionInfo.ReadData", GetHashCode());
try
{
_RevisionID = dr.GetInt32("RevisionID");
_ItemID = dr.GetInt32("ItemID");
_TypeID = dr.GetInt32("TypeID");
_RevisionNumber = dr.GetString("RevisionNumber");
if (!dr.IsDBNull(dr.GetOrdinal("RevisionDate"))) _RevisionDate = dr.GetDateTime("RevisionDate");
_Notes = dr.GetString("Notes");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_RevisionCheckCount = dr.GetInt32("CheckCount");
_RevisionVersionCount = dr.GetInt32("VersionCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionInfo.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 = "getRevision";
cm.Parameters.AddWithValue("@RevisionID", criteria.RevisionID);
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("RevisionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RevisionInfoExtension _RevisionInfoExtension = new RevisionInfoExtension();
[Serializable()]
partial class RevisionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RevisionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RevisionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionInfo)
{
// Return the ToString value
return ((RevisionInfo)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>
/// RevisionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionInfoListConverter))]
public partial class RevisionInfoList : ReadOnlyListBase<RevisionInfoList, RevisionInfo>, 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<RevisionInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (RevisionInfo tmp in this)
{
tmp.Changed += new RevisionInfoEvent(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 (RevisionInfo tmp in this)
{
tmp.Changed -= new RevisionInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static RevisionInfoList _RevisionInfoList = null;
/// <summary>
/// Return a list of all RevisionInfo.
/// </summary>
public static RevisionInfoList Get()
{
try
{
if (_RevisionInfoList != null)
return _RevisionInfoList;
RevisionInfoList tmp = DataPortal.Fetch<RevisionInfoList>();
RevisionInfo.AddList(tmp);
tmp.AddEvents();
_RevisionInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all RevisionInfo.
/// </summary>
public static void Reset()
{
_RevisionInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static RevisionInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<RevisionInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on RevisionInfoList.Get", ex);
// }
//}
private RevisionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRevisions";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new RevisionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("RevisionInfoList.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
RevisionInfoListPropertyDescriptor pd = new RevisionInfoListPropertyDescriptor(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 RevisionInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private RevisionInfo Item { get { return (RevisionInfo)_Item; } }
public RevisionInfoListPropertyDescriptor(RevisionInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class RevisionInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionInfoList)
{
// Return department and department role separated by comma.
return ((RevisionInfoList)value).Items.Count.ToString() + " Revisions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,557 @@
// ========================================================================
// 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>
/// RevisionVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionVersionConverter))]
public partial class RevisionVersion : BusinessBase<RevisionVersion>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionID", true);
if (_MyVersion != null) _VersionID = _MyVersion.VersionID;
return _VersionID;
}
}
private Version _MyVersion;
[System.ComponentModel.DataObjectField(true, true)]
public Version MyVersion
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyVersion", true);
if (_MyVersion == null && _VersionID != 0) _MyVersion = Version.Get(_VersionID);
return _MyVersion;
}
}
private int _StageID;
public int StageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageID", true);
if (_MyStage != null) _StageID = _MyStage.StageID;
return _StageID;
}
}
private Stage _MyStage;
public Stage MyStage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyStage", true);
if (_MyStage == null && _StageID != 0) _MyStage = Stage.Get(_StageID);
return _MyStage;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyStage", true);
if (_MyStage != value)
{
_MyStage = value;
_StageID = value.StageID;// Update underlying data field
PropertyHasChanged();
}
}
}
private byte[] _PDF;
public byte[] PDF
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PDF", true);
return _PDF;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("PDF", true);
if (_PDF != value)
{
_PDF = value;
PropertyHasChanged();
}
}
}
private byte[] _SummaryPDF;
public byte[] SummaryPDF
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SummaryPDF", true);
return _SummaryPDF;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("SummaryPDF", true);
if (_SummaryPDF != value)
{
_SummaryPDF = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Stage_Name = string.Empty;
public string Stage_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_Name", true);
return _Stage_Name;
}
}
private string _Stage_Description = string.Empty;
public string Stage_Description
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_Description", true);
return _Stage_Description;
}
}
private int _Stage_IsApproved;
public int Stage_IsApproved
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_IsApproved", true);
return _Stage_IsApproved;
}
}
private DateTime _Stage_DTS = new DateTime();
public DateTime Stage_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_DTS", true);
return _Stage_DTS;
}
}
private string _Stage_UserID = string.Empty;
public string Stage_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Stage_UserID", true);
return _Stage_UserID;
}
}
// CSLATODO: Check RevisionVersion.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 RevisionVersion</returns>
protected override object GetIdValue()
{
return MyRevisionVersionUnique; // Absolutely Unique ID
}
// CSLATODO: Replace base RevisionVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RevisionVersion</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get
{
if ( base.IsDirty )
return true;
return IsDirtyList(new List<object>());
}
}
public bool IsDirtyList(List<object> list)
{
if (base.IsDirty || list.Contains(this))
return base.IsDirty;
list.Add(this);
return base.IsDirty || (_MyStage == null ? false : _MyStage.IsDirtyList(list));
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> list)
{
if(list.Contains(this))
return (IsNew && !IsDirty) ? true : base.IsValid;
list.Add(this);
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyStage == null ? true : _MyStage.IsValidList(list));
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyStage != null && (hasBrokenRules = _MyStage.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<RevisionVersion>(MyStageRequired, "MyStage");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 200));
// CSLATODO: Add other validation rules
}
private static bool MyStageRequired(RevisionVersion target, Csla.Validation.RuleArgs e)
{
if (target._StageID == 0 && target._MyStage == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(StageID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StageID, "<Role(s)>");
//AuthorizationRules.AllowRead(PDF, "<Role(s)>");
//AuthorizationRules.AllowWrite(PDF, "<Role(s)>");
//AuthorizationRules.AllowRead(SummaryPDF, "<Role(s)>");
//AuthorizationRules.AllowWrite(SummaryPDF, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
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 _RevisionVersionUnique = 0;
private static int RevisionVersionUnique
{ get { return ++_RevisionVersionUnique; } }
private int _MyRevisionVersionUnique = RevisionVersionUnique;
public int MyRevisionVersionUnique // Absolutely Unique ID - Editable FK
{ get { return _MyRevisionVersionUnique; } }
internal static RevisionVersion New(Stage myStage, DateTime dts, string userID)
{
return new RevisionVersion(myStage, dts, userID);
}
internal static RevisionVersion Get(SafeDataReader dr)
{
return new RevisionVersion(dr);
}
public RevisionVersion()
{
MarkAsChild();
_VersionID = Version.NextVersionID;
ValidationRules.CheckRules();
}
private RevisionVersion(Stage myStage, DateTime dts, string userID)
{
MarkAsChild();
// CSLATODO: Add any initialization & defaults
_VersionID = Version.NextVersionID;
_MyStage = myStage;
_DTS = dts;
_UserID = userID;
ValidationRules.CheckRules();
}
internal RevisionVersion(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionVersion.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_StageID = dr.GetInt32("StageID");
_PDF = (byte[])dr.GetValue("PDF");
_SummaryPDF = (byte[])dr.GetValue("SummaryPDF");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Stage_Name = dr.GetString("Stage_Name");
_Stage_Description = dr.GetString("Stage_Description");
_Stage_IsApproved = dr.GetInt32("Stage_IsApproved");
_Stage_DTS = dr.GetDateTime("Stage_DTS");
_Stage_UserID = dr.GetString("Stage_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionVersion.FetchDR", ex);
throw new DbCslaException("RevisionVersion.Fetch", ex);
}
MarkOld();
}
internal void Insert(Revision myRevision)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Version.Add(cn, ref _VersionID, myRevision, _MyStage, _PDF, _SummaryPDF, _DTS, _UserID);
MarkOld();
}
internal void Update(Revision myRevision)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Version.Update(cn, ref _VersionID, myRevision.RevisionID, _StageID, _PDF, _SummaryPDF, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Revision myRevision)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Version.Remove(cn, _VersionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RevisionVersionExtension _RevisionVersionExtension = new RevisionVersionExtension();
[Serializable()]
partial class RevisionVersionExtension : 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 RevisionVersionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionVersion)
{
// Return the ToString value
return ((RevisionVersion)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RevisionVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class RevisionVersion
// {
// partial class RevisionVersionExtension : 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,322 @@
// ========================================================================
// 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>
/// RevisionVersions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionVersionsConverter))]
public partial class RevisionVersions : BusinessListBase<RevisionVersions, RevisionVersion>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public RevisionVersion this[Version myVersion]
{
get
{
foreach (RevisionVersion version in this)
if (version.VersionID == myVersion.VersionID)
return version;
return null;
}
}
public new System.Collections.Generic.IList<RevisionVersion> Items
{
get { return base.Items; }
}
public RevisionVersion GetItem(Version myVersion)
{
foreach (RevisionVersion version in this)
if (version.VersionID == myVersion.VersionID)
return version;
return null;
}
public RevisionVersion Add(Stage myStage, DateTime dts, string userID) // One to Many
{
RevisionVersion version = RevisionVersion.New(myStage, dts, userID);
this.Add(version);
return version;
}
public void Remove(Version myVersion)
{
foreach (RevisionVersion version in this)
{
if (version.VersionID == myVersion.VersionID)
{
Remove(version);
break;
}
}
}
public bool Contains(Version myVersion)
{
foreach (RevisionVersion version in this)
if (version.VersionID == myVersion.VersionID)
return true;
return false;
}
public bool ContainsDeleted(Version myVersion)
{
foreach (RevisionVersion version in DeletedList)
if (version.VersionID == myVersion.VersionID)
return true;
return false;
}
public bool IsDirtyList(List<object> list)
{
// any non-new deletions make us dirty
foreach (RevisionVersion item in DeletedList)
if (!item.IsNew)
return true;
// run through all the child objects
// and if any are dirty then then
// collection is dirty
foreach (RevisionVersion child in this)
if (child.IsDirtyList(list))
return true;
return false;
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> list)
{
// run through all the child objects
// and if any are invalid then the
// collection is invalid
foreach (RevisionVersion child in this)
if (!child.IsValidList(list))
{
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
return false;
}
return true;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (RevisionVersion revisionVersion in this)
if ((hasBrokenRules = revisionVersion.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static RevisionVersions New()
{
return new RevisionVersions();
}
internal static RevisionVersions Get(SafeDataReader dr)
{
return new RevisionVersions(dr);
}
public static RevisionVersions GetByRevisionID(int revisionID)
{
try
{
return DataPortal.Fetch<RevisionVersions>(new RevisionIDCriteria(revisionID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionVersions.GetByRevisionID", ex);
}
}
private RevisionVersions()
{
MarkAsChild();
}
internal RevisionVersions(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(RevisionVersion.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RevisionIDCriteria
{
public RevisionIDCriteria(int revisionID)
{
_RevisionID = revisionID;
}
private int _RevisionID;
public int RevisionID
{
get { return _RevisionID; }
set { _RevisionID = value; }
}
}
private void DataPortal_Fetch(RevisionIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionVersions.DataPortal_FetchRevisionID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getVersionsByRevisionID";
cm.Parameters.AddWithValue("@RevisionID", criteria.RevisionID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new RevisionVersion(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionVersions.DataPortal_FetchRevisionID", ex);
throw new DbCslaException("RevisionVersions.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Revision revision)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (RevisionVersion obj in DeletedList)
obj.DeleteSelf(revision);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (RevisionVersion obj in this)
{
if (obj.IsNew)
obj.Insert(revision);
else
obj.Update(revision);
}
}
finally
{
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
RevisionVersionsPropertyDescriptor pd = new RevisionVersionsPropertyDescriptor(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 RevisionVersionsPropertyDescriptor : vlnListPropertyDescriptor
{
private RevisionVersion Item { get { return (RevisionVersion)_Item; } }
public RevisionVersionsPropertyDescriptor(RevisionVersions collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class RevisionVersionsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionVersions)
{
// Return department and department role separated by comma.
return ((RevisionVersions)value).Items.Count.ToString() + " Versions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,587 @@
// ========================================================================
// 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>
/// StageCheck Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(StageCheckConverter))]
public partial class StageCheck : BusinessBase<StageCheck>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _CheckID;
[System.ComponentModel.DataObjectField(true, true)]
public int CheckID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("CheckID", true);
if (_MyCheck != null) _CheckID = _MyCheck.CheckID;
return _CheckID;
}
}
private Check _MyCheck;
[System.ComponentModel.DataObjectField(true, true)]
public Check MyCheck
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyCheck", true);
if (_MyCheck == null && _CheckID != 0) _MyCheck = Check.Get(_CheckID);
return _MyCheck;
}
}
private int _RevisionID;
public int RevisionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionID", true);
if (_MyRevision != null) _RevisionID = _MyRevision.RevisionID;
return _RevisionID;
}
}
private Revision _MyRevision;
public Revision MyRevision
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRevision", true);
if (_MyRevision == null && _RevisionID != 0) _MyRevision = Revision.Get(_RevisionID);
return _MyRevision;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyRevision", true);
if (_MyRevision != value)
{
_MyRevision = value;
_RevisionID = value.RevisionID;// Update underlying data field
PropertyHasChanged();
}
}
}
private string _ConsistencyChecks = string.Empty;
public string ConsistencyChecks
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConsistencyChecks", true);
return _ConsistencyChecks;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ConsistencyChecks", true);
if (value == null) value = string.Empty;
if (_ConsistencyChecks != value)
{
_ConsistencyChecks = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _Revision_ItemID;
public int Revision_ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_ItemID", true);
return _Revision_ItemID;
}
}
private int _Revision_TypeID;
public int Revision_TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_TypeID", true);
return _Revision_TypeID;
}
}
private string _Revision_RevisionNumber = string.Empty;
public string Revision_RevisionNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_RevisionNumber", true);
return _Revision_RevisionNumber;
}
}
private DateTime? _Revision_RevisionDate;
public DateTime? Revision_RevisionDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_RevisionDate", true);
return _Revision_RevisionDate;
}
}
private string _Revision_Notes = string.Empty;
public string Revision_Notes
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_Notes", true);
return _Revision_Notes;
}
}
private string _Revision_Config = string.Empty;
public string Revision_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_Config", true);
return _Revision_Config;
}
}
private DateTime _Revision_DTS = new DateTime();
public DateTime Revision_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_DTS", true);
return _Revision_DTS;
}
}
private string _Revision_UserID = string.Empty;
public string Revision_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_UserID", true);
return _Revision_UserID;
}
}
// CSLATODO: Check StageCheck.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 StageCheck</returns>
protected override object GetIdValue()
{
return MyStageCheckUnique; // Absolutely Unique ID
}
// CSLATODO: Replace base StageCheck.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StageCheck</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get
{
if ( base.IsDirty )
return true;
return IsDirtyList(new List<object>());
}
}
public bool IsDirtyList(List<object> list)
{
if (base.IsDirty || list.Contains(this))
return base.IsDirty;
list.Add(this);
return base.IsDirty || (_MyRevision == null ? false : _MyRevision.IsDirtyList(list));
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> list)
{
if(list.Contains(this))
return (IsNew && !IsDirty) ? true : base.IsValid;
list.Add(this);
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyRevision == null ? true : _MyRevision.IsValidList(list));
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyRevision != null && (hasBrokenRules = _MyRevision.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<StageCheck>(MyRevisionRequired, "MyRevision");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ConsistencyChecks", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// CSLATODO: Add other validation rules
}
private static bool MyRevisionRequired(StageCheck target, Csla.Validation.RuleArgs e)
{
if (target._RevisionID == 0 && target._MyRevision == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
//AuthorizationRules.AllowRead(CheckID, "<Role(s)>");
//AuthorizationRules.AllowRead(RevisionID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RevisionID, "<Role(s)>");
//AuthorizationRules.AllowRead(ConsistencyChecks, "<Role(s)>");
//AuthorizationRules.AllowWrite(ConsistencyChecks, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
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 _StageCheckUnique = 0;
private static int StageCheckUnique
{ get { return ++_StageCheckUnique; } }
private int _MyStageCheckUnique = StageCheckUnique;
public int MyStageCheckUnique // Absolutely Unique ID - Editable FK
{ get { return _MyStageCheckUnique; } }
internal static StageCheck New(Revision myRevision)
{
return new StageCheck(myRevision);
}
internal static StageCheck Get(SafeDataReader dr)
{
return new StageCheck(dr);
}
public StageCheck()
{
MarkAsChild();
_CheckID = Check.NextCheckID;
_DTS = _StageCheckExtension.DefaultDTS;
_UserID = _StageCheckExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private StageCheck(Revision myRevision)
{
MarkAsChild();
// CSLATODO: Add any initialization & defaults
_CheckID = Check.NextCheckID;
_DTS = _StageCheckExtension.DefaultDTS;
_UserID = _StageCheckExtension.DefaultUserID;
_MyRevision = myRevision;
ValidationRules.CheckRules();
}
internal StageCheck(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageCheck.FetchDR", GetHashCode());
try
{
_CheckID = dr.GetInt32("CheckID");
_RevisionID = dr.GetInt32("RevisionID");
_ConsistencyChecks = dr.GetString("ConsistencyChecks");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Revision_ItemID = dr.GetInt32("Revision_ItemID");
_Revision_TypeID = dr.GetInt32("Revision_TypeID");
_Revision_RevisionNumber = dr.GetString("Revision_RevisionNumber");
if (!dr.IsDBNull(dr.GetOrdinal("Revision_RevisionDate"))) _Revision_RevisionDate = dr.GetDateTime("Revision_RevisionDate");
_Revision_Notes = dr.GetString("Revision_Notes");
_Revision_Config = dr.GetString("Revision_Config");
_Revision_DTS = dr.GetDateTime("Revision_DTS");
_Revision_UserID = dr.GetString("Revision_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("StageCheck.FetchDR", ex);
throw new DbCslaException("StageCheck.Fetch", ex);
}
MarkOld();
}
internal void Insert(Stage myStage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Check.Add(cn, ref _CheckID, _MyRevision, myStage, _ConsistencyChecks, _DTS, _UserID);
MarkOld();
}
internal void Update(Stage myStage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Check.Update(cn, ref _CheckID, _RevisionID, myStage.StageID, _ConsistencyChecks, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Stage myStage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Check.Remove(cn, _CheckID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
StageCheckExtension _StageCheckExtension = new StageCheckExtension();
[Serializable()]
partial class StageCheckExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class StageCheckConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is StageCheck)
{
// Return the ToString value
return ((StageCheck)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create StageCheckExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class StageCheck
// {
// partial class StageCheckExtension : extensionBase
// {
// // CSLATODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@ -0,0 +1,322 @@
// ========================================================================
// 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>
/// StageChecks Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(StageChecksConverter))]
public partial class StageChecks : BusinessListBase<StageChecks, StageCheck>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public StageCheck this[Check myCheck]
{
get
{
foreach (StageCheck check in this)
if (check.CheckID == myCheck.CheckID)
return check;
return null;
}
}
public new System.Collections.Generic.IList<StageCheck> Items
{
get { return base.Items; }
}
public StageCheck GetItem(Check myCheck)
{
foreach (StageCheck check in this)
if (check.CheckID == myCheck.CheckID)
return check;
return null;
}
public StageCheck Add(Revision myRevision) // One to Many
{
StageCheck check = StageCheck.New(myRevision);
this.Add(check);
return check;
}
public void Remove(Check myCheck)
{
foreach (StageCheck check in this)
{
if (check.CheckID == myCheck.CheckID)
{
Remove(check);
break;
}
}
}
public bool Contains(Check myCheck)
{
foreach (StageCheck check in this)
if (check.CheckID == myCheck.CheckID)
return true;
return false;
}
public bool ContainsDeleted(Check myCheck)
{
foreach (StageCheck check in DeletedList)
if (check.CheckID == myCheck.CheckID)
return true;
return false;
}
public bool IsDirtyList(List<object> list)
{
// any non-new deletions make us dirty
foreach (StageCheck item in DeletedList)
if (!item.IsNew)
return true;
// run through all the child objects
// and if any are dirty then then
// collection is dirty
foreach (StageCheck child in this)
if (child.IsDirtyList(list))
return true;
return false;
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> list)
{
// run through all the child objects
// and if any are invalid then the
// collection is invalid
foreach (StageCheck child in this)
if (!child.IsValidList(list))
{
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
return false;
}
return true;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (StageCheck stageCheck in this)
if ((hasBrokenRules = stageCheck.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static StageChecks New()
{
return new StageChecks();
}
internal static StageChecks Get(SafeDataReader dr)
{
return new StageChecks(dr);
}
public static StageChecks GetByStageID(int stageID)
{
try
{
return DataPortal.Fetch<StageChecks>(new StageIDCriteria(stageID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on StageChecks.GetByStageID", ex);
}
}
private StageChecks()
{
MarkAsChild();
}
internal StageChecks(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(StageCheck.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StageIDCriteria
{
public StageIDCriteria(int stageID)
{
_StageID = stageID;
}
private int _StageID;
public int StageID
{
get { return _StageID; }
set { _StageID = value; }
}
}
private void DataPortal_Fetch(StageIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageChecks.DataPortal_FetchStageID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getChecksByStageID";
cm.Parameters.AddWithValue("@StageID", criteria.StageID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new StageCheck(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("StageChecks.DataPortal_FetchStageID", ex);
throw new DbCslaException("StageChecks.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Stage stage)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (StageCheck obj in DeletedList)
obj.DeleteSelf(stage);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (StageCheck obj in this)
{
if (obj.IsNew)
obj.Insert(stage);
else
obj.Update(stage);
}
}
finally
{
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
StageChecksPropertyDescriptor pd = new StageChecksPropertyDescriptor(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 StageChecksPropertyDescriptor : vlnListPropertyDescriptor
{
private StageCheck Item { get { return (StageCheck)_Item; } }
public StageChecksPropertyDescriptor(StageChecks collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class StageChecksConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is StageChecks)
{
// Return department and department role separated by comma.
return ((StageChecks)value).Items.Count.ToString() + " Checks";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,424 @@
// ========================================================================
// 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 StageInfoEvent(object sender);
/// <summary>
/// StageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(StageInfoConverter))]
public partial class StageInfo : ReadOnlyBase<StageInfo>, IDisposable
{
public event StageInfoEvent 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<StageInfo> _CacheList = new List<StageInfo>();
protected static void AddToCache(StageInfo stageInfo)
{
if (!_CacheList.Contains(stageInfo)) _CacheList.Add(stageInfo); // In AddToCache
}
protected static void RemoveFromCache(StageInfo stageInfo)
{
while (_CacheList.Contains(stageInfo)) _CacheList.Remove(stageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<StageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<StageInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move StageInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
StageInfo tmp = _CacheList[0]; // Get the first StageInfo
string pKey = tmp.StageID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<StageInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first StageInfo
}
}
internal static void AddList(StageInfoList lst)
{
foreach (StageInfo item in lst) AddToCache(item);
}
protected static StageInfo GetCachedByPrimaryKey(int stageID)
{
ConvertListToDictionary();
string key = stageID.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 Stage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _StageID;
[System.ComponentModel.DataObjectField(true, true)]
public int StageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageID", true);
return _StageID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name", true);
return _Name;
}
}
private string _Description = string.Empty;
public string Description
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Description", true);
return _Description;
}
}
private int _IsApproved;
public int IsApproved
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("IsApproved", true);
return _IsApproved;
}
}
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 _StageCheckCount = 0;
/// <summary>
/// Count of StageChecks for this Stage
/// </summary>
public int StageCheckCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageCheckCount", true);
if (_StageCheckCount < 0)
_StageCheckCount = StageChecks.Count;
return _StageCheckCount;
}
}
private CheckInfoList _StageChecks = null;
[TypeConverter(typeof(CheckInfoListConverter))]
public CheckInfoList StageChecks
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageChecks", true);
if (_StageCheckCount < 0 || (_StageCheckCount > 0 && _StageChecks == null))
_StageChecks = CheckInfoList.GetByStageID(_StageID);
if (_StageCheckCount < 0)
_StageCheckCount = _StageChecks.Count;
return _StageChecks;
}
}
public void RefreshStageChecks()
{
_StageCheckCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_StageID.ToString()))
foreach (StageInfo tmp in _CacheByPrimaryKey[_StageID.ToString()])
tmp._StageCheckCount = -1; // This will cause the data to be requeried
}
private int _StageVersionCount = 0;
/// <summary>
/// Count of StageVersions for this Stage
/// </summary>
public int StageVersionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageVersionCount", true);
if (_StageVersionCount < 0)
_StageVersionCount = StageVersions.Count;
return _StageVersionCount;
}
}
private VersionInfoList _StageVersions = null;
[TypeConverter(typeof(VersionInfoListConverter))]
public VersionInfoList StageVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageVersions", true);
if (_StageVersionCount < 0 || (_StageVersionCount > 0 && _StageVersions == null))
_StageVersions = VersionInfoList.GetByStageID(_StageID);
if (_StageVersionCount < 0)
_StageVersionCount = _StageVersions.Count;
return _StageVersions;
}
}
public void RefreshStageVersions()
{
_StageVersionCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_StageID.ToString()))
foreach (StageInfo tmp in _CacheByPrimaryKey[_StageID.ToString()])
tmp._StageVersionCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base StageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check StageInfo.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 StageInfo</returns>
protected override object GetIdValue()
{
return MyStageInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _StageInfoUnique = 0;
private static int StageInfoUnique
{ get { return ++_StageInfoUnique; } }
private int _MyStageInfoUnique = StageInfoUnique;
public int MyStageInfoUnique // Absolutely Unique ID - Info
{ get { return _MyStageInfoUnique; } }
protected StageInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(StageID.ToString())) return;
List<StageInfo> listStageInfo = _CacheByPrimaryKey[StageID.ToString()]; // Get the list of items
while (listStageInfo.Contains(this)) listStageInfo.Remove(this); // Remove the item from the list
if (listStageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(StageID.ToString()); // remove the list
}
public virtual Stage Get()
{
return _Editable = Stage.Get(_StageID);
}
public static void Refresh(Stage tmp)
{
string key = tmp.StageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (StageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Stage tmp)
{
_Name = tmp.Name;
_Description = tmp.Description;
_IsApproved = tmp.IsApproved;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_StageInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static StageInfo Get(int stageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Stage");
try
{
StageInfo tmp = GetCachedByPrimaryKey(stageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<StageInfo>(new PKCriteria(stageID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up StageInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on StageInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal StageInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("StageInfo.Constructor", ex);
throw new DbCslaException("StageInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _StageID;
public int StageID
{ get { return _StageID; } }
public PKCriteria(int stageID)
{
_StageID = stageID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageInfo.ReadData", GetHashCode());
try
{
_StageID = dr.GetInt32("StageID");
_Name = dr.GetString("Name");
_Description = dr.GetString("Description");
_IsApproved = dr.GetInt32("IsApproved");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_StageCheckCount = dr.GetInt32("CheckCount");
_StageVersionCount = dr.GetInt32("VersionCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("StageInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("StageInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageInfo.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 = "getStage";
cm.Parameters.AddWithValue("@StageID", criteria.StageID);
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("StageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("StageInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
StageInfoExtension _StageInfoExtension = new StageInfoExtension();
[Serializable()]
partial class StageInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(StageInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class StageInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is StageInfo)
{
// Return the ToString value
return ((StageInfo)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>
/// StageInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(StageInfoListConverter))]
public partial class StageInfoList : ReadOnlyListBase<StageInfoList, StageInfo>, 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<StageInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (StageInfo tmp in this)
{
tmp.Changed += new StageInfoEvent(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 (StageInfo tmp in this)
{
tmp.Changed -= new StageInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static StageInfoList _StageInfoList = null;
/// <summary>
/// Return a list of all StageInfo.
/// </summary>
public static StageInfoList Get()
{
try
{
if (_StageInfoList != null)
return _StageInfoList;
StageInfoList tmp = DataPortal.Fetch<StageInfoList>();
StageInfo.AddList(tmp);
tmp.AddEvents();
_StageInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on StageInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all StageInfo.
/// </summary>
public static void Reset()
{
_StageInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static StageInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<StageInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on StageInfoList.Get", ex);
// }
//}
private StageInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStages";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new StageInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("StageInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("StageInfoList.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
StageInfoListPropertyDescriptor pd = new StageInfoListPropertyDescriptor(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 StageInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private StageInfo Item { get { return (StageInfo)_Item; } }
public StageInfoListPropertyDescriptor(StageInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class StageInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is StageInfoList)
{
// Return department and department role separated by comma.
return ((StageInfoList)value).Items.Count.ToString() + " Stages";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,590 @@
// ========================================================================
// 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>
/// StageVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(StageVersionConverter))]
public partial class StageVersion : BusinessBase<StageVersion>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionID", true);
if (_MyVersion != null) _VersionID = _MyVersion.VersionID;
return _VersionID;
}
}
private Version _MyVersion;
[System.ComponentModel.DataObjectField(true, true)]
public Version MyVersion
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyVersion", true);
if (_MyVersion == null && _VersionID != 0) _MyVersion = Version.Get(_VersionID);
return _MyVersion;
}
}
private int _RevisionID;
public int RevisionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionID", true);
if (_MyRevision != null) _RevisionID = _MyRevision.RevisionID;
return _RevisionID;
}
}
private Revision _MyRevision;
public Revision MyRevision
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRevision", true);
if (_MyRevision == null && _RevisionID != 0) _MyRevision = Revision.Get(_RevisionID);
return _MyRevision;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyRevision", true);
if (_MyRevision != value)
{
_MyRevision = value;
_RevisionID = value.RevisionID;// Update underlying data field
PropertyHasChanged();
}
}
}
private byte[] _PDF;
public byte[] PDF
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PDF", true);
return _PDF;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("PDF", true);
if (_PDF != value)
{
_PDF = value;
PropertyHasChanged();
}
}
}
private byte[] _SummaryPDF;
public byte[] SummaryPDF
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SummaryPDF", true);
return _SummaryPDF;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("SummaryPDF", true);
if (_SummaryPDF != value)
{
_SummaryPDF = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _Revision_ItemID;
public int Revision_ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_ItemID", true);
return _Revision_ItemID;
}
}
private int _Revision_TypeID;
public int Revision_TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_TypeID", true);
return _Revision_TypeID;
}
}
private string _Revision_RevisionNumber = string.Empty;
public string Revision_RevisionNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_RevisionNumber", true);
return _Revision_RevisionNumber;
}
}
private DateTime? _Revision_RevisionDate;
public DateTime? Revision_RevisionDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_RevisionDate", true);
return _Revision_RevisionDate;
}
}
private string _Revision_Notes = string.Empty;
public string Revision_Notes
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_Notes", true);
return _Revision_Notes;
}
}
private string _Revision_Config = string.Empty;
public string Revision_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_Config", true);
return _Revision_Config;
}
}
private DateTime _Revision_DTS = new DateTime();
public DateTime Revision_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_DTS", true);
return _Revision_DTS;
}
}
private string _Revision_UserID = string.Empty;
public string Revision_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Revision_UserID", true);
return _Revision_UserID;
}
}
// CSLATODO: Check StageVersion.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 StageVersion</returns>
protected override object GetIdValue()
{
return MyStageVersionUnique; // Absolutely Unique ID
}
// CSLATODO: Replace base StageVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StageVersion</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get
{
if ( base.IsDirty )
return true;
return IsDirtyList(new List<object>());
}
}
public bool IsDirtyList(List<object> list)
{
if (base.IsDirty || list.Contains(this))
return base.IsDirty;
list.Add(this);
return base.IsDirty || (_MyRevision == null ? false : _MyRevision.IsDirtyList(list));
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> list)
{
if(list.Contains(this))
return (IsNew && !IsDirty) ? true : base.IsValid;
list.Add(this);
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyRevision == null ? true : _MyRevision.IsValidList(list));
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyRevision != null && (hasBrokenRules = _MyRevision.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<StageVersion>(MyRevisionRequired, "MyRevision");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 200));
// CSLATODO: Add other validation rules
}
private static bool MyRevisionRequired(StageVersion target, Csla.Validation.RuleArgs e)
{
if (target._RevisionID == 0 && target._MyRevision == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(RevisionID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RevisionID, "<Role(s)>");
//AuthorizationRules.AllowRead(PDF, "<Role(s)>");
//AuthorizationRules.AllowWrite(PDF, "<Role(s)>");
//AuthorizationRules.AllowRead(SummaryPDF, "<Role(s)>");
//AuthorizationRules.AllowWrite(SummaryPDF, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
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 _StageVersionUnique = 0;
private static int StageVersionUnique
{ get { return ++_StageVersionUnique; } }
private int _MyStageVersionUnique = StageVersionUnique;
public int MyStageVersionUnique // Absolutely Unique ID - Editable FK
{ get { return _MyStageVersionUnique; } }
internal static StageVersion New(Revision myRevision, DateTime dts, string userID)
{
return new StageVersion(myRevision, dts, userID);
}
internal static StageVersion Get(SafeDataReader dr)
{
return new StageVersion(dr);
}
public StageVersion()
{
MarkAsChild();
_VersionID = Version.NextVersionID;
ValidationRules.CheckRules();
}
private StageVersion(Revision myRevision, DateTime dts, string userID)
{
MarkAsChild();
// CSLATODO: Add any initialization & defaults
_VersionID = Version.NextVersionID;
_MyRevision = myRevision;
_DTS = dts;
_UserID = userID;
ValidationRules.CheckRules();
}
internal StageVersion(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageVersion.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_RevisionID = dr.GetInt32("RevisionID");
_PDF = (byte[])dr.GetValue("PDF");
_SummaryPDF = (byte[])dr.GetValue("SummaryPDF");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Revision_ItemID = dr.GetInt32("Revision_ItemID");
_Revision_TypeID = dr.GetInt32("Revision_TypeID");
_Revision_RevisionNumber = dr.GetString("Revision_RevisionNumber");
if (!dr.IsDBNull(dr.GetOrdinal("Revision_RevisionDate"))) _Revision_RevisionDate = dr.GetDateTime("Revision_RevisionDate");
_Revision_Notes = dr.GetString("Revision_Notes");
_Revision_Config = dr.GetString("Revision_Config");
_Revision_DTS = dr.GetDateTime("Revision_DTS");
_Revision_UserID = dr.GetString("Revision_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("StageVersion.FetchDR", ex);
throw new DbCslaException("StageVersion.Fetch", ex);
}
MarkOld();
}
internal void Insert(Stage myStage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Version.Add(cn, ref _VersionID, _MyRevision, myStage, _PDF, _SummaryPDF, _DTS, _UserID);
MarkOld();
}
internal void Update(Stage myStage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Version.Update(cn, ref _VersionID, _RevisionID, myStage.StageID, _PDF, _SummaryPDF, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Stage myStage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Version.Remove(cn, _VersionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
StageVersionExtension _StageVersionExtension = new StageVersionExtension();
[Serializable()]
partial class StageVersionExtension : 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 StageVersionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is StageVersion)
{
// Return the ToString value
return ((StageVersion)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create StageVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class StageVersion
// {
// partial class StageVersionExtension : 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,322 @@
// ========================================================================
// 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>
/// StageVersions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(StageVersionsConverter))]
public partial class StageVersions : BusinessListBase<StageVersions, StageVersion>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public StageVersion this[Version myVersion]
{
get
{
foreach (StageVersion version in this)
if (version.VersionID == myVersion.VersionID)
return version;
return null;
}
}
public new System.Collections.Generic.IList<StageVersion> Items
{
get { return base.Items; }
}
public StageVersion GetItem(Version myVersion)
{
foreach (StageVersion version in this)
if (version.VersionID == myVersion.VersionID)
return version;
return null;
}
public StageVersion Add(Revision myRevision, DateTime dts, string userID) // One to Many
{
StageVersion version = StageVersion.New(myRevision, dts, userID);
this.Add(version);
return version;
}
public void Remove(Version myVersion)
{
foreach (StageVersion version in this)
{
if (version.VersionID == myVersion.VersionID)
{
Remove(version);
break;
}
}
}
public bool Contains(Version myVersion)
{
foreach (StageVersion version in this)
if (version.VersionID == myVersion.VersionID)
return true;
return false;
}
public bool ContainsDeleted(Version myVersion)
{
foreach (StageVersion version in DeletedList)
if (version.VersionID == myVersion.VersionID)
return true;
return false;
}
public bool IsDirtyList(List<object> list)
{
// any non-new deletions make us dirty
foreach (StageVersion item in DeletedList)
if (!item.IsNew)
return true;
// run through all the child objects
// and if any are dirty then then
// collection is dirty
foreach (StageVersion child in this)
if (child.IsDirtyList(list))
return true;
return false;
}
public override bool IsValid
{
get { return IsValidList(new List<object>()); }
}
public bool IsValidList(List<object> list)
{
// run through all the child objects
// and if any are invalid then the
// collection is invalid
foreach (StageVersion child in this)
if (!child.IsValidList(list))
{
//Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString());
return false;
}
return true;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (StageVersion stageVersion in this)
if ((hasBrokenRules = stageVersion.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static StageVersions New()
{
return new StageVersions();
}
internal static StageVersions Get(SafeDataReader dr)
{
return new StageVersions(dr);
}
public static StageVersions GetByStageID(int stageID)
{
try
{
return DataPortal.Fetch<StageVersions>(new StageIDCriteria(stageID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on StageVersions.GetByStageID", ex);
}
}
private StageVersions()
{
MarkAsChild();
}
internal StageVersions(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(StageVersion.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StageIDCriteria
{
public StageIDCriteria(int stageID)
{
_StageID = stageID;
}
private int _StageID;
public int StageID
{
get { return _StageID; }
set { _StageID = value; }
}
}
private void DataPortal_Fetch(StageIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageVersions.DataPortal_FetchStageID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getVersionsByStageID";
cm.Parameters.AddWithValue("@StageID", criteria.StageID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new StageVersion(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("StageVersions.DataPortal_FetchStageID", ex);
throw new DbCslaException("StageVersions.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Stage stage)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (StageVersion obj in DeletedList)
obj.DeleteSelf(stage);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (StageVersion obj in this)
{
if (obj.IsNew)
obj.Insert(stage);
else
obj.Update(stage);
}
}
finally
{
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
StageVersionsPropertyDescriptor pd = new StageVersionsPropertyDescriptor(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 StageVersionsPropertyDescriptor : vlnListPropertyDescriptor
{
private StageVersion Item { get { return (StageVersion)_Item; } }
public StageVersionsPropertyDescriptor(StageVersions collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class StageVersionsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is StageVersions)
{
// Return department and department role separated by comma.
return ((StageVersions)value).Items.Count.ToString() + " Versions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,490 @@
// ========================================================================
// 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 VersionInfoEvent(object sender);
/// <summary>
/// VersionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(VersionInfoConverter))]
public partial class VersionInfo : ReadOnlyBase<VersionInfo>, IDisposable
{
public event VersionInfoEvent 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<VersionInfo> _CacheList = new List<VersionInfo>();
protected static void AddToCache(VersionInfo versionInfo)
{
if (!_CacheList.Contains(versionInfo)) _CacheList.Add(versionInfo); // In AddToCache
}
protected static void RemoveFromCache(VersionInfo versionInfo)
{
while (_CacheList.Contains(versionInfo)) _CacheList.Remove(versionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<VersionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<VersionInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move VersionInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
VersionInfo tmp = _CacheList[0]; // Get the first VersionInfo
string pKey = tmp.VersionID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<VersionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first VersionInfo
}
}
internal static void AddList(VersionInfoList lst)
{
foreach (VersionInfo item in lst) AddToCache(item);
}
protected static VersionInfo GetCachedByPrimaryKey(int versionID)
{
ConvertListToDictionary();
string key = versionID.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 Version _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionID", true);
return _VersionID;
}
}
private int _RevisionID;
public int RevisionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RevisionID", true);
if (_MyRevision != null) _RevisionID = _MyRevision.RevisionID;
return _RevisionID;
}
}
private RevisionInfo _MyRevision;
public RevisionInfo MyRevision
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRevision", true);
if (_MyRevision == null && _RevisionID != 0) _MyRevision = RevisionInfo.Get(_RevisionID);
return _MyRevision;
}
}
private int _StageID;
public int StageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StageID", true);
if (_MyStage != null) _StageID = _MyStage.StageID;
return _StageID;
}
}
private StageInfo _MyStage;
public StageInfo MyStage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyStage", true);
if (_MyStage == null && _StageID != 0) _MyStage = StageInfo.Get(_StageID);
return _MyStage;
}
}
private byte[] _PDF;
public byte[] PDF
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PDF", true);
return _PDF;
}
}
private byte[] _SummaryPDF;
public byte[] SummaryPDF
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SummaryPDF", true);
return _SummaryPDF;
}
}
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;
}
}
// CSLATODO: Replace base VersionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current VersionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check VersionInfo.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 VersionInfo</returns>
protected override object GetIdValue()
{
return MyVersionInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _VersionInfoUnique = 0;
private static int VersionInfoUnique
{ get { return ++_VersionInfoUnique; } }
private int _MyVersionInfoUnique = VersionInfoUnique;
public int MyVersionInfoUnique // Absolutely Unique ID - Info
{ get { return _MyVersionInfoUnique; } }
protected VersionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(VersionID.ToString())) return;
List<VersionInfo> listVersionInfo = _CacheByPrimaryKey[VersionID.ToString()]; // Get the list of items
while (listVersionInfo.Contains(this)) listVersionInfo.Remove(this); // Remove the item from the list
if (listVersionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(VersionID.ToString()); // remove the list
}
public virtual Version Get()
{
return _Editable = Version.Get(_VersionID);
}
public static void Refresh(Version tmp)
{
string key = tmp.VersionID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (VersionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Version tmp)
{
if (_RevisionID != tmp.RevisionID)
{
if (MyRevision != null) MyRevision.RefreshRevisionVersions(); // Update List for old value
_RevisionID = tmp.RevisionID; // Update the value
}
_MyRevision = null; // Reset list so that the next line gets a new list
if (MyRevision != null) MyRevision.RefreshRevisionVersions(); // Update List for new value
if (_StageID != tmp.StageID)
{
if (MyStage != null) MyStage.RefreshStageVersions(); // Update List for old value
_StageID = tmp.StageID; // Update the value
}
_MyStage = null; // Reset list so that the next line gets a new list
if (MyStage != null) MyStage.RefreshStageVersions(); // Update List for new value
_PDF = tmp.PDF;
_SummaryPDF = tmp.SummaryPDF;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_VersionInfoExtension.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(_MyRevision != null)
// {
// _MyRevision.Dispose();// Dispose related value
// _MyRevision = 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(_MyStage != null)
// {
// _MyStage.Dispose();// Dispose related value
// _MyStage = null;// Reset related value
// }
OnChange();// raise an event
}
public static void Refresh(RevisionVersion tmp)
{
string key = tmp.VersionID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (VersionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RevisionVersion tmp)
{
if (_StageID != tmp.StageID)
{
if (MyStage != null) MyStage.RefreshStageVersions(); // Update List for old value
_StageID = tmp.StageID; // Update the value
}
_MyStage = null; // Reset list so that the next line gets a new list
if (MyStage != null) MyStage.RefreshStageVersions(); // Update List for new value
_PDF = tmp.PDF;
_SummaryPDF = tmp.SummaryPDF;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_VersionInfoExtension.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(_MyRevision != null)
// {
// _MyRevision.Dispose();// Dispose related value
// _MyRevision = 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(_MyStage != null)
// {
// _MyStage.Dispose();// Dispose related value
// _MyStage = null;// Reset related value
// }
OnChange();// raise an event
}
public static void Refresh(StageVersion tmp)
{
string key = tmp.VersionID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (VersionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(StageVersion tmp)
{
if (_RevisionID != tmp.RevisionID)
{
if (MyRevision != null) MyRevision.RefreshRevisionVersions(); // Update List for old value
_RevisionID = tmp.RevisionID; // Update the value
}
_MyRevision = null; // Reset list so that the next line gets a new list
if (MyRevision != null) MyRevision.RefreshRevisionVersions(); // Update List for new value
_PDF = tmp.PDF;
_SummaryPDF = tmp.SummaryPDF;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_VersionInfoExtension.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(_MyRevision != null)
// {
// _MyRevision.Dispose();// Dispose related value
// _MyRevision = 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(_MyStage != null)
// {
// _MyStage.Dispose();// Dispose related value
// _MyStage = null;// Reset related value
// }
OnChange();// raise an event
}
public static VersionInfo Get(int versionID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Version");
try
{
VersionInfo tmp = GetCachedByPrimaryKey(versionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<VersionInfo>(new PKCriteria(versionID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up VersionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on VersionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal VersionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] VersionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("VersionInfo.Constructor", ex);
throw new DbCslaException("VersionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _VersionID;
public int VersionID
{ get { return _VersionID; } }
public PKCriteria(int versionID)
{
_VersionID = versionID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] VersionInfo.ReadData", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_RevisionID = dr.GetInt32("RevisionID");
_StageID = dr.GetInt32("StageID");
_PDF = (byte[])dr.GetValue("PDF");
_SummaryPDF = (byte[])dr.GetValue("SummaryPDF");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("VersionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("VersionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] VersionInfo.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 = "getVersion";
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
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("VersionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("VersionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
VersionInfoExtension _VersionInfoExtension = new VersionInfoExtension();
[Serializable()]
partial class VersionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(VersionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class VersionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is VersionInfo)
{
// Return the ToString value
return ((VersionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,319 @@
// ========================================================================
// 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>
/// VersionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(VersionInfoListConverter))]
public partial class VersionInfoList : ReadOnlyListBase<VersionInfoList, VersionInfo>, 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<VersionInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (VersionInfo tmp in this)
{
tmp.Changed += new VersionInfoEvent(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 (VersionInfo tmp in this)
{
tmp.Changed -= new VersionInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static VersionInfoList _VersionInfoList = null;
/// <summary>
/// Return a list of all VersionInfo.
/// </summary>
public static VersionInfoList Get()
{
try
{
if (_VersionInfoList != null)
return _VersionInfoList;
VersionInfoList tmp = DataPortal.Fetch<VersionInfoList>();
VersionInfo.AddList(tmp);
tmp.AddEvents();
_VersionInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on VersionInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all VersionInfo.
/// </summary>
public static void Reset()
{
_VersionInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static VersionInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<VersionInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on VersionInfoList.Get", ex);
// }
//}
public static VersionInfoList GetByRevisionID(int revisionID)
{
try
{
VersionInfoList tmp = DataPortal.Fetch<VersionInfoList>(new RevisionIDCriteria(revisionID));
VersionInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on VersionInfoList.GetByRevisionID", ex);
}
}
public static VersionInfoList GetByStageID(int stageID)
{
try
{
VersionInfoList tmp = DataPortal.Fetch<VersionInfoList>(new StageIDCriteria(stageID));
VersionInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on VersionInfoList.GetByStageID", ex);
}
}
private VersionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] VersionInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getVersions";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new VersionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("VersionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("VersionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RevisionIDCriteria
{
public RevisionIDCriteria(int revisionID)
{
_RevisionID = revisionID;
}
private int _RevisionID;
public int RevisionID
{
get { return _RevisionID; }
set { _RevisionID = value; }
}
}
private void DataPortal_Fetch(RevisionIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] VersionInfoList.DataPortal_FetchRevisionID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getVersionsByRevisionID";
cm.Parameters.AddWithValue("@RevisionID", criteria.RevisionID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new VersionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("VersionInfoList.DataPortal_FetchRevisionID", ex);
throw new DbCslaException("VersionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StageIDCriteria
{
public StageIDCriteria(int stageID)
{
_StageID = stageID;
}
private int _StageID;
public int StageID
{
get { return _StageID; }
set { _StageID = value; }
}
}
private void DataPortal_Fetch(StageIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] VersionInfoList.DataPortal_FetchStageID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getVersionsByStageID";
cm.Parameters.AddWithValue("@StageID", criteria.StageID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new VersionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("VersionInfoList.DataPortal_FetchStageID", ex);
throw new DbCslaException("VersionInfoList.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
VersionInfoListPropertyDescriptor pd = new VersionInfoListPropertyDescriptor(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 VersionInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private VersionInfo Item { get { return (VersionInfo)_Item; } }
public VersionInfoListPropertyDescriptor(VersionInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class VersionInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is VersionInfoList)
{
// Return department and department role separated by comma.
return ((VersionInfoList)value).Items.Count.ToString() + " Versions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace