C2025-011 PROMS – RO Update Admin Tool Memory Enhancements

The purpose of this upgrade is to improve the user experience when using the Admin tool to Update ROs. Currently for larger RO dbs (like Barakah) we can run up against memory constraints that do not allow all the ROs to be updated at one time. This is based upon some initial resource where some places were identified where we could improve memory usage.  Some of these should benefit PROMS as a whole while others will be specific to the RO Update option in Admin Tools.
This commit is contained in:
2025-02-04 13:23:21 -05:00
parent f2d330bd0e
commit 378653c536
254 changed files with 159727 additions and 163222 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -19,469 +19,459 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void AnnotationInfoEvent(object sender);
/// <summary>
/// AnnotationInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationInfoConverter))]
public partial class AnnotationInfo : ReadOnlyBase<AnnotationInfo>, IDisposable
{
public event AnnotationInfoEvent 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<AnnotationInfo> _CacheList = new List<AnnotationInfo>();
protected static void AddToCache(AnnotationInfo annotationInfo)
{
if (!_CacheList.Contains(annotationInfo)) _CacheList.Add(annotationInfo); // In AddToCache
}
protected static void RemoveFromCache(AnnotationInfo annotationInfo)
{
while (_CacheList.Contains(annotationInfo)) _CacheList.Remove(annotationInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AnnotationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
private static void ConvertListToDictionary()
{
List<AnnotationInfo> remove = new List<AnnotationInfo>();
foreach (AnnotationInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
{
_CacheByPrimaryKey[tmp.AnnotationID.ToString()] = new List<AnnotationInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (AnnotationInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(AnnotationInfoList lst)
{
foreach (AnnotationInfo item in lst) AddToCache(item);
}
protected static AnnotationInfo GetCachedByPrimaryKey(int annotationID)
{
ConvertListToDictionary();
string key = annotationID.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 Annotation _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationID", true);
return _AnnotationID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private ItemInfo _MyItem;
public ItemInfo MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID;
}
}
private AnnotationTypeInfo _MyAnnotationType;
public AnnotationTypeInfo MyAnnotationType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID);
return _MyAnnotationType;
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText", true);
return _RtfText;
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText", true);
return _SearchText;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
// TODO: Replace base AnnotationInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AnnotationInfo.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 AnnotationInfo</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
#endregion
#region Factory Methods
private static int _AnnotationInfoUnique = 0;
private static int AnnotationInfoUnique
{ get { return ++_AnnotationInfoUnique; } }
private int _MyAnnotationInfoUnique = AnnotationInfoUnique;
public int MyAnnotationInfoUnique
{ get { return _MyAnnotationInfoUnique; } }
protected AnnotationInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
List<AnnotationInfo> listAnnotationInfo = _CacheByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
while (listAnnotationInfo.Contains(this)) listAnnotationInfo.Remove(this); // Remove the item from the list
if (listAnnotationInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
}
public virtual Annotation Get()
{
return _Editable = Annotation.Get(_AnnotationID);
}
public static void Refresh(Annotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Annotation tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
if (_TypeID != tmp.TypeID)
{
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value
}
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if(_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(AnnotationTypeAnnotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(AnnotationTypeAnnotation tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if(_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ItemAnnotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ItemAnnotation tmp)
{
if (_TypeID != tmp.TypeID)
{
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value
}
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if(_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static AnnotationInfo Get(int annotationID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Annotation");
try
{
AnnotationInfo tmp = GetCachedByPrimaryKey(annotationID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.Constructor", ex);
throw new DbCslaException("AnnotationInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _AnnotationID;
public int AnnotationID
{ get { return _AnnotationID; } }
public PKCriteria(int annotationID)
{
_AnnotationID = annotationID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_ItemID = dr.GetInt32("ItemID");
_TypeID = dr.GetInt32("TypeID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.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 = "getAnnotation";
cm.Parameters.AddWithValue("@AnnotationID", criteria.AnnotationID);
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("AnnotationInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension();
[Serializable()]
partial class AnnotationInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationInfo)
{
// Return the ToString value
return ((AnnotationInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void AnnotationInfoEvent(object sender);
/// <summary>
/// AnnotationInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationInfoConverter))]
public partial class AnnotationInfo : ReadOnlyBase<AnnotationInfo>, IDisposable
{
public event AnnotationInfoEvent 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<AnnotationInfo> _CacheList = new List<AnnotationInfo>();
protected static void AddToCache(AnnotationInfo annotationInfo)
{
if (!_CacheList.Contains(annotationInfo)) _CacheList.Add(annotationInfo); // In AddToCache
}
protected static void RemoveFromCache(AnnotationInfo annotationInfo)
{
while (_CacheList.Contains(annotationInfo)) _CacheList.Remove(annotationInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AnnotationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
private static void ConvertListToDictionary()
{
List<AnnotationInfo> remove = new List<AnnotationInfo>();
foreach (AnnotationInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
{
_CacheByPrimaryKey[tmp.AnnotationID.ToString()] = new List<AnnotationInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (AnnotationInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(AnnotationInfoList lst)
{
foreach (AnnotationInfo item in lst) AddToCache(item);
}
protected static AnnotationInfo GetCachedByPrimaryKey(int annotationID)
{
ConvertListToDictionary();
string key = annotationID.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 Annotation _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _AnnotationID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private ItemInfo _MyItem;
public ItemInfo MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID;
}
}
private AnnotationTypeInfo _MyAnnotationType;
public AnnotationTypeInfo MyAnnotationType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID);
return _MyAnnotationType;
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RtfText;
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _SearchText;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
// TODO: Replace base AnnotationInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AnnotationInfo.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 AnnotationInfo</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
#endregion
#region Factory Methods
private static int _AnnotationInfoUnique = 0;
private static int AnnotationInfoUnique
{ get { return ++_AnnotationInfoUnique; } }
private int _MyAnnotationInfoUnique = AnnotationInfoUnique;
public int MyAnnotationInfoUnique
{ get { return _MyAnnotationInfoUnique; } }
protected AnnotationInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
List<AnnotationInfo> listAnnotationInfo = _CacheByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
while (listAnnotationInfo.Contains(this)) listAnnotationInfo.Remove(this); // Remove the item from the list
if (listAnnotationInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
}
public virtual Annotation Get()
{
return _Editable = Annotation.Get(_AnnotationID);
}
public static void Refresh(Annotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Annotation tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
if (_TypeID != tmp.TypeID)
{
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value
}
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if (_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if (_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(AnnotationTypeAnnotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(AnnotationTypeAnnotation tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if (_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if (_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ItemAnnotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ItemAnnotation tmp)
{
if (_TypeID != tmp.TypeID)
{
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value
}
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if (_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if (_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static AnnotationInfo Get(int annotationID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Annotation");
try
{
AnnotationInfo tmp = GetCachedByPrimaryKey(annotationID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.Constructor", ex);
throw new DbCslaException("AnnotationInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _AnnotationID;
public int AnnotationID
{ get { return _AnnotationID; } }
public PKCriteria(int annotationID)
{
_AnnotationID = annotationID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_ItemID = dr.GetInt32("ItemID");
_TypeID = dr.GetInt32("TypeID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.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 = "getAnnotation";
cm.Parameters.AddWithValue("@AnnotationID", criteria.AnnotationID);
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("AnnotationInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension();
[Serializable()]
partial class AnnotationInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationInfo)
{
// Return the ToString value
return ((AnnotationInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,509 +19,490 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// AnnotationTypeAnnotation Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationTypeAnnotationConverter))]
public partial class AnnotationTypeAnnotation : BusinessBase<AnnotationTypeAnnotation>, 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 _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationID", true);
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID;
}
}
private Annotation _MyAnnotation;
[System.ComponentModel.DataObjectField(true, true)]
public Annotation MyAnnotation
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotation", true);
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItem", true);
if (_MyItem != value)
{
_MyItem = value;
PropertyHasChanged();
}
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText", true);
return _RtfText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("RtfText", true);
if (value == null) value = string.Empty;
if (_RtfText != value)
{
_RtfText = value;
PropertyHasChanged();
}
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText", true);
return _SearchText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("SearchText", true);
if (value == null) value = string.Empty;
if (_SearchText != value)
{
_SearchText = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config", true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _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? _Item_PreviousID;
public int? Item_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_PreviousID", true);
return _Item_PreviousID;
}
}
private int _Item_ContentID;
public int Item_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ContentID", true);
return _Item_ContentID;
}
}
private DateTime _Item_DTS = new DateTime();
public DateTime Item_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_DTS", true);
return _Item_DTS;
}
}
private string _Item_UserID = string.Empty;
public string Item_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_UserID", true);
return _Item_UserID;
}
}
// TODO: Check AnnotationTypeAnnotation.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 AnnotationTypeAnnotation</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
// TODO: Replace base AnnotationTypeAnnotation.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationTypeAnnotation</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
}
#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 (_MyItem != null && (hasBrokenRules = _MyItem.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<AnnotationTypeAnnotation>(MyItemRequired, "MyItem");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("RtfText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("SearchText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyItemRequired(AnnotationTypeAnnotation target, Csla.Validation.RuleArgs e)
{
if (target._ItemID == 0 && target._MyItem == 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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static AnnotationTypeAnnotation New(Item myItem)
{
return new AnnotationTypeAnnotation(myItem);
}
internal static AnnotationTypeAnnotation Get(SafeDataReader dr)
{
return new AnnotationTypeAnnotation(dr);
}
public AnnotationTypeAnnotation()
{
MarkAsChild();
_AnnotationID = Annotation.NextAnnotationID;
_DTS = _AnnotationTypeAnnotationExtension.DefaultDTS;
_UserID = _AnnotationTypeAnnotationExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private AnnotationTypeAnnotation(Item myItem)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _AnnotationTypeAnnotationExtension.DefaultDTS;
_UserID = _AnnotationTypeAnnotationExtension.DefaultUserID;
_MyItem = myItem;
ValidationRules.CheckRules();
}
internal AnnotationTypeAnnotation(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeAnnotation.FetchDR", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_ItemID = dr.GetInt32("ItemID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_PreviousID = (int?)dr.GetValue("Item_PreviousID");
_Item_ContentID = dr.GetInt32("Item_ContentID");
_Item_DTS = dr.GetDateTime("Item_DTS");
_Item_UserID = dr.GetString("Item_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeAnnotation.FetchDR", ex);
throw new DbCslaException("AnnotationTypeAnnotation.Fetch", ex);
}
MarkOld();
}
internal void Insert(AnnotationType myAnnotationType)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Add(cn, ref _AnnotationID, _MyItem, myAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(AnnotationType myAnnotationType)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _MyItem, myAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(AnnotationType myAnnotationType)
{
// 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"];
Annotation.Remove(cn, _AnnotationID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
AnnotationTypeAnnotationExtension _AnnotationTypeAnnotationExtension = new AnnotationTypeAnnotationExtension();
[Serializable()]
partial class AnnotationTypeAnnotationExtension : 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 AnnotationTypeAnnotationConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationTypeAnnotation)
{
// Return the ToString value
return ((AnnotationTypeAnnotation)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
/// <summary>
/// AnnotationTypeAnnotation Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationTypeAnnotationConverter))]
public partial class AnnotationTypeAnnotation : BusinessBase<AnnotationTypeAnnotation>, 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 _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID;
}
}
private Annotation _MyAnnotation;
[System.ComponentModel.DataObjectField(true, true)]
public Annotation MyAnnotation
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_MyItem != value)
{
_MyItem = value;
PropertyHasChanged();
}
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RtfText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_RtfText != value)
{
_RtfText = value;
PropertyHasChanged();
}
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _SearchText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_SearchText != value)
{
_SearchText = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int? _Item_PreviousID;
public int? Item_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Item_PreviousID;
}
}
private int _Item_ContentID;
public int Item_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Item_ContentID;
}
}
private DateTime _Item_DTS = new DateTime();
public DateTime Item_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Item_DTS;
}
}
private string _Item_UserID = string.Empty;
public string Item_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Item_UserID;
}
}
// TODO: Check AnnotationTypeAnnotation.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 AnnotationTypeAnnotation</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
// TODO: Replace base AnnotationTypeAnnotation.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationTypeAnnotation</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
}
#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 (_MyItem != null && (hasBrokenRules = _MyItem.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<AnnotationTypeAnnotation>(MyItemRequired, "MyItem");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("RtfText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("SearchText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyItemRequired(AnnotationTypeAnnotation target, Csla.Validation.RuleArgs e)
{
if (target._ItemID == 0 && target._MyItem == 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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static AnnotationTypeAnnotation New(Item myItem)
{
return new AnnotationTypeAnnotation(myItem);
}
internal static AnnotationTypeAnnotation Get(SafeDataReader dr)
{
return new AnnotationTypeAnnotation(dr);
}
public AnnotationTypeAnnotation()
{
MarkAsChild();
_AnnotationID = Annotation.NextAnnotationID;
_DTS = _AnnotationTypeAnnotationExtension.DefaultDTS;
_UserID = _AnnotationTypeAnnotationExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private AnnotationTypeAnnotation(Item myItem)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _AnnotationTypeAnnotationExtension.DefaultDTS;
_UserID = _AnnotationTypeAnnotationExtension.DefaultUserID;
_MyItem = myItem;
ValidationRules.CheckRules();
}
internal AnnotationTypeAnnotation(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeAnnotation.FetchDR", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_ItemID = dr.GetInt32("ItemID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_PreviousID = (int?)dr.GetValue("Item_PreviousID");
_Item_ContentID = dr.GetInt32("Item_ContentID");
_Item_DTS = dr.GetDateTime("Item_DTS");
_Item_UserID = dr.GetString("Item_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeAnnotation.FetchDR", ex);
throw new DbCslaException("AnnotationTypeAnnotation.Fetch", ex);
}
MarkOld();
}
internal void Insert(AnnotationType myAnnotationType)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Add(cn, ref _AnnotationID, _MyItem, myAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(AnnotationType myAnnotationType)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _MyItem, myAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(AnnotationType myAnnotationType)
{
// 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"];
Annotation.Remove(cn, _AnnotationID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
AnnotationTypeAnnotationExtension _AnnotationTypeAnnotationExtension = new AnnotationTypeAnnotationExtension();
[Serializable()]
partial class AnnotationTypeAnnotationExtension : 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 AnnotationTypeAnnotationConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationTypeAnnotation)
{
// Return the ToString value
return ((AnnotationTypeAnnotation)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,353 +19,346 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void AnnotationTypeInfoEvent(object sender);
/// <summary>
/// AnnotationTypeInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationTypeInfoConverter))]
public partial class AnnotationTypeInfo : ReadOnlyBase<AnnotationTypeInfo>, IDisposable
{
public event AnnotationTypeInfoEvent 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<AnnotationTypeInfo> _CacheList = new List<AnnotationTypeInfo>();
protected static void AddToCache(AnnotationTypeInfo annotationTypeInfo)
{
if (!_CacheList.Contains(annotationTypeInfo)) _CacheList.Add(annotationTypeInfo); // In AddToCache
}
protected static void RemoveFromCache(AnnotationTypeInfo annotationTypeInfo)
{
while (_CacheList.Contains(annotationTypeInfo)) _CacheList.Remove(annotationTypeInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AnnotationTypeInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationTypeInfo>>();
private static void ConvertListToDictionary()
{
List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>();
foreach (AnnotationTypeInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
{
_CacheByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationTypeInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (AnnotationTypeInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(AnnotationTypeInfoList lst)
{
foreach (AnnotationTypeInfo item in lst) AddToCache(item);
}
protected static AnnotationTypeInfo GetCachedByPrimaryKey(int typeID)
{
ConvertListToDictionary();
string key = typeID.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 AnnotationType _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _TypeID;
[System.ComponentModel.DataObjectField(true, true)]
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID", true);
return _TypeID;
}
}
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 _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 _AnnotationTypeAnnotationCount = 0;
/// <summary>
/// Count of AnnotationTypeAnnotations for this AnnotationType
/// </summary>
public int AnnotationTypeAnnotationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationTypeAnnotationCount", true);
return _AnnotationTypeAnnotationCount;
}
}
private AnnotationInfoList _AnnotationTypeAnnotations = null;
[TypeConverter(typeof(AnnotationInfoListConverter))]
public AnnotationInfoList AnnotationTypeAnnotations
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationTypeAnnotations", true);
if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null))
_AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID);
if (_AnnotationTypeAnnotationCount < 0)
_AnnotationTypeAnnotationCount = _AnnotationTypeAnnotations.Count;
return _AnnotationTypeAnnotations;
}
}
public void RefreshAnnotationTypeAnnotations()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_TypeID.ToString()))
foreach (AnnotationTypeInfo tmp in _CacheByPrimaryKey[_TypeID.ToString()])
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base AnnotationTypeInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationTypeInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AnnotationTypeInfo.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 AnnotationTypeInfo</returns>
protected override object GetIdValue()
{
return _TypeID;
}
#endregion
#region Factory Methods
private static int _AnnotationTypeInfoUnique = 0;
private static int AnnotationTypeInfoUnique
{ get { return ++_AnnotationTypeInfoUnique; } }
private int _MyAnnotationTypeInfoUnique = AnnotationTypeInfoUnique;
public int MyAnnotationTypeInfoUnique
{ get { return _MyAnnotationTypeInfoUnique; } }
protected AnnotationTypeInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(TypeID.ToString())) return;
List<AnnotationTypeInfo> listAnnotationTypeInfo = _CacheByPrimaryKey[TypeID.ToString()]; // Get the list of items
while (listAnnotationTypeInfo.Contains(this)) listAnnotationTypeInfo.Remove(this); // Remove the item from the list
if (listAnnotationTypeInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(TypeID.ToString()); // remove the list
}
public virtual AnnotationType Get()
{
return _Editable = AnnotationType.Get(_TypeID);
}
public static void Refresh(AnnotationType tmp)
{
string key = tmp.TypeID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationTypeInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(AnnotationType tmp)
{
_Name = tmp.Name;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationTypeInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static AnnotationTypeInfo Get(int typeID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
try
{
AnnotationTypeInfo tmp = GetCachedByPrimaryKey(typeID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationTypeInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationTypeInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.Constructor", ex);
throw new DbCslaException("AnnotationTypeInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _TypeID;
public int TypeID
{ get { return _TypeID; } }
public PKCriteria(int typeID)
{
_TypeID = typeID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode());
try
{
_TypeID = dr.GetInt32("TypeID");
_Name = dr.GetString("Name");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_AnnotationTypeAnnotationCount = dr.GetInt32("AnnotationCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.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 = "getAnnotationType";
cm.Parameters.AddWithValue("@TypeID", criteria.TypeID);
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("AnnotationTypeInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension();
[Serializable()]
partial class AnnotationTypeInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationTypeInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationTypeInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationTypeInfo)
{
// Return the ToString value
return ((AnnotationTypeInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void AnnotationTypeInfoEvent(object sender);
/// <summary>
/// AnnotationTypeInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationTypeInfoConverter))]
public partial class AnnotationTypeInfo : ReadOnlyBase<AnnotationTypeInfo>, IDisposable
{
public event AnnotationTypeInfoEvent 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<AnnotationTypeInfo> _CacheList = new List<AnnotationTypeInfo>();
protected static void AddToCache(AnnotationTypeInfo annotationTypeInfo)
{
if (!_CacheList.Contains(annotationTypeInfo)) _CacheList.Add(annotationTypeInfo); // In AddToCache
}
protected static void RemoveFromCache(AnnotationTypeInfo annotationTypeInfo)
{
while (_CacheList.Contains(annotationTypeInfo)) _CacheList.Remove(annotationTypeInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AnnotationTypeInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationTypeInfo>>();
private static void ConvertListToDictionary()
{
List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>();
foreach (AnnotationTypeInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
{
_CacheByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationTypeInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (AnnotationTypeInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(AnnotationTypeInfoList lst)
{
foreach (AnnotationTypeInfo item in lst) AddToCache(item);
}
protected static AnnotationTypeInfo GetCachedByPrimaryKey(int typeID)
{
ConvertListToDictionary();
string key = typeID.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 AnnotationType _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _TypeID;
[System.ComponentModel.DataObjectField(true, true)]
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _TypeID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Name;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
private int _AnnotationTypeAnnotationCount = 0;
/// <summary>
/// Count of AnnotationTypeAnnotations for this AnnotationType
/// </summary>
public int AnnotationTypeAnnotationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _AnnotationTypeAnnotationCount;
}
}
private AnnotationInfoList _AnnotationTypeAnnotations = null;
[TypeConverter(typeof(AnnotationInfoListConverter))]
public AnnotationInfoList AnnotationTypeAnnotations
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null))
_AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID);
if (_AnnotationTypeAnnotationCount < 0)
_AnnotationTypeAnnotationCount = _AnnotationTypeAnnotations.Count;
return _AnnotationTypeAnnotations;
}
}
public void RefreshAnnotationTypeAnnotations()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_TypeID.ToString()))
foreach (AnnotationTypeInfo tmp in _CacheByPrimaryKey[_TypeID.ToString()])
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base AnnotationTypeInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationTypeInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AnnotationTypeInfo.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 AnnotationTypeInfo</returns>
protected override object GetIdValue()
{
return _TypeID;
}
#endregion
#region Factory Methods
private static int _AnnotationTypeInfoUnique = 0;
private static int AnnotationTypeInfoUnique
{ get { return ++_AnnotationTypeInfoUnique; } }
private int _MyAnnotationTypeInfoUnique = AnnotationTypeInfoUnique;
public int MyAnnotationTypeInfoUnique
{ get { return _MyAnnotationTypeInfoUnique; } }
protected AnnotationTypeInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(TypeID.ToString())) return;
List<AnnotationTypeInfo> listAnnotationTypeInfo = _CacheByPrimaryKey[TypeID.ToString()]; // Get the list of items
while (listAnnotationTypeInfo.Contains(this)) listAnnotationTypeInfo.Remove(this); // Remove the item from the list
if (listAnnotationTypeInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(TypeID.ToString()); // remove the list
}
public virtual AnnotationType Get()
{
return _Editable = AnnotationType.Get(_TypeID);
}
public static void Refresh(AnnotationType tmp)
{
string key = tmp.TypeID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationTypeInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(AnnotationType tmp)
{
_Name = tmp.Name;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationTypeInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static AnnotationTypeInfo Get(int typeID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
try
{
AnnotationTypeInfo tmp = GetCachedByPrimaryKey(typeID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationTypeInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationTypeInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.Constructor", ex);
throw new DbCslaException("AnnotationTypeInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _TypeID;
public int TypeID
{ get { return _TypeID; } }
public PKCriteria(int typeID)
{
_TypeID = typeID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode());
try
{
_TypeID = dr.GetInt32("TypeID");
_Name = dr.GetString("Name");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_AnnotationTypeAnnotationCount = dr.GetInt32("AnnotationCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.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 = "getAnnotationType";
cm.Parameters.AddWithValue("@TypeID", criteria.TypeID);
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("AnnotationTypeInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension();
[Serializable()]
partial class AnnotationTypeInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationTypeInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationTypeInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationTypeInfo)
{
// Return the ToString value
return ((AnnotationTypeInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,392 +19,382 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ConnectionInfoEvent(object sender);
/// <summary>
/// ConnectionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ConnectionInfoConverter))]
public partial class ConnectionInfo : ReadOnlyBase<ConnectionInfo>, IDisposable
{
public event ConnectionInfoEvent 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<ConnectionInfo> _CacheList = new List<ConnectionInfo>();
protected static void AddToCache(ConnectionInfo connectionInfo)
{
if (!_CacheList.Contains(connectionInfo)) _CacheList.Add(connectionInfo); // In AddToCache
}
protected static void RemoveFromCache(ConnectionInfo connectionInfo)
{
while (_CacheList.Contains(connectionInfo)) _CacheList.Remove(connectionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ConnectionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ConnectionInfo>>();
private static void ConvertListToDictionary()
{
List<ConnectionInfo> remove = new List<ConnectionInfo>();
foreach (ConnectionInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.DBID.ToString()))
{
_CacheByPrimaryKey[tmp.DBID.ToString()] = new List<ConnectionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.DBID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ConnectionInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ConnectionInfoList lst)
{
foreach (ConnectionInfo item in lst) AddToCache(item);
}
protected static ConnectionInfo GetCachedByPrimaryKey(int dbid)
{
ConvertListToDictionary();
string key = dbid.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 Connection _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DBID;
[System.ComponentModel.DataObjectField(true, true)]
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DBID", true);
return _DBID;
}
}
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 _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title", true);
return _Title;
}
}
private string _ConnectionString = string.Empty;
public string ConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionString", true);
return _ConnectionString;
}
}
private int _ServerType;
/// <summary>
/// 0 SQL Server
/// </summary>
public int ServerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ServerType", true);
return _ServerType;
}
}
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 _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID", true);
return _UsrID;
}
}
private int _ConnectionFolderCount = 0;
/// <summary>
/// Count of ConnectionFolders for this Connection
/// </summary>
public int ConnectionFolderCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionFolderCount", true);
return _ConnectionFolderCount;
}
}
private FolderInfoList _ConnectionFolders = null;
[TypeConverter(typeof(FolderInfoListConverter))]
public FolderInfoList ConnectionFolders
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionFolders", true);
if (_ConnectionFolderCount < 0 || (_ConnectionFolderCount > 0 && _ConnectionFolders == null))
_ConnectionFolders = FolderInfoList.GetByDBID(_DBID);
if (_ConnectionFolderCount < 0)
_ConnectionFolderCount = _ConnectionFolders.Count;
return _ConnectionFolders;
}
}
public void RefreshConnectionFolders()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_DBID.ToString()))
foreach (ConnectionInfo tmp in _CacheByPrimaryKey[_DBID.ToString()])
tmp._ConnectionFolderCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ConnectionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ConnectionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ConnectionInfo.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 ConnectionInfo</returns>
protected override object GetIdValue()
{
return _DBID;
}
#endregion
#region Factory Methods
private static int _ConnectionInfoUnique = 0;
private static int ConnectionInfoUnique
{ get { return ++_ConnectionInfoUnique; } }
private int _MyConnectionInfoUnique = ConnectionInfoUnique;
public int MyConnectionInfoUnique
{ get { return _MyConnectionInfoUnique; } }
protected ConnectionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(DBID.ToString())) return;
List<ConnectionInfo> listConnectionInfo = _CacheByPrimaryKey[DBID.ToString()]; // Get the list of items
while (listConnectionInfo.Contains(this)) listConnectionInfo.Remove(this); // Remove the item from the list
if (listConnectionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(DBID.ToString()); // remove the list
}
public virtual Connection Get()
{
return _Editable = Connection.Get(_DBID);
}
public static void Refresh(Connection tmp)
{
string key = tmp.DBID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ConnectionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Connection tmp)
{
_Name = tmp.Name;
_Title = tmp.Title;
_ConnectionString = tmp.ConnectionString;
_ServerType = tmp.ServerType;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_ConnectionInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static ConnectionInfo Get(int dbid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Connection");
try
{
ConnectionInfo tmp = GetCachedByPrimaryKey(dbid);
if (tmp == null)
{
tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ConnectionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ConnectionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ConnectionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.Constructor", ex);
throw new DbCslaException("ConnectionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DBID;
public int DBID
{ get { return _DBID; } }
public PKCriteria(int dbid)
{
_DBID = dbid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode());
try
{
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ConnectionString = dr.GetString("ConnectionString");
_ServerType = dr.GetInt32("ServerType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_ConnectionFolderCount = dr.GetInt32("FolderCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.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 = "getConnection";
cm.Parameters.AddWithValue("@DBID", criteria.DBID);
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("ConnectionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension();
[Serializable()]
partial class ConnectionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ConnectionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ConnectionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ConnectionInfo)
{
// Return the ToString value
return ((ConnectionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void ConnectionInfoEvent(object sender);
/// <summary>
/// ConnectionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ConnectionInfoConverter))]
public partial class ConnectionInfo : ReadOnlyBase<ConnectionInfo>, IDisposable
{
public event ConnectionInfoEvent 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<ConnectionInfo> _CacheList = new List<ConnectionInfo>();
protected static void AddToCache(ConnectionInfo connectionInfo)
{
if (!_CacheList.Contains(connectionInfo)) _CacheList.Add(connectionInfo); // In AddToCache
}
protected static void RemoveFromCache(ConnectionInfo connectionInfo)
{
while (_CacheList.Contains(connectionInfo)) _CacheList.Remove(connectionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ConnectionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ConnectionInfo>>();
private static void ConvertListToDictionary()
{
List<ConnectionInfo> remove = new List<ConnectionInfo>();
foreach (ConnectionInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.DBID.ToString()))
{
_CacheByPrimaryKey[tmp.DBID.ToString()] = new List<ConnectionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.DBID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ConnectionInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ConnectionInfoList lst)
{
foreach (ConnectionInfo item in lst) AddToCache(item);
}
protected static ConnectionInfo GetCachedByPrimaryKey(int dbid)
{
ConvertListToDictionary();
string key = dbid.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 Connection _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DBID;
[System.ComponentModel.DataObjectField(true, true)]
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DBID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Name;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Title;
}
}
private string _ConnectionString = string.Empty;
public string ConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ConnectionString;
}
}
private int _ServerType;
/// <summary>
/// 0 SQL Server
/// </summary>
public int ServerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ServerType;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UsrID;
}
}
private int _ConnectionFolderCount = 0;
/// <summary>
/// Count of ConnectionFolders for this Connection
/// </summary>
public int ConnectionFolderCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ConnectionFolderCount;
}
}
private FolderInfoList _ConnectionFolders = null;
[TypeConverter(typeof(FolderInfoListConverter))]
public FolderInfoList ConnectionFolders
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_ConnectionFolderCount < 0 || (_ConnectionFolderCount > 0 && _ConnectionFolders == null))
_ConnectionFolders = FolderInfoList.GetByDBID(_DBID);
if (_ConnectionFolderCount < 0)
_ConnectionFolderCount = _ConnectionFolders.Count;
return _ConnectionFolders;
}
}
public void RefreshConnectionFolders()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_DBID.ToString()))
foreach (ConnectionInfo tmp in _CacheByPrimaryKey[_DBID.ToString()])
tmp._ConnectionFolderCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ConnectionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ConnectionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ConnectionInfo.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 ConnectionInfo</returns>
protected override object GetIdValue()
{
return _DBID;
}
#endregion
#region Factory Methods
private static int _ConnectionInfoUnique = 0;
private static int ConnectionInfoUnique
{ get { return ++_ConnectionInfoUnique; } }
private int _MyConnectionInfoUnique = ConnectionInfoUnique;
public int MyConnectionInfoUnique
{ get { return _MyConnectionInfoUnique; } }
protected ConnectionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(DBID.ToString())) return;
List<ConnectionInfo> listConnectionInfo = _CacheByPrimaryKey[DBID.ToString()]; // Get the list of items
while (listConnectionInfo.Contains(this)) listConnectionInfo.Remove(this); // Remove the item from the list
if (listConnectionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(DBID.ToString()); // remove the list
}
public virtual Connection Get()
{
return _Editable = Connection.Get(_DBID);
}
public static void Refresh(Connection tmp)
{
string key = tmp.DBID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ConnectionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Connection tmp)
{
_Name = tmp.Name;
_Title = tmp.Title;
_ConnectionString = tmp.ConnectionString;
_ServerType = tmp.ServerType;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_ConnectionInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static ConnectionInfo Get(int dbid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Connection");
try
{
ConnectionInfo tmp = GetCachedByPrimaryKey(dbid);
if (tmp == null)
{
tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ConnectionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ConnectionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ConnectionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.Constructor", ex);
throw new DbCslaException("ConnectionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DBID;
public int DBID
{ get { return _DBID; } }
public PKCriteria(int dbid)
{
_DBID = dbid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode());
try
{
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ConnectionString = dr.GetString("ConnectionString");
_ServerType = dr.GetInt32("ServerType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_ConnectionFolderCount = dr.GetInt32("FolderCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.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 = "getConnection";
cm.Parameters.AddWithValue("@DBID", criteria.DBID);
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("ConnectionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension();
[Serializable()]
partial class ConnectionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ConnectionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ConnectionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ConnectionInfo)
{
// Return the ToString value
return ((ConnectionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,410 +19,398 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentDetail Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentDetailConverter))]
public partial class ContentDetail : BusinessBase<ContentDetail>, 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 _DetailID;
[System.ComponentModel.DataObjectField(true, true)]
public int DetailID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DetailID", true);
if (_MyDetail != null) _DetailID = _MyDetail.DetailID;
return _DetailID;
}
}
private Detail _MyDetail;
[System.ComponentModel.DataObjectField(true, true)]
public Detail MyDetail
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDetail", true);
if (_MyDetail == null && _DetailID != 0) _MyDetail = Detail.Get(_DetailID);
return _MyDetail;
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemType", true);
return _ItemType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ItemType", true);
if (_ItemType != value)
{
_ItemType = value;
PropertyHasChanged();
}
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text", true);
return _Text;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Text", true);
if (value == null) value = string.Empty;
if (_Text != value)
{
_Text = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config", true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _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
// TODO: Check ContentDetail.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 ContentDetail</returns>
protected override object GetIdValue()
{
return _DetailID;
}
// TODO: Replace base ContentDetail.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentDetail</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Text");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(DetailID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemType, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemType, "<Role(s)>");
//AuthorizationRules.AllowRead(Text, "<Role(s)>");
//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentDetail New(int itemType, string text)
{
return new ContentDetail(itemType, text);
}
internal static ContentDetail Get(SafeDataReader dr)
{
return new ContentDetail(dr);
}
public ContentDetail()
{
MarkAsChild();
_DetailID = Detail.NextDetailID;
_DTS = _ContentDetailExtension.DefaultDTS;
_UserID = _ContentDetailExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentDetail(int itemType, string text)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentDetailExtension.DefaultDTS;
_UserID = _ContentDetailExtension.DefaultUserID;
_ItemType = itemType;
_Text = text;
ValidationRules.CheckRules();
}
internal ContentDetail(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode());
try
{
_DetailID = dr.GetInt32("DetailID");
_ItemType = dr.GetInt32("ItemType");
_Text = dr.GetString("Text");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentDetail.FetchDR", ex);
throw new DbCslaException("ContentDetail.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Detail.Add(cn, ref _DetailID, myContent, _ItemType, _Text, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Detail.Update(cn, ref _DetailID, myContent, _ItemType, _Text, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// 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"];
Detail.Remove(cn, _DetailID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentDetailExtension _ContentDetailExtension = new ContentDetailExtension();
[Serializable()]
partial class ContentDetailExtension : 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 ContentDetailConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentDetail)
{
// Return the ToString value
return ((ContentDetail)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
/// <summary>
/// ContentDetail Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentDetailConverter))]
public partial class ContentDetail : BusinessBase<ContentDetail>, 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 _DetailID;
[System.ComponentModel.DataObjectField(true, true)]
public int DetailID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyDetail != null) _DetailID = _MyDetail.DetailID;
return _DetailID;
}
}
private Detail _MyDetail;
[System.ComponentModel.DataObjectField(true, true)]
public Detail MyDetail
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyDetail == null && _DetailID != 0) _MyDetail = Detail.Get(_DetailID);
return _MyDetail;
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ItemType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_ItemType != value)
{
_ItemType = value;
PropertyHasChanged();
}
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Text;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_Text != value)
{
_Text = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check ContentDetail.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 ContentDetail</returns>
protected override object GetIdValue()
{
return _DetailID;
}
// TODO: Replace base ContentDetail.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentDetail</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Text");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(DetailID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemType, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemType, "<Role(s)>");
//AuthorizationRules.AllowRead(Text, "<Role(s)>");
//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentDetail New(int itemType, string text)
{
return new ContentDetail(itemType, text);
}
internal static ContentDetail Get(SafeDataReader dr)
{
return new ContentDetail(dr);
}
public ContentDetail()
{
MarkAsChild();
_DetailID = Detail.NextDetailID;
_DTS = _ContentDetailExtension.DefaultDTS;
_UserID = _ContentDetailExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentDetail(int itemType, string text)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentDetailExtension.DefaultDTS;
_UserID = _ContentDetailExtension.DefaultUserID;
_ItemType = itemType;
_Text = text;
ValidationRules.CheckRules();
}
internal ContentDetail(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode());
try
{
_DetailID = dr.GetInt32("DetailID");
_ItemType = dr.GetInt32("ItemType");
_Text = dr.GetString("Text");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentDetail.FetchDR", ex);
throw new DbCslaException("ContentDetail.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Detail.Add(cn, ref _DetailID, myContent, _ItemType, _Text, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Detail.Update(cn, ref _DetailID, myContent, _ItemType, _Text, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// 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"];
Detail.Remove(cn, _DetailID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentDetailExtension _ContentDetailExtension = new ContentDetailExtension();
[Serializable()]
partial class ContentDetailExtension : 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 ContentDetailConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentDetail)
{
// Return the ToString value
return ((ContentDetail)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,358 +19,349 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentItem Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentItemConverter))]
public partial class ContentItem : BusinessBase<ContentItem>, 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 _ItemID;
[System.ComponentModel.DataObjectField(true, true)]
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
[System.ComponentModel.DataObjectField(true, true)]
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
}
private int? _PreviousID;
public int? PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PreviousID", true);
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID;
}
}
private Item _MyPrevious;
public Item MyPrevious
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyPrevious", true);
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID);
return _MyPrevious;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyPrevious", true);
if ((_MyPrevious == null ? _PreviousID : (int?)_MyPrevious.ItemID) != (value == null ? null : (int?)value.ItemID))
{
_MyPrevious = value;
_PreviousID = (value == null ? null : (int?)value.ItemID);
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
// TODO: Check ContentItem.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 ContentItem</returns>
protected override object GetIdValue()
{
return _ItemID;
}
// TODO: Replace base ContentItem.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentItem</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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 (_MyItem != null && (hasBrokenRules = _MyItem.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(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(PreviousID, "<Role(s)>");
//AuthorizationRules.AllowWrite(PreviousID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentItem New()
{
return new ContentItem();
}
internal static ContentItem Get(SafeDataReader dr)
{
return new ContentItem(dr);
}
public ContentItem()
{
MarkAsChild();
_ItemID = Item.NextItemID;
_DTS = _ContentItemExtension.DefaultDTS;
_UserID = _ContentItemExtension.DefaultUserID;
ValidationRules.CheckRules();
}
internal ContentItem(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode());
try
{
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentItem.FetchDR", ex);
throw new DbCslaException("ContentItem.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Item.Add(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Item.Update(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// 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"];
Item.Remove(cn, _ItemID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentItemExtension _ContentItemExtension = new ContentItemExtension();
[Serializable()]
partial class ContentItemExtension : 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 ContentItemConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentItem)
{
// Return the ToString value
return ((ContentItem)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
/// <summary>
/// ContentItem Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentItemConverter))]
public partial class ContentItem : BusinessBase<ContentItem>, 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 _ItemID;
[System.ComponentModel.DataObjectField(true, true)]
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
[System.ComponentModel.DataObjectField(true, true)]
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
}
private int? _PreviousID;
public int? PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID;
}
}
private Item _MyPrevious;
public Item MyPrevious
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID);
return _MyPrevious;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if ((_MyPrevious == null ? _PreviousID : (int?)_MyPrevious.ItemID) != (value == null ? null : (int?)value.ItemID))
{
_MyPrevious = value;
_PreviousID = (value == null ? null : (int?)value.ItemID);
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check ContentItem.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 ContentItem</returns>
protected override object GetIdValue()
{
return _ItemID;
}
// TODO: Replace base ContentItem.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentItem</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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 (_MyItem != null && (hasBrokenRules = _MyItem.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(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(PreviousID, "<Role(s)>");
//AuthorizationRules.AllowWrite(PreviousID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentItem New()
{
return new ContentItem();
}
internal static ContentItem Get(SafeDataReader dr)
{
return new ContentItem(dr);
}
public ContentItem()
{
MarkAsChild();
_ItemID = Item.NextItemID;
_DTS = _ContentItemExtension.DefaultDTS;
_UserID = _ContentItemExtension.DefaultUserID;
ValidationRules.CheckRules();
}
internal ContentItem(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode());
try
{
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentItem.FetchDR", ex);
throw new DbCslaException("ContentItem.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Item.Add(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Item.Update(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// 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"];
Item.Remove(cn, _ItemID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentItemExtension _ContentItemExtension = new ContentItemExtension();
[Serializable()]
partial class ContentItemExtension : 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 ContentItemConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentItem)
{
// Return the ToString value
return ((ContentItem)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,416 +19,404 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentPart Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentPartConverter))]
public partial class ContentPart : BusinessBase<ContentPart>, 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 _FromType;
[System.ComponentModel.DataObjectField(true, true)]
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FromType", true);
return _FromType;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItem", true);
if (_MyItem != value)
{
_MyItem = 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? _Item_PreviousID;
public int? Item_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_PreviousID", true);
return _Item_PreviousID;
}
}
private int _Item_ContentID;
public int Item_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ContentID", true);
return _Item_ContentID;
}
}
private DateTime _Item_DTS = new DateTime();
public DateTime Item_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_DTS", true);
return _Item_DTS;
}
}
private string _Item_UserID = string.Empty;
public string Item_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_UserID", true);
return _Item_UserID;
}
}
// TODO: Check ContentPart.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 ContentPart</returns>
protected override object GetIdValue()
{
return _FromType;
}
// TODO: Replace base ContentPart.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentPart</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
}
#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 (_MyItem != null && (hasBrokenRules = _MyItem.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<ContentPart>(MyItemRequired, "MyItem");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyItemRequired(ContentPart target, Csla.Validation.RuleArgs e)
{
if (target._ItemID == 0 && target._MyItem == 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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(FromType, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentPart New(int fromType, Item myItem)
{
return new ContentPart(fromType, myItem);
}
internal static ContentPart Get(SafeDataReader dr)
{
return new ContentPart(dr);
}
public ContentPart()
{
MarkAsChild();
/// <summary>
/// ContentPart Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentPartConverter))]
public partial class ContentPart : BusinessBase<ContentPart>, 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 _FromType;
[System.ComponentModel.DataObjectField(true, true)]
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _FromType;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_MyItem != value)
{
_MyItem = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int? _Item_PreviousID;
public int? Item_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Item_PreviousID;
}
}
private int _Item_ContentID;
public int Item_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Item_ContentID;
}
}
private DateTime _Item_DTS = new DateTime();
public DateTime Item_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Item_DTS;
}
}
private string _Item_UserID = string.Empty;
public string Item_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Item_UserID;
}
}
// TODO: Check ContentPart.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 ContentPart</returns>
protected override object GetIdValue()
{
return _FromType;
}
// TODO: Replace base ContentPart.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentPart</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
}
#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 (_MyItem != null && (hasBrokenRules = _MyItem.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<ContentPart>(MyItemRequired, "MyItem");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyItemRequired(ContentPart target, Csla.Validation.RuleArgs e)
{
if (target._ItemID == 0 && target._MyItem == 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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(FromType, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentPart New(int fromType, Item myItem)
{
return new ContentPart(fromType, myItem);
}
internal static ContentPart Get(SafeDataReader dr)
{
return new ContentPart(dr);
}
public ContentPart()
{
MarkAsChild();
_DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentPart(int fromType, Item myItem)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID;
_FromType = fromType;
_MyItem = myItem;
ValidationRules.CheckRules();
}
internal ContentPart(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode());
try
{
_FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_PreviousID = (int?)dr.GetValue("Item_PreviousID");
_Item_ContentID = dr.GetInt32("Item_ContentID");
_Item_DTS = dr.GetDateTime("Item_DTS");
_Item_UserID = dr.GetString("Item_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentPart.FetchDR", ex);
throw new DbCslaException("ContentPart.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Add(cn, myContent, _FromType, _MyItem, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Update(cn, myContent, _FromType, _MyItem, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// 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"];
Part.Remove(cn, myContent.ContentID, _FromType);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentPartExtension _ContentPartExtension = new ContentPartExtension();
[Serializable()]
partial class ContentPartExtension : 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 ContentPartConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentPart)
{
// Return the ToString value
return ((ContentPart)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
_DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentPart(int fromType, Item myItem)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID;
_FromType = fromType;
_MyItem = myItem;
ValidationRules.CheckRules();
}
internal ContentPart(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode());
try
{
_FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_PreviousID = (int?)dr.GetValue("Item_PreviousID");
_Item_ContentID = dr.GetInt32("Item_ContentID");
_Item_DTS = dr.GetDateTime("Item_DTS");
_Item_UserID = dr.GetString("Item_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentPart.FetchDR", ex);
throw new DbCslaException("ContentPart.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Add(cn, myContent, _FromType, _MyItem, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Update(cn, myContent, _FromType, _MyItem, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// 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"];
Part.Remove(cn, myContent.ContentID, _FromType);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentPartExtension _ContentPartExtension = new ContentPartExtension();
[Serializable()]
partial class ContentPartExtension : 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 ContentPartConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentPart)
{
// Return the ToString value
return ((ContentPart)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,509 +19,491 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentRoUsage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentRoUsageConverter))]
public partial class ContentRoUsage : BusinessBase<ContentRoUsage>, 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 _ROUsageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROUsageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROUsageID", true);
if (_MyRoUsage != null) _ROUsageID = _MyRoUsage.ROUsageID;
return _ROUsageID;
}
}
private RoUsage _MyRoUsage;
[System.ComponentModel.DataObjectField(true, true)]
public RoUsage MyRoUsage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRoUsage", true);
if (_MyRoUsage == null && _ROUsageID != 0) _MyRoUsage = RoUsage.Get(_ROUsageID);
return _MyRoUsage;
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROID", true);
return _ROID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROID", true);
if (value == null) value = string.Empty;
if (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config", true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _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 _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODb _MyRODb;
public RODb MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODb.Get(_RODbID);
return _MyRODb;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyRODb", true);
if (_MyRODb != value)
{
_MyRODb = value;
PropertyHasChanged();
}
}
}
private string _RODb_ROName = string.Empty;
/// <summary>
/// Hook for future - to allow the user to select multiple RO Databases assocaiated with on DocVersion
/// </summary>
public string RODb_ROName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_ROName", true);
return _RODb_ROName;
}
}
private string _RODb_FolderPath = string.Empty;
/// <summary>
/// Path to the RO database
/// </summary>
public string RODb_FolderPath
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_FolderPath", true);
return _RODb_FolderPath;
}
}
private string _RODb_DBConnectionString = string.Empty;
/// <summary>
/// Connection String - Default could just be the full path and name of the database
/// </summary>
public string RODb_DBConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_DBConnectionString", true);
return _RODb_DBConnectionString;
}
}
private DateTime _RODb_DTS = new DateTime();
public DateTime RODb_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_DTS", true);
return _RODb_DTS;
}
}
private string _RODb_UserID = string.Empty;
public string RODb_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_UserID", true);
return _RODb_UserID;
}
}
// TODO: Check ContentRoUsage.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 ContentRoUsage</returns>
protected override object GetIdValue()
{
return _ROUsageID;
}
// TODO: Replace base ContentRoUsage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentRoUsage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyRODb == null ? false : _MyRODb.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyRODb == null ? true : _MyRODb.IsValid); }
}
#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 (_MyRODb != null && (hasBrokenRules = _MyRODb.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(
Csla.Validation.CommonRules.StringRequired, "ROID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ROID", 16));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ValidationRules.AddRule<ContentRoUsage>(MyRODbRequired, "MyRODb");
// TODO: Add other validation rules
}
private static bool MyRODbRequired(ContentRoUsage target, Csla.Validation.RuleArgs e)
{
if (target._RODbID == 0 && target._MyRODb == 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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROUsageID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(RODbID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RODbID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentRoUsage New(string roid, RODb myRODb)
{
return new ContentRoUsage(roid, myRODb);
}
internal static ContentRoUsage Get(SafeDataReader dr)
{
return new ContentRoUsage(dr);
}
public ContentRoUsage()
{
MarkAsChild();
_ROUsageID = RoUsage.NextROUsageID;
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentRoUsage(string roid, RODb myRODb)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
_ROID = roid;
_MyRODb = myRODb;
ValidationRules.CheckRules();
}
internal ContentRoUsage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentRoUsage.FetchDR", GetHashCode());
try
{
_ROUsageID = dr.GetInt32("ROUsageID");
_ROID = dr.GetString("ROID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_RODbID = dr.GetInt32("RODbID");
_RODb_ROName = dr.GetString("RODb_ROName");
_RODb_FolderPath = dr.GetString("RODb_FolderPath");
_RODb_DBConnectionString = dr.GetString("RODb_DBConnectionString");
_RODb_DTS = dr.GetDateTime("RODb_DTS");
_RODb_UserID = dr.GetString("RODb_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentRoUsage.FetchDR", ex);
throw new DbCslaException("ContentRoUsage.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Add(cn, ref _ROUsageID, myContent, _ROID, _Config, _DTS, _UserID, _MyRODb);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Update(cn, ref _ROUsageID, myContent, _ROID, _Config, _DTS, _UserID, ref _LastChanged, _MyRODb);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// 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"];
RoUsage.Remove(cn, _ROUsageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentRoUsageExtension _ContentRoUsageExtension = new ContentRoUsageExtension();
[Serializable()]
partial class ContentRoUsageExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultContentID
{
get { return 0; }
}
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 ContentRoUsageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentRoUsage)
{
// Return the ToString value
return ((ContentRoUsage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
/// <summary>
/// ContentRoUsage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentRoUsageConverter))]
public partial class ContentRoUsage : BusinessBase<ContentRoUsage>, 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 _ROUsageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROUsageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRoUsage != null) _ROUsageID = _MyRoUsage.ROUsageID;
return _ROUsageID;
}
}
private RoUsage _MyRoUsage;
[System.ComponentModel.DataObjectField(true, true)]
public RoUsage MyRoUsage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRoUsage == null && _ROUsageID != 0) _MyRoUsage = RoUsage.Get(_ROUsageID);
return _MyRoUsage;
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODb _MyRODb;
public RODb MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODb.Get(_RODbID);
return _MyRODb;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_MyRODb != value)
{
_MyRODb = value;
PropertyHasChanged();
}
}
}
private string _RODb_ROName = string.Empty;
/// <summary>
/// Hook for future - to allow the user to select multiple RO Databases assocaiated with on DocVersion
/// </summary>
public string RODb_ROName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODb_ROName;
}
}
private string _RODb_FolderPath = string.Empty;
/// <summary>
/// Path to the RO database
/// </summary>
public string RODb_FolderPath
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODb_FolderPath;
}
}
private string _RODb_DBConnectionString = string.Empty;
/// <summary>
/// Connection String - Default could just be the full path and name of the database
/// </summary>
public string RODb_DBConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODb_DBConnectionString;
}
}
private DateTime _RODb_DTS = new DateTime();
public DateTime RODb_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODb_DTS;
}
}
private string _RODb_UserID = string.Empty;
public string RODb_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODb_UserID;
}
}
// TODO: Check ContentRoUsage.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 ContentRoUsage</returns>
protected override object GetIdValue()
{
return _ROUsageID;
}
// TODO: Replace base ContentRoUsage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentRoUsage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyRODb == null ? false : _MyRODb.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyRODb == null ? true : _MyRODb.IsValid); }
}
#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 (_MyRODb != null && (hasBrokenRules = _MyRODb.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(
Csla.Validation.CommonRules.StringRequired, "ROID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ROID", 16));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ValidationRules.AddRule<ContentRoUsage>(MyRODbRequired, "MyRODb");
// TODO: Add other validation rules
}
private static bool MyRODbRequired(ContentRoUsage target, Csla.Validation.RuleArgs e)
{
if (target._RODbID == 0 && target._MyRODb == 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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROUsageID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(RODbID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RODbID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentRoUsage New(string roid, RODb myRODb)
{
return new ContentRoUsage(roid, myRODb);
}
internal static ContentRoUsage Get(SafeDataReader dr)
{
return new ContentRoUsage(dr);
}
public ContentRoUsage()
{
MarkAsChild();
_ROUsageID = RoUsage.NextROUsageID;
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentRoUsage(string roid, RODb myRODb)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
_ROID = roid;
_MyRODb = myRODb;
ValidationRules.CheckRules();
}
internal ContentRoUsage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentRoUsage.FetchDR", GetHashCode());
try
{
_ROUsageID = dr.GetInt32("ROUsageID");
_ROID = dr.GetString("ROID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_RODbID = dr.GetInt32("RODbID");
_RODb_ROName = dr.GetString("RODb_ROName");
_RODb_FolderPath = dr.GetString("RODb_FolderPath");
_RODb_DBConnectionString = dr.GetString("RODb_DBConnectionString");
_RODb_DTS = dr.GetDateTime("RODb_DTS");
_RODb_UserID = dr.GetString("RODb_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentRoUsage.FetchDR", ex);
throw new DbCslaException("ContentRoUsage.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Add(cn, ref _ROUsageID, myContent, _ROID, _Config, _DTS, _UserID, _MyRODb);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Update(cn, ref _ROUsageID, myContent, _ROID, _Config, _DTS, _UserID, ref _LastChanged, _MyRODb);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// 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"];
RoUsage.Remove(cn, _ROUsageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentRoUsageExtension _ContentRoUsageExtension = new ContentRoUsageExtension();
[Serializable()]
partial class ContentRoUsageExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultContentID
{
get { return 0; }
}
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 ContentRoUsageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentRoUsage)
{
// Return the ToString value
return ((ContentRoUsage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,387 +19,379 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void DetailInfoEvent(object sender);
/// <summary>
/// DetailInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DetailInfoConverter))]
public partial class DetailInfo : ReadOnlyBase<DetailInfo>, IDisposable
{
public event DetailInfoEvent 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<DetailInfo> _CacheList = new List<DetailInfo>();
protected static void AddToCache(DetailInfo detailInfo)
{
if (!_CacheList.Contains(detailInfo)) _CacheList.Add(detailInfo); // In AddToCache
}
protected static void RemoveFromCache(DetailInfo detailInfo)
{
while (_CacheList.Contains(detailInfo)) _CacheList.Remove(detailInfo); // In RemoveFromCache
}
private static Dictionary<string, List<DetailInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DetailInfo>>();
private static void ConvertListToDictionary()
{
List<DetailInfo> remove = new List<DetailInfo>();
foreach (DetailInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.DetailID.ToString()))
{
_CacheByPrimaryKey[tmp.DetailID.ToString()] = new List<DetailInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.DetailID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (DetailInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(DetailInfoList lst)
{
foreach (DetailInfo item in lst) AddToCache(item);
}
protected static DetailInfo GetCachedByPrimaryKey(int detailID)
{
ConvertListToDictionary();
string key = detailID.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 Detail _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DetailID;
[System.ComponentModel.DataObjectField(true, true)]
public int DetailID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DetailID", true);
return _DetailID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemType", true);
return _ItemType;
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text", true);
return _Text;
}
}
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;
}
}
// TODO: Replace base DetailInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DetailInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DetailInfo.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 DetailInfo</returns>
protected override object GetIdValue()
{
return _DetailID;
}
#endregion
#region Factory Methods
private static int _DetailInfoUnique = 0;
private static int DetailInfoUnique
{ get { return ++_DetailInfoUnique; } }
private int _MyDetailInfoUnique = DetailInfoUnique;
public int MyDetailInfoUnique
{ get { return _MyDetailInfoUnique; } }
protected DetailInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(DetailID.ToString())) return;
List<DetailInfo> listDetailInfo = _CacheByPrimaryKey[DetailID.ToString()]; // Get the list of items
while (listDetailInfo.Contains(this)) listDetailInfo.Remove(this); // Remove the item from the list
if (listDetailInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(DetailID.ToString()); // remove the list
}
public virtual Detail Get()
{
return _Editable = Detail.Get(_DetailID);
}
public static void Refresh(Detail tmp)
{
string key = tmp.DetailID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DetailInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Detail tmp)
{
if (_ContentID != tmp.ContentID)
{
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for new value
_ItemType = tmp.ItemType;
_Text = tmp.Text;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DetailInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ContentDetail tmp)
{
string key = tmp.DetailID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DetailInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentDetail tmp)
{
_ItemType = tmp.ItemType;
_Text = tmp.Text;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DetailInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
OnChange();// raise an event
}
public static DetailInfo Get(int detailID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Detail");
try
{
DetailInfo tmp = GetCachedByPrimaryKey(detailID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DetailInfo>(new PKCriteria(detailID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up DetailInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DetailInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DetailInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.Constructor", ex);
throw new DbCslaException("DetailInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DetailID;
public int DetailID
{ get { return _DetailID; } }
public PKCriteria(int detailID)
{
_DetailID = detailID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode());
try
{
_DetailID = dr.GetInt32("DetailID");
_ContentID = dr.GetInt32("ContentID");
_ItemType = dr.GetInt32("ItemType");
_Text = dr.GetString("Text");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DetailInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.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 = "getDetail";
cm.Parameters.AddWithValue("@DetailID", criteria.DetailID);
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("DetailInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DetailInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
[Serializable()]
partial class DetailInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DetailInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DetailInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DetailInfo)
{
// Return the ToString value
return ((DetailInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void DetailInfoEvent(object sender);
/// <summary>
/// DetailInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DetailInfoConverter))]
public partial class DetailInfo : ReadOnlyBase<DetailInfo>, IDisposable
{
public event DetailInfoEvent 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<DetailInfo> _CacheList = new List<DetailInfo>();
protected static void AddToCache(DetailInfo detailInfo)
{
if (!_CacheList.Contains(detailInfo)) _CacheList.Add(detailInfo); // In AddToCache
}
protected static void RemoveFromCache(DetailInfo detailInfo)
{
while (_CacheList.Contains(detailInfo)) _CacheList.Remove(detailInfo); // In RemoveFromCache
}
private static Dictionary<string, List<DetailInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DetailInfo>>();
private static void ConvertListToDictionary()
{
List<DetailInfo> remove = new List<DetailInfo>();
foreach (DetailInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.DetailID.ToString()))
{
_CacheByPrimaryKey[tmp.DetailID.ToString()] = new List<DetailInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.DetailID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (DetailInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(DetailInfoList lst)
{
foreach (DetailInfo item in lst) AddToCache(item);
}
protected static DetailInfo GetCachedByPrimaryKey(int detailID)
{
ConvertListToDictionary();
string key = detailID.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 Detail _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DetailID;
[System.ComponentModel.DataObjectField(true, true)]
public int DetailID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DetailID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ItemType;
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Text;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
// TODO: Replace base DetailInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DetailInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DetailInfo.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 DetailInfo</returns>
protected override object GetIdValue()
{
return _DetailID;
}
#endregion
#region Factory Methods
private static int _DetailInfoUnique = 0;
private static int DetailInfoUnique
{ get { return ++_DetailInfoUnique; } }
private int _MyDetailInfoUnique = DetailInfoUnique;
public int MyDetailInfoUnique
{ get { return _MyDetailInfoUnique; } }
protected DetailInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(DetailID.ToString())) return;
List<DetailInfo> listDetailInfo = _CacheByPrimaryKey[DetailID.ToString()]; // Get the list of items
while (listDetailInfo.Contains(this)) listDetailInfo.Remove(this); // Remove the item from the list
if (listDetailInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(DetailID.ToString()); // remove the list
}
public virtual Detail Get()
{
return _Editable = Detail.Get(_DetailID);
}
public static void Refresh(Detail tmp)
{
string key = tmp.DetailID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DetailInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Detail tmp)
{
if (_ContentID != tmp.ContentID)
{
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for new value
_ItemType = tmp.ItemType;
_Text = tmp.Text;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DetailInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ContentDetail tmp)
{
string key = tmp.DetailID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DetailInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentDetail tmp)
{
_ItemType = tmp.ItemType;
_Text = tmp.Text;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DetailInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
OnChange();// raise an event
}
public static DetailInfo Get(int detailID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Detail");
try
{
DetailInfo tmp = GetCachedByPrimaryKey(detailID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DetailInfo>(new PKCriteria(detailID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up DetailInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DetailInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DetailInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.Constructor", ex);
throw new DbCslaException("DetailInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DetailID;
public int DetailID
{ get { return _DetailID; } }
public PKCriteria(int detailID)
{
_DetailID = detailID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode());
try
{
_DetailID = dr.GetInt32("DetailID");
_ContentID = dr.GetInt32("ContentID");
_ItemType = dr.GetInt32("ItemType");
_Text = dr.GetString("Text");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DetailInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.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 = "getDetail";
cm.Parameters.AddWithValue("@DetailID", criteria.DetailID);
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("DetailInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DetailInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
[Serializable()]
partial class DetailInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DetailInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DetailInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DetailInfo)
{
// Return the ToString value
return ((DetailInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,374 +19,363 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// DocVersionDocVersionROFst Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocVersionDocVersionROFstConverter))]
public partial class DocVersionDocVersionROFst : BusinessBase<DocVersionDocVersionROFst>, 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 _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFst _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFst MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROFst", true);
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFst.Get(_ROFstID);
return _MyROFst;
}
}
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 _ROFst_RODbID;
public int ROFst_RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_RODbID", true);
return _ROFst_RODbID;
}
}
private byte[] _ROFst_ROFST;
public byte[] ROFst_ROFST
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_ROFST", true);
return _ROFst_ROFST;
}
}
private DateTime _ROFst_DTS = new DateTime();
public DateTime ROFst_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_DTS", true);
return _ROFst_DTS;
}
}
private string _ROFst_UserID = string.Empty;
public string ROFst_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_UserID", true);
return _ROFst_UserID;
}
}
// TODO: Check DocVersionDocVersionROFst.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 DocVersionDocVersionROFst</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
// TODO: Replace base DocVersionDocVersionROFst.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocVersionDocVersionROFst</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROFstID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static DocVersionDocVersionROFst New(ROFst myROFst)
{
return new DocVersionDocVersionROFst(myROFst);
}
internal static DocVersionDocVersionROFst Get(SafeDataReader dr)
{
return new DocVersionDocVersionROFst(dr);
}
public DocVersionDocVersionROFst()
{
MarkAsChild();
/// <summary>
/// DocVersionDocVersionROFst Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocVersionDocVersionROFstConverter))]
public partial class DocVersionDocVersionROFst : BusinessBase<DocVersionDocVersionROFst>, 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 _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
}
}
private ROFst _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFst MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFst.Get(_ROFstID);
return _MyROFst;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _ROFst_RODbID;
public int ROFst_RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFst_RODbID;
}
}
private byte[] _ROFst_ROFST;
public byte[] ROFst_ROFST
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFst_ROFST;
}
}
private DateTime _ROFst_DTS = new DateTime();
public DateTime ROFst_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFst_DTS;
}
}
private string _ROFst_UserID = string.Empty;
public string ROFst_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFst_UserID;
}
}
// TODO: Check DocVersionDocVersionROFst.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 DocVersionDocVersionROFst</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
// TODO: Replace base DocVersionDocVersionROFst.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocVersionDocVersionROFst</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROFstID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static DocVersionDocVersionROFst New(ROFst myROFst)
{
return new DocVersionDocVersionROFst(myROFst);
}
internal static DocVersionDocVersionROFst Get(SafeDataReader dr)
{
return new DocVersionDocVersionROFst(dr);
}
public DocVersionDocVersionROFst()
{
MarkAsChild();
_DTS = _DocVersionDocVersionROFstExtension.DefaultDTS;
_UserID = _DocVersionDocVersionROFstExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private DocVersionDocVersionROFst(ROFst myROFst)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _DocVersionDocVersionROFstExtension.DefaultDTS;
_UserID = _DocVersionDocVersionROFstExtension.DefaultUserID;
_MyROFst = myROFst;
ValidationRules.CheckRules();
}
internal DocVersionDocVersionROFst(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionDocVersionROFst.FetchDR", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROFst_RODbID = dr.GetInt32("ROFst_RODbID");
_ROFst_ROFST = (byte[])dr.GetValue("ROFst_ROFST");
_ROFst_DTS = dr.GetDateTime("ROFst_DTS");
_ROFst_UserID = dr.GetString("ROFst_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionDocVersionROFst.FetchDR", ex);
throw new DbCslaException("DocVersionDocVersionROFst.Fetch", ex);
}
MarkOld();
}
internal void Insert(DocVersion myDocVersion)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersionROFst.Add(cn, myDocVersion, _MyROFst, _DTS, _UserID);
MarkOld();
}
internal void Update(DocVersion myDocVersion)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersionROFst.Update(cn, myDocVersion, _MyROFst, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(DocVersion myDocVersion)
{
// 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"];
DocVersionROFst.Remove(cn, myDocVersion.VersionID, _ROFstID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
DocVersionDocVersionROFstExtension _DocVersionDocVersionROFstExtension = new DocVersionDocVersionROFstExtension();
[Serializable()]
partial class DocVersionDocVersionROFstExtension : 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 DocVersionDocVersionROFstConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocVersionDocVersionROFst)
{
// Return the ToString value
return ((DocVersionDocVersionROFst)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
_DTS = _DocVersionDocVersionROFstExtension.DefaultDTS;
_UserID = _DocVersionDocVersionROFstExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private DocVersionDocVersionROFst(ROFst myROFst)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _DocVersionDocVersionROFstExtension.DefaultDTS;
_UserID = _DocVersionDocVersionROFstExtension.DefaultUserID;
_MyROFst = myROFst;
ValidationRules.CheckRules();
}
internal DocVersionDocVersionROFst(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionDocVersionROFst.FetchDR", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROFst_RODbID = dr.GetInt32("ROFst_RODbID");
_ROFst_ROFST = (byte[])dr.GetValue("ROFst_ROFST");
_ROFst_DTS = dr.GetDateTime("ROFst_DTS");
_ROFst_UserID = dr.GetString("ROFst_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionDocVersionROFst.FetchDR", ex);
throw new DbCslaException("DocVersionDocVersionROFst.Fetch", ex);
}
MarkOld();
}
internal void Insert(DocVersion myDocVersion)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersionROFst.Add(cn, myDocVersion, _MyROFst, _DTS, _UserID);
MarkOld();
}
internal void Update(DocVersion myDocVersion)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersionROFst.Update(cn, myDocVersion, _MyROFst, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(DocVersion myDocVersion)
{
// 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"];
DocVersionROFst.Remove(cn, myDocVersion.VersionID, _ROFstID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
DocVersionDocVersionROFstExtension _DocVersionDocVersionROFstExtension = new DocVersionDocVersionROFstExtension();
[Serializable()]
partial class DocVersionDocVersionROFstExtension : 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 DocVersionDocVersionROFstConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocVersionDocVersionROFst)
{
// Return the ToString value
return ((DocVersionDocVersionROFst)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,396 +19,390 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void DocVersionROFstInfoEvent(object sender);
/// <summary>
/// DocVersionROFstInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocVersionROFstInfoConverter))]
public partial class DocVersionROFstInfo : ReadOnlyBase<DocVersionROFstInfo>, IDisposable
{
public event DocVersionROFstInfoEvent 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<DocVersionROFstInfo> _CacheList = new List<DocVersionROFstInfo>();
protected static void AddToCache(DocVersionROFstInfo docVersionROFstInfo)
{
if (!_CacheList.Contains(docVersionROFstInfo)) _CacheList.Add(docVersionROFstInfo); // In AddToCache
}
protected static void RemoveFromCache(DocVersionROFstInfo docVersionROFstInfo)
{
while (_CacheList.Contains(docVersionROFstInfo)) _CacheList.Remove(docVersionROFstInfo); // In RemoveFromCache
}
private static Dictionary<string, List<DocVersionROFstInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocVersionROFstInfo>>();
private static void ConvertListToDictionary()
{
List<DocVersionROFstInfo> remove = new List<DocVersionROFstInfo>();
foreach (DocVersionROFstInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.VersionID.ToString() + "_" + tmp.ROFstID.ToString()))
{
_CacheByPrimaryKey[tmp.VersionID.ToString() + "_" + tmp.ROFstID.ToString()] = new List<DocVersionROFstInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.VersionID.ToString() + "_" + tmp.ROFstID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (DocVersionROFstInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(DocVersionROFstInfoList lst)
{
foreach (DocVersionROFstInfo item in lst) AddToCache(item);
}
protected static DocVersionROFstInfo GetCachedByPrimaryKey(int versionID, int rOFstID)
{
ConvertListToDictionary();
string key = versionID.ToString() + "_" + rOFstID.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 DocVersionROFst _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);
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID;
}
}
private DocVersionInfo _MyDocVersion;
[System.ComponentModel.DataObjectField(true, true)]
public DocVersionInfo MyDocVersion
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDocVersion", true);
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersionInfo.Get(_VersionID);
return _MyDocVersion;
}
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFstInfo _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFstInfo MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROFst", true);
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.Get(_ROFstID);
return _MyROFst;
}
}
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;
}
}
// TODO: Replace base DocVersionROFstInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocVersionROFstInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocVersionROFstInfo.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 DocVersionROFstInfo</returns>
protected override object GetIdValue()
{
return (_VersionID.ToString() + "." + _ROFstID.ToString()).GetHashCode();
}
#endregion
#region Factory Methods
private static int _DocVersionROFstInfoUnique = 0;
private static int DocVersionROFstInfoUnique
{ get { return ++_DocVersionROFstInfoUnique; } }
private int _MyDocVersionROFstInfoUnique = DocVersionROFstInfoUnique;
public int MyDocVersionROFstInfoUnique
{ get { return _MyDocVersionROFstInfoUnique; } }
protected DocVersionROFstInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(VersionID.ToString() + "_" + ROFstID.ToString())) return;
List<DocVersionROFstInfo> listDocVersionROFstInfo = _CacheByPrimaryKey[VersionID.ToString() + "_" + ROFstID.ToString()]; // Get the list of items
while (listDocVersionROFstInfo.Contains(this)) listDocVersionROFstInfo.Remove(this); // Remove the item from the list
if (listDocVersionROFstInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(VersionID.ToString() + "_" + ROFstID.ToString()); // remove the list
}
public virtual DocVersionROFst Get()
{
return _Editable = DocVersionROFst.Get(_VersionID, _ROFstID);
}
public static void Refresh(DocVersionROFst tmp)
{
string key = tmp.VersionID.ToString() + "_" + tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocVersionROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(DocVersionROFst tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionROFstInfoExtension.Refresh(this);
if(_MyDocVersion != null)
{
_MyDocVersion.Dispose();// Dispose related value
_MyDocVersion = null;// Reset related value
}
if(_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(DocVersion myDocVersion, DocVersionDocVersionROFst tmp)
{
string key = myDocVersion.VersionID.ToString() + "_" + tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocVersionROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(DocVersionDocVersionROFst tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionROFstInfoExtension.Refresh(this);
if(_MyDocVersion != null)
{
_MyDocVersion.Dispose();// Dispose related value
_MyDocVersion = null;// Reset related value
}
if(_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ROFst myROFst, ROFstDocVersionROFst tmp)
{
string key = tmp.VersionID.ToString() + "_" + myROFst.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocVersionROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFstDocVersionROFst tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionROFstInfoExtension.Refresh(this);
if(_MyDocVersion != null)
{
_MyDocVersion.Dispose();// Dispose related value
_MyDocVersion = null;// Reset related value
}
if(_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
OnChange();// raise an event
}
public static DocVersionROFstInfo Get(int versionID, int rOFstID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a DocVersionROFst");
try
{
DocVersionROFstInfo tmp = GetCachedByPrimaryKey(versionID, rOFstID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocVersionROFstInfo>(new PKCriteria(versionID, rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up DocVersionROFstInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocVersionROFstInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DocVersionROFstInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionROFstInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionROFstInfo.Constructor", ex);
throw new DbCslaException("DocVersionROFstInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _VersionID;
public int VersionID
{ get { return _VersionID; } }
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteria(int versionID, int rOFstID)
{
_VersionID = versionID;
_ROFstID = rOFstID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionROFstInfo.ReadData", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_ROFstID = dr.GetInt32("ROFstID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionROFstInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocVersionROFstInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionROFstInfo.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 = "getDocVersionROFst";
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
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("DocVersionROFstInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocVersionROFstInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DocVersionROFstInfoExtension _DocVersionROFstInfoExtension = new DocVersionROFstInfoExtension();
[Serializable()]
partial class DocVersionROFstInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DocVersionROFstInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DocVersionROFstInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocVersionROFstInfo)
{
// Return the ToString value
return ((DocVersionROFstInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void DocVersionROFstInfoEvent(object sender);
/// <summary>
/// DocVersionROFstInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocVersionROFstInfoConverter))]
public partial class DocVersionROFstInfo : ReadOnlyBase<DocVersionROFstInfo>, IDisposable
{
public event DocVersionROFstInfoEvent 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<DocVersionROFstInfo> _CacheList = new List<DocVersionROFstInfo>();
protected static void AddToCache(DocVersionROFstInfo docVersionROFstInfo)
{
if (!_CacheList.Contains(docVersionROFstInfo)) _CacheList.Add(docVersionROFstInfo); // In AddToCache
}
protected static void RemoveFromCache(DocVersionROFstInfo docVersionROFstInfo)
{
while (_CacheList.Contains(docVersionROFstInfo)) _CacheList.Remove(docVersionROFstInfo); // In RemoveFromCache
}
private static Dictionary<string, List<DocVersionROFstInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocVersionROFstInfo>>();
private static void ConvertListToDictionary()
{
List<DocVersionROFstInfo> remove = new List<DocVersionROFstInfo>();
foreach (DocVersionROFstInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.VersionID.ToString() + "_" + tmp.ROFstID.ToString()))
{
_CacheByPrimaryKey[tmp.VersionID.ToString() + "_" + tmp.ROFstID.ToString()] = new List<DocVersionROFstInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.VersionID.ToString() + "_" + tmp.ROFstID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (DocVersionROFstInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(DocVersionROFstInfoList lst)
{
foreach (DocVersionROFstInfo item in lst) AddToCache(item);
}
protected static DocVersionROFstInfo GetCachedByPrimaryKey(int versionID, int rOFstID)
{
ConvertListToDictionary();
string key = versionID.ToString() + "_" + rOFstID.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 DocVersionROFst _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
{
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID;
}
}
private DocVersionInfo _MyDocVersion;
[System.ComponentModel.DataObjectField(true, true)]
public DocVersionInfo MyDocVersion
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersionInfo.Get(_VersionID);
return _MyDocVersion;
}
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFstInfo _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFstInfo MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.Get(_ROFstID);
return _MyROFst;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
// TODO: Replace base DocVersionROFstInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocVersionROFstInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocVersionROFstInfo.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 DocVersionROFstInfo</returns>
protected override object GetIdValue()
{
return (_VersionID.ToString() + "." + _ROFstID.ToString()).GetHashCode();
}
#endregion
#region Factory Methods
private static int _DocVersionROFstInfoUnique = 0;
private static int DocVersionROFstInfoUnique
{ get { return ++_DocVersionROFstInfoUnique; } }
private int _MyDocVersionROFstInfoUnique = DocVersionROFstInfoUnique;
public int MyDocVersionROFstInfoUnique
{ get { return _MyDocVersionROFstInfoUnique; } }
protected DocVersionROFstInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(VersionID.ToString() + "_" + ROFstID.ToString())) return;
List<DocVersionROFstInfo> listDocVersionROFstInfo = _CacheByPrimaryKey[VersionID.ToString() + "_" + ROFstID.ToString()]; // Get the list of items
while (listDocVersionROFstInfo.Contains(this)) listDocVersionROFstInfo.Remove(this); // Remove the item from the list
if (listDocVersionROFstInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(VersionID.ToString() + "_" + ROFstID.ToString()); // remove the list
}
public virtual DocVersionROFst Get()
{
return _Editable = DocVersionROFst.Get(_VersionID, _ROFstID);
}
public static void Refresh(DocVersionROFst tmp)
{
string key = tmp.VersionID.ToString() + "_" + tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocVersionROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(DocVersionROFst tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionROFstInfoExtension.Refresh(this);
if (_MyDocVersion != null)
{
_MyDocVersion.Dispose();// Dispose related value
_MyDocVersion = null;// Reset related value
}
if (_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(DocVersion myDocVersion, DocVersionDocVersionROFst tmp)
{
string key = myDocVersion.VersionID.ToString() + "_" + tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocVersionROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(DocVersionDocVersionROFst tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionROFstInfoExtension.Refresh(this);
if (_MyDocVersion != null)
{
_MyDocVersion.Dispose();// Dispose related value
_MyDocVersion = null;// Reset related value
}
if (_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ROFst myROFst, ROFstDocVersionROFst tmp)
{
string key = tmp.VersionID.ToString() + "_" + myROFst.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocVersionROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFstDocVersionROFst tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionROFstInfoExtension.Refresh(this);
if (_MyDocVersion != null)
{
_MyDocVersion.Dispose();// Dispose related value
_MyDocVersion = null;// Reset related value
}
if (_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
OnChange();// raise an event
}
public static DocVersionROFstInfo Get(int versionID, int rOFstID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a DocVersionROFst");
try
{
DocVersionROFstInfo tmp = GetCachedByPrimaryKey(versionID, rOFstID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocVersionROFstInfo>(new PKCriteria(versionID, rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up DocVersionROFstInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocVersionROFstInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DocVersionROFstInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionROFstInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionROFstInfo.Constructor", ex);
throw new DbCslaException("DocVersionROFstInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _VersionID;
public int VersionID
{ get { return _VersionID; } }
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteria(int versionID, int rOFstID)
{
_VersionID = versionID;
_ROFstID = rOFstID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionROFstInfo.ReadData", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_ROFstID = dr.GetInt32("ROFstID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocVersionROFstInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocVersionROFstInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionROFstInfo.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 = "getDocVersionROFst";
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
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("DocVersionROFstInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocVersionROFstInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DocVersionROFstInfoExtension _DocVersionROFstInfoExtension = new DocVersionROFstInfoExtension();
[Serializable()]
partial class DocVersionROFstInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DocVersionROFstInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DocVersionROFstInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocVersionROFstInfo)
{
// Return the ToString value
return ((DocVersionROFstInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,410 +19,397 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// DocumentEntry Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentEntryConverter))]
public partial class DocumentEntry : BusinessBase<DocumentEntry>, 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 _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyEntry != null) _ContentID = _MyEntry.ContentID;
return _ContentID;
}
}
private Entry _MyEntry;
[System.ComponentModel.DataObjectField(true, true)]
public Entry MyEntry
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyEntry", true);
if (_MyEntry == null && _ContentID != 0) _MyEntry = Entry.Get(_ContentID);
return _MyEntry;
}
}
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 _Content_Number = string.Empty;
public string Content_Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Number", true);
return _Content_Number;
}
}
private string _Content_Text = string.Empty;
public string Content_Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Text", true);
return _Content_Text;
}
}
private int? _Content_Type;
/// <summary>
/// 0 - Procedure, 10000 - Section, 20000 Step
/// </summary>
public int? Content_Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Type", true);
return _Content_Type;
}
}
private int? _Content_FormatID;
public int? Content_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_FormatID", true);
return _Content_FormatID;
}
}
private string _Content_Config = string.Empty;
public string Content_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Config", true);
return _Content_Config;
}
}
private DateTime _Content_DTS = new DateTime();
public DateTime Content_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_DTS", true);
return _Content_DTS;
}
}
private string _Content_UserID = string.Empty;
public string Content_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_UserID", true);
return _Content_UserID;
}
}
// TODO: Check DocumentEntry.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 DocumentEntry</returns>
protected override object GetIdValue()
{
return _ContentID;
}
// TODO: Replace base DocumentEntry.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentEntry</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ContentID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static DocumentEntry New(Entry myEntry)
{
return new DocumentEntry(myEntry);
}
internal static DocumentEntry Get(SafeDataReader dr)
{
return new DocumentEntry(dr);
}
public DocumentEntry()
{
MarkAsChild();
/// <summary>
/// DocumentEntry Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentEntryConverter))]
public partial class DocumentEntry : BusinessBase<DocumentEntry>, 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 _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyEntry != null) _ContentID = _MyEntry.ContentID;
return _ContentID;
}
}
private Entry _MyEntry;
[System.ComponentModel.DataObjectField(true, true)]
public Entry MyEntry
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyEntry == null && _ContentID != 0) _MyEntry = Entry.Get(_ContentID);
return _MyEntry;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Content_Number = string.Empty;
public string Content_Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_Number;
}
}
private string _Content_Text = string.Empty;
public string Content_Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_Text;
}
}
private int? _Content_Type;
/// <summary>
/// 0 - Procedure, 10000 - Section, 20000 Step
/// </summary>
public int? Content_Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_Type;
}
}
private int? _Content_FormatID;
public int? Content_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_FormatID;
}
}
private string _Content_Config = string.Empty;
public string Content_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_Config;
}
}
private DateTime _Content_DTS = new DateTime();
public DateTime Content_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_DTS;
}
}
private string _Content_UserID = string.Empty;
public string Content_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_UserID;
}
}
// TODO: Check DocumentEntry.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 DocumentEntry</returns>
protected override object GetIdValue()
{
return _ContentID;
}
// TODO: Replace base DocumentEntry.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentEntry</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ContentID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static DocumentEntry New(Entry myEntry)
{
return new DocumentEntry(myEntry);
}
internal static DocumentEntry Get(SafeDataReader dr)
{
return new DocumentEntry(dr);
}
public DocumentEntry()
{
MarkAsChild();
_DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private DocumentEntry(Entry myEntry)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID;
_MyEntry = myEntry;
ValidationRules.CheckRules();
}
internal DocumentEntry(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Content_Number = dr.GetString("Content_Number");
_Content_Text = dr.GetString("Content_Text");
_Content_Type = (int?)dr.GetValue("Content_Type");
_Content_FormatID = (int?)dr.GetValue("Content_FormatID");
_Content_Config = dr.GetString("Content_Config");
_Content_DTS = dr.GetDateTime("Content_DTS");
_Content_UserID = dr.GetString("Content_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentEntry.FetchDR", ex);
throw new DbCslaException("DocumentEntry.Fetch", ex);
}
MarkOld();
}
internal void Insert(Document myDocument)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Entry.Add(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID);
MarkOld();
}
internal void Update(Document myDocument)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Entry.Update(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Document myDocument)
{
// 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"];
Entry.Remove(cn, _ContentID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
DocumentEntryExtension _DocumentEntryExtension = new DocumentEntryExtension();
[Serializable()]
partial class DocumentEntryExtension : 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 DocumentEntryConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentEntry)
{
// Return the ToString value
return ((DocumentEntry)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
_DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private DocumentEntry(Entry myEntry)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID;
_MyEntry = myEntry;
ValidationRules.CheckRules();
}
internal DocumentEntry(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Content_Number = dr.GetString("Content_Number");
_Content_Text = dr.GetString("Content_Text");
_Content_Type = (int?)dr.GetValue("Content_Type");
_Content_FormatID = (int?)dr.GetValue("Content_FormatID");
_Content_Config = dr.GetString("Content_Config");
_Content_DTS = dr.GetDateTime("Content_DTS");
_Content_UserID = dr.GetString("Content_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentEntry.FetchDR", ex);
throw new DbCslaException("DocumentEntry.Fetch", ex);
}
MarkOld();
}
internal void Insert(Document myDocument)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Entry.Add(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID);
MarkOld();
}
internal void Update(Document myDocument)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Entry.Update(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Document myDocument)
{
// 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"];
Entry.Remove(cn, _ContentID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
DocumentEntryExtension _DocumentEntryExtension = new DocumentEntryExtension();
[Serializable()]
partial class DocumentEntryExtension : 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 DocumentEntryConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentEntry)
{
// Return the ToString value
return ((DocumentEntry)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,383 +19,374 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void DocumentInfoEvent(object sender);
/// <summary>
/// DocumentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentInfoConverter))]
public partial class DocumentInfo : ReadOnlyBase<DocumentInfo>, IDisposable
{
public event DocumentInfoEvent 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<DocumentInfo> _CacheList = new List<DocumentInfo>();
protected static void AddToCache(DocumentInfo documentInfo)
{
if (!_CacheList.Contains(documentInfo)) _CacheList.Add(documentInfo); // In AddToCache
}
protected static void RemoveFromCache(DocumentInfo documentInfo)
{
while (_CacheList.Contains(documentInfo)) _CacheList.Remove(documentInfo); // In RemoveFromCache
}
private static Dictionary<string, List<DocumentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentInfo>>();
private static void ConvertListToDictionary()
{
List<DocumentInfo> remove = new List<DocumentInfo>();
foreach (DocumentInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.DocID.ToString()))
{
_CacheByPrimaryKey[tmp.DocID.ToString()] = new List<DocumentInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.DocID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (DocumentInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(DocumentInfoList lst)
{
foreach (DocumentInfo item in lst) AddToCache(item);
}
protected static DocumentInfo GetCachedByPrimaryKey(int docID)
{
ConvertListToDictionary();
string key = docID.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 Document _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DocID;
[System.ComponentModel.DataObjectField(true, true)]
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID", true);
return _DocID;
}
}
private string _LibTitle = string.Empty;
public string LibTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("LibTitle", true);
return _LibTitle;
}
}
private byte[] _DocContent;
/// <summary>
/// Actual content of a Word Document (RTF, DOC or XML Format)
/// </summary>
public byte[] DocContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocContent", true);
return _DocContent;
}
}
private string _DocAscii = string.Empty;
/// <summary>
/// Used for searching
/// </summary>
public string DocAscii
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocAscii", true);
return _DocAscii;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _DocumentEntryCount = 0;
/// <summary>
/// Count of DocumentEntries for this Document
/// </summary>
public int DocumentEntryCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocumentEntryCount", true);
return _DocumentEntryCount;
}
}
private EntryInfoList _DocumentEntries = null;
[TypeConverter(typeof(EntryInfoListConverter))]
public EntryInfoList DocumentEntries
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocumentEntries", true);
if (_DocumentEntryCount < 0 || (_DocumentEntryCount > 0 && _DocumentEntries == null))
_DocumentEntries = EntryInfoList.GetByDocID(_DocID);
if (_DocumentEntryCount < 0)
_DocumentEntryCount = _DocumentEntries.Count;
return _DocumentEntries;
}
}
public void RefreshDocumentEntries()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString()))
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
tmp._DocumentEntryCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base DocumentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocumentInfo.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 DocumentInfo</returns>
protected override object GetIdValue()
{
return _DocID;
}
#endregion
#region Factory Methods
private static int _DocumentInfoUnique = 0;
private static int DocumentInfoUnique
{ get { return ++_DocumentInfoUnique; } }
private int _MyDocumentInfoUnique = DocumentInfoUnique;
public int MyDocumentInfoUnique
{ get { return _MyDocumentInfoUnique; } }
protected DocumentInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(DocID.ToString())) return;
List<DocumentInfo> listDocumentInfo = _CacheByPrimaryKey[DocID.ToString()]; // Get the list of items
while (listDocumentInfo.Contains(this)) listDocumentInfo.Remove(this); // Remove the item from the list
if (listDocumentInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(DocID.ToString()); // remove the list
}
public virtual Document Get()
{
return _Editable = Document.Get(_DocID);
}
public static void Refresh(Document tmp)
{
string key = tmp.DocID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocumentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Document tmp)
{
_LibTitle = tmp.LibTitle;
_DocContent = tmp.DocContent;
_DocAscii = tmp.DocAscii;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocumentInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static DocumentInfo Get(int docID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Document");
try
{
DocumentInfo tmp = GetCachedByPrimaryKey(docID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocumentInfo>(new PKCriteria(docID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up DocumentInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DocumentInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.Constructor", ex);
throw new DbCslaException("DocumentInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DocID;
public int DocID
{ get { return _DocID; } }
public PKCriteria(int docID)
{
_DocID = docID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode());
try
{
_DocID = dr.GetInt32("DocID");
_LibTitle = dr.GetString("LibTitle");
_DocContent = (byte[])dr.GetValue("DocContent");
_DocAscii = dr.GetString("DocAscii");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DocumentEntryCount = dr.GetInt32("EntryCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.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 = "getDocument";
cm.Parameters.AddWithValue("@DocID", criteria.DocID);
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("DocumentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
[Serializable()]
partial class DocumentInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DocumentInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DocumentInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentInfo)
{
// Return the ToString value
return ((DocumentInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void DocumentInfoEvent(object sender);
/// <summary>
/// DocumentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentInfoConverter))]
public partial class DocumentInfo : ReadOnlyBase<DocumentInfo>, IDisposable
{
public event DocumentInfoEvent 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<DocumentInfo> _CacheList = new List<DocumentInfo>();
protected static void AddToCache(DocumentInfo documentInfo)
{
if (!_CacheList.Contains(documentInfo)) _CacheList.Add(documentInfo); // In AddToCache
}
protected static void RemoveFromCache(DocumentInfo documentInfo)
{
while (_CacheList.Contains(documentInfo)) _CacheList.Remove(documentInfo); // In RemoveFromCache
}
private static Dictionary<string, List<DocumentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentInfo>>();
private static void ConvertListToDictionary()
{
List<DocumentInfo> remove = new List<DocumentInfo>();
foreach (DocumentInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.DocID.ToString()))
{
_CacheByPrimaryKey[tmp.DocID.ToString()] = new List<DocumentInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.DocID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (DocumentInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(DocumentInfoList lst)
{
foreach (DocumentInfo item in lst) AddToCache(item);
}
protected static DocumentInfo GetCachedByPrimaryKey(int docID)
{
ConvertListToDictionary();
string key = docID.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 Document _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DocID;
[System.ComponentModel.DataObjectField(true, true)]
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocID;
}
}
private string _LibTitle = string.Empty;
public string LibTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _LibTitle;
}
}
private byte[] _DocContent;
/// <summary>
/// Actual content of a Word Document (RTF, DOC or XML Format)
/// </summary>
public byte[] DocContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocContent;
}
}
private string _DocAscii = string.Empty;
/// <summary>
/// Used for searching
/// </summary>
public string DocAscii
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocAscii;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
private int _DocumentEntryCount = 0;
/// <summary>
/// Count of DocumentEntries for this Document
/// </summary>
public int DocumentEntryCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocumentEntryCount;
}
}
private EntryInfoList _DocumentEntries = null;
[TypeConverter(typeof(EntryInfoListConverter))]
public EntryInfoList DocumentEntries
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_DocumentEntryCount < 0 || (_DocumentEntryCount > 0 && _DocumentEntries == null))
_DocumentEntries = EntryInfoList.GetByDocID(_DocID);
if (_DocumentEntryCount < 0)
_DocumentEntryCount = _DocumentEntries.Count;
return _DocumentEntries;
}
}
public void RefreshDocumentEntries()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString()))
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
tmp._DocumentEntryCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base DocumentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocumentInfo.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 DocumentInfo</returns>
protected override object GetIdValue()
{
return _DocID;
}
#endregion
#region Factory Methods
private static int _DocumentInfoUnique = 0;
private static int DocumentInfoUnique
{ get { return ++_DocumentInfoUnique; } }
private int _MyDocumentInfoUnique = DocumentInfoUnique;
public int MyDocumentInfoUnique
{ get { return _MyDocumentInfoUnique; } }
protected DocumentInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(DocID.ToString())) return;
List<DocumentInfo> listDocumentInfo = _CacheByPrimaryKey[DocID.ToString()]; // Get the list of items
while (listDocumentInfo.Contains(this)) listDocumentInfo.Remove(this); // Remove the item from the list
if (listDocumentInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(DocID.ToString()); // remove the list
}
public virtual Document Get()
{
return _Editable = Document.Get(_DocID);
}
public static void Refresh(Document tmp)
{
string key = tmp.DocID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocumentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Document tmp)
{
_LibTitle = tmp.LibTitle;
_DocContent = tmp.DocContent;
_DocAscii = tmp.DocAscii;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocumentInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static DocumentInfo Get(int docID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Document");
try
{
DocumentInfo tmp = GetCachedByPrimaryKey(docID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocumentInfo>(new PKCriteria(docID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up DocumentInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DocumentInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.Constructor", ex);
throw new DbCslaException("DocumentInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DocID;
public int DocID
{ get { return _DocID; } }
public PKCriteria(int docID)
{
_DocID = docID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode());
try
{
_DocID = dr.GetInt32("DocID");
_LibTitle = dr.GetString("LibTitle");
_DocContent = (byte[])dr.GetValue("DocContent");
_DocAscii = dr.GetString("DocAscii");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DocumentEntryCount = dr.GetInt32("EntryCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.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 = "getDocument";
cm.Parameters.AddWithValue("@DocID", criteria.DocID);
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("DocumentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
[Serializable()]
partial class DocumentInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DocumentInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DocumentInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentInfo)
{
// Return the ToString value
return ((DocumentInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,371 +19,365 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void EntryInfoEvent(object sender);
/// <summary>
/// EntryInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(EntryInfoConverter))]
public partial class EntryInfo : ReadOnlyBase<EntryInfo>, IDisposable
{
public event EntryInfoEvent 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<EntryInfo> _CacheList = new List<EntryInfo>();
protected static void AddToCache(EntryInfo entryInfo)
{
if (!_CacheList.Contains(entryInfo)) _CacheList.Add(entryInfo); // In AddToCache
}
protected static void RemoveFromCache(EntryInfo entryInfo)
{
while (_CacheList.Contains(entryInfo)) _CacheList.Remove(entryInfo); // In RemoveFromCache
}
private static Dictionary<string, List<EntryInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryInfo>>();
private static void ConvertListToDictionary()
{
List<EntryInfo> remove = new List<EntryInfo>();
foreach (EntryInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<EntryInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (EntryInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(EntryInfoList lst)
{
foreach (EntryInfo item in lst) AddToCache(item);
}
protected static EntryInfo GetCachedByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.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 Entry _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private int _DocID;
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID", true);
if (_MyDocument != null) _DocID = _MyDocument.DocID;
return _DocID;
}
}
private DocumentInfo _MyDocument;
public DocumentInfo MyDocument
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDocument", true);
if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID);
return _MyDocument;
}
}
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;
}
}
// TODO: Replace base EntryInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current EntryInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check EntryInfo.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 EntryInfo</returns>
protected override object GetIdValue()
{
return _ContentID;
}
#endregion
#region Factory Methods
private static int _EntryInfoUnique = 0;
private static int EntryInfoUnique
{ get { return ++_EntryInfoUnique; } }
private int _MyEntryInfoUnique = EntryInfoUnique;
public int MyEntryInfoUnique
{ get { return _MyEntryInfoUnique; } }
protected EntryInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<EntryInfo> listEntryInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
while (listEntryInfo.Contains(this)) listEntryInfo.Remove(this); // Remove the item from the list
if (listEntryInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual Entry Get()
{
return _Editable = Entry.Get(_ContentID);
}
public static void Refresh(Entry tmp)
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (EntryInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Entry tmp)
{
if (_DocID != tmp.DocID)
{
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for old value
_DocID = tmp.DocID; // Update the value
}
_MyDocument = null; // Reset list so that the next line gets a new list
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyDocument != null)
{
_MyDocument.Dispose();// Dispose related value
_MyDocument = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(DocumentEntry tmp)
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (EntryInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(DocumentEntry tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyDocument != null)
{
_MyDocument.Dispose();// Dispose related value
_MyDocument = null;// Reset related value
}
OnChange();// raise an event
}
public static EntryInfo Get(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Entry");
try
{
EntryInfo tmp = GetCachedByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up EntryInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal EntryInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.Constructor", ex);
throw new DbCslaException("EntryInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
public PKCriteria(int contentID)
{
_ContentID = contentID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_DocID = dr.GetInt32("DocID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.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 = "getEntry";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
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("EntryInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
[Serializable()]
partial class EntryInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(EntryInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class EntryInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is EntryInfo)
{
// Return the ToString value
return ((EntryInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void EntryInfoEvent(object sender);
/// <summary>
/// EntryInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(EntryInfoConverter))]
public partial class EntryInfo : ReadOnlyBase<EntryInfo>, IDisposable
{
public event EntryInfoEvent 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<EntryInfo> _CacheList = new List<EntryInfo>();
protected static void AddToCache(EntryInfo entryInfo)
{
if (!_CacheList.Contains(entryInfo)) _CacheList.Add(entryInfo); // In AddToCache
}
protected static void RemoveFromCache(EntryInfo entryInfo)
{
while (_CacheList.Contains(entryInfo)) _CacheList.Remove(entryInfo); // In RemoveFromCache
}
private static Dictionary<string, List<EntryInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryInfo>>();
private static void ConvertListToDictionary()
{
List<EntryInfo> remove = new List<EntryInfo>();
foreach (EntryInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<EntryInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (EntryInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(EntryInfoList lst)
{
foreach (EntryInfo item in lst) AddToCache(item);
}
protected static EntryInfo GetCachedByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.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 Entry _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private int _DocID;
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyDocument != null) _DocID = _MyDocument.DocID;
return _DocID;
}
}
private DocumentInfo _MyDocument;
public DocumentInfo MyDocument
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID);
return _MyDocument;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
// TODO: Replace base EntryInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current EntryInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check EntryInfo.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 EntryInfo</returns>
protected override object GetIdValue()
{
return _ContentID;
}
#endregion
#region Factory Methods
private static int _EntryInfoUnique = 0;
private static int EntryInfoUnique
{ get { return ++_EntryInfoUnique; } }
private int _MyEntryInfoUnique = EntryInfoUnique;
public int MyEntryInfoUnique
{ get { return _MyEntryInfoUnique; } }
protected EntryInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<EntryInfo> listEntryInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
while (listEntryInfo.Contains(this)) listEntryInfo.Remove(this); // Remove the item from the list
if (listEntryInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual Entry Get()
{
return _Editable = Entry.Get(_ContentID);
}
public static void Refresh(Entry tmp)
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (EntryInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Entry tmp)
{
if (_DocID != tmp.DocID)
{
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for old value
_DocID = tmp.DocID; // Update the value
}
_MyDocument = null; // Reset list so that the next line gets a new list
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if (_MyDocument != null)
{
_MyDocument.Dispose();// Dispose related value
_MyDocument = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(DocumentEntry tmp)
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (EntryInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(DocumentEntry tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if (_MyDocument != null)
{
_MyDocument.Dispose();// Dispose related value
_MyDocument = null;// Reset related value
}
OnChange();// raise an event
}
public static EntryInfo Get(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Entry");
try
{
EntryInfo tmp = GetCachedByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up EntryInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal EntryInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.Constructor", ex);
throw new DbCslaException("EntryInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
public PKCriteria(int contentID)
{
_ContentID = contentID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_DocID = dr.GetInt32("DocID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.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 = "getEntry";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
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("EntryInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
[Serializable()]
partial class EntryInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(EntryInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class EntryInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is EntryInfo)
{
// Return the ToString value
return ((EntryInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,428 +19,414 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FormatContent Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatContentConverter))]
public partial class FormatContent : BusinessBase<FormatContent>, 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 _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private Content _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public Content MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Number", true);
return _Number;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Number", true);
if (value == null) value = string.Empty;
if (_Number != value)
{
_Number = value;
PropertyHasChanged();
}
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text", true);
return _Text;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Text", true);
if (value == null) value = string.Empty;
if (_Text != value)
{
_Text = value;
PropertyHasChanged();
}
}
}
private int? _Type;
/// <summary>
/// 0 - Procedure, 10000 - Section, 20000 Step
/// </summary>
public int? Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Type", true);
return _Type;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Type", true);
if (_Type != value)
{
_Type = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config", true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _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
// TODO: Check FormatContent.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 FormatContent</returns>
protected override object GetIdValue()
{
return _ContentID;
}
// TODO: Replace base FormatContent.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FormatContent</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 30));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(Number, "<Role(s)>");
//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
//AuthorizationRules.AllowRead(Text, "<Role(s)>");
//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
//AuthorizationRules.AllowRead(Type, "<Role(s)>");
//AuthorizationRules.AllowWrite(Type, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static FormatContent New()
{
return new FormatContent();
}
internal static FormatContent Get(SafeDataReader dr)
{
return new FormatContent(dr);
}
public FormatContent()
{
MarkAsChild();
_ContentID = Content.NextContentID;
_DTS = _FormatContentExtension.DefaultDTS;
_UserID = _FormatContentExtension.DefaultUserID;
ValidationRules.CheckRules();
}
internal FormatContent(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_Number = dr.GetString("Number");
_Text = dr.GetString("Text");
_Type = (int?)dr.GetValue("Type");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatContent.FetchDR", ex);
throw new DbCslaException("FormatContent.Fetch", ex);
}
MarkOld();
}
internal void Insert(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Content.Add(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Content.Update(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Format myFormat)
{
// 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"];
Content.Remove(cn, _ContentID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FormatContentExtension _FormatContentExtension = new FormatContentExtension();
[Serializable()]
partial class FormatContentExtension : 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 FormatContentConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatContent)
{
// Return the ToString value
return ((FormatContent)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
/// <summary>
/// FormatContent Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatContentConverter))]
public partial class FormatContent : BusinessBase<FormatContent>, 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 _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private Content _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public Content MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Number;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_Number != value)
{
_Number = value;
PropertyHasChanged();
}
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Text;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_Text != value)
{
_Text = value;
PropertyHasChanged();
}
}
}
private int? _Type;
/// <summary>
/// 0 - Procedure, 10000 - Section, 20000 Step
/// </summary>
public int? Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Type;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_Type != value)
{
_Type = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check FormatContent.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 FormatContent</returns>
protected override object GetIdValue()
{
return _ContentID;
}
// TODO: Replace base FormatContent.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FormatContent</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 30));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(Number, "<Role(s)>");
//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
//AuthorizationRules.AllowRead(Text, "<Role(s)>");
//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
//AuthorizationRules.AllowRead(Type, "<Role(s)>");
//AuthorizationRules.AllowWrite(Type, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static FormatContent New()
{
return new FormatContent();
}
internal static FormatContent Get(SafeDataReader dr)
{
return new FormatContent(dr);
}
public FormatContent()
{
MarkAsChild();
_ContentID = Content.NextContentID;
_DTS = _FormatContentExtension.DefaultDTS;
_UserID = _FormatContentExtension.DefaultUserID;
ValidationRules.CheckRules();
}
internal FormatContent(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_Number = dr.GetString("Number");
_Text = dr.GetString("Text");
_Type = (int?)dr.GetValue("Type");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatContent.FetchDR", ex);
throw new DbCslaException("FormatContent.Fetch", ex);
}
MarkOld();
}
internal void Insert(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Content.Add(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Content.Update(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Format myFormat)
{
// 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"];
Content.Remove(cn, _ContentID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FormatContentExtension _FormatContentExtension = new FormatContentExtension();
[Serializable()]
partial class FormatContentExtension : 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 FormatContentConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatContent)
{
// Return the ToString value
return ((FormatContent)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,401 +19,391 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void GroupInfoEvent(object sender);
/// <summary>
/// GroupInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GroupInfoConverter))]
public partial class GroupInfo : ReadOnlyBase<GroupInfo>, IDisposable
{
public event GroupInfoEvent 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<GroupInfo> _CacheList = new List<GroupInfo>();
protected static void AddToCache(GroupInfo groupInfo)
{
if (!_CacheList.Contains(groupInfo)) _CacheList.Add(groupInfo); // In AddToCache
}
protected static void RemoveFromCache(GroupInfo groupInfo)
{
while (_CacheList.Contains(groupInfo)) _CacheList.Remove(groupInfo); // In RemoveFromCache
}
private static Dictionary<string, List<GroupInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GroupInfo>>();
private static void ConvertListToDictionary()
{
List<GroupInfo> remove = new List<GroupInfo>();
foreach (GroupInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.GID.ToString()))
{
_CacheByPrimaryKey[tmp.GID.ToString()] = new List<GroupInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (GroupInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(GroupInfoList lst)
{
foreach (GroupInfo item in lst) AddToCache(item);
}
protected static GroupInfo GetCachedByPrimaryKey(int gid)
{
ConvertListToDictionary();
string key = gid.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 Group _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _GID;
[System.ComponentModel.DataObjectField(true, true)]
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GID", true);
return _GID;
}
}
private string _GroupName = string.Empty;
public string GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupName", true);
return _GroupName;
}
}
private int? _GroupType;
public int? GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupType", true);
return _GroupType;
}
}
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 _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID", true);
return _UsrID;
}
}
private int _GroupAssignmentCount = 0;
/// <summary>
/// Count of GroupAssignments for this Group
/// </summary>
public int GroupAssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupAssignmentCount", true);
return _GroupAssignmentCount;
}
}
private AssignmentInfoList _GroupAssignments = null;
[TypeConverter(typeof(AssignmentInfoListConverter))]
public AssignmentInfoList GroupAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupAssignments", true);
if (_GroupAssignmentCount < 0 || (_GroupAssignmentCount > 0 && _GroupAssignments == null))
_GroupAssignments = AssignmentInfoList.GetByGID(_GID);
if (_GroupAssignmentCount < 0)
_GroupAssignmentCount = _GroupAssignments.Count;
return _GroupAssignments;
}
}
public void RefreshGroupAssignments()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_GID.ToString()))
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
tmp._GroupAssignmentCount = -1; // This will cause the data to be requeried
}
private int _GroupMembershipCount = 0;
/// <summary>
/// Count of GroupMemberships for this Group
/// </summary>
public int GroupMembershipCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupMembershipCount", true);
return _GroupMembershipCount;
}
}
private MembershipInfoList _GroupMemberships = null;
[TypeConverter(typeof(MembershipInfoListConverter))]
public MembershipInfoList GroupMemberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupMemberships", true);
if (_GroupMembershipCount < 0 || (_GroupMembershipCount > 0 && _GroupMemberships == null))
_GroupMemberships = MembershipInfoList.GetByGID(_GID);
if (_GroupMembershipCount < 0)
_GroupMembershipCount = _GroupMemberships.Count;
return _GroupMemberships;
}
}
public void RefreshGroupMemberships()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_GID.ToString()))
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
tmp._GroupMembershipCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base GroupInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check GroupInfo.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 GroupInfo</returns>
protected override object GetIdValue()
{
return _GID;
}
#endregion
#region Factory Methods
private static int _GroupInfoUnique = 0;
private static int GroupInfoUnique
{ get { return ++_GroupInfoUnique; } }
private int _MyGroupInfoUnique = GroupInfoUnique;
public int MyGroupInfoUnique
{ get { return _MyGroupInfoUnique; } }
protected GroupInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(GID.ToString())) return;
List<GroupInfo> listGroupInfo = _CacheByPrimaryKey[GID.ToString()]; // Get the list of items
while (listGroupInfo.Contains(this)) listGroupInfo.Remove(this); // Remove the item from the list
if (listGroupInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(GID.ToString()); // remove the list
}
public virtual Group Get()
{
return _Editable = Group.Get(_GID);
}
public static void Refresh(Group tmp)
{
string key = tmp.GID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (GroupInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Group tmp)
{
_GroupName = tmp.GroupName;
_GroupType = tmp.GroupType;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_GroupInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static GroupInfo Get(int gid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Group");
try
{
GroupInfo tmp = GetCachedByPrimaryKey(gid);
if (tmp == null)
{
tmp = DataPortal.Fetch<GroupInfo>(new PKCriteria(gid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up GroupInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on GroupInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal GroupInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.Constructor", ex);
throw new DbCslaException("GroupInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _GID;
public int GID
{ get { return _GID; } }
public PKCriteria(int gid)
{
_GID = gid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode());
try
{
_GID = dr.GetInt32("GID");
_GroupName = dr.GetString("GroupName");
_GroupType = (int?)dr.GetValue("GroupType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_GroupAssignmentCount = dr.GetInt32("AssignmentCount");
_GroupMembershipCount = dr.GetInt32("MembershipCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("GroupInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.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 = "getGroup";
cm.Parameters.AddWithValue("@GID", criteria.GID);
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("GroupInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("GroupInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
[Serializable()]
partial class GroupInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(GroupInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class GroupInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupInfo)
{
// Return the ToString value
return ((GroupInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void GroupInfoEvent(object sender);
/// <summary>
/// GroupInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GroupInfoConverter))]
public partial class GroupInfo : ReadOnlyBase<GroupInfo>, IDisposable
{
public event GroupInfoEvent 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<GroupInfo> _CacheList = new List<GroupInfo>();
protected static void AddToCache(GroupInfo groupInfo)
{
if (!_CacheList.Contains(groupInfo)) _CacheList.Add(groupInfo); // In AddToCache
}
protected static void RemoveFromCache(GroupInfo groupInfo)
{
while (_CacheList.Contains(groupInfo)) _CacheList.Remove(groupInfo); // In RemoveFromCache
}
private static Dictionary<string, List<GroupInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GroupInfo>>();
private static void ConvertListToDictionary()
{
List<GroupInfo> remove = new List<GroupInfo>();
foreach (GroupInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.GID.ToString()))
{
_CacheByPrimaryKey[tmp.GID.ToString()] = new List<GroupInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.GID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (GroupInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(GroupInfoList lst)
{
foreach (GroupInfo item in lst) AddToCache(item);
}
protected static GroupInfo GetCachedByPrimaryKey(int gid)
{
ConvertListToDictionary();
string key = gid.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 Group _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _GID;
[System.ComponentModel.DataObjectField(true, true)]
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _GID;
}
}
private string _GroupName = string.Empty;
public string GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _GroupName;
}
}
private int? _GroupType;
public int? GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _GroupType;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UsrID;
}
}
private int _GroupAssignmentCount = 0;
/// <summary>
/// Count of GroupAssignments for this Group
/// </summary>
public int GroupAssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _GroupAssignmentCount;
}
}
private AssignmentInfoList _GroupAssignments = null;
[TypeConverter(typeof(AssignmentInfoListConverter))]
public AssignmentInfoList GroupAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_GroupAssignmentCount < 0 || (_GroupAssignmentCount > 0 && _GroupAssignments == null))
_GroupAssignments = AssignmentInfoList.GetByGID(_GID);
if (_GroupAssignmentCount < 0)
_GroupAssignmentCount = _GroupAssignments.Count;
return _GroupAssignments;
}
}
public void RefreshGroupAssignments()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_GID.ToString()))
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
tmp._GroupAssignmentCount = -1; // This will cause the data to be requeried
}
private int _GroupMembershipCount = 0;
/// <summary>
/// Count of GroupMemberships for this Group
/// </summary>
public int GroupMembershipCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _GroupMembershipCount;
}
}
private MembershipInfoList _GroupMemberships = null;
[TypeConverter(typeof(MembershipInfoListConverter))]
public MembershipInfoList GroupMemberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_GroupMembershipCount < 0 || (_GroupMembershipCount > 0 && _GroupMemberships == null))
_GroupMemberships = MembershipInfoList.GetByGID(_GID);
if (_GroupMembershipCount < 0)
_GroupMembershipCount = _GroupMemberships.Count;
return _GroupMemberships;
}
}
public void RefreshGroupMemberships()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_GID.ToString()))
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
tmp._GroupMembershipCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base GroupInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check GroupInfo.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 GroupInfo</returns>
protected override object GetIdValue()
{
return _GID;
}
#endregion
#region Factory Methods
private static int _GroupInfoUnique = 0;
private static int GroupInfoUnique
{ get { return ++_GroupInfoUnique; } }
private int _MyGroupInfoUnique = GroupInfoUnique;
public int MyGroupInfoUnique
{ get { return _MyGroupInfoUnique; } }
protected GroupInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(GID.ToString())) return;
List<GroupInfo> listGroupInfo = _CacheByPrimaryKey[GID.ToString()]; // Get the list of items
while (listGroupInfo.Contains(this)) listGroupInfo.Remove(this); // Remove the item from the list
if (listGroupInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(GID.ToString()); // remove the list
}
public virtual Group Get()
{
return _Editable = Group.Get(_GID);
}
public static void Refresh(Group tmp)
{
string key = tmp.GID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (GroupInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Group tmp)
{
_GroupName = tmp.GroupName;
_GroupType = tmp.GroupType;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_GroupInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static GroupInfo Get(int gid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Group");
try
{
GroupInfo tmp = GetCachedByPrimaryKey(gid);
if (tmp == null)
{
tmp = DataPortal.Fetch<GroupInfo>(new PKCriteria(gid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up GroupInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on GroupInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal GroupInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.Constructor", ex);
throw new DbCslaException("GroupInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _GID;
public int GID
{ get { return _GID; } }
public PKCriteria(int gid)
{
_GID = gid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode());
try
{
_GID = dr.GetInt32("GID");
_GroupName = dr.GetString("GroupName");
_GroupType = (int?)dr.GetValue("GroupType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_GroupAssignmentCount = dr.GetInt32("AssignmentCount");
_GroupMembershipCount = dr.GetInt32("MembershipCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("GroupInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.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 = "getGroup";
cm.Parameters.AddWithValue("@GID", criteria.GID);
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("GroupInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("GroupInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
[Serializable()]
partial class GroupInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(GroupInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class GroupInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupInfo)
{
// Return the ToString value
return ((GroupInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,509 +19,490 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemAnnotation Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemAnnotationConverter))]
public partial class ItemAnnotation : BusinessBase<ItemAnnotation>, 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 _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationID", true);
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID;
}
}
private Annotation _MyAnnotation;
[System.ComponentModel.DataObjectField(true, true)]
public Annotation MyAnnotation
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotation", true);
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID;
}
}
private AnnotationType _MyAnnotationType;
public AnnotationType MyAnnotationType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID);
return _MyAnnotationType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyAnnotationType", true);
if (_MyAnnotationType != value)
{
_MyAnnotationType = value;
PropertyHasChanged();
}
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText", true);
return _RtfText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("RtfText", true);
if (value == null) value = string.Empty;
if (_RtfText != value)
{
_RtfText = value;
PropertyHasChanged();
}
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText", true);
return _SearchText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("SearchText", true);
if (value == null) value = string.Empty;
if (_SearchText != value)
{
_SearchText = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config", true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _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 _AnnotationType_Name = string.Empty;
public string AnnotationType_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationType_Name", true);
return _AnnotationType_Name;
}
}
private string _AnnotationType_Config = string.Empty;
public string AnnotationType_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationType_Config", true);
return _AnnotationType_Config;
}
}
private DateTime _AnnotationType_DTS = new DateTime();
public DateTime AnnotationType_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationType_DTS", true);
return _AnnotationType_DTS;
}
}
private string _AnnotationType_UserID = string.Empty;
public string AnnotationType_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationType_UserID", true);
return _AnnotationType_UserID;
}
}
// TODO: Check ItemAnnotation.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 ItemAnnotation</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
// TODO: Replace base ItemAnnotation.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemAnnotation</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyAnnotationType == null ? false : _MyAnnotationType.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyAnnotationType == null ? true : _MyAnnotationType.IsValid); }
}
#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 (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.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<ItemAnnotation>(MyAnnotationTypeRequired, "MyAnnotationType");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("RtfText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("SearchText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyAnnotationTypeRequired(ItemAnnotation target, Csla.Validation.RuleArgs e)
{
if (target._TypeID == 0 && target._MyAnnotationType == 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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
//AuthorizationRules.AllowRead(TypeID, "<Role(s)>");
//AuthorizationRules.AllowWrite(TypeID, "<Role(s)>");
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ItemAnnotation New(AnnotationType myAnnotationType)
{
return new ItemAnnotation(myAnnotationType);
}
internal static ItemAnnotation Get(SafeDataReader dr)
{
return new ItemAnnotation(dr);
}
public ItemAnnotation()
{
MarkAsChild();
_AnnotationID = Annotation.NextAnnotationID;
_DTS = _ItemAnnotationExtension.DefaultDTS;
_UserID = _ItemAnnotationExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ItemAnnotation(AnnotationType myAnnotationType)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ItemAnnotationExtension.DefaultDTS;
_UserID = _ItemAnnotationExtension.DefaultUserID;
_MyAnnotationType = myAnnotationType;
ValidationRules.CheckRules();
}
internal ItemAnnotation(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAnnotation.FetchDR", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_TypeID = dr.GetInt32("TypeID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_AnnotationType_Name = dr.GetString("AnnotationType_Name");
_AnnotationType_Config = dr.GetString("AnnotationType_Config");
_AnnotationType_DTS = dr.GetDateTime("AnnotationType_DTS");
_AnnotationType_UserID = dr.GetString("AnnotationType_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAnnotation.FetchDR", ex);
throw new DbCslaException("ItemAnnotation.Fetch", ex);
}
MarkOld();
}
internal void Insert(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Add(cn, ref _AnnotationID, myItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Update(cn, ref _AnnotationID, myItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Item myItem)
{
// 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"];
Annotation.Remove(cn, _AnnotationID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ItemAnnotationExtension _ItemAnnotationExtension = new ItemAnnotationExtension();
[Serializable()]
partial class ItemAnnotationExtension : 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 ItemAnnotationConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemAnnotation)
{
// Return the ToString value
return ((ItemAnnotation)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
/// <summary>
/// ItemAnnotation Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemAnnotationConverter))]
public partial class ItemAnnotation : BusinessBase<ItemAnnotation>, 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 _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID;
}
}
private Annotation _MyAnnotation;
[System.ComponentModel.DataObjectField(true, true)]
public Annotation MyAnnotation
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID;
}
}
private AnnotationType _MyAnnotationType;
public AnnotationType MyAnnotationType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID);
return _MyAnnotationType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_MyAnnotationType != value)
{
_MyAnnotationType = value;
PropertyHasChanged();
}
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RtfText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_RtfText != value)
{
_RtfText = value;
PropertyHasChanged();
}
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _SearchText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_SearchText != value)
{
_SearchText = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _AnnotationType_Name = string.Empty;
public string AnnotationType_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _AnnotationType_Name;
}
}
private string _AnnotationType_Config = string.Empty;
public string AnnotationType_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _AnnotationType_Config;
}
}
private DateTime _AnnotationType_DTS = new DateTime();
public DateTime AnnotationType_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _AnnotationType_DTS;
}
}
private string _AnnotationType_UserID = string.Empty;
public string AnnotationType_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _AnnotationType_UserID;
}
}
// TODO: Check ItemAnnotation.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 ItemAnnotation</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
// TODO: Replace base ItemAnnotation.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemAnnotation</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyAnnotationType == null ? false : _MyAnnotationType.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyAnnotationType == null ? true : _MyAnnotationType.IsValid); }
}
#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 (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.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<ItemAnnotation>(MyAnnotationTypeRequired, "MyAnnotationType");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("RtfText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("SearchText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyAnnotationTypeRequired(ItemAnnotation target, Csla.Validation.RuleArgs e)
{
if (target._TypeID == 0 && target._MyAnnotationType == 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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
//AuthorizationRules.AllowRead(TypeID, "<Role(s)>");
//AuthorizationRules.AllowWrite(TypeID, "<Role(s)>");
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ItemAnnotation New(AnnotationType myAnnotationType)
{
return new ItemAnnotation(myAnnotationType);
}
internal static ItemAnnotation Get(SafeDataReader dr)
{
return new ItemAnnotation(dr);
}
public ItemAnnotation()
{
MarkAsChild();
_AnnotationID = Annotation.NextAnnotationID;
_DTS = _ItemAnnotationExtension.DefaultDTS;
_UserID = _ItemAnnotationExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ItemAnnotation(AnnotationType myAnnotationType)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ItemAnnotationExtension.DefaultDTS;
_UserID = _ItemAnnotationExtension.DefaultUserID;
_MyAnnotationType = myAnnotationType;
ValidationRules.CheckRules();
}
internal ItemAnnotation(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAnnotation.FetchDR", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_TypeID = dr.GetInt32("TypeID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_AnnotationType_Name = dr.GetString("AnnotationType_Name");
_AnnotationType_Config = dr.GetString("AnnotationType_Config");
_AnnotationType_DTS = dr.GetDateTime("AnnotationType_DTS");
_AnnotationType_UserID = dr.GetString("AnnotationType_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAnnotation.FetchDR", ex);
throw new DbCslaException("ItemAnnotation.Fetch", ex);
}
MarkOld();
}
internal void Insert(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Add(cn, ref _AnnotationID, myItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Update(cn, ref _AnnotationID, myItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Item myItem)
{
// 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"];
Annotation.Remove(cn, _AnnotationID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ItemAnnotationExtension _ItemAnnotationExtension = new ItemAnnotationExtension();
[Serializable()]
partial class ItemAnnotationExtension : 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 ItemAnnotationConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemAnnotation)
{
// Return the ToString value
return ((ItemAnnotation)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,424 +19,410 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemPart Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemPartConverter))]
public partial class ItemPart : BusinessBase<ItemPart>, 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 _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private Content _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public Content MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent;
}
}
private int _FromType;
[System.ComponentModel.DataObjectField(true, true)]
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FromType", true);
return _FromType;
}
}
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 _Content_Number = string.Empty;
public string Content_Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Number", true);
return _Content_Number;
}
}
private string _Content_Text = string.Empty;
public string Content_Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Text", true);
return _Content_Text;
}
}
private int? _Content_Type;
/// <summary>
/// 0 - Procedure, 10000 - Section, 20000 Step
/// </summary>
public int? Content_Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Type", true);
return _Content_Type;
}
}
private int? _Content_FormatID;
public int? Content_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_FormatID", true);
return _Content_FormatID;
}
}
private string _Content_Config = string.Empty;
public string Content_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Config", true);
return _Content_Config;
}
}
private DateTime _Content_DTS = new DateTime();
public DateTime Content_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_DTS", true);
return _Content_DTS;
}
}
private string _Content_UserID = string.Empty;
public string Content_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_UserID", true);
return _Content_UserID;
}
}
// TODO: Check ItemPart.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 ItemPart</returns>
protected override object GetIdValue()
{
return (((((_ContentID.ToString() + _FromType.ToString()).GetHashCode().ToString()).GetHashCode().ToString()).GetHashCode().ToString()).GetHashCode().ToString()).GetHashCode();
}
// TODO: Replace base ItemPart.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemPart</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(FromType, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ItemPart New(Content myContent, int fromType)
{
return new ItemPart(myContent, fromType);
}
internal static ItemPart Get(SafeDataReader dr)
{
return new ItemPart(dr);
}
public ItemPart()
{
MarkAsChild();
/// <summary>
/// ItemPart Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemPartConverter))]
public partial class ItemPart : BusinessBase<ItemPart>, 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 _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private Content _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public Content MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent;
}
}
private int _FromType;
[System.ComponentModel.DataObjectField(true, true)]
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _FromType;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Content_Number = string.Empty;
public string Content_Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_Number;
}
}
private string _Content_Text = string.Empty;
public string Content_Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_Text;
}
}
private int? _Content_Type;
/// <summary>
/// 0 - Procedure, 10000 - Section, 20000 Step
/// </summary>
public int? Content_Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_Type;
}
}
private int? _Content_FormatID;
public int? Content_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_FormatID;
}
}
private string _Content_Config = string.Empty;
public string Content_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_Config;
}
}
private DateTime _Content_DTS = new DateTime();
public DateTime Content_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_DTS;
}
}
private string _Content_UserID = string.Empty;
public string Content_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content_UserID;
}
}
// TODO: Check ItemPart.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 ItemPart</returns>
protected override object GetIdValue()
{
return (((((_ContentID.ToString() + _FromType.ToString()).GetHashCode().ToString()).GetHashCode().ToString()).GetHashCode().ToString()).GetHashCode().ToString()).GetHashCode();
}
// TODO: Replace base ItemPart.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemPart</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(FromType, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ItemPart New(Content myContent, int fromType)
{
return new ItemPart(myContent, fromType);
}
internal static ItemPart Get(SafeDataReader dr)
{
return new ItemPart(dr);
}
public ItemPart()
{
MarkAsChild();
_DTS = _ItemPartExtension.DefaultDTS;
_UserID = _ItemPartExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ItemPart(Content myContent, int fromType)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ItemPartExtension.DefaultDTS;
_UserID = _ItemPartExtension.DefaultUserID;
_MyContent = myContent;
_FromType = fromType;
ValidationRules.CheckRules();
}
internal ItemPart(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemPart.FetchDR", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_FromType = dr.GetInt32("FromType");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Content_Number = dr.GetString("Content_Number");
_Content_Text = dr.GetString("Content_Text");
_Content_Type = (int?)dr.GetValue("Content_Type");
_Content_FormatID = (int?)dr.GetValue("Content_FormatID");
_Content_Config = dr.GetString("Content_Config");
_Content_DTS = dr.GetDateTime("Content_DTS");
_Content_UserID = dr.GetString("Content_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemPart.FetchDR", ex);
throw new DbCslaException("ItemPart.Fetch", ex);
}
MarkOld();
}
internal void Insert(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Add(cn, _MyContent, _FromType, myItem, _DTS, _UserID);
MarkOld();
}
internal void Update(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Update(cn, _MyContent, _FromType, myItem, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Item myItem)
{
// 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"];
Part.Remove(cn, _ContentID, _FromType);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ItemPartExtension _ItemPartExtension = new ItemPartExtension();
[Serializable()]
partial class ItemPartExtension : 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 ItemPartConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemPart)
{
// Return the ToString value
return ((ItemPart)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
_DTS = _ItemPartExtension.DefaultDTS;
_UserID = _ItemPartExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ItemPart(Content myContent, int fromType)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ItemPartExtension.DefaultDTS;
_UserID = _ItemPartExtension.DefaultUserID;
_MyContent = myContent;
_FromType = fromType;
ValidationRules.CheckRules();
}
internal ItemPart(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemPart.FetchDR", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_FromType = dr.GetInt32("FromType");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Content_Number = dr.GetString("Content_Number");
_Content_Text = dr.GetString("Content_Text");
_Content_Type = (int?)dr.GetValue("Content_Type");
_Content_FormatID = (int?)dr.GetValue("Content_FormatID");
_Content_Config = dr.GetString("Content_Config");
_Content_DTS = dr.GetDateTime("Content_DTS");
_Content_UserID = dr.GetString("Content_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemPart.FetchDR", ex);
throw new DbCslaException("ItemPart.Fetch", ex);
}
MarkOld();
}
internal void Insert(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Add(cn, _MyContent, _FromType, myItem, _DTS, _UserID);
MarkOld();
}
internal void Update(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Update(cn, _MyContent, _FromType, myItem, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Item myItem)
{
// 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"];
Part.Remove(cn, _ContentID, _FromType);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ItemPartExtension _ItemPartExtension = new ItemPartExtension();
[Serializable()]
partial class ItemPartExtension : 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 ItemPartConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemPart)
{
// Return the ToString value
return ((ItemPart)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,469 +19,459 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void MembershipInfoEvent(object sender);
/// <summary>
/// MembershipInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(MembershipInfoConverter))]
public partial class MembershipInfo : ReadOnlyBase<MembershipInfo>, IDisposable
{
public event MembershipInfoEvent 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<MembershipInfo> _CacheList = new List<MembershipInfo>();
protected static void AddToCache(MembershipInfo membershipInfo)
{
if (!_CacheList.Contains(membershipInfo)) _CacheList.Add(membershipInfo); // In AddToCache
}
protected static void RemoveFromCache(MembershipInfo membershipInfo)
{
while (_CacheList.Contains(membershipInfo)) _CacheList.Remove(membershipInfo); // In RemoveFromCache
}
private static Dictionary<string, List<MembershipInfo>> _CacheByPrimaryKey = new Dictionary<string, List<MembershipInfo>>();
private static void ConvertListToDictionary()
{
List<MembershipInfo> remove = new List<MembershipInfo>();
foreach (MembershipInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
{
_CacheByPrimaryKey[tmp.UGID.ToString()] = new List<MembershipInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (MembershipInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(MembershipInfoList lst)
{
foreach (MembershipInfo item in lst) AddToCache(item);
}
protected static MembershipInfo GetCachedByPrimaryKey(int ugid)
{
ConvertListToDictionary();
string key = ugid.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 Membership _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _UGID;
[System.ComponentModel.DataObjectField(true, true)]
public int UGID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UGID", true);
return _UGID;
}
}
private int _UID;
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UID", true);
if (_MyUser != null) _UID = _MyUser.UID;
return _UID;
}
}
private UserInfo _MyUser;
public UserInfo MyUser
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyUser", true);
if (_MyUser == null && _UID != 0) _MyUser = UserInfo.Get(_UID);
return _MyUser;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID;
}
}
private GroupInfo _MyGroup;
public GroupInfo MyGroup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID);
return _MyGroup;
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StartDate", true);
return _StartDate;
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("EndDate", true);
return _EndDate;
}
}
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 _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID", true);
return _UsrID;
}
}
// TODO: Replace base MembershipInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current MembershipInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check MembershipInfo.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 MembershipInfo</returns>
protected override object GetIdValue()
{
return _UGID;
}
#endregion
#region Factory Methods
private static int _MembershipInfoUnique = 0;
private static int MembershipInfoUnique
{ get { return ++_MembershipInfoUnique; } }
private int _MyMembershipInfoUnique = MembershipInfoUnique;
public int MyMembershipInfoUnique
{ get { return _MyMembershipInfoUnique; } }
protected MembershipInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(UGID.ToString())) return;
List<MembershipInfo> listMembershipInfo = _CacheByPrimaryKey[UGID.ToString()]; // Get the list of items
while (listMembershipInfo.Contains(this)) listMembershipInfo.Remove(this); // Remove the item from the list
if (listMembershipInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(UGID.ToString()); // remove the list
}
public virtual Membership Get()
{
return _Editable = Membership.Get(_UGID);
}
public static void Refresh(Membership tmp)
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Membership tmp)
{
if (_UID != tmp.UID)
{
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value
_UID = tmp.UID; // Update the value
}
_MyUser = null; // Reset list so that the next line gets a new list
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
if (_GID != tmp.GID)
{
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value
_GID = tmp.GID; // Update the value
}
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
if(_MyUser != null)
{
_MyUser.Dispose();// Dispose related value
_MyUser = null;// Reset related value
}
if(_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(GroupMembership tmp)
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(GroupMembership tmp)
{
if (_UID != tmp.UID)
{
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value
_UID = tmp.UID; // Update the value
}
_MyUser = null; // Reset list so that the next line gets a new list
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
if(_MyUser != null)
{
_MyUser.Dispose();// Dispose related value
_MyUser = null;// Reset related value
}
if(_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(UserMembership tmp)
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(UserMembership tmp)
{
if (_GID != tmp.GID)
{
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value
_GID = tmp.GID; // Update the value
}
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
if(_MyUser != null)
{
_MyUser.Dispose();// Dispose related value
_MyUser = null;// Reset related value
}
if(_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
OnChange();// raise an event
}
public static MembershipInfo Get(int ugid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Membership");
try
{
MembershipInfo tmp = GetCachedByPrimaryKey(ugid);
if (tmp == null)
{
tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up MembershipInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on MembershipInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal MembershipInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.Constructor", ex);
throw new DbCslaException("MembershipInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _UGID;
public int UGID
{ get { return _UGID; } }
public PKCriteria(int ugid)
{
_UGID = ugid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode());
try
{
_UGID = dr.GetInt32("UGID");
_UID = dr.GetInt32("UID");
_GID = dr.GetInt32("GID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("MembershipInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.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 = "getMembership";
cm.Parameters.AddWithValue("@UGID", criteria.UGID);
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("MembershipInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("MembershipInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension();
[Serializable()]
partial class MembershipInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(MembershipInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class MembershipInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is MembershipInfo)
{
// Return the ToString value
return ((MembershipInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void MembershipInfoEvent(object sender);
/// <summary>
/// MembershipInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(MembershipInfoConverter))]
public partial class MembershipInfo : ReadOnlyBase<MembershipInfo>, IDisposable
{
public event MembershipInfoEvent 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<MembershipInfo> _CacheList = new List<MembershipInfo>();
protected static void AddToCache(MembershipInfo membershipInfo)
{
if (!_CacheList.Contains(membershipInfo)) _CacheList.Add(membershipInfo); // In AddToCache
}
protected static void RemoveFromCache(MembershipInfo membershipInfo)
{
while (_CacheList.Contains(membershipInfo)) _CacheList.Remove(membershipInfo); // In RemoveFromCache
}
private static Dictionary<string, List<MembershipInfo>> _CacheByPrimaryKey = new Dictionary<string, List<MembershipInfo>>();
private static void ConvertListToDictionary()
{
List<MembershipInfo> remove = new List<MembershipInfo>();
foreach (MembershipInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
{
_CacheByPrimaryKey[tmp.UGID.ToString()] = new List<MembershipInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (MembershipInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(MembershipInfoList lst)
{
foreach (MembershipInfo item in lst) AddToCache(item);
}
protected static MembershipInfo GetCachedByPrimaryKey(int ugid)
{
ConvertListToDictionary();
string key = ugid.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 Membership _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _UGID;
[System.ComponentModel.DataObjectField(true, true)]
public int UGID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UGID;
}
}
private int _UID;
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyUser != null) _UID = _MyUser.UID;
return _UID;
}
}
private UserInfo _MyUser;
public UserInfo MyUser
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyUser == null && _UID != 0) _MyUser = UserInfo.Get(_UID);
return _MyUser;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID;
}
}
private GroupInfo _MyGroup;
public GroupInfo MyGroup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID);
return _MyGroup;
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _StartDate;
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _EndDate;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UsrID;
}
}
// TODO: Replace base MembershipInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current MembershipInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check MembershipInfo.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 MembershipInfo</returns>
protected override object GetIdValue()
{
return _UGID;
}
#endregion
#region Factory Methods
private static int _MembershipInfoUnique = 0;
private static int MembershipInfoUnique
{ get { return ++_MembershipInfoUnique; } }
private int _MyMembershipInfoUnique = MembershipInfoUnique;
public int MyMembershipInfoUnique
{ get { return _MyMembershipInfoUnique; } }
protected MembershipInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(UGID.ToString())) return;
List<MembershipInfo> listMembershipInfo = _CacheByPrimaryKey[UGID.ToString()]; // Get the list of items
while (listMembershipInfo.Contains(this)) listMembershipInfo.Remove(this); // Remove the item from the list
if (listMembershipInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(UGID.ToString()); // remove the list
}
public virtual Membership Get()
{
return _Editable = Membership.Get(_UGID);
}
public static void Refresh(Membership tmp)
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Membership tmp)
{
if (_UID != tmp.UID)
{
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value
_UID = tmp.UID; // Update the value
}
_MyUser = null; // Reset list so that the next line gets a new list
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
if (_GID != tmp.GID)
{
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value
_GID = tmp.GID; // Update the value
}
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
if (_MyUser != null)
{
_MyUser.Dispose();// Dispose related value
_MyUser = null;// Reset related value
}
if (_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(GroupMembership tmp)
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(GroupMembership tmp)
{
if (_UID != tmp.UID)
{
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value
_UID = tmp.UID; // Update the value
}
_MyUser = null; // Reset list so that the next line gets a new list
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
if (_MyUser != null)
{
_MyUser.Dispose();// Dispose related value
_MyUser = null;// Reset related value
}
if (_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(UserMembership tmp)
{
string key = tmp.UGID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(UserMembership tmp)
{
if (_GID != tmp.GID)
{
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value
_GID = tmp.GID; // Update the value
}
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
if (_MyUser != null)
{
_MyUser.Dispose();// Dispose related value
_MyUser = null;// Reset related value
}
if (_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
OnChange();// raise an event
}
public static MembershipInfo Get(int ugid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Membership");
try
{
MembershipInfo tmp = GetCachedByPrimaryKey(ugid);
if (tmp == null)
{
tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up MembershipInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on MembershipInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal MembershipInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.Constructor", ex);
throw new DbCslaException("MembershipInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _UGID;
public int UGID
{ get { return _UGID; } }
public PKCriteria(int ugid)
{
_UGID = ugid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode());
try
{
_UGID = dr.GetInt32("UGID");
_UID = dr.GetInt32("UID");
_GID = dr.GetInt32("GID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("MembershipInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.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 = "getMembership";
cm.Parameters.AddWithValue("@UGID", criteria.UGID);
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("MembershipInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("MembershipInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension();
[Serializable()]
partial class MembershipInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(MembershipInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class MembershipInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is MembershipInfo)
{
// Return the ToString value
return ((MembershipInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,420 +19,413 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void PartInfoEvent(object sender);
/// <summary>
/// PartInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(PartInfoConverter))]
public partial class PartInfo : ReadOnlyBase<PartInfo>, IDisposable
{
public event PartInfoEvent 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<PartInfo> _CacheList = new List<PartInfo>();
protected static void AddToCache(PartInfo partInfo)
{
if (!_CacheList.Contains(partInfo)) _CacheList.Add(partInfo); // In AddToCache
}
protected static void RemoveFromCache(PartInfo partInfo)
{
while (_CacheList.Contains(partInfo)) _CacheList.Remove(partInfo); // In RemoveFromCache
}
private static Dictionary<string, List<PartInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartInfo>>();
private static void ConvertListToDictionary()
{
List<PartInfo> remove = new List<PartInfo>();
foreach (PartInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
{
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<PartInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (PartInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(PartInfoList lst)
{
foreach (PartInfo item in lst) AddToCache(item);
}
protected static PartInfo GetCachedByPrimaryKey(int contentID, int fromType)
{
ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.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 Part _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private int _FromType;
[System.ComponentModel.DataObjectField(true, true)]
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FromType", true);
return _FromType;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private ItemInfo _MyItem;
public ItemInfo MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem;
}
}
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;
}
}
// TODO: Replace base PartInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PartInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check PartInfo.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 PartInfo</returns>
protected override object GetIdValue()
{
return (_ContentID.ToString() + "." + _FromType.ToString()).GetHashCode();
}
#endregion
#region Factory Methods
private static int _PartInfoUnique = 0;
private static int PartInfoUnique
{ get { return ++_PartInfoUnique; } }
private int _MyPartInfoUnique = PartInfoUnique;
public int MyPartInfoUnique
{ get { return _MyPartInfoUnique; } }
protected PartInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return;
List<PartInfo> listPartInfo = _CacheByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
while (listPartInfo.Contains(this)) listPartInfo.Remove(this); // Remove the item from the list
if (listPartInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
}
public virtual Part Get()
{
return _Editable = Part.Get(_ContentID, _FromType);
}
public static void Refresh(Part tmp)
{
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Part tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(Content myContent, ContentPart tmp)
{
string key = myContent.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentPart tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ItemPart tmp)
{
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ItemPart tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
OnChange();// raise an event
}
public static PartInfo Get(int contentID, int fromType)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Part");
try
{
PartInfo tmp = GetCachedByPrimaryKey(contentID, fromType);
if (tmp == null)
{
tmp = DataPortal.Fetch<PartInfo>(new PKCriteria(contentID, fromType));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up PartInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on PartInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal PartInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.Constructor", ex);
throw new DbCslaException("PartInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
private int _FromType;
public int FromType
{ get { return _FromType; } }
public PKCriteria(int contentID, int fromType)
{
_ContentID = contentID;
_FromType = fromType;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.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 = "getPart";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
cm.Parameters.AddWithValue("@FromType", criteria.FromType);
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("PartInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
PartInfoExtension _PartInfoExtension = new PartInfoExtension();
[Serializable()]
partial class PartInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(PartInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class PartInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is PartInfo)
{
// Return the ToString value
return ((PartInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void PartInfoEvent(object sender);
/// <summary>
/// PartInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(PartInfoConverter))]
public partial class PartInfo : ReadOnlyBase<PartInfo>, IDisposable
{
public event PartInfoEvent 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<PartInfo> _CacheList = new List<PartInfo>();
protected static void AddToCache(PartInfo partInfo)
{
if (!_CacheList.Contains(partInfo)) _CacheList.Add(partInfo); // In AddToCache
}
protected static void RemoveFromCache(PartInfo partInfo)
{
while (_CacheList.Contains(partInfo)) _CacheList.Remove(partInfo); // In RemoveFromCache
}
private static Dictionary<string, List<PartInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartInfo>>();
private static void ConvertListToDictionary()
{
List<PartInfo> remove = new List<PartInfo>();
foreach (PartInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()))
{
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()] = new List<PartInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (PartInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(PartInfoList lst)
{
foreach (PartInfo item in lst) AddToCache(item);
}
protected static PartInfo GetCachedByPrimaryKey(int contentID, int fromType)
{
ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.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 Part _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private int _FromType;
[System.ComponentModel.DataObjectField(true, true)]
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _FromType;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private ItemInfo _MyItem;
public ItemInfo MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
// TODO: Replace base PartInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PartInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check PartInfo.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 PartInfo</returns>
protected override object GetIdValue()
{
return (_ContentID.ToString() + "." + _FromType.ToString()).GetHashCode();
}
#endregion
#region Factory Methods
private static int _PartInfoUnique = 0;
private static int PartInfoUnique
{ get { return ++_PartInfoUnique; } }
private int _MyPartInfoUnique = PartInfoUnique;
public int MyPartInfoUnique
{ get { return _MyPartInfoUnique; } }
protected PartInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return;
List<PartInfo> listPartInfo = _CacheByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
while (listPartInfo.Contains(this)) listPartInfo.Remove(this); // Remove the item from the list
if (listPartInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
}
public virtual Part Get()
{
return _Editable = Part.Get(_ContentID, _FromType);
}
public static void Refresh(Part tmp)
{
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Part tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if (_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(Content myContent, ContentPart tmp)
{
string key = myContent.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentPart tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if (_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ItemPart tmp)
{
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ItemPart tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if (_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
OnChange();// raise an event
}
public static PartInfo Get(int contentID, int fromType)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Part");
try
{
PartInfo tmp = GetCachedByPrimaryKey(contentID, fromType);
if (tmp == null)
{
tmp = DataPortal.Fetch<PartInfo>(new PKCriteria(contentID, fromType));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up PartInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on PartInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal PartInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.Constructor", ex);
throw new DbCslaException("PartInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
private int _FromType;
public int FromType
{ get { return _FromType; } }
public PKCriteria(int contentID, int fromType)
{
_ContentID = contentID;
_FromType = fromType;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.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 = "getPart";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
cm.Parameters.AddWithValue("@FromType", criteria.FromType);
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("PartInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PartInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
PartInfoExtension _PartInfoExtension = new PartInfoExtension();
[Serializable()]
partial class PartInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(PartInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class PartInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is PartInfo)
{
// Return the ToString value
return ((PartInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,451 +19,439 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void PermissionInfoEvent(object sender);
/// <summary>
/// PermissionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(PermissionInfoConverter))]
public partial class PermissionInfo : ReadOnlyBase<PermissionInfo>, IDisposable
{
public event PermissionInfoEvent 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<PermissionInfo> _CacheList = new List<PermissionInfo>();
protected static void AddToCache(PermissionInfo permissionInfo)
{
if (!_CacheList.Contains(permissionInfo)) _CacheList.Add(permissionInfo); // In AddToCache
}
protected static void RemoveFromCache(PermissionInfo permissionInfo)
{
while (_CacheList.Contains(permissionInfo)) _CacheList.Remove(permissionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<PermissionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PermissionInfo>>();
private static void ConvertListToDictionary()
{
List<PermissionInfo> remove = new List<PermissionInfo>();
foreach (PermissionInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.PID.ToString()))
{
_CacheByPrimaryKey[tmp.PID.ToString()] = new List<PermissionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (PermissionInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(PermissionInfoList lst)
{
foreach (PermissionInfo item in lst) AddToCache(item);
}
protected static PermissionInfo GetCachedByPrimaryKey(int pid)
{
ConvertListToDictionary();
string key = pid.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 Permission _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _PID;
[System.ComponentModel.DataObjectField(true, true)]
public int PID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PID", true);
return _PID;
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID;
return _RID;
}
}
private RoleInfo _MyRole;
public RoleInfo MyRole
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID);
return _MyRole;
}
}
private int _PermLevel;
/// <summary>
/// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments
/// </summary>
public int PermLevel
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PermLevel", true);
return _PermLevel;
}
}
private int _VersionType;
/// <summary>
/// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionType", true);
return _VersionType;
}
}
private int _PermValue;
/// <summary>
/// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All)
/// </summary>
public int PermValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PermValue", true);
return _PermValue;
}
}
private int _PermAD;
/// <summary>
/// 0 - Allow, 1 - Deny
/// </summary>
public int PermAD
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PermAD", true);
return _PermAD;
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StartDate", true);
return _StartDate;
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("EndDate", true);
return _EndDate;
}
}
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 _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID", true);
return _UsrID;
}
}
// TODO: Replace base PermissionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PermissionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check PermissionInfo.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 PermissionInfo</returns>
protected override object GetIdValue()
{
return _PID;
}
#endregion
#region Factory Methods
private static int _PermissionInfoUnique = 0;
private static int PermissionInfoUnique
{ get { return ++_PermissionInfoUnique; } }
private int _MyPermissionInfoUnique = PermissionInfoUnique;
public int MyPermissionInfoUnique
{ get { return _MyPermissionInfoUnique; } }
protected PermissionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(PID.ToString())) return;
List<PermissionInfo> listPermissionInfo = _CacheByPrimaryKey[PID.ToString()]; // Get the list of items
while (listPermissionInfo.Contains(this)) listPermissionInfo.Remove(this); // Remove the item from the list
if (listPermissionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(PID.ToString()); // remove the list
}
public virtual Permission Get()
{
return _Editable = Permission.Get(_PID);
}
public static void Refresh(Permission tmp)
{
string key = tmp.PID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Permission tmp)
{
if (_RID != tmp.RID)
{
if (MyRole != null) MyRole.RefreshRolePermissions(); // Update List for old value
_RID = tmp.RID; // Update the value
}
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRolePermissions(); // Update List for new value
_PermLevel = tmp.PermLevel;
_VersionType = tmp.VersionType;
_PermValue = tmp.PermValue;
_PermAD = tmp.PermAD;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_PermissionInfoExtension.Refresh(this);
if(_MyRole != null)
{
_MyRole.Dispose();// Dispose related value
_MyRole = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RolePermission tmp)
{
string key = tmp.PID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RolePermission tmp)
{
_PermLevel = tmp.PermLevel;
_VersionType = tmp.VersionType;
_PermValue = tmp.PermValue;
_PermAD = tmp.PermAD;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_PermissionInfoExtension.Refresh(this);
if(_MyRole != null)
{
_MyRole.Dispose();// Dispose related value
_MyRole = null;// Reset related value
}
OnChange();// raise an event
}
public static PermissionInfo Get(int pid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Permission");
try
{
PermissionInfo tmp = GetCachedByPrimaryKey(pid);
if (tmp == null)
{
tmp = DataPortal.Fetch<PermissionInfo>(new PKCriteria(pid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up PermissionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on PermissionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal PermissionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.Constructor", ex);
throw new DbCslaException("PermissionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _PID;
public int PID
{ get { return _PID; } }
public PKCriteria(int pid)
{
_PID = pid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.ReadData", GetHashCode());
try
{
_PID = dr.GetInt32("PID");
_RID = dr.GetInt32("RID");
_PermLevel = dr.GetInt32("PermLevel");
_VersionType = dr.GetInt32("VersionType");
_PermValue = dr.GetInt32("PermValue");
_PermAD = dr.GetInt32("PermAD");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PermissionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.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 = "getPermission";
cm.Parameters.AddWithValue("@PID", criteria.PID);
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("PermissionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PermissionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
PermissionInfoExtension _PermissionInfoExtension = new PermissionInfoExtension();
[Serializable()]
partial class PermissionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(PermissionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class PermissionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is PermissionInfo)
{
// Return the ToString value
return ((PermissionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void PermissionInfoEvent(object sender);
/// <summary>
/// PermissionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(PermissionInfoConverter))]
public partial class PermissionInfo : ReadOnlyBase<PermissionInfo>, IDisposable
{
public event PermissionInfoEvent 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<PermissionInfo> _CacheList = new List<PermissionInfo>();
protected static void AddToCache(PermissionInfo permissionInfo)
{
if (!_CacheList.Contains(permissionInfo)) _CacheList.Add(permissionInfo); // In AddToCache
}
protected static void RemoveFromCache(PermissionInfo permissionInfo)
{
while (_CacheList.Contains(permissionInfo)) _CacheList.Remove(permissionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<PermissionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PermissionInfo>>();
private static void ConvertListToDictionary()
{
List<PermissionInfo> remove = new List<PermissionInfo>();
foreach (PermissionInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.PID.ToString()))
{
_CacheByPrimaryKey[tmp.PID.ToString()] = new List<PermissionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.PID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (PermissionInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(PermissionInfoList lst)
{
foreach (PermissionInfo item in lst) AddToCache(item);
}
protected static PermissionInfo GetCachedByPrimaryKey(int pid)
{
ConvertListToDictionary();
string key = pid.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 Permission _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _PID;
[System.ComponentModel.DataObjectField(true, true)]
public int PID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _PID;
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRole != null) _RID = _MyRole.RID;
return _RID;
}
}
private RoleInfo _MyRole;
public RoleInfo MyRole
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRole == null && _RID != 0) _MyRole = RoleInfo.Get(_RID);
return _MyRole;
}
}
private int _PermLevel;
/// <summary>
/// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments
/// </summary>
public int PermLevel
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _PermLevel;
}
}
private int _VersionType;
/// <summary>
/// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _VersionType;
}
}
private int _PermValue;
/// <summary>
/// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All)
/// </summary>
public int PermValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _PermValue;
}
}
private int _PermAD;
/// <summary>
/// 0 - Allow, 1 - Deny
/// </summary>
public int PermAD
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _PermAD;
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _StartDate;
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _EndDate;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UsrID;
}
}
// TODO: Replace base PermissionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PermissionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check PermissionInfo.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 PermissionInfo</returns>
protected override object GetIdValue()
{
return _PID;
}
#endregion
#region Factory Methods
private static int _PermissionInfoUnique = 0;
private static int PermissionInfoUnique
{ get { return ++_PermissionInfoUnique; } }
private int _MyPermissionInfoUnique = PermissionInfoUnique;
public int MyPermissionInfoUnique
{ get { return _MyPermissionInfoUnique; } }
protected PermissionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(PID.ToString())) return;
List<PermissionInfo> listPermissionInfo = _CacheByPrimaryKey[PID.ToString()]; // Get the list of items
while (listPermissionInfo.Contains(this)) listPermissionInfo.Remove(this); // Remove the item from the list
if (listPermissionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(PID.ToString()); // remove the list
}
public virtual Permission Get()
{
return _Editable = Permission.Get(_PID);
}
public static void Refresh(Permission tmp)
{
string key = tmp.PID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Permission tmp)
{
if (_RID != tmp.RID)
{
if (MyRole != null) MyRole.RefreshRolePermissions(); // Update List for old value
_RID = tmp.RID; // Update the value
}
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRolePermissions(); // Update List for new value
_PermLevel = tmp.PermLevel;
_VersionType = tmp.VersionType;
_PermValue = tmp.PermValue;
_PermAD = tmp.PermAD;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_PermissionInfoExtension.Refresh(this);
if (_MyRole != null)
{
_MyRole.Dispose();// Dispose related value
_MyRole = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RolePermission tmp)
{
string key = tmp.PID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (PermissionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RolePermission tmp)
{
_PermLevel = tmp.PermLevel;
_VersionType = tmp.VersionType;
_PermValue = tmp.PermValue;
_PermAD = tmp.PermAD;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_PermissionInfoExtension.Refresh(this);
if (_MyRole != null)
{
_MyRole.Dispose();// Dispose related value
_MyRole = null;// Reset related value
}
OnChange();// raise an event
}
public static PermissionInfo Get(int pid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Permission");
try
{
PermissionInfo tmp = GetCachedByPrimaryKey(pid);
if (tmp == null)
{
tmp = DataPortal.Fetch<PermissionInfo>(new PKCriteria(pid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up PermissionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on PermissionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal PermissionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.Constructor", ex);
throw new DbCslaException("PermissionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _PID;
public int PID
{ get { return _PID; } }
public PKCriteria(int pid)
{
_PID = pid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.ReadData", GetHashCode());
try
{
_PID = dr.GetInt32("PID");
_RID = dr.GetInt32("RID");
_PermLevel = dr.GetInt32("PermLevel");
_VersionType = dr.GetInt32("VersionType");
_PermValue = dr.GetInt32("PermValue");
_PermAD = dr.GetInt32("PermAD");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("PermissionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PermissionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PermissionInfo.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 = "getPermission";
cm.Parameters.AddWithValue("@PID", criteria.PID);
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("PermissionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("PermissionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
PermissionInfoExtension _PermissionInfoExtension = new PermissionInfoExtension();
[Serializable()]
partial class PermissionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(PermissionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class PermissionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is PermissionInfo)
{
// Return the ToString value
return ((PermissionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,446 +19,434 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void RODbInfoEvent(object sender);
/// <summary>
/// RODbInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbInfoConverter))]
public partial class RODbInfo : ReadOnlyBase<RODbInfo>, IDisposable
{
public event RODbInfoEvent 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<RODbInfo> _CacheList = new List<RODbInfo>();
protected static void AddToCache(RODbInfo rODbInfo)
{
if (!_CacheList.Contains(rODbInfo)) _CacheList.Add(rODbInfo); // In AddToCache
}
protected static void RemoveFromCache(RODbInfo rODbInfo)
{
while (_CacheList.Contains(rODbInfo)) _CacheList.Remove(rODbInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RODbInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RODbInfo>>();
private static void ConvertListToDictionary()
{
List<RODbInfo> remove = new List<RODbInfo>();
foreach (RODbInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.RODbID.ToString()))
{
_CacheByPrimaryKey[tmp.RODbID.ToString()] = new List<RODbInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.RODbID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RODbInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(RODbInfoList lst)
{
foreach (RODbInfo item in lst) AddToCache(item);
}
protected static RODbInfo GetCachedByPrimaryKey(int rODbID)
{
ConvertListToDictionary();
string key = rODbID.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 RODb _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _RODbID;
[System.ComponentModel.DataObjectField(true, true)]
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
return _RODbID;
}
}
private string _ROName = string.Empty;
/// <summary>
/// Hook for future - to allow the user to select multiple RO Databases assocaiated with on DocVersion
/// </summary>
public string ROName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROName", true);
return _ROName;
}
}
private string _FolderPath = string.Empty;
/// <summary>
/// Path to the RO database
/// </summary>
public string FolderPath
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderPath", true);
return _FolderPath;
}
}
private string _DBConnectionString = string.Empty;
/// <summary>
/// Connection String - Default could just be the full path and name of the database
/// </summary>
public string DBConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DBConnectionString", true);
return _DBConnectionString;
}
}
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 _RODbROFstCount = 0;
/// <summary>
/// Count of RODbROFsts for this RODb
/// </summary>
public int RODbROFstCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbROFstCount", true);
return _RODbROFstCount;
}
}
private ROFstInfoList _RODbROFsts = null;
[TypeConverter(typeof(ROFstInfoListConverter))]
public ROFstInfoList RODbROFsts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbROFsts", true);
if (_RODbROFstCount < 0 || (_RODbROFstCount > 0 && _RODbROFsts == null))
_RODbROFsts = ROFstInfoList.GetByRODbID(_RODbID);
if (_RODbROFstCount < 0)
_RODbROFstCount = _RODbROFsts.Count;
return _RODbROFsts;
}
}
public void RefreshRODbROFsts()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RODbID.ToString()))
foreach (RODbInfo tmp in _CacheByPrimaryKey[_RODbID.ToString()])
tmp._RODbROFstCount = -1; // This will cause the data to be requeried
}
private int _RODbROImageCount = 0;
/// <summary>
/// Count of RODbROImages for this RODb
/// </summary>
public int RODbROImageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbROImageCount", true);
return _RODbROImageCount;
}
}
private ROImageInfoList _RODbROImages = null;
[TypeConverter(typeof(ROImageInfoListConverter))]
public ROImageInfoList RODbROImages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbROImages", true);
if (_RODbROImageCount < 0 || (_RODbROImageCount > 0 && _RODbROImages == null))
_RODbROImages = ROImageInfoList.GetByRODbID(_RODbID);
if (_RODbROImageCount < 0)
_RODbROImageCount = _RODbROImages.Count;
return _RODbROImages;
}
}
public void RefreshRODbROImages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RODbID.ToString()))
foreach (RODbInfo tmp in _CacheByPrimaryKey[_RODbID.ToString()])
tmp._RODbROImageCount = -1; // This will cause the data to be requeried
}
private int _RODbRoUsageCount = 0;
/// <summary>
/// Count of RODbRoUsages for this RODb
/// </summary>
public int RODbRoUsageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbRoUsageCount", true);
return _RODbRoUsageCount;
}
}
private RoUsageInfoList _RODbRoUsages = null;
[TypeConverter(typeof(RoUsageInfoListConverter))]
public RoUsageInfoList RODbRoUsages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbRoUsages", true);
if (_RODbRoUsageCount < 0 || (_RODbRoUsageCount > 0 && _RODbRoUsages == null))
_RODbRoUsages = RoUsageInfoList.GetByRODbID(_RODbID);
if (_RODbRoUsageCount < 0)
_RODbRoUsageCount = _RODbRoUsages.Count;
return _RODbRoUsages;
}
}
public void RefreshRODbRoUsages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RODbID.ToString()))
foreach (RODbInfo tmp in _CacheByPrimaryKey[_RODbID.ToString()])
tmp._RODbRoUsageCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base RODbInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RODbInfo.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 RODbInfo</returns>
protected override object GetIdValue()
{
return _RODbID;
}
#endregion
#region Factory Methods
private static int _RODbInfoUnique = 0;
private static int RODbInfoUnique
{ get { return ++_RODbInfoUnique; } }
private int _MyRODbInfoUnique = RODbInfoUnique;
public int MyRODbInfoUnique
{ get { return _MyRODbInfoUnique; } }
protected RODbInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(RODbID.ToString())) return;
List<RODbInfo> listRODbInfo = _CacheByPrimaryKey[RODbID.ToString()]; // Get the list of items
while (listRODbInfo.Contains(this)) listRODbInfo.Remove(this); // Remove the item from the list
if (listRODbInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(RODbID.ToString()); // remove the list
}
public virtual RODb Get()
{
return _Editable = RODb.Get(_RODbID);
}
public static void Refresh(RODb tmp)
{
string key = tmp.RODbID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RODbInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODb tmp)
{
_ROName = tmp.ROName;
_FolderPath = tmp.FolderPath;
_DBConnectionString = tmp.DBConnectionString;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_RODbInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static RODbInfo Get(int rODbID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a RODb");
try
{
RODbInfo tmp = GetCachedByPrimaryKey(rODbID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RODbInfo>(new PKCriteria(rODbID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RODbInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RODbInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RODbInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbInfo.Constructor", ex);
throw new DbCslaException("RODbInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _RODbID;
public int RODbID
{ get { return _RODbID; } }
public PKCriteria(int rODbID)
{
_RODbID = rODbID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbInfo.ReadData", GetHashCode());
try
{
_RODbID = dr.GetInt32("RODbID");
_ROName = dr.GetString("ROName");
_FolderPath = dr.GetString("FolderPath");
_DBConnectionString = dr.GetString("DBConnectionString");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_RODbROFstCount = dr.GetInt32("ROFstCount");
_RODbROImageCount = dr.GetInt32("ROImageCount");
_RODbRoUsageCount = dr.GetInt32("RoUsageCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RODbInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbInfo.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 = "getRODb";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
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("RODbInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RODbInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RODbInfoExtension _RODbInfoExtension = new RODbInfoExtension();
[Serializable()]
partial class RODbInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RODbInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RODbInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbInfo)
{
// Return the ToString value
return ((RODbInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void RODbInfoEvent(object sender);
/// <summary>
/// RODbInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbInfoConverter))]
public partial class RODbInfo : ReadOnlyBase<RODbInfo>, IDisposable
{
public event RODbInfoEvent 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<RODbInfo> _CacheList = new List<RODbInfo>();
protected static void AddToCache(RODbInfo rODbInfo)
{
if (!_CacheList.Contains(rODbInfo)) _CacheList.Add(rODbInfo); // In AddToCache
}
protected static void RemoveFromCache(RODbInfo rODbInfo)
{
while (_CacheList.Contains(rODbInfo)) _CacheList.Remove(rODbInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RODbInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RODbInfo>>();
private static void ConvertListToDictionary()
{
List<RODbInfo> remove = new List<RODbInfo>();
foreach (RODbInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.RODbID.ToString()))
{
_CacheByPrimaryKey[tmp.RODbID.ToString()] = new List<RODbInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.RODbID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RODbInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(RODbInfoList lst)
{
foreach (RODbInfo item in lst) AddToCache(item);
}
protected static RODbInfo GetCachedByPrimaryKey(int rODbID)
{
ConvertListToDictionary();
string key = rODbID.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 RODb _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _RODbID;
[System.ComponentModel.DataObjectField(true, true)]
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODbID;
}
}
private string _ROName = string.Empty;
/// <summary>
/// Hook for future - to allow the user to select multiple RO Databases assocaiated with on DocVersion
/// </summary>
public string ROName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROName;
}
}
private string _FolderPath = string.Empty;
/// <summary>
/// Path to the RO database
/// </summary>
public string FolderPath
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _FolderPath;
}
}
private string _DBConnectionString = string.Empty;
/// <summary>
/// Connection String - Default could just be the full path and name of the database
/// </summary>
public string DBConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DBConnectionString;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
private int _RODbROFstCount = 0;
/// <summary>
/// Count of RODbROFsts for this RODb
/// </summary>
public int RODbROFstCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODbROFstCount;
}
}
private ROFstInfoList _RODbROFsts = null;
[TypeConverter(typeof(ROFstInfoListConverter))]
public ROFstInfoList RODbROFsts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_RODbROFstCount < 0 || (_RODbROFstCount > 0 && _RODbROFsts == null))
_RODbROFsts = ROFstInfoList.GetByRODbID(_RODbID);
if (_RODbROFstCount < 0)
_RODbROFstCount = _RODbROFsts.Count;
return _RODbROFsts;
}
}
public void RefreshRODbROFsts()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RODbID.ToString()))
foreach (RODbInfo tmp in _CacheByPrimaryKey[_RODbID.ToString()])
tmp._RODbROFstCount = -1; // This will cause the data to be requeried
}
private int _RODbROImageCount = 0;
/// <summary>
/// Count of RODbROImages for this RODb
/// </summary>
public int RODbROImageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODbROImageCount;
}
}
private ROImageInfoList _RODbROImages = null;
[TypeConverter(typeof(ROImageInfoListConverter))]
public ROImageInfoList RODbROImages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_RODbROImageCount < 0 || (_RODbROImageCount > 0 && _RODbROImages == null))
_RODbROImages = ROImageInfoList.GetByRODbID(_RODbID);
if (_RODbROImageCount < 0)
_RODbROImageCount = _RODbROImages.Count;
return _RODbROImages;
}
}
public void RefreshRODbROImages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RODbID.ToString()))
foreach (RODbInfo tmp in _CacheByPrimaryKey[_RODbID.ToString()])
tmp._RODbROImageCount = -1; // This will cause the data to be requeried
}
private int _RODbRoUsageCount = 0;
/// <summary>
/// Count of RODbRoUsages for this RODb
/// </summary>
public int RODbRoUsageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RODbRoUsageCount;
}
}
private RoUsageInfoList _RODbRoUsages = null;
[TypeConverter(typeof(RoUsageInfoListConverter))]
public RoUsageInfoList RODbRoUsages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_RODbRoUsageCount < 0 || (_RODbRoUsageCount > 0 && _RODbRoUsages == null))
_RODbRoUsages = RoUsageInfoList.GetByRODbID(_RODbID);
if (_RODbRoUsageCount < 0)
_RODbRoUsageCount = _RODbRoUsages.Count;
return _RODbRoUsages;
}
}
public void RefreshRODbRoUsages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RODbID.ToString()))
foreach (RODbInfo tmp in _CacheByPrimaryKey[_RODbID.ToString()])
tmp._RODbRoUsageCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base RODbInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RODbInfo.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 RODbInfo</returns>
protected override object GetIdValue()
{
return _RODbID;
}
#endregion
#region Factory Methods
private static int _RODbInfoUnique = 0;
private static int RODbInfoUnique
{ get { return ++_RODbInfoUnique; } }
private int _MyRODbInfoUnique = RODbInfoUnique;
public int MyRODbInfoUnique
{ get { return _MyRODbInfoUnique; } }
protected RODbInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(RODbID.ToString())) return;
List<RODbInfo> listRODbInfo = _CacheByPrimaryKey[RODbID.ToString()]; // Get the list of items
while (listRODbInfo.Contains(this)) listRODbInfo.Remove(this); // Remove the item from the list
if (listRODbInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(RODbID.ToString()); // remove the list
}
public virtual RODb Get()
{
return _Editable = RODb.Get(_RODbID);
}
public static void Refresh(RODb tmp)
{
string key = tmp.RODbID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RODbInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODb tmp)
{
_ROName = tmp.ROName;
_FolderPath = tmp.FolderPath;
_DBConnectionString = tmp.DBConnectionString;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_RODbInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static RODbInfo Get(int rODbID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a RODb");
try
{
RODbInfo tmp = GetCachedByPrimaryKey(rODbID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RODbInfo>(new PKCriteria(rODbID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RODbInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RODbInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RODbInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbInfo.Constructor", ex);
throw new DbCslaException("RODbInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _RODbID;
public int RODbID
{ get { return _RODbID; } }
public PKCriteria(int rODbID)
{
_RODbID = rODbID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbInfo.ReadData", GetHashCode());
try
{
_RODbID = dr.GetInt32("RODbID");
_ROName = dr.GetString("ROName");
_FolderPath = dr.GetString("FolderPath");
_DBConnectionString = dr.GetString("DBConnectionString");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_RODbROFstCount = dr.GetInt32("ROFstCount");
_RODbROImageCount = dr.GetInt32("ROImageCount");
_RODbRoUsageCount = dr.GetInt32("RoUsageCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RODbInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbInfo.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 = "getRODb";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
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("RODbInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RODbInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RODbInfoExtension _RODbInfoExtension = new RODbInfoExtension();
[Serializable()]
partial class RODbInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RODbInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RODbInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbInfo)
{
// Return the ToString value
return ((RODbInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,353 +19,345 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// RODbROFst Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbROFstConverter))]
public partial class RODbROFst : BusinessBase<RODbROFst>, 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 _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFst _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFst MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROFst", true);
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFst.Get(_ROFstID);
return _MyROFst;
}
}
private byte[] _ROFST;
public byte[] ROFST
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFST", true);
return _ROFST;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROFST", true);
if (_ROFST != value)
{
_ROFST = 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
// TODO: Check RODbROFst.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 RODbROFst</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
// TODO: Replace base RODbROFst.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbROFst</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROFstID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROFST, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROFST, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static RODbROFst New(byte[] rofst)
{
return new RODbROFst(rofst);
}
internal static RODbROFst Get(SafeDataReader dr)
{
return new RODbROFst(dr);
}
public RODbROFst()
{
MarkAsChild();
_ROFstID = ROFst.NextROFstID;
_DTS = _RODbROFstExtension.DefaultDTS;
_UserID = _RODbROFstExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private RODbROFst(byte[] rofst)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _RODbROFstExtension.DefaultDTS;
_UserID = _RODbROFstExtension.DefaultUserID;
_ROFST = rofst;
ValidationRules.CheckRules();
}
internal RODbROFst(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbROFst.FetchDR", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_ROFST = (byte[])dr.GetValue("ROFST");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbROFst.FetchDR", ex);
throw new DbCslaException("RODbROFst.Fetch", ex);
}
MarkOld();
}
internal void Insert(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFst.Add(cn, ref _ROFstID, myRODb, _ROFST, _DTS, _UserID);
MarkOld();
}
internal void Update(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFst.Update(cn, ref _ROFstID, myRODb, _ROFST, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(RODb myRODb)
{
// 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"];
ROFst.Remove(cn, _ROFstID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RODbROFstExtension _RODbROFstExtension = new RODbROFstExtension();
[Serializable()]
partial class RODbROFstExtension : 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 RODbROFstConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbROFst)
{
// Return the ToString value
return ((RODbROFst)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
/// <summary>
/// RODbROFst Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbROFstConverter))]
public partial class RODbROFst : BusinessBase<RODbROFst>, 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 _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFst _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFst MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFst.Get(_ROFstID);
return _MyROFst;
}
}
private byte[] _ROFST;
public byte[] ROFST
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFST;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_ROFST != value)
{
_ROFST = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check RODbROFst.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 RODbROFst</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
// TODO: Replace base RODbROFst.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbROFst</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROFstID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROFST, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROFST, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static RODbROFst New(byte[] rofst)
{
return new RODbROFst(rofst);
}
internal static RODbROFst Get(SafeDataReader dr)
{
return new RODbROFst(dr);
}
public RODbROFst()
{
MarkAsChild();
_ROFstID = ROFst.NextROFstID;
_DTS = _RODbROFstExtension.DefaultDTS;
_UserID = _RODbROFstExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private RODbROFst(byte[] rofst)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _RODbROFstExtension.DefaultDTS;
_UserID = _RODbROFstExtension.DefaultUserID;
_ROFST = rofst;
ValidationRules.CheckRules();
}
internal RODbROFst(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbROFst.FetchDR", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_ROFST = (byte[])dr.GetValue("ROFST");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbROFst.FetchDR", ex);
throw new DbCslaException("RODbROFst.Fetch", ex);
}
MarkOld();
}
internal void Insert(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFst.Add(cn, ref _ROFstID, myRODb, _ROFST, _DTS, _UserID);
MarkOld();
}
internal void Update(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFst.Update(cn, ref _ROFstID, myRODb, _ROFST, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(RODb myRODb)
{
// 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"];
ROFst.Remove(cn, _ROFstID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RODbROFstExtension _RODbROFstExtension = new RODbROFstExtension();
[Serializable()]
partial class RODbROFstExtension : 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 RODbROFstConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbROFst)
{
// Return the ToString value
return ((RODbROFst)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,383 +19,373 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// RODbROImage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbROImageConverter))]
public partial class RODbROImage : BusinessBase<RODbROImage>, 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 _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ImageID", true);
if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
return _ImageID;
}
}
private ROImage _MyROImage;
[System.ComponentModel.DataObjectField(true, true)]
public ROImage MyROImage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROImage", true);
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
return _MyROImage;
}
}
private string _FileName = string.Empty;
public string FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FileName", true);
return _FileName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("FileName", true);
if (value == null) value = string.Empty;
if (_FileName != value)
{
_FileName = value;
PropertyHasChanged();
}
}
}
private byte[] _Content;
public byte[] Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content", true);
return _Content;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Content", true);
if (_Content != value)
{
_Content = 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
// TODO: Check RODbROImage.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 RODbROImage</returns>
protected override object GetIdValue()
{
return _ImageID;
}
// TODO: Replace base RODbROImage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbROImage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "FileName");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("FileName", 255));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ImageID, "<Role(s)>");
//AuthorizationRules.AllowRead(FileName, "<Role(s)>");
//AuthorizationRules.AllowWrite(FileName, "<Role(s)>");
//AuthorizationRules.AllowRead(Content, "<Role(s)>");
//AuthorizationRules.AllowWrite(Content, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static RODbROImage New(string fileName, byte[] content)
{
return new RODbROImage(fileName, content);
}
internal static RODbROImage Get(SafeDataReader dr)
{
return new RODbROImage(dr);
}
public RODbROImage()
{
MarkAsChild();
_ImageID = ROImage.NextImageID;
_DTS = _RODbROImageExtension.DefaultDTS;
_UserID = _RODbROImageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private RODbROImage(string fileName, byte[] content)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _RODbROImageExtension.DefaultDTS;
_UserID = _RODbROImageExtension.DefaultUserID;
_FileName = fileName;
_Content = content;
ValidationRules.CheckRules();
}
internal RODbROImage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbROImage.FetchDR", GetHashCode());
try
{
_ImageID = dr.GetInt32("ImageID");
_FileName = dr.GetString("FileName");
_Content = (byte[])dr.GetValue("Content");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbROImage.FetchDR", ex);
throw new DbCslaException("RODbROImage.Fetch", ex);
}
MarkOld();
}
internal void Insert(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROImage.Add(cn, ref _ImageID, myRODb, _FileName, _Content, _DTS, _UserID);
MarkOld();
}
internal void Update(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROImage.Update(cn, ref _ImageID, myRODb, _FileName, _Content, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(RODb myRODb)
{
// 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"];
ROImage.Remove(cn, _ImageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RODbROImageExtension _RODbROImageExtension = new RODbROImageExtension();
[Serializable()]
partial class RODbROImageExtension : 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 RODbROImageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbROImage)
{
// Return the ToString value
return ((RODbROImage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
/// <summary>
/// RODbROImage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbROImageConverter))]
public partial class RODbROImage : BusinessBase<RODbROImage>, 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 _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
return _ImageID;
}
}
private ROImage _MyROImage;
[System.ComponentModel.DataObjectField(true, true)]
public ROImage MyROImage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
return _MyROImage;
}
}
private string _FileName = string.Empty;
public string FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _FileName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_FileName != value)
{
_FileName = value;
PropertyHasChanged();
}
}
}
private byte[] _Content;
public byte[] Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_Content != value)
{
_Content = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check RODbROImage.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 RODbROImage</returns>
protected override object GetIdValue()
{
return _ImageID;
}
// TODO: Replace base RODbROImage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbROImage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "FileName");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("FileName", 255));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ImageID, "<Role(s)>");
//AuthorizationRules.AllowRead(FileName, "<Role(s)>");
//AuthorizationRules.AllowWrite(FileName, "<Role(s)>");
//AuthorizationRules.AllowRead(Content, "<Role(s)>");
//AuthorizationRules.AllowWrite(Content, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static RODbROImage New(string fileName, byte[] content)
{
return new RODbROImage(fileName, content);
}
internal static RODbROImage Get(SafeDataReader dr)
{
return new RODbROImage(dr);
}
public RODbROImage()
{
MarkAsChild();
_ImageID = ROImage.NextImageID;
_DTS = _RODbROImageExtension.DefaultDTS;
_UserID = _RODbROImageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private RODbROImage(string fileName, byte[] content)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _RODbROImageExtension.DefaultDTS;
_UserID = _RODbROImageExtension.DefaultUserID;
_FileName = fileName;
_Content = content;
ValidationRules.CheckRules();
}
internal RODbROImage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbROImage.FetchDR", GetHashCode());
try
{
_ImageID = dr.GetInt32("ImageID");
_FileName = dr.GetString("FileName");
_Content = (byte[])dr.GetValue("Content");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbROImage.FetchDR", ex);
throw new DbCslaException("RODbROImage.Fetch", ex);
}
MarkOld();
}
internal void Insert(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROImage.Add(cn, ref _ImageID, myRODb, _FileName, _Content, _DTS, _UserID);
MarkOld();
}
internal void Update(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROImage.Update(cn, ref _ImageID, myRODb, _FileName, _Content, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(RODb myRODb)
{
// 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"];
ROImage.Remove(cn, _ImageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RODbROImageExtension _RODbROImageExtension = new RODbROImageExtension();
[Serializable()]
partial class RODbROImageExtension : 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 RODbROImageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbROImage)
{
// Return the ToString value
return ((RODbROImage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,432 +19,417 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ROFstDocVersionROFst Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstDocVersionROFstConverter))]
public partial class ROFstDocVersionROFst : BusinessBase<ROFstDocVersionROFst>, 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 (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID;
}
}
private DocVersion _MyDocVersion;
[System.ComponentModel.DataObjectField(true, true)]
public DocVersion MyDocVersion
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDocVersion", true);
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID);
return _MyDocVersion;
}
}
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 _DocVersion_FolderID;
public int DocVersion_FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_FolderID", true);
return _DocVersion_FolderID;
}
}
private int _DocVersion_VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int DocVersion_VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_VersionType", true);
return _DocVersion_VersionType;
}
}
private string _DocVersion_Name = string.Empty;
public string DocVersion_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_Name", true);
return _DocVersion_Name;
}
}
private string _DocVersion_Title = string.Empty;
public string DocVersion_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_Title", true);
return _DocVersion_Title;
}
}
private int? _DocVersion_ItemID;
public int? DocVersion_ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_ItemID", true);
return _DocVersion_ItemID;
}
}
private int? _DocVersion_FormatID;
public int? DocVersion_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_FormatID", true);
return _DocVersion_FormatID;
}
}
private string _DocVersion_Config = string.Empty;
public string DocVersion_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_Config", true);
return _DocVersion_Config;
}
}
private DateTime _DocVersion_DTS = new DateTime();
public DateTime DocVersion_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_DTS", true);
return _DocVersion_DTS;
}
}
private string _DocVersion_UserID = string.Empty;
public string DocVersion_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_UserID", true);
return _DocVersion_UserID;
}
}
// TODO: Check ROFstDocVersionROFst.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 ROFstDocVersionROFst</returns>
protected override object GetIdValue()
{
return _VersionID;
}
// TODO: Replace base ROFstDocVersionROFst.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstDocVersionROFst</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(VersionID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ROFstDocVersionROFst New(DocVersion myDocVersion)
{
return new ROFstDocVersionROFst(myDocVersion);
}
internal static ROFstDocVersionROFst Get(SafeDataReader dr)
{
return new ROFstDocVersionROFst(dr);
}
public ROFstDocVersionROFst()
{
MarkAsChild();
/// <summary>
/// ROFstDocVersionROFst Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstDocVersionROFstConverter))]
public partial class ROFstDocVersionROFst : BusinessBase<ROFstDocVersionROFst>, 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
{
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID;
}
}
private DocVersion _MyDocVersion;
[System.ComponentModel.DataObjectField(true, true)]
public DocVersion MyDocVersion
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID);
return _MyDocVersion;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _DocVersion_FolderID;
public int DocVersion_FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_FolderID;
}
}
private int _DocVersion_VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int DocVersion_VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_VersionType;
}
}
private string _DocVersion_Name = string.Empty;
public string DocVersion_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_Name;
}
}
private string _DocVersion_Title = string.Empty;
public string DocVersion_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_Title;
}
}
private int? _DocVersion_ItemID;
public int? DocVersion_ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_ItemID;
}
}
private int? _DocVersion_FormatID;
public int? DocVersion_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_FormatID;
}
}
private string _DocVersion_Config = string.Empty;
public string DocVersion_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_Config;
}
}
private DateTime _DocVersion_DTS = new DateTime();
public DateTime DocVersion_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_DTS;
}
}
private string _DocVersion_UserID = string.Empty;
public string DocVersion_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DocVersion_UserID;
}
}
// TODO: Check ROFstDocVersionROFst.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 ROFstDocVersionROFst</returns>
protected override object GetIdValue()
{
return _VersionID;
}
// TODO: Replace base ROFstDocVersionROFst.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstDocVersionROFst</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(VersionID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ROFstDocVersionROFst New(DocVersion myDocVersion)
{
return new ROFstDocVersionROFst(myDocVersion);
}
internal static ROFstDocVersionROFst Get(SafeDataReader dr)
{
return new ROFstDocVersionROFst(dr);
}
public ROFstDocVersionROFst()
{
MarkAsChild();
_DTS = _ROFstDocVersionROFstExtension.DefaultDTS;
_UserID = _ROFstDocVersionROFstExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROFstDocVersionROFst(DocVersion myDocVersion)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROFstDocVersionROFstExtension.DefaultDTS;
_UserID = _ROFstDocVersionROFstExtension.DefaultUserID;
_MyDocVersion = myDocVersion;
ValidationRules.CheckRules();
}
internal ROFstDocVersionROFst(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstDocVersionROFst.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_DocVersion_FolderID = dr.GetInt32("DocVersion_FolderID");
_DocVersion_VersionType = dr.GetInt32("DocVersion_VersionType");
_DocVersion_Name = dr.GetString("DocVersion_Name");
_DocVersion_Title = dr.GetString("DocVersion_Title");
_DocVersion_ItemID = (int?)dr.GetValue("DocVersion_ItemID");
_DocVersion_FormatID = (int?)dr.GetValue("DocVersion_FormatID");
_DocVersion_Config = dr.GetString("DocVersion_Config");
_DocVersion_DTS = dr.GetDateTime("DocVersion_DTS");
_DocVersion_UserID = dr.GetString("DocVersion_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstDocVersionROFst.FetchDR", ex);
throw new DbCslaException("ROFstDocVersionROFst.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersionROFst.Add(cn, _MyDocVersion, myROFst, _DTS, _UserID);
MarkOld();
}
internal void Update(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersionROFst.Update(cn, _MyDocVersion, myROFst, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROFst myROFst)
{
// 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"];
DocVersionROFst.Remove(cn, _VersionID, myROFst.ROFstID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROFstDocVersionROFstExtension _ROFstDocVersionROFstExtension = new ROFstDocVersionROFstExtension();
[Serializable()]
partial class ROFstDocVersionROFstExtension : 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 ROFstDocVersionROFstConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstDocVersionROFst)
{
// Return the ToString value
return ((ROFstDocVersionROFst)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
_DTS = _ROFstDocVersionROFstExtension.DefaultDTS;
_UserID = _ROFstDocVersionROFstExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROFstDocVersionROFst(DocVersion myDocVersion)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROFstDocVersionROFstExtension.DefaultDTS;
_UserID = _ROFstDocVersionROFstExtension.DefaultUserID;
_MyDocVersion = myDocVersion;
ValidationRules.CheckRules();
}
internal ROFstDocVersionROFst(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstDocVersionROFst.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_DocVersion_FolderID = dr.GetInt32("DocVersion_FolderID");
_DocVersion_VersionType = dr.GetInt32("DocVersion_VersionType");
_DocVersion_Name = dr.GetString("DocVersion_Name");
_DocVersion_Title = dr.GetString("DocVersion_Title");
_DocVersion_ItemID = (int?)dr.GetValue("DocVersion_ItemID");
_DocVersion_FormatID = (int?)dr.GetValue("DocVersion_FormatID");
_DocVersion_Config = dr.GetString("DocVersion_Config");
_DocVersion_DTS = dr.GetDateTime("DocVersion_DTS");
_DocVersion_UserID = dr.GetString("DocVersion_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstDocVersionROFst.FetchDR", ex);
throw new DbCslaException("ROFstDocVersionROFst.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersionROFst.Add(cn, _MyDocVersion, myROFst, _DTS, _UserID);
MarkOld();
}
internal void Update(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersionROFst.Update(cn, _MyDocVersion, myROFst, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROFst myROFst)
{
// 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"];
DocVersionROFst.Remove(cn, _VersionID, myROFst.ROFstID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROFstDocVersionROFstExtension _ROFstDocVersionROFstExtension = new ROFstDocVersionROFstExtension();
[Serializable()]
partial class ROFstDocVersionROFstExtension : 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 ROFstDocVersionROFstConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstDocVersionROFst)
{
// Return the ToString value
return ((ROFstDocVersionROFst)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,396 +19,390 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ROFstImageInfoEvent(object sender);
/// <summary>
/// ROFstImageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstImageInfoConverter))]
public partial class ROFstImageInfo : ReadOnlyBase<ROFstImageInfo>, IDisposable
{
public event ROFstImageInfoEvent 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<ROFstImageInfo> _CacheList = new List<ROFstImageInfo>();
protected static void AddToCache(ROFstImageInfo rOFstImageInfo)
{
if (!_CacheList.Contains(rOFstImageInfo)) _CacheList.Add(rOFstImageInfo); // In AddToCache
}
protected static void RemoveFromCache(ROFstImageInfo rOFstImageInfo)
{
while (_CacheList.Contains(rOFstImageInfo)) _CacheList.Remove(rOFstImageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ROFstImageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROFstImageInfo>>();
private static void ConvertListToDictionary()
{
List<ROFstImageInfo> remove = new List<ROFstImageInfo>();
foreach (ROFstImageInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROFstID.ToString() + "_" + tmp.ImageID.ToString()))
{
_CacheByPrimaryKey[tmp.ROFstID.ToString() + "_" + tmp.ImageID.ToString()] = new List<ROFstImageInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ROFstID.ToString() + "_" + tmp.ImageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ROFstImageInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ROFstImageInfoList lst)
{
foreach (ROFstImageInfo item in lst) AddToCache(item);
}
protected static ROFstImageInfo GetCachedByPrimaryKey(int rOFstID, int imageID)
{
ConvertListToDictionary();
string key = rOFstID.ToString() + "_" + imageID.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 ROFstImage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFstInfo _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFstInfo MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROFst", true);
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.Get(_ROFstID);
return _MyROFst;
}
}
private int _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ImageID", true);
if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
return _ImageID;
}
}
private ROImageInfo _MyROImage;
[System.ComponentModel.DataObjectField(true, true)]
public ROImageInfo MyROImage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROImage", true);
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImageInfo.Get(_ImageID);
return _MyROImage;
}
}
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;
}
}
// TODO: Replace base ROFstImageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstImageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ROFstImageInfo.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 ROFstImageInfo</returns>
protected override object GetIdValue()
{
return (_ROFstID.ToString() + "." + _ImageID.ToString()).GetHashCode();
}
#endregion
#region Factory Methods
private static int _ROFstImageInfoUnique = 0;
private static int ROFstImageInfoUnique
{ get { return ++_ROFstImageInfoUnique; } }
private int _MyROFstImageInfoUnique = ROFstImageInfoUnique;
public int MyROFstImageInfoUnique
{ get { return _MyROFstImageInfoUnique; } }
protected ROFstImageInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ROFstID.ToString() + "_" + ImageID.ToString())) return;
List<ROFstImageInfo> listROFstImageInfo = _CacheByPrimaryKey[ROFstID.ToString() + "_" + ImageID.ToString()]; // Get the list of items
while (listROFstImageInfo.Contains(this)) listROFstImageInfo.Remove(this); // Remove the item from the list
if (listROFstImageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ROFstID.ToString() + "_" + ImageID.ToString()); // remove the list
}
public virtual ROFstImage Get()
{
return _Editable = ROFstImage.Get(_ROFstID, _ImageID);
}
public static void Refresh(ROFstImage tmp)
{
string key = tmp.ROFstID.ToString() + "_" + tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFstImage tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstImageInfoExtension.Refresh(this);
if(_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
if(_MyROImage != null)
{
_MyROImage.Dispose();// Dispose related value
_MyROImage = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ROFst myROFst, ROFstROFstImage tmp)
{
string key = myROFst.ROFstID.ToString() + "_" + tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFstROFstImage tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstImageInfoExtension.Refresh(this);
if(_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
if(_MyROImage != null)
{
_MyROImage.Dispose();// Dispose related value
_MyROImage = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ROImage myROImage, ROImageROFstImage tmp)
{
string key = tmp.ROFstID.ToString() + "_" + myROImage.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROImageROFstImage tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstImageInfoExtension.Refresh(this);
if(_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
if(_MyROImage != null)
{
_MyROImage.Dispose();// Dispose related value
_MyROImage = null;// Reset related value
}
OnChange();// raise an event
}
public static ROFstImageInfo Get(int rOFstID, int imageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROFstImage");
try
{
ROFstImageInfo tmp = GetCachedByPrimaryKey(rOFstID, imageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROFstImageInfo>(new PKCriteria(rOFstID, imageID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFstImageInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstImageInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROFstImageInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstImageInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstImageInfo.Constructor", ex);
throw new DbCslaException("ROFstImageInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
private int _ImageID;
public int ImageID
{ get { return _ImageID; } }
public PKCriteria(int rOFstID, int imageID)
{
_ROFstID = rOFstID;
_ImageID = imageID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstImageInfo.ReadData", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_ImageID = dr.GetInt32("ImageID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstImageInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstImageInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstImageInfo.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 = "getROFstImage";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
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("ROFstImageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstImageInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROFstImageInfoExtension _ROFstImageInfoExtension = new ROFstImageInfoExtension();
[Serializable()]
partial class ROFstImageInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ROFstImageInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ROFstImageInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstImageInfo)
{
// Return the ToString value
return ((ROFstImageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void ROFstImageInfoEvent(object sender);
/// <summary>
/// ROFstImageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstImageInfoConverter))]
public partial class ROFstImageInfo : ReadOnlyBase<ROFstImageInfo>, IDisposable
{
public event ROFstImageInfoEvent 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<ROFstImageInfo> _CacheList = new List<ROFstImageInfo>();
protected static void AddToCache(ROFstImageInfo rOFstImageInfo)
{
if (!_CacheList.Contains(rOFstImageInfo)) _CacheList.Add(rOFstImageInfo); // In AddToCache
}
protected static void RemoveFromCache(ROFstImageInfo rOFstImageInfo)
{
while (_CacheList.Contains(rOFstImageInfo)) _CacheList.Remove(rOFstImageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ROFstImageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROFstImageInfo>>();
private static void ConvertListToDictionary()
{
List<ROFstImageInfo> remove = new List<ROFstImageInfo>();
foreach (ROFstImageInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROFstID.ToString() + "_" + tmp.ImageID.ToString()))
{
_CacheByPrimaryKey[tmp.ROFstID.ToString() + "_" + tmp.ImageID.ToString()] = new List<ROFstImageInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ROFstID.ToString() + "_" + tmp.ImageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ROFstImageInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ROFstImageInfoList lst)
{
foreach (ROFstImageInfo item in lst) AddToCache(item);
}
protected static ROFstImageInfo GetCachedByPrimaryKey(int rOFstID, int imageID)
{
ConvertListToDictionary();
string key = rOFstID.ToString() + "_" + imageID.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 ROFstImage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFstInfo _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFstInfo MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.Get(_ROFstID);
return _MyROFst;
}
}
private int _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
return _ImageID;
}
}
private ROImageInfo _MyROImage;
[System.ComponentModel.DataObjectField(true, true)]
public ROImageInfo MyROImage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImageInfo.Get(_ImageID);
return _MyROImage;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
// TODO: Replace base ROFstImageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstImageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ROFstImageInfo.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 ROFstImageInfo</returns>
protected override object GetIdValue()
{
return (_ROFstID.ToString() + "." + _ImageID.ToString()).GetHashCode();
}
#endregion
#region Factory Methods
private static int _ROFstImageInfoUnique = 0;
private static int ROFstImageInfoUnique
{ get { return ++_ROFstImageInfoUnique; } }
private int _MyROFstImageInfoUnique = ROFstImageInfoUnique;
public int MyROFstImageInfoUnique
{ get { return _MyROFstImageInfoUnique; } }
protected ROFstImageInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ROFstID.ToString() + "_" + ImageID.ToString())) return;
List<ROFstImageInfo> listROFstImageInfo = _CacheByPrimaryKey[ROFstID.ToString() + "_" + ImageID.ToString()]; // Get the list of items
while (listROFstImageInfo.Contains(this)) listROFstImageInfo.Remove(this); // Remove the item from the list
if (listROFstImageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ROFstID.ToString() + "_" + ImageID.ToString()); // remove the list
}
public virtual ROFstImage Get()
{
return _Editable = ROFstImage.Get(_ROFstID, _ImageID);
}
public static void Refresh(ROFstImage tmp)
{
string key = tmp.ROFstID.ToString() + "_" + tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFstImage tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstImageInfoExtension.Refresh(this);
if (_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
if (_MyROImage != null)
{
_MyROImage.Dispose();// Dispose related value
_MyROImage = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ROFst myROFst, ROFstROFstImage tmp)
{
string key = myROFst.ROFstID.ToString() + "_" + tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFstROFstImage tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstImageInfoExtension.Refresh(this);
if (_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
if (_MyROImage != null)
{
_MyROImage.Dispose();// Dispose related value
_MyROImage = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ROImage myROImage, ROImageROFstImage tmp)
{
string key = tmp.ROFstID.ToString() + "_" + myROImage.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROImageROFstImage tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstImageInfoExtension.Refresh(this);
if (_MyROFst != null)
{
_MyROFst.Dispose();// Dispose related value
_MyROFst = null;// Reset related value
}
if (_MyROImage != null)
{
_MyROImage.Dispose();// Dispose related value
_MyROImage = null;// Reset related value
}
OnChange();// raise an event
}
public static ROFstImageInfo Get(int rOFstID, int imageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROFstImage");
try
{
ROFstImageInfo tmp = GetCachedByPrimaryKey(rOFstID, imageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROFstImageInfo>(new PKCriteria(rOFstID, imageID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFstImageInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstImageInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROFstImageInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstImageInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstImageInfo.Constructor", ex);
throw new DbCslaException("ROFstImageInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
private int _ImageID;
public int ImageID
{ get { return _ImageID; } }
public PKCriteria(int rOFstID, int imageID)
{
_ROFstID = rOFstID;
_ImageID = imageID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstImageInfo.ReadData", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_ImageID = dr.GetInt32("ImageID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstImageInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstImageInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstImageInfo.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 = "getROFstImage";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
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("ROFstImageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstImageInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROFstImageInfoExtension _ROFstImageInfoExtension = new ROFstImageInfoExtension();
[Serializable()]
partial class ROFstImageInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ROFstImageInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ROFstImageInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstImageInfo)
{
// Return the ToString value
return ((ROFstImageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,433 +19,423 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ROFstInfoEvent(object sender);
/// <summary>
/// ROFstInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstInfoConverter))]
public partial class ROFstInfo : ReadOnlyBase<ROFstInfo>, IDisposable
{
public event ROFstInfoEvent 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<ROFstInfo> _CacheList = new List<ROFstInfo>();
protected static void AddToCache(ROFstInfo rOFstInfo)
{
if (!_CacheList.Contains(rOFstInfo)) _CacheList.Add(rOFstInfo); // In AddToCache
}
protected static void RemoveFromCache(ROFstInfo rOFstInfo)
{
while (_CacheList.Contains(rOFstInfo)) _CacheList.Remove(rOFstInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ROFstInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROFstInfo>>();
private static void ConvertListToDictionary()
{
List<ROFstInfo> remove = new List<ROFstInfo>();
foreach (ROFstInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROFstID.ToString()))
{
_CacheByPrimaryKey[tmp.ROFstID.ToString()] = new List<ROFstInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ROFstID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ROFstInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ROFstInfoList lst)
{
foreach (ROFstInfo item in lst) AddToCache(item);
}
protected static ROFstInfo GetCachedByPrimaryKey(int rOFstID)
{
ConvertListToDictionary();
string key = rOFstID.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 ROFst _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
return _ROFstID;
}
}
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
private byte[] _ROFST;
public byte[] ROFST
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFST", true);
return _ROFST;
}
}
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 _ROFstDocVersionROFstCount = 0;
/// <summary>
/// Count of ROFstDocVersionROFsts for this ROFst
/// </summary>
public int ROFstDocVersionROFstCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstDocVersionROFstCount", true);
return _ROFstDocVersionROFstCount;
}
}
private DocVersionROFstInfoList _ROFstDocVersionROFsts = null;
[TypeConverter(typeof(DocVersionROFstInfoListConverter))]
public DocVersionROFstInfoList ROFstDocVersionROFsts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstDocVersionROFsts", true);
if (_ROFstDocVersionROFstCount < 0 || (_ROFstDocVersionROFstCount > 0 && _ROFstDocVersionROFsts == null))
_ROFstDocVersionROFsts = DocVersionROFstInfoList.GetByROFstID(_ROFstID);
if (_ROFstDocVersionROFstCount < 0)
_ROFstDocVersionROFstCount = _ROFstDocVersionROFsts.Count;
return _ROFstDocVersionROFsts;
}
}
public void RefreshROFstDocVersionROFsts()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ROFstID.ToString()))
foreach (ROFstInfo tmp in _CacheByPrimaryKey[_ROFstID.ToString()])
tmp._ROFstDocVersionROFstCount = -1; // This will cause the data to be requeried
}
private int _ROFstROFstImageCount = 0;
/// <summary>
/// Count of ROFstROFstImages for this ROFst
/// </summary>
public int ROFstROFstImageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstROFstImageCount", true);
return _ROFstROFstImageCount;
}
}
private ROFstImageInfoList _ROFstROFstImages = null;
[TypeConverter(typeof(ROFstImageInfoListConverter))]
public ROFstImageInfoList ROFstROFstImages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstROFstImages", true);
if (_ROFstROFstImageCount < 0 || (_ROFstROFstImageCount > 0 && _ROFstROFstImages == null))
_ROFstROFstImages = ROFstImageInfoList.GetByROFstID(_ROFstID);
if (_ROFstROFstImageCount < 0)
_ROFstROFstImageCount = _ROFstROFstImages.Count;
return _ROFstROFstImages;
}
}
public void RefreshROFstROFstImages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ROFstID.ToString()))
foreach (ROFstInfo tmp in _CacheByPrimaryKey[_ROFstID.ToString()])
tmp._ROFstROFstImageCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ROFstInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ROFstInfo.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 ROFstInfo</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
#endregion
#region Factory Methods
private static int _ROFstInfoUnique = 0;
private static int ROFstInfoUnique
{ get { return ++_ROFstInfoUnique; } }
private int _MyROFstInfoUnique = ROFstInfoUnique;
public int MyROFstInfoUnique
{ get { return _MyROFstInfoUnique; } }
protected ROFstInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ROFstID.ToString())) return;
List<ROFstInfo> listROFstInfo = _CacheByPrimaryKey[ROFstID.ToString()]; // Get the list of items
while (listROFstInfo.Contains(this)) listROFstInfo.Remove(this); // Remove the item from the list
if (listROFstInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ROFstID.ToString()); // remove the list
}
public virtual ROFst Get()
{
return _Editable = ROFst.Get(_ROFstID);
}
public static void Refresh(ROFst tmp)
{
string key = tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFst tmp)
{
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for new value
_ROFST = tmp.ROFST;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstInfoExtension.Refresh(this);
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbROFst tmp)
{
string key = tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbROFst tmp)
{
_ROFST = tmp.ROFST;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstInfoExtension.Refresh(this);
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static ROFstInfo Get(int rOFstID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFstInfo tmp = GetCachedByPrimaryKey(rOFstID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROFstInfo>(new PKCriteria(rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFstInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROFstInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfo.Constructor", ex);
throw new DbCslaException("ROFstInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.ReadData", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_RODbID = dr.GetInt32("RODbID");
_ROFST = (byte[])dr.GetValue("ROFST");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ROFstDocVersionROFstCount = dr.GetInt32("DocVersionROFstCount");
_ROFstROFstImageCount = dr.GetInt32("ROFstImageCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.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 = "getROFst";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
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("ROFstInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROFstInfoExtension _ROFstInfoExtension = new ROFstInfoExtension();
[Serializable()]
partial class ROFstInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ROFstInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ROFstInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstInfo)
{
// Return the ToString value
return ((ROFstInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void ROFstInfoEvent(object sender);
/// <summary>
/// ROFstInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstInfoConverter))]
public partial class ROFstInfo : ReadOnlyBase<ROFstInfo>, IDisposable
{
public event ROFstInfoEvent 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<ROFstInfo> _CacheList = new List<ROFstInfo>();
protected static void AddToCache(ROFstInfo rOFstInfo)
{
if (!_CacheList.Contains(rOFstInfo)) _CacheList.Add(rOFstInfo); // In AddToCache
}
protected static void RemoveFromCache(ROFstInfo rOFstInfo)
{
while (_CacheList.Contains(rOFstInfo)) _CacheList.Remove(rOFstInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ROFstInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROFstInfo>>();
private static void ConvertListToDictionary()
{
List<ROFstInfo> remove = new List<ROFstInfo>();
foreach (ROFstInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROFstID.ToString()))
{
_CacheByPrimaryKey[tmp.ROFstID.ToString()] = new List<ROFstInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ROFstID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ROFstInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ROFstInfoList lst)
{
foreach (ROFstInfo item in lst) AddToCache(item);
}
protected static ROFstInfo GetCachedByPrimaryKey(int rOFstID)
{
ConvertListToDictionary();
string key = rOFstID.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 ROFst _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFstID;
}
}
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
private byte[] _ROFST;
public byte[] ROFST
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFST;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
private int _ROFstDocVersionROFstCount = 0;
/// <summary>
/// Count of ROFstDocVersionROFsts for this ROFst
/// </summary>
public int ROFstDocVersionROFstCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFstDocVersionROFstCount;
}
}
private DocVersionROFstInfoList _ROFstDocVersionROFsts = null;
[TypeConverter(typeof(DocVersionROFstInfoListConverter))]
public DocVersionROFstInfoList ROFstDocVersionROFsts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_ROFstDocVersionROFstCount < 0 || (_ROFstDocVersionROFstCount > 0 && _ROFstDocVersionROFsts == null))
_ROFstDocVersionROFsts = DocVersionROFstInfoList.GetByROFstID(_ROFstID);
if (_ROFstDocVersionROFstCount < 0)
_ROFstDocVersionROFstCount = _ROFstDocVersionROFsts.Count;
return _ROFstDocVersionROFsts;
}
}
public void RefreshROFstDocVersionROFsts()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ROFstID.ToString()))
foreach (ROFstInfo tmp in _CacheByPrimaryKey[_ROFstID.ToString()])
tmp._ROFstDocVersionROFstCount = -1; // This will cause the data to be requeried
}
private int _ROFstROFstImageCount = 0;
/// <summary>
/// Count of ROFstROFstImages for this ROFst
/// </summary>
public int ROFstROFstImageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFstROFstImageCount;
}
}
private ROFstImageInfoList _ROFstROFstImages = null;
[TypeConverter(typeof(ROFstImageInfoListConverter))]
public ROFstImageInfoList ROFstROFstImages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_ROFstROFstImageCount < 0 || (_ROFstROFstImageCount > 0 && _ROFstROFstImages == null))
_ROFstROFstImages = ROFstImageInfoList.GetByROFstID(_ROFstID);
if (_ROFstROFstImageCount < 0)
_ROFstROFstImageCount = _ROFstROFstImages.Count;
return _ROFstROFstImages;
}
}
public void RefreshROFstROFstImages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ROFstID.ToString()))
foreach (ROFstInfo tmp in _CacheByPrimaryKey[_ROFstID.ToString()])
tmp._ROFstROFstImageCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ROFstInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ROFstInfo.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 ROFstInfo</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
#endregion
#region Factory Methods
private static int _ROFstInfoUnique = 0;
private static int ROFstInfoUnique
{ get { return ++_ROFstInfoUnique; } }
private int _MyROFstInfoUnique = ROFstInfoUnique;
public int MyROFstInfoUnique
{ get { return _MyROFstInfoUnique; } }
protected ROFstInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ROFstID.ToString())) return;
List<ROFstInfo> listROFstInfo = _CacheByPrimaryKey[ROFstID.ToString()]; // Get the list of items
while (listROFstInfo.Contains(this)) listROFstInfo.Remove(this); // Remove the item from the list
if (listROFstInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ROFstID.ToString()); // remove the list
}
public virtual ROFst Get()
{
return _Editable = ROFst.Get(_ROFstID);
}
public static void Refresh(ROFst tmp)
{
string key = tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFst tmp)
{
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for new value
_ROFST = tmp.ROFST;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstInfoExtension.Refresh(this);
if (_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbROFst tmp)
{
string key = tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbROFst tmp)
{
_ROFST = tmp.ROFST;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstInfoExtension.Refresh(this);
if (_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static ROFstInfo Get(int rOFstID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFstInfo tmp = GetCachedByPrimaryKey(rOFstID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROFstInfo>(new PKCriteria(rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFstInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROFstInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfo.Constructor", ex);
throw new DbCslaException("ROFstInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.ReadData", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_RODbID = dr.GetInt32("RODbID");
_ROFST = (byte[])dr.GetValue("ROFST");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ROFstDocVersionROFstCount = dr.GetInt32("DocVersionROFstCount");
_ROFstROFstImageCount = dr.GetInt32("ROFstImageCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.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 = "getROFst";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
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("ROFstInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROFstInfoExtension _ROFstInfoExtension = new ROFstInfoExtension();
[Serializable()]
partial class ROFstInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ROFstInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ROFstInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstInfo)
{
// Return the ToString value
return ((ROFstInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,385 +19,374 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ROFstROFstImage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstROFstImageConverter))]
public partial class ROFstROFstImage : BusinessBase<ROFstROFstImage>, 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 _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ImageID", true);
if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
return _ImageID;
}
}
private ROImage _MyROImage;
[System.ComponentModel.DataObjectField(true, true)]
public ROImage MyROImage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROImage", true);
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
return _MyROImage;
}
}
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 _ROImage_RODbID;
public int ROImage_RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_RODbID", true);
return _ROImage_RODbID;
}
}
private string _ROImage_FileName = string.Empty;
public string ROImage_FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_FileName", true);
return _ROImage_FileName;
}
}
private byte[] _ROImage_Content;
public byte[] ROImage_Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_Content", true);
return _ROImage_Content;
}
}
private DateTime _ROImage_DTS = new DateTime();
public DateTime ROImage_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_DTS", true);
return _ROImage_DTS;
}
}
private string _ROImage_UserID = string.Empty;
public string ROImage_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_UserID", true);
return _ROImage_UserID;
}
}
// TODO: Check ROFstROFstImage.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 ROFstROFstImage</returns>
protected override object GetIdValue()
{
return _ImageID;
}
// TODO: Replace base ROFstROFstImage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstROFstImage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ImageID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ROFstROFstImage New(ROImage myROImage)
{
return new ROFstROFstImage(myROImage);
}
internal static ROFstROFstImage Get(SafeDataReader dr)
{
return new ROFstROFstImage(dr);
}
public ROFstROFstImage()
{
MarkAsChild();
/// <summary>
/// ROFstROFstImage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstROFstImageConverter))]
public partial class ROFstROFstImage : BusinessBase<ROFstROFstImage>, 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 _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
return _ImageID;
}
}
private ROImage _MyROImage;
[System.ComponentModel.DataObjectField(true, true)]
public ROImage MyROImage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
return _MyROImage;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _ROImage_RODbID;
public int ROImage_RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROImage_RODbID;
}
}
private string _ROImage_FileName = string.Empty;
public string ROImage_FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROImage_FileName;
}
}
private byte[] _ROImage_Content;
public byte[] ROImage_Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROImage_Content;
}
}
private DateTime _ROImage_DTS = new DateTime();
public DateTime ROImage_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROImage_DTS;
}
}
private string _ROImage_UserID = string.Empty;
public string ROImage_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROImage_UserID;
}
}
// TODO: Check ROFstROFstImage.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 ROFstROFstImage</returns>
protected override object GetIdValue()
{
return _ImageID;
}
// TODO: Replace base ROFstROFstImage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstROFstImage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ImageID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ROFstROFstImage New(ROImage myROImage)
{
return new ROFstROFstImage(myROImage);
}
internal static ROFstROFstImage Get(SafeDataReader dr)
{
return new ROFstROFstImage(dr);
}
public ROFstROFstImage()
{
MarkAsChild();
_DTS = _ROFstROFstImageExtension.DefaultDTS;
_UserID = _ROFstROFstImageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROFstROFstImage(ROImage myROImage)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROFstROFstImageExtension.DefaultDTS;
_UserID = _ROFstROFstImageExtension.DefaultUserID;
_MyROImage = myROImage;
ValidationRules.CheckRules();
}
internal ROFstROFstImage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstROFstImage.FetchDR", GetHashCode());
try
{
_ImageID = dr.GetInt32("ImageID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROImage_RODbID = dr.GetInt32("ROImage_RODbID");
_ROImage_FileName = dr.GetString("ROImage_FileName");
_ROImage_Content = (byte[])dr.GetValue("ROImage_Content");
_ROImage_DTS = dr.GetDateTime("ROImage_DTS");
_ROImage_UserID = dr.GetString("ROImage_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstROFstImage.FetchDR", ex);
throw new DbCslaException("ROFstROFstImage.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFstImage.Add(cn, myROFst, _MyROImage, _DTS, _UserID);
MarkOld();
}
internal void Update(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFstImage.Update(cn, myROFst, _MyROImage, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROFst myROFst)
{
// 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"];
ROFstImage.Remove(cn, myROFst.ROFstID, _ImageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROFstROFstImageExtension _ROFstROFstImageExtension = new ROFstROFstImageExtension();
[Serializable()]
partial class ROFstROFstImageExtension : 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 ROFstROFstImageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstROFstImage)
{
// Return the ToString value
return ((ROFstROFstImage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
_DTS = _ROFstROFstImageExtension.DefaultDTS;
_UserID = _ROFstROFstImageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROFstROFstImage(ROImage myROImage)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROFstROFstImageExtension.DefaultDTS;
_UserID = _ROFstROFstImageExtension.DefaultUserID;
_MyROImage = myROImage;
ValidationRules.CheckRules();
}
internal ROFstROFstImage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstROFstImage.FetchDR", GetHashCode());
try
{
_ImageID = dr.GetInt32("ImageID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROImage_RODbID = dr.GetInt32("ROImage_RODbID");
_ROImage_FileName = dr.GetString("ROImage_FileName");
_ROImage_Content = (byte[])dr.GetValue("ROImage_Content");
_ROImage_DTS = dr.GetDateTime("ROImage_DTS");
_ROImage_UserID = dr.GetString("ROImage_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstROFstImage.FetchDR", ex);
throw new DbCslaException("ROFstROFstImage.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFstImage.Add(cn, myROFst, _MyROImage, _DTS, _UserID);
MarkOld();
}
internal void Update(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFstImage.Update(cn, myROFst, _MyROImage, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROFst myROFst)
{
// 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"];
ROFstImage.Remove(cn, myROFst.ROFstID, _ImageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROFstROFstImageExtension _ROFstROFstImageExtension = new ROFstROFstImageExtension();
[Serializable()]
partial class ROFstROFstImageExtension : 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 ROFstROFstImageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstROFstImage)
{
// Return the ToString value
return ((ROFstROFstImage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,410 +19,401 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ROImageInfoEvent(object sender);
/// <summary>
/// ROImageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROImageInfoConverter))]
public partial class ROImageInfo : ReadOnlyBase<ROImageInfo>, IDisposable
{
public event ROImageInfoEvent 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<ROImageInfo> _CacheList = new List<ROImageInfo>();
protected static void AddToCache(ROImageInfo rOImageInfo)
{
if (!_CacheList.Contains(rOImageInfo)) _CacheList.Add(rOImageInfo); // In AddToCache
}
protected static void RemoveFromCache(ROImageInfo rOImageInfo)
{
while (_CacheList.Contains(rOImageInfo)) _CacheList.Remove(rOImageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ROImageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROImageInfo>>();
private static void ConvertListToDictionary()
{
List<ROImageInfo> remove = new List<ROImageInfo>();
foreach (ROImageInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ImageID.ToString()))
{
_CacheByPrimaryKey[tmp.ImageID.ToString()] = new List<ROImageInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ImageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ROImageInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ROImageInfoList lst)
{
foreach (ROImageInfo item in lst) AddToCache(item);
}
protected static ROImageInfo GetCachedByPrimaryKey(int imageID)
{
ConvertListToDictionary();
string key = imageID.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 ROImage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ImageID", true);
return _ImageID;
}
}
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
private string _FileName = string.Empty;
public string FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FileName", true);
return _FileName;
}
}
private byte[] _Content;
public byte[] Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content", true);
return _Content;
}
}
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 _ROImageROFstImageCount = 0;
/// <summary>
/// Count of ROImageROFstImages for this ROImage
/// </summary>
public int ROImageROFstImageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImageROFstImageCount", true);
return _ROImageROFstImageCount;
}
}
private ROFstImageInfoList _ROImageROFstImages = null;
[TypeConverter(typeof(ROFstImageInfoListConverter))]
public ROFstImageInfoList ROImageROFstImages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImageROFstImages", true);
if (_ROImageROFstImageCount < 0 || (_ROImageROFstImageCount > 0 && _ROImageROFstImages == null))
_ROImageROFstImages = ROFstImageInfoList.GetByImageID(_ImageID);
if (_ROImageROFstImageCount < 0)
_ROImageROFstImageCount = _ROImageROFstImages.Count;
return _ROImageROFstImages;
}
}
public void RefreshROImageROFstImages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ImageID.ToString()))
foreach (ROImageInfo tmp in _CacheByPrimaryKey[_ImageID.ToString()])
tmp._ROImageROFstImageCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ROImageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROImageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ROImageInfo.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 ROImageInfo</returns>
protected override object GetIdValue()
{
return _ImageID;
}
#endregion
#region Factory Methods
private static int _ROImageInfoUnique = 0;
private static int ROImageInfoUnique
{ get { return ++_ROImageInfoUnique; } }
private int _MyROImageInfoUnique = ROImageInfoUnique;
public int MyROImageInfoUnique
{ get { return _MyROImageInfoUnique; } }
protected ROImageInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ImageID.ToString())) return;
List<ROImageInfo> listROImageInfo = _CacheByPrimaryKey[ImageID.ToString()]; // Get the list of items
while (listROImageInfo.Contains(this)) listROImageInfo.Remove(this); // Remove the item from the list
if (listROImageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ImageID.ToString()); // remove the list
}
public virtual ROImage Get()
{
return _Editable = ROImage.Get(_ImageID);
}
public static void Refresh(ROImage tmp)
{
string key = tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROImage tmp)
{
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbROImages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbROImages(); // Update List for new value
_FileName = tmp.FileName;
_Content = tmp.Content;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROImageInfoExtension.Refresh(this);
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbROImage tmp)
{
string key = tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbROImage tmp)
{
_FileName = tmp.FileName;
_Content = tmp.Content;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROImageInfoExtension.Refresh(this);
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static ROImageInfo Get(int imageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROImage");
try
{
ROImageInfo tmp = GetCachedByPrimaryKey(imageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROImageInfo>(new PKCriteria(imageID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROImageInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROImageInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROImageInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfo.Constructor", ex);
throw new DbCslaException("ROImageInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ImageID;
public int ImageID
{ get { return _ImageID; } }
public PKCriteria(int imageID)
{
_ImageID = imageID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.ReadData", GetHashCode());
try
{
_ImageID = dr.GetInt32("ImageID");
_RODbID = dr.GetInt32("RODbID");
_FileName = dr.GetString("FileName");
_Content = (byte[])dr.GetValue("Content");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ROImageROFstImageCount = dr.GetInt32("ROFstImageCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROImageInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.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 = "getROImage";
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
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("ROImageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROImageInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROImageInfoExtension _ROImageInfoExtension = new ROImageInfoExtension();
[Serializable()]
partial class ROImageInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ROImageInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ROImageInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROImageInfo)
{
// Return the ToString value
return ((ROImageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void ROImageInfoEvent(object sender);
/// <summary>
/// ROImageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROImageInfoConverter))]
public partial class ROImageInfo : ReadOnlyBase<ROImageInfo>, IDisposable
{
public event ROImageInfoEvent 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<ROImageInfo> _CacheList = new List<ROImageInfo>();
protected static void AddToCache(ROImageInfo rOImageInfo)
{
if (!_CacheList.Contains(rOImageInfo)) _CacheList.Add(rOImageInfo); // In AddToCache
}
protected static void RemoveFromCache(ROImageInfo rOImageInfo)
{
while (_CacheList.Contains(rOImageInfo)) _CacheList.Remove(rOImageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ROImageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROImageInfo>>();
private static void ConvertListToDictionary()
{
List<ROImageInfo> remove = new List<ROImageInfo>();
foreach (ROImageInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ImageID.ToString()))
{
_CacheByPrimaryKey[tmp.ImageID.ToString()] = new List<ROImageInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ImageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ROImageInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ROImageInfoList lst)
{
foreach (ROImageInfo item in lst) AddToCache(item);
}
protected static ROImageInfo GetCachedByPrimaryKey(int imageID)
{
ConvertListToDictionary();
string key = imageID.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 ROImage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ImageID;
}
}
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
private string _FileName = string.Empty;
public string FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _FileName;
}
}
private byte[] _Content;
public byte[] Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Content;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
private int _ROImageROFstImageCount = 0;
/// <summary>
/// Count of ROImageROFstImages for this ROImage
/// </summary>
public int ROImageROFstImageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROImageROFstImageCount;
}
}
private ROFstImageInfoList _ROImageROFstImages = null;
[TypeConverter(typeof(ROFstImageInfoListConverter))]
public ROFstImageInfoList ROImageROFstImages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_ROImageROFstImageCount < 0 || (_ROImageROFstImageCount > 0 && _ROImageROFstImages == null))
_ROImageROFstImages = ROFstImageInfoList.GetByImageID(_ImageID);
if (_ROImageROFstImageCount < 0)
_ROImageROFstImageCount = _ROImageROFstImages.Count;
return _ROImageROFstImages;
}
}
public void RefreshROImageROFstImages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ImageID.ToString()))
foreach (ROImageInfo tmp in _CacheByPrimaryKey[_ImageID.ToString()])
tmp._ROImageROFstImageCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ROImageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROImageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ROImageInfo.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 ROImageInfo</returns>
protected override object GetIdValue()
{
return _ImageID;
}
#endregion
#region Factory Methods
private static int _ROImageInfoUnique = 0;
private static int ROImageInfoUnique
{ get { return ++_ROImageInfoUnique; } }
private int _MyROImageInfoUnique = ROImageInfoUnique;
public int MyROImageInfoUnique
{ get { return _MyROImageInfoUnique; } }
protected ROImageInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ImageID.ToString())) return;
List<ROImageInfo> listROImageInfo = _CacheByPrimaryKey[ImageID.ToString()]; // Get the list of items
while (listROImageInfo.Contains(this)) listROImageInfo.Remove(this); // Remove the item from the list
if (listROImageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ImageID.ToString()); // remove the list
}
public virtual ROImage Get()
{
return _Editable = ROImage.Get(_ImageID);
}
public static void Refresh(ROImage tmp)
{
string key = tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROImage tmp)
{
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbROImages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbROImages(); // Update List for new value
_FileName = tmp.FileName;
_Content = tmp.Content;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROImageInfoExtension.Refresh(this);
if (_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbROImage tmp)
{
string key = tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbROImage tmp)
{
_FileName = tmp.FileName;
_Content = tmp.Content;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROImageInfoExtension.Refresh(this);
if (_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static ROImageInfo Get(int imageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROImage");
try
{
ROImageInfo tmp = GetCachedByPrimaryKey(imageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROImageInfo>(new PKCriteria(imageID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROImageInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROImageInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROImageInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfo.Constructor", ex);
throw new DbCslaException("ROImageInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ImageID;
public int ImageID
{ get { return _ImageID; } }
public PKCriteria(int imageID)
{
_ImageID = imageID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.ReadData", GetHashCode());
try
{
_ImageID = dr.GetInt32("ImageID");
_RODbID = dr.GetInt32("RODbID");
_FileName = dr.GetString("FileName");
_Content = (byte[])dr.GetValue("Content");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ROImageROFstImageCount = dr.GetInt32("ROFstImageCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROImageInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.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 = "getROImage";
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
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("ROImageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROImageInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROImageInfoExtension _ROImageInfoExtension = new ROImageInfoExtension();
[Serializable()]
partial class ROImageInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ROImageInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ROImageInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROImageInfo)
{
// Return the ToString value
return ((ROImageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -19,374 +19,364 @@ using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ROImageROFstImage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROImageROFstImageConverter))]
public partial class ROImageROFstImage : BusinessBase<ROImageROFstImage>, 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 _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFst _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFst MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROFst", true);
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFst.Get(_ROFstID);
return _MyROFst;
}
}
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 _ROFst_RODbID;
public int ROFst_RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_RODbID", true);
return _ROFst_RODbID;
}
}
private byte[] _ROFst_ROFST;
public byte[] ROFst_ROFST
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_ROFST", true);
return _ROFst_ROFST;
}
}
private DateTime _ROFst_DTS = new DateTime();
public DateTime ROFst_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_DTS", true);
return _ROFst_DTS;
}
}
private string _ROFst_UserID = string.Empty;
public string ROFst_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_UserID", true);
return _ROFst_UserID;
}
}
// TODO: Check ROImageROFstImage.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 ROImageROFstImage</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
// TODO: Replace base ROImageROFstImage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROImageROFstImage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROFstID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ROImageROFstImage New(ROFst myROFst)
{
return new ROImageROFstImage(myROFst);
}
internal static ROImageROFstImage Get(SafeDataReader dr)
{
return new ROImageROFstImage(dr);
}
public ROImageROFstImage()
{
MarkAsChild();
/// <summary>
/// ROImageROFstImage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROImageROFstImageConverter))]
public partial class ROImageROFstImage : BusinessBase<ROImageROFstImage>, 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 _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFst _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFst MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFst.Get(_ROFstID);
return _MyROFst;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _ROFst_RODbID;
public int ROFst_RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFst_RODbID;
}
}
private byte[] _ROFst_ROFST;
public byte[] ROFst_ROFST
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFst_ROFST;
}
}
private DateTime _ROFst_DTS = new DateTime();
public DateTime ROFst_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFst_DTS;
}
}
private string _ROFst_UserID = string.Empty;
public string ROFst_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROFst_UserID;
}
}
// TODO: Check ROImageROFstImage.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 ROImageROFstImage</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
// TODO: Replace base ROImageROFstImage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROImageROFstImage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#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;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROFstID, "<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()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: 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()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ROImageROFstImage New(ROFst myROFst)
{
return new ROImageROFstImage(myROFst);
}
internal static ROImageROFstImage Get(SafeDataReader dr)
{
return new ROImageROFstImage(dr);
}
public ROImageROFstImage()
{
MarkAsChild();
_DTS = _ROImageROFstImageExtension.DefaultDTS;
_UserID = _ROImageROFstImageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROImageROFstImage(ROFst myROFst)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROImageROFstImageExtension.DefaultDTS;
_UserID = _ROImageROFstImageExtension.DefaultUserID;
_MyROFst = myROFst;
ValidationRules.CheckRules();
}
internal ROImageROFstImage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageROFstImage.FetchDR", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROFst_RODbID = dr.GetInt32("ROFst_RODbID");
_ROFst_ROFST = (byte[])dr.GetValue("ROFst_ROFST");
_ROFst_DTS = dr.GetDateTime("ROFst_DTS");
_ROFst_UserID = dr.GetString("ROFst_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageROFstImage.FetchDR", ex);
throw new DbCslaException("ROImageROFstImage.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROImage myROImage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFstImage.Add(cn, _MyROFst, myROImage, _DTS, _UserID);
MarkOld();
}
internal void Update(ROImage myROImage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFstImage.Update(cn, _MyROFst, myROImage, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROImage myROImage)
{
// 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"];
ROFstImage.Remove(cn, _ROFstID, myROImage.ImageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROImageROFstImageExtension _ROImageROFstImageExtension = new ROImageROFstImageExtension();
[Serializable()]
partial class ROImageROFstImageExtension : 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 ROImageROFstImageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROImageROFstImage)
{
// Return the ToString value
return ((ROImageROFstImage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
_DTS = _ROImageROFstImageExtension.DefaultDTS;
_UserID = _ROImageROFstImageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROImageROFstImage(ROFst myROFst)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROImageROFstImageExtension.DefaultDTS;
_UserID = _ROImageROFstImageExtension.DefaultUserID;
_MyROFst = myROFst;
ValidationRules.CheckRules();
}
internal ROImageROFstImage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageROFstImage.FetchDR", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROFst_RODbID = dr.GetInt32("ROFst_RODbID");
_ROFst_ROFST = (byte[])dr.GetValue("ROFst_ROFST");
_ROFst_DTS = dr.GetDateTime("ROFst_DTS");
_ROFst_UserID = dr.GetString("ROFst_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageROFstImage.FetchDR", ex);
throw new DbCslaException("ROImageROFstImage.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROImage myROImage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFstImage.Add(cn, _MyROFst, myROImage, _DTS, _UserID);
MarkOld();
}
internal void Update(ROImage myROImage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFstImage.Update(cn, _MyROFst, myROImage, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROImage myROImage)
{
// 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"];
ROFstImage.Remove(cn, _ROFstID, myROImage.ImageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROImageROFstImageExtension _ROImageROFstImageExtension = new ROImageROFstImageExtension();
[Serializable()]
partial class ROImageROFstImageExtension : 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 ROImageROFstImageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROImageROFstImage)
{
// Return the ToString value
return ((ROImageROFstImage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,455 +19,446 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void RoUsageInfoEvent(object sender);
/// <summary>
/// RoUsageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RoUsageInfoConverter))]
public partial class RoUsageInfo : ReadOnlyBase<RoUsageInfo>, IDisposable
{
public event RoUsageInfoEvent 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<RoUsageInfo> _CacheList = new List<RoUsageInfo>();
protected static void AddToCache(RoUsageInfo roUsageInfo)
{
if (!_CacheList.Contains(roUsageInfo)) _CacheList.Add(roUsageInfo); // In AddToCache
}
protected static void RemoveFromCache(RoUsageInfo roUsageInfo)
{
while (_CacheList.Contains(roUsageInfo)) _CacheList.Remove(roUsageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RoUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RoUsageInfo>>();
private static void ConvertListToDictionary()
{
List<RoUsageInfo> remove = new List<RoUsageInfo>();
foreach (RoUsageInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
{
_CacheByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsageInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RoUsageInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(RoUsageInfoList lst)
{
foreach (RoUsageInfo item in lst) AddToCache(item);
}
protected static RoUsageInfo GetCachedByPrimaryKey(int rOUsageID)
{
ConvertListToDictionary();
string key = rOUsageID.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 RoUsage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ROUsageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROUsageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROUsageID", true);
return _ROUsageID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROID", true);
return _ROID;
}
}
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 _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
// TODO: Replace base RoUsageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoUsageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RoUsageInfo.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 RoUsageInfo</returns>
protected override object GetIdValue()
{
return _ROUsageID;
}
#endregion
#region Factory Methods
private static int _RoUsageInfoUnique = 0;
private static int RoUsageInfoUnique
{ get { return ++_RoUsageInfoUnique; } }
private int _MyRoUsageInfoUnique = RoUsageInfoUnique;
public int MyRoUsageInfoUnique
{ get { return _MyRoUsageInfoUnique; } }
protected RoUsageInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ROUsageID.ToString())) return;
List<RoUsageInfo> listRoUsageInfo = _CacheByPrimaryKey[ROUsageID.ToString()]; // Get the list of items
while (listRoUsageInfo.Contains(this)) listRoUsageInfo.Remove(this); // Remove the item from the list
if (listRoUsageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
}
public virtual RoUsage Get()
{
return _Editable = RoUsage.Get(_ROUsageID);
}
public static void Refresh(RoUsage tmp)
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RoUsage tmp)
{
if (_ContentID != tmp.ContentID)
{
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for new value
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for new value
_RoUsageInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ContentRoUsage tmp)
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentRoUsage tmp)
{
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for new value
_RoUsageInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbRoUsage tmp)
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbRoUsage tmp)
{
if (_ContentID != tmp.ContentID)
{
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for new value
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_RoUsageInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static RoUsageInfo Get(int rOUsageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a RoUsage");
try
{
RoUsageInfo tmp = GetCachedByPrimaryKey(rOUsageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RoUsageInfo>(new PKCriteria(rOUsageID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RoUsageInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RoUsageInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RoUsageInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.Constructor", ex);
throw new DbCslaException("RoUsageInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ROUsageID;
public int ROUsageID
{ get { return _ROUsageID; } }
public PKCriteria(int rOUsageID)
{
_ROUsageID = rOUsageID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.ReadData", GetHashCode());
try
{
_ROUsageID = dr.GetInt32("ROUsageID");
_ContentID = dr.GetInt32("ContentID");
_ROID = dr.GetString("ROID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_RODbID = dr.GetInt32("RODbID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RoUsageInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.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 = "getRoUsage";
cm.Parameters.AddWithValue("@ROUsageID", criteria.ROUsageID);
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("RoUsageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RoUsageInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RoUsageInfoExtension _RoUsageInfoExtension = new RoUsageInfoExtension();
[Serializable()]
partial class RoUsageInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RoUsageInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RoUsageInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RoUsageInfo)
{
// Return the ToString value
return ((RoUsageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void RoUsageInfoEvent(object sender);
/// <summary>
/// RoUsageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RoUsageInfoConverter))]
public partial class RoUsageInfo : ReadOnlyBase<RoUsageInfo>, IDisposable
{
public event RoUsageInfoEvent 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<RoUsageInfo> _CacheList = new List<RoUsageInfo>();
protected static void AddToCache(RoUsageInfo roUsageInfo)
{
if (!_CacheList.Contains(roUsageInfo)) _CacheList.Add(roUsageInfo); // In AddToCache
}
protected static void RemoveFromCache(RoUsageInfo roUsageInfo)
{
while (_CacheList.Contains(roUsageInfo)) _CacheList.Remove(roUsageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RoUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RoUsageInfo>>();
private static void ConvertListToDictionary()
{
List<RoUsageInfo> remove = new List<RoUsageInfo>();
foreach (RoUsageInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROUsageID.ToString()))
{
_CacheByPrimaryKey[tmp.ROUsageID.ToString()] = new List<RoUsageInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ROUsageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RoUsageInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(RoUsageInfoList lst)
{
foreach (RoUsageInfo item in lst) AddToCache(item);
}
protected static RoUsageInfo GetCachedByPrimaryKey(int rOUsageID)
{
ConvertListToDictionary();
string key = rOUsageID.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 RoUsage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ROUsageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROUsageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROUsageID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _ROID;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
// TODO: Replace base RoUsageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoUsageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RoUsageInfo.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 RoUsageInfo</returns>
protected override object GetIdValue()
{
return _ROUsageID;
}
#endregion
#region Factory Methods
private static int _RoUsageInfoUnique = 0;
private static int RoUsageInfoUnique
{ get { return ++_RoUsageInfoUnique; } }
private int _MyRoUsageInfoUnique = RoUsageInfoUnique;
public int MyRoUsageInfoUnique
{ get { return _MyRoUsageInfoUnique; } }
protected RoUsageInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ROUsageID.ToString())) return;
List<RoUsageInfo> listRoUsageInfo = _CacheByPrimaryKey[ROUsageID.ToString()]; // Get the list of items
while (listRoUsageInfo.Contains(this)) listRoUsageInfo.Remove(this); // Remove the item from the list
if (listRoUsageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ROUsageID.ToString()); // remove the list
}
public virtual RoUsage Get()
{
return _Editable = RoUsage.Get(_ROUsageID);
}
public static void Refresh(RoUsage tmp)
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RoUsage tmp)
{
if (_ContentID != tmp.ContentID)
{
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for new value
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for new value
_RoUsageInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if (_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ContentRoUsage tmp)
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentRoUsage tmp)
{
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for new value
_RoUsageInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if (_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbRoUsage tmp)
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbRoUsage tmp)
{
if (_ContentID != tmp.ContentID)
{
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for new value
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_RoUsageInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if (_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static RoUsageInfo Get(int rOUsageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a RoUsage");
try
{
RoUsageInfo tmp = GetCachedByPrimaryKey(rOUsageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RoUsageInfo>(new PKCriteria(rOUsageID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RoUsageInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RoUsageInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RoUsageInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.Constructor", ex);
throw new DbCslaException("RoUsageInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ROUsageID;
public int ROUsageID
{ get { return _ROUsageID; } }
public PKCriteria(int rOUsageID)
{
_ROUsageID = rOUsageID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.ReadData", GetHashCode());
try
{
_ROUsageID = dr.GetInt32("ROUsageID");
_ContentID = dr.GetInt32("ContentID");
_ROID = dr.GetString("ROID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_RODbID = dr.GetInt32("RODbID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoUsageInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RoUsageInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfo.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 = "getRoUsage";
cm.Parameters.AddWithValue("@ROUsageID", criteria.ROUsageID);
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("RoUsageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RoUsageInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RoUsageInfoExtension _RoUsageInfoExtension = new RoUsageInfoExtension();
[Serializable()]
partial class RoUsageInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RoUsageInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RoUsageInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RoUsageInfo)
{
// Return the ToString value
return ((RoUsageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,389 +19,380 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void RoleInfoEvent(object sender);
/// <summary>
/// RoleInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RoleInfoConverter))]
public partial class RoleInfo : ReadOnlyBase<RoleInfo>, IDisposable
{
public event RoleInfoEvent 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<RoleInfo> _CacheList = new List<RoleInfo>();
protected static void AddToCache(RoleInfo roleInfo)
{
if (!_CacheList.Contains(roleInfo)) _CacheList.Add(roleInfo); // In AddToCache
}
protected static void RemoveFromCache(RoleInfo roleInfo)
{
while (_CacheList.Contains(roleInfo)) _CacheList.Remove(roleInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RoleInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RoleInfo>>();
private static void ConvertListToDictionary()
{
List<RoleInfo> remove = new List<RoleInfo>();
foreach (RoleInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.RID.ToString()))
{
_CacheByPrimaryKey[tmp.RID.ToString()] = new List<RoleInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RoleInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(RoleInfoList lst)
{
foreach (RoleInfo item in lst) AddToCache(item);
}
protected static RoleInfo GetCachedByPrimaryKey(int rid)
{
ConvertListToDictionary();
string key = rid.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 Role _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _RID;
[System.ComponentModel.DataObjectField(true, true)]
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RID", true);
return _RID;
}
}
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 _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title", true);
return _Title;
}
}
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 _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID", true);
return _UsrID;
}
}
private int _RoleAssignmentCount = 0;
/// <summary>
/// Count of RoleAssignments for this Role
/// </summary>
public int RoleAssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RoleAssignmentCount", true);
return _RoleAssignmentCount;
}
}
private AssignmentInfoList _RoleAssignments = null;
[TypeConverter(typeof(AssignmentInfoListConverter))]
public AssignmentInfoList RoleAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RoleAssignments", true);
if (_RoleAssignmentCount < 0 || (_RoleAssignmentCount > 0 && _RoleAssignments == null))
_RoleAssignments = AssignmentInfoList.GetByRID(_RID);
if (_RoleAssignmentCount < 0)
_RoleAssignmentCount = _RoleAssignments.Count;
return _RoleAssignments;
}
}
public void RefreshRoleAssignments()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RID.ToString()))
foreach (RoleInfo tmp in _CacheByPrimaryKey[_RID.ToString()])
tmp._RoleAssignmentCount = -1; // This will cause the data to be requeried
}
private int _RolePermissionCount = 0;
/// <summary>
/// Count of RolePermissions for this Role
/// </summary>
public int RolePermissionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RolePermissionCount", true);
return _RolePermissionCount;
}
}
private PermissionInfoList _RolePermissions = null;
[TypeConverter(typeof(PermissionInfoListConverter))]
public PermissionInfoList RolePermissions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RolePermissions", true);
if (_RolePermissionCount < 0 || (_RolePermissionCount > 0 && _RolePermissions == null))
_RolePermissions = PermissionInfoList.GetByRID(_RID);
if (_RolePermissionCount < 0)
_RolePermissionCount = _RolePermissions.Count;
return _RolePermissions;
}
}
public void RefreshRolePermissions()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RID.ToString()))
foreach (RoleInfo tmp in _CacheByPrimaryKey[_RID.ToString()])
tmp._RolePermissionCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base RoleInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoleInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RoleInfo.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 RoleInfo</returns>
protected override object GetIdValue()
{
return _RID;
}
#endregion
#region Factory Methods
private static int _RoleInfoUnique = 0;
private static int RoleInfoUnique
{ get { return ++_RoleInfoUnique; } }
private int _MyRoleInfoUnique = RoleInfoUnique;
public int MyRoleInfoUnique
{ get { return _MyRoleInfoUnique; } }
protected RoleInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(RID.ToString())) return;
List<RoleInfo> listRoleInfo = _CacheByPrimaryKey[RID.ToString()]; // Get the list of items
while (listRoleInfo.Contains(this)) listRoleInfo.Remove(this); // Remove the item from the list
if (listRoleInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(RID.ToString()); // remove the list
}
public virtual Role Get()
{
return _Editable = Role.Get(_RID);
}
public static void Refresh(Role tmp)
{
string key = tmp.RID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoleInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Role tmp)
{
_Name = tmp.Name;
_Title = tmp.Title;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_RoleInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static RoleInfo Get(int rid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Role");
try
{
RoleInfo tmp = GetCachedByPrimaryKey(rid);
if (tmp == null)
{
tmp = DataPortal.Fetch<RoleInfo>(new PKCriteria(rid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RoleInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RoleInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RoleInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleInfo.Constructor", ex);
throw new DbCslaException("RoleInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _RID;
public int RID
{ get { return _RID; } }
public PKCriteria(int rid)
{
_RID = rid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.ReadData", GetHashCode());
try
{
_RID = dr.GetInt32("RID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_RoleAssignmentCount = dr.GetInt32("AssignmentCount");
_RolePermissionCount = dr.GetInt32("PermissionCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RoleInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.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 = "getRole";
cm.Parameters.AddWithValue("@RID", criteria.RID);
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("RoleInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RoleInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RoleInfoExtension _RoleInfoExtension = new RoleInfoExtension();
[Serializable()]
partial class RoleInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RoleInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RoleInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RoleInfo)
{
// Return the ToString value
return ((RoleInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void RoleInfoEvent(object sender);
/// <summary>
/// RoleInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RoleInfoConverter))]
public partial class RoleInfo : ReadOnlyBase<RoleInfo>, IDisposable
{
public event RoleInfoEvent 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<RoleInfo> _CacheList = new List<RoleInfo>();
protected static void AddToCache(RoleInfo roleInfo)
{
if (!_CacheList.Contains(roleInfo)) _CacheList.Add(roleInfo); // In AddToCache
}
protected static void RemoveFromCache(RoleInfo roleInfo)
{
while (_CacheList.Contains(roleInfo)) _CacheList.Remove(roleInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RoleInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RoleInfo>>();
private static void ConvertListToDictionary()
{
List<RoleInfo> remove = new List<RoleInfo>();
foreach (RoleInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.RID.ToString()))
{
_CacheByPrimaryKey[tmp.RID.ToString()] = new List<RoleInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (RoleInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(RoleInfoList lst)
{
foreach (RoleInfo item in lst) AddToCache(item);
}
protected static RoleInfo GetCachedByPrimaryKey(int rid)
{
ConvertListToDictionary();
string key = rid.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 Role _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _RID;
[System.ComponentModel.DataObjectField(true, true)]
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Name;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Title;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UsrID;
}
}
private int _RoleAssignmentCount = 0;
/// <summary>
/// Count of RoleAssignments for this Role
/// </summary>
public int RoleAssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RoleAssignmentCount;
}
}
private AssignmentInfoList _RoleAssignments = null;
[TypeConverter(typeof(AssignmentInfoListConverter))]
public AssignmentInfoList RoleAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_RoleAssignmentCount < 0 || (_RoleAssignmentCount > 0 && _RoleAssignments == null))
_RoleAssignments = AssignmentInfoList.GetByRID(_RID);
if (_RoleAssignmentCount < 0)
_RoleAssignmentCount = _RoleAssignments.Count;
return _RoleAssignments;
}
}
public void RefreshRoleAssignments()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RID.ToString()))
foreach (RoleInfo tmp in _CacheByPrimaryKey[_RID.ToString()])
tmp._RoleAssignmentCount = -1; // This will cause the data to be requeried
}
private int _RolePermissionCount = 0;
/// <summary>
/// Count of RolePermissions for this Role
/// </summary>
public int RolePermissionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _RolePermissionCount;
}
}
private PermissionInfoList _RolePermissions = null;
[TypeConverter(typeof(PermissionInfoListConverter))]
public PermissionInfoList RolePermissions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_RolePermissionCount < 0 || (_RolePermissionCount > 0 && _RolePermissions == null))
_RolePermissions = PermissionInfoList.GetByRID(_RID);
if (_RolePermissionCount < 0)
_RolePermissionCount = _RolePermissions.Count;
return _RolePermissions;
}
}
public void RefreshRolePermissions()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_RID.ToString()))
foreach (RoleInfo tmp in _CacheByPrimaryKey[_RID.ToString()])
tmp._RolePermissionCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base RoleInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoleInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RoleInfo.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 RoleInfo</returns>
protected override object GetIdValue()
{
return _RID;
}
#endregion
#region Factory Methods
private static int _RoleInfoUnique = 0;
private static int RoleInfoUnique
{ get { return ++_RoleInfoUnique; } }
private int _MyRoleInfoUnique = RoleInfoUnique;
public int MyRoleInfoUnique
{ get { return _MyRoleInfoUnique; } }
protected RoleInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(RID.ToString())) return;
List<RoleInfo> listRoleInfo = _CacheByPrimaryKey[RID.ToString()]; // Get the list of items
while (listRoleInfo.Contains(this)) listRoleInfo.Remove(this); // Remove the item from the list
if (listRoleInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(RID.ToString()); // remove the list
}
public virtual Role Get()
{
return _Editable = Role.Get(_RID);
}
public static void Refresh(Role tmp)
{
string key = tmp.RID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoleInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Role tmp)
{
_Name = tmp.Name;
_Title = tmp.Title;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_RoleInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static RoleInfo Get(int rid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Role");
try
{
RoleInfo tmp = GetCachedByPrimaryKey(rid);
if (tmp == null)
{
tmp = DataPortal.Fetch<RoleInfo>(new PKCriteria(rid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RoleInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RoleInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RoleInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleInfo.Constructor", ex);
throw new DbCslaException("RoleInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _RID;
public int RID
{ get { return _RID; } }
public PKCriteria(int rid)
{
_RID = rid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.ReadData", GetHashCode());
try
{
_RID = dr.GetInt32("RID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_RoleAssignmentCount = dr.GetInt32("AssignmentCount");
_RolePermissionCount = dr.GetInt32("PermissionCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RoleInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RoleInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoleInfo.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 = "getRole";
cm.Parameters.AddWithValue("@RID", criteria.RID);
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("RoleInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RoleInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RoleInfoExtension _RoleInfoExtension = new RoleInfoExtension();
[Serializable()]
partial class RoleInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RoleInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RoleInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RoleInfo)
{
// Return the ToString value
return ((RoleInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,461 +19,445 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void UserInfoEvent(object sender);
/// <summary>
/// UserInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(UserInfoConverter))]
public partial class UserInfo : ReadOnlyBase<UserInfo>, IDisposable
{
public event UserInfoEvent 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<UserInfo> _CacheList = new List<UserInfo>();
protected static void AddToCache(UserInfo userInfo)
{
if (!_CacheList.Contains(userInfo)) _CacheList.Add(userInfo); // In AddToCache
}
protected static void RemoveFromCache(UserInfo userInfo)
{
while (_CacheList.Contains(userInfo)) _CacheList.Remove(userInfo); // In RemoveFromCache
}
private static Dictionary<string, List<UserInfo>> _CacheByPrimaryKey = new Dictionary<string, List<UserInfo>>();
private static void ConvertListToDictionary()
{
List<UserInfo> remove = new List<UserInfo>();
foreach (UserInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.UID.ToString()))
{
_CacheByPrimaryKey[tmp.UID.ToString()] = new List<UserInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.UID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (UserInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(UserInfoList lst)
{
foreach (UserInfo item in lst) AddToCache(item);
}
protected static UserInfo GetCachedByPrimaryKey(int uid)
{
ConvertListToDictionary();
string key = uid.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 User _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _UID;
[System.ComponentModel.DataObjectField(true, true)]
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UID", true);
return _UID;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private string _FirstName = string.Empty;
public string FirstName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FirstName", true);
return _FirstName;
}
}
private string _MiddleName = string.Empty;
public string MiddleName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MiddleName", true);
return _MiddleName;
}
}
private string _LastName = string.Empty;
public string LastName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("LastName", true);
return _LastName;
}
}
private string _Suffix = string.Empty;
public string Suffix
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Suffix", true);
return _Suffix;
}
}
private string _CourtesyTitle = string.Empty;
public string CourtesyTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("CourtesyTitle", true);
return _CourtesyTitle;
}
}
private string _PhoneNumber = string.Empty;
public string PhoneNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PhoneNumber", true);
return _PhoneNumber;
}
}
private string _CFGName = string.Empty;
public string CFGName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("CFGName", true);
return _CFGName;
}
}
private string _UserLogin = string.Empty;
public string UserLogin
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserLogin", true);
return _UserLogin;
}
}
private string _UserName = string.Empty;
public string UserName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserName", true);
return _UserName;
}
}
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 _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID", true);
return _UsrID;
}
}
private int _UserMembershipCount = 0;
/// <summary>
/// Count of UserMemberships for this User
/// </summary>
public int UserMembershipCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserMembershipCount", true);
return _UserMembershipCount;
}
}
private MembershipInfoList _UserMemberships = null;
[TypeConverter(typeof(MembershipInfoListConverter))]
public MembershipInfoList UserMemberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserMemberships", true);
if (_UserMembershipCount < 0 || (_UserMembershipCount > 0 && _UserMemberships == null))
_UserMemberships = MembershipInfoList.GetByUID(_UID);
if (_UserMembershipCount < 0)
_UserMembershipCount = _UserMemberships.Count;
return _UserMemberships;
}
}
public void RefreshUserMemberships()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_UID.ToString()))
foreach (UserInfo tmp in _CacheByPrimaryKey[_UID.ToString()])
tmp._UserMembershipCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base UserInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current UserInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check UserInfo.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 UserInfo</returns>
protected override object GetIdValue()
{
return _UID;
}
#endregion
#region Factory Methods
private static int _UserInfoUnique = 0;
private static int UserInfoUnique
{ get { return ++_UserInfoUnique; } }
private int _MyUserInfoUnique = UserInfoUnique;
public int MyUserInfoUnique
{ get { return _MyUserInfoUnique; } }
protected UserInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(UID.ToString())) return;
List<UserInfo> listUserInfo = _CacheByPrimaryKey[UID.ToString()]; // Get the list of items
while (listUserInfo.Contains(this)) listUserInfo.Remove(this); // Remove the item from the list
if (listUserInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(UID.ToString()); // remove the list
}
public virtual User Get()
{
return _Editable = User.Get(_UID);
}
public static void Refresh(User tmp)
{
string key = tmp.UID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (UserInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(User tmp)
{
_UserID = tmp.UserID;
_FirstName = tmp.FirstName;
_MiddleName = tmp.MiddleName;
_LastName = tmp.LastName;
_Suffix = tmp.Suffix;
_CourtesyTitle = tmp.CourtesyTitle;
_PhoneNumber = tmp.PhoneNumber;
_CFGName = tmp.CFGName;
_UserLogin = tmp.UserLogin;
_UserName = tmp.UserName;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_UserInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static UserInfo Get(int uid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a User");
try
{
UserInfo tmp = GetCachedByPrimaryKey(uid);
if (tmp == null)
{
tmp = DataPortal.Fetch<UserInfo>(new PKCriteria(uid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up UserInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on UserInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal UserInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfo.Constructor", ex);
throw new DbCslaException("UserInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _UID;
public int UID
{ get { return _UID; } }
public PKCriteria(int uid)
{
_UID = uid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.ReadData", GetHashCode());
try
{
_UID = dr.GetInt32("UID");
_UserID = dr.GetString("UserID");
_FirstName = dr.GetString("FirstName");
_MiddleName = dr.GetString("MiddleName");
_LastName = dr.GetString("LastName");
_Suffix = dr.GetString("Suffix");
_CourtesyTitle = dr.GetString("CourtesyTitle");
_PhoneNumber = dr.GetString("PhoneNumber");
_CFGName = dr.GetString("CFGName");
_UserLogin = dr.GetString("UserLogin");
_UserName = dr.GetString("UserName");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_UserMembershipCount = dr.GetInt32("MembershipCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("UserInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.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 = "getUser";
cm.Parameters.AddWithValue("@UID", criteria.UID);
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("UserInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("UserInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
UserInfoExtension _UserInfoExtension = new UserInfoExtension();
[Serializable()]
partial class UserInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(UserInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class UserInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is UserInfo)
{
// Return the ToString value
return ((UserInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void UserInfoEvent(object sender);
/// <summary>
/// UserInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(UserInfoConverter))]
public partial class UserInfo : ReadOnlyBase<UserInfo>, IDisposable
{
public event UserInfoEvent 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<UserInfo> _CacheList = new List<UserInfo>();
protected static void AddToCache(UserInfo userInfo)
{
if (!_CacheList.Contains(userInfo)) _CacheList.Add(userInfo); // In AddToCache
}
protected static void RemoveFromCache(UserInfo userInfo)
{
while (_CacheList.Contains(userInfo)) _CacheList.Remove(userInfo); // In RemoveFromCache
}
private static Dictionary<string, List<UserInfo>> _CacheByPrimaryKey = new Dictionary<string, List<UserInfo>>();
private static void ConvertListToDictionary()
{
List<UserInfo> remove = new List<UserInfo>();
foreach (UserInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.UID.ToString()))
{
_CacheByPrimaryKey[tmp.UID.ToString()] = new List<UserInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.UID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (UserInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(UserInfoList lst)
{
foreach (UserInfo item in lst) AddToCache(item);
}
protected static UserInfo GetCachedByPrimaryKey(int uid)
{
ConvertListToDictionary();
string key = uid.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 User _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _UID;
[System.ComponentModel.DataObjectField(true, true)]
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UID;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
}
private string _FirstName = string.Empty;
public string FirstName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _FirstName;
}
}
private string _MiddleName = string.Empty;
public string MiddleName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _MiddleName;
}
}
private string _LastName = string.Empty;
public string LastName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _LastName;
}
}
private string _Suffix = string.Empty;
public string Suffix
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Suffix;
}
}
private string _CourtesyTitle = string.Empty;
public string CourtesyTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _CourtesyTitle;
}
}
private string _PhoneNumber = string.Empty;
public string PhoneNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _PhoneNumber;
}
}
private string _CFGName = string.Empty;
public string CFGName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _CFGName;
}
}
private string _UserLogin = string.Empty;
public string UserLogin
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserLogin;
}
}
private string _UserName = string.Empty;
public string UserName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserName;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UsrID;
}
}
private int _UserMembershipCount = 0;
/// <summary>
/// Count of UserMemberships for this User
/// </summary>
public int UserMembershipCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserMembershipCount;
}
}
private MembershipInfoList _UserMemberships = null;
[TypeConverter(typeof(MembershipInfoListConverter))]
public MembershipInfoList UserMemberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_UserMembershipCount < 0 || (_UserMembershipCount > 0 && _UserMemberships == null))
_UserMemberships = MembershipInfoList.GetByUID(_UID);
if (_UserMembershipCount < 0)
_UserMembershipCount = _UserMemberships.Count;
return _UserMemberships;
}
}
public void RefreshUserMemberships()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_UID.ToString()))
foreach (UserInfo tmp in _CacheByPrimaryKey[_UID.ToString()])
tmp._UserMembershipCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base UserInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current UserInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check UserInfo.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 UserInfo</returns>
protected override object GetIdValue()
{
return _UID;
}
#endregion
#region Factory Methods
private static int _UserInfoUnique = 0;
private static int UserInfoUnique
{ get { return ++_UserInfoUnique; } }
private int _MyUserInfoUnique = UserInfoUnique;
public int MyUserInfoUnique
{ get { return _MyUserInfoUnique; } }
protected UserInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(UID.ToString())) return;
List<UserInfo> listUserInfo = _CacheByPrimaryKey[UID.ToString()]; // Get the list of items
while (listUserInfo.Contains(this)) listUserInfo.Remove(this); // Remove the item from the list
if (listUserInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(UID.ToString()); // remove the list
}
public virtual User Get()
{
return _Editable = User.Get(_UID);
}
public static void Refresh(User tmp)
{
string key = tmp.UID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (UserInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(User tmp)
{
_UserID = tmp.UserID;
_FirstName = tmp.FirstName;
_MiddleName = tmp.MiddleName;
_LastName = tmp.LastName;
_Suffix = tmp.Suffix;
_CourtesyTitle = tmp.CourtesyTitle;
_PhoneNumber = tmp.PhoneNumber;
_CFGName = tmp.CFGName;
_UserLogin = tmp.UserLogin;
_UserName = tmp.UserName;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_UserInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static UserInfo Get(int uid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a User");
try
{
UserInfo tmp = GetCachedByPrimaryKey(uid);
if (tmp == null)
{
tmp = DataPortal.Fetch<UserInfo>(new PKCriteria(uid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up UserInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on UserInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal UserInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfo.Constructor", ex);
throw new DbCslaException("UserInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _UID;
public int UID
{ get { return _UID; } }
public PKCriteria(int uid)
{
_UID = uid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.ReadData", GetHashCode());
try
{
_UID = dr.GetInt32("UID");
_UserID = dr.GetString("UserID");
_FirstName = dr.GetString("FirstName");
_MiddleName = dr.GetString("MiddleName");
_LastName = dr.GetString("LastName");
_Suffix = dr.GetString("Suffix");
_CourtesyTitle = dr.GetString("CourtesyTitle");
_PhoneNumber = dr.GetString("PhoneNumber");
_CFGName = dr.GetString("CFGName");
_UserLogin = dr.GetString("UserLogin");
_UserName = dr.GetString("UserName");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_UserMembershipCount = dr.GetInt32("MembershipCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("UserInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.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 = "getUser";
cm.Parameters.AddWithValue("@UID", criteria.UID);
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("UserInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("UserInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
UserInfoExtension _UserInfoExtension = new UserInfoExtension();
[Serializable()]
partial class UserInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(UserInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class UserInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is UserInfo)
{
// Return the ToString value
return ((UserInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,295 +19,292 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ZContentInfoEvent(object sender);
/// <summary>
/// ZContentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ZContentInfoConverter))]
public partial class ZContentInfo : ReadOnlyBase<ZContentInfo>, IDisposable
{
public event ZContentInfoEvent 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<ZContentInfo> _CacheList = new List<ZContentInfo>();
protected static void AddToCache(ZContentInfo zContentInfo)
{
if (!_CacheList.Contains(zContentInfo)) _CacheList.Add(zContentInfo); // In AddToCache
}
protected static void RemoveFromCache(ZContentInfo zContentInfo)
{
while (_CacheList.Contains(zContentInfo)) _CacheList.Remove(zContentInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ZContentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ZContentInfo>>();
private static void ConvertListToDictionary()
{
List<ZContentInfo> remove = new List<ZContentInfo>();
foreach (ZContentInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<ZContentInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ZContentInfo tmp in remove)
RemoveFromCache(tmp);
}
protected static ZContentInfo GetCachedByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.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 ZContent _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private string _OldStepSequence = string.Empty;
public string OldStepSequence
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("OldStepSequence", true);
return _OldStepSequence;
}
}
// TODO: Replace base ZContentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZContentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZContentInfo.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 ZContentInfo</returns>
protected override object GetIdValue()
{
return _ContentID;
}
#endregion
#region Factory Methods
private static int _ZContentInfoUnique = 0;
private static int ZContentInfoUnique
{ get { return ++_ZContentInfoUnique; } }
private int _MyZContentInfoUnique = ZContentInfoUnique;
public int MyZContentInfoUnique
{ get { return _MyZContentInfoUnique; } }
protected ZContentInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<ZContentInfo> listZContentInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
while (listZContentInfo.Contains(this)) listZContentInfo.Remove(this); // Remove the item from the list
if (listZContentInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual ZContent Get()
{
return _Editable = ZContent.Get(_ContentID);
}
public static void Refresh(ZContent tmp)
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ZContentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ZContent tmp)
{
_OldStepSequence = tmp.OldStepSequence;
_ZContentInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
OnChange();// raise an event
}
public static ZContentInfo Get(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ZContent");
try
{
ZContentInfo tmp = GetCachedByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ZContentInfo>(new PKCriteria(contentID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ZContentInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ZContentInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ZContentInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContentInfo.Constructor", ex);
throw new DbCslaException("ZContentInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
public PKCriteria(int contentID)
{
_ContentID = contentID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_OldStepSequence = dr.GetString("OldStepSequence");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContentInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ZContentInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.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 = "getZContent";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
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("ZContentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ZContentInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ZContentInfoExtension _ZContentInfoExtension = new ZContentInfoExtension();
[Serializable()]
partial class ZContentInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ZContentInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ZContentInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ZContentInfo)
{
// Return the ToString value
return ((ZContentInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void ZContentInfoEvent(object sender);
/// <summary>
/// ZContentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ZContentInfoConverter))]
public partial class ZContentInfo : ReadOnlyBase<ZContentInfo>, IDisposable
{
public event ZContentInfoEvent 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<ZContentInfo> _CacheList = new List<ZContentInfo>();
protected static void AddToCache(ZContentInfo zContentInfo)
{
if (!_CacheList.Contains(zContentInfo)) _CacheList.Add(zContentInfo); // In AddToCache
}
protected static void RemoveFromCache(ZContentInfo zContentInfo)
{
while (_CacheList.Contains(zContentInfo)) _CacheList.Remove(zContentInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ZContentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ZContentInfo>>();
private static void ConvertListToDictionary()
{
List<ZContentInfo> remove = new List<ZContentInfo>();
foreach (ZContentInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<ZContentInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ZContentInfo tmp in remove)
RemoveFromCache(tmp);
}
protected static ZContentInfo GetCachedByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.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 ZContent _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private string _OldStepSequence = string.Empty;
public string OldStepSequence
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _OldStepSequence;
}
}
// TODO: Replace base ZContentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZContentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZContentInfo.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 ZContentInfo</returns>
protected override object GetIdValue()
{
return _ContentID;
}
#endregion
#region Factory Methods
private static int _ZContentInfoUnique = 0;
private static int ZContentInfoUnique
{ get { return ++_ZContentInfoUnique; } }
private int _MyZContentInfoUnique = ZContentInfoUnique;
public int MyZContentInfoUnique
{ get { return _MyZContentInfoUnique; } }
protected ZContentInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<ZContentInfo> listZContentInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
while (listZContentInfo.Contains(this)) listZContentInfo.Remove(this); // Remove the item from the list
if (listZContentInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual ZContent Get()
{
return _Editable = ZContent.Get(_ContentID);
}
public static void Refresh(ZContent tmp)
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ZContentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ZContent tmp)
{
_OldStepSequence = tmp.OldStepSequence;
_ZContentInfoExtension.Refresh(this);
if (_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
OnChange();// raise an event
}
public static ZContentInfo Get(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ZContent");
try
{
ZContentInfo tmp = GetCachedByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ZContentInfo>(new PKCriteria(contentID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ZContentInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ZContentInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ZContentInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContentInfo.Constructor", ex);
throw new DbCslaException("ZContentInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
public PKCriteria(int contentID)
{
_ContentID = contentID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_OldStepSequence = dr.GetString("OldStepSequence");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZContentInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ZContentInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZContentInfo.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 = "getZContent";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
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("ZContentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ZContentInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ZContentInfoExtension _ZContentInfoExtension = new ZContentInfoExtension();
[Serializable()]
partial class ZContentInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ZContentInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ZContentInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ZContentInfo)
{
// Return the ToString value
return ((ZContentInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -19,295 +19,292 @@ using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ZTransitionInfoEvent(object sender);
/// <summary>
/// ZTransitionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ZTransitionInfoConverter))]
public partial class ZTransitionInfo : ReadOnlyBase<ZTransitionInfo>, IDisposable
{
public event ZTransitionInfoEvent 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<ZTransitionInfo> _CacheList = new List<ZTransitionInfo>();
protected static void AddToCache(ZTransitionInfo zTransitionInfo)
{
if (!_CacheList.Contains(zTransitionInfo)) _CacheList.Add(zTransitionInfo); // In AddToCache
}
protected static void RemoveFromCache(ZTransitionInfo zTransitionInfo)
{
while (_CacheList.Contains(zTransitionInfo)) _CacheList.Remove(zTransitionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ZTransitionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ZTransitionInfo>>();
private static void ConvertListToDictionary()
{
List<ZTransitionInfo> remove = new List<ZTransitionInfo>();
foreach (ZTransitionInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
{
_CacheByPrimaryKey[tmp.TransitionID.ToString()] = new List<ZTransitionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ZTransitionInfo tmp in remove)
RemoveFromCache(tmp);
}
protected static ZTransitionInfo GetCachedByPrimaryKey(int transitionID)
{
ConvertListToDictionary();
string key = transitionID.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 ZTransition _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _TransitionID;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TransitionID", true);
if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID;
return _TransitionID;
}
}
private TransitionInfo _MyTransition;
[System.ComponentModel.DataObjectField(true, true)]
public TransitionInfo MyTransition
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyTransition", true);
if (_MyTransition == null && _TransitionID != 0) _MyTransition = TransitionInfo.Get(_TransitionID);
return _MyTransition;
}
}
private string _Oldto = string.Empty;
public string Oldto
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Oldto", true);
return _Oldto;
}
}
// TODO: Replace base ZTransitionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZTransitionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZTransitionInfo.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 ZTransitionInfo</returns>
protected override object GetIdValue()
{
return _TransitionID;
}
#endregion
#region Factory Methods
private static int _ZTransitionInfoUnique = 0;
private static int ZTransitionInfoUnique
{ get { return ++_ZTransitionInfoUnique; } }
private int _MyZTransitionInfoUnique = ZTransitionInfoUnique;
public int MyZTransitionInfoUnique
{ get { return _MyZTransitionInfoUnique; } }
protected ZTransitionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<ZTransitionInfo> listZTransitionInfo = _CacheByPrimaryKey[TransitionID.ToString()]; // Get the list of items
while (listZTransitionInfo.Contains(this)) listZTransitionInfo.Remove(this); // Remove the item from the list
if (listZTransitionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
}
public virtual ZTransition Get()
{
return _Editable = ZTransition.Get(_TransitionID);
}
public static void Refresh(ZTransition tmp)
{
string key = tmp.TransitionID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ZTransitionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ZTransition tmp)
{
_Oldto = tmp.Oldto;
_ZTransitionInfoExtension.Refresh(this);
if(_MyTransition != null)
{
_MyTransition.Dispose();// Dispose related value
_MyTransition = null;// Reset related value
}
OnChange();// raise an event
}
public static ZTransitionInfo Get(int transitionID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ZTransition");
try
{
ZTransitionInfo tmp = GetCachedByPrimaryKey(transitionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ZTransitionInfo>(new PKCriteria(transitionID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ZTransitionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ZTransitionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ZTransitionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.Constructor", ex);
throw new DbCslaException("ZTransitionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _TransitionID;
public int TransitionID
{ get { return _TransitionID; } }
public PKCriteria(int transitionID)
{
_TransitionID = transitionID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.ReadData", GetHashCode());
try
{
_TransitionID = dr.GetInt32("TransitionID");
_Oldto = dr.GetString("oldto");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ZTransitionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.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 = "getZTransition";
cm.Parameters.AddWithValue("@TransitionID", criteria.TransitionID);
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("ZTransitionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ZTransitionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ZTransitionInfoExtension _ZTransitionInfoExtension = new ZTransitionInfoExtension();
[Serializable()]
partial class ZTransitionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ZTransitionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ZTransitionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ZTransitionInfo)
{
// Return the ToString value
return ((ZTransitionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
public delegate void ZTransitionInfoEvent(object sender);
/// <summary>
/// ZTransitionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ZTransitionInfoConverter))]
public partial class ZTransitionInfo : ReadOnlyBase<ZTransitionInfo>, IDisposable
{
public event ZTransitionInfoEvent 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<ZTransitionInfo> _CacheList = new List<ZTransitionInfo>();
protected static void AddToCache(ZTransitionInfo zTransitionInfo)
{
if (!_CacheList.Contains(zTransitionInfo)) _CacheList.Add(zTransitionInfo); // In AddToCache
}
protected static void RemoveFromCache(ZTransitionInfo zTransitionInfo)
{
while (_CacheList.Contains(zTransitionInfo)) _CacheList.Remove(zTransitionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ZTransitionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ZTransitionInfo>>();
private static void ConvertListToDictionary()
{
List<ZTransitionInfo> remove = new List<ZTransitionInfo>();
foreach (ZTransitionInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.TransitionID.ToString()))
{
_CacheByPrimaryKey[tmp.TransitionID.ToString()] = new List<ZTransitionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.TransitionID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ZTransitionInfo tmp in remove)
RemoveFromCache(tmp);
}
protected static ZTransitionInfo GetCachedByPrimaryKey(int transitionID)
{
ConvertListToDictionary();
string key = transitionID.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 ZTransition _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _TransitionID;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID;
return _TransitionID;
}
}
private TransitionInfo _MyTransition;
[System.ComponentModel.DataObjectField(true, true)]
public TransitionInfo MyTransition
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyTransition == null && _TransitionID != 0) _MyTransition = TransitionInfo.Get(_TransitionID);
return _MyTransition;
}
}
private string _Oldto = string.Empty;
public string Oldto
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _Oldto;
}
}
// TODO: Replace base ZTransitionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZTransitionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZTransitionInfo.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 ZTransitionInfo</returns>
protected override object GetIdValue()
{
return _TransitionID;
}
#endregion
#region Factory Methods
private static int _ZTransitionInfoUnique = 0;
private static int ZTransitionInfoUnique
{ get { return ++_ZTransitionInfoUnique; } }
private int _MyZTransitionInfoUnique = ZTransitionInfoUnique;
public int MyZTransitionInfoUnique
{ get { return _MyZTransitionInfoUnique; } }
protected ZTransitionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(TransitionID.ToString())) return;
List<ZTransitionInfo> listZTransitionInfo = _CacheByPrimaryKey[TransitionID.ToString()]; // Get the list of items
while (listZTransitionInfo.Contains(this)) listZTransitionInfo.Remove(this); // Remove the item from the list
if (listZTransitionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(TransitionID.ToString()); // remove the list
}
public virtual ZTransition Get()
{
return _Editable = ZTransition.Get(_TransitionID);
}
public static void Refresh(ZTransition tmp)
{
string key = tmp.TransitionID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ZTransitionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ZTransition tmp)
{
_Oldto = tmp.Oldto;
_ZTransitionInfoExtension.Refresh(this);
if (_MyTransition != null)
{
_MyTransition.Dispose();// Dispose related value
_MyTransition = null;// Reset related value
}
OnChange();// raise an event
}
public static ZTransitionInfo Get(int transitionID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ZTransition");
try
{
ZTransitionInfo tmp = GetCachedByPrimaryKey(transitionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ZTransitionInfo>(new PKCriteria(transitionID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ZTransitionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ZTransitionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ZTransitionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.Constructor", ex);
throw new DbCslaException("ZTransitionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _TransitionID;
public int TransitionID
{ get { return _TransitionID; } }
public PKCriteria(int transitionID)
{
_TransitionID = transitionID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.ReadData", GetHashCode());
try
{
_TransitionID = dr.GetInt32("TransitionID");
_Oldto = dr.GetString("oldto");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ZTransitionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ZTransitionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ZTransitionInfo.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 = "getZTransition";
cm.Parameters.AddWithValue("@TransitionID", criteria.TransitionID);
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("ZTransitionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ZTransitionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ZTransitionInfoExtension _ZTransitionInfoExtension = new ZTransitionInfoExtension();
[Serializable()]
partial class ZTransitionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ZTransitionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ZTransitionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ZTransitionInfo)
{
// Return the ToString value
return ((ZTransitionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace