This commit is contained in:
Jsj
2007-11-20 20:12:45 +00:00
parent d0793524be
commit 6e00716c47
149 changed files with 71953 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,407 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<AnnotationInfo> _AllList = new List<AnnotationInfo>();
private static Dictionary<string, AnnotationInfo> _AllByPrimaryKey = new Dictionary<string, AnnotationInfo>();
private static void ConvertListToDictionary()
{
List<AnnotationInfo> remove = new List<AnnotationInfo>();
foreach (AnnotationInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.AnnotationID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (AnnotationInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(AnnotationInfoList lst)
{
foreach (AnnotationInfo item in lst) _AllList.Add(item);
}
public static AnnotationInfo GetExistingByPrimaryKey(int annotationID)
{
ConvertListToDictionary();
string key = annotationID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 AnnotationInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(AnnotationID.ToString());
}
public virtual Annotation Get()
{
return _Editable = Annotation.Get(_AnnotationID);
}
public static void Refresh(Annotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Annotation tmp)
{
_ItemID = tmp.ItemID;
_TypeID = tmp.TypeID;
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
_MyItem = null;
_MyAnnotationType = null;
OnChange();// raise an event
}
public static void Refresh(AnnotationTypeAnnotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(AnnotationTypeAnnotation tmp)
{
_ItemID = tmp.ItemID;
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
_MyItem = null;
_MyAnnotationType = null;
OnChange();// raise an event
}
public static void Refresh(ItemAnnotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ItemAnnotation tmp)
{
_TypeID = tmp.TypeID;
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
_MyItem = null;
_MyAnnotationType = null;
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 = GetExistingByPrimaryKey(annotationID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,569 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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
} // Namespace
//// The following is a sample Extension File. You can use it to create AnnotationTypeAnnotationExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class AnnotationTypeAnnotation
// {
// partial class AnnotationTypeAnnotationExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// AnnotationTypeAnnotations Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationTypeAnnotationsConverter))]
public partial class AnnotationTypeAnnotations : BusinessListBase<AnnotationTypeAnnotations, AnnotationTypeAnnotation>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public AnnotationTypeAnnotation this[Annotation myAnnotation]
{
get
{
foreach (AnnotationTypeAnnotation annotation in this)
if (annotation.AnnotationID == myAnnotation.AnnotationID)
return annotation;
return null;
}
}
public new System.Collections.Generic.IList<AnnotationTypeAnnotation> Items
{
get { return base.Items; }
}
public AnnotationTypeAnnotation GetItem(Annotation myAnnotation)
{
foreach (AnnotationTypeAnnotation annotation in this)
if (annotation.AnnotationID == myAnnotation.AnnotationID)
return annotation;
return null;
}
public AnnotationTypeAnnotation Add(Item myItem) // One to Many
{
AnnotationTypeAnnotation annotation = AnnotationTypeAnnotation.New(myItem);
this.Add(annotation);
return annotation;
}
public void Remove(Annotation myAnnotation)
{
foreach (AnnotationTypeAnnotation annotation in this)
{
if (annotation.AnnotationID == myAnnotation.AnnotationID)
{
Remove(annotation);
break;
}
}
}
public bool Contains(Annotation myAnnotation)
{
foreach (AnnotationTypeAnnotation annotation in this)
if (annotation.AnnotationID == myAnnotation.AnnotationID)
return true;
return false;
}
public bool ContainsDeleted(Annotation myAnnotation)
{
foreach (AnnotationTypeAnnotation annotation in DeletedList)
if (annotation.AnnotationID == myAnnotation.AnnotationID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(AnnotationTypeAnnotation annotationTypeAnnotation in this)
if ((hasBrokenRules = annotationTypeAnnotation.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static AnnotationTypeAnnotations New()
{
return new AnnotationTypeAnnotations();
}
internal static AnnotationTypeAnnotations Get(SafeDataReader dr)
{
return new AnnotationTypeAnnotations(dr);
}
public static AnnotationTypeAnnotations GetByTypeID(int typeID)
{
try
{
return DataPortal.Fetch<AnnotationTypeAnnotations>(new TypeIDCriteria(typeID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeAnnotations.GetByTypeID", ex);
}
}
private AnnotationTypeAnnotations()
{
MarkAsChild();
}
internal AnnotationTypeAnnotations(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(AnnotationTypeAnnotation.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class TypeIDCriteria
{
public TypeIDCriteria(int typeID)
{
_TypeID = typeID;
}
private int _TypeID;
public int TypeID
{
get { return _TypeID; }
set { _TypeID = value; }
}
}
private void DataPortal_Fetch(TypeIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeAnnotations.DataPortal_FetchTypeID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationsByTypeID";
cm.Parameters.AddWithValue("@TypeID", criteria.TypeID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new AnnotationTypeAnnotation(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeAnnotations.DataPortal_FetchTypeID", ex);
throw new DbCslaException("AnnotationTypeAnnotations.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(AnnotationType annotationType)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (AnnotationTypeAnnotation obj in DeletedList)
obj.DeleteSelf(annotationType);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (AnnotationTypeAnnotation obj in this)
{
if (obj.IsNew)
obj.Insert(annotationType);
else
obj.Update(annotationType);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
AnnotationTypeAnnotationsPropertyDescriptor pd = new AnnotationTypeAnnotationsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class AnnotationTypeAnnotationsPropertyDescriptor : vlnListPropertyDescriptor
{
private AnnotationTypeAnnotation Item { get { return (AnnotationTypeAnnotation) _Item;} }
public AnnotationTypeAnnotationsPropertyDescriptor(AnnotationTypeAnnotations collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class AnnotationTypeAnnotationsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationTypeAnnotations)
{
// Return department and department role separated by comma.
return ((AnnotationTypeAnnotations) value).Items.Count.ToString() + " Annotations";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,334 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<AnnotationTypeInfo> _AllList = new List<AnnotationTypeInfo>();
private static Dictionary<string, AnnotationTypeInfo> _AllByPrimaryKey = new Dictionary<string, AnnotationTypeInfo>();
private static void ConvertListToDictionary()
{
List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>();
foreach (AnnotationTypeInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.TypeID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (AnnotationTypeInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(AnnotationTypeInfoList lst)
{
foreach (AnnotationTypeInfo item in lst) _AllList.Add(item);
}
public static AnnotationTypeInfo GetExistingByPrimaryKey(int typeID)
{
ConvertListToDictionary();
string key = typeID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 && _AnnotationTypeAnnotations == null)
_AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID);
return _AnnotationTypeAnnotations;
}
}
// 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 AnnotationTypeInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(TypeID.ToString());
}
public virtual AnnotationType Get()
{
return _Editable = AnnotationType.Get(_TypeID);
}
public static void Refresh(AnnotationType tmp)
{
AnnotationTypeInfo tmpInfo = GetExistingByPrimaryKey(tmp.TypeID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private 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 = GetExistingByPrimaryKey(typeID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,442 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void AssignmentInfoEvent(object sender);
/// <summary>
/// AssignmentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AssignmentInfoConverter))]
public partial class AssignmentInfo : ReadOnlyBase<AssignmentInfo>, IDisposable
{
public event AssignmentInfoEvent 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
protected static List<AssignmentInfo> _AllList = new List<AssignmentInfo>();
private static Dictionary<string, AssignmentInfo> _AllByPrimaryKey = new Dictionary<string, AssignmentInfo>();
private static void ConvertListToDictionary()
{
List<AssignmentInfo> remove = new List<AssignmentInfo>();
foreach (AssignmentInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.AID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (AssignmentInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(AssignmentInfoList lst)
{
foreach (AssignmentInfo item in lst) _AllList.Add(item);
}
public static AssignmentInfo GetExistingByPrimaryKey(int aid)
{
ConvertListToDictionary();
string key = aid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Assignment _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AID",true);
return _AID;
}
}
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 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 _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private FolderInfo _MyFolder;
public FolderInfo MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID);
return _MyFolder;
}
}
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 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 AssignmentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AssignmentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AssignmentInfo.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 AssignmentInfo</returns>
protected override object GetIdValue()
{
return _AID;
}
#endregion
#region Factory Methods
private AssignmentInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(AID.ToString());
}
public virtual Assignment Get()
{
return _Editable = Assignment.Get(_AID);
}
public static void Refresh(Assignment tmp)
{
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Assignment tmp)
{
_GID = tmp.GID;
_RID = tmp.RID;
_FolderID = tmp.FolderID;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_AssignmentInfoExtension.Refresh(this);
_MyGroup = null;
_MyRole = null;
_MyFolder = null;
OnChange();// raise an event
}
public static void Refresh(FolderAssignment tmp)
{
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(FolderAssignment tmp)
{
_GID = tmp.GID;
_RID = tmp.RID;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_AssignmentInfoExtension.Refresh(this);
_MyGroup = null;
_MyRole = null;
_MyFolder = null;
OnChange();// raise an event
}
public static void Refresh(GroupAssignment tmp)
{
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(GroupAssignment tmp)
{
_RID = tmp.RID;
_FolderID = tmp.FolderID;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_AssignmentInfoExtension.Refresh(this);
_MyGroup = null;
_MyRole = null;
_MyFolder = null;
OnChange();// raise an event
}
public static void Refresh(RoleAssignment tmp)
{
AssignmentInfo tmpInfo = GetExistingByPrimaryKey(tmp.AID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(RoleAssignment tmp)
{
_GID = tmp.GID;
_FolderID = tmp.FolderID;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_AssignmentInfoExtension.Refresh(this);
_MyGroup = null;
_MyRole = null;
_MyFolder = null;
OnChange();// raise an event
}
public static AssignmentInfo Get(int aid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Assignment");
try
{
AssignmentInfo tmp = GetExistingByPrimaryKey(aid);
if (tmp == null)
{
tmp = DataPortal.Fetch<AssignmentInfo>(new PKCriteria(aid));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AssignmentInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AssignmentInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.Constructor", ex);
throw new DbCslaException("AssignmentInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _AID;
public int AID
{ get { return _AID; } }
public PKCriteria(int aid)
{
_AID = aid;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.ReadData", GetHashCode());
try
{
_AID = dr.GetInt32("AID");
_GID = dr.GetInt32("GID");
_RID = dr.GetInt32("RID");
_FolderID = dr.GetInt32("FolderID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AssignmentInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AssignmentInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AssignmentInfo.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 = "getAssignment";
cm.Parameters.AddWithValue("@AID", criteria.AID);
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("AssignmentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AssignmentInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AssignmentInfoExtension _AssignmentInfoExtension = new AssignmentInfoExtension();
[Serializable()]
partial class AssignmentInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AssignmentInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AssignmentInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AssignmentInfo)
{
// Return the ToString value
return ((AssignmentInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

View File

@@ -0,0 +1,309 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ChildFolders Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ChildFoldersConverter))]
public partial class ChildFolders : BusinessListBase<ChildFolders, Folder>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public new Folder this[int folderID]
{
get
{
foreach (Folder folder in this)
if (folder.FolderID == folderID)
return folder;
return null;
}
}
public new System.Collections.Generic.IList<Folder> Items
{
get { return base.Items; }
}
public Folder GetItem(int folderID)
{
foreach (Folder folder in this)
if (folder.FolderID == folderID)
return folder;
return null;
}
public Folder Add(Folder myParent, string name, string shortName) // One to Many with unique fields
{
if (!Contains(name))
{
Folder folder = Folder.New(myParent, name, shortName);
this.Add(folder);
return folder;
}
else
throw new InvalidOperationException("folder already exists");
}
public void Remove(int folderID)
{
foreach (Folder folder in this)
{
if (folder.FolderID == folderID)
{
Remove(folder);
break;
}
}
}
public bool Contains(int folderID)
{
foreach (Folder folder in this)
if (folder.FolderID == folderID)
return true;
return false;
}
public bool ContainsDeleted(int folderID)
{
foreach (Folder folder in DeletedList)
if (folder.FolderID == folderID)
return true;
return false;
}
public bool Contains(string name)
{
foreach (Folder folder in this)
if (folder.Name == name)
return true;
return false;
}
public bool ContainsDeleted(string name)
{
foreach (Folder folder in DeletedList)
if (folder.Name == name)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(Folder folder in this)
if ((hasBrokenRules = folder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ChildFolders New()
{
return new ChildFolders();
}
internal static ChildFolders Get(SafeDataReader dr, Folder parent)
{
return new ChildFolders(dr, parent);
}
public static ChildFolders GetByParentID(int parentID)
{
try
{
return DataPortal.Fetch<ChildFolders>(new ParentIDCriteria(parentID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ChildFolders.GetByParentID", ex);
}
}
private ChildFolders()
{
MarkAsChild();
}
internal ChildFolders(SafeDataReader dr, Folder parent)
{
MarkAsChild();
Fetch(dr, parent);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr, Folder parent)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(Folder.Get(dr, parent));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ParentIDCriteria
{
public ParentIDCriteria(int parentID)
{
_ParentID = parentID;
}
private int _ParentID;
public int ParentID
{
get { return _ParentID; }
set { _ParentID = value; }
}
}
private void DataPortal_Fetch(ParentIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ChildFolders.DataPortal_FetchParentID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getChildFolders";
cm.Parameters.AddWithValue("@ParentID", criteria.ParentID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new Folder(dr, criteria.ParentID));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ChildFolders.DataPortal_FetchParentID", ex);
throw new DbCslaException("ChildFolders.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Folder folder)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (Folder obj in DeletedList)
obj.DeleteSelf(folder);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (Folder obj in this)
{
if (obj.IsNew)
obj.SQLInsert();
else
obj.SQLUpdate();
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ChildFoldersPropertyDescriptor pd = new ChildFoldersPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ChildFoldersPropertyDescriptor : vlnListPropertyDescriptor
{
private Folder Item { get { return (Folder) _Item;} }
public ChildFoldersPropertyDescriptor(ChildFolders collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ChildFoldersConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ChildFolders)
{
// Return department and department role separated by comma.
return ((ChildFolders) value).Items.Count.ToString() + " Folders";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,309 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ChildFormats Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ChildFormatsConverter))]
public partial class ChildFormats : BusinessListBase<ChildFormats, Format>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public new Format this[int formatID]
{
get
{
foreach (Format format in this)
if (format.FormatID == formatID)
return format;
return null;
}
}
public new System.Collections.Generic.IList<Format> Items
{
get { return base.Items; }
}
public Format GetItem(int formatID)
{
foreach (Format format in this)
if (format.FormatID == formatID)
return format;
return null;
}
public Format Add(Format myParent, string name, string data) // One to Many with unique fields
{
if (!Contains(name))
{
Format format = Format.New(myParent, name, data);
this.Add(format);
return format;
}
else
throw new InvalidOperationException("format already exists");
}
public void Remove(int formatID)
{
foreach (Format format in this)
{
if (format.FormatID == formatID)
{
Remove(format);
break;
}
}
}
public bool Contains(int formatID)
{
foreach (Format format in this)
if (format.FormatID == formatID)
return true;
return false;
}
public bool ContainsDeleted(int formatID)
{
foreach (Format format in DeletedList)
if (format.FormatID == formatID)
return true;
return false;
}
public bool Contains(string name)
{
foreach (Format format in this)
if (format.Name == name)
return true;
return false;
}
public bool ContainsDeleted(string name)
{
foreach (Format format in DeletedList)
if (format.Name == name)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(Format format in this)
if ((hasBrokenRules = format.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ChildFormats New()
{
return new ChildFormats();
}
internal static ChildFormats Get(SafeDataReader dr, Format parent)
{
return new ChildFormats(dr, parent);
}
public static ChildFormats GetByParentID(int parentID)
{
try
{
return DataPortal.Fetch<ChildFormats>(new ParentIDCriteria(parentID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ChildFormats.GetByParentID", ex);
}
}
private ChildFormats()
{
MarkAsChild();
}
internal ChildFormats(SafeDataReader dr, Format parent)
{
MarkAsChild();
Fetch(dr, parent);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr, Format parent)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(Format.Get(dr, parent));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ParentIDCriteria
{
public ParentIDCriteria(int parentID)
{
_ParentID = parentID;
}
private int _ParentID;
public int ParentID
{
get { return _ParentID; }
set { _ParentID = value; }
}
}
private void DataPortal_Fetch(ParentIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ChildFormats.DataPortal_FetchParentID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getChildFormats";
cm.Parameters.AddWithValue("@ParentID", criteria.ParentID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new Format(dr, criteria.ParentID));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ChildFormats.DataPortal_FetchParentID", ex);
throw new DbCslaException("ChildFormats.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Format format)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (Format obj in DeletedList)
obj.DeleteSelf(format);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (Format obj in this)
{
if (obj.IsNew)
obj.SQLInsert();
else
obj.SQLUpdate();
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ChildFormatsPropertyDescriptor pd = new ChildFormatsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ChildFormatsPropertyDescriptor : vlnListPropertyDescriptor
{
private Format Item { get { return (Format) _Item;} }
public ChildFormatsPropertyDescriptor(ChildFormats collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ChildFormatsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ChildFormats)
{
// Return department and department role separated by comma.
return ((ChildFormats) value).Items.Count.ToString() + " Formats";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,40 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
using System.Reflection;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// CommonRules Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
public static class CommonRules
{
public static bool Required(object target, Csla.Validation.RuleArgs e)
{
PropertyInfo propertyInfoObj = target.GetType().GetProperty(e.PropertyName);
if (propertyInfoObj == null) return true;
if (propertyInfoObj.GetValue(target, null) == null)
{
e.Description = e.PropertyName + " is a required field";
return false;
}
return true;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,613 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ConnectionFolder Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ConnectionFolderConverter))]
public partial class ConnectionFolder : BusinessBase<ConnectionFolder>, 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 _FolderID;
[System.ComponentModel.DataObjectField(true, true)]
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
[System.ComponentModel.DataObjectField(true, true)]
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
}
private int _ParentID;
public int ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ParentID",true);
if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID;
}
}
private Folder _MyParent;
public Folder MyParent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyParent",true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID);
return _MyParent;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyParent",true);
if (_MyParent != value)
{
_MyParent = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Name",true);
if (value == null) value = string.Empty;
if (_Name != value)
{
_Name = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Title",true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private string _ShortName = string.Empty;
public string ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ShortName",true);
return _ShortName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ShortName",true);
if (value == null) value = string.Empty;
if (_ShortName != value)
{
_ShortName = value;
PropertyHasChanged();
}
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
}
private Format _MyFormat;
public Format MyFormat
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFormat",true);
if (_MyFormat != value)
{
_MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID);
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID",true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check ConnectionFolder.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 ConnectionFolder</returns>
protected override object GetIdValue()
{
return _FolderID;
}
// TODO: Replace base ConnectionFolder.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ConnectionFolder</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.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 (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<ConnectionFolder>(MyFolderRequired, "MyFolder");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "ShortName");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ShortName", 20));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private static bool MyFolderRequired(ConnectionFolder target, Csla.Validation.RuleArgs e)
{
if (target._ParentID == 0 && target._MyFolder == 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(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ShortName, "<Role(s)>");
//AuthorizationRules.AllowWrite(ShortName, "<Role(s)>");
//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FormatID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<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 ConnectionFolder New(Folder myParent, string name, string shortName)
{
return new ConnectionFolder(myParent, name, shortName);
}
internal static ConnectionFolder Get(SafeDataReader dr)
{
return new ConnectionFolder(dr);
}
public ConnectionFolder()
{
MarkAsChild();
_FolderID = Folder.NextFolderID;
_ParentID = _ConnectionFolderExtension.DefaultParentID;
_DTS = _ConnectionFolderExtension.DefaultDTS;
_UsrID = _ConnectionFolderExtension.DefaultUsrID;
ValidationRules.CheckRules();
}
private ConnectionFolder(Folder myParent, string name, string shortName)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_ParentID = _ConnectionFolderExtension.DefaultParentID;
_DTS = _ConnectionFolderExtension.DefaultDTS;
_UsrID = _ConnectionFolderExtension.DefaultUsrID;
_MyParent = myParent;
_Name = name;
_ShortName = shortName;
ValidationRules.CheckRules();
}
internal ConnectionFolder(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionFolder.FetchDR", GetHashCode());
try
{
_FolderID = dr.GetInt32("FolderID");
_ParentID = dr.GetInt32("ParentID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ShortName = dr.GetString("ShortName");
_FormatID = (int?)dr.GetValue("FormatID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionFolder.FetchDR", ex);
throw new DbCslaException("ConnectionFolder.Fetch", ex);
}
MarkOld();
}
internal void Insert(Connection myConnection)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Folder.Add(cn, ref _FolderID, Folder.Get(_ParentID), myConnection, _Name, _Title, _ShortName, _MyFormat, _Config, _DTS, _UsrID);
MarkOld();
}
internal void Update(Connection myConnection)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Folder.Update(cn, ref _FolderID, Folder.Get(_ParentID), myConnection, _Name, _Title, _ShortName, _MyFormat, _Config, _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Connection myConnection)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Folder.Remove(cn, _FolderID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ConnectionFolderExtension _ConnectionFolderExtension = new ConnectionFolderExtension();
[Serializable()]
partial class ConnectionFolderExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultParentID
{
get { return 1; }
}
public virtual int DefaultDBID
{
get { return 1; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return 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 ConnectionFolderConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ConnectionFolder)
{
// Return the ToString value
return ((ConnectionFolder)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ConnectionFolderExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ConnectionFolder
// {
// partial class ConnectionFolderExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultParentID
// {
// get { return 1; }
// }
// public virtual int DefaultDBID
// {
// get { return 1; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ConnectionFolders Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ConnectionFoldersConverter))]
public partial class ConnectionFolders : BusinessListBase<ConnectionFolders, ConnectionFolder>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ConnectionFolder this[Folder myFolder]
{
get
{
foreach (ConnectionFolder folder in this)
if (folder.FolderID == myFolder.FolderID)
return folder;
return null;
}
}
public new System.Collections.Generic.IList<ConnectionFolder> Items
{
get { return base.Items; }
}
public ConnectionFolder GetItem(Folder myFolder)
{
foreach (ConnectionFolder folder in this)
if (folder.FolderID == myFolder.FolderID)
return folder;
return null;
}
public ConnectionFolder Add(Folder myParent, string name, string shortName) // One to Many
{
ConnectionFolder folder = ConnectionFolder.New(myParent, name, shortName);
this.Add(folder);
return folder;
}
public void Remove(Folder myFolder)
{
foreach (ConnectionFolder folder in this)
{
if (folder.FolderID == myFolder.FolderID)
{
Remove(folder);
break;
}
}
}
public bool Contains(Folder myFolder)
{
foreach (ConnectionFolder folder in this)
if (folder.FolderID == myFolder.FolderID)
return true;
return false;
}
public bool ContainsDeleted(Folder myFolder)
{
foreach (ConnectionFolder folder in DeletedList)
if (folder.FolderID == myFolder.FolderID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ConnectionFolder connectionFolder in this)
if ((hasBrokenRules = connectionFolder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ConnectionFolders New()
{
return new ConnectionFolders();
}
internal static ConnectionFolders Get(SafeDataReader dr)
{
return new ConnectionFolders(dr);
}
public static ConnectionFolders GetByDBID(int dbid)
{
try
{
return DataPortal.Fetch<ConnectionFolders>(new DBIDCriteria(dbid));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ConnectionFolders.GetByDBID", ex);
}
}
private ConnectionFolders()
{
MarkAsChild();
}
internal ConnectionFolders(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ConnectionFolder.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class DBIDCriteria
{
public DBIDCriteria(int dbid)
{
_DBID = dbid;
}
private int _DBID;
public int DBID
{
get { return _DBID; }
set { _DBID = value; }
}
}
private void DataPortal_Fetch(DBIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionFolders.DataPortal_FetchDBID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFoldersByDBID";
cm.Parameters.AddWithValue("@DBID", criteria.DBID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ConnectionFolder(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionFolders.DataPortal_FetchDBID", ex);
throw new DbCslaException("ConnectionFolders.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Connection connection)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ConnectionFolder obj in DeletedList)
obj.DeleteSelf(connection);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ConnectionFolder obj in this)
{
if (obj.IsNew)
obj.Insert(connection);
else
obj.Update(connection);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ConnectionFoldersPropertyDescriptor pd = new ConnectionFoldersPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ConnectionFoldersPropertyDescriptor : vlnListPropertyDescriptor
{
private ConnectionFolder Item { get { return (ConnectionFolder) _Item;} }
public ConnectionFoldersPropertyDescriptor(ConnectionFolders collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ConnectionFoldersConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ConnectionFolders)
{
// Return department and department role separated by comma.
return ((ConnectionFolders) value).Items.Count.ToString() + " Folders";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,373 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<ConnectionInfo> _AllList = new List<ConnectionInfo>();
private static Dictionary<string, ConnectionInfo> _AllByPrimaryKey = new Dictionary<string, ConnectionInfo>();
private static void ConvertListToDictionary()
{
List<ConnectionInfo> remove = new List<ConnectionInfo>();
foreach (ConnectionInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.DBID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (ConnectionInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(ConnectionInfoList lst)
{
foreach (ConnectionInfo item in lst) _AllList.Add(item);
}
public static ConnectionInfo GetExistingByPrimaryKey(int dbid)
{
ConvertListToDictionary();
string key = dbid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 && _ConnectionFolders == null)
_ConnectionFolders = FolderInfoList.GetByDBID(_DBID);
return _ConnectionFolders;
}
}
// 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 ConnectionInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(DBID.ToString());
}
public virtual Connection Get()
{
return _Editable = Connection.Get(_DBID);
}
public static void Refresh(Connection tmp)
{
ConnectionInfo tmpInfo = GetExistingByPrimaryKey(tmp.DBID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private 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 = GetExistingByPrimaryKey(dbid);
if (tmp == null)
{
tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,470 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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
} // Namespace
//// The following is a sample Extension File. You can use it to create ContentDetailExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentDetail
// {
// partial class ContentDetailExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentDetails Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentDetailsConverter))]
public partial class ContentDetails : BusinessListBase<ContentDetails, ContentDetail>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ContentDetail this[Detail myDetail]
{
get
{
foreach (ContentDetail detail in this)
if (detail.DetailID == myDetail.DetailID)
return detail;
return null;
}
}
public new System.Collections.Generic.IList<ContentDetail> Items
{
get { return base.Items; }
}
public ContentDetail GetItem(Detail myDetail)
{
foreach (ContentDetail detail in this)
if (detail.DetailID == myDetail.DetailID)
return detail;
return null;
}
public ContentDetail Add(int itemType, string text) // One to Many
{
ContentDetail detail = ContentDetail.New(itemType, text);
this.Add(detail);
return detail;
}
public void Remove(Detail myDetail)
{
foreach (ContentDetail detail in this)
{
if (detail.DetailID == myDetail.DetailID)
{
Remove(detail);
break;
}
}
}
public bool Contains(Detail myDetail)
{
foreach (ContentDetail detail in this)
if (detail.DetailID == myDetail.DetailID)
return true;
return false;
}
public bool ContainsDeleted(Detail myDetail)
{
foreach (ContentDetail detail in DeletedList)
if (detail.DetailID == myDetail.DetailID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ContentDetail contentDetail in this)
if ((hasBrokenRules = contentDetail.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ContentDetails New()
{
return new ContentDetails();
}
internal static ContentDetails Get(SafeDataReader dr)
{
return new ContentDetails(dr);
}
public static ContentDetails GetByContentID(int contentID)
{
try
{
return DataPortal.Fetch<ContentDetails>(new ContentIDCriteria(contentID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentDetails.GetByContentID", ex);
}
}
private ContentDetails()
{
MarkAsChild();
}
internal ContentDetails(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ContentDetail.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ContentIDCriteria
{
public ContentIDCriteria(int contentID)
{
_ContentID = contentID;
}
private int _ContentID;
public int ContentID
{
get { return _ContentID; }
set { _ContentID = value; }
}
}
private void DataPortal_Fetch(ContentIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentDetails.DataPortal_FetchContentID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDetailsByContentID";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ContentDetail(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentDetails.DataPortal_FetchContentID", ex);
throw new DbCslaException("ContentDetails.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Content content)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ContentDetail obj in DeletedList)
obj.DeleteSelf(content);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ContentDetail obj in this)
{
if (obj.IsNew)
obj.Insert(content);
else
obj.Update(content);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ContentDetailsPropertyDescriptor pd = new ContentDetailsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ContentDetailsPropertyDescriptor : vlnListPropertyDescriptor
{
private ContentDetail Item { get { return (ContentDetail) _Item;} }
public ContentDetailsPropertyDescriptor(ContentDetails collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ContentDetailsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentDetails)
{
// Return department and department role separated by comma.
return ((ContentDetails) value).Items.Count.ToString() + " Details";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,570 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ContentInfoEvent(object sender);
/// <summary>
/// ContentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentInfoConverter))]
public partial class ContentInfo : ReadOnlyBase<ContentInfo>, IDisposable
{
public event ContentInfoEvent 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
protected static List<ContentInfo> _AllList = new List<ContentInfo>();
private static Dictionary<string, ContentInfo> _AllByPrimaryKey = new Dictionary<string, ContentInfo>();
private static void ConvertListToDictionary()
{
List<ContentInfo> remove = new List<ContentInfo>();
foreach (ContentInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (ContentInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(ContentInfoList lst)
{
foreach (ContentInfo item in lst) _AllList.Add(item);
}
public static ContentInfo GetExistingByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Content _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);
return _ContentID;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Number",true);
return _Number;
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text",true);
return _Text;
}
}
private int? _Type;
/// <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;
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
}
private FormatInfo _MyFormat;
public FormatInfo MyFormat
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID);
return _MyFormat;
}
}
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 _ContentDetailCount = 0;
/// <summary>
/// Count of ContentDetails for this Content
/// </summary>
public int ContentDetailCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentDetailCount",true);
return _ContentDetailCount;
}
}
private DetailInfoList _ContentDetails = null;
[TypeConverter(typeof(DetailInfoListConverter))]
public DetailInfoList ContentDetails
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentDetails",true);
if (_ContentDetailCount > 0 && _ContentDetails == null)
_ContentDetails = DetailInfoList.GetByContentID(_ContentID);
return _ContentDetails;
}
}
private int _ContentEntryCount = 0;
/// <summary>
/// Count of ContentEntries for this Content
/// </summary>
public int ContentEntryCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentEntryCount",true);
return _ContentEntryCount;
}
}
private EntryInfo _MyEntry = null;
[TypeConverter(typeof(EntryInfoConverter))]
public EntryInfo MyEntry
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyEntry",true);
if (_ContentEntryCount > 0 && _MyEntry == null)
_MyEntry = EntryInfo.Get(_ContentID);
return _MyEntry;
}
}
private int _ContentItemCount = 0;
/// <summary>
/// Count of ContentItems for this Content
/// </summary>
public int ContentItemCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentItemCount",true);
return _ContentItemCount;
}
}
private ItemInfoList _ContentItems = null;
[TypeConverter(typeof(ItemInfoListConverter))]
public ItemInfoList ContentItems
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentItems",true);
if (_ContentItemCount > 0 && _ContentItems == null)
_ContentItems = ItemInfoList.GetByContentID(_ContentID);
return _ContentItems;
}
}
private int _ContentPartCount = 0;
/// <summary>
/// Count of ContentParts for this Content
/// </summary>
public int ContentPartCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentPartCount",true);
return _ContentPartCount;
}
}
private PartInfoList _ContentParts = null;
[TypeConverter(typeof(PartInfoListConverter))]
public PartInfoList ContentParts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentParts",true);
if (_ContentPartCount > 0 && _ContentParts == null)
_ContentParts = PartInfoList.GetByContentID(_ContentID);
return _ContentParts;
}
}
private int _ContentRoUsageCount = 0;
/// <summary>
/// Count of ContentRoUsages for this Content
/// </summary>
public int ContentRoUsageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentRoUsageCount",true);
return _ContentRoUsageCount;
}
}
private RoUsageInfoList _ContentRoUsages = null;
[TypeConverter(typeof(RoUsageInfoListConverter))]
public RoUsageInfoList ContentRoUsages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentRoUsages",true);
if (_ContentRoUsageCount > 0 && _ContentRoUsages == null)
_ContentRoUsages = RoUsageInfoList.GetByContentID(_ContentID);
return _ContentRoUsages;
}
}
private int _ContentTransitionCount = 0;
/// <summary>
/// Count of ContentTransitions for this Content
/// </summary>
public int ContentTransitionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentTransitionCount",true);
return _ContentTransitionCount;
}
}
private TransitionInfoList _ContentTransitions = null;
[TypeConverter(typeof(TransitionInfoListConverter))]
public TransitionInfoList ContentTransitions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentTransitions",true);
if (_ContentTransitionCount > 0 && _ContentTransitions == null)
_ContentTransitions = TransitionInfoList.GetByFromID(_ContentID);
return _ContentTransitions;
}
}
private int _ContentZContentCount = 0;
/// <summary>
/// Count of ContentZContents for this Content
/// </summary>
public int ContentZContentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentZContentCount",true);
return _ContentZContentCount;
}
}
private ZContentInfo _MyZContent = null;
[TypeConverter(typeof(ZContentInfoConverter))]
public ZContentInfo MyZContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyZContent",true);
if (_ContentZContentCount > 0 && _MyZContent == null)
_MyZContent = ZContentInfo.Get(_ContentID);
return _MyZContent;
}
}
// TODO: Replace base ContentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ContentInfo.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 ContentInfo</returns>
protected override object GetIdValue()
{
return _ContentID;
}
#endregion
#region Factory Methods
private ContentInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString());
}
public virtual Content Get()
{
return _Editable = Content.Get(_ContentID);
}
public static void Refresh(Content tmp)
{
ContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Content tmp)
{
_Number = tmp.Number;
_Text = tmp.Text;
_Type = tmp.Type;
_FormatID = tmp.FormatID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ContentInfoExtension.Refresh(this);
_MyFormat = null;
_MyEntry = null;
_MyZContent = null;
OnChange();// raise an event
}
public static void Refresh(FormatContent tmp)
{
ContentInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(FormatContent tmp)
{
_Number = tmp.Number;
_Text = tmp.Text;
_Type = tmp.Type;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ContentInfoExtension.Refresh(this);
_MyFormat = null;
_MyEntry = null;
_MyZContent = null;
OnChange();// raise an event
}
public static ContentInfo Get(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Content");
try
{
ContentInfo tmp = GetExistingByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ContentInfo>(new PKCriteria(contentID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ContentInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.Constructor", ex);
throw new DbCslaException("ContentInfo.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}] ContentInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_Number = dr.GetString("Number");
_Text = dr.GetString("Text");
_Type = (int?)dr.GetValue("Type");
_FormatID = (int?)dr.GetValue("FormatID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ContentDetailCount = dr.GetInt32("DetailCount");
_ContentEntryCount = dr.GetInt32("EntryCount");
_ContentItemCount = dr.GetInt32("ItemCount");
_ContentPartCount = dr.GetInt32("PartCount");
_ContentRoUsageCount = dr.GetInt32("RoUsageCount");
_ContentTransitionCount = dr.GetInt32("TransitionCount");
_ContentZContentCount = dr.GetInt32("ZContentCount");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ContentInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentInfo.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 = "getContent";
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("ContentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ContentInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ContentInfoExtension _ContentInfoExtension = new ContentInfoExtension();
[Serializable()]
partial class ContentInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ContentInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ContentInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentInfo)
{
// Return the ToString value
return ((ContentInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

View File

@@ -0,0 +1,418 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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 != value)
{
_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
} // Namespace
//// The following is a sample Extension File. You can use it to create ContentItemExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentItem
// {
// partial class ContentItemExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentItems Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentItemsConverter))]
public partial class ContentItems : BusinessListBase<ContentItems, ContentItem>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ContentItem this[Item myItem]
{
get
{
foreach (ContentItem item in this)
if (item.ItemID == myItem.ItemID)
return item;
return null;
}
}
public new System.Collections.Generic.IList<ContentItem> Items
{
get { return base.Items; }
}
public ContentItem GetItem(Item myItem)
{
foreach (ContentItem item in this)
if (item.ItemID == myItem.ItemID)
return item;
return null;
}
public ContentItem Add() // One to Many
{
ContentItem item = ContentItem.New();
this.Add(item);
return item;
}
public void Remove(Item myItem)
{
foreach (ContentItem item in this)
{
if (item.ItemID == myItem.ItemID)
{
Remove(item);
break;
}
}
}
public bool Contains(Item myItem)
{
foreach (ContentItem item in this)
if (item.ItemID == myItem.ItemID)
return true;
return false;
}
public bool ContainsDeleted(Item myItem)
{
foreach (ContentItem item in DeletedList)
if (item.ItemID == myItem.ItemID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ContentItem contentItem in this)
if ((hasBrokenRules = contentItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ContentItems New()
{
return new ContentItems();
}
internal static ContentItems Get(SafeDataReader dr)
{
return new ContentItems(dr);
}
public static ContentItems GetByContentID(int contentID)
{
try
{
return DataPortal.Fetch<ContentItems>(new ContentIDCriteria(contentID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentItems.GetByContentID", ex);
}
}
private ContentItems()
{
MarkAsChild();
}
internal ContentItems(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ContentItem.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ContentIDCriteria
{
public ContentIDCriteria(int contentID)
{
_ContentID = contentID;
}
private int _ContentID;
public int ContentID
{
get { return _ContentID; }
set { _ContentID = value; }
}
}
private void DataPortal_Fetch(ContentIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentItems.DataPortal_FetchContentID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getItemsByContentID";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ContentItem(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentItems.DataPortal_FetchContentID", ex);
throw new DbCslaException("ContentItems.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Content content)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ContentItem obj in DeletedList)
obj.DeleteSelf(content);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ContentItem obj in this)
{
if (obj.IsNew)
obj.Insert(content);
else
obj.Update(content);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ContentItemsPropertyDescriptor pd = new ContentItemsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ContentItemsPropertyDescriptor : vlnListPropertyDescriptor
{
private ContentItem Item { get { return (ContentItem) _Item;} }
public ContentItemsPropertyDescriptor(ContentItems collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ContentItemsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentItems)
{
// Return department and department role separated by comma.
return ((ContentItems) value).Items.Count.ToString() + " Items";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,476 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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();
_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
//// The following is a sample Extension File. You can use it to create ContentPartExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentPart
// {
// partial class ContentPartExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,295 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentParts Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentPartsConverter))]
public partial class ContentParts : BusinessListBase<ContentParts, ContentPart>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public new ContentPart this[int fromType]
{
get
{
foreach (ContentPart part in this)
if (part.FromType == fromType)
return part;
return null;
}
}
public new System.Collections.Generic.IList<ContentPart> Items
{
get { return base.Items; }
}
public ContentPart GetItem(int fromType)
{
foreach (ContentPart part in this)
if (part.FromType == fromType)
return part;
return null;
}
public ContentPart Add(int fromType, Item myItem) // One to Many with unique fields
{
if (!Contains(fromType))
{
ContentPart part = ContentPart.New(fromType, myItem);
this.Add(part);
return part;
}
else
throw new InvalidOperationException("part already exists");
}
public void Remove(int fromType)
{
foreach (ContentPart part in this)
{
if (part.FromType == fromType)
{
Remove(part);
break;
}
}
}
public bool Contains(int fromType)
{
foreach (ContentPart part in this)
if (part.FromType == fromType)
return true;
return false;
}
public bool ContainsDeleted(int fromType)
{
foreach (ContentPart part in DeletedList)
if (part.FromType == fromType)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ContentPart contentPart in this)
if ((hasBrokenRules = contentPart.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ContentParts New()
{
return new ContentParts();
}
internal static ContentParts Get(SafeDataReader dr)
{
return new ContentParts(dr);
}
public static ContentParts GetByContentID(int contentID)
{
try
{
return DataPortal.Fetch<ContentParts>(new ContentIDCriteria(contentID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentParts.GetByContentID", ex);
}
}
private ContentParts()
{
MarkAsChild();
}
internal ContentParts(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ContentPart.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ContentIDCriteria
{
public ContentIDCriteria(int contentID)
{
_ContentID = contentID;
}
private int _ContentID;
public int ContentID
{
get { return _ContentID; }
set { _ContentID = value; }
}
}
private void DataPortal_Fetch(ContentIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentParts.DataPortal_FetchContentID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getPartsByContentID";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ContentPart(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentParts.DataPortal_FetchContentID", ex);
throw new DbCslaException("ContentParts.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Content content)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ContentPart obj in DeletedList)
obj.DeleteSelf(content);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ContentPart obj in this)
{
if (obj.IsNew)
obj.Insert(content);
else
obj.Update(content);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ContentPartsPropertyDescriptor pd = new ContentPartsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ContentPartsPropertyDescriptor : vlnListPropertyDescriptor
{
private ContentPart Item { get { return (ContentPart) _Item;} }
public ContentPartsPropertyDescriptor(ContentParts collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ContentPartsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentParts)
{
// Return department and department role separated by comma.
return ((ContentParts) value).Items.Count.ToString() + " Parts";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,454 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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
// 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();
//}
#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, "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));
// 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(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)>");
}
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)
{
return new ContentRoUsage(roid);
}
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)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
_ROID = roid;
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);
}
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);
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);
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
//// The following is a sample Extension File. You can use it to create ContentRoUsageExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentRoUsage
// {
// partial class ContentRoUsageExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultContentID
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentRoUsages Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentRoUsagesConverter))]
public partial class ContentRoUsages : BusinessListBase<ContentRoUsages, ContentRoUsage>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ContentRoUsage this[RoUsage myRoUsage]
{
get
{
foreach (ContentRoUsage roUsage in this)
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
return roUsage;
return null;
}
}
public new System.Collections.Generic.IList<ContentRoUsage> Items
{
get { return base.Items; }
}
public ContentRoUsage GetItem(RoUsage myRoUsage)
{
foreach (ContentRoUsage roUsage in this)
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
return roUsage;
return null;
}
public ContentRoUsage Add(string roid) // One to Many
{
ContentRoUsage roUsage = ContentRoUsage.New(roid);
this.Add(roUsage);
return roUsage;
}
public void Remove(RoUsage myRoUsage)
{
foreach (ContentRoUsage roUsage in this)
{
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
{
Remove(roUsage);
break;
}
}
}
public bool Contains(RoUsage myRoUsage)
{
foreach (ContentRoUsage roUsage in this)
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
return true;
return false;
}
public bool ContainsDeleted(RoUsage myRoUsage)
{
foreach (ContentRoUsage roUsage in DeletedList)
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ContentRoUsage contentRoUsage in this)
if ((hasBrokenRules = contentRoUsage.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ContentRoUsages New()
{
return new ContentRoUsages();
}
internal static ContentRoUsages Get(SafeDataReader dr)
{
return new ContentRoUsages(dr);
}
public static ContentRoUsages GetByContentID(int contentID)
{
try
{
return DataPortal.Fetch<ContentRoUsages>(new ContentIDCriteria(contentID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentRoUsages.GetByContentID", ex);
}
}
private ContentRoUsages()
{
MarkAsChild();
}
internal ContentRoUsages(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ContentRoUsage.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ContentIDCriteria
{
public ContentIDCriteria(int contentID)
{
_ContentID = contentID;
}
private int _ContentID;
public int ContentID
{
get { return _ContentID; }
set { _ContentID = value; }
}
}
private void DataPortal_Fetch(ContentIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentRoUsages.DataPortal_FetchContentID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRoUsagesByContentID";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ContentRoUsage(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentRoUsages.DataPortal_FetchContentID", ex);
throw new DbCslaException("ContentRoUsages.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Content content)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ContentRoUsage obj in DeletedList)
obj.DeleteSelf(content);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ContentRoUsage obj in this)
{
if (obj.IsNew)
obj.Insert(content);
else
obj.Update(content);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ContentRoUsagesPropertyDescriptor pd = new ContentRoUsagesPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ContentRoUsagesPropertyDescriptor : vlnListPropertyDescriptor
{
private ContentRoUsage Item { get { return (ContentRoUsage) _Item;} }
public ContentRoUsagesPropertyDescriptor(ContentRoUsages collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ContentRoUsagesConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentRoUsages)
{
// Return department and department role separated by comma.
return ((ContentRoUsages) value).Items.Count.ToString() + " RoUsages";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,642 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentTransition Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentTransitionConverter))]
public partial class ContentTransition : BusinessBase<ContentTransition>, 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 _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 Transition _MyTransition;
[System.ComponentModel.DataObjectField(true, true)]
public Transition MyTransition
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyTransition",true);
if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID);
return _MyTransition;
}
}
private int _ToID;
/// <summary>
/// StructureID
/// </summary>
public int ToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ToID",true);
if (_MyItemToID != null) _ToID = _MyItemToID.ItemID;
return _ToID;
}
}
private Item _MyItemToID;
public Item MyItemToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItemToID",true);
if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID);
return _MyItemToID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItemToID",true);
if (_MyItemToID != value)
{
_MyItemToID = value;
PropertyHasChanged();
}
}
}
private int _RangeID;
public int RangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RangeID",true);
if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID;
return _RangeID;
}
}
private Item _MyItemRangeID;
public Item MyItemRangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItemRangeID",true);
if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID);
return _MyItemRangeID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItemRangeID",true);
if (_MyItemRangeID != value)
{
_MyItemRangeID = value;
PropertyHasChanged();
}
}
}
private int _TranType;
public int TranType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TranType",true);
return _TranType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("TranType",true);
if (_TranType != value)
{
_TranType = 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_RangeID_PreviousID;
public int? Item_RangeID_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_RangeID_PreviousID",true);
return _Item_RangeID_PreviousID;
}
}
private int _Item_RangeID_ContentID;
public int Item_RangeID_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_RangeID_ContentID",true);
return _Item_RangeID_ContentID;
}
}
private DateTime _Item_RangeID_DTS = new DateTime();
public DateTime Item_RangeID_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_RangeID_DTS",true);
return _Item_RangeID_DTS;
}
}
private string _Item_RangeID_UserID = string.Empty;
public string Item_RangeID_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_RangeID_UserID",true);
return _Item_RangeID_UserID;
}
}
private int? _Item_ToID_PreviousID;
public int? Item_ToID_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ToID_PreviousID",true);
return _Item_ToID_PreviousID;
}
}
private int _Item_ToID_ContentID;
public int Item_ToID_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ToID_ContentID",true);
return _Item_ToID_ContentID;
}
}
private DateTime _Item_ToID_DTS = new DateTime();
public DateTime Item_ToID_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ToID_DTS",true);
return _Item_ToID_DTS;
}
}
private string _Item_ToID_UserID = string.Empty;
public string Item_ToID_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ToID_UserID",true);
return _Item_ToID_UserID;
}
}
// TODO: Check ContentTransition.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 ContentTransition</returns>
protected override object GetIdValue()
{
return _TransitionID;
}
// TODO: Replace base ContentTransition.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentTransition</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyItemToID == null ? false : _MyItemToID.IsDirty) || (_MyItemRangeID == null ? false : _MyItemRangeID.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyItemToID == null ? true : _MyItemToID.IsValid) && (_MyItemRangeID == null ? true : _MyItemRangeID.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 (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.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<ContentTransition>(MyItemToIDRequired, "MyItemToID");
ValidationRules.AddRule<ContentTransition>(MyItemRangeIDRequired, "MyItemRangeID");
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 MyItemToIDRequired(ContentTransition target, Csla.Validation.RuleArgs e)
{
if (target._ToID == 0 && target._MyItemToID == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
private static bool MyItemRangeIDRequired(ContentTransition target, Csla.Validation.RuleArgs e)
{
if (target._RangeID == 0 && target._MyItemRangeID == 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(TransitionID, "<Role(s)>");
//AuthorizationRules.AllowRead(ToID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ToID, "<Role(s)>");
//AuthorizationRules.AllowRead(RangeID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RangeID, "<Role(s)>");
//AuthorizationRules.AllowRead(TranType, "<Role(s)>");
//AuthorizationRules.AllowWrite(TranType, "<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 ContentTransition New(Item myItemToID, Item myItemRangeID)
{
return new ContentTransition(myItemToID, myItemRangeID);
}
internal static ContentTransition Get(SafeDataReader dr)
{
return new ContentTransition(dr);
}
public ContentTransition()
{
MarkAsChild();
_TransitionID = Transition.NextTransitionID;
_TranType = _ContentTransitionExtension.DefaultTranType;
_DTS = _ContentTransitionExtension.DefaultDTS;
_UserID = _ContentTransitionExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentTransition(Item myItemToID, Item myItemRangeID)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_TranType = _ContentTransitionExtension.DefaultTranType;
_DTS = _ContentTransitionExtension.DefaultDTS;
_UserID = _ContentTransitionExtension.DefaultUserID;
_MyItemToID = myItemToID;
_MyItemRangeID = myItemRangeID;
ValidationRules.CheckRules();
}
internal ContentTransition(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentTransition.FetchDR", GetHashCode());
try
{
_TransitionID = dr.GetInt32("TransitionID");
_ToID = dr.GetInt32("ToID");
_RangeID = dr.GetInt32("RangeID");
_TranType = dr.GetInt32("TranType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_RangeID_PreviousID = (int?)dr.GetValue("Item_RangeID_PreviousID");
_Item_RangeID_ContentID = dr.GetInt32("Item_RangeID_ContentID");
_Item_RangeID_DTS = dr.GetDateTime("Item_RangeID_DTS");
_Item_RangeID_UserID = dr.GetString("Item_RangeID_UserID");
_Item_ToID_PreviousID = (int?)dr.GetValue("Item_ToID_PreviousID");
_Item_ToID_ContentID = dr.GetInt32("Item_ToID_ContentID");
_Item_ToID_DTS = dr.GetDateTime("Item_ToID_DTS");
_Item_ToID_UserID = dr.GetString("Item_ToID_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentTransition.FetchDR", ex);
throw new DbCslaException("ContentTransition.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 = Transition.Add(cn, ref _TransitionID, myContent, _MyItemToID, _MyItemRangeID, _TranType, _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 = Transition.Update(cn, ref _TransitionID, myContent, _MyItemToID, _MyItemRangeID, _TranType, _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"];
Transition.Remove(cn, _TransitionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentTransitionExtension _ContentTransitionExtension = new ContentTransitionExtension();
[Serializable()]
partial class ContentTransitionExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultTranType
{
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 ContentTransitionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentTransition)
{
// Return the ToString value
return ((ContentTransition)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ContentTransitionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentTransition
// {
// partial class ContentTransitionExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultTranType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentTransitions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentTransitionsConverter))]
public partial class ContentTransitions : BusinessListBase<ContentTransitions, ContentTransition>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ContentTransition this[Transition myTransition]
{
get
{
foreach (ContentTransition transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return transition;
return null;
}
}
public new System.Collections.Generic.IList<ContentTransition> Items
{
get { return base.Items; }
}
public ContentTransition GetItem(Transition myTransition)
{
foreach (ContentTransition transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return transition;
return null;
}
public ContentTransition Add(Item myItemToID, Item myItemRangeID) // One to Many
{
ContentTransition transition = ContentTransition.New(myItemToID, myItemRangeID);
this.Add(transition);
return transition;
}
public void Remove(Transition myTransition)
{
foreach (ContentTransition transition in this)
{
if (transition.TransitionID == myTransition.TransitionID)
{
Remove(transition);
break;
}
}
}
public bool Contains(Transition myTransition)
{
foreach (ContentTransition transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return true;
return false;
}
public bool ContainsDeleted(Transition myTransition)
{
foreach (ContentTransition transition in DeletedList)
if (transition.TransitionID == myTransition.TransitionID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ContentTransition contentTransition in this)
if ((hasBrokenRules = contentTransition.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ContentTransitions New()
{
return new ContentTransitions();
}
internal static ContentTransitions Get(SafeDataReader dr)
{
return new ContentTransitions(dr);
}
public static ContentTransitions GetByFromID(int fromID)
{
try
{
return DataPortal.Fetch<ContentTransitions>(new FromIDCriteria(fromID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentTransitions.GetByFromID", ex);
}
}
private ContentTransitions()
{
MarkAsChild();
}
internal ContentTransitions(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ContentTransition.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class FromIDCriteria
{
public FromIDCriteria(int fromID)
{
_FromID = fromID;
}
private int _FromID;
public int FromID
{
get { return _FromID; }
set { _FromID = value; }
}
}
private void DataPortal_Fetch(FromIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentTransitions.DataPortal_FetchFromID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getTransitionsByFromID";
cm.Parameters.AddWithValue("@FromID", criteria.FromID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ContentTransition(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentTransitions.DataPortal_FetchFromID", ex);
throw new DbCslaException("ContentTransitions.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Content content)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ContentTransition obj in DeletedList)
obj.DeleteSelf(content);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ContentTransition obj in this)
{
if (obj.IsNew)
obj.Insert(content);
else
obj.Update(content);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ContentTransitionsPropertyDescriptor pd = new ContentTransitionsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ContentTransitionsPropertyDescriptor : vlnListPropertyDescriptor
{
private ContentTransition Item { get { return (ContentTransition) _Item;} }
public ContentTransitionsPropertyDescriptor(ContentTransitions collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ContentTransitionsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentTransitions)
{
// Return department and department role separated by comma.
return ((ContentTransitions) value).Items.Count.ToString() + " Transitions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,138 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Diagnostics;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// Database Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public static partial class Database
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
public static void LogException(string s,Exception ex)
{
int i = 0;
Console.WriteLine("Error - {0}", s);
for (; ex != null; ex = ex.InnerException)
{
Console.WriteLine("{0}{1} - {2}", "".PadLeft(++i * 2), ex.GetType().ToString(), ex.Message);
}
}
private static bool _LoggingInfo = false; // By default don't log info
public static bool LoggingInfo
{
get { return _LoggingInfo; }
set { _LoggingInfo = value; }
}
static System.Diagnostics.Process _CurrentProcess = System.Diagnostics.Process.GetCurrentProcess();
public static void LogInfo(string s,int hashCode)
{
if (_LoggingInfo)
Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode));
}
public static void LogDebug(string s,int hashCode)
{
if (_LoggingInfo)
Console.WriteLine("{0} MB {1}", _CurrentProcess.WorkingSet64 / 1000000, string.Format(s, hashCode));
}
public static string VEPROMS_Connection
{
get
{
DateTime.Today.ToLongDateString();
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings["VEPROMS"];
if (cs == null)
{
throw new ApplicationException("Database.cs Could not find connection VEPROMS");
}
return cs.ConnectionString;
}
}
public static SqlConnection VEPROMS_SqlConnection
{
get
{
string strConn = VEPROMS_Connection; // If failure - Fail (Don't try to catch)
// Attempt to make a connection
try
{
SqlConnection cn = new SqlConnection(strConn);
cn.Open();
return cn;
}
catch (SqlException exsql)
{
const string strAttachError = "An attempt to attach an auto-named database for file ";
if (exsql.Message.StartsWith(strAttachError))
{// Check to see if the file is missing
string sFile = exsql.Message.Substring(strAttachError.Length);
sFile = sFile.Substring(0, sFile.IndexOf(" failed"));
// "An attempt to attach an auto-named database for file <mdf file> failed"
if (strConn.ToLower().IndexOf("user instance=true") < 0)
{
throw new ApplicationException("Connection String missing attribute: User Instance=True");
}
if (System.IO.File.Exists(sFile))
{
throw new ApplicationException("Database file " + sFile + " Cannot be opened\r\n", exsql);
}
else
{
throw new FileNotFoundException("Database file " + sFile + " Not Found", exsql);
}
}
else
{
throw new ApplicationException("Failure on Connect", exsql);
}
}
catch (Exception ex)// Throw Application Exception on Failure
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Connection Error", ex);
throw new ApplicationException("Failure on Connect", ex);
}
}
}
public static void PurgeData()
{
try
{
SqlConnection cn = VEPROMS_SqlConnection;
SqlCommand cmd = new SqlCommand("purgedata", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Purge Error", ex);
throw new ApplicationException("Failure on Purge", ex);
}
}
}
public class DbCslaException : Exception
{
internal DbCslaException(string message, Exception innerException):base(message,innerException){;}
internal DbCslaException(string message) : base(message) { ;}
internal DbCslaException() : base() { ;}
} // Class
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,361 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<DetailInfo> _AllList = new List<DetailInfo>();
private static Dictionary<string, DetailInfo> _AllByPrimaryKey = new Dictionary<string, DetailInfo>();
private static void ConvertListToDictionary()
{
List<DetailInfo> remove = new List<DetailInfo>();
foreach (DetailInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.DetailID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (DetailInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(DetailInfoList lst)
{
foreach (DetailInfo item in lst) _AllList.Add(item);
}
public static DetailInfo GetExistingByPrimaryKey(int detailID)
{
ConvertListToDictionary();
string key = detailID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 DetailInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(DetailID.ToString());
}
public virtual Detail Get()
{
return _Editable = Detail.Get(_DetailID);
}
public static void Refresh(Detail tmp)
{
DetailInfo tmpInfo = GetExistingByPrimaryKey(tmp.DetailID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Detail tmp)
{
_ContentID = tmp.ContentID;
_ItemType = tmp.ItemType;
_Text = tmp.Text;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DetailInfoExtension.Refresh(this);
_MyContent = null;
OnChange();// raise an event
}
public static void Refresh(ContentDetail tmp)
{
DetailInfo tmpInfo = GetExistingByPrimaryKey(tmp.DetailID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ContentDetail tmp)
{
_ItemType = tmp.ItemType;
_Text = tmp.Text;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DetailInfoExtension.Refresh(this);
_MyContent = null;
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 = GetExistingByPrimaryKey(detailID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DetailInfo>(new PKCriteria(detailID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,475 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void DocVersionInfoEvent(object sender);
/// <summary>
/// DocVersionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocVersionInfoConverter))]
public partial class DocVersionInfo : ReadOnlyBase<DocVersionInfo>, IDisposable
{
public event DocVersionInfoEvent 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
protected static List<DocVersionInfo> _AllList = new List<DocVersionInfo>();
private static Dictionary<string, DocVersionInfo> _AllByPrimaryKey = new Dictionary<string, DocVersionInfo>();
private static void ConvertListToDictionary()
{
List<DocVersionInfo> remove = new List<DocVersionInfo>();
foreach (DocVersionInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.VersionID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (DocVersionInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(DocVersionInfoList lst)
{
foreach (DocVersionInfo item in lst) _AllList.Add(item);
}
public static DocVersionInfo GetExistingByPrimaryKey(int versionID)
{
ConvertListToDictionary();
string key = versionID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected DocVersion _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionID",true);
return _VersionID;
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private FolderInfo _MyFolder;
public FolderInfo MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = FolderInfo.Get(_FolderID);
return _MyFolder;
}
}
private int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionType",true);
return _VersionType;
}
}
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 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 != null) _MyItem = ItemInfo.Get((int)_ItemID);
return _MyItem;
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
}
private FormatInfo _MyFormat;
public FormatInfo MyFormat
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID);
return _MyFormat;
}
}
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 DocVersionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocVersionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocVersionInfo.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 DocVersionInfo</returns>
protected override object GetIdValue()
{
return _VersionID;
}
#endregion
#region Factory Methods
private DocVersionInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(VersionID.ToString());
}
public virtual DocVersion Get()
{
return _Editable = DocVersion.Get(_VersionID);
}
public static void Refresh(DocVersion tmp)
{
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(DocVersion tmp)
{
_FolderID = tmp.FolderID;
_VersionType = tmp.VersionType;
_Name = tmp.Name;
_Title = tmp.Title;
_ItemID = tmp.ItemID;
_FormatID = tmp.FormatID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionInfoExtension.Refresh(this);
_MyFolder = null;
_MyItem = null;
_MyFormat = null;
OnChange();// raise an event
}
public static void Refresh(FolderDocVersion tmp)
{
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(FolderDocVersion tmp)
{
_VersionType = tmp.VersionType;
_Name = tmp.Name;
_Title = tmp.Title;
_ItemID = tmp.ItemID;
_FormatID = tmp.FormatID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionInfoExtension.Refresh(this);
_MyFolder = null;
_MyItem = null;
_MyFormat = null;
OnChange();// raise an event
}
public static void Refresh(FormatDocVersion tmp)
{
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(FormatDocVersion tmp)
{
_FolderID = tmp.FolderID;
_VersionType = tmp.VersionType;
_Name = tmp.Name;
_Title = tmp.Title;
_ItemID = tmp.ItemID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionInfoExtension.Refresh(this);
_MyFolder = null;
_MyItem = null;
_MyFormat = null;
OnChange();// raise an event
}
public static void Refresh(ItemDocVersion tmp)
{
DocVersionInfo tmpInfo = GetExistingByPrimaryKey(tmp.VersionID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ItemDocVersion tmp)
{
_FolderID = tmp.FolderID;
_VersionType = tmp.VersionType;
_Name = tmp.Name;
_Title = tmp.Title;
_FormatID = tmp.FormatID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocVersionInfoExtension.Refresh(this);
_MyFolder = null;
_MyItem = null;
_MyFormat = null;
OnChange();// raise an event
}
public static DocVersionInfo Get(int versionID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a DocVersion");
try
{
DocVersionInfo tmp = GetExistingByPrimaryKey(versionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocVersionInfo>(new PKCriteria(versionID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocVersionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DocVersionInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.Constructor", ex);
throw new DbCslaException("DocVersionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _VersionID;
public int VersionID
{ get { return _VersionID; } }
public PKCriteria(int versionID)
{
_VersionID = versionID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.ReadData", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_FolderID = dr.GetInt32("FolderID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ItemID = (int?)dr.GetValue("ItemID");
_FormatID = (int?)dr.GetValue("FormatID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocVersionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocVersionInfo.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 = "getDocVersion";
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocVersionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocVersionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DocVersionInfoExtension _DocVersionInfoExtension = new DocVersionInfoExtension();
[Serializable()]
partial class DocVersionInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DocVersionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DocVersionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocVersionInfo)
{
// Return the ToString value
return ((DocVersionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// DocumentEntries Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentEntriesConverter))]
public partial class DocumentEntries : BusinessListBase<DocumentEntries, DocumentEntry>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public DocumentEntry this[Entry myEntry]
{
get
{
foreach (DocumentEntry entry in this)
if (entry.ContentID == myEntry.ContentID)
return entry;
return null;
}
}
public new System.Collections.Generic.IList<DocumentEntry> Items
{
get { return base.Items; }
}
public DocumentEntry GetItem(Entry myEntry)
{
foreach (DocumentEntry entry in this)
if (entry.ContentID == myEntry.ContentID)
return entry;
return null;
}
public DocumentEntry Add(Entry myEntry) // One to Many
{
DocumentEntry entry = DocumentEntry.New(myEntry);
this.Add(entry);
return entry;
}
public void Remove(Entry myEntry)
{
foreach (DocumentEntry entry in this)
{
if (entry.ContentID == myEntry.ContentID)
{
Remove(entry);
break;
}
}
}
public bool Contains(Entry myEntry)
{
foreach (DocumentEntry entry in this)
if (entry.ContentID == myEntry.ContentID)
return true;
return false;
}
public bool ContainsDeleted(Entry myEntry)
{
foreach (DocumentEntry entry in DeletedList)
if (entry.ContentID == myEntry.ContentID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(DocumentEntry documentEntry in this)
if ((hasBrokenRules = documentEntry.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static DocumentEntries New()
{
return new DocumentEntries();
}
internal static DocumentEntries Get(SafeDataReader dr)
{
return new DocumentEntries(dr);
}
public static DocumentEntries GetByDocID(int docID)
{
try
{
return DataPortal.Fetch<DocumentEntries>(new DocIDCriteria(docID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentEntries.GetByDocID", ex);
}
}
private DocumentEntries()
{
MarkAsChild();
}
internal DocumentEntries(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(DocumentEntry.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class DocIDCriteria
{
public DocIDCriteria(int docID)
{
_DocID = docID;
}
private int _DocID;
public int DocID
{
get { return _DocID; }
set { _DocID = value; }
}
}
private void DataPortal_Fetch(DocIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentEntries.DataPortal_FetchDocID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getEntriesByDocID";
cm.Parameters.AddWithValue("@DocID", criteria.DocID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new DocumentEntry(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentEntries.DataPortal_FetchDocID", ex);
throw new DbCslaException("DocumentEntries.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Document document)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (DocumentEntry obj in DeletedList)
obj.DeleteSelf(document);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (DocumentEntry obj in this)
{
if (obj.IsNew)
obj.Insert(document);
else
obj.Update(document);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
DocumentEntriesPropertyDescriptor pd = new DocumentEntriesPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class DocumentEntriesPropertyDescriptor : vlnListPropertyDescriptor
{
private DocumentEntry Item { get { return (DocumentEntry) _Item;} }
public DocumentEntriesPropertyDescriptor(DocumentEntries collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class DocumentEntriesConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentEntries)
{
// Return department and department role separated by comma.
return ((DocumentEntries) value).Items.Count.ToString() + " Entries";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,470 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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();
_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
//// The following is a sample Extension File. You can use it to create DocumentEntryExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class DocumentEntry
// {
// partial class DocumentEntryExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,364 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<DocumentInfo> _AllList = new List<DocumentInfo>();
private static Dictionary<string, DocumentInfo> _AllByPrimaryKey = new Dictionary<string, DocumentInfo>();
private static void ConvertListToDictionary()
{
List<DocumentInfo> remove = new List<DocumentInfo>();
foreach (DocumentInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.DocID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (DocumentInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(DocumentInfoList lst)
{
foreach (DocumentInfo item in lst) _AllList.Add(item);
}
public static DocumentInfo GetExistingByPrimaryKey(int docID)
{
ConvertListToDictionary();
string key = docID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 && _DocumentEntries == null)
_DocumentEntries = EntryInfoList.GetByDocID(_DocID);
return _DocumentEntries;
}
}
// 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 DocumentInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(DocID.ToString());
}
public virtual Document Get()
{
return _Editable = Document.Get(_DocID);
}
public static void Refresh(Document tmp)
{
DocumentInfo tmpInfo = GetExistingByPrimaryKey(tmp.DocID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private 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 = GetExistingByPrimaryKey(docID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocumentInfo>(new PKCriteria(docID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

View File

@@ -0,0 +1,933 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// Entry Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(EntryConverter))]
public partial class Entry : BusinessBase<Entry>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<Entry> _RefreshEntries = new List<Entry>();
private void AddToRefreshList(List<Entry> refreshEntries)
{
if (IsDirty)
refreshEntries.Add(this);
}
private void BuildRefreshList()
{
_RefreshEntries = new List<Entry>();
AddToRefreshList(_RefreshEntries);
}
private void ProcessRefreshList()
{
foreach (Entry tmp in _RefreshEntries)
{
EntryInfo.Refresh(tmp);
if(tmp._MyDocument != null) DocumentInfo.Refresh(tmp._MyDocument);
}
}
#endregion
#region Collection
protected static List<Entry> _AllList = new List<Entry>();
private static Dictionary<string, Entry> _AllByPrimaryKey = new Dictionary<string, Entry>();
private static void ConvertListToDictionary()
{
List<Entry> remove = new List<Entry>();
foreach (Entry tmp in _AllList)
{
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (Entry tmp in remove)
_AllList.Remove(tmp);
}
public static Entry GetExistingByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#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 _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 Document _MyDocument;
public Document MyDocument
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDocument",true);
if (_MyDocument == null && _DocID != 0) _MyDocument = Document.Get(_DocID);
return _MyDocument;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyDocument",true);
if (_MyDocument != value)
{
_MyDocument = 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
public override bool IsDirty
{
get { return base.IsDirty || (_MyDocument == null? false : _MyDocument.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyDocument == null? true : _MyDocument.IsValid); }
}
// TODO: Replace base Entry.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Entry</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Entry.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 Entry</returns>
protected override object GetIdValue()
{
return _ContentID;
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get {
if(_CheckingBrokenRules)return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyDocument != null && (hasBrokenRules = _MyDocument.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<Entry>(MyDocumentRequired, "MyDocument");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
//ValidationRules.AddDependantProperty("x", "y");
_EntryExtension.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_EntryExtension.AddInstanceValidationRules(ValidationRules);
// TODO: Add other validation rules
}
private static bool MyDocumentRequired(Entry target, Csla.Validation.RuleArgs e)
{
if (target._DocID == 0 && target._MyDocument == 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(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(DocID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DocID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
_EntryExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//TODO: Who can read/write which fields
_EntryExtension.AddInstanceAuthorizationRules(AuthorizationRules);
}
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; } }
protected Entry()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString());
}
public static Entry New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Entry");
try
{
return DataPortal.Create<Entry>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on Entry.New", ex);
}
}
public static Entry New(Content myContent, Document myDocument)
{
Entry tmp = Entry.New();
tmp._MyContent = myContent;
tmp.MyDocument = myDocument;
return tmp;
}
public static Entry New(Content myContent, Document myDocument, DateTime dts, string userID)
{
Entry tmp = Entry.New();
tmp._MyContent = myContent;
tmp.MyDocument = myDocument;
tmp.DTS = dts;
tmp.UserID = userID;
return tmp;
}
public static Entry MakeEntry(Content myContent, Document myDocument, DateTime dts, string userID)
{
Entry tmp = Entry.New(myContent, myDocument, dts, userID);
if (tmp.IsSavable)
tmp = tmp.Save();
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
tmp._ErrorMessage = "Failed Validation:";
foreach (Csla.Validation.BrokenRule br in brc)
{
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
}
}
return tmp;
}
public static Entry New(Content myContent)
{
Entry tmp = Entry.New();
tmp._MyContent = myContent;
tmp.MarkClean();
tmp.MarkAsChild();
return tmp;
}
public static Entry Get(int contentID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Entry");
try
{
Entry tmp = GetExistingByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Entry>(new PKCriteria(contentID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Entry.Get", ex);
}
}
public static Entry Get(SafeDataReader dr)
{
if (dr.Read()) return new Entry(dr);
return null;
}
internal Entry(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(int contentID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Entry");
try
{
DataPortal.Delete(new PKCriteria(contentID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on Entry.Delete", ex);
}
}
public override Entry Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Entry");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Entry");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Entry");
try
{
BuildRefreshList();
Entry entry = base.Save();
_AllList.Add(entry);//Refresh the item in AllList
ProcessRefreshList();
return entry;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
public PKCriteria(int contentID)
{
_ContentID = contentID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
// Database Defaults
_DTS = _EntryExtension.DefaultDTS;
_UserID = _EntryExtension.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_DocID = dr.GetInt32("DocID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
MarkOld();
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Entry.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.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("Entry.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Entry.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
SQLInsert();
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Entry.DataPortal_Insert", ex);
}
finally
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
try
{
if(_MyDocument != null) _MyDocument.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addEntry";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", ContentID);
cm.Parameters.AddWithValue("@DocID", DocID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
MarkOld();
// update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Entry.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, Content myContent, Document myDocument, DateTime dts, string userID)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addEntry";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", myContent.ContentID);
cm.Parameters.AddWithValue("@DocID", myDocument.DocID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.Add", ex);
throw new DbCslaException("Entry.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Update", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
SQLUpdate();
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Update", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLUpdate()
{
if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.SQLUpdate", GetHashCode());
try
{
if(_MyDocument != null) _MyDocument.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateEntry";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@ContentID", ContentID);
cm.Parameters.AddWithValue("@DocID", DocID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
MarkOld();
// use the open connection to update child objects
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.SQLUpdate", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
internal void Update(Content content)
{
if (!this.IsDirty) return;
if (base.IsDirty)
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (IsNew)
_LastChanged = Entry.Add(cn, content, MyDocument, _DTS, _UserID);
else
_LastChanged = Entry.Update(cn, content, MyDocument, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, Content myContent, Document myDocument, DateTime dts, string userID, ref byte[] lastChanged)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateEntry";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", myContent.ContentID);
cm.Parameters.AddWithValue("@DocID", myDocument.DocID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.Update", ex);
throw new DbCslaException("Entry.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_ContentID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteEntry";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Entry.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int contentID)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteEntry";
// Input PK Fields
cm.Parameters.AddWithValue("@ContentID", contentID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.Remove", ex);
throw new DbCslaException("Entry.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int contentID)
{
ExistsCommand result;
try
{
result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(contentID));
return result.Exists;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Entry.Exists", ex);
}
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _ContentID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int contentID)
{
_ContentID = contentID;
}
protected override void DataPortal_Execute()
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Entry.DataPortal_Execute", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsEntry";
cm.Parameters.AddWithValue("@ContentID", _ContentID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Entry.DataPortal_Execute", ex);
throw new DbCslaException("Entry.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
EntryExtension _EntryExtension = new EntryExtension();
[Serializable()]
partial class EntryExtension : 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 EntryConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is Entry)
{
// Return the ToString value
return ((Entry)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create EntryExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class Entry
// {
// partial class EntryExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,340 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<EntryInfo> _AllList = new List<EntryInfo>();
private static Dictionary<string, EntryInfo> _AllByPrimaryKey = new Dictionary<string, EntryInfo>();
private static void ConvertListToDictionary()
{
List<EntryInfo> remove = new List<EntryInfo>();
foreach (EntryInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (EntryInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(EntryInfoList lst)
{
foreach (EntryInfo item in lst) _AllList.Add(item);
}
public static EntryInfo GetExistingByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 EntryInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString());
}
public virtual Entry Get()
{
return _Editable = Entry.Get(_ContentID);
}
public static void Refresh(Entry tmp)
{
EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Entry tmp)
{
_DocID = tmp.DocID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
_MyContent = null;
_MyDocument = null;
OnChange();// raise an event
}
public static void Refresh(DocumentEntry tmp)
{
EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(DocumentEntry tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
_MyContent = null;
_MyDocument = null;
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 = GetExistingByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp._ContentID = contentID;
}
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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,696 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FolderAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FolderAssignmentConverter))]
public partial class FolderAssignment : BusinessBase<FolderAssignment>, 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 _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AID",true);
if (_MyAssignment != null) _AID = _MyAssignment.AID;
return _AID;
}
}
private Assignment _MyAssignment;
[System.ComponentModel.DataObjectField(true, true)]
public Assignment MyAssignment
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAssignment",true);
if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID);
return _MyAssignment;
}
}
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 Group _MyGroup;
public Group MyGroup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyGroup",true);
if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID);
return _MyGroup;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyGroup",true);
if (_MyGroup != value)
{
_MyGroup = value;
PropertyHasChanged();
}
}
}
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 Role _MyRole;
public Role MyRole
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRole",true);
if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID);
return _MyRole;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyRole",true);
if (_MyRole != value)
{
_MyRole = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StartDate",true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("StartDate",true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("EndDate",true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("EndDate",true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID",true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Group_GroupName = string.Empty;
public string Group_GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_GroupName",true);
return _Group_GroupName;
}
}
private int? _Group_GroupType;
public int? Group_GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_GroupType",true);
return _Group_GroupType;
}
}
private string _Group_Config = string.Empty;
public string Group_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_Config",true);
return _Group_Config;
}
}
private DateTime _Group_DTS = new DateTime();
public DateTime Group_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_DTS",true);
return _Group_DTS;
}
}
private string _Group_UsrID = string.Empty;
public string Group_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_UsrID",true);
return _Group_UsrID;
}
}
private string _Role_Name = string.Empty;
public string Role_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Role_Name",true);
return _Role_Name;
}
}
private string _Role_Title = string.Empty;
public string Role_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Role_Title",true);
return _Role_Title;
}
}
private DateTime _Role_DTS = new DateTime();
public DateTime Role_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Role_DTS",true);
return _Role_DTS;
}
}
private string _Role_UsrID = string.Empty;
public string Role_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Role_UsrID",true);
return _Role_UsrID;
}
}
// TODO: Check FolderAssignment.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 FolderAssignment</returns>
protected override object GetIdValue()
{
return _AID;
}
// TODO: Replace base FolderAssignment.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FolderAssignment</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyGroup == null ? false : _MyGroup.IsDirty) || (_MyRole == null ? false : _MyRole.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyGroup == null ? true : _MyGroup.IsValid) && (_MyRole == null ? true : _MyRole.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 (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules;
if (_MyRole != null && (hasBrokenRules = _MyRole.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<FolderAssignment>(MyGroupRequired, "MyGroup");
ValidationRules.AddRule<FolderAssignment>(MyRoleRequired, "MyRole");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule<FolderAssignment>(StartDateValid, "StartDate");
ValidationRules.AddRule<FolderAssignment>(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private static bool StartDateValid(FolderAssignment target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool EndDateValid(FolderAssignment target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._EndDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool MyGroupRequired(FolderAssignment target, Csla.Validation.RuleArgs e)
{
if (target._GID == 0 && target._MyGroup == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
private static bool MyRoleRequired(FolderAssignment target, Csla.Validation.RuleArgs e)
{
if (target._RID == 0 && target._MyRole == 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(AID, "<Role(s)>");
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<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 FolderAssignment New(Group myGroup, Role myRole)
{
return new FolderAssignment(myGroup, myRole);
}
internal static FolderAssignment Get(SafeDataReader dr)
{
return new FolderAssignment(dr);
}
public FolderAssignment()
{
MarkAsChild();
_AID = Assignment.NextAID;
_StartDate = _FolderAssignmentExtension.DefaultStartDate;
_DTS = _FolderAssignmentExtension.DefaultDTS;
_UsrID = _FolderAssignmentExtension.DefaultUsrID;
ValidationRules.CheckRules();
}
private FolderAssignment(Group myGroup, Role myRole)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = _FolderAssignmentExtension.DefaultStartDate;
_DTS = _FolderAssignmentExtension.DefaultDTS;
_UsrID = _FolderAssignmentExtension.DefaultUsrID;
_MyGroup = myGroup;
_MyRole = myRole;
ValidationRules.CheckRules();
}
internal FolderAssignment(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderAssignment.FetchDR", GetHashCode());
try
{
_AID = dr.GetInt32("AID");
_GID = dr.GetInt32("GID");
_RID = dr.GetInt32("RID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Group_GroupName = dr.GetString("Group_GroupName");
_Group_GroupType = (int?)dr.GetValue("Group_GroupType");
_Group_Config = dr.GetString("Group_Config");
_Group_DTS = dr.GetDateTime("Group_DTS");
_Group_UsrID = dr.GetString("Group_UsrID");
_Role_Name = dr.GetString("Role_Name");
_Role_Title = dr.GetString("Role_Title");
_Role_DTS = dr.GetDateTime("Role_DTS");
_Role_UsrID = dr.GetString("Role_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderAssignment.FetchDR", ex);
throw new DbCslaException("FolderAssignment.Fetch", ex);
}
MarkOld();
}
internal void Insert(Folder myFolder)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Assignment.Add(cn, ref _AID, _MyGroup, _MyRole, myFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(Folder myFolder)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Assignment.Update(cn, ref _AID, _MyGroup, _MyRole, myFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Folder myFolder)
{
// 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"];
Assignment.Remove(cn, _AID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FolderAssignmentExtension _FolderAssignmentExtension = new FolderAssignmentExtension();
[Serializable()]
partial class FolderAssignmentExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
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 FolderAssignmentConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FolderAssignment)
{
// Return the ToString value
return ((FolderAssignment)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create FolderAssignmentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class FolderAssignment
// {
// partial class FolderAssignmentExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FolderAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FolderAssignmentsConverter))]
public partial class FolderAssignments : BusinessListBase<FolderAssignments, FolderAssignment>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public FolderAssignment this[Assignment myAssignment]
{
get
{
foreach (FolderAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return assignment;
return null;
}
}
public new System.Collections.Generic.IList<FolderAssignment> Items
{
get { return base.Items; }
}
public FolderAssignment GetItem(Assignment myAssignment)
{
foreach (FolderAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return assignment;
return null;
}
public FolderAssignment Add(Group myGroup, Role myRole) // One to Many
{
FolderAssignment assignment = FolderAssignment.New(myGroup, myRole);
this.Add(assignment);
return assignment;
}
public void Remove(Assignment myAssignment)
{
foreach (FolderAssignment assignment in this)
{
if (assignment.AID == myAssignment.AID)
{
Remove(assignment);
break;
}
}
}
public bool Contains(Assignment myAssignment)
{
foreach (FolderAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return true;
return false;
}
public bool ContainsDeleted(Assignment myAssignment)
{
foreach (FolderAssignment assignment in DeletedList)
if (assignment.AID == myAssignment.AID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(FolderAssignment folderAssignment in this)
if ((hasBrokenRules = folderAssignment.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static FolderAssignments New()
{
return new FolderAssignments();
}
internal static FolderAssignments Get(SafeDataReader dr)
{
return new FolderAssignments(dr);
}
public static FolderAssignments GetByFolderID(int folderID)
{
try
{
return DataPortal.Fetch<FolderAssignments>(new FolderIDCriteria(folderID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on FolderAssignments.GetByFolderID", ex);
}
}
private FolderAssignments()
{
MarkAsChild();
}
internal FolderAssignments(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(FolderAssignment.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class FolderIDCriteria
{
public FolderIDCriteria(int folderID)
{
_FolderID = folderID;
}
private int _FolderID;
public int FolderID
{
get { return _FolderID; }
set { _FolderID = value; }
}
}
private void DataPortal_Fetch(FolderIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderAssignments.DataPortal_FetchFolderID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAssignmentsByFolderID";
cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new FolderAssignment(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderAssignments.DataPortal_FetchFolderID", ex);
throw new DbCslaException("FolderAssignments.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Folder folder)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (FolderAssignment obj in DeletedList)
obj.DeleteSelf(folder);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (FolderAssignment obj in this)
{
if (obj.IsNew)
obj.Insert(folder);
else
obj.Update(folder);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
FolderAssignmentsPropertyDescriptor pd = new FolderAssignmentsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class FolderAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
{
private FolderAssignment Item { get { return (FolderAssignment) _Item;} }
public FolderAssignmentsPropertyDescriptor(FolderAssignments collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class FolderAssignmentsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FolderAssignments)
{
// Return department and department role separated by comma.
return ((FolderAssignments) value).Items.Count.ToString() + " Assignments";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,583 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FolderDocVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FolderDocVersionConverter))]
public partial class FolderDocVersion : BusinessBase<FolderDocVersion>, 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 int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionType",true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("VersionType",true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Name",true);
if (value == null) value = string.Empty;
if (_Name != value)
{
_Name = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Title",true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private 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 != null) _MyItem = Item.Get((int)_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItem",true);
if (_MyItem != value)
{
_MyItem = value;
_ItemID = (value == null ? null : (int?) value.ItemID);
PropertyHasChanged();
}
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
}
private Format _MyFormat;
public Format MyFormat
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFormat",true);
if (_MyFormat != value)
{
_MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID);
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 FolderDocVersion.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 FolderDocVersion</returns>
protected override object GetIdValue()
{
return _VersionID;
}
// TODO: Replace base FolderDocVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FolderDocVersion</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;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.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(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FormatID, "<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 FolderDocVersion New(string name)
{
return new FolderDocVersion(name);
}
internal static FolderDocVersion Get(SafeDataReader dr)
{
return new FolderDocVersion(dr);
}
public FolderDocVersion()
{
MarkAsChild();
_VersionID = DocVersion.NextVersionID;
_VersionType = _FolderDocVersionExtension.DefaultVersionType;
_DTS = _FolderDocVersionExtension.DefaultDTS;
_UserID = _FolderDocVersionExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private FolderDocVersion(string name)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_VersionType = _FolderDocVersionExtension.DefaultVersionType;
_DTS = _FolderDocVersionExtension.DefaultDTS;
_UserID = _FolderDocVersionExtension.DefaultUserID;
_Name = name;
ValidationRules.CheckRules();
}
internal FolderDocVersion(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderDocVersion.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ItemID = (int?)dr.GetValue("ItemID");
_FormatID = (int?)dr.GetValue("FormatID");
_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("FolderDocVersion.FetchDR", ex);
throw new DbCslaException("FolderDocVersion.Fetch", ex);
}
MarkOld();
}
internal void Insert(Folder myFolder)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersion.Add(cn, ref _VersionID, myFolder, _VersionType, _Name, _Title, _MyItem, _MyFormat, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Folder myFolder)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersion.Update(cn, ref _VersionID, myFolder, _VersionType, _Name, _Title, _MyItem, _MyFormat, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Folder myFolder)
{
// 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"];
DocVersion.Remove(cn, _VersionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FolderDocVersionExtension _FolderDocVersionExtension = new FolderDocVersionExtension();
[Serializable()]
partial class FolderDocVersionExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultVersionType
{
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 FolderDocVersionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FolderDocVersion)
{
// Return the ToString value
return ((FolderDocVersion)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create FolderDocVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class FolderDocVersion
// {
// partial class FolderDocVersionExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultVersionType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FolderDocVersions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FolderDocVersionsConverter))]
public partial class FolderDocVersions : BusinessListBase<FolderDocVersions, FolderDocVersion>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public FolderDocVersion this[DocVersion myDocVersion]
{
get
{
foreach (FolderDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return docVersion;
return null;
}
}
public new System.Collections.Generic.IList<FolderDocVersion> Items
{
get { return base.Items; }
}
public FolderDocVersion GetItem(DocVersion myDocVersion)
{
foreach (FolderDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return docVersion;
return null;
}
public FolderDocVersion Add(string name) // One to Many
{
FolderDocVersion docVersion = FolderDocVersion.New(name);
this.Add(docVersion);
return docVersion;
}
public void Remove(DocVersion myDocVersion)
{
foreach (FolderDocVersion docVersion in this)
{
if (docVersion.VersionID == myDocVersion.VersionID)
{
Remove(docVersion);
break;
}
}
}
public bool Contains(DocVersion myDocVersion)
{
foreach (FolderDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return true;
return false;
}
public bool ContainsDeleted(DocVersion myDocVersion)
{
foreach (FolderDocVersion docVersion in DeletedList)
if (docVersion.VersionID == myDocVersion.VersionID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(FolderDocVersion folderDocVersion in this)
if ((hasBrokenRules = folderDocVersion.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static FolderDocVersions New()
{
return new FolderDocVersions();
}
internal static FolderDocVersions Get(SafeDataReader dr)
{
return new FolderDocVersions(dr);
}
public static FolderDocVersions GetByFolderID(int folderID)
{
try
{
return DataPortal.Fetch<FolderDocVersions>(new FolderIDCriteria(folderID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on FolderDocVersions.GetByFolderID", ex);
}
}
private FolderDocVersions()
{
MarkAsChild();
}
internal FolderDocVersions(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(FolderDocVersion.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class FolderIDCriteria
{
public FolderIDCriteria(int folderID)
{
_FolderID = folderID;
}
private int _FolderID;
public int FolderID
{
get { return _FolderID; }
set { _FolderID = value; }
}
}
private void DataPortal_Fetch(FolderIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderDocVersions.DataPortal_FetchFolderID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocVersionsByFolderID";
cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new FolderDocVersion(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderDocVersions.DataPortal_FetchFolderID", ex);
throw new DbCslaException("FolderDocVersions.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Folder folder)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (FolderDocVersion obj in DeletedList)
obj.DeleteSelf(folder);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (FolderDocVersion obj in this)
{
if (obj.IsNew)
obj.Insert(folder);
else
obj.Update(folder);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
FolderDocVersionsPropertyDescriptor pd = new FolderDocVersionsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class FolderDocVersionsPropertyDescriptor : vlnListPropertyDescriptor
{
private FolderDocVersion Item { get { return (FolderDocVersion) _Item;} }
public FolderDocVersionsPropertyDescriptor(FolderDocVersions collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class FolderDocVersionsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FolderDocVersions)
{
// Return department and department role separated by comma.
return ((FolderDocVersions) value).Items.Count.ToString() + " DocVersions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,531 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void FolderInfoEvent(object sender);
/// <summary>
/// FolderInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FolderInfoConverter))]
public partial class FolderInfo : ReadOnlyBase<FolderInfo>, IDisposable
{
public event FolderInfoEvent 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
protected static List<FolderInfo> _AllList = new List<FolderInfo>();
private static Dictionary<string, FolderInfo> _AllByPrimaryKey = new Dictionary<string, FolderInfo>();
private static void ConvertListToDictionary()
{
List<FolderInfo> remove = new List<FolderInfo>();
foreach (FolderInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.FolderID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (FolderInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(FolderInfoList lst)
{
foreach (FolderInfo item in lst) _AllList.Add(item);
}
public static FolderInfo GetExistingByPrimaryKey(int folderID)
{
ConvertListToDictionary();
string key = folderID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Folder _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _FolderID;
[System.ComponentModel.DataObjectField(true, true)]
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
return _FolderID;
}
}
private int _ParentID;
public int ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ParentID",true);
if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID;
}
}
private FolderInfo _MyParent;
public FolderInfo MyParent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyParent",true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = FolderInfo.Get(_ParentID);
return _MyParent;
}
}
private int _DBID;
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DBID",true);
if (_MyConnection != null) _DBID = _MyConnection.DBID;
return _DBID;
}
}
private ConnectionInfo _MyConnection;
public ConnectionInfo MyConnection
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyConnection",true);
if (_MyConnection == null && _DBID != 0) _MyConnection = ConnectionInfo.Get(_DBID);
return _MyConnection;
}
}
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 _ShortName = string.Empty;
public string ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ShortName",true);
return _ShortName;
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
}
private FormatInfo _MyFormat;
public FormatInfo MyFormat
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
if (_MyFormat == null && _FormatID != null) _MyFormat = FormatInfo.Get((int)_FormatID);
return _MyFormat;
}
}
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 _FolderAssignmentCount = 0;
/// <summary>
/// Count of FolderAssignments for this Folder
/// </summary>
public int FolderAssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderAssignmentCount",true);
return _FolderAssignmentCount;
}
}
private AssignmentInfoList _FolderAssignments = null;
[TypeConverter(typeof(AssignmentInfoListConverter))]
public AssignmentInfoList FolderAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderAssignments",true);
if (_FolderAssignmentCount > 0 && _FolderAssignments == null)
_FolderAssignments = AssignmentInfoList.GetByFolderID(_FolderID);
return _FolderAssignments;
}
}
private int _FolderDocVersionCount = 0;
/// <summary>
/// Count of FolderDocVersions for this Folder
/// </summary>
public int FolderDocVersionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderDocVersionCount",true);
return _FolderDocVersionCount;
}
}
private DocVersionInfoList _FolderDocVersions = null;
[TypeConverter(typeof(DocVersionInfoListConverter))]
public DocVersionInfoList FolderDocVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderDocVersions",true);
if (_FolderDocVersionCount > 0 && _FolderDocVersions == null)
_FolderDocVersions = DocVersionInfoList.GetByFolderID(_FolderID);
return _FolderDocVersions;
}
}
private int _ChildFolderCount = 0;
/// <summary>
/// Count of ChildFolders for this Folder
/// </summary>
public int ChildFolderCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ChildFolderCount",true);
return _ChildFolderCount;
}
}
private FolderInfoList _ChildFolders = null;
[TypeConverter(typeof(FolderInfoListConverter))]
public FolderInfoList ChildFolders
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ChildFolders",true);
if (_ChildFolderCount > 0 && _ChildFolders == null)
_ChildFolders = FolderInfoList.GetChildren(_FolderID);
return _ChildFolders;
}
}
// TODO: Replace base FolderInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FolderInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check FolderInfo.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 FolderInfo</returns>
protected override object GetIdValue()
{
return _FolderID;
}
#endregion
#region Factory Methods
private FolderInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(FolderID.ToString());
}
public virtual Folder Get()
{
return _Editable = Folder.Get(_FolderID);
}
public static void Refresh(Folder tmp)
{
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Folder tmp)
{
_ParentID = tmp.ParentID;
_DBID = tmp.DBID;
_Name = tmp.Name;
_Title = tmp.Title;
_ShortName = tmp.ShortName;
_FormatID = tmp.FormatID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_FolderInfoExtension.Refresh(this);
_MyParent = null;
_MyConnection = null;
_MyFormat = null;
OnChange();// raise an event
}
public static void Refresh(ConnectionFolder tmp)
{
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ConnectionFolder tmp)
{
_ParentID = tmp.ParentID;
_Name = tmp.Name;
_Title = tmp.Title;
_ShortName = tmp.ShortName;
_FormatID = tmp.FormatID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_FolderInfoExtension.Refresh(this);
_MyParent = null;
_MyConnection = null;
_MyFormat = null;
OnChange();// raise an event
}
public static void Refresh(FormatFolder tmp)
{
FolderInfo tmpInfo = GetExistingByPrimaryKey(tmp.FolderID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(FormatFolder tmp)
{
_ParentID = tmp.ParentID;
_DBID = tmp.DBID;
_Name = tmp.Name;
_Title = tmp.Title;
_ShortName = tmp.ShortName;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_FolderInfoExtension.Refresh(this);
_MyParent = null;
_MyConnection = null;
_MyFormat = null;
OnChange();// raise an event
}
public static FolderInfo Get(int folderID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Folder");
try
{
FolderInfo tmp = GetExistingByPrimaryKey(folderID);
if (tmp == null)
{
tmp = DataPortal.Fetch<FolderInfo>(new PKCriteria(folderID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FolderInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal FolderInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.Constructor", ex);
throw new DbCslaException("FolderInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _FolderID;
public int FolderID
{ get { return _FolderID; } }
public PKCriteria(int folderID)
{
_FolderID = folderID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.ReadData", GetHashCode());
try
{
_FolderID = dr.GetInt32("FolderID");
_ParentID = dr.GetInt32("ParentID");
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ShortName = dr.GetString("ShortName");
_FormatID = (int?)dr.GetValue("FormatID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_FolderAssignmentCount = dr.GetInt32("AssignmentCount");
_FolderDocVersionCount = dr.GetInt32("DocVersionCount");
_ChildFolderCount = dr.GetInt32("ChildCount");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("FolderInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFolder";
cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
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("FolderInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("FolderInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
FolderInfoExtension _FolderInfoExtension = new FolderInfoExtension();
[Serializable()]
partial class FolderInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(FolderInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class FolderInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FolderInfo)
{
// Return the ToString value
return ((FolderInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,488 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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
} // Namespace
//// The following is a sample Extension File. You can use it to create FormatContentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class FormatContent
// {
// partial class FormatContentExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FormatContents Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatContentsConverter))]
public partial class FormatContents : BusinessListBase<FormatContents, FormatContent>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public FormatContent this[Content myContent]
{
get
{
foreach (FormatContent content in this)
if (content.ContentID == myContent.ContentID)
return content;
return null;
}
}
public new System.Collections.Generic.IList<FormatContent> Items
{
get { return base.Items; }
}
public FormatContent GetItem(Content myContent)
{
foreach (FormatContent content in this)
if (content.ContentID == myContent.ContentID)
return content;
return null;
}
public FormatContent Add() // One to Many
{
FormatContent content = FormatContent.New();
this.Add(content);
return content;
}
public void Remove(Content myContent)
{
foreach (FormatContent content in this)
{
if (content.ContentID == myContent.ContentID)
{
Remove(content);
break;
}
}
}
public bool Contains(Content myContent)
{
foreach (FormatContent content in this)
if (content.ContentID == myContent.ContentID)
return true;
return false;
}
public bool ContainsDeleted(Content myContent)
{
foreach (FormatContent content in DeletedList)
if (content.ContentID == myContent.ContentID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(FormatContent formatContent in this)
if ((hasBrokenRules = formatContent.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static FormatContents New()
{
return new FormatContents();
}
internal static FormatContents Get(SafeDataReader dr)
{
return new FormatContents(dr);
}
public static FormatContents GetByFormatID(int formatID)
{
try
{
return DataPortal.Fetch<FormatContents>(new FormatIDCriteria(formatID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on FormatContents.GetByFormatID", ex);
}
}
private FormatContents()
{
MarkAsChild();
}
internal FormatContents(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(FormatContent.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class FormatIDCriteria
{
public FormatIDCriteria(int formatID)
{
_FormatID = formatID;
}
private int _FormatID;
public int FormatID
{
get { return _FormatID; }
set { _FormatID = value; }
}
}
private void DataPortal_Fetch(FormatIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatContents.DataPortal_FetchFormatID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getContentsByFormatID";
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new FormatContent(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatContents.DataPortal_FetchFormatID", ex);
throw new DbCslaException("FormatContents.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Format format)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (FormatContent obj in DeletedList)
obj.DeleteSelf(format);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (FormatContent obj in this)
{
if (obj.IsNew)
obj.Insert(format);
else
obj.Update(format);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
FormatContentsPropertyDescriptor pd = new FormatContentsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class FormatContentsPropertyDescriptor : vlnListPropertyDescriptor
{
private FormatContent Item { get { return (FormatContent) _Item;} }
public FormatContentsPropertyDescriptor(FormatContents collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class FormatContentsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatContents)
{
// Return department and department role separated by comma.
return ((FormatContents) value).Items.Count.ToString() + " Contents";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,700 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FormatDocVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatDocVersionConverter))]
public partial class FormatDocVersion : BusinessBase<FormatDocVersion>, 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 int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFolder",true);
if (_MyFolder != value)
{
_MyFolder = value;
PropertyHasChanged();
}
}
}
private int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionType",true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("VersionType",true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Name",true);
if (value == null) value = string.Empty;
if (_Name != value)
{
_Name = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Title",true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private 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 != null) _MyItem = Item.Get((int)_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItem",true);
if (_MyItem != value)
{
_MyItem = value;
_ItemID = (value == null ? null : (int?) value.ItemID);
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 _Folder_ParentID;
public int Folder_ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ParentID",true);
return _Folder_ParentID;
}
}
private int _Folder_DBID;
public int Folder_DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DBID",true);
return _Folder_DBID;
}
}
private string _Folder_Name = string.Empty;
public string Folder_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Name",true);
return _Folder_Name;
}
}
private string _Folder_Title = string.Empty;
public string Folder_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Title",true);
return _Folder_Title;
}
}
private string _Folder_ShortName = string.Empty;
public string Folder_ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ShortName",true);
return _Folder_ShortName;
}
}
private int? _Folder_FormatID;
public int? Folder_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_FormatID",true);
return _Folder_FormatID;
}
}
private string _Folder_Config = string.Empty;
public string Folder_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Config",true);
return _Folder_Config;
}
}
private DateTime _Folder_DTS = new DateTime();
public DateTime Folder_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DTS",true);
return _Folder_DTS;
}
}
private string _Folder_UsrID = string.Empty;
public string Folder_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_UsrID",true);
return _Folder_UsrID;
}
}
// TODO: Check FormatDocVersion.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 FormatDocVersion</returns>
protected override object GetIdValue()
{
return _VersionID;
}
// TODO: Replace base FormatDocVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FormatDocVersion</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.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 (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
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<FormatDocVersion>(MyFolderRequired, "MyFolder");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.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 MyFolderRequired(FormatDocVersion target, Csla.Validation.RuleArgs e)
{
if (target._FolderID == 0 && target._MyFolder == 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(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<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 FormatDocVersion New(Folder myFolder, string name)
{
return new FormatDocVersion(myFolder, name);
}
internal static FormatDocVersion Get(SafeDataReader dr)
{
return new FormatDocVersion(dr);
}
public FormatDocVersion()
{
MarkAsChild();
_VersionID = DocVersion.NextVersionID;
_VersionType = _FormatDocVersionExtension.DefaultVersionType;
_DTS = _FormatDocVersionExtension.DefaultDTS;
_UserID = _FormatDocVersionExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private FormatDocVersion(Folder myFolder, string name)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_VersionType = _FormatDocVersionExtension.DefaultVersionType;
_DTS = _FormatDocVersionExtension.DefaultDTS;
_UserID = _FormatDocVersionExtension.DefaultUserID;
_MyFolder = myFolder;
_Name = name;
ValidationRules.CheckRules();
}
internal FormatDocVersion(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatDocVersion.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_FolderID = dr.GetInt32("FolderID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ItemID = (int?)dr.GetValue("ItemID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Folder_ParentID = dr.GetInt32("Folder_ParentID");
_Folder_DBID = dr.GetInt32("Folder_DBID");
_Folder_Name = dr.GetString("Folder_Name");
_Folder_Title = dr.GetString("Folder_Title");
_Folder_ShortName = dr.GetString("Folder_ShortName");
_Folder_FormatID = (int?)dr.GetValue("Folder_FormatID");
_Folder_Config = dr.GetString("Folder_Config");
_Folder_DTS = dr.GetDateTime("Folder_DTS");
_Folder_UsrID = dr.GetString("Folder_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatDocVersion.FetchDR", ex);
throw new DbCslaException("FormatDocVersion.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 = DocVersion.Add(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, _MyItem, 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 = DocVersion.Update(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, _MyItem, 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"];
DocVersion.Remove(cn, _VersionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FormatDocVersionExtension _FormatDocVersionExtension = new FormatDocVersionExtension();
[Serializable()]
partial class FormatDocVersionExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultVersionType
{
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 FormatDocVersionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatDocVersion)
{
// Return the ToString value
return ((FormatDocVersion)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create FormatDocVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class FormatDocVersion
// {
// partial class FormatDocVersionExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultVersionType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FormatDocVersions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatDocVersionsConverter))]
public partial class FormatDocVersions : BusinessListBase<FormatDocVersions, FormatDocVersion>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public FormatDocVersion this[DocVersion myDocVersion]
{
get
{
foreach (FormatDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return docVersion;
return null;
}
}
public new System.Collections.Generic.IList<FormatDocVersion> Items
{
get { return base.Items; }
}
public FormatDocVersion GetItem(DocVersion myDocVersion)
{
foreach (FormatDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return docVersion;
return null;
}
public FormatDocVersion Add(Folder myFolder, string name) // One to Many
{
FormatDocVersion docVersion = FormatDocVersion.New(myFolder, name);
this.Add(docVersion);
return docVersion;
}
public void Remove(DocVersion myDocVersion)
{
foreach (FormatDocVersion docVersion in this)
{
if (docVersion.VersionID == myDocVersion.VersionID)
{
Remove(docVersion);
break;
}
}
}
public bool Contains(DocVersion myDocVersion)
{
foreach (FormatDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return true;
return false;
}
public bool ContainsDeleted(DocVersion myDocVersion)
{
foreach (FormatDocVersion docVersion in DeletedList)
if (docVersion.VersionID == myDocVersion.VersionID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(FormatDocVersion formatDocVersion in this)
if ((hasBrokenRules = formatDocVersion.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static FormatDocVersions New()
{
return new FormatDocVersions();
}
internal static FormatDocVersions Get(SafeDataReader dr)
{
return new FormatDocVersions(dr);
}
public static FormatDocVersions GetByFormatID(int formatID)
{
try
{
return DataPortal.Fetch<FormatDocVersions>(new FormatIDCriteria(formatID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on FormatDocVersions.GetByFormatID", ex);
}
}
private FormatDocVersions()
{
MarkAsChild();
}
internal FormatDocVersions(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(FormatDocVersion.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class FormatIDCriteria
{
public FormatIDCriteria(int formatID)
{
_FormatID = formatID;
}
private int _FormatID;
public int FormatID
{
get { return _FormatID; }
set { _FormatID = value; }
}
}
private void DataPortal_Fetch(FormatIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatDocVersions.DataPortal_FetchFormatID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocVersionsByFormatID";
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new FormatDocVersion(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatDocVersions.DataPortal_FetchFormatID", ex);
throw new DbCslaException("FormatDocVersions.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Format format)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (FormatDocVersion obj in DeletedList)
obj.DeleteSelf(format);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (FormatDocVersion obj in this)
{
if (obj.IsNew)
obj.Insert(format);
else
obj.Update(format);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
FormatDocVersionsPropertyDescriptor pd = new FormatDocVersionsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class FormatDocVersionsPropertyDescriptor : vlnListPropertyDescriptor
{
private FormatDocVersion Item { get { return (FormatDocVersion) _Item;} }
public FormatDocVersionsPropertyDescriptor(FormatDocVersions collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class FormatDocVersionsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatDocVersions)
{
// Return department and department role separated by comma.
return ((FormatDocVersions) value).Items.Count.ToString() + " DocVersions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,704 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FormatFolder Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatFolderConverter))]
public partial class FormatFolder : BusinessBase<FormatFolder>, 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 _FolderID;
[System.ComponentModel.DataObjectField(true, true)]
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
[System.ComponentModel.DataObjectField(true, true)]
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
}
private int _ParentID;
public int ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ParentID",true);
if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID;
}
}
private Folder _MyParent;
public Folder MyParent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyParent",true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID);
return _MyParent;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyParent",true);
if (_MyParent != value)
{
_MyParent = value;
PropertyHasChanged();
}
}
}
private int _DBID;
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DBID",true);
if (_MyConnection != null) _DBID = _MyConnection.DBID;
return _DBID;
}
}
private Connection _MyConnection;
public Connection MyConnection
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyConnection",true);
if (_MyConnection == null && _DBID != 0) _MyConnection = Connection.Get(_DBID);
return _MyConnection;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyConnection",true);
if (_MyConnection != value)
{
_MyConnection = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Name",true);
if (value == null) value = string.Empty;
if (_Name != value)
{
_Name = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Title",true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private string _ShortName = string.Empty;
public string ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ShortName",true);
return _ShortName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ShortName",true);
if (value == null) value = string.Empty;
if (_ShortName != value)
{
_ShortName = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID",true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Connection_Name = string.Empty;
public string Connection_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Connection_Name",true);
return _Connection_Name;
}
}
private string _Connection_Title = string.Empty;
public string Connection_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Connection_Title",true);
return _Connection_Title;
}
}
private string _Connection_ConnectionString = string.Empty;
public string Connection_ConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Connection_ConnectionString",true);
return _Connection_ConnectionString;
}
}
private int _Connection_ServerType;
/// <summary>
/// 0 SQL Server
/// </summary>
public int Connection_ServerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Connection_ServerType",true);
return _Connection_ServerType;
}
}
private string _Connection_Config = string.Empty;
public string Connection_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Connection_Config",true);
return _Connection_Config;
}
}
private DateTime _Connection_DTS = new DateTime();
public DateTime Connection_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Connection_DTS",true);
return _Connection_DTS;
}
}
private string _Connection_UsrID = string.Empty;
public string Connection_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Connection_UsrID",true);
return _Connection_UsrID;
}
}
// TODO: Check FormatFolder.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 FormatFolder</returns>
protected override object GetIdValue()
{
return _FolderID;
}
// TODO: Replace base FormatFolder.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FormatFolder</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirty) || (_MyConnection == null ? false : _MyConnection.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.IsValid) && (_MyConnection == null ? true : _MyConnection.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 (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyConnection != null && (hasBrokenRules = _MyConnection.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<FormatFolder>(MyFolderRequired, "MyFolder");
ValidationRules.AddRule<FormatFolder>(MyConnectionRequired, "MyConnection");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "ShortName");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ShortName", 20));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private static bool MyFolderRequired(FormatFolder target, Csla.Validation.RuleArgs e)
{
if (target._ParentID == 0 && target._MyFolder == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
private static bool MyConnectionRequired(FormatFolder target, Csla.Validation.RuleArgs e)
{
if (target._DBID == 0 && target._MyConnection == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
//AuthorizationRules.AllowRead(DBID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DBID, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ShortName, "<Role(s)>");
//AuthorizationRules.AllowWrite(ShortName, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<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 FormatFolder New(Folder myParent, string name, string shortName)
{
return new FormatFolder(myParent, name, shortName);
}
internal static FormatFolder Get(SafeDataReader dr)
{
return new FormatFolder(dr);
}
public FormatFolder()
{
MarkAsChild();
_FolderID = Folder.NextFolderID;
_ParentID = _FormatFolderExtension.DefaultParentID;
_DBID = _FormatFolderExtension.DefaultDBID;
_DTS = _FormatFolderExtension.DefaultDTS;
_UsrID = _FormatFolderExtension.DefaultUsrID;
ValidationRules.CheckRules();
}
private FormatFolder(Folder myParent, string name, string shortName)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_ParentID = _FormatFolderExtension.DefaultParentID;
_DBID = _FormatFolderExtension.DefaultDBID;
_DTS = _FormatFolderExtension.DefaultDTS;
_UsrID = _FormatFolderExtension.DefaultUsrID;
_MyParent = myParent;
_Name = name;
_ShortName = shortName;
ValidationRules.CheckRules();
}
internal FormatFolder(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatFolder.FetchDR", GetHashCode());
try
{
_FolderID = dr.GetInt32("FolderID");
_ParentID = dr.GetInt32("ParentID");
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ShortName = dr.GetString("ShortName");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Connection_Name = dr.GetString("Connection_Name");
_Connection_Title = dr.GetString("Connection_Title");
_Connection_ConnectionString = dr.GetString("Connection_ConnectionString");
_Connection_ServerType = dr.GetInt32("Connection_ServerType");
_Connection_Config = dr.GetString("Connection_Config");
_Connection_DTS = dr.GetDateTime("Connection_DTS");
_Connection_UsrID = dr.GetString("Connection_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatFolder.FetchDR", ex);
throw new DbCslaException("FormatFolder.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 = Folder.Add(cn, ref _FolderID, Folder.Get(_ParentID), _MyConnection, _Name, _Title, _ShortName, myFormat, _Config, _DTS, _UsrID);
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 = Folder.Update(cn, ref _FolderID, Folder.Get(_ParentID), _MyConnection, _Name, _Title, _ShortName, myFormat, _Config, _DTS, _UsrID, 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"];
Folder.Remove(cn, _FolderID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FormatFolderExtension _FormatFolderExtension = new FormatFolderExtension();
[Serializable()]
partial class FormatFolderExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultParentID
{
get { return 1; }
}
public virtual int DefaultDBID
{
get { return 1; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return 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 FormatFolderConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatFolder)
{
// Return the ToString value
return ((FormatFolder)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create FormatFolderExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class FormatFolder
// {
// partial class FormatFolderExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultParentID
// {
// get { return 1; }
// }
// public virtual int DefaultDBID
// {
// get { return 1; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FormatFolders Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatFoldersConverter))]
public partial class FormatFolders : BusinessListBase<FormatFolders, FormatFolder>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public FormatFolder this[Folder myFolder]
{
get
{
foreach (FormatFolder folder in this)
if (folder.FolderID == myFolder.FolderID)
return folder;
return null;
}
}
public new System.Collections.Generic.IList<FormatFolder> Items
{
get { return base.Items; }
}
public FormatFolder GetItem(Folder myFolder)
{
foreach (FormatFolder folder in this)
if (folder.FolderID == myFolder.FolderID)
return folder;
return null;
}
public FormatFolder Add(Folder myParent, string name, string shortName) // One to Many
{
FormatFolder folder = FormatFolder.New(myParent, name, shortName);
this.Add(folder);
return folder;
}
public void Remove(Folder myFolder)
{
foreach (FormatFolder folder in this)
{
if (folder.FolderID == myFolder.FolderID)
{
Remove(folder);
break;
}
}
}
public bool Contains(Folder myFolder)
{
foreach (FormatFolder folder in this)
if (folder.FolderID == myFolder.FolderID)
return true;
return false;
}
public bool ContainsDeleted(Folder myFolder)
{
foreach (FormatFolder folder in DeletedList)
if (folder.FolderID == myFolder.FolderID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(FormatFolder formatFolder in this)
if ((hasBrokenRules = formatFolder.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static FormatFolders New()
{
return new FormatFolders();
}
internal static FormatFolders Get(SafeDataReader dr)
{
return new FormatFolders(dr);
}
public static FormatFolders GetByFormatID(int formatID)
{
try
{
return DataPortal.Fetch<FormatFolders>(new FormatIDCriteria(formatID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on FormatFolders.GetByFormatID", ex);
}
}
private FormatFolders()
{
MarkAsChild();
}
internal FormatFolders(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(FormatFolder.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class FormatIDCriteria
{
public FormatIDCriteria(int formatID)
{
_FormatID = formatID;
}
private int _FormatID;
public int FormatID
{
get { return _FormatID; }
set { _FormatID = value; }
}
}
private void DataPortal_Fetch(FormatIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatFolders.DataPortal_FetchFormatID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFoldersByFormatID";
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new FormatFolder(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatFolders.DataPortal_FetchFormatID", ex);
throw new DbCslaException("FormatFolders.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Format format)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (FormatFolder obj in DeletedList)
obj.DeleteSelf(format);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (FormatFolder obj in this)
{
if (obj.IsNew)
obj.Insert(format);
else
obj.Update(format);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
FormatFoldersPropertyDescriptor pd = new FormatFoldersPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class FormatFoldersPropertyDescriptor : vlnListPropertyDescriptor
{
private FormatFolder Item { get { return (FormatFolder) _Item;} }
public FormatFoldersPropertyDescriptor(FormatFolders collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class FormatFoldersConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatFolders)
{
// Return department and department role separated by comma.
return ((FormatFolders) value).Items.Count.ToString() + " Folders";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,464 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void FormatInfoEvent(object sender);
/// <summary>
/// FormatInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatInfoConverter))]
public partial class FormatInfo : ReadOnlyBase<FormatInfo>, IDisposable
{
public event FormatInfoEvent 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
protected static List<FormatInfo> _AllList = new List<FormatInfo>();
private static Dictionary<string, FormatInfo> _AllByPrimaryKey = new Dictionary<string, FormatInfo>();
private static void ConvertListToDictionary()
{
List<FormatInfo> remove = new List<FormatInfo>();
foreach (FormatInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.FormatID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (FormatInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(FormatInfoList lst)
{
foreach (FormatInfo item in lst) _AllList.Add(item);
}
public static FormatInfo GetExistingByPrimaryKey(int formatID)
{
ConvertListToDictionary();
string key = formatID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Format _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _FormatID;
[System.ComponentModel.DataObjectField(true, true)]
public int FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
return _FormatID;
}
}
private int _ParentID;
public int ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ParentID",true);
if (_MyParent != null) _ParentID = _MyParent.FormatID;
return _ParentID;
}
}
private FormatInfo _MyParent;
public FormatInfo MyParent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyParent",true);
if (_MyParent == null && _ParentID != _FormatID) _MyParent = FormatInfo.Get(_ParentID);
return _MyParent;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
}
private string _Description = string.Empty;
public string Description
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Description",true);
return _Description;
}
}
private string _Data = string.Empty;
public string Data
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Data",true);
return _Data;
}
}
private string _GenMac = string.Empty;
public string GenMac
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GenMac",true);
return _GenMac;
}
}
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 _FormatContentCount = 0;
/// <summary>
/// Count of FormatContents for this Format
/// </summary>
public int FormatContentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatContentCount",true);
return _FormatContentCount;
}
}
private ContentInfoList _FormatContents = null;
[TypeConverter(typeof(ContentInfoListConverter))]
public ContentInfoList FormatContents
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatContents",true);
if (_FormatContentCount > 0 && _FormatContents == null)
_FormatContents = ContentInfoList.GetByFormatID(_FormatID);
return _FormatContents;
}
}
private int _FormatDocVersionCount = 0;
/// <summary>
/// Count of FormatDocVersions for this Format
/// </summary>
public int FormatDocVersionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatDocVersionCount",true);
return _FormatDocVersionCount;
}
}
private DocVersionInfoList _FormatDocVersions = null;
[TypeConverter(typeof(DocVersionInfoListConverter))]
public DocVersionInfoList FormatDocVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatDocVersions",true);
if (_FormatDocVersionCount > 0 && _FormatDocVersions == null)
_FormatDocVersions = DocVersionInfoList.GetByFormatID(_FormatID);
return _FormatDocVersions;
}
}
private int _FormatFolderCount = 0;
/// <summary>
/// Count of FormatFolders for this Format
/// </summary>
public int FormatFolderCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatFolderCount",true);
return _FormatFolderCount;
}
}
private FolderInfoList _FormatFolders = null;
[TypeConverter(typeof(FolderInfoListConverter))]
public FolderInfoList FormatFolders
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatFolders",true);
if (_FormatFolderCount > 0 && _FormatFolders == null)
_FormatFolders = FolderInfoList.GetByFormatID(_FormatID);
return _FormatFolders;
}
}
private int _ChildFormatCount = 0;
/// <summary>
/// Count of ChildFormats for this Format
/// </summary>
public int ChildFormatCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ChildFormatCount",true);
return _ChildFormatCount;
}
}
private FormatInfoList _ChildFormats = null;
[TypeConverter(typeof(FormatInfoListConverter))]
public FormatInfoList ChildFormats
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ChildFormats",true);
if (_ChildFormatCount > 0 && _ChildFormats == null)
_ChildFormats = FormatInfoList.GetChildren(_FormatID);
return _ChildFormats;
}
}
// TODO: Replace base FormatInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FormatInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check FormatInfo.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 FormatInfo</returns>
protected override object GetIdValue()
{
return _FormatID;
}
#endregion
#region Factory Methods
private FormatInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(FormatID.ToString());
}
public virtual Format Get()
{
return _Editable = Format.Get(_FormatID);
}
public static void Refresh(Format tmp)
{
FormatInfo tmpInfo = GetExistingByPrimaryKey(tmp.FormatID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Format tmp)
{
_ParentID = tmp.ParentID;
_Name = tmp.Name;
_Description = tmp.Description;
_Data = tmp.Data;
_GenMac = tmp.GenMac;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_FormatInfoExtension.Refresh(this);
_MyParent = null;
OnChange();// raise an event
}
public static FormatInfo Get(int formatID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Format");
try
{
FormatInfo tmp = GetExistingByPrimaryKey(formatID);
if (tmp == null)
{
tmp = DataPortal.Fetch<FormatInfo>(new PKCriteria(formatID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FormatInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal FormatInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfo.Constructor", ex);
throw new DbCslaException("FormatInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _FormatID;
public int FormatID
{ get { return _FormatID; } }
public PKCriteria(int formatID)
{
_FormatID = formatID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfo.ReadData", GetHashCode());
try
{
_FormatID = dr.GetInt32("FormatID");
_ParentID = dr.GetInt32("ParentID");
_Name = dr.GetString("Name");
_Description = dr.GetString("Description");
_Data = dr.GetString("Data");
_GenMac = dr.GetString("GenMac");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_FormatContentCount = dr.GetInt32("ContentCount");
_FormatDocVersionCount = dr.GetInt32("DocVersionCount");
_FormatFolderCount = dr.GetInt32("FolderCount");
_ChildFormatCount = dr.GetInt32("ChildCount");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("FormatInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatInfo.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 = "getFormat";
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
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("FormatInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
FormatInfoExtension _FormatInfoExtension = new FormatInfoExtension();
[Serializable()]
partial class FormatInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(FormatInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class FormatInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatInfo)
{
// Return the ToString value
return ((FormatInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,740 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// GroupAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GroupAssignmentConverter))]
public partial class GroupAssignment : BusinessBase<GroupAssignment>, 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 _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AID",true);
if (_MyAssignment != null) _AID = _MyAssignment.AID;
return _AID;
}
}
private Assignment _MyAssignment;
[System.ComponentModel.DataObjectField(true, true)]
public Assignment MyAssignment
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAssignment",true);
if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID);
return _MyAssignment;
}
}
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 Role _MyRole;
public Role MyRole
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRole",true);
if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID);
return _MyRole;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyRole",true);
if (_MyRole != value)
{
_MyRole = value;
PropertyHasChanged();
}
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFolder",true);
if (_MyFolder != value)
{
_MyFolder = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StartDate",true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("StartDate",true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("EndDate",true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("EndDate",true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID",true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _Folder_ParentID;
public int Folder_ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ParentID",true);
return _Folder_ParentID;
}
}
private int _Folder_DBID;
public int Folder_DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DBID",true);
return _Folder_DBID;
}
}
private string _Folder_Name = string.Empty;
public string Folder_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Name",true);
return _Folder_Name;
}
}
private string _Folder_Title = string.Empty;
public string Folder_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Title",true);
return _Folder_Title;
}
}
private string _Folder_ShortName = string.Empty;
public string Folder_ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ShortName",true);
return _Folder_ShortName;
}
}
private int? _Folder_FormatID;
public int? Folder_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_FormatID",true);
return _Folder_FormatID;
}
}
private string _Folder_Config = string.Empty;
public string Folder_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Config",true);
return _Folder_Config;
}
}
private DateTime _Folder_DTS = new DateTime();
public DateTime Folder_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DTS",true);
return _Folder_DTS;
}
}
private string _Folder_UsrID = string.Empty;
public string Folder_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_UsrID",true);
return _Folder_UsrID;
}
}
private string _Role_Name = string.Empty;
public string Role_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Role_Name",true);
return _Role_Name;
}
}
private string _Role_Title = string.Empty;
public string Role_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Role_Title",true);
return _Role_Title;
}
}
private DateTime _Role_DTS = new DateTime();
public DateTime Role_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Role_DTS",true);
return _Role_DTS;
}
}
private string _Role_UsrID = string.Empty;
public string Role_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Role_UsrID",true);
return _Role_UsrID;
}
}
// TODO: Check GroupAssignment.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 GroupAssignment</returns>
protected override object GetIdValue()
{
return _AID;
}
// TODO: Replace base GroupAssignment.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupAssignment</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyRole == null ? false : _MyRole.IsDirty) || (_MyFolder == null ? false : _MyFolder.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyRole == null ? true : _MyRole.IsValid) && (_MyFolder == null ? true : _MyFolder.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 (_MyRole != null && (hasBrokenRules = _MyRole.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.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<GroupAssignment>(MyRoleRequired, "MyRole");
ValidationRules.AddRule<GroupAssignment>(MyFolderRequired, "MyFolder");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule<GroupAssignment>(StartDateValid, "StartDate");
ValidationRules.AddRule<GroupAssignment>(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private static bool StartDateValid(GroupAssignment target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool EndDateValid(GroupAssignment target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._EndDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool MyRoleRequired(GroupAssignment target, Csla.Validation.RuleArgs e)
{
if (target._RID == 0 && target._MyRole == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
private static bool MyFolderRequired(GroupAssignment target, Csla.Validation.RuleArgs e)
{
if (target._FolderID == 0 && target._MyFolder == 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(AID, "<Role(s)>");
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<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 GroupAssignment New(Role myRole, Folder myFolder)
{
return new GroupAssignment(myRole, myFolder);
}
internal static GroupAssignment Get(SafeDataReader dr)
{
return new GroupAssignment(dr);
}
public GroupAssignment()
{
MarkAsChild();
_AID = Assignment.NextAID;
_StartDate = _GroupAssignmentExtension.DefaultStartDate;
_DTS = _GroupAssignmentExtension.DefaultDTS;
_UsrID = _GroupAssignmentExtension.DefaultUsrID;
ValidationRules.CheckRules();
}
private GroupAssignment(Role myRole, Folder myFolder)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = _GroupAssignmentExtension.DefaultStartDate;
_DTS = _GroupAssignmentExtension.DefaultDTS;
_UsrID = _GroupAssignmentExtension.DefaultUsrID;
_MyRole = myRole;
_MyFolder = myFolder;
ValidationRules.CheckRules();
}
internal GroupAssignment(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupAssignment.FetchDR", GetHashCode());
try
{
_AID = dr.GetInt32("AID");
_RID = dr.GetInt32("RID");
_FolderID = dr.GetInt32("FolderID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Folder_ParentID = dr.GetInt32("Folder_ParentID");
_Folder_DBID = dr.GetInt32("Folder_DBID");
_Folder_Name = dr.GetString("Folder_Name");
_Folder_Title = dr.GetString("Folder_Title");
_Folder_ShortName = dr.GetString("Folder_ShortName");
_Folder_FormatID = (int?)dr.GetValue("Folder_FormatID");
_Folder_Config = dr.GetString("Folder_Config");
_Folder_DTS = dr.GetDateTime("Folder_DTS");
_Folder_UsrID = dr.GetString("Folder_UsrID");
_Role_Name = dr.GetString("Role_Name");
_Role_Title = dr.GetString("Role_Title");
_Role_DTS = dr.GetDateTime("Role_DTS");
_Role_UsrID = dr.GetString("Role_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupAssignment.FetchDR", ex);
throw new DbCslaException("GroupAssignment.Fetch", ex);
}
MarkOld();
}
internal void Insert(Group myGroup)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Assignment.Add(cn, ref _AID, myGroup, _MyRole, _MyFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(Group myGroup)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Assignment.Update(cn, ref _AID, myGroup, _MyRole, _MyFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Group myGroup)
{
// 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"];
Assignment.Remove(cn, _AID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
GroupAssignmentExtension _GroupAssignmentExtension = new GroupAssignmentExtension();
[Serializable()]
partial class GroupAssignmentExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
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 GroupAssignmentConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupAssignment)
{
// Return the ToString value
return ((GroupAssignment)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create GroupAssignmentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class GroupAssignment
// {
// partial class GroupAssignmentExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// GroupAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GroupAssignmentsConverter))]
public partial class GroupAssignments : BusinessListBase<GroupAssignments, GroupAssignment>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public GroupAssignment this[Assignment myAssignment]
{
get
{
foreach (GroupAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return assignment;
return null;
}
}
public new System.Collections.Generic.IList<GroupAssignment> Items
{
get { return base.Items; }
}
public GroupAssignment GetItem(Assignment myAssignment)
{
foreach (GroupAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return assignment;
return null;
}
public GroupAssignment Add(Role myRole, Folder myFolder) // One to Many
{
GroupAssignment assignment = GroupAssignment.New(myRole, myFolder);
this.Add(assignment);
return assignment;
}
public void Remove(Assignment myAssignment)
{
foreach (GroupAssignment assignment in this)
{
if (assignment.AID == myAssignment.AID)
{
Remove(assignment);
break;
}
}
}
public bool Contains(Assignment myAssignment)
{
foreach (GroupAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return true;
return false;
}
public bool ContainsDeleted(Assignment myAssignment)
{
foreach (GroupAssignment assignment in DeletedList)
if (assignment.AID == myAssignment.AID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(GroupAssignment groupAssignment in this)
if ((hasBrokenRules = groupAssignment.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static GroupAssignments New()
{
return new GroupAssignments();
}
internal static GroupAssignments Get(SafeDataReader dr)
{
return new GroupAssignments(dr);
}
public static GroupAssignments GetByGID(int gid)
{
try
{
return DataPortal.Fetch<GroupAssignments>(new GIDCriteria(gid));
}
catch (Exception ex)
{
throw new DbCslaException("Error on GroupAssignments.GetByGID", ex);
}
}
private GroupAssignments()
{
MarkAsChild();
}
internal GroupAssignments(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(GroupAssignment.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class GIDCriteria
{
public GIDCriteria(int gid)
{
_GID = gid;
}
private int _GID;
public int GID
{
get { return _GID; }
set { _GID = value; }
}
}
private void DataPortal_Fetch(GIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupAssignments.DataPortal_FetchGID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAssignmentsByGID";
cm.Parameters.AddWithValue("@GID", criteria.GID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new GroupAssignment(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupAssignments.DataPortal_FetchGID", ex);
throw new DbCslaException("GroupAssignments.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Group group)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (GroupAssignment obj in DeletedList)
obj.DeleteSelf(group);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (GroupAssignment obj in this)
{
if (obj.IsNew)
obj.Insert(group);
else
obj.Update(group);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
GroupAssignmentsPropertyDescriptor pd = new GroupAssignmentsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class GroupAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
{
private GroupAssignment Item { get { return (GroupAssignment) _Item;} }
public GroupAssignmentsPropertyDescriptor(GroupAssignments collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class GroupAssignmentsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupAssignments)
{
// Return department and department role separated by comma.
return ((GroupAssignments) value).Items.Count.ToString() + " Assignments";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,373 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<GroupInfo> _AllList = new List<GroupInfo>();
private static Dictionary<string, GroupInfo> _AllByPrimaryKey = new Dictionary<string, GroupInfo>();
private static void ConvertListToDictionary()
{
List<GroupInfo> remove = new List<GroupInfo>();
foreach (GroupInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.GID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (GroupInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(GroupInfoList lst)
{
foreach (GroupInfo item in lst) _AllList.Add(item);
}
public static GroupInfo GetExistingByPrimaryKey(int gid)
{
ConvertListToDictionary();
string key = gid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 && _GroupAssignments == null)
_GroupAssignments = AssignmentInfoList.GetByGID(_GID);
return _GroupAssignments;
}
}
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 && _GroupMemberships == null)
_GroupMemberships = MembershipInfoList.GetByGID(_GID);
return _GroupMemberships;
}
}
// 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 GroupInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(GID.ToString());
}
public virtual Group Get()
{
return _Editable = Group.Get(_GID);
}
public static void Refresh(Group tmp)
{
GroupInfo tmpInfo = GetExistingByPrimaryKey(tmp.GID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private 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 = GetExistingByPrimaryKey(gid);
if (tmp == null)
{
tmp = DataPortal.Fetch<GroupInfo>(new PKCriteria(gid));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

View File

@@ -0,0 +1,720 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// GroupMembership Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GroupMembershipConverter))]
public partial class GroupMembership : BusinessBase<GroupMembership>, 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 _UGID;
[System.ComponentModel.DataObjectField(true, true)]
public int UGID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UGID",true);
if (_MyMembership != null) _UGID = _MyMembership.UGID;
return _UGID;
}
}
private Membership _MyMembership;
[System.ComponentModel.DataObjectField(true, true)]
public Membership MyMembership
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyMembership",true);
if (_MyMembership == null && _UGID != 0) _MyMembership = Membership.Get(_UGID);
return _MyMembership;
}
}
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 User _MyUser;
public User MyUser
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyUser",true);
if (_MyUser == null && _UID != 0) _MyUser = User.Get(_UID);
return _MyUser;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyUser",true);
if (_MyUser != value)
{
_MyUser = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StartDate",true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("StartDate",true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("EndDate",true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("EndDate",true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID",true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _User_UserID = string.Empty;
public string User_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_UserID",true);
return _User_UserID;
}
}
private string _User_FirstName = string.Empty;
public string User_FirstName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_FirstName",true);
return _User_FirstName;
}
}
private string _User_MiddleName = string.Empty;
public string User_MiddleName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_MiddleName",true);
return _User_MiddleName;
}
}
private string _User_LastName = string.Empty;
public string User_LastName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_LastName",true);
return _User_LastName;
}
}
private string _User_Suffix = string.Empty;
public string User_Suffix
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_Suffix",true);
return _User_Suffix;
}
}
private string _User_CourtesyTitle = string.Empty;
public string User_CourtesyTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_CourtesyTitle",true);
return _User_CourtesyTitle;
}
}
private string _User_PhoneNumber = string.Empty;
public string User_PhoneNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_PhoneNumber",true);
return _User_PhoneNumber;
}
}
private string _User_CFGName = string.Empty;
public string User_CFGName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_CFGName",true);
return _User_CFGName;
}
}
private string _User_UserLogin = string.Empty;
public string User_UserLogin
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_UserLogin",true);
return _User_UserLogin;
}
}
private string _User_UserName = string.Empty;
public string User_UserName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_UserName",true);
return _User_UserName;
}
}
private string _User_Config = string.Empty;
public string User_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_Config",true);
return _User_Config;
}
}
private DateTime _User_DTS = new DateTime();
public DateTime User_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_DTS",true);
return _User_DTS;
}
}
private string _User_UsrID = string.Empty;
public string User_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_UsrID",true);
return _User_UsrID;
}
}
// TODO: Check GroupMembership.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 GroupMembership</returns>
protected override object GetIdValue()
{
return _UGID;
}
// TODO: Replace base GroupMembership.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupMembership</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyUser == null ? false : _MyUser.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyUser == null ? true : _MyUser.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 (_MyUser != null && (hasBrokenRules = _MyUser.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<GroupMembership>(MyUserRequired, "MyUser");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule<GroupMembership>(StartDateValid, "StartDate");
ValidationRules.AddRule<GroupMembership>(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private static bool StartDateValid(GroupMembership target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool EndDateValid(GroupMembership target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._EndDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool MyUserRequired(GroupMembership target, Csla.Validation.RuleArgs e)
{
if (target._UID == 0 && target._MyUser == 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(UGID, "<Role(s)>");
//AuthorizationRules.AllowRead(UID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<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 GroupMembership New(User myUser)
{
return new GroupMembership(myUser);
}
internal static GroupMembership Get(SafeDataReader dr)
{
return new GroupMembership(dr);
}
public GroupMembership()
{
MarkAsChild();
_UGID = Membership.NextUGID;
_StartDate = _GroupMembershipExtension.DefaultStartDate;
_DTS = _GroupMembershipExtension.DefaultDTS;
_UsrID = _GroupMembershipExtension.DefaultUsrID;
ValidationRules.CheckRules();
}
private GroupMembership(User myUser)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = _GroupMembershipExtension.DefaultStartDate;
_DTS = _GroupMembershipExtension.DefaultDTS;
_UsrID = _GroupMembershipExtension.DefaultUsrID;
_MyUser = myUser;
ValidationRules.CheckRules();
}
internal GroupMembership(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupMembership.FetchDR", GetHashCode());
try
{
_UGID = dr.GetInt32("UGID");
_UID = dr.GetInt32("UID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_User_UserID = dr.GetString("User_UserID");
_User_FirstName = dr.GetString("User_FirstName");
_User_MiddleName = dr.GetString("User_MiddleName");
_User_LastName = dr.GetString("User_LastName");
_User_Suffix = dr.GetString("User_Suffix");
_User_CourtesyTitle = dr.GetString("User_CourtesyTitle");
_User_PhoneNumber = dr.GetString("User_PhoneNumber");
_User_CFGName = dr.GetString("User_CFGName");
_User_UserLogin = dr.GetString("User_UserLogin");
_User_UserName = dr.GetString("User_UserName");
_User_Config = dr.GetString("User_Config");
_User_DTS = dr.GetDateTime("User_DTS");
_User_UsrID = dr.GetString("User_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupMembership.FetchDR", ex);
throw new DbCslaException("GroupMembership.Fetch", ex);
}
MarkOld();
}
internal void Insert(Group myGroup)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Membership.Add(cn, ref _UGID, _MyUser, myGroup, new SmartDate(_StartDate), new SmartDate(_EndDate), _Config, _DTS, _UsrID);
MarkOld();
}
internal void Update(Group myGroup)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Membership.Update(cn, ref _UGID, _MyUser, myGroup, new SmartDate(_StartDate), new SmartDate(_EndDate), _Config, _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Group myGroup)
{
// 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"];
Membership.Remove(cn, _UGID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
GroupMembershipExtension _GroupMembershipExtension = new GroupMembershipExtension();
[Serializable()]
partial class GroupMembershipExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
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 GroupMembershipConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupMembership)
{
// Return the ToString value
return ((GroupMembership)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create GroupMembershipExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class GroupMembership
// {
// partial class GroupMembershipExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// GroupMemberships Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GroupMembershipsConverter))]
public partial class GroupMemberships : BusinessListBase<GroupMemberships, GroupMembership>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public GroupMembership this[Membership myMembership]
{
get
{
foreach (GroupMembership membership in this)
if (membership.UGID == myMembership.UGID)
return membership;
return null;
}
}
public new System.Collections.Generic.IList<GroupMembership> Items
{
get { return base.Items; }
}
public GroupMembership GetItem(Membership myMembership)
{
foreach (GroupMembership membership in this)
if (membership.UGID == myMembership.UGID)
return membership;
return null;
}
public GroupMembership Add(User myUser) // One to Many
{
GroupMembership membership = GroupMembership.New(myUser);
this.Add(membership);
return membership;
}
public void Remove(Membership myMembership)
{
foreach (GroupMembership membership in this)
{
if (membership.UGID == myMembership.UGID)
{
Remove(membership);
break;
}
}
}
public bool Contains(Membership myMembership)
{
foreach (GroupMembership membership in this)
if (membership.UGID == myMembership.UGID)
return true;
return false;
}
public bool ContainsDeleted(Membership myMembership)
{
foreach (GroupMembership membership in DeletedList)
if (membership.UGID == myMembership.UGID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(GroupMembership groupMembership in this)
if ((hasBrokenRules = groupMembership.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static GroupMemberships New()
{
return new GroupMemberships();
}
internal static GroupMemberships Get(SafeDataReader dr)
{
return new GroupMemberships(dr);
}
public static GroupMemberships GetByGID(int gid)
{
try
{
return DataPortal.Fetch<GroupMemberships>(new GIDCriteria(gid));
}
catch (Exception ex)
{
throw new DbCslaException("Error on GroupMemberships.GetByGID", ex);
}
}
private GroupMemberships()
{
MarkAsChild();
}
internal GroupMemberships(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(GroupMembership.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class GIDCriteria
{
public GIDCriteria(int gid)
{
_GID = gid;
}
private int _GID;
public int GID
{
get { return _GID; }
set { _GID = value; }
}
}
private void DataPortal_Fetch(GIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupMemberships.DataPortal_FetchGID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getMembershipsByGID";
cm.Parameters.AddWithValue("@GID", criteria.GID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new GroupMembership(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupMemberships.DataPortal_FetchGID", ex);
throw new DbCslaException("GroupMemberships.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Group group)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (GroupMembership obj in DeletedList)
obj.DeleteSelf(group);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (GroupMembership obj in this)
{
if (obj.IsNew)
obj.Insert(group);
else
obj.Update(group);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
GroupMembershipsPropertyDescriptor pd = new GroupMembershipsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class GroupMembershipsPropertyDescriptor : vlnListPropertyDescriptor
{
private GroupMembership Item { get { return (GroupMembership) _Item;} }
public GroupMembershipsPropertyDescriptor(GroupMemberships collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class GroupMembershipsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupMemberships)
{
// Return department and department role separated by comma.
return ((GroupMemberships) value).Items.Count.ToString() + " Memberships";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,569 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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
} // Namespace
//// The following is a sample Extension File. You can use it to create ItemAnnotationExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ItemAnnotation
// {
// partial class ItemAnnotationExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemAnnotations Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemAnnotationsConverter))]
public partial class ItemAnnotations : BusinessListBase<ItemAnnotations, ItemAnnotation>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ItemAnnotation this[Annotation myAnnotation]
{
get
{
foreach (ItemAnnotation annotation in this)
if (annotation.AnnotationID == myAnnotation.AnnotationID)
return annotation;
return null;
}
}
public new System.Collections.Generic.IList<ItemAnnotation> Items
{
get { return base.Items; }
}
public ItemAnnotation GetItem(Annotation myAnnotation)
{
foreach (ItemAnnotation annotation in this)
if (annotation.AnnotationID == myAnnotation.AnnotationID)
return annotation;
return null;
}
public ItemAnnotation Add(AnnotationType myAnnotationType) // One to Many
{
ItemAnnotation annotation = ItemAnnotation.New(myAnnotationType);
this.Add(annotation);
return annotation;
}
public void Remove(Annotation myAnnotation)
{
foreach (ItemAnnotation annotation in this)
{
if (annotation.AnnotationID == myAnnotation.AnnotationID)
{
Remove(annotation);
break;
}
}
}
public bool Contains(Annotation myAnnotation)
{
foreach (ItemAnnotation annotation in this)
if (annotation.AnnotationID == myAnnotation.AnnotationID)
return true;
return false;
}
public bool ContainsDeleted(Annotation myAnnotation)
{
foreach (ItemAnnotation annotation in DeletedList)
if (annotation.AnnotationID == myAnnotation.AnnotationID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ItemAnnotation itemAnnotation in this)
if ((hasBrokenRules = itemAnnotation.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ItemAnnotations New()
{
return new ItemAnnotations();
}
internal static ItemAnnotations Get(SafeDataReader dr)
{
return new ItemAnnotations(dr);
}
public static ItemAnnotations GetByItemID(int itemID)
{
try
{
return DataPortal.Fetch<ItemAnnotations>(new ItemIDCriteria(itemID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemAnnotations.GetByItemID", ex);
}
}
private ItemAnnotations()
{
MarkAsChild();
}
internal ItemAnnotations(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ItemAnnotation.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ItemIDCriteria
{
public ItemIDCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
private void DataPortal_Fetch(ItemIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemAnnotations.DataPortal_FetchItemID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationsByItemID";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ItemAnnotation(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemAnnotations.DataPortal_FetchItemID", ex);
throw new DbCslaException("ItemAnnotations.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Item item)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ItemAnnotation obj in DeletedList)
obj.DeleteSelf(item);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ItemAnnotation obj in this)
{
if (obj.IsNew)
obj.Insert(item);
else
obj.Update(item);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ItemAnnotationsPropertyDescriptor pd = new ItemAnnotationsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ItemAnnotationsPropertyDescriptor : vlnListPropertyDescriptor
{
private ItemAnnotation Item { get { return (ItemAnnotation) _Item;} }
public ItemAnnotationsPropertyDescriptor(ItemAnnotations collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ItemAnnotationsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemAnnotations)
{
// Return department and department role separated by comma.
return ((ItemAnnotations) value).Items.Count.ToString() + " Annotations";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,700 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemDocVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemDocVersionConverter))]
public partial class ItemDocVersion : BusinessBase<ItemDocVersion>, 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 int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFolder",true);
if (_MyFolder != value)
{
_MyFolder = value;
PropertyHasChanged();
}
}
}
private int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionType",true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("VersionType",true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Name",true);
if (value == null) value = string.Empty;
if (_Name != value)
{
_Name = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Title",true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
}
private Format _MyFormat;
public Format MyFormat
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFormat",true);
if (_MyFormat != value)
{
_MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID);
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 _Folder_ParentID;
public int Folder_ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ParentID",true);
return _Folder_ParentID;
}
}
private int _Folder_DBID;
public int Folder_DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DBID",true);
return _Folder_DBID;
}
}
private string _Folder_Name = string.Empty;
public string Folder_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Name",true);
return _Folder_Name;
}
}
private string _Folder_Title = string.Empty;
public string Folder_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Title",true);
return _Folder_Title;
}
}
private string _Folder_ShortName = string.Empty;
public string Folder_ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ShortName",true);
return _Folder_ShortName;
}
}
private int? _Folder_FormatID;
public int? Folder_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_FormatID",true);
return _Folder_FormatID;
}
}
private string _Folder_Config = string.Empty;
public string Folder_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Config",true);
return _Folder_Config;
}
}
private DateTime _Folder_DTS = new DateTime();
public DateTime Folder_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DTS",true);
return _Folder_DTS;
}
}
private string _Folder_UsrID = string.Empty;
public string Folder_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_UsrID",true);
return _Folder_UsrID;
}
}
// TODO: Check ItemDocVersion.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 ItemDocVersion</returns>
protected override object GetIdValue()
{
return _VersionID;
}
// TODO: Replace base ItemDocVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemDocVersion</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.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 (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<ItemDocVersion>(MyFolderRequired, "MyFolder");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.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 MyFolderRequired(ItemDocVersion target, Csla.Validation.RuleArgs e)
{
if (target._FolderID == 0 && target._MyFolder == 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(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FormatID, "<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 ItemDocVersion New(Folder myFolder, string name)
{
return new ItemDocVersion(myFolder, name);
}
internal static ItemDocVersion Get(SafeDataReader dr)
{
return new ItemDocVersion(dr);
}
public ItemDocVersion()
{
MarkAsChild();
_VersionID = DocVersion.NextVersionID;
_VersionType = _ItemDocVersionExtension.DefaultVersionType;
_DTS = _ItemDocVersionExtension.DefaultDTS;
_UserID = _ItemDocVersionExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ItemDocVersion(Folder myFolder, string name)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_VersionType = _ItemDocVersionExtension.DefaultVersionType;
_DTS = _ItemDocVersionExtension.DefaultDTS;
_UserID = _ItemDocVersionExtension.DefaultUserID;
_MyFolder = myFolder;
_Name = name;
ValidationRules.CheckRules();
}
internal ItemDocVersion(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemDocVersion.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_FolderID = dr.GetInt32("FolderID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_FormatID = (int?)dr.GetValue("FormatID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Folder_ParentID = dr.GetInt32("Folder_ParentID");
_Folder_DBID = dr.GetInt32("Folder_DBID");
_Folder_Name = dr.GetString("Folder_Name");
_Folder_Title = dr.GetString("Folder_Title");
_Folder_ShortName = dr.GetString("Folder_ShortName");
_Folder_FormatID = (int?)dr.GetValue("Folder_FormatID");
_Folder_Config = dr.GetString("Folder_Config");
_Folder_DTS = dr.GetDateTime("Folder_DTS");
_Folder_UsrID = dr.GetString("Folder_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemDocVersion.FetchDR", ex);
throw new DbCslaException("ItemDocVersion.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 = DocVersion.Add(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, myItem, _MyFormat, _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 = DocVersion.Update(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, myItem, _MyFormat, _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"];
DocVersion.Remove(cn, _VersionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ItemDocVersionExtension _ItemDocVersionExtension = new ItemDocVersionExtension();
[Serializable()]
partial class ItemDocVersionExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultVersionType
{
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 ItemDocVersionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemDocVersion)
{
// Return the ToString value
return ((ItemDocVersion)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ItemDocVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ItemDocVersion
// {
// partial class ItemDocVersionExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultVersionType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemDocVersions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemDocVersionsConverter))]
public partial class ItemDocVersions : BusinessListBase<ItemDocVersions, ItemDocVersion>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ItemDocVersion this[DocVersion myDocVersion]
{
get
{
foreach (ItemDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return docVersion;
return null;
}
}
public new System.Collections.Generic.IList<ItemDocVersion> Items
{
get { return base.Items; }
}
public ItemDocVersion GetItem(DocVersion myDocVersion)
{
foreach (ItemDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return docVersion;
return null;
}
public ItemDocVersion Add(Folder myFolder, string name) // One to Many
{
ItemDocVersion docVersion = ItemDocVersion.New(myFolder, name);
this.Add(docVersion);
return docVersion;
}
public void Remove(DocVersion myDocVersion)
{
foreach (ItemDocVersion docVersion in this)
{
if (docVersion.VersionID == myDocVersion.VersionID)
{
Remove(docVersion);
break;
}
}
}
public bool Contains(DocVersion myDocVersion)
{
foreach (ItemDocVersion docVersion in this)
if (docVersion.VersionID == myDocVersion.VersionID)
return true;
return false;
}
public bool ContainsDeleted(DocVersion myDocVersion)
{
foreach (ItemDocVersion docVersion in DeletedList)
if (docVersion.VersionID == myDocVersion.VersionID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ItemDocVersion itemDocVersion in this)
if ((hasBrokenRules = itemDocVersion.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ItemDocVersions New()
{
return new ItemDocVersions();
}
internal static ItemDocVersions Get(SafeDataReader dr)
{
return new ItemDocVersions(dr);
}
public static ItemDocVersions GetByItemID(int itemID)
{
try
{
return DataPortal.Fetch<ItemDocVersions>(new ItemIDCriteria(itemID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemDocVersions.GetByItemID", ex);
}
}
private ItemDocVersions()
{
MarkAsChild();
}
internal ItemDocVersions(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ItemDocVersion.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ItemIDCriteria
{
public ItemIDCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
private void DataPortal_Fetch(ItemIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemDocVersions.DataPortal_FetchItemID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocVersionsByItemID";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ItemDocVersion(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemDocVersions.DataPortal_FetchItemID", ex);
throw new DbCslaException("ItemDocVersions.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Item item)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ItemDocVersion obj in DeletedList)
obj.DeleteSelf(item);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ItemDocVersion obj in this)
{
if (obj.IsNew)
obj.Insert(item);
else
obj.Update(item);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ItemDocVersionsPropertyDescriptor pd = new ItemDocVersionsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ItemDocVersionsPropertyDescriptor : vlnListPropertyDescriptor
{
private ItemDocVersion Item { get { return (ItemDocVersion) _Item;} }
public ItemDocVersionsPropertyDescriptor(ItemDocVersions collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ItemDocVersionsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemDocVersions)
{
// Return department and department role separated by comma.
return ((ItemDocVersions) value).Items.Count.ToString() + " DocVersions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,511 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ItemInfoEvent(object sender);
/// <summary>
/// ItemInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemInfoConverter))]
public partial class ItemInfo : ReadOnlyBase<ItemInfo>, IDisposable
{
public event ItemInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<ItemInfo> _AllList = new List<ItemInfo>();
private static Dictionary<string, ItemInfo> _AllByPrimaryKey = new Dictionary<string, ItemInfo>();
private static void ConvertListToDictionary()
{
List<ItemInfo> remove = new List<ItemInfo>();
foreach (ItemInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.ItemID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (ItemInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(ItemInfoList lst)
{
foreach (ItemInfo item in lst) _AllList.Add(item);
}
public static ItemInfo GetExistingByPrimaryKey(int itemID)
{
ConvertListToDictionary();
string key = itemID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Item _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ItemID;
[System.ComponentModel.DataObjectField(true, true)]
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
return _ItemID;
}
}
private int? _PreviousID;
public int? PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PreviousID",true);
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID;
}
}
private ItemInfo _MyPrevious;
public ItemInfo MyPrevious
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyPrevious",true);
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = ItemInfo.Get((int)_PreviousID);
return _MyPrevious;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID",true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent",true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
}
private int _ItemAnnotationCount = 0;
/// <summary>
/// Count of ItemAnnotations for this Item
/// </summary>
public int ItemAnnotationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemAnnotationCount",true);
return _ItemAnnotationCount;
}
}
private AnnotationInfoList _ItemAnnotations = null;
[TypeConverter(typeof(AnnotationInfoListConverter))]
public AnnotationInfoList ItemAnnotations
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemAnnotations",true);
if (_ItemAnnotationCount > 0 && _ItemAnnotations == null)
_ItemAnnotations = AnnotationInfoList.GetByItemID(_ItemID);
return _ItemAnnotations;
}
}
private int _ItemDocVersionCount = 0;
/// <summary>
/// Count of ItemDocVersions for this Item
/// </summary>
public int ItemDocVersionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemDocVersionCount",true);
return _ItemDocVersionCount;
}
}
private DocVersionInfoList _ItemDocVersions = null;
[TypeConverter(typeof(DocVersionInfoListConverter))]
public DocVersionInfoList ItemDocVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemDocVersions",true);
if (_ItemDocVersionCount > 0 && _ItemDocVersions == null)
_ItemDocVersions = DocVersionInfoList.GetByItemID(_ItemID);
return _ItemDocVersions;
}
}
private int _NextItemCount = 0;
/// <summary>
/// Count of NextItems for this Item
/// </summary>
public int NextItemCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("NextItemCount",true);
return _NextItemCount;
}
}
private ItemInfoList _NextItems = null;
[TypeConverter(typeof(ItemInfoListConverter))]
public ItemInfoList NextItems
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("NextItems",true);
if (_NextItemCount > 0 && _NextItems == null)
_NextItems = ItemInfoList.GetNext(_ItemID);
return _NextItems;
}
}
private int _ItemPartCount = 0;
/// <summary>
/// Count of ItemParts for this Item
/// </summary>
public int ItemPartCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemPartCount",true);
return _ItemPartCount;
}
}
private PartInfoList _ItemParts = null;
[TypeConverter(typeof(PartInfoListConverter))]
public PartInfoList ItemParts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemParts",true);
if (_ItemPartCount > 0 && _ItemParts == null)
_ItemParts = PartInfoList.GetByItemID(_ItemID);
return _ItemParts;
}
}
private int _ItemTransition_RangeIDCount = 0;
/// <summary>
/// Count of ItemTransitions for this Item
/// </summary>
public int ItemTransition_RangeIDCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransition_RangeIDCount",true);
return _ItemTransition_RangeIDCount;
}
}
private TransitionInfoList _ItemTransitions_RangeID = null;
[TypeConverter(typeof(TransitionInfoListConverter))]
public TransitionInfoList ItemTransitions_RangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransitions_RangeID",true);
if (_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null)
_ItemTransitions_RangeID = TransitionInfoList.GetByRangeID(_ItemID);
return _ItemTransitions_RangeID;
}
}
private int _ItemTransition_ToIDCount = 0;
/// <summary>
/// Count of ItemTransitions for this Item
/// </summary>
public int ItemTransition_ToIDCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransition_ToIDCount",true);
return _ItemTransition_ToIDCount;
}
}
private TransitionInfoList _ItemTransitions_ToID = null;
[TypeConverter(typeof(TransitionInfoListConverter))]
public TransitionInfoList ItemTransitions_ToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransitions_ToID",true);
if (_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null)
_ItemTransitions_ToID = TransitionInfoList.GetByToID(_ItemID);
return _ItemTransitions_ToID;
}
}
// TODO: Replace base ItemInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ItemInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ItemInfo</returns>
protected override object GetIdValue()
{
return _ItemID;
}
#endregion
#region Factory Methods
private ItemInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ItemID.ToString());
}
public virtual Item Get()
{
return _Editable = Item.Get(_ItemID);
}
public static void Refresh(Item tmp)
{
ItemInfo tmpInfo = GetExistingByPrimaryKey(tmp.ItemID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Item tmp)
{
_PreviousID = tmp.PreviousID;
_ContentID = tmp.ContentID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ItemInfoExtension.Refresh(this);
_MyPrevious = null;
_MyContent = null;
OnChange();// raise an event
}
public static void Refresh(ContentItem tmp)
{
ItemInfo tmpInfo = GetExistingByPrimaryKey(tmp.ItemID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ContentItem tmp)
{
_PreviousID = tmp.PreviousID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ItemInfoExtension.Refresh(this);
_MyPrevious = null;
_MyContent = null;
OnChange();// raise an event
}
public static ItemInfo Get(int itemID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
ItemInfo tmp = GetExistingByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ItemInfo>(new PKCriteria(itemID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ItemInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfo.Constructor", ex);
throw new DbCslaException("ItemInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
public PKCriteria(int itemID)
{
_ItemID = itemID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfo.ReadData", GetHashCode());
try
{
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ItemAnnotationCount = dr.GetInt32("AnnotationCount");
_ItemDocVersionCount = dr.GetInt32("DocVersionCount");
_NextItemCount = dr.GetInt32("NextCount");
_ItemPartCount = dr.GetInt32("PartCount");
_ItemTransition_RangeIDCount = dr.GetInt32("Transition_RangeIDCount");
_ItemTransition_ToIDCount = dr.GetInt32("Transition_ToIDCount");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getItem";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ItemInfoExtension _ItemInfoExtension = new ItemInfoExtension();
[Serializable()]
partial class ItemInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ItemInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ItemInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemInfo)
{
// Return the ToString value
return ((ItemInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

View File

@@ -0,0 +1,484 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using 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();
_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
//// The following is a sample Extension File. You can use it to create ItemPartExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ItemPart
// {
// partial class ItemPartExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemParts Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemPartsConverter))]
public partial class ItemParts : BusinessListBase<ItemParts, ItemPart>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ItemPart this[Content myContent, int fromType]
{
get
{
foreach (ItemPart part in this)
if (part.ContentID == myContent.ContentID && part.FromType == fromType)
return part;
return null;
}
}
public new System.Collections.Generic.IList<ItemPart> Items
{
get { return base.Items; }
}
public ItemPart GetItem(Content myContent, int fromType)
{
foreach (ItemPart part in this)
if (part.ContentID == myContent.ContentID && part.FromType == fromType)
return part;
return null;
}
public ItemPart Add(Content myContent, int fromType) // One to Many
{
ItemPart part = ItemPart.New(myContent, fromType);
this.Add(part);
return part;
}
public void Remove(Content myContent, int fromType)
{
foreach (ItemPart part in this)
{
if (part.ContentID == myContent.ContentID && part.FromType == fromType)
{
Remove(part);
break;
}
}
}
public bool Contains(Content myContent, int fromType)
{
foreach (ItemPart part in this)
if (part.ContentID == myContent.ContentID && part.FromType == fromType)
return true;
return false;
}
public bool ContainsDeleted(Content myContent, int fromType)
{
foreach (ItemPart part in DeletedList)
if (part.ContentID == myContent.ContentID && part.FromType == fromType)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ItemPart itemPart in this)
if ((hasBrokenRules = itemPart.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ItemParts New()
{
return new ItemParts();
}
internal static ItemParts Get(SafeDataReader dr)
{
return new ItemParts(dr);
}
public static ItemParts GetByItemID(int itemID)
{
try
{
return DataPortal.Fetch<ItemParts>(new ItemIDCriteria(itemID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemParts.GetByItemID", ex);
}
}
private ItemParts()
{
MarkAsChild();
}
internal ItemParts(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ItemPart.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ItemIDCriteria
{
public ItemIDCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
private void DataPortal_Fetch(ItemIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemParts.DataPortal_FetchItemID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getPartsByItemID";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ItemPart(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemParts.DataPortal_FetchItemID", ex);
throw new DbCslaException("ItemParts.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Item item)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ItemPart obj in DeletedList)
obj.DeleteSelf(item);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ItemPart obj in this)
{
if (obj.IsNew)
obj.Insert(item);
else
obj.Update(item);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ItemPartsPropertyDescriptor pd = new ItemPartsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ItemPartsPropertyDescriptor : vlnListPropertyDescriptor
{
private ItemPart Item { get { return (ItemPart) _Item;} }
public ItemPartsPropertyDescriptor(ItemParts collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ItemPartsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemParts)
{
// Return department and department role separated by comma.
return ((ItemParts) value).Items.Count.ToString() + " Parts";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,623 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemTransition_RangeID Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemTransition_RangeIDConverter))]
public partial class ItemTransition_RangeID : BusinessBase<ItemTransition_RangeID>, 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 _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 Transition _MyTransition;
[System.ComponentModel.DataObjectField(true, true)]
public Transition MyTransition
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyTransition",true);
if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID);
return _MyTransition;
}
}
private int _FromID;
public int FromID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FromID",true);
if (_MyContent != null) _FromID = _MyContent.ContentID;
return _FromID;
}
}
private Content _MyContent;
public Content MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent",true);
if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID);
return _MyContent;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyContent",true);
if (_MyContent != value)
{
_MyContent = value;
PropertyHasChanged();
}
}
}
private int _ToID;
/// <summary>
/// StructureID
/// </summary>
public int ToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ToID",true);
if (_MyItemToID != null) _ToID = _MyItemToID.ItemID;
return _ToID;
}
}
private Item _MyItemToID;
public Item MyItemToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItemToID",true);
if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID);
return _MyItemToID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItemToID",true);
if (_MyItemToID != value)
{
_MyItemToID = value;
PropertyHasChanged();
}
}
}
private int _TranType;
public int TranType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TranType",true);
return _TranType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("TranType",true);
if (_TranType != value)
{
_TranType = 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 _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 ItemTransition_RangeID.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 ItemTransition_RangeID</returns>
protected override object GetIdValue()
{
return _TransitionID;
}
// TODO: Replace base ItemTransition_RangeID.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemTransition_RangeID</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null ? true : _MyContent.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 (_MyContent != null && (hasBrokenRules = _MyContent.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<ItemTransition_RangeID>(MyContentRequired, "MyContent");
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 MyContentRequired(ItemTransition_RangeID target, Csla.Validation.RuleArgs e)
{
if (target._FromID == 0 && target._MyContent == 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(TransitionID, "<Role(s)>");
//AuthorizationRules.AllowRead(FromID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FromID, "<Role(s)>");
//AuthorizationRules.AllowRead(ToID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ToID, "<Role(s)>");
//AuthorizationRules.AllowRead(TranType, "<Role(s)>");
//AuthorizationRules.AllowWrite(TranType, "<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 ItemTransition_RangeID New(Content myContent, Item myItemToID)
{
return new ItemTransition_RangeID(myContent, myItemToID);
}
internal static ItemTransition_RangeID Get(SafeDataReader dr)
{
return new ItemTransition_RangeID(dr);
}
public ItemTransition_RangeID()
{
MarkAsChild();
_TransitionID = Transition.NextTransitionID;
_TranType = _ItemTransition_RangeIDExtension.DefaultTranType;
_DTS = _ItemTransition_RangeIDExtension.DefaultDTS;
_UserID = _ItemTransition_RangeIDExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ItemTransition_RangeID(Content myContent, Item myItemToID)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_TranType = _ItemTransition_RangeIDExtension.DefaultTranType;
_DTS = _ItemTransition_RangeIDExtension.DefaultDTS;
_UserID = _ItemTransition_RangeIDExtension.DefaultUserID;
_MyContent = myContent;
_MyItemToID = myItemToID;
ValidationRules.CheckRules();
}
internal ItemTransition_RangeID(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemTransition_RangeID.FetchDR", GetHashCode());
try
{
_TransitionID = dr.GetInt32("TransitionID");
_FromID = dr.GetInt32("FromID");
_ToID = dr.GetInt32("ToID");
_TranType = dr.GetInt32("TranType");
_Config = dr.GetString("Config");
_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("ItemTransition_RangeID.FetchDR", ex);
throw new DbCslaException("ItemTransition_RangeID.Fetch", ex);
}
MarkOld();
}
internal void Insert(Item myItemRangeID)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Transition.Add(cn, ref _TransitionID, _MyContent, _MyItemToID, myItemRangeID, _TranType, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Item myItemRangeID)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Transition.Update(cn, ref _TransitionID, _MyContent, _MyItemToID, myItemRangeID, _TranType, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Item myItemRangeID)
{
// 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"];
Transition.Remove(cn, _TransitionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ItemTransition_RangeIDExtension _ItemTransition_RangeIDExtension = new ItemTransition_RangeIDExtension();
[Serializable()]
partial class ItemTransition_RangeIDExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultTranType
{
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 ItemTransition_RangeIDConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemTransition_RangeID)
{
// Return the ToString value
return ((ItemTransition_RangeID)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ItemTransition_RangeIDExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ItemTransition_RangeID
// {
// partial class ItemTransition_RangeIDExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultTranType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,620 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemTransition_ToID Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemTransition_ToIDConverter))]
public partial class ItemTransition_ToID : BusinessBase<ItemTransition_ToID>, 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 _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 Transition _MyTransition;
[System.ComponentModel.DataObjectField(true, true)]
public Transition MyTransition
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyTransition",true);
if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID);
return _MyTransition;
}
}
private int _FromID;
public int FromID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FromID",true);
if (_MyContent != null) _FromID = _MyContent.ContentID;
return _FromID;
}
}
private Content _MyContent;
public Content MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent",true);
if (_MyContent == null && _FromID != 0) _MyContent = Content.Get(_FromID);
return _MyContent;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyContent",true);
if (_MyContent != value)
{
_MyContent = value;
PropertyHasChanged();
}
}
}
private int _RangeID;
public int RangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RangeID",true);
if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID;
return _RangeID;
}
}
private Item _MyItemRangeID;
public Item MyItemRangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItemRangeID",true);
if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID);
return _MyItemRangeID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItemRangeID",true);
if (_MyItemRangeID != value)
{
_MyItemRangeID = value;
PropertyHasChanged();
}
}
}
private int _TranType;
public int TranType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TranType",true);
return _TranType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("TranType",true);
if (_TranType != value)
{
_TranType = 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 _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 ItemTransition_ToID.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 ItemTransition_ToID</returns>
protected override object GetIdValue()
{
return _TransitionID;
}
// TODO: Replace base ItemTransition_ToID.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemTransition_ToID</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null ? true : _MyContent.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 (_MyContent != null && (hasBrokenRules = _MyContent.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<ItemTransition_ToID>(MyContentRequired, "MyContent");
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 MyContentRequired(ItemTransition_ToID target, Csla.Validation.RuleArgs e)
{
if (target._FromID == 0 && target._MyContent == 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(TransitionID, "<Role(s)>");
//AuthorizationRules.AllowRead(FromID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FromID, "<Role(s)>");
//AuthorizationRules.AllowRead(RangeID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RangeID, "<Role(s)>");
//AuthorizationRules.AllowRead(TranType, "<Role(s)>");
//AuthorizationRules.AllowWrite(TranType, "<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 ItemTransition_ToID New(Content myContent, Item myItemRangeID)
{
return new ItemTransition_ToID(myContent, myItemRangeID);
}
internal static ItemTransition_ToID Get(SafeDataReader dr)
{
return new ItemTransition_ToID(dr);
}
public ItemTransition_ToID()
{
MarkAsChild();
_TransitionID = Transition.NextTransitionID;
_TranType = _ItemTransition_ToIDExtension.DefaultTranType;
_DTS = _ItemTransition_ToIDExtension.DefaultDTS;
_UserID = _ItemTransition_ToIDExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ItemTransition_ToID(Content myContent, Item myItemRangeID)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_TranType = _ItemTransition_ToIDExtension.DefaultTranType;
_DTS = _ItemTransition_ToIDExtension.DefaultDTS;
_UserID = _ItemTransition_ToIDExtension.DefaultUserID;
_MyContent = myContent;
_MyItemRangeID = myItemRangeID;
ValidationRules.CheckRules();
}
internal ItemTransition_ToID(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemTransition_ToID.FetchDR", GetHashCode());
try
{
_TransitionID = dr.GetInt32("TransitionID");
_FromID = dr.GetInt32("FromID");
_RangeID = dr.GetInt32("RangeID");
_TranType = dr.GetInt32("TranType");
_Config = dr.GetString("Config");
_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("ItemTransition_ToID.FetchDR", ex);
throw new DbCslaException("ItemTransition_ToID.Fetch", ex);
}
MarkOld();
}
internal void Insert(Item myItemToID)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Transition.Add(cn, ref _TransitionID, _MyContent, myItemToID, _MyItemRangeID, _TranType, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Item myItemToID)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Transition.Update(cn, ref _TransitionID, _MyContent, myItemToID, _MyItemRangeID, _TranType, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Item myItemToID)
{
// 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"];
Transition.Remove(cn, _TransitionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ItemTransition_ToIDExtension _ItemTransition_ToIDExtension = new ItemTransition_ToIDExtension();
[Serializable()]
partial class ItemTransition_ToIDExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultTranType
{
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 ItemTransition_ToIDConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemTransition_ToID)
{
// Return the ToString value
return ((ItemTransition_ToID)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ItemTransition_ToIDExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ItemTransition_ToID
// {
// partial class ItemTransition_ToIDExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultTranType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemTransitions_RangeID Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemTransitions_RangeIDConverter))]
public partial class ItemTransitions_RangeID : BusinessListBase<ItemTransitions_RangeID, ItemTransition_RangeID>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ItemTransition_RangeID this[Transition myTransition]
{
get
{
foreach (ItemTransition_RangeID transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return transition;
return null;
}
}
public new System.Collections.Generic.IList<ItemTransition_RangeID> Items
{
get { return base.Items; }
}
public ItemTransition_RangeID GetItem(Transition myTransition)
{
foreach (ItemTransition_RangeID transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return transition;
return null;
}
public ItemTransition_RangeID Add(Content myContent, Item myItemToID) // One to Many
{
ItemTransition_RangeID transition = ItemTransition_RangeID.New(myContent, myItemToID);
this.Add(transition);
return transition;
}
public void Remove(Transition myTransition)
{
foreach (ItemTransition_RangeID transition in this)
{
if (transition.TransitionID == myTransition.TransitionID)
{
Remove(transition);
break;
}
}
}
public bool Contains(Transition myTransition)
{
foreach (ItemTransition_RangeID transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return true;
return false;
}
public bool ContainsDeleted(Transition myTransition)
{
foreach (ItemTransition_RangeID transition in DeletedList)
if (transition.TransitionID == myTransition.TransitionID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ItemTransition_RangeID itemTransitionRangeID in this)
if ((hasBrokenRules = itemTransitionRangeID.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ItemTransitions_RangeID New()
{
return new ItemTransitions_RangeID();
}
internal static ItemTransitions_RangeID Get(SafeDataReader dr)
{
return new ItemTransitions_RangeID(dr);
}
public static ItemTransitions_RangeID GetByRangeID(int rangeID)
{
try
{
return DataPortal.Fetch<ItemTransitions_RangeID>(new RangeIDCriteria(rangeID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemTransitions_RangeID.GetByRangeID", ex);
}
}
private ItemTransitions_RangeID()
{
MarkAsChild();
}
internal ItemTransitions_RangeID(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ItemTransition_RangeID.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RangeIDCriteria
{
public RangeIDCriteria(int rangeID)
{
_RangeID = rangeID;
}
private int _RangeID;
public int RangeID
{
get { return _RangeID; }
set { _RangeID = value; }
}
}
private void DataPortal_Fetch(RangeIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemTransitions_RangeID.DataPortal_FetchRangeID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getTransitionsByRangeID";
cm.Parameters.AddWithValue("@RangeID", criteria.RangeID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ItemTransition_RangeID(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemTransitions_RangeID.DataPortal_FetchRangeID", ex);
throw new DbCslaException("ItemTransitions_RangeID.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Item item)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ItemTransition_RangeID obj in DeletedList)
obj.DeleteSelf(item);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ItemTransition_RangeID obj in this)
{
if (obj.IsNew)
obj.Insert(item);
else
obj.Update(item);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ItemTransitions_RangeIDPropertyDescriptor pd = new ItemTransitions_RangeIDPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ItemTransitions_RangeIDPropertyDescriptor : vlnListPropertyDescriptor
{
private ItemTransition_RangeID Item { get { return (ItemTransition_RangeID) _Item;} }
public ItemTransitions_RangeIDPropertyDescriptor(ItemTransitions_RangeID collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ItemTransitions_RangeIDConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemTransitions_RangeID)
{
// Return department and department role separated by comma.
return ((ItemTransitions_RangeID) value).Items.Count.ToString() + " Transitions_RangeID";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemTransitions_ToID Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemTransitions_ToIDConverter))]
public partial class ItemTransitions_ToID : BusinessListBase<ItemTransitions_ToID, ItemTransition_ToID>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public ItemTransition_ToID this[Transition myTransition]
{
get
{
foreach (ItemTransition_ToID transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return transition;
return null;
}
}
public new System.Collections.Generic.IList<ItemTransition_ToID> Items
{
get { return base.Items; }
}
public ItemTransition_ToID GetItem(Transition myTransition)
{
foreach (ItemTransition_ToID transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return transition;
return null;
}
public ItemTransition_ToID Add(Content myContent, Item myItemRangeID) // One to Many
{
ItemTransition_ToID transition = ItemTransition_ToID.New(myContent, myItemRangeID);
this.Add(transition);
return transition;
}
public void Remove(Transition myTransition)
{
foreach (ItemTransition_ToID transition in this)
{
if (transition.TransitionID == myTransition.TransitionID)
{
Remove(transition);
break;
}
}
}
public bool Contains(Transition myTransition)
{
foreach (ItemTransition_ToID transition in this)
if (transition.TransitionID == myTransition.TransitionID)
return true;
return false;
}
public bool ContainsDeleted(Transition myTransition)
{
foreach (ItemTransition_ToID transition in DeletedList)
if (transition.TransitionID == myTransition.TransitionID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(ItemTransition_ToID itemTransitionToID in this)
if ((hasBrokenRules = itemTransitionToID.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static ItemTransitions_ToID New()
{
return new ItemTransitions_ToID();
}
internal static ItemTransitions_ToID Get(SafeDataReader dr)
{
return new ItemTransitions_ToID(dr);
}
public static ItemTransitions_ToID GetByToID(int toID)
{
try
{
return DataPortal.Fetch<ItemTransitions_ToID>(new ToIDCriteria(toID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemTransitions_ToID.GetByToID", ex);
}
}
private ItemTransitions_ToID()
{
MarkAsChild();
}
internal ItemTransitions_ToID(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(ItemTransition_ToID.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ToIDCriteria
{
public ToIDCriteria(int toID)
{
_ToID = toID;
}
private int _ToID;
public int ToID
{
get { return _ToID; }
set { _ToID = value; }
}
}
private void DataPortal_Fetch(ToIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemTransitions_ToID.DataPortal_FetchToID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getTransitionsByToID";
cm.Parameters.AddWithValue("@ToID", criteria.ToID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ItemTransition_ToID(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemTransitions_ToID.DataPortal_FetchToID", ex);
throw new DbCslaException("ItemTransitions_ToID.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Item item)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ItemTransition_ToID obj in DeletedList)
obj.DeleteSelf(item);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ItemTransition_ToID obj in this)
{
if (obj.IsNew)
obj.Insert(item);
else
obj.Update(item);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
ItemTransitions_ToIDPropertyDescriptor pd = new ItemTransitions_ToIDPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class ItemTransitions_ToIDPropertyDescriptor : vlnListPropertyDescriptor
{
private ItemTransition_ToID Item { get { return (ItemTransition_ToID) _Item;} }
public ItemTransitions_ToIDPropertyDescriptor(ItemTransitions_ToID collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class ItemTransitions_ToIDConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemTransitions_ToID)
{
// Return department and department role separated by comma.
return ((ItemTransitions_ToID) value).Items.Count.ToString() + " Transitions_ToID";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,407 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<MembershipInfo> _AllList = new List<MembershipInfo>();
private static Dictionary<string, MembershipInfo> _AllByPrimaryKey = new Dictionary<string, MembershipInfo>();
private static void ConvertListToDictionary()
{
List<MembershipInfo> remove = new List<MembershipInfo>();
foreach (MembershipInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.UGID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (MembershipInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(MembershipInfoList lst)
{
foreach (MembershipInfo item in lst) _AllList.Add(item);
}
public static MembershipInfo GetExistingByPrimaryKey(int ugid)
{
ConvertListToDictionary();
string key = ugid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 MembershipInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(UGID.ToString());
}
public virtual Membership Get()
{
return _Editable = Membership.Get(_UGID);
}
public static void Refresh(Membership tmp)
{
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Membership tmp)
{
_UID = tmp.UID;
_GID = tmp.GID;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
_MyUser = null;
_MyGroup = null;
OnChange();// raise an event
}
public static void Refresh(GroupMembership tmp)
{
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(GroupMembership tmp)
{
_UID = tmp.UID;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
_MyUser = null;
_MyGroup = null;
OnChange();// raise an event
}
public static void Refresh(UserMembership tmp)
{
MembershipInfo tmpInfo = GetExistingByPrimaryKey(tmp.UGID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(UserMembership tmp)
{
_GID = tmp.GID;
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_MembershipInfoExtension.Refresh(this);
_MyUser = null;
_MyGroup = null;
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 = GetExistingByPrimaryKey(ugid);
if (tmp == null)
{
tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// NextItems Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(NextItemsConverter))]
public partial class NextItems : BusinessListBase<NextItems, Item>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public new Item this[int itemID]
{
get
{
foreach (Item item in this)
if (item.ItemID == itemID)
return item;
return null;
}
}
public new System.Collections.Generic.IList<Item> Items
{
get { return base.Items; }
}
public Item GetItem(int itemID)
{
foreach (Item item in this)
if (item.ItemID == itemID)
return item;
return null;
}
public Item Add(Content myContent) // One to Many
{
Item item = Item.New(myContent);
this.Add(item);
return item;
}
public void Remove(int itemID)
{
foreach (Item item in this)
{
if (item.ItemID == itemID)
{
Remove(item);
break;
}
}
}
public bool Contains(int itemID)
{
foreach (Item item in this)
if (item.ItemID == itemID)
return true;
return false;
}
public bool ContainsDeleted(int itemID)
{
foreach (Item item in DeletedList)
if (item.ItemID == itemID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(Item item in this)
if ((hasBrokenRules = item.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static NextItems New()
{
return new NextItems();
}
internal static NextItems Get(SafeDataReader dr, Item parent)
{
return new NextItems(dr, parent);
}
public static NextItems GetByPreviousID(int previousID)
{
try
{
return DataPortal.Fetch<NextItems>(new PreviousIDCriteria(previousID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on NextItems.GetByPreviousID", ex);
}
}
private NextItems()
{
MarkAsChild();
}
internal NextItems(SafeDataReader dr, Item parent)
{
MarkAsChild();
Fetch(dr, parent);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr, Item parent)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(Item.Get(dr, parent));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class PreviousIDCriteria
{
public PreviousIDCriteria(int previousID)
{
_PreviousID = previousID;
}
private int _PreviousID;
public int PreviousID
{
get { return _PreviousID; }
set { _PreviousID = value; }
}
}
private void DataPortal_Fetch(PreviousIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] NextItems.DataPortal_FetchPreviousID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getNextItems";
cm.Parameters.AddWithValue("@PreviousID", criteria.PreviousID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new Item(dr, criteria.PreviousID));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("NextItems.DataPortal_FetchPreviousID", ex);
throw new DbCslaException("NextItems.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Item item)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (Item obj in DeletedList)
obj.DeleteSelf(item);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (Item obj in this)
{
if (obj.IsNew)
obj.SQLInsert();
else
obj.SQLUpdate();
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
NextItemsPropertyDescriptor pd = new NextItemsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class NextItemsPropertyDescriptor : vlnListPropertyDescriptor
{
private Item Item { get { return (Item) _Item;} }
public NextItemsPropertyDescriptor(NextItems collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class NextItemsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is NextItems)
{
// Return department and department role separated by comma.
return ((NextItems) value).Items.Count.ToString() + " Items";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@@ -0,0 +1,957 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// Part Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(PartConverter))]
public partial class Part : BusinessBase<Part>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<Part> _RefreshParts = new List<Part>();
private void AddToRefreshList(List<Part> refreshParts)
{
if (IsDirty)
refreshParts.Add(this);
}
private void BuildRefreshList()
{
_RefreshParts = new List<Part>();
AddToRefreshList(_RefreshParts);
}
private void ProcessRefreshList()
{
foreach (Part tmp in _RefreshParts)
{
PartInfo.Refresh(tmp);
if(tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
if(tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem);
}
}
#endregion
#region Collection
protected static List<Part> _AllList = new List<Part>();
private static Dictionary<string, Part> _AllByPrimaryKey = new Dictionary<string, Part>();
private static void ConvertListToDictionary()
{
List<Part> remove = new List<Part>();
foreach (Part tmp in _AllList)
{
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (Part tmp in remove)
_AllList.Remove(tmp);
}
public static Part GetExistingByPrimaryKey(int contentID, int fromType)
{
ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#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 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
public override bool IsDirty
{
get { return base.IsDirty || (_MyContent == null? false : _MyContent.IsDirty) || (_MyItem == null? false : _MyItem.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null? true : _MyContent.IsValid) && (_MyItem == null? true : _MyItem.IsValid); }
}
// TODO: Replace base Part.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Part</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Part.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 Part</returns>
protected override object GetIdValue()
{
return (_ContentID.ToString()+"."+_FromType.ToString()).GetHashCode();
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get {
if(_CheckingBrokenRules)return null;
if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_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<Part>(MyItemRequired, "MyItem");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
//ValidationRules.AddDependantProperty("x", "y");
_PartExtension.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_PartExtension.AddInstanceValidationRules(ValidationRules);
// TODO: Add other validation rules
}
private static bool MyItemRequired(Part 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(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(FromType, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
_PartExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//TODO: Who can read/write which fields
_PartExtension.AddInstanceAuthorizationRules(AuthorizationRules);
}
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; } }
protected Part()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString());
}
public static Part New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Part");
try
{
return DataPortal.Create<Part>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on Part.New", ex);
}
}
public static Part New(Content myContent, int fromType, Item myItem)
{
Part tmp = Part.New();
tmp._MyContent = myContent;
tmp._FromType = fromType;
tmp.MyItem = myItem;
return tmp;
}
public static Part New(Content myContent, int fromType, Item myItem, DateTime dts, string userID)
{
Part tmp = Part.New();
tmp._MyContent = myContent;
tmp._FromType = fromType;
tmp.MyItem = myItem;
tmp.DTS = dts;
tmp.UserID = userID;
return tmp;
}
public static Part MakePart(Content myContent, int fromType, Item myItem, DateTime dts, string userID)
{
Part tmp = Part.New(myContent, fromType, myItem, dts, userID);
if (tmp.IsSavable)
tmp = tmp.Save();
else
{
Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules();
tmp._ErrorMessage = "Failed Validation:";
foreach (Csla.Validation.BrokenRule br in brc)
{
tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName;
}
}
return tmp;
}
public static Part Get(int contentID, int fromType)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Part");
try
{
Part tmp = GetExistingByPrimaryKey(contentID, fromType);
if (tmp == null)
{
tmp = DataPortal.Fetch<Part>(new PKCriteria(contentID, fromType));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Part.Get", ex);
}
}
public static Part Get(SafeDataReader dr)
{
if (dr.Read()) return new Part(dr);
return null;
}
internal Part(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(int contentID, int fromType)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Part");
try
{
DataPortal.Delete(new PKCriteria(contentID, fromType));
}
catch (Exception ex)
{
throw new DbCslaException("Error on Part.Delete", ex);
}
}
public override Part Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Part");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Part");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Part");
try
{
BuildRefreshList();
Part part = base.Save();
_AllList.Add(part);//Refresh the item in AllList
ProcessRefreshList();
return part;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[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;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
// Database Defaults
_DTS = _PartExtension.DefaultDTS;
_UserID = _PartExtension.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
MarkOld();
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Part.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.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("Part.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Part.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
SQLInsert();
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Part.DataPortal_Insert", ex);
}
finally
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
try
{
if(_MyContent != null) _MyContent.Update();
if(_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addPart";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", ContentID);
cm.Parameters.AddWithValue("@FromType", _FromType);
cm.Parameters.AddWithValue("@ItemID", ItemID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
MarkOld();
// update child objects
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Part.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, Content myContent, int fromType, Item myItem, DateTime dts, string userID)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addPart";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", myContent.ContentID);
cm.Parameters.AddWithValue("@FromType", fromType);
cm.Parameters.AddWithValue("@ItemID", myItem.ItemID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.Add", ex);
throw new DbCslaException("Part.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Update", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
SQLUpdate();
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Update", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLUpdate()
{
if (!IsDirty) return; // If not dirty - nothing to do
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.SQLUpdate", GetHashCode());
try
{
if(_MyContent != null) _MyContent.Update();
if(_MyItem != null) _MyItem.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updatePart";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@ContentID", ContentID);
cm.Parameters.AddWithValue("@FromType", _FromType);
cm.Parameters.AddWithValue("@ItemID", ItemID);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
MarkOld();
// use the open connection to update child objects
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.SQLUpdate", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
internal void Update()
{
if (!this.IsDirty) return;
if (base.IsDirty)
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (IsNew)
_LastChanged = Part.Add(cn, _MyContent, _FromType, _MyItem, _DTS, _UserID);
else
_LastChanged = Part.Update(cn, _MyContent, _FromType, _MyItem, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, Content myContent, int fromType, Item myItem, DateTime dts, string userID, ref byte[] lastChanged)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updatePart";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ContentID", myContent.ContentID);
cm.Parameters.AddWithValue("@FromType", fromType);
cm.Parameters.AddWithValue("@ItemID", myItem.ItemID);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.Update", ex);
throw new DbCslaException("Part.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_ContentID, _FromType));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deletePart";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
cm.Parameters.AddWithValue("@FromType", criteria.FromType);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Part.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int contentID, int fromType)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deletePart";
// Input PK Fields
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@FromType", fromType);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.Remove", ex);
throw new DbCslaException("Part.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int contentID, int fromType)
{
ExistsCommand result;
try
{
result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(contentID, fromType));
return result.Exists;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Part.Exists", ex);
}
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _ContentID;
private int _FromType;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int contentID, int fromType)
{
_ContentID = contentID;
_FromType = fromType;
}
protected override void DataPortal_Execute()
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] Part.DataPortal_Execute", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsPart";
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@FromType", _FromType);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("Part.DataPortal_Execute", ex);
throw new DbCslaException("Part.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
PartExtension _PartExtension = new PartExtension();
[Serializable()]
partial class PartExtension : 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 PartConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is Part)
{
// Return the ToString value
return ((Part)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create PartExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class Part
// {
// partial class PartExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,370 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<PartInfo> _AllList = new List<PartInfo>();
private static Dictionary<string, PartInfo> _AllByPrimaryKey = new Dictionary<string, PartInfo>();
private static void ConvertListToDictionary()
{
List<PartInfo> remove = new List<PartInfo>();
foreach (PartInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.ContentID.ToString() + "_" + tmp.FromType.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (PartInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(PartInfoList lst)
{
foreach (PartInfo item in lst) _AllList.Add(item);
}
public static PartInfo GetExistingByPrimaryKey(int contentID, int fromType)
{
ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 PartInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString());
}
public virtual Part Get()
{
return _Editable = Part.Get(_ContentID, _FromType);
}
public static void Refresh(Part tmp)
{
PartInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID, tmp.FromType);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Part tmp)
{
_ItemID = tmp.ItemID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
_MyContent = null;
_MyItem = null;
OnChange();// raise an event
}
public static void Refresh(Content myContent, ContentPart tmp)
{
PartInfo tmpInfo = GetExistingByPrimaryKey(myContent.ContentID, tmp.FromType);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ContentPart tmp)
{
_ItemID = tmp.ItemID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
_MyContent = null;
_MyItem = null;
OnChange();// raise an event
}
public static void Refresh(ItemPart tmp)
{
PartInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID, tmp.FromType);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ItemPart tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_PartInfoExtension.Refresh(this);
_MyContent = null;
_MyItem = null;
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 = GetExistingByPrimaryKey(contentID, fromType);
if (tmp == null)
{
tmp = DataPortal.Fetch<PartInfo>(new PKCriteria(contentID, fromType));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,425 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<PermissionInfo> _AllList = new List<PermissionInfo>();
private static Dictionary<string, PermissionInfo> _AllByPrimaryKey = new Dictionary<string, PermissionInfo>();
private static void ConvertListToDictionary()
{
List<PermissionInfo> remove = new List<PermissionInfo>();
foreach (PermissionInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.PID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (PermissionInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(PermissionInfoList lst)
{
foreach (PermissionInfo item in lst) _AllList.Add(item);
}
public static PermissionInfo GetExistingByPrimaryKey(int pid)
{
ConvertListToDictionary();
string key = pid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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 PermissionInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(PID.ToString());
}
public virtual Permission Get()
{
return _Editable = Permission.Get(_PID);
}
public static void Refresh(Permission tmp)
{
PermissionInfo tmpInfo = GetExistingByPrimaryKey(tmp.PID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Permission tmp)
{
_RID = tmp.RID;
_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);
_MyRole = null;
OnChange();// raise an event
}
public static void Refresh(RolePermission tmp)
{
PermissionInfo tmpInfo = GetExistingByPrimaryKey(tmp.PID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private 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);
_MyRole = null;
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 = GetExistingByPrimaryKey(pid);
if (tmp == null)
{
tmp = DataPortal.Fetch<PermissionInfo>(new PKCriteria(pid));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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

View File

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

View File

@@ -0,0 +1,197 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// PropertyDescriptor Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class vlnListPropertyDescriptor : PropertyDescriptor
{
protected object _Item = null;
public vlnListPropertyDescriptor(System.Collections.IList collection, int index)
: base("#" + index.ToString(), null)
{ _Item = collection[index]; }
public override bool CanResetValue(object component)
{ return true; }
public override Type ComponentType
{ get { return _Item.GetType(); } }
public override object GetValue(object component)
{ return _Item; }
public override bool IsReadOnly
{ get { return false; } }
public override Type PropertyType
{ get { return _Item.GetType(); } }
public override void ResetValue(object component)
{ ;}
public override bool ShouldSerializeValue(object component)
{ return true; }
public override void SetValue(object component, object value)
{ /*_Item = value*/;}
//public override AttributeCollection Attributes
//{ get { return new AttributeCollection(null); } }
public override string DisplayName
{ get { return _Item.ToString(); } }
public override string Description
{ get { return _Item.ToString(); } }
public override string Name
{ get { return _Item.ToString(); } }
} // Class
public interface IVEHasBrokenRules
{
IVEHasBrokenRules HasBrokenRules { get; }
BrokenRulesCollection BrokenRules { get; }
}
} // Namespace
// The following are samples of ToString overrides
// public partial class Annotation
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class AnnotationInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class AnnotationType
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class AnnotationTypeAnnotation
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class AnnotationTypeInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Assignment
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class AssignmentInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Connection
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ConnectionFolder
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ConnectionInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Content
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ContentDetail
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ContentItem
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ContentPart
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ContentRoUsage
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ContentTransition
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ContentInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Detail
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class DetailInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Document
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class DocumentEntry
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class DocumentInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class DocVersion
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class DocVersionInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Entry
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class EntryInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Folder
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class FolderAssignment
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class FolderDocVersion
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class FolderInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Format
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class FormatContent
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class FormatDocVersion
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class FormatFolder
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class FormatInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Group
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class GroupAssignment
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class GroupMembership
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class GroupInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Item
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ItemAnnotation
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ItemDocVersion
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ItemPart
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ItemTransition_RangeID
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ItemTransition_ToID
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ItemInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Membership
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class MembershipInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Part
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class PartInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Permission
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class PermissionInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Role
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class RoleAssignment
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class RolePermission
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class RoleInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class RoUsage
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class RoUsageInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class Transition
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class TransitionInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class User
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class UserMembership
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class UserInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ZContent
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ZContentInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ZTransition
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class ZTransitionInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,348 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void 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
protected static List<RoUsageInfo> _AllList = new List<RoUsageInfo>();
private static Dictionary<string, RoUsageInfo> _AllByPrimaryKey = new Dictionary<string, RoUsageInfo>();
private static void ConvertListToDictionary()
{
List<RoUsageInfo> remove = new List<RoUsageInfo>();
foreach (RoUsageInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.ROUsageID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (RoUsageInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(RoUsageInfoList lst)
{
foreach (RoUsageInfo item in lst) _AllList.Add(item);
}
public static RoUsageInfo GetExistingByPrimaryKey(int rOUsageID)
{
ConvertListToDictionary();
string key = rOUsageID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
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;
}
}
// 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 RoUsageInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ROUsageID.ToString());
}
public virtual RoUsage Get()
{
return _Editable = RoUsage.Get(_ROUsageID);
}
public static void Refresh(RoUsage tmp)
{
RoUsageInfo tmpInfo = GetExistingByPrimaryKey(tmp.ROUsageID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(RoUsage tmp)
{
_ContentID = tmp.ContentID;
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_RoUsageInfoExtension.Refresh(this);
_MyContent = null;
OnChange();// raise an event
}
public static void Refresh(ContentRoUsage tmp)
{
RoUsageInfo tmpInfo = GetExistingByPrimaryKey(tmp.ROUsageID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ContentRoUsage tmp)
{
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_RoUsageInfoExtension.Refresh(this);
_MyContent = null;
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 = GetExistingByPrimaryKey(rOUsageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RoUsageInfo>(new PKCriteria(rOUsageID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") 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");
}
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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,751 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// RoleAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RoleAssignmentConverter))]
public partial class RoleAssignment : BusinessBase<RoleAssignment>, 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 _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AID",true);
if (_MyAssignment != null) _AID = _MyAssignment.AID;
return _AID;
}
}
private Assignment _MyAssignment;
[System.ComponentModel.DataObjectField(true, true)]
public Assignment MyAssignment
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAssignment",true);
if (_MyAssignment == null && _AID != 0) _MyAssignment = Assignment.Get(_AID);
return _MyAssignment;
}
}
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 Group _MyGroup;
public Group MyGroup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyGroup",true);
if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID);
return _MyGroup;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyGroup",true);
if (_MyGroup != value)
{
_MyGroup = value;
PropertyHasChanged();
}
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFolder",true);
if (_MyFolder != value)
{
_MyFolder = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StartDate",true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("StartDate",true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("EndDate",true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("EndDate",true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID",true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _Folder_ParentID;
public int Folder_ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ParentID",true);
return _Folder_ParentID;
}
}
private int _Folder_DBID;
public int Folder_DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DBID",true);
return _Folder_DBID;
}
}
private string _Folder_Name = string.Empty;
public string Folder_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Name",true);
return _Folder_Name;
}
}
private string _Folder_Title = string.Empty;
public string Folder_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Title",true);
return _Folder_Title;
}
}
private string _Folder_ShortName = string.Empty;
public string Folder_ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ShortName",true);
return _Folder_ShortName;
}
}
private int? _Folder_FormatID;
public int? Folder_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_FormatID",true);
return _Folder_FormatID;
}
}
private string _Folder_Config = string.Empty;
public string Folder_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Config",true);
return _Folder_Config;
}
}
private DateTime _Folder_DTS = new DateTime();
public DateTime Folder_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DTS",true);
return _Folder_DTS;
}
}
private string _Folder_UsrID = string.Empty;
public string Folder_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_UsrID",true);
return _Folder_UsrID;
}
}
private string _Group_GroupName = string.Empty;
public string Group_GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_GroupName",true);
return _Group_GroupName;
}
}
private int? _Group_GroupType;
public int? Group_GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_GroupType",true);
return _Group_GroupType;
}
}
private string _Group_Config = string.Empty;
public string Group_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_Config",true);
return _Group_Config;
}
}
private DateTime _Group_DTS = new DateTime();
public DateTime Group_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_DTS",true);
return _Group_DTS;
}
}
private string _Group_UsrID = string.Empty;
public string Group_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Group_UsrID",true);
return _Group_UsrID;
}
}
// TODO: Check RoleAssignment.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 RoleAssignment</returns>
protected override object GetIdValue()
{
return _AID;
}
// TODO: Replace base RoleAssignment.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoleAssignment</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyGroup == null ? false : _MyGroup.IsDirty) || (_MyFolder == null ? false : _MyFolder.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyGroup == null ? true : _MyGroup.IsValid) && (_MyFolder == null ? true : _MyFolder.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 (_MyGroup != null && (hasBrokenRules = _MyGroup.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.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<RoleAssignment>(MyGroupRequired, "MyGroup");
ValidationRules.AddRule<RoleAssignment>(MyFolderRequired, "MyFolder");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule<RoleAssignment>(StartDateValid, "StartDate");
ValidationRules.AddRule<RoleAssignment>(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private static bool StartDateValid(RoleAssignment target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool EndDateValid(RoleAssignment target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._EndDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool MyGroupRequired(RoleAssignment target, Csla.Validation.RuleArgs e)
{
if (target._GID == 0 && target._MyGroup == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
private static bool MyFolderRequired(RoleAssignment target, Csla.Validation.RuleArgs e)
{
if (target._FolderID == 0 && target._MyFolder == 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(AID, "<Role(s)>");
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<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 RoleAssignment New(Group myGroup, Folder myFolder)
{
return new RoleAssignment(myGroup, myFolder);
}
internal static RoleAssignment Get(SafeDataReader dr)
{
return new RoleAssignment(dr);
}
public RoleAssignment()
{
MarkAsChild();
_AID = Assignment.NextAID;
_StartDate = _RoleAssignmentExtension.DefaultStartDate;
_DTS = _RoleAssignmentExtension.DefaultDTS;
_UsrID = _RoleAssignmentExtension.DefaultUsrID;
ValidationRules.CheckRules();
}
private RoleAssignment(Group myGroup, Folder myFolder)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = _RoleAssignmentExtension.DefaultStartDate;
_DTS = _RoleAssignmentExtension.DefaultDTS;
_UsrID = _RoleAssignmentExtension.DefaultUsrID;
_MyGroup = myGroup;
_MyFolder = myFolder;
ValidationRules.CheckRules();
}
internal RoleAssignment(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleAssignment.FetchDR", GetHashCode());
try
{
_AID = dr.GetInt32("AID");
_GID = dr.GetInt32("GID");
_FolderID = dr.GetInt32("FolderID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Folder_ParentID = dr.GetInt32("Folder_ParentID");
_Folder_DBID = dr.GetInt32("Folder_DBID");
_Folder_Name = dr.GetString("Folder_Name");
_Folder_Title = dr.GetString("Folder_Title");
_Folder_ShortName = dr.GetString("Folder_ShortName");
_Folder_FormatID = (int?)dr.GetValue("Folder_FormatID");
_Folder_Config = dr.GetString("Folder_Config");
_Folder_DTS = dr.GetDateTime("Folder_DTS");
_Folder_UsrID = dr.GetString("Folder_UsrID");
_Group_GroupName = dr.GetString("Group_GroupName");
_Group_GroupType = (int?)dr.GetValue("Group_GroupType");
_Group_Config = dr.GetString("Group_Config");
_Group_DTS = dr.GetDateTime("Group_DTS");
_Group_UsrID = dr.GetString("Group_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoleAssignment.FetchDR", ex);
throw new DbCslaException("RoleAssignment.Fetch", ex);
}
MarkOld();
}
internal void Insert(Role myRole)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Assignment.Add(cn, ref _AID, _MyGroup, myRole, _MyFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(Role myRole)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Assignment.Update(cn, ref _AID, _MyGroup, myRole, _MyFolder, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Role myRole)
{
// 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"];
Assignment.Remove(cn, _AID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RoleAssignmentExtension _RoleAssignmentExtension = new RoleAssignmentExtension();
[Serializable()]
partial class RoleAssignmentExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
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 RoleAssignmentConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RoleAssignment)
{
// Return the ToString value
return ((RoleAssignment)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RoleAssignmentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class RoleAssignment
// {
// partial class RoleAssignmentExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@@ -0,0 +1,290 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// RoleAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RoleAssignmentsConverter))]
public partial class RoleAssignments : BusinessListBase<RoleAssignments, RoleAssignment>, ICustomTypeDescriptor, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
// One To Many
public RoleAssignment this[Assignment myAssignment]
{
get
{
foreach (RoleAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return assignment;
return null;
}
}
public new System.Collections.Generic.IList<RoleAssignment> Items
{
get { return base.Items; }
}
public RoleAssignment GetItem(Assignment myAssignment)
{
foreach (RoleAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return assignment;
return null;
}
public RoleAssignment Add(Group myGroup, Folder myFolder) // One to Many
{
RoleAssignment assignment = RoleAssignment.New(myGroup, myFolder);
this.Add(assignment);
return assignment;
}
public void Remove(Assignment myAssignment)
{
foreach (RoleAssignment assignment in this)
{
if (assignment.AID == myAssignment.AID)
{
Remove(assignment);
break;
}
}
}
public bool Contains(Assignment myAssignment)
{
foreach (RoleAssignment assignment in this)
if (assignment.AID == myAssignment.AID)
return true;
return false;
}
public bool ContainsDeleted(Assignment myAssignment)
{
foreach (RoleAssignment assignment in DeletedList)
if (assignment.AID == myAssignment.AID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules=null;
foreach(RoleAssignment roleAssignment in this)
if ((hasBrokenRules = roleAssignment.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
#endregion
#region Factory Methods
internal static RoleAssignments New()
{
return new RoleAssignments();
}
internal static RoleAssignments Get(SafeDataReader dr)
{
return new RoleAssignments(dr);
}
public static RoleAssignments GetByRID(int rid)
{
try
{
return DataPortal.Fetch<RoleAssignments>(new RIDCriteria(rid));
}
catch (Exception ex)
{
throw new DbCslaException("Error on RoleAssignments.GetByRID", ex);
}
}
private RoleAssignments()
{
MarkAsChild();
}
internal RoleAssignments(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(RoleAssignment.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RIDCriteria
{
public RIDCriteria(int rid)
{
_RID = rid;
}
private int _RID;
public int RID
{
get { return _RID; }
set { _RID = value; }
}
}
private void DataPortal_Fetch(RIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] RoleAssignments.DataPortal_FetchRID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAssignmentsByRID";
cm.Parameters.AddWithValue("@RID", criteria.RID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new RoleAssignment(dr));
}
}
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("RoleAssignments.DataPortal_FetchRID", ex);
throw new DbCslaException("RoleAssignments.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(Role role)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (RoleAssignment obj in DeletedList)
obj.DeleteSelf(role);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (RoleAssignment obj in this)
{
if (obj.IsNew)
obj.Insert(role);
else
obj.Update(role);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
for (int i = 0; i < this.Items.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
RoleAssignmentsPropertyDescriptor pd = new RoleAssignmentsPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
} // Class
#region Property Descriptor
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public partial class RoleAssignmentsPropertyDescriptor : vlnListPropertyDescriptor
{
private RoleAssignment Item { get { return (RoleAssignment) _Item;} }
public RoleAssignmentsPropertyDescriptor(RoleAssignments collection, int index):base(collection, index){;}
}
#endregion
#region Converter
internal class RoleAssignmentsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RoleAssignments)
{
// Return department and department role separated by comma.
return ((RoleAssignments) value).Items.Count.ToString() + " Assignments";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

Some files were not shown because too many files have changed in this diff Show More