This commit is contained in:
Kathy Ruffing 2009-01-27 15:45:38 +00:00
parent a95b610d3f
commit 258b503bed
21 changed files with 9137 additions and 14 deletions

View File

@ -0,0 +1,440 @@
// ========================================================================
// 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>
/// RODbROFst Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbROFstConverter))]
public partial class RODbROFst : BusinessBase<RODbROFst>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFst _MyROFst;
[System.ComponentModel.DataObjectField(true, true)]
public ROFst MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROFst", true);
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFst.Get(_ROFstID);
return _MyROFst;
}
}
private byte[] _ROLookup;
public byte[] ROLookup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROLookup", true);
return _ROLookup;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROLookup", true);
if (_ROLookup != value)
{
_ROLookup = 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 RODbROFst.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current RODbROFst</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
// TODO: Replace base RODbROFst.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbROFst</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.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(ROFstID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROLookup, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROLookup, "<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 RODbROFst New(byte[] rOLookup)
{
return new RODbROFst(rOLookup);
}
internal static RODbROFst Get(SafeDataReader dr)
{
return new RODbROFst(dr);
}
public RODbROFst()
{
MarkAsChild();
_ROFstID = ROFst.NextROFstID;
_DTS = _RODbROFstExtension.DefaultDTS;
_UserID = _RODbROFstExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private RODbROFst(byte[] rOLookup)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _RODbROFstExtension.DefaultDTS;
_UserID = _RODbROFstExtension.DefaultUserID;
_ROLookup = rOLookup;
ValidationRules.CheckRules();
}
internal RODbROFst(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbROFst.FetchDR", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_ROLookup = (byte[])dr.GetValue("ROLookup");
_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("RODbROFst.FetchDR", ex);
throw new DbCslaException("RODbROFst.Fetch", ex);
}
MarkOld();
}
internal void Insert(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFst.Add(cn, ref _ROFstID, myRODb, _ROLookup, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROFst.Update(cn, ref _ROFstID, myRODb, _ROLookup, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
ROFst.Remove(cn, _ROFstID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RODbROFstExtension _RODbROFstExtension = new RODbROFstExtension();
[Serializable()]
partial class RODbROFstExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class RODbROFstConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbROFst)
{
// Return the ToString value
return ((RODbROFst)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RODbROFstExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class RODbROFst
// {
// partial class RODbROFstExtension : 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,304 @@
// ========================================================================
// 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>
/// RODbROFsts Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbROFstsConverter))]
public partial class RODbROFsts : BusinessListBase<RODbROFsts, RODbROFst>, 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 RODbROFst this[ROFst myROFst]
{
get
{
foreach (RODbROFst rOFst in this)
if (rOFst.ROFstID == myROFst.ROFstID)
return rOFst;
return null;
}
}
public new System.Collections.Generic.IList<RODbROFst> Items
{
get { return base.Items; }
}
public RODbROFst GetItem(ROFst myROFst)
{
foreach (RODbROFst rOFst in this)
if (rOFst.ROFstID == myROFst.ROFstID)
return rOFst;
return null;
}
public RODbROFst Add(byte[] rOLookup) // One to Many
{
RODbROFst rOFst = RODbROFst.New(rOLookup);
this.Add(rOFst);
return rOFst;
}
public void Remove(ROFst myROFst)
{
foreach (RODbROFst rOFst in this)
{
if (rOFst.ROFstID == myROFst.ROFstID)
{
Remove(rOFst);
break;
}
}
}
public bool Contains(ROFst myROFst)
{
foreach (RODbROFst rOFst in this)
if (rOFst.ROFstID == myROFst.ROFstID)
return true;
return false;
}
public bool ContainsDeleted(ROFst myROFst)
{
foreach (RODbROFst rOFst in DeletedList)
if (rOFst.ROFstID == myROFst.ROFstID)
return true;
return false;
}
public bool Contains(DateTime dts)
{
foreach (RODbROFst rOFst in this)
if (rOFst.DTS == dts)
return true;
return false;
}
public bool ContainsDeleted(DateTime dts)
{
foreach (RODbROFst rOFst in DeletedList)
if (rOFst.DTS == dts)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (RODbROFst rODbROFst in this)
if ((hasBrokenRules = rODbROFst.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 RODbROFsts New()
{
return new RODbROFsts();
}
internal static RODbROFsts Get(SafeDataReader dr)
{
return new RODbROFsts(dr);
}
public static RODbROFsts GetByRODbID(int rODbID)
{
try
{
return DataPortal.Fetch<RODbROFsts>(new RODbIDCriteria(rODbID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on RODbROFsts.GetByRODbID", ex);
}
}
private RODbROFsts()
{
MarkAsChild();
}
internal RODbROFsts(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(RODbROFst.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RODbIDCriteria
{
public RODbIDCriteria(int rODbID)
{
_RODbID = rODbID;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
}
private void DataPortal_Fetch(RODbIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbROFsts.DataPortal_FetchRODbID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getROFstsByRODbID";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new RODbROFst(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbROFsts.DataPortal_FetchRODbID", ex);
throw new DbCslaException("RODbROFsts.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(RODb rODb)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (RODbROFst obj in DeletedList)
obj.DeleteSelf(rODb);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (RODbROFst obj in this)
{
if (obj.IsNew)
obj.Insert(rODb);
else
obj.Update(rODb);
}
}
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
RODbROFstsPropertyDescriptor pd = new RODbROFstsPropertyDescriptor(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 RODbROFstsPropertyDescriptor : vlnListPropertyDescriptor
{
private RODbROFst Item { get { return (RODbROFst)_Item; } }
public RODbROFstsPropertyDescriptor(RODbROFsts collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class RODbROFstsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbROFsts)
{
// Return department and department role separated by comma.
return ((RODbROFsts)value).Items.Count.ToString() + " ROFsts";
}
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>
/// RODbROImage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbROImageConverter))]
public partial class RODbROImage : BusinessBase<RODbROImage>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ImageID", true);
if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
return _ImageID;
}
}
private ROImage _MyROImage;
[System.ComponentModel.DataObjectField(true, true)]
public ROImage MyROImage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROImage", true);
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
return _MyROImage;
}
}
private string _FileName = string.Empty;
public string FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FileName", true);
return _FileName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("FileName", true);
if (value == null) value = string.Empty;
if (_FileName != value)
{
_FileName = value;
PropertyHasChanged();
}
}
}
private byte[] _Content;
public byte[] Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content", true);
return _Content;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Content", true);
if (_Content != value)
{
_Content = value;
PropertyHasChanged();
}
}
}
private 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 RODbROImage.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current RODbROImage</returns>
protected override object GetIdValue()
{
return _ImageID;
}
// TODO: Replace base RODbROImage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbROImage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "FileName");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("FileName", 255));
ValidationRules.AddRule(
Csla.Validation.CommonRules.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(ImageID, "<Role(s)>");
//AuthorizationRules.AllowRead(FileName, "<Role(s)>");
//AuthorizationRules.AllowWrite(FileName, "<Role(s)>");
//AuthorizationRules.AllowRead(Content, "<Role(s)>");
//AuthorizationRules.AllowWrite(Content, "<Role(s)>");
//AuthorizationRules.AllowRead(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 RODbROImage New(string fileName, byte[] content)
{
return new RODbROImage(fileName, content);
}
internal static RODbROImage Get(SafeDataReader dr)
{
return new RODbROImage(dr);
}
public RODbROImage()
{
MarkAsChild();
_ImageID = ROImage.NextImageID;
_DTS = _RODbROImageExtension.DefaultDTS;
_UserID = _RODbROImageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private RODbROImage(string fileName, byte[] content)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _RODbROImageExtension.DefaultDTS;
_UserID = _RODbROImageExtension.DefaultUserID;
_FileName = fileName;
_Content = content;
ValidationRules.CheckRules();
}
internal RODbROImage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbROImage.FetchDR", GetHashCode());
try
{
_ImageID = dr.GetInt32("ImageID");
_FileName = dr.GetString("FileName");
_Content = (byte[])dr.GetValue("Content");
_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("RODbROImage.FetchDR", ex);
throw new DbCslaException("RODbROImage.Fetch", ex);
}
MarkOld();
}
internal void Insert(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROImage.Add(cn, ref _ImageID, myRODb, _FileName, _Content, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = ROImage.Update(cn, ref _ImageID, myRODb, _FileName, _Content, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
ROImage.Remove(cn, _ImageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RODbROImageExtension _RODbROImageExtension = new RODbROImageExtension();
[Serializable()]
partial class RODbROImageExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class RODbROImageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbROImage)
{
// Return the ToString value
return ((RODbROImage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RODbROImageExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class RODbROImage
// {
// partial class RODbROImageExtension : 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,304 @@
// ========================================================================
// 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>
/// RODbROImages Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbROImagesConverter))]
public partial class RODbROImages : BusinessListBase<RODbROImages, RODbROImage>, 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 RODbROImage this[ROImage myROImage]
{
get
{
foreach (RODbROImage rOImage in this)
if (rOImage.ImageID == myROImage.ImageID)
return rOImage;
return null;
}
}
public new System.Collections.Generic.IList<RODbROImage> Items
{
get { return base.Items; }
}
public RODbROImage GetItem(ROImage myROImage)
{
foreach (RODbROImage rOImage in this)
if (rOImage.ImageID == myROImage.ImageID)
return rOImage;
return null;
}
public RODbROImage Add(string fileName, byte[] content) // One to Many
{
RODbROImage rOImage = RODbROImage.New(fileName, content);
this.Add(rOImage);
return rOImage;
}
public void Remove(ROImage myROImage)
{
foreach (RODbROImage rOImage in this)
{
if (rOImage.ImageID == myROImage.ImageID)
{
Remove(rOImage);
break;
}
}
}
public bool Contains(ROImage myROImage)
{
foreach (RODbROImage rOImage in this)
if (rOImage.ImageID == myROImage.ImageID)
return true;
return false;
}
public bool ContainsDeleted(ROImage myROImage)
{
foreach (RODbROImage rOImage in DeletedList)
if (rOImage.ImageID == myROImage.ImageID)
return true;
return false;
}
public bool Contains(string fileName, DateTime dts)
{
foreach (RODbROImage rOImage in this)
if (rOImage.FileName == fileName && rOImage.DTS == dts)
return true;
return false;
}
public bool ContainsDeleted(string fileName, DateTime dts)
{
foreach (RODbROImage rOImage in DeletedList)
if (rOImage.FileName == fileName && rOImage.DTS == dts)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (RODbROImage rODbROImage in this)
if ((hasBrokenRules = rODbROImage.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 RODbROImages New()
{
return new RODbROImages();
}
internal static RODbROImages Get(SafeDataReader dr)
{
return new RODbROImages(dr);
}
public static RODbROImages GetByRODbID(int rODbID)
{
try
{
return DataPortal.Fetch<RODbROImages>(new RODbIDCriteria(rODbID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on RODbROImages.GetByRODbID", ex);
}
}
private RODbROImages()
{
MarkAsChild();
}
internal RODbROImages(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(RODbROImage.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RODbIDCriteria
{
public RODbIDCriteria(int rODbID)
{
_RODbID = rODbID;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
}
private void DataPortal_Fetch(RODbIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbROImages.DataPortal_FetchRODbID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getROImagesByRODbID";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new RODbROImage(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbROImages.DataPortal_FetchRODbID", ex);
throw new DbCslaException("RODbROImages.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(RODb rODb)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (RODbROImage obj in DeletedList)
obj.DeleteSelf(rODb);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (RODbROImage obj in this)
{
if (obj.IsNew)
obj.Insert(rODb);
else
obj.Update(rODb);
}
}
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
RODbROImagesPropertyDescriptor pd = new RODbROImagesPropertyDescriptor(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 RODbROImagesPropertyDescriptor : vlnListPropertyDescriptor
{
private RODbROImage Item { get { return (RODbROImage)_Item; } }
public RODbROImagesPropertyDescriptor(RODbROImages collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class RODbROImagesConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbROImages)
{
// Return department and department role separated by comma.
return ((RODbROImages)value).Items.Count.ToString() + " ROImages";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,590 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// RODbRoUsage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbRoUsageConverter))]
public partial class RODbRoUsage : BusinessBase<RODbRoUsage>, 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 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 Content _MyContent;
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;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyContent", true);
if (_MyContent != value)
{
_MyContent = value;
PropertyHasChanged();
}
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROID", true);
return _ROID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROID", true);
if (value == null) value = string.Empty;
if (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config", true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private 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 RODbRoUsage.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 RODbRoUsage</returns>
protected override object GetIdValue()
{
return _ROUsageID;
}
// TODO: Replace base RODbRoUsage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RODbRoUsage</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<RODbRoUsage>(MyContentRequired, "MyContent");
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
}
private static bool MyContentRequired(RODbRoUsage target, Csla.Validation.RuleArgs e)
{
if (target._ContentID == 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(ROUsageID, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<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 RODbRoUsage New(string roid)
{
return new RODbRoUsage(roid);
}
internal static RODbRoUsage Get(SafeDataReader dr)
{
return new RODbRoUsage(dr);
}
public RODbRoUsage()
{
MarkAsChild();
_ROUsageID = RoUsage.NextROUsageID;
_ContentID = _RODbRoUsageExtension.DefaultContentID;
_DTS = _RODbRoUsageExtension.DefaultDTS;
_UserID = _RODbRoUsageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private RODbRoUsage(string roid)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_ContentID = _RODbRoUsageExtension.DefaultContentID;
_DTS = _RODbRoUsageExtension.DefaultDTS;
_UserID = _RODbRoUsageExtension.DefaultUserID;
_ROID = roid;
ValidationRules.CheckRules();
}
internal RODbRoUsage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbRoUsage.FetchDR", 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");
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("RODbRoUsage.FetchDR", ex);
throw new DbCslaException("RODbRoUsage.Fetch", ex);
}
MarkOld();
}
internal void Insert(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Add(cn, ref _ROUsageID, _MyContent, _ROID, _Config, _DTS, _UserID, myRODb);
MarkOld();
}
internal void Update(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Update(cn, ref _ROUsageID, _MyContent, _ROID, _Config, _DTS, _UserID, ref _LastChanged, myRODb);
MarkOld();
}
internal void DeleteSelf(RODb myRODb)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
RoUsage.Remove(cn, _ROUsageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
RODbRoUsageExtension _RODbRoUsageExtension = new RODbRoUsageExtension();
[Serializable()]
partial class RODbRoUsageExtension : 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 RODbRoUsageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbRoUsage)
{
// Return the ToString value
return ((RODbRoUsage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RODbRoUsageExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class RODbRoUsage
// {
// partial class RODbRoUsageExtension : 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>
/// RODbRoUsages Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RODbRoUsagesConverter))]
public partial class RODbRoUsages : BusinessListBase<RODbRoUsages, RODbRoUsage>, 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 RODbRoUsage this[RoUsage myRoUsage]
{
get
{
foreach (RODbRoUsage roUsage in this)
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
return roUsage;
return null;
}
}
public new System.Collections.Generic.IList<RODbRoUsage> Items
{
get { return base.Items; }
}
public RODbRoUsage GetItem(RoUsage myRoUsage)
{
foreach (RODbRoUsage roUsage in this)
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
return roUsage;
return null;
}
public RODbRoUsage Add(string roid) // One to Many
{
RODbRoUsage roUsage = RODbRoUsage.New(roid);
this.Add(roUsage);
return roUsage;
}
public void Remove(RoUsage myRoUsage)
{
foreach (RODbRoUsage roUsage in this)
{
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
{
Remove(roUsage);
break;
}
}
}
public bool Contains(RoUsage myRoUsage)
{
foreach (RODbRoUsage roUsage in this)
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
return true;
return false;
}
public bool ContainsDeleted(RoUsage myRoUsage)
{
foreach (RODbRoUsage roUsage in DeletedList)
if (roUsage.ROUsageID == myRoUsage.ROUsageID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (RODbRoUsage rODbRoUsage in this)
if ((hasBrokenRules = rODbRoUsage.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 RODbRoUsages New()
{
return new RODbRoUsages();
}
internal static RODbRoUsages Get(SafeDataReader dr)
{
return new RODbRoUsages(dr);
}
public static RODbRoUsages GetByRODbID(int rODbID)
{
try
{
return DataPortal.Fetch<RODbRoUsages>(new RODbIDCriteria(rODbID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on RODbRoUsages.GetByRODbID", ex);
}
}
private RODbRoUsages()
{
MarkAsChild();
}
internal RODbRoUsages(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(RODbRoUsage.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RODbIDCriteria
{
public RODbIDCriteria(int rODbID)
{
_RODbID = rODbID;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
}
private void DataPortal_Fetch(RODbIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbRoUsages.DataPortal_FetchRODbID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRoUsagesByRODbID";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new RODbRoUsage(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RODbRoUsages.DataPortal_FetchRODbID", ex);
throw new DbCslaException("RODbRoUsages.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(RODb rODb)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (RODbRoUsage obj in DeletedList)
obj.DeleteSelf(rODb);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (RODbRoUsage obj in this)
{
if (obj.IsNew)
obj.Insert(rODb);
else
obj.Update(rODb);
}
}
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
RODbRoUsagesPropertyDescriptor pd = new RODbRoUsagesPropertyDescriptor(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 RODbRoUsagesPropertyDescriptor : vlnListPropertyDescriptor
{
private RODbRoUsage Item { get { return (RODbRoUsage)_Item; } }
public RODbRoUsagesPropertyDescriptor(RODbRoUsages collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class RODbRoUsagesConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RODbRoUsages)
{
// Return department and department role separated by comma.
return ((RODbRoUsages)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,573 @@
// ========================================================================
// 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>
/// ROFstAssociation Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstAssociationConverter))]
public partial class ROFstAssociation : BusinessBase<ROFstAssociation>, 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 _AssociationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AssociationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AssociationID", true);
if (_MyAssociation != null) _AssociationID = _MyAssociation.AssociationID;
return _AssociationID;
}
}
private Association _MyAssociation;
[System.ComponentModel.DataObjectField(true, true)]
public Association MyAssociation
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAssociation", true);
if (_MyAssociation == null && _AssociationID != 0) _MyAssociation = Association.Get(_AssociationID);
return _MyAssociation;
}
}
private int _VersionID;
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;
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;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyDocVersion", true);
if (_MyDocVersion != value)
{
_MyDocVersion = 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 _DocVersion_FolderID;
public int DocVersion_FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_FolderID", true);
return _DocVersion_FolderID;
}
}
private int _DocVersion_VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int DocVersion_VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_VersionType", true);
return _DocVersion_VersionType;
}
}
private string _DocVersion_Name = string.Empty;
public string DocVersion_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_Name", true);
return _DocVersion_Name;
}
}
private string _DocVersion_Title = string.Empty;
public string DocVersion_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_Title", true);
return _DocVersion_Title;
}
}
private int? _DocVersion_ItemID;
public int? DocVersion_ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_ItemID", true);
return _DocVersion_ItemID;
}
}
private int? _DocVersion_FormatID;
public int? DocVersion_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_FormatID", true);
return _DocVersion_FormatID;
}
}
private string _DocVersion_Config = string.Empty;
public string DocVersion_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_Config", true);
return _DocVersion_Config;
}
}
private DateTime _DocVersion_DTS = new DateTime();
public DateTime DocVersion_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_DTS", true);
return _DocVersion_DTS;
}
}
private string _DocVersion_UserID = string.Empty;
public string DocVersion_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocVersion_UserID", true);
return _DocVersion_UserID;
}
}
// TODO: Check ROFstAssociation.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 ROFstAssociation</returns>
protected override object GetIdValue()
{
return _AssociationID;
}
// TODO: Replace base ROFstAssociation.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstAssociation</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyDocVersion == null ? false : _MyDocVersion.IsDirty); }
}
public override bool IsValid
{
get { return true;} // (IsNew && !IsDirty ? true : base.IsValid) && (_MyDocVersion == null ? true : _MyDocVersion.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 (_MyDocVersion != null && (hasBrokenRules = _MyDocVersion.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<ROFstAssociation>(MyDocVersionRequired, "MyDocVersion");
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 MyDocVersionRequired(ROFstAssociation target, Csla.Validation.RuleArgs e)
{
if (target._VersionID == 0 && target._MyDocVersion == 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(AssociationID, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionID, "<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 ROFstAssociation New(DocVersion myDocVersion)
{
return new ROFstAssociation(myDocVersion);
}
internal static ROFstAssociation Get(SafeDataReader dr)
{
return new ROFstAssociation(dr);
}
public ROFstAssociation()
{
MarkAsChild();
_AssociationID = Association.NextAssociationID;
_DTS = _ROFstAssociationExtension.DefaultDTS;
_UserID = _ROFstAssociationExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROFstAssociation(DocVersion myDocVersion)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROFstAssociationExtension.DefaultDTS;
_UserID = _ROFstAssociationExtension.DefaultUserID;
_MyDocVersion = myDocVersion;
ValidationRules.CheckRules();
}
internal ROFstAssociation(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstAssociation.FetchDR", GetHashCode());
try
{
_AssociationID = dr.GetInt32("AssociationID");
_VersionID = dr.GetInt32("VersionID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_DocVersion_FolderID = dr.GetInt32("DocVersion_FolderID");
_DocVersion_VersionType = dr.GetInt32("DocVersion_VersionType");
_DocVersion_Name = dr.GetString("DocVersion_Name");
_DocVersion_Title = dr.GetString("DocVersion_Title");
_DocVersion_ItemID = (int?)dr.GetValue("DocVersion_ItemID");
_DocVersion_FormatID = (int?)dr.GetValue("DocVersion_FormatID");
_DocVersion_Config = dr.GetString("DocVersion_Config");
_DocVersion_DTS = dr.GetDateTime("DocVersion_DTS");
_DocVersion_UserID = dr.GetString("DocVersion_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstAssociation.FetchDR", ex);
throw new DbCslaException("ROFstAssociation.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Association.Add(cn, ref _AssociationID, _MyDocVersion, myROFst, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Association.Update(cn, ref _AssociationID, _MyDocVersion, myROFst, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Association.Remove(cn, _AssociationID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROFstAssociationExtension _ROFstAssociationExtension = new ROFstAssociationExtension();
[Serializable()]
partial class ROFstAssociationExtension : 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 ROFstAssociationConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstAssociation)
{
// Return the ToString value
return ((ROFstAssociation)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ROFstAssociationExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ROFstAssociation
// {
// partial class ROFstAssociationExtension : 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,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>
/// ROFstAssociations Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstAssociationsConverter))]
public partial class ROFstAssociations : BusinessListBase<ROFstAssociations, ROFstAssociation>, 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 ROFstAssociation this[Association myAssociation]
{
get
{
foreach (ROFstAssociation association in this)
if (association.AssociationID == myAssociation.AssociationID)
return association;
return null;
}
}
public new System.Collections.Generic.IList<ROFstAssociation> Items
{
get { return base.Items; }
}
public ROFstAssociation GetItem(Association myAssociation)
{
foreach (ROFstAssociation association in this)
if (association.AssociationID == myAssociation.AssociationID)
return association;
return null;
}
public ROFstAssociation Add(DocVersion myDocVersion) // One to Many with unique fields
{
if (!Contains(myDocVersion))
{
ROFstAssociation association = ROFstAssociation.New(myDocVersion);
this.Add(association);
return association;
}
else
throw new InvalidOperationException("association already exists");
}
public void Remove(Association myAssociation)
{
foreach (ROFstAssociation association in this)
{
if (association.AssociationID == myAssociation.AssociationID)
{
Remove(association);
break;
}
}
}
public bool Contains(Association myAssociation)
{
foreach (ROFstAssociation association in this)
if (association.AssociationID == myAssociation.AssociationID)
return true;
return false;
}
public bool ContainsDeleted(Association myAssociation)
{
foreach (ROFstAssociation association in DeletedList)
if (association.AssociationID == myAssociation.AssociationID)
return true;
return false;
}
public bool Contains(DocVersion myDocVersion)
{
foreach (ROFstAssociation association in this)
if (association.VersionID == myDocVersion.VersionID)
return true;
return false;
}
public bool ContainsDeleted(DocVersion myDocVersion)
{
foreach (ROFstAssociation association in DeletedList)
if (association.VersionID == myDocVersion.VersionID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (ROFstAssociation rOFstAssociation in this)
if ((hasBrokenRules = rOFstAssociation.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 ROFstAssociations New()
{
return new ROFstAssociations();
}
internal static ROFstAssociations Get(SafeDataReader dr)
{
return new ROFstAssociations(dr);
}
public static ROFstAssociations GetByROFstID(int rOFstID)
{
try
{
return DataPortal.Fetch<ROFstAssociations>(new ROFstIDCriteria(rOFstID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstAssociations.GetByROFstID", ex);
}
}
private ROFstAssociations()
{
MarkAsChild();
}
internal ROFstAssociations(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(ROFstAssociation.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ROFstIDCriteria
{
public ROFstIDCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
private int _ROFstID;
public int ROFstID
{
get { return _ROFstID; }
set { _ROFstID = value; }
}
}
private void DataPortal_Fetch(ROFstIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstAssociations.DataPortal_FetchROFstID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAssociationsByROFstID";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ROFstAssociation(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstAssociations.DataPortal_FetchROFstID", ex);
throw new DbCslaException("ROFstAssociations.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(ROFst rOFst)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ROFstAssociation obj in DeletedList)
obj.DeleteSelf(rOFst);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ROFstAssociation obj in this)
{
if (obj.IsNew)
obj.Insert(rOFst);
else
obj.Update(rOFst);
}
}
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
ROFstAssociationsPropertyDescriptor pd = new ROFstAssociationsPropertyDescriptor(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 ROFstAssociationsPropertyDescriptor : vlnListPropertyDescriptor
{
private ROFstAssociation Item { get { return (ROFstAssociation)_Item; } }
public ROFstAssociationsPropertyDescriptor(ROFstAssociations collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ROFstAssociationsConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstAssociations)
{
// Return department and department role separated by comma.
return ((ROFstAssociations)value).Items.Count.ToString() + " Associations";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,537 @@
// ========================================================================
// 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>
/// ROFstFigure Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstFigureConverter))]
public partial class ROFstFigure : BusinessBase<ROFstFigure>, 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 _FigureID;
[System.ComponentModel.DataObjectField(true, true)]
public int FigureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FigureID", true);
if (_MyFigure != null) _FigureID = _MyFigure.FigureID;
return _FigureID;
}
}
private Figure _MyFigure;
[System.ComponentModel.DataObjectField(true, true)]
public Figure MyFigure
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFigure", true);
if (_MyFigure == null && _FigureID != 0) _MyFigure = Figure.Get(_FigureID);
return _MyFigure;
}
}
private int _ImageID;
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ImageID", true);
if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
return _ImageID;
}
}
private ROImage _MyROImage;
public ROImage MyROImage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROImage", true);
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImage.Get(_ImageID);
return _MyROImage;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyROImage", true);
if (_MyROImage != value)
{
_MyROImage = 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 _ROImage_RODbID;
public int ROImage_RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_RODbID", true);
return _ROImage_RODbID;
}
}
private string _ROImage_FileName = string.Empty;
public string ROImage_FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_FileName", true);
return _ROImage_FileName;
}
}
private byte[] _ROImage_Content;
public byte[] ROImage_Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_Content", true);
return _ROImage_Content;
}
}
private string _ROImage_Config = string.Empty;
public string ROImage_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_Config", true);
return _ROImage_Config;
}
}
private DateTime _ROImage_DTS = new DateTime();
public DateTime ROImage_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_DTS", true);
return _ROImage_DTS;
}
}
private string _ROImage_UserID = string.Empty;
public string ROImage_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImage_UserID", true);
return _ROImage_UserID;
}
}
// TODO: Check ROFstFigure.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 ROFstFigure</returns>
protected override object GetIdValue()
{
return _FigureID;
}
// TODO: Replace base ROFstFigure.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstFigure</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyROImage == null ? false : _MyROImage.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyROImage == null ? true : _MyROImage.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 (_MyROImage != null && (hasBrokenRules = _MyROImage.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<ROFstFigure>(MyROImageRequired, "MyROImage");
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 MyROImageRequired(ROFstFigure target, Csla.Validation.RuleArgs e)
{
if (target._ImageID == 0 && target._MyROImage == 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(FigureID, "<Role(s)>");
//AuthorizationRules.AllowRead(ImageID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ImageID, "<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 ROFstFigure New(ROImage myROImage)
{
return new ROFstFigure(myROImage);
}
internal static ROFstFigure Get(SafeDataReader dr)
{
return new ROFstFigure(dr);
}
public ROFstFigure()
{
MarkAsChild();
_FigureID = Figure.NextFigureID;
_DTS = _ROFstFigureExtension.DefaultDTS;
_UserID = _ROFstFigureExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROFstFigure(ROImage myROImage)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROFstFigureExtension.DefaultDTS;
_UserID = _ROFstFigureExtension.DefaultUserID;
_MyROImage = myROImage;
ValidationRules.CheckRules();
}
internal ROFstFigure(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstFigure.FetchDR", GetHashCode());
try
{
_FigureID = dr.GetInt32("FigureID");
_ImageID = dr.GetInt32("ImageID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROImage_RODbID = dr.GetInt32("ROImage_RODbID");
_ROImage_FileName = dr.GetString("ROImage_FileName");
_ROImage_Content = (byte[])dr.GetValue("ROImage_Content");
_ROImage_Config = dr.GetString("ROImage_Config");
_ROImage_DTS = dr.GetDateTime("ROImage_DTS");
_ROImage_UserID = dr.GetString("ROImage_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstFigure.FetchDR", ex);
throw new DbCslaException("ROFstFigure.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Figure.Add(cn, ref _FigureID, myROFst, _MyROImage, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Figure.Update(cn, ref _FigureID, myROFst, _MyROImage, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROFst myROFst)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Figure.Remove(cn, _FigureID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROFstFigureExtension _ROFstFigureExtension = new ROFstFigureExtension();
[Serializable()]
partial class ROFstFigureExtension : 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 ROFstFigureConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstFigure)
{
// Return the ToString value
return ((ROFstFigure)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ROFstFigureExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ROFstFigure
// {
// partial class ROFstFigureExtension : 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,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>
/// ROFstFigures Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstFiguresConverter))]
public partial class ROFstFigures : BusinessListBase<ROFstFigures, ROFstFigure>, 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 ROFstFigure this[Figure myFigure]
{
get
{
foreach (ROFstFigure figure in this)
if (figure.FigureID == myFigure.FigureID)
return figure;
return null;
}
}
public new System.Collections.Generic.IList<ROFstFigure> Items
{
get { return base.Items; }
}
public ROFstFigure GetItem(Figure myFigure)
{
foreach (ROFstFigure figure in this)
if (figure.FigureID == myFigure.FigureID)
return figure;
return null;
}
public ROFstFigure Add(ROImage myROImage) // One to Many with unique fields
{
if (!Contains(myROImage))
{
ROFstFigure figure = ROFstFigure.New(myROImage);
this.Add(figure);
return figure;
}
else
throw new InvalidOperationException("figure already exists");
}
public void Remove(Figure myFigure)
{
foreach (ROFstFigure figure in this)
{
if (figure.FigureID == myFigure.FigureID)
{
Remove(figure);
break;
}
}
}
public bool Contains(Figure myFigure)
{
foreach (ROFstFigure figure in this)
if (figure.FigureID == myFigure.FigureID)
return true;
return false;
}
public bool ContainsDeleted(Figure myFigure)
{
foreach (ROFstFigure figure in DeletedList)
if (figure.FigureID == myFigure.FigureID)
return true;
return false;
}
public bool Contains(ROImage myROImage)
{
foreach (ROFstFigure figure in this)
if (figure.ImageID == myROImage.ImageID)
return true;
return false;
}
public bool ContainsDeleted(ROImage myROImage)
{
foreach (ROFstFigure figure in DeletedList)
if (figure.ImageID == myROImage.ImageID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (ROFstFigure rOFstFigure in this)
if ((hasBrokenRules = rOFstFigure.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 ROFstFigures New()
{
return new ROFstFigures();
}
internal static ROFstFigures Get(SafeDataReader dr)
{
return new ROFstFigures(dr);
}
public static ROFstFigures GetByROFstID(int rOFstID)
{
try
{
return DataPortal.Fetch<ROFstFigures>(new ROFstIDCriteria(rOFstID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstFigures.GetByROFstID", ex);
}
}
private ROFstFigures()
{
MarkAsChild();
}
internal ROFstFigures(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(ROFstFigure.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ROFstIDCriteria
{
public ROFstIDCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
private int _ROFstID;
public int ROFstID
{
get { return _ROFstID; }
set { _ROFstID = value; }
}
}
private void DataPortal_Fetch(ROFstIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstFigures.DataPortal_FetchROFstID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFiguresByROFstID";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ROFstFigure(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstFigures.DataPortal_FetchROFstID", ex);
throw new DbCslaException("ROFstFigures.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(ROFst rOFst)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ROFstFigure obj in DeletedList)
obj.DeleteSelf(rOFst);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ROFstFigure obj in this)
{
if (obj.IsNew)
obj.Insert(rOFst);
else
obj.Update(rOFst);
}
}
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
ROFstFiguresPropertyDescriptor pd = new ROFstFiguresPropertyDescriptor(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 ROFstFiguresPropertyDescriptor : vlnListPropertyDescriptor
{
private ROFstFigure Item { get { return (ROFstFigure)_Item; } }
public ROFstFiguresPropertyDescriptor(ROFstFigures collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ROFstFiguresConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstFigures)
{
// Return department and department role separated by comma.
return ((ROFstFigures)value).Items.Count.ToString() + " Figures";
}
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 ROFstInfoEvent(object sender);
/// <summary>
/// ROFstInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstInfoConverter))]
public partial class ROFstInfo : ReadOnlyBase<ROFstInfo>, IDisposable
{
public event ROFstInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<ROFstInfo> _CacheList = new List<ROFstInfo>();
protected static void AddToCache(ROFstInfo rOFstInfo)
{
if (!_CacheList.Contains(rOFstInfo)) _CacheList.Add(rOFstInfo); // In AddToCache
}
protected static void RemoveFromCache(ROFstInfo rOFstInfo)
{
while (_CacheList.Contains(rOFstInfo)) _CacheList.Remove(rOFstInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ROFstInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROFstInfo>>();
private static void ConvertListToDictionary()
{
List<ROFstInfo> remove = new List<ROFstInfo>();
foreach (ROFstInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROFstID.ToString()))
{
_CacheByPrimaryKey[tmp.ROFstID.ToString()] = new List<ROFstInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ROFstID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ROFstInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ROFstInfoList lst)
{
foreach (ROFstInfo item in lst) AddToCache(item);
}
protected static ROFstInfo GetCachedByPrimaryKey(int rOFstID)
{
ConvertListToDictionary();
string key = rOFstID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected ROFst _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ROFstID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
return _ROFstID;
}
}
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
private byte[] _ROLookup;
public byte[] ROLookup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROLookup", true);
return _ROLookup;
}
}
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 _ROFstAssociationCount = 0;
/// <summary>
/// Count of ROFstAssociations for this ROFst
/// </summary>
public int ROFstAssociationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstAssociationCount", true);
return _ROFstAssociationCount;
}
}
private AssociationInfoList _ROFstAssociations = null;
[TypeConverter(typeof(AssociationInfoListConverter))]
public AssociationInfoList ROFstAssociations
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstAssociations", true);
if (_ROFstAssociationCount < 0 || (_ROFstAssociationCount > 0 && _ROFstAssociations == null))
_ROFstAssociations = AssociationInfoList.GetByROFstID(_ROFstID);
if (_ROFstAssociationCount < 0)
_ROFstAssociationCount = _ROFstAssociations.Count;
return _ROFstAssociations;
}
}
public void RefreshROFstAssociations()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ROFstID.ToString()))
foreach (ROFstInfo tmp in _CacheByPrimaryKey[_ROFstID.ToString()])
tmp._ROFstAssociationCount = -1; // This will cause the data to be requeried
}
private int _ROFstFigureCount = 0;
/// <summary>
/// Count of ROFstFigures for this ROFst
/// </summary>
public int ROFstFigureCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstFigureCount", true);
return _ROFstFigureCount;
}
}
private FigureInfoList _ROFstFigures = null;
[TypeConverter(typeof(FigureInfoListConverter))]
public FigureInfoList ROFstFigures
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstFigures", true);
if (_ROFstFigureCount < 0 || (_ROFstFigureCount > 0 && _ROFstFigures == null))
_ROFstFigures = FigureInfoList.GetByROFstID(_ROFstID);
if (_ROFstFigureCount < 0)
_ROFstFigureCount = _ROFstFigures.Count;
return _ROFstFigures;
}
}
public void RefreshROFstFigures()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ROFstID.ToString()))
foreach (ROFstInfo tmp in _CacheByPrimaryKey[_ROFstID.ToString()])
tmp._ROFstFigureCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ROFstInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROFstInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ROFstInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ROFstInfo</returns>
protected override object GetIdValue()
{
return _ROFstID;
}
#endregion
#region Factory Methods
private static int _ROFstInfoUnique = 0;
private static int ROFstInfoUnique
{ get { return ++_ROFstInfoUnique; } }
private int _MyROFstInfoUnique = ROFstInfoUnique;
public int MyROFstInfoUnique
{ get { return _MyROFstInfoUnique; } }
protected ROFstInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ROFstID.ToString())) return;
List<ROFstInfo> listROFstInfo = _CacheByPrimaryKey[ROFstID.ToString()]; // Get the list of items
while (listROFstInfo.Contains(this)) listROFstInfo.Remove(this); // Remove the item from the list
if (listROFstInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ROFstID.ToString()); // remove the list
}
public virtual ROFst Get()
{
return _Editable = ROFst.Get(_ROFstID);
}
public static void Refresh(ROFst tmp)
{
string key = tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROFst tmp)
{
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for new value
_ROLookup = tmp.ROLookup;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstInfoExtension.Refresh(this);
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbROFst tmp)
{
string key = tmp.ROFstID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROFstInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbROFst tmp)
{
_ROLookup = tmp.ROLookup;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROFstInfoExtension.Refresh(this);
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static ROFstInfo Get(int rOFstID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFstInfo tmp = GetCachedByPrimaryKey(rOFstID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROFstInfo>(new PKCriteria(rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFstInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROFstInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfo.Constructor", ex);
throw new DbCslaException("ROFstInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.ReadData", GetHashCode());
try
{
_ROFstID = dr.GetInt32("ROFstID");
_RODbID = dr.GetInt32("RODbID");
_ROLookup = (byte[])dr.GetValue("ROLookup");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ROFstAssociationCount = dr.GetInt32("AssociationCount");
_ROFstFigureCount = dr.GetInt32("FigureCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getROFst";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROFstInfoExtension _ROFstInfoExtension = new ROFstInfoExtension();
[Serializable()]
partial class ROFstInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ROFstInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ROFstInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstInfo)
{
// Return the ToString value
return ((ROFstInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,262 @@
// ========================================================================
// 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>
/// ROFstInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROFstInfoListConverter))]
public partial class ROFstInfoList : ReadOnlyListBase<ROFstInfoList, ROFstInfo>, 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<ROFstInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (ROFstInfo tmp in this)
{
tmp.Changed += new ROFstInfoEvent(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 (ROFstInfo tmp in this)
{
tmp.Changed -= new ROFstInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static ROFstInfoList _ROFstInfoList = null;
/// <summary>
/// Return a list of all ROFstInfo.
/// </summary>
public static ROFstInfoList Get()
{
try
{
if (_ROFstInfoList != null)
return _ROFstInfoList;
ROFstInfoList tmp = DataPortal.Fetch<ROFstInfoList>();
ROFstInfo.AddList(tmp);
tmp.AddEvents();
_ROFstInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all ROFstInfo.
/// </summary>
public static void Reset()
{
_ROFstInfoList = null;
}
// TODO: Add alternative gets -
//public static ROFstInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<ROFstInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on ROFstInfoList.Get", ex);
// }
//}
public static ROFstInfoList GetByRODbID(int rODbID)
{
try
{
ROFstInfoList tmp = DataPortal.Fetch<ROFstInfoList>(new RODbIDCriteria(rODbID));
ROFstInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstInfoList.GetByRODbID", ex);
}
}
private ROFstInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getROFsts";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ROFstInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ROFstInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RODbIDCriteria
{
public RODbIDCriteria(int rODbID)
{
_RODbID = rODbID;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
}
private void DataPortal_Fetch(RODbIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfoList.DataPortal_FetchRODbID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getROFstsByRODbID";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ROFstInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfoList.DataPortal_FetchRODbID", ex);
throw new DbCslaException("ROFstInfoList.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
ROFstInfoListPropertyDescriptor pd = new ROFstInfoListPropertyDescriptor(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 ROFstInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private ROFstInfo Item { get { return (ROFstInfo)_Item; } }
public ROFstInfoListPropertyDescriptor(ROFstInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ROFstInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROFstInfoList)
{
// Return department and department role separated by comma.
return ((ROFstInfoList)value).Items.Count.ToString() + " ROFsts";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,526 @@
// ========================================================================
// 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>
/// ROImageFigure Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROImageFigureConverter))]
public partial class ROImageFigure : BusinessBase<ROImageFigure>, 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 _FigureID;
[System.ComponentModel.DataObjectField(true, true)]
public int FigureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FigureID", true);
if (_MyFigure != null) _FigureID = _MyFigure.FigureID;
return _FigureID;
}
}
private Figure _MyFigure;
[System.ComponentModel.DataObjectField(true, true)]
public Figure MyFigure
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFigure", true);
if (_MyFigure == null && _FigureID != 0) _MyFigure = Figure.Get(_FigureID);
return _MyFigure;
}
}
private int _ROFstID;
public int ROFstID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFstID", true);
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
return _ROFstID;
}
}
private ROFst _MyROFst;
public ROFst MyROFst
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyROFst", true);
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFst.Get(_ROFstID);
return _MyROFst;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyROFst", true);
if (_MyROFst != value)
{
_MyROFst = 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 _ROFst_RODbID;
public int ROFst_RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_RODbID", true);
return _ROFst_RODbID;
}
}
private byte[] _ROFst_ROLookup;
public byte[] ROFst_ROLookup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_ROLookup", true);
return _ROFst_ROLookup;
}
}
private string _ROFst_Config = string.Empty;
public string ROFst_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_Config", true);
return _ROFst_Config;
}
}
private DateTime _ROFst_DTS = new DateTime();
public DateTime ROFst_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_DTS", true);
return _ROFst_DTS;
}
}
private string _ROFst_UserID = string.Empty;
public string ROFst_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROFst_UserID", true);
return _ROFst_UserID;
}
}
// TODO: Check ROImageFigure.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 ROImageFigure</returns>
protected override object GetIdValue()
{
return _FigureID;
}
// TODO: Replace base ROImageFigure.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROImageFigure</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyROFst == null ? false : _MyROFst.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyROFst == null ? true : _MyROFst.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 (_MyROFst != null && (hasBrokenRules = _MyROFst.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<ROImageFigure>(MyROFstRequired, "MyROFst");
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 MyROFstRequired(ROImageFigure target, Csla.Validation.RuleArgs e)
{
if (target._ROFstID == 0 && target._MyROFst == 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(FigureID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROFstID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROFstID, "<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 ROImageFigure New(ROFst myROFst)
{
return new ROImageFigure(myROFst);
}
internal static ROImageFigure Get(SafeDataReader dr)
{
return new ROImageFigure(dr);
}
public ROImageFigure()
{
MarkAsChild();
_FigureID = Figure.NextFigureID;
_DTS = _ROImageFigureExtension.DefaultDTS;
_UserID = _ROImageFigureExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ROImageFigure(ROFst myROFst)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ROImageFigureExtension.DefaultDTS;
_UserID = _ROImageFigureExtension.DefaultUserID;
_MyROFst = myROFst;
ValidationRules.CheckRules();
}
internal ROImageFigure(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageFigure.FetchDR", GetHashCode());
try
{
_FigureID = dr.GetInt32("FigureID");
_ROFstID = dr.GetInt32("ROFstID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_ROFst_RODbID = dr.GetInt32("ROFst_RODbID");
_ROFst_ROLookup = (byte[])dr.GetValue("ROFst_ROLookup");
_ROFst_Config = dr.GetString("ROFst_Config");
_ROFst_DTS = dr.GetDateTime("ROFst_DTS");
_ROFst_UserID = dr.GetString("ROFst_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageFigure.FetchDR", ex);
throw new DbCslaException("ROImageFigure.Fetch", ex);
}
MarkOld();
}
internal void Insert(ROImage myROImage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Figure.Add(cn, ref _FigureID, _MyROFst, myROImage, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(ROImage myROImage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Figure.Update(cn, ref _FigureID, _MyROFst, myROImage, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(ROImage myROImage)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Figure.Remove(cn, _FigureID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ROImageFigureExtension _ROImageFigureExtension = new ROImageFigureExtension();
[Serializable()]
partial class ROImageFigureExtension : 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 ROImageFigureConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROImageFigure)
{
// Return the ToString value
return ((ROImageFigure)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ROImageFigureExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ROImageFigure
// {
// partial class ROImageFigureExtension : 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,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>
/// ROImageFigures Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROImageFiguresConverter))]
public partial class ROImageFigures : BusinessListBase<ROImageFigures, ROImageFigure>, 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 ROImageFigure this[Figure myFigure]
{
get
{
foreach (ROImageFigure figure in this)
if (figure.FigureID == myFigure.FigureID)
return figure;
return null;
}
}
public new System.Collections.Generic.IList<ROImageFigure> Items
{
get { return base.Items; }
}
public ROImageFigure GetItem(Figure myFigure)
{
foreach (ROImageFigure figure in this)
if (figure.FigureID == myFigure.FigureID)
return figure;
return null;
}
public ROImageFigure Add(ROFst myROFst) // One to Many with unique fields
{
if (!Contains(myROFst))
{
ROImageFigure figure = ROImageFigure.New(myROFst);
this.Add(figure);
return figure;
}
else
throw new InvalidOperationException("figure already exists");
}
public void Remove(Figure myFigure)
{
foreach (ROImageFigure figure in this)
{
if (figure.FigureID == myFigure.FigureID)
{
Remove(figure);
break;
}
}
}
public bool Contains(Figure myFigure)
{
foreach (ROImageFigure figure in this)
if (figure.FigureID == myFigure.FigureID)
return true;
return false;
}
public bool ContainsDeleted(Figure myFigure)
{
foreach (ROImageFigure figure in DeletedList)
if (figure.FigureID == myFigure.FigureID)
return true;
return false;
}
public bool Contains(ROFst myROFst)
{
foreach (ROImageFigure figure in this)
if (figure.ROFstID == myROFst.ROFstID)
return true;
return false;
}
public bool ContainsDeleted(ROFst myROFst)
{
foreach (ROImageFigure figure in DeletedList)
if (figure.ROFstID == myROFst.ROFstID)
return true;
return false;
}
#endregion
#region ValidationRules
public IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
foreach (ROImageFigure rOImageFigure in this)
if ((hasBrokenRules = rOImageFigure.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 ROImageFigures New()
{
return new ROImageFigures();
}
internal static ROImageFigures Get(SafeDataReader dr)
{
return new ROImageFigures(dr);
}
public static ROImageFigures GetByImageID(int imageID)
{
try
{
return DataPortal.Fetch<ROImageFigures>(new ImageIDCriteria(imageID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROImageFigures.GetByImageID", ex);
}
}
private ROImageFigures()
{
MarkAsChild();
}
internal ROImageFigures(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(ROImageFigure.Get(dr));
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ImageIDCriteria
{
public ImageIDCriteria(int imageID)
{
_ImageID = imageID;
}
private int _ImageID;
public int ImageID
{
get { return _ImageID; }
set { _ImageID = value; }
}
}
private void DataPortal_Fetch(ImageIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageFigures.DataPortal_FetchImageID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFiguresByImageID";
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read()) this.Add(new ROImageFigure(dr));
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageFigures.DataPortal_FetchImageID", ex);
throw new DbCslaException("ROImageFigures.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
internal void Update(ROImage rOImage)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ROImageFigure obj in DeletedList)
obj.DeleteSelf(rOImage);// Deletes related record
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (ROImageFigure obj in this)
{
if (obj.IsNew)
obj.Insert(rOImage);
else
obj.Update(rOImage);
}
}
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
ROImageFiguresPropertyDescriptor pd = new ROImageFiguresPropertyDescriptor(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 ROImageFiguresPropertyDescriptor : vlnListPropertyDescriptor
{
private ROImageFigure Item { get { return (ROImageFigure)_Item; } }
public ROImageFiguresPropertyDescriptor(ROImageFigures collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ROImageFiguresConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROImageFigures)
{
// Return department and department role separated by comma.
return ((ROImageFigures)value).Items.Count.ToString() + " Figures";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,441 @@
// ========================================================================
// 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 ROImageInfoEvent(object sender);
/// <summary>
/// ROImageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROImageInfoConverter))]
public partial class ROImageInfo : ReadOnlyBase<ROImageInfo>, IDisposable
{
public event ROImageInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<ROImageInfo> _CacheList = new List<ROImageInfo>();
protected static void AddToCache(ROImageInfo rOImageInfo)
{
if (!_CacheList.Contains(rOImageInfo)) _CacheList.Add(rOImageInfo); // In AddToCache
}
protected static void RemoveFromCache(ROImageInfo rOImageInfo)
{
while (_CacheList.Contains(rOImageInfo)) _CacheList.Remove(rOImageInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ROImageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ROImageInfo>>();
private static void ConvertListToDictionary()
{
List<ROImageInfo> remove = new List<ROImageInfo>();
foreach (ROImageInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ImageID.ToString()))
{
_CacheByPrimaryKey[tmp.ImageID.ToString()] = new List<ROImageInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ImageID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ROImageInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ROImageInfoList lst)
{
foreach (ROImageInfo item in lst) AddToCache(item);
}
protected static ROImageInfo GetCachedByPrimaryKey(int imageID)
{
ConvertListToDictionary();
string key = imageID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected ROImage _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ImageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ImageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ImageID", true);
return _ImageID;
}
}
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
private string _FileName = string.Empty;
public string FileName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FileName", true);
return _FileName;
}
}
private byte[] _Content;
public byte[] Content
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content", true);
return _Content;
}
}
private 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 _ROImageFigureCount = 0;
/// <summary>
/// Count of ROImageFigures for this ROImage
/// </summary>
public int ROImageFigureCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImageFigureCount", true);
return _ROImageFigureCount;
}
}
private FigureInfoList _ROImageFigures = null;
[TypeConverter(typeof(FigureInfoListConverter))]
public FigureInfoList ROImageFigures
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROImageFigures", true);
if (_ROImageFigureCount < 0 || (_ROImageFigureCount > 0 && _ROImageFigures == null))
_ROImageFigures = FigureInfoList.GetByImageID(_ImageID);
if (_ROImageFigureCount < 0)
_ROImageFigureCount = _ROImageFigures.Count;
return _ROImageFigures;
}
}
public void RefreshROImageFigures()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ImageID.ToString()))
foreach (ROImageInfo tmp in _CacheByPrimaryKey[_ImageID.ToString()])
tmp._ROImageFigureCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ROImageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ROImageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ROImageInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ROImageInfo</returns>
protected override object GetIdValue()
{
return _ImageID;
}
#endregion
#region Factory Methods
private static int _ROImageInfoUnique = 0;
private static int ROImageInfoUnique
{ get { return ++_ROImageInfoUnique; } }
private int _MyROImageInfoUnique = ROImageInfoUnique;
public int MyROImageInfoUnique
{ get { return _MyROImageInfoUnique; } }
protected ROImageInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ImageID.ToString())) return;
List<ROImageInfo> listROImageInfo = _CacheByPrimaryKey[ImageID.ToString()]; // Get the list of items
while (listROImageInfo.Contains(this)) listROImageInfo.Remove(this); // Remove the item from the list
if (listROImageInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ImageID.ToString()); // remove the list
}
public virtual ROImage Get()
{
return _Editable = ROImage.Get(_ImageID);
}
public static void Refresh(ROImage tmp)
{
string key = tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ROImage tmp)
{
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbROImages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbROImages(); // Update List for new value
_FileName = tmp.FileName;
_Content = tmp.Content;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROImageInfoExtension.Refresh(this);
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbROImage tmp)
{
string key = tmp.ImageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ROImageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbROImage tmp)
{
_FileName = tmp.FileName;
_Content = tmp.Content;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ROImageInfoExtension.Refresh(this);
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static ROImageInfo Get(int imageID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROImage");
try
{
ROImageInfo tmp = GetCachedByPrimaryKey(imageID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROImageInfo>(new PKCriteria(imageID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROImageInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROImageInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ROImageInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfo.Constructor", ex);
throw new DbCslaException("ROImageInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ImageID;
public int ImageID
{ get { return _ImageID; } }
public PKCriteria(int imageID)
{
_ImageID = imageID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.ReadData", GetHashCode());
try
{
_ImageID = dr.GetInt32("ImageID");
_RODbID = dr.GetInt32("RODbID");
_FileName = dr.GetString("FileName");
_Content = (byte[])dr.GetValue("Content");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ROImageFigureCount = dr.GetInt32("FigureCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROImageInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getROImage";
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROImageInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ROImageInfoExtension _ROImageInfoExtension = new ROImageInfoExtension();
[Serializable()]
partial class ROImageInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ROImageInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ROImageInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROImageInfo)
{
// Return the ToString value
return ((ROImageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -0,0 +1,262 @@
// ========================================================================
// 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>
/// ROImageInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ROImageInfoListConverter))]
public partial class ROImageInfoList : ReadOnlyListBase<ROImageInfoList, ROImageInfo>, 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<ROImageInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (ROImageInfo tmp in this)
{
tmp.Changed += new ROImageInfoEvent(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 (ROImageInfo tmp in this)
{
tmp.Changed -= new ROImageInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static ROImageInfoList _ROImageInfoList = null;
/// <summary>
/// Return a list of all ROImageInfo.
/// </summary>
public static ROImageInfoList Get()
{
try
{
if (_ROImageInfoList != null)
return _ROImageInfoList;
ROImageInfoList tmp = DataPortal.Fetch<ROImageInfoList>();
ROImageInfo.AddList(tmp);
tmp.AddEvents();
_ROImageInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROImageInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all ROImageInfo.
/// </summary>
public static void Reset()
{
_ROImageInfoList = null;
}
// TODO: Add alternative gets -
//public static ROImageInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<ROImageInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on ROImageInfoList.Get", ex);
// }
//}
public static ROImageInfoList GetByRODbID(int rODbID)
{
try
{
ROImageInfoList tmp = DataPortal.Fetch<ROImageInfoList>(new RODbIDCriteria(rODbID));
ROImageInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROImageInfoList.GetByRODbID", ex);
}
}
private ROImageInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getROImages";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ROImageInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ROImageInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RODbIDCriteria
{
public RODbIDCriteria(int rODbID)
{
_RODbID = rODbID;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
}
private void DataPortal_Fetch(RODbIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfoList.DataPortal_FetchRODbID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getROImagesByRODbID";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ROImageInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfoList.DataPortal_FetchRODbID", ex);
throw new DbCslaException("ROImageInfoList.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
ROImageInfoListPropertyDescriptor pd = new ROImageInfoListPropertyDescriptor(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 ROImageInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private ROImageInfo Item { get { return (ROImageInfo)_Item; } }
public ROImageInfoListPropertyDescriptor(ROImageInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ROImageInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ROImageInfoList)
{
// Return department and department role separated by comma.
return ((ROImageInfoList)value).Items.Count.ToString() + " ROImages";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

@ -48,6 +48,7 @@ namespace VEPROMS.CSLA.Library
{
RoUsageInfo.Refresh(tmp);
if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
if (tmp._MyRODb != null) RODbInfo.Refresh(tmp._MyRODb);
}
}
#endregion
@ -223,13 +224,45 @@ namespace VEPROMS.CSLA.Library
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODb _MyRODb;
public RODb MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODb.Get(_RODbID);
return _MyRODb;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyRODb", true);
if (_MyRODb != value)
{
_MyRODb = value;
PropertyHasChanged();
}
}
}
public override bool IsDirty
{
get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty); }
get { return base.IsDirty || (_MyContent == null ? false : _MyContent.IsDirty) || (_MyRODb == null ? false : _MyRODb.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null ? true : _MyContent.IsValid); }
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyContent == null ? true : _MyContent.IsValid) && (_MyRODb == null ? true : _MyRODb.IsValid); }
}
// TODO: Replace base RoUsage.ToString function as necessary
/// <summary>
@ -264,6 +297,7 @@ namespace VEPROMS.CSLA.Library
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyContent != null && (hasBrokenRules = _MyContent.HasBrokenRules) != null) return hasBrokenRules;
if (_MyRODb != null && (hasBrokenRules = _MyRODb.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
@ -297,6 +331,7 @@ namespace VEPROMS.CSLA.Library
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ValidationRules.AddRule<RoUsage>(MyRODbRequired, "MyRODb");
//ValidationRules.AddDependantProperty("x", "y");
_RoUsageExtension.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
@ -315,6 +350,15 @@ namespace VEPROMS.CSLA.Library
}
return true;
}
private static bool MyRODbRequired(RoUsage target, Csla.Validation.RuleArgs e)
{
if (target._RODbID == 0 && target._MyRODb == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
@ -337,11 +381,13 @@ namespace VEPROMS.CSLA.Library
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(RODbID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RODbID, "<Role(s)>");
_RoUsageExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
@ -417,13 +463,14 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on RoUsage.New", ex);
}
}
public static RoUsage New(string roid)
public static RoUsage New(string roid, RODb myRODb)
{
RoUsage tmp = RoUsage.New();
tmp.ROID = roid;
tmp.MyRODb = myRODb;
return tmp;
}
public static RoUsage New(Content myContent, string roid, string config, DateTime dts, string userID)
public static RoUsage New(Content myContent, string roid, string config, DateTime dts, string userID, RODb myRODb)
{
RoUsage tmp = RoUsage.New();
tmp.MyContent = myContent;
@ -431,11 +478,12 @@ namespace VEPROMS.CSLA.Library
tmp.Config = config;
tmp.DTS = dts;
tmp.UserID = userID;
tmp.MyRODb = myRODb;
return tmp;
}
public static RoUsage MakeRoUsage(Content myContent, string roid, string config, DateTime dts, string userID)
public static RoUsage MakeRoUsage(Content myContent, string roid, string config, DateTime dts, string userID, RODb myRODb)
{
RoUsage tmp = RoUsage.New(myContent, roid, config, dts, userID);
RoUsage tmp = RoUsage.New(myContent, roid, config, dts, userID, myRODb);
if (tmp.IsSavable)
{
RoUsage tmp2 = tmp;
@ -453,17 +501,18 @@ namespace VEPROMS.CSLA.Library
}
return tmp;
}
public static RoUsage New(Content myContent, string roid, string config)
public static RoUsage New(Content myContent, string roid, string config, RODb myRODb)
{
RoUsage tmp = RoUsage.New();
tmp.MyContent = myContent;
tmp.ROID = roid;
tmp.Config = config;
tmp.MyRODb = myRODb;
return tmp;
}
public static RoUsage MakeRoUsage(Content myContent, string roid, string config)
public static RoUsage MakeRoUsage(Content myContent, string roid, string config, RODb myRODb)
{
RoUsage tmp = RoUsage.New(myContent, roid, config);
RoUsage tmp = RoUsage.New(myContent, roid, config, myRODb);
if (tmp.IsSavable)
{
RoUsage tmp2 = tmp;
@ -586,6 +635,7 @@ namespace VEPROMS.CSLA.Library
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_RODbID = dr.GetInt32("RODbID");
MarkOld();
}
catch (Exception ex)
@ -662,6 +712,7 @@ namespace VEPROMS.CSLA.Library
try
{
if (_MyContent != null) _MyContent.Update();
if (_MyRODb != null) _MyRODb.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
@ -673,6 +724,7 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@Config", _Config);
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@RODbID", RODbID);
// Output Calculated Columns
SqlParameter param_ROUsageID = new SqlParameter("@newROUsageID", SqlDbType.Int);
param_ROUsageID.Direction = ParameterDirection.Output;
@ -698,7 +750,7 @@ namespace VEPROMS.CSLA.Library
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int rOUsageID, Content myContent, string roid, string config, DateTime dts, string userID)
public static byte[] Add(SqlConnection cn, ref int rOUsageID, Content myContent, string roid, string config, DateTime dts, string userID, RODb myRODb)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.Add", 0);
try
@ -713,6 +765,7 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@Config", config);
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@RODbID", myRODb.RODbID);
// Output Calculated Columns
SqlParameter param_ROUsageID = new SqlParameter("@newROUsageID", SqlDbType.Int);
param_ROUsageID.Direction = ParameterDirection.Output;
@ -764,6 +817,7 @@ namespace VEPROMS.CSLA.Library
try
{
if (_MyContent != null) _MyContent.Update();
if (_MyRODb != null) _MyRODb.Update();
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
@ -779,6 +833,7 @@ namespace VEPROMS.CSLA.Library
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
cm.Parameters.AddWithValue("@RODbID", RODbID);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
@ -806,14 +861,14 @@ namespace VEPROMS.CSLA.Library
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (IsNew)
_LastChanged = RoUsage.Add(cn, ref _ROUsageID, _MyContent, _ROID, _Config, _DTS, _UserID);
_LastChanged = RoUsage.Add(cn, ref _ROUsageID, _MyContent, _ROID, _Config, _DTS, _UserID, _MyRODb);
else
_LastChanged = RoUsage.Update(cn, ref _ROUsageID, _MyContent, _ROID, _Config, _DTS, _UserID, ref _LastChanged);
_LastChanged = RoUsage.Update(cn, ref _ROUsageID, _MyContent, _ROID, _Config, _DTS, _UserID, ref _LastChanged, _MyRODb);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int rOUsageID, Content myContent, string roid, string config, DateTime dts, string userID, ref byte[] lastChanged)
public static byte[] Update(SqlConnection cn, ref int rOUsageID, Content myContent, string roid, string config, DateTime dts, string userID, ref byte[] lastChanged, RODb myRODb)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsage.Update", 0);
try
@ -830,6 +885,7 @@ namespace VEPROMS.CSLA.Library
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
cm.Parameters.AddWithValue("@RODbID", myRODb.RODbID);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;

View File

@ -163,6 +163,28 @@ namespace VEPROMS.CSLA.Library
return _UserID;
}
}
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODbInfo _MyRODb;
public RODbInfo MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
return _MyRODb;
}
}
// TODO: Replace base RoUsageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
@ -227,12 +249,24 @@ namespace VEPROMS.CSLA.Library
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for new value
_RoUsageInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ContentRoUsage tmp)
@ -249,12 +283,58 @@ namespace VEPROMS.CSLA.Library
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
if (_RODbID != tmp.RODbID)
{
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for old value
_RODbID = tmp.RODbID; // Update the value
}
_MyRODb = null; // Reset list so that the next line gets a new list
if (MyRODb != null) MyRODb.RefreshRODbRoUsages(); // Update List for new value
_RoUsageInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RODbRoUsage tmp)
{
string key = tmp.ROUsageID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RoUsageInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RODbRoUsage tmp)
{
if (_ContentID != tmp.ContentID)
{
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentRoUsages(); // Update List for new value
_ROID = tmp.ROID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_RoUsageInfoExtension.Refresh(this);
if(_MyContent != null)
{
_MyContent.Dispose();// Dispose related value
_MyContent = null;// Reset related value
}
if(_MyRODb != null)
{
_MyRODb.Dispose();// Dispose related value
_MyRODb = null;// Reset related value
}
OnChange();// raise an event
}
public static RoUsageInfo Get(int rOUsageID)
@ -318,6 +398,7 @@ namespace VEPROMS.CSLA.Library
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_RODbID = dr.GetInt32("RODbID");
}
catch (Exception ex)
{

View File

@ -58,7 +58,7 @@ namespace VEPROMS.CSLA.Library
#region Factory Methods
public static RoUsageInfoList _RoUsageInfoList = null;
/// <summary>
/// Return a list of all projects.
/// Return a list of all RoUsageInfo.
/// </summary>
public static RoUsageInfoList Get()
{
@ -77,6 +77,13 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on RoUsageInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all RoUsageInfo.
/// </summary>
public static void Reset()
{
_RoUsageInfoList = null;
}
// TODO: Add alternative gets -
//public static RoUsageInfoList Get(<criteria>)
//{
@ -103,6 +110,20 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on RoUsageInfoList.GetByContentID", ex);
}
}
public static RoUsageInfoList GetByRODbID(int rODbID)
{
try
{
RoUsageInfoList tmp = DataPortal.Fetch<RoUsageInfoList>(new RODbIDCriteria(rODbID));
RoUsageInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RoUsageInfoList.GetByRODbID", ex);
}
}
private RoUsageInfoList()
{ /* require use of factory methods */ }
#endregion
@ -178,6 +199,49 @@ namespace VEPROMS.CSLA.Library
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RODbIDCriteria
{
public RODbIDCriteria(int rODbID)
{
_RODbID = rODbID;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
}
private void DataPortal_Fetch(RODbIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RoUsageInfoList.DataPortal_FetchRODbID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRoUsagesByRODbID";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
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_FetchRODbID", ex);
throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region ICustomTypeDescriptor impl
public String GetClassName()