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

View File

@ -0,0 +1 @@

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
public class DynamicPropertyDescriptor : PropertyDescriptor
{
private PropertyDescriptor _BasePropertyDescriptor;
private DynamicTypeDescriptor _Instance;
public DynamicPropertyDescriptor(DynamicTypeDescriptor instance, PropertyDescriptor basePropertyDescriptor)
: base(basePropertyDescriptor)
{
_Instance = instance;
_BasePropertyDescriptor = basePropertyDescriptor;
}
public override bool CanResetValue(object component)
{ return _BasePropertyDescriptor.CanResetValue(component); }
public override Type ComponentType
{ get { return _BasePropertyDescriptor.ComponentType; } }
public override object GetValue(object component)
{ return _BasePropertyDescriptor.GetValue(component); }
public override bool IsReadOnly
{ get { return _Instance.IsReadOnly; } }
public override Type PropertyType
{ get { return _BasePropertyDescriptor.PropertyType; } }
public override void ResetValue(object component)
{ _BasePropertyDescriptor.ResetValue(component); }
public override bool ShouldSerializeValue(object component)
{ return _BasePropertyDescriptor.ShouldSerializeValue(component); }
public override void SetValue(object component, object value)
{ _BasePropertyDescriptor.SetValue(component, value); }
}
[Serializable()]
public class DynamicTypeDescriptor //: ICustomTypeDescriptor//, ISupportInitialize
{
[NonSerialized]
private PropertyDescriptorCollection dynamicProps;
private bool _IsReadOnly = false;
internal virtual bool IsReadOnly
{
get { return _IsReadOnly; }
set { _IsReadOnly = value; }
}
public DynamicTypeDescriptor() { }
#region "TypeDescriptor Implementation"
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 PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
return GetProperties();
}
public PropertyDescriptorCollection GetProperties()
{
if (dynamicProps == null)
{
PropertyDescriptorCollection baseProps = TypeDescriptor.GetProperties(this, true);
dynamicProps = new PropertyDescriptorCollection(null);
foreach (PropertyDescriptor oProp in baseProps)
{
dynamicProps.Add(new DynamicPropertyDescriptor(this, oProp));
}
}
return dynamicProps;
}
public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; }
#endregion
}
}

View File

@ -0,0 +1,164 @@
/*****************************************************************
* Module: EnumDescConverter.cs
* Type: C# Source Code
* Version: 1.0
* Description: Enum Converter using Description Attributes
*
* Revisions
* ------------------------------------------------
* [F] 24/02/2004, Jcl - Shaping up
* [B] 25/02/2004, Jcl - Made it much easier :-)
*
*****************************************************************/
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Reflection;
using System.Collections;
using System.Data;
namespace DescriptiveEnum
{
/// <summary>
/// EnumConverter supporting System.ComponentModel.DescriptionAttribute
/// </summary>
public class EnumDescConverter : System.ComponentModel.EnumConverter
{
protected System.Type myVal;
/// <summary>
/// Gets Enum Value's Description Attribute
/// </summary>
/// <param name="value">The value you want the description attribute for</param>
/// <returns>The description, if any, else it's .ToString()</returns>
public static string GetEnumDescription(Enum value)
{
Console.WriteLine("{0}", value);
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
//Console.WriteLine("{0},{1},{2}", value.ToString(), attributes.Length, (attributes.Length > 0) ? attributes[0].Description : value.ToString());
return (attributes.Length>0)?attributes[0].Description:value.ToString();
}
/// <summary>
/// Gets the description for certaing named value in an Enumeration
/// </summary>
/// <param name="value">The type of the Enumeration</param>
/// <param name="name">The name of the Enumeration value</param>
/// <returns>The description, if any, else the passed name</returns>
public static string GetEnumDescription(System.Type value, string name)
{
FieldInfo fi= value.GetField(name);
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
return (attributes.Length>0)?attributes[0].Description:name;
}
/// <summary>
/// Gets the value of an Enum, based on it's Description Attribute or named value
/// </summary>
/// <param name="value">The Enum type</param>
/// <param name="description">The description or name of the element</param>
/// <returns>The value, or the passed in description, if it was not found</returns>
public static object GetEnumValue(System.Type value, string description)
{
FieldInfo [] fis = value.GetFields();
foreach(FieldInfo fi in fis)
{
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
if(attributes.Length>0)
{
if(attributes[0].Description == description)
{
return fi.GetValue(fi.Name);
}
}
if(fi.Name == description)
{
return fi.GetValue(fi.Name);
}
}
return description;
}
public EnumDescConverter(System.Type type) : base(type.GetType())
{
myVal = type;
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if(value is Enum && destinationType == typeof(string))
{
return EnumDescConverter.GetEnumDescription((Enum)value);
}
if(value is string && destinationType == typeof(string))
{
return EnumDescConverter.GetEnumDescription(myVal, (string)value);
}
return base.ConvertTo (context, culture, value, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if(value is string)
{
return EnumDescConverter.GetEnumValue(myVal, (string)value);
}
if(value is Enum)
{
return EnumDescConverter.GetEnumDescription((Enum)value);
}
return base.ConvertFrom (context, culture, value);
}
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
ArrayList values = new ArrayList();
FieldInfo[] fis = myVal.GetFields();
foreach (FieldInfo fi in fis)
{
DescriptionAttribute[] attributes =(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
//if (attributes.Length > 0)
if (fi.Name != "value__")
values.Add(fi.GetValue(fi.Name));
}
return new TypeConverter.StandardValuesCollection(values);
}
public static string GetEnumKeyDescription(Enum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
return (attributes.Length > 0) ? attributes[0].Description : value.ToString();
}
public static DataTable GetEnumAsDataTable(System.Type EnumType)
{
DataTable DTEnum = new DataTable();
DTEnum.Columns.Add(new DataColumn("EnumID", typeof(Int32)));
DTEnum.Columns.Add(new DataColumn("Enum", typeof(string)));
DTEnum.Columns.Add(new DataColumn("Description", typeof(string)));
foreach (int i in Enum.GetValues(EnumType))
{
System.Enum fooItem = (System.Enum)Enum.ToObject(EnumType, i);
DTEnum.Rows.Add(new object[] { i, fooItem.ToString(), GetEnumKeyDescription(fooItem) });
}
return DTEnum;
}
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
public class EnumDetail<T>
{
private T _EValue;
public T EValue
{
get { return _EValue; }
set { _EValue = value; }
}
private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}
public EnumDetail(string name, T eValue)
{
_Name = name;
_EValue = eValue;
}
public static EnumDetail<T>[] Details()
{
string[] names = Enum.GetNames(typeof(T));
Array values = Enum.GetValues(typeof(T));
EnumDetail<T>[] retval = new EnumDetail<T>[values.Length];
for (int i = 0; i < values.Length; i++)
{
T val = (T)values.GetValue(i);
FieldInfo fi = val.GetType().GetField(val.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
retval[i] = new EnumDetail<T>(((attributes.Length > 0) ? attributes[0].Description : names[i]), (T)values.GetValue(i));
}
return retval;
}
}
}

View File

@ -0,0 +1,804 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using DescriptiveEnum;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
//public class FolderConfig : INotifyPropertyChanged
public class FolderConfig : DynamicTypeDescriptor, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
internal override bool IsReadOnly
{
get { return _Folder == null; }
}
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
[NonSerialized]
private bool _AncestorLookup;
public bool AncestorLookup
{
get { return _AncestorLookup; }
set { _AncestorLookup = value; }
}
private Folder _Folder;
private FolderInfo _FolderInfo;
public FolderConfig(Folder folder)
{
_Folder = folder;
string xml = _Folder.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
if(folder.MyParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
{
if (_AncestorLookup || ParentLookup)
{
for (Folder folder = _Folder.MyParent; folder != null; folder = folder.MyParent)
{
string retval = folder.FolderConfig.GetValue( args.Group, args.Item);
if (retval != string.Empty) return retval;
}
}
return string.Empty;
}
private string Xp_LookInAncestorFolderInfo(object sender, XMLPropertiesArgs args)
{
if (_AncestorLookup || ParentLookup)
{
for (FolderInfo folder = _FolderInfo.MyParent; folder != null; folder = folder.MyParent)
{
string retval = folder.FolderConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
}
}
return string.Empty;
}
public FolderConfig(FolderInfo folderInfo)
{
_FolderInfo = folderInfo;
string xml = _FolderInfo.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public FolderConfig(string xml)
{
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public FolderConfig()
{
_Xp = new XMLProperties("<config/>");
}
internal string GetValue(string group, string item)
{
return _Xp[group, item];
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Name")]
[Description("Name")]
public string Name
{
get { return (_Folder != null ? _Folder.Name : _FolderInfo.Name); }
set { if (_Folder != null)_Folder.Name = value; }
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Title")]
[Description("Title")]
public string Title
{
get { return (_Folder != null ? _Folder.Title : _FolderInfo.Title); }
set { _Folder.Title = value; }
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Short Name")]
[Description("Short Name")]
public string ShortName
{
get { return (_Folder != null ? _Folder.ShortName : _FolderInfo.ShortName); }
set { if (_Folder != null)_Folder.ShortName = value; }
}
//[Category("Format")]
[Category("Format Settings")]
[DisplayName("Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string FormatSelection
{
get
{
//if (_Folder != null) return FormatList.ToString(_Folder.FormatID);
//if (_FolderInfo != null) return FormatList.ToString(_FolderInfo.FormatID);
if (_Folder != null && _Folder.MyFormat != null) return _Folder.MyFormat.PlantFormat.FormatData.Name;
if (_FolderInfo != null && _FolderInfo.MyFormat != null) return _FolderInfo.MyFormat.PlantFormat.FormatData.Name;
return null;
}
set
{
if (_Folder != null)_Folder.MyFormat = FormatList.ToFormat(value);
}
}
//[Category("Format")]
[Category("Format Settings")]
[DisplayName("Default Format")]
//[DisplayName("Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string DefaultFormatSelection
{
get
{
//if (_Folder != null) return FormatList.ToString(_Folder.FormatID);
//if (_FolderInfo != null) return FormatList.ToString(_FolderInfo.FormatID);
if (_Folder != null && _Folder.MyParent!= null && _Folder.MyParent.ActiveFormat != null) return _Folder.MyParent.ActiveFormat.PlantFormat.FormatData.Name;
if (_FolderInfo != null && _FolderInfo.MyParent != null && _FolderInfo.MyParent.ActiveFormat != null) return _FolderInfo.MyParent.ActiveFormat.PlantFormat.FormatData.Name;
return null;
}
}
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<config/>" || s == "<config></config>") return string.Empty;
return s;
}
#region GraphicsCategory // From veproms.ini
public bool CanWrite(string str)
{
return true;
}
//[Category("Graphics")]
[Category("Referenced Objects")]
[DisplayName("Graphic File Extension")]
//[DisplayName("Default File Extension")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default File Extension")]
public string Graphics_defaultext
{
get
{
return _Xp["Graphics", "defaultext"];
}
set
{
_Xp["Graphics", "defaultext"] = value;
OnPropertyChanged("Graphics_defaultext");
}
}
#endregion
#region ColorCategory // From veproms.ini
// Note that not all possibilities from 16-bit will be added here, until
// it is determined how these will be used
//[Category("Color")]
[Category("Editor Settings")]
//[DisplayName("Referenced Object Highlight")]
[DisplayName("Step Editor Colors - Referenced Objects")]
[RefreshProperties(RefreshProperties.All)]
[Description("Color used to highlight an RO in procedure text")]
public string Color_ro
{
get
{
return _Xp["Color", "ro"];
}
set
{
_Xp["Color", "ro"] = value;
OnPropertyChanged("Color_ro");
}
}
//[Category("Color")]
[Category("Editor Settings")]
//[DisplayName("Transition Highlight")]
[DisplayName("Step Editor Colors - Transitions")]
[RefreshProperties(RefreshProperties.All)]
[Description("Color used to highlight a Transition in procedure text")]
public string Color_transition
{
get
{
return _Xp["Color", "transition"];
}
set
{
_Xp["Color", "transition"] = value;
OnPropertyChanged("Color_transition");
}
}
//[Category("Color")]
[Category("Editor Settings")]
//[DisplayName("editbackground")]
[DisplayName("Step Editor Colors - Active Background")]
[RefreshProperties(RefreshProperties.All)]
[Description("editbackground")]
public string Color_editbackground
{
get
{
return _Xp["Color", "editbackground"];
}
set
{
_Xp["Color", "editbackground"] = value;
OnPropertyChanged("Color_editbackground");
}
}
[Category("Color")]
[DisplayName("black")]
[RefreshProperties(RefreshProperties.All)]
[Description("black")]
public string Color_black
{
get
{
return _Xp["Color", "black"];
}
set
{
_Xp["Color", "black"] = value;
OnPropertyChanged("Color_black");
}
}
[Category("Color")]
[DisplayName("blue")]
[RefreshProperties(RefreshProperties.All)]
[Description("blue")]
public string Color_blue
{
get
{
return _Xp["Color", "blue"];
}
set
{
_Xp["Color", "blue"] = value;
OnPropertyChanged("Color_blue");
}
}
#endregion // From veproms.ini
#region SystemPrintCategory // From veproms.ini
//[Category("System Print")]
[Category("Print Settings")]
[DisplayName("Override Underline Thickness (dots)")]
//[DisplayName("Underline Width")]
[RefreshProperties(RefreshProperties.All)]
[Description("Underline Width")]
public int SysPrint_UWidth
{
get
{
string s = _Xp["SystemPrint", "UnderlineWidth"];
if (s == string.Empty) return 10;
return int.Parse(_Xp["SystemPrint", "UnderlineWidth"]);
}
set
{
_Xp["SystemPrint", "UnderlineWidth"] = value.ToString();
OnPropertyChanged("SysPrint_UWidth");
}
}
//[Category("System Print")]
[Category("Print Settings")]
[DisplayName("Adjust Starting Print Position (dots)")]
//[DisplayName("Vertical Offset")]
[RefreshProperties(RefreshProperties.All)]
[Description("Vertical Offset")]
public int SysPrint_VOffset
{
get
{
string s = _Xp["SystemPrint", "VerticalOffset"];
if (s == string.Empty) return 0;
return int.Parse(_Xp["SystemPrint", "VerticalOffset"]);
}
set
{
_Xp["SystemPrint", "VerticalOffset"] = value.ToString();
OnPropertyChanged("SysPrint_VOffset");
}
}
//[Category("System Print")]
[Category("Print Settings")]
[DisplayName("Override Normal Pen Width (dots)")]
//[DisplayName("Stroke Width")]
[RefreshProperties(RefreshProperties.All)]
[Description("Stroke Width")]
public int SysPrint_StrokeWidth
{
get
{
string s = _Xp["SystemPrint", "StrokeWidth"];
if (s == string.Empty) return 0;
return int.Parse(_Xp["SystemPrint", "StrokeWidth"]);
}
set
{
_Xp["SystemPrint", "StrokeWidth"] = value.ToString();
OnPropertyChanged("SysPrint_StrokeWidth");
}
}
//[Category("System Print")]
[Category("Print Settings")]
[DisplayName("Override Bold Pen Width (dots)")]
//[DisplayName("Stroke Width Bold")]
[RefreshProperties(RefreshProperties.All)]
[Description("Stroke Width Bold")]
public int SysPrint_StrokeWidthBold
{
get
{
string s = _Xp["SystemPrint", "StrokeWidthBold"];
if (s == string.Empty) return 0;
return int.Parse(_Xp["SystemPrint", "StrokeWidthBold"]);
}
set
{
_Xp["SystemPrint", "StrokeWidthBold"] = value.ToString();
OnPropertyChanged("SysPrint_StrokeWidthBold");
}
}
#endregion
#region StartupCategory // From veproms.ini
//[Category("Startup")]
[Category("Startup Message")]
[DisplayName("Startup MessageBox Title")]
[RefreshProperties(RefreshProperties.All)]
[Description("Startup MessageBox Title")]
public string Startup_MsgTitle
{
get
{
return _Xp["Startup", "MessageBoxTitle"];
}
set
{
_Xp["Startup", "MessageBoxTitle"] = value;
OnPropertyChanged("Startup_MsgTitle");
}
}
//[Category("Startup")]
[Category("Startup Message")]
[DisplayName("Startup Message File")]
[RefreshProperties(RefreshProperties.All)]
[Description("Startup Message File")]
public string Startup_MsgFile
{
get
{
return _Xp["Startup", "MessageFile"];
}
set
{
_Xp["Startup", "MessageFile"] = value;
OnPropertyChanged("Startup_MsgFile");
}
}
#endregion
#region ProcedureListTabStopsCategory // From veproms.ini
[Category("ProcedureListTabStops")]
[DisplayName("Procedure Number Tab")]
[RefreshProperties(RefreshProperties.All)]
[Description("Procedure Number Tab")]
public int ProcListTab_Number
{
get
{
string s = _Xp["ProcedureListTabStops", "ProcedureNumberTab"];
if (s == string.Empty) return 75;
return int.Parse(_Xp["ProcedureListTabStops", "ProcedureNumberTab"]);
}
set
{
_Xp["ProcedureListTabStops", "ProcedureNumberTab"] = value.ToString();
OnPropertyChanged("ProcListTab_Number");
}
}
[Category("ProcedureListTabStops")]
[DisplayName("Procedure Title Tab")]
[RefreshProperties(RefreshProperties.All)]
[Description("Procedure Title Tab")]
public int ProcListTab_Title
{
get
{
string s = _Xp["ProcedureListTabStops", "ProcedureTitleTab"];
if (s == string.Empty) return 175;
return int.Parse(_Xp["ProcedureListTabStops", "ProcedureTitleTab"]);
}
set
{
_Xp["ProcedureListTabStops", "ProcedureTitleTab"] = value.ToString();
OnPropertyChanged("ProcListTab_Title");
}
}
#endregion
#region FormatCategory
[TypeConverter(typeof(EnumDescConverter))]
public enum FormatColumns : int
{
Default = 0,
[Description("Single Column")]OneColumn,
[Description("Duel Column")]TwoColumn,
[Description("Triple Column")]ThreeColumn,
[Description("Quad Column")]FourColumns
}
//[Category("Format")]
//[DisplayName("Column Layout")]
[Category("Editor Settings")]
[DisplayName("Step Editor Columns")]
[RefreshProperties(RefreshProperties.All)]
[Description("Column Layout")]
public FormatColumns Format_Columns
{
get
{
string s = _Xp["format", "columns"];
if (s == string.Empty || s.Equals("-1")) return FormatColumns.Default;//return (FormatColumns)0;
return (FormatColumns)int.Parse(_Xp["format", "columns"]);
//return Enum.Parse(typeof(FormatColumns),_Xp["format", "columns"]);
}
set
{
if (value == 0) _Xp["format", "columns"] = string.Empty;
else _Xp["format", "columns"] = ((int)value).ToString();
OnPropertyChanged("Format_Columns");
}
}
//[Category("Format")]
//[DisplayName("Plant Format Name")]
[Category("Format Settings")]
[DisplayName("Format")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Plant Format")]
public string Format_Plant
{
get
{
return _Xp["format", "plant"];
}
set
{
_Xp["format", "plant"] = value;
OnPropertyChanged("Format_Plant");
}
}
#endregion
#region DefaultsCategory // from proc.ini
//[Category("Defaults")]
[Category("Referenced Objects")]
//[DisplayName("Default Setpoint Prefix")]
[DisplayName("Default RO Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Setpoint Prefix")]
public string Default_SPPrefix
{
get { return _Xp["default", "spprefix"]; }
set
{
_Xp["default", "spprefix"] = value;
OnPropertyChanged("Default_SPPrefix");
}
}
//[Category("Defaults")]
[Category("Referenced Objects")]
[DisplayName("Default Image Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Image Prefix")]
public string Default_IMPrefix
{
get { return _Xp["default", "imprefix"]; }
set
{
_Xp["default", "imprefix"] = value;
OnPropertyChanged("RO_IMPrefix");
}
}
#endregion
#region PrintSettingsCategory // From curset.dat
[Category("Print Settings")]
[DisplayName("Number of Copies")]
[RefreshProperties(RefreshProperties.All)]
[Description("Number of Copies")]
public int Print_NumCopies
{
get
{
string s = _Xp["PrintSettings", "numcopies"];
if (s == string.Empty) return 1;
return int.Parse(_Xp["PrintSettings", "numcopies"]);
}
set
{
_Xp["PrintSettings", "numcopies"] = value.ToString();
OnPropertyChanged("Print_NumCopies");
}
}
public enum PrintPagination : int
{
Free = 0, Fixed, Auto
}
[Category("Print Settings")]
[DisplayName("Pagination")]
[RefreshProperties(RefreshProperties.All)]
[Description("Pagination")]
public PrintPagination Print_Pagination
{
get
{
string s = _Xp["PrintSettings", "Pagination"];
if (s == string.Empty || s.Equals("-1")) return PrintPagination.Auto;
return (PrintPagination)int.Parse(_Xp["PrintSettings", "Pagination"]);
}
set
{
if (value == PrintPagination.Auto) _Xp["PrintSettings", "Pagination"] = string.Empty;
else _Xp["PrintSettings", "Pagination"] = ((int)value).ToString();
OnPropertyChanged("Print_Pagination");
}
}
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintWatermark : int
{
None = 0, Reference, Draft, Master, Sample,
[Description("Information Only")]InformationOnly
}
[Category("Print Settings")]
[DisplayName("Watermark")]
[RefreshProperties(RefreshProperties.All)]
[Description("Watermark")]
public PrintWatermark Print_Watermark
{
get
{
string s = _Xp["PrintSettings", "Watermark"];
if (s == string.Empty || s.Equals("-1")) return PrintWatermark.Draft;
return (PrintWatermark)int.Parse(_Xp["PrintSettings", "Watermark"]);
}
set
{
if (value == PrintWatermark.Draft) _Xp["PrintSettings", "Watermark"] = string.Empty;
else _Xp["PrintSettings", "Watermark"] = ((int)value).ToString();
OnPropertyChanged("Print_Watermark");
}
}
[Category("Print Settings")]
[DisplayName("Disable Automatic Duplexing")]
//[DisplayName("Disable Duplex Printing")]
[RefreshProperties(RefreshProperties.All)]
[Description("Disable Duplex Printing")]
public bool Print_DisableDuplex
{
get
{
string s = _Xp["PrintSettings", "disableduplex"];
if (s == string.Empty) return false;
return bool.Parse(_Xp["PrintSettings", "disableduplex"]);
}
set
{
_Xp["PrintSettings", "disableduplex"] = value.ToString();
OnPropertyChanged("Print_DisableDuplex");
}
}
// Change Bar Use from 16-bit code:
// No Default
// Without Change Bars
// With Default Change Bars
// With User Specified Change Bars
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintChangeBar : int
{
[Description("Select Before Printing")]SelectBeforePrinting = 0,
[Description("Without Change Bars")]Without,
[Description("With Default Change Bars")]WithDefault,
[Description("Use Custom Change Bars")]WithUserSpecified
}
//{
// [Description("Select When Printed")]NoDefault = 0,
// [Description("None")]Without,
// [Description("Default")]WithDefault,
// [Description("User Specified")]WithUserSpecified
//}
//[Category("Print Settings")]
[Category("Format Settings")]
[DisplayName("Change Bar")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Use")]
public PrintChangeBar Print_ChangeBar
{
get
{
string s = _Xp["PrintSettings", "ChangeBar"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBar.SelectBeforePrinting;//PrintChangeBar.NoDefault;
return (PrintChangeBar)int.Parse(_Xp["PrintSettings", "ChangeBar"]);
}
set
{
// if (value == PrintChangeBar.NoDefault) _Xp["PrintSettings", "ChangeBar"] = string.Empty;
if (value == PrintChangeBar.SelectBeforePrinting) _Xp["PrintSettings", "ChangeBar"] = string.Empty;
else _Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBar");
}
}
// User Specified Change Bar Location from16-bit code:
// With Text
// Outside Box
// AER on LEFT, RNO on Right
// To the Left of Text
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintChangeBarLoc : int
{
[Description("With Text")]WithText = 0,
[Description("Outside Box")]OutsideBox,
[Description("AER on Left RNO on Right")]AERleftRNOright,
[Description("To the Left of the Text")]LeftOfText
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("Change Bar Location")]
[DisplayName("Change Bar Position")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Specified Change Bar Location")]
public PrintChangeBarLoc Print_ChangeBarLoc
{
get
{
string s = _Xp["PrintSettings", "ChangeBarLoc"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBarLoc.WithText;
return (PrintChangeBarLoc)int.Parse(_Xp["PrintSettings", "ChangeBarLoc"]);
}
set
{
if (value == PrintChangeBarLoc.WithText) _Xp["PrintSettings", "ChangeBarLoc"] = string.Empty;
else _Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBarLoc");
}
}
// Change Bar Text from16-bit code:
// Date and Change ID
// Revision Number
// Change ID
// No Change Bar Message
// User Defined Message
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintChangeBarText : int
{
[Description("Date and Change ID")]DateChgID = 0,
[Description("Revision Number")]RevNum,
[Description("Change ID")]ChgID,
[Description("No Change Bar Text")]None,
[Description("Custom Change Bar Text")]UserDef
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("Change Bar Text")]
[DisplayName("Change bar Text Type")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Text")]
public PrintChangeBarText Print_ChangeBarText
{
get
{
string s = _Xp["PrintSettings", "ChangeBarText"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBarText.DateChgID;
return (PrintChangeBarText)int.Parse(_Xp["PrintSettings", "ChangeBarText"]);
}
set
{
if (value == PrintChangeBarText.DateChgID) _Xp["PrintSettings", "ChangeBarText"] = string.Empty;
else _Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBarText");
}
}
[Category("Print Settings")]
[DisplayName("User Format")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Format")]
public string Print_UserFormat
{
get
{
return _Xp["PrintSettings", "userformat"];
}
set
{
_Xp["PrintSettings", "userformat"] = value;
OnPropertyChanged("Print_UserFormat");
}
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("User Change Bar Message1")]
[DisplayName("Custom Change Bar Message Line One")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message1")]
public string Print_UserCBMess1
{
get
{
return _Xp["PrintSettings", "usercbmess1"];
}
set
{
_Xp["PrintSettings", "usercbmess1"] = value;
OnPropertyChanged("Print_UserCBMess1");
}
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("User Change Bar Message2")]
[DisplayName("Custom Change Bar Message Line Two")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message2")]
public string Print_UserCBMess2
{
get
{
return _Xp["PrintSettings", "usercbmess2"];
}
set
{
_Xp["PrintSettings", "usercbmess2"] = value;
OnPropertyChanged("Print_UserCBMess2");
}
}
#endregion
//[Category("Defaults")]
[Category("Editor Settings")]
//[DisplayName("Default BackColor")]
[DisplayName("Step Editor Colors - Non Active Background")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Background Color")]
public Color Default_BkColor
{
get
{
//return _Xp["default", "BkColor"];
string sColor = _Xp["default", "BkColor"];
if (sColor == string.Empty) sColor = "White";
if (sColor[0] == '[')
{
string[] parts = sColor.Substring(1, sColor.Length - 2).Split(",".ToCharArray());
return Color.FromArgb(Int32.Parse(parts[0]), Int32.Parse(parts[1]), Int32.Parse(parts[2]));
}
else return Color.FromName(sColor);
}
set
{
if (value.IsNamedColor) _Xp["default", "BkColor"] = value.Name;
else
{
_Xp["default", "BkColor"] = string.Format("[{0},{1},{2}]", value.R, value.G, value.B);
}
OnPropertyChanged("Default_BkColor");
}
}
}
}

View File

@ -0,0 +1,520 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DescriptiveEnum;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class ProcedureConfig : DynamicTypeDescriptor, INotifyPropertyChanged
{
#region Events
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
#endregion
#region DynamicTypeDescriptor
internal override bool IsReadOnly
{
get { return _Procedure == null; }
}
#endregion
#region XML
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
#endregion
#region Constructors
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
[NonSerialized]
private bool _AncestorLookup;
public bool AncestorLookup
{
get { return _AncestorLookup; }
set { _AncestorLookup = value; }
}
private Procedure _Procedure;
private ProcedureInfo _ProcedureInfo;
public ProcedureConfig(Procedure procedure)
{
_Procedure = procedure;
string xml = procedure.MyContent.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
if (procedure.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
{
if (_AncestorLookup || ParentLookup)
{
string retval;
Procedure proc = _Procedure;
while (proc.ActiveParent.GetType() == typeof(Procedure))
{
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
proc = (Procedure) proc.ActiveParent;
}
DocVersion docVersion = (DocVersion)proc.ActiveParent;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
for (Folder folder = docVersion.MyFolder; folder != null; folder = folder.MyParent)
{
retval = folder.FolderConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
}
}
return string.Empty;
}
private string Xp_LookInAncestorFolderInfo(object sender, XMLPropertiesArgs args)
{
if (_AncestorLookup || ParentLookup)
{
DocVersionInfo docVersion = (DocVersionInfo)_Procedure.ActiveParent;
string retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
for (FolderInfo folder = docVersion.MyFolder; folder != null; folder = folder.MyParent)
{
retval = folder.FolderConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
}
}
return string.Empty;
}
public ProcedureConfig(ProcedureInfo procedureInfo)
{
_ProcedureInfo = procedureInfo;
string xml = procedureInfo.MyContent.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public ProcedureConfig(string xml)
{
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
//public ProcedureConfig()
//{
// _Xp = new XMLProperties();
//}
internal string GetValue(string group, string item)
{
return _Xp[group, item];
}
#endregion
#region Local Properties
//[Category("Identification")]
[Category("General")]
[DisplayName("Number")]
[Description("Number")]
public string Number
{
get { return (_Procedure != null ? _Procedure.MyContent.Number : _ProcedureInfo.MyContent.Number); }
set { if (_Procedure != null) _Procedure.MyContent.Number = value; }
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Title")]
[Description("Title")]
public string Title
{
get { return (_Procedure != null ? _Procedure.MyContent.Text : _ProcedureInfo.MyContent.Text); }
set { if (_Procedure != null) _Procedure.MyContent.Text = value; }
}
[Category("Identification")]
[DisplayName("Old Sequence")]
[Description("Old Sequence")]
public string OldSequence
{
get { return (_Procedure != null ? _Procedure.MyContent.MyZContent.OldStepSequence : (_ProcedureInfo.MyContent.MyZContent == null? null :_ProcedureInfo.MyContent.MyZContent.OldStepSequence)); }
set { if (_Procedure != null) _Procedure.MyContent.MyZContent.OldStepSequence = value; }
}
[Category("Identification")]
[DisplayName("Dirty")]
[Description("Dirty")]
public bool Dirty
{
get { return (_Procedure != null ? _Procedure.IsDirty : false ); }
}
//[Category("Format")]
[Category("Format Settings")]
[DisplayName("Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string FormatSelection
{
get
{
//if (_DocVersion != null) return FormatList.ToString(_DocVersion.FormatID);
//if (_DocVersionInfo != null) return FormatList.ToString(_DocVersionInfo.FormatID);
if (_Procedure != null && _Procedure.MyContent.MyFormat != null) return _Procedure.MyContent.MyFormat.PlantFormat.FormatData.Name;
if (_ProcedureInfo != null && _ProcedureInfo.MyContent.MyFormat != null) return _ProcedureInfo.MyContent.MyFormat.PlantFormat.FormatData.Name;
return null;
}
set
{
if (_Procedure != null) _Procedure.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
}
}
//[Category("Format")]
[Category("Format Settings")]
//[DisplayName("Format")]
[DisplayName("Default Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string DefaultFormatSelection
{
get
{
//if (_Folder != null) return FormatList.ToString(_Folder.FormatID);
//if (_FolderInfo != null) return FormatList.ToString(_FolderInfo.FormatID);
if (_Procedure != null && _Procedure.ActiveParent != null && _Procedure.ActiveParent.ActiveFormat != null) return _Procedure.ActiveParent.ActiveFormat.PlantFormat.FormatData.Name;
if (_ProcedureInfo != null && _ProcedureInfo.MyParent != null && _ProcedureInfo.MyParent.ActiveFormat != null) return _ProcedureInfo.MyParent.ActiveFormat.PlantFormat.FormatData.Name;
return null;
}
}
#endregion
#region ToString
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<config/>" || s == "<config></config>") return string.Empty;
return s;
}
#endregion
#region FormatCategory
[TypeConverter(typeof(EnumDescConverter))]
public enum FormatColumns : int
{
Default = 0,
[Description("Single Column")]
OneColumn,
[Description("Duel Column")]
TwoColumn,
[Description("Triple Column")]
ThreeColumn,
[Description("Quad Column")]
FourColumns
}
//[Category("Format")]
[Category("General")]
//[DisplayName("Column Layout")]
[DisplayName("Default Column Mode")]
[RefreshProperties(RefreshProperties.All)]
[Description("Column Layout")]
public FormatColumns Format_Columns
{
get
{
string s = _Xp["format", "columns"];
if (s == string.Empty || s.Equals("-1")) return FormatColumns.Default;//(FormatColumns)0;
return (FormatColumns)int.Parse(_Xp["format", "columns"]);
//return Enum.Parse(typeof(FormatColumns),_Xp["format", "columns"]);
}
set
{
if (value == 0) _Xp["format", "columns"] = string.Empty;
else _Xp["format", "columns"] = ((int)value).ToString();
OnPropertyChanged("Format_Columns");
}
}
[Category("Format")]
[DisplayName("Plant Format Name")]
[RefreshProperties(RefreshProperties.All)]
[Description("Default Plant Format")]
public string Format_Plant
{
get
{
return _Xp["format", "plant"];
}
set
{
_Xp["format", "plant"] = value;
OnPropertyChanged("Format_Plant");
}
}
#endregion
#region PrintSettingsCategory // From curset.dat
[Category("Print Settings")]
[DisplayName("Number of Copies")]
[RefreshProperties(RefreshProperties.All)]
[Description("Number of Copies")]
public int Print_NumCopies
{
get
{
string s = _Xp["PrintSettings", "numcopies"];
if (s == string.Empty) return 1;
return int.Parse(_Xp["PrintSettings", "numcopies"]);
}
set
{
_Xp["PrintSettings", "numcopies"] = value.ToString();
OnPropertyChanged("Print_NumCopies");
}
}
public enum PrintPagination : int
{
Free = 0, Fixed,
[Description("Automatic")]
Auto
}
[Category("Print Settings")]
[DisplayName("Pagination")]
[RefreshProperties(RefreshProperties.All)]
[Description("Pagination")]
public PrintPagination Print_Pagination
{
get
{
string s = _Xp["PrintSettings", "Pagination"];
if (s == string.Empty || s.Equals("-1")) return PrintPagination.Auto;
return (PrintPagination)int.Parse(_Xp["PrintSettings", "Pagination"]);
}
set
{
if (value == PrintPagination.Auto) _Xp["PrintSettings", "Pagination"] = string.Empty;
else _Xp["PrintSettings", "Pagination"] = ((int)value).ToString();
OnPropertyChanged("Print_Pagination");
}
}
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintWatermark : int
{
None = 0, Reference, Draft, Master, Sample,
[Description("Information Only")]
InformationOnly
}
[Category("Print Settings")]
[DisplayName("Watermark")]
[RefreshProperties(RefreshProperties.All)]
[Description("Watermark")]
public PrintWatermark Print_Watermark
{
get
{
string s = _Xp["PrintSettings", "Watermark"];
if (s == string.Empty || s.Equals("-1")) return PrintWatermark.Draft;
return (PrintWatermark)int.Parse(_Xp["PrintSettings", "Watermark"]);
}
set
{
if (value == PrintWatermark.Draft) _Xp["PrintSettings", "Watermark"] = string.Empty;
else _Xp["PrintSettings", "Watermark"] = ((int)value).ToString();
OnPropertyChanged("Print_Watermark");
}
}
[Category("Print Settings")]
//[DisplayName("Disable Duplex Printing")]
[DisplayName("Disable Automatic Duplexing")]
[RefreshProperties(RefreshProperties.All)]
[Description("Disable Duplex Printing")]
public bool Print_DisableDuplex
{
get
{
string s = _Xp["PrintSettings", "disableduplex"];
if (s == string.Empty) return false;
return bool.Parse(_Xp["PrintSettings", "disableduplex"]);
}
set
{
_Xp["PrintSettings", "disableduplex"] = value.ToString();
OnPropertyChanged("Print_DisableDuplex");
}
}
// Change Bar Use from 16-bit code:
// No Default
// Without Change Bars
// With Default Change Bars
// With User Specified Change Bars
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintChangeBar : int
{
[Description("Select Before Printing")]
SelectBeforePrinting = 0,
[Description("Without Change Bars")]
Without,
[Description("With Default Change Bars")]
WithDefault,
[Description("Use Custom Change Bars")]
WithUserSpecified
}
//{
// [Description("Select When Printed")]NoDefault = 0,
// [Description("None")]Without,
// [Description("Default")]WithDefault,
// [Description("User Specified")]WithUserSpecified
//}
//[Category("Print Settings")]
[Category("Format Settings")]
[DisplayName("Change Bar")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Use")]
public PrintChangeBar Print_ChangeBar
{
get
{
string s = _Xp["PrintSettings", "ChangeBar"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBar.SelectBeforePrinting;//PrintChangeBar.NoDefault;
return (PrintChangeBar)int.Parse(_Xp["PrintSettings", "ChangeBar"]);
}
set
{
//if (value == PrintChangeBar.NoDefault) _Xp["PrintSettings", "ChangeBar"] = string.Empty;
if (value == PrintChangeBar.SelectBeforePrinting) _Xp["PrintSettings", "ChangeBar"] = string.Empty;
else _Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBar");
}
}
// User Specified Change Bar Location from16-bit code:
// With Text
// Outside Box
// AER on LEFT, RNO on Right
// To the Left of Text
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintChangeBarLoc : int
{
[Description("With Text")]
WithText = 0,
[Description("Outside Box")]
OutsideBox,
[Description("AER on Left RNO on Right")]
AERleftRNOright,
[Description("To the Left of the Text")]
LeftOfText
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("Change Bar Location")]
[DisplayName("Change Bar Position")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Specified Change Bar Location")]
public PrintChangeBarLoc Print_ChangeBarLoc
{
get
{
string s = _Xp["PrintSettings", "ChangeBarLoc"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBarLoc.WithText;
return (PrintChangeBarLoc)int.Parse(_Xp["PrintSettings", "ChangeBarLoc"]);
}
set
{
if (value == PrintChangeBarLoc.WithText) _Xp["PrintSettings", "ChangeBarLoc"] = string.Empty;
else _Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBarLoc");
}
}
// Change Bar Text from16-bit code:
// Date and Change ID
// Revision Number
// Change ID
// No Change Bar Message
// User Defined Message
[TypeConverter(typeof(EnumDescConverter))]
public enum PrintChangeBarText : int
{
[Description("Date and Change ID")]
DateChgID = 0,
[Description("Revision Number")]
RevNum,
[Description("Change ID")]
ChgID,
[Description("No Change Bar Text")]
None,
[Description("Custom Change Bar Text")]
UserDef
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("Change Bar Text")]
[DisplayName("Change Bar Text Type")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Text")]
public PrintChangeBarText Print_ChangeBarText
{
get
{
string s = _Xp["PrintSettings", "ChangeBarText"];
if (s == string.Empty || s.Equals("-1")) return PrintChangeBarText.DateChgID;
return (PrintChangeBarText)int.Parse(_Xp["PrintSettings", "ChangeBarText"]);
}
set
{
if (value == PrintChangeBarText.DateChgID) _Xp["PrintSettings", "ChangeBarText"] = string.Empty;
else _Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString();
OnPropertyChanged("Print_ChangeBarText");
}
}
[Category("Print Settings")]
[DisplayName("User Format")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Format")]
public string Print_UserFormat
{
get
{
return _Xp["PrintSettings", "userformat"];
}
set
{
_Xp["PrintSettings", "userformat"] = value;
OnPropertyChanged("Print_UserFormat");
}
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("User Change Bar Message1")]
[DisplayName("Custom Change Bar Message Line One")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message1")]
public string Print_UserCBMess1
{
get
{
return _Xp["PrintSettings", "usercbmess1"];
}
set
{
_Xp["PrintSettings", "usercbmess1"] = value;
OnPropertyChanged("Print_UserCBMess1");
}
}
//[Category("Print Settings")]
[Category("Format Settings")]
//[DisplayName("User Change Bar Message2")]
[DisplayName("Custom Change Bar Message Line Two")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message2")]
public string Print_UserCBMess2
{
get
{
return _Xp["PrintSettings", "usercbmess2"];
}
set
{
_Xp["PrintSettings", "usercbmess2"] = value;
OnPropertyChanged("Print_UserCBMess2");
}
}
#endregion
}
}

View File

@ -0,0 +1,441 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DescriptiveEnum;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class SectionConfig : DynamicTypeDescriptor, INotifyPropertyChanged
{
#region Events
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
#endregion
#region DynamicTypeDescriptor
internal override bool IsReadOnly
{
get { return false; }//_Section == null; }
}
#endregion
#region XML
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
#endregion
#region Constructors
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
[NonSerialized]
private bool _AncestorLookup;
public bool AncestorLookup
{
get { return _AncestorLookup; }
set { _AncestorLookup = value; }
}
private Section _Section;
private SectionInfo _SectionInfo;
public SectionConfig(Section section)
{
_Section = section;
string xml = section.MyContent.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
if (section.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
{
if (_AncestorLookup || ParentLookup)
{
string retval;
Section sect = _Section;
while (sect.ActiveParent.GetType() == typeof(Section))
{
retval = sect.SectionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
sect = (Section)sect.ActiveParent;
}
Procedure proc = (Procedure) sect.ActiveParent;
while (proc.ActiveParent.GetType() == typeof(Procedure))
{
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
proc = (Procedure)proc.ActiveParent;
}
DocVersion docVersion = (DocVersion)proc.ActiveParent;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
for (Folder folder = docVersion.MyFolder; folder != null; folder = folder.MyParent)
{
retval = folder.FolderConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
}
}
return string.Empty;
}
private string Xp_LookInAncestorFolderInfo(object sender, XMLPropertiesArgs args)
{
if (_AncestorLookup || ParentLookup)
{
string retval;
Section sect = _Section;
while (sect.ActiveParent.GetType() == typeof(Section))
{
//retval = sect.SectionConfig.GetValue(args.Group, args.Item);
//if (retval != string.Empty) return retval;
sect = (Section)sect.ActiveParent;
}
Procedure proc = (Procedure)sect.ActiveParent;
DocVersionInfo docVersion = (DocVersionInfo) proc.ActiveParent;
retval = docVersion.DocVersionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
for (FolderInfo folder = docVersion.MyFolder; folder != null; folder = folder.MyParent)
{
retval = folder.FolderConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
}
}
return string.Empty;
}
public SectionConfig(SectionInfo sectionInfo)
{
_SectionInfo = sectionInfo;
string xml = sectionInfo.MyContent.Config;
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public SectionConfig(string xml)
{
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public SectionConfig()
{
_Xp = new XMLProperties();
}
internal string GetValue(string group, string item)
{
return _Xp[group, item];
}
#endregion
#region Local Properties
//[Category("Identification")]
[Category("General")]
[DisplayName("Number")]
[Description("Number")]
public string Number
{
get { return (_Section != null ? _Section.MyContent.Number : _SectionInfo.MyContent.Number); }
set { if (_Section != null) _Section.MyContent.Number = value; }
}
//[Category("Identification")]
[Category("General")]
[DisplayName("Title")]
[Description("Title")]
public string Title
{
get { return (_Section != null ? _Section.MyContent.Text : _SectionInfo.MyContent.Text); }
set { if (_Section != null) _Section.MyContent.Text = value; }
}
[Category("Identification")]
[DisplayName("Old Sequence")]
[Description("Old Sequence")]
public string OldSequence
{
get { return (_Section != null ? _Section.MyContent.MyZContent.OldStepSequence : (_SectionInfo.MyContent.MyZContent == null ? null : _SectionInfo.MyContent.MyZContent.OldStepSequence)); }
set { if (_Section != null) _Section.MyContent.MyZContent.OldStepSequence = value; }
}
[Category("Identification")]
[DisplayName("Dirty")]
[Description("Dirty")]
public bool Dirty
{
get { return (_Section != null ? _Section.IsDirty : false); }
}
[Category("Format")]
[DisplayName("Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string FormatSelection
{
get
{
//if (_DocVersion != null) return FormatList.ToString(_DocVersion.FormatID);
//if (_DocVersionInfo != null) return FormatList.ToString(_DocVersionInfo.FormatID);
if (_Section != null && _Section.MyContent.MyFormat != null) return _Section.MyContent.MyFormat.PlantFormat.FormatData.Name;
if (_SectionInfo != null && _SectionInfo.MyContent.MyFormat != null) return _SectionInfo.MyContent.MyFormat.PlantFormat.FormatData.Name;
return null;
}
set
{
if (_Section != null) _Section.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
}
}
[Category("Format")]
//[DisplayName("DefFormat")]
[DisplayName("Default Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string DefaultFormatSelection
{
get
{
//if (_Folder != null) return FormatList.ToString(_Folder.FormatID);
//if (_FolderInfo != null) return FormatList.ToString(_FolderInfo.FormatID);
if (_Section != null && _Section.ActiveParent != null && _Section.ActiveParent.ActiveFormat != null) return _Section.ActiveParent.ActiveFormat.PlantFormat.FormatData.Name;
if (_SectionInfo != null && _SectionInfo.MyParent != null && _SectionInfo.MyParent.ActiveFormat != null) return _SectionInfo.MyParent.ActiveFormat.PlantFormat.FormatData.Name;
return null;
}
}
#endregion
#region ToString
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<config/>" || s == "<config></config>") return string.Empty;
return s;
}
#endregion
#region SectionCategory // from sequence number in 16-bit database.
// jsj ...
public enum SectionPagination : int
{
Default = 0, Continuous, Separate
}
//[Category("Section")]
[Category("Format")]
[DisplayName("Section Pagination")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section Pagination")]
public SectionPagination Section_Pagination
{
get
{
string s = _Xp["Section", "Pagination"];
if (s == string.Empty || s.Equals("-1")) return SectionPagination.Default;
return (SectionPagination)int.Parse(_Xp["Section", "Pagination"]);
}
set
{
if (value == SectionPagination.Default) _Xp["Section", "Pagination"] = string.Empty;
else _Xp["Section", "Pagination"] = ((int)value).ToString();
OnPropertyChanged("Section_Pagination");
}
}
// ... jsj
//[Category("Section")]
//[DisplayName("Section Pagination")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Section Pagination")]
//public string Section_Pagination
//{
// get
// {
// return _Xp["Section", "Pagination"];
// }
// set
// {
// _Xp["Section", "Pagination"] = value;
// OnPropertyChanged("Section_Pagination");
// }
//}
//[Category("Section")]
[Category("View Settings")]
//[DisplayName("Section LinkEnhanced")]
[DisplayName("Include in Background/Deviation")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section LinkEnhanced")]
public string Section_LnkEnh
{
get
{
return _Xp["Section", "LnkEnh"];
}
set
{
_Xp["Section", "LnkEnh"] = value;
OnPropertyChanged("Section_LnkEnh");
}
}
//[Category("Section")]
[Category("General")]
//[DisplayName("Section TOC")]
[DisplayName("Include On Table Of Contents")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section TOC")]
public string Section_TOC
{
get
{
return _Xp["Section", "TOC"];
}
set
{
_Xp["Section", "TOC"] = value;
OnPropertyChanged("Section_TOC");
}
}
[Category("Section")]
[DisplayName("Section AutoGen")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section AutoGen")]
public string Section_AutoGen
{
get
{
return _Xp["Section", "AutoGen"];
}
set
{
_Xp["Section", "AutoGen"] = value;
OnPropertyChanged("Section_AutoGen");
}
}
[Category("Section")]
[DisplayName("Section NumPages")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section NumPages")]
public string Section_NumPages
{
get
{
return _Xp["Section", "NumPages"];
}
set
{
_Xp["Section", "NumPages"] = value;
OnPropertyChanged("Section_NumPages");
}
}
// jsj ...
[TypeConverter(typeof(EnumDescConverter))]
public enum SectionColumnMode : int
{
Default = 0,
[Description("Single Column")]One,
[Description("Duel Column")]Two,
[Description("Triple Column")]Three,
[Description("Quad Column")]Four
}
//[Category("Section")]
[Category("Format")]
//[DisplayName("Section ColumnMode")]
[DisplayName("Columns")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section ColumnMode")]
public SectionColumnMode Section_ColumnMode
{
get
{
string s = _Xp["Section", "ColumnMode"];
if (s == string.Empty || s.Equals("-1")) return SectionColumnMode.Default;
return (SectionColumnMode)int.Parse(_Xp["Section", "ColumnMode"]);
}
set
{
if (value == SectionColumnMode.Default) _Xp["Section", "ColumnMode"] = string.Empty;
else _Xp["Section", "ColumnMode"] = ((int)value).ToString();
OnPropertyChanged("Section_ColumnMode");
}
}
// ... jsj
//[Category("Section")]
//[DisplayName("Section ColumnMode")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Section ColumnMode")]
//public string Section_ColumnMode
//{
// get
// {
// return _Xp["Section", "ColumnMode"];
// }
// set
// {
// _Xp["Section", "ColumnMode"] = value;
// OnPropertyChanged("Section_ColumnMode");
// }
//}
#endregion
#region SubSectionCategory // from sequence number in 16-bit database.
[Category("SubSection")]
[DisplayName("SubSection Edit")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection Edit")]
public string SubSection_Edit
{
get
{
return _Xp["SubSection", "Edit"];
}
set
{
_Xp["SubSection", "Edit"] = value;
OnPropertyChanged("SubSection_Edit");
}
}
[Category("SubSection")]
[DisplayName("SubSection PH")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection PH")]
public string SubSection_PH
{
get
{
return _Xp["SubSection", "PH"];
}
set
{
_Xp["SubSection", "PH"] = value;
OnPropertyChanged("SubSection_PH");
}
}
[Category("SubSection")]
[DisplayName("SubSection AutoIndent")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection AutoIndent")]
public string SubSection_AutoIndent
{
get
{
return _Xp["SubSection", "AutoIndent"];
}
set
{
_Xp["SubSection", "AutoIndent"] = value;
OnPropertyChanged("SubSection_AutoIndent");
}
}
#endregion
#region LibDocCategory // from library document file during migration
[Category("LibraryDocument")]
[DisplayName("LibraryDocument Comment")]
[RefreshProperties(RefreshProperties.All)]
[Description("LibraryDocument Comment")]
public string LibDoc_Comment
{
get
{
return _Xp["LibraryDocument", "Comment"];
}
set
{
_Xp["LibraryDocument", "Comment"] = value;
OnPropertyChanged("LibDoc_Comment");
}
}
#endregion
}
}

View File

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class UserConfig:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
public UserConfig(string xml)
{
if (xml == string.Empty) xml = "<config/>";
_Xp = new XMLProperties(xml);
}
public UserConfig()
{
_Xp = new XMLProperties();
}
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<config/>" || s == "<config></config>") return string.Empty;
return s;
}
#region UserCategory // from user.cfg
[Category("User")]
[DisplayName("User Location1")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Location1")]
public string User_UserLoc1
{
get
{
return _Xp["user", "UserLoc1"];
}
set
{
_Xp["user", "UserLoc1"] = value;
OnPropertyChanged("User_UserLoc1");
}
}
[Category("User")]
[DisplayName("User Location2")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Location2")]
public string User_UserLoc2
{
get
{
return _Xp["user", "UserLoc2"];
}
set
{
_Xp["user", "UserLoc2"] = value;
OnPropertyChanged("User_UserLoc2");
}
}
[Category("User")]
[DisplayName("User Phone1")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Phone1")]
public string User_UserPhone1
{
get
{
return _Xp["user", "UserPhone1"];
}
set
{
_Xp["user", "UserPhone1"] = value;
OnPropertyChanged("User_UserPhone1");
}
}
[Category("User")]
[DisplayName("User Phone2")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Phone2")]
public string User_UserPhone2
{
get
{
return _Xp["user", "UserPhone2"];
}
set
{
_Xp["user", "UserPhone2"] = value;
OnPropertyChanged("User_UserPhone2");
}
}
#endregion
}
}

View File

@ -0,0 +1,171 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
public delegate string XMLPropertiesEvent(object sender, XMLPropertiesArgs args);
[Serializable()]
public class XMLProperties
{
#region Events
public event XMLPropertiesEvent LookInAncestor;
private string OnLookInAncestor(object sender, XMLPropertiesArgs args)
{
if (LookInAncestor != null) return LookInAncestor(sender, args);
return string.Empty;
}
#endregion
#region Constructors
public XMLProperties()
{
_XmlContents = new XmlDocument();
_XmlContents.LoadXml("<config/>");
}
public XMLProperties(string xml)
{
_XmlContents = new XmlDocument();
_XmlContents.LoadXml(xml);
}
#endregion
#region BusinessMethods
[NonSerialized]
private bool _ParentLookup=false;
public bool ParentLookup
{
get { return _ParentLookup; }
set { _ParentLookup = value; }
}
[NonSerialized]
XmlDocument _XmlContents;
public XmlDocument XmlContents
{
get { return _XmlContents; }
}
private XmlNode GetGroup(string group)
{
XmlNodeList xl = _XmlContents.DocumentElement.SelectNodes(string.Format("//{0}", group));
switch (xl.Count)
{
case 0: // No nodes found
return null;
case 1: // Found the node
XmlNode xn = xl[0];
if (xn.GetType() == typeof(XmlElement)) return xn;
throw new XmlPropertiesException("Retrieved {0} while looking for XmlElement //{1}", xn.GetType().ToString(), group);
default: // Found more than 1 node
throw new XmlPropertiesException("Found more than one node //{0}", group);
}
}
private XmlAttribute GetItem(XmlNode xx, string item)
{
XmlNodeList xl = xx.SelectNodes(string.Format("@{0}", item));
switch (xl.Count)
{
case 0: // No nodes found
return null;
case 1: // Found the node
XmlNode xn = xl[0];
if (xn.GetType() == typeof(XmlAttribute)) return (XmlAttribute)xn;
throw new XmlPropertiesException("Retrieved {0} while looking for XmlAttribute @{1}", xn.GetType().ToString(), item);
default: // Found more than 1 node
throw new XmlPropertiesException("Found more than one node @{0}", item);
}
}
public string this[string group, string item]
{
get
{
if (_ParentLookup)
return OnLookInAncestor(this, new XMLPropertiesArgs(group, item));
XmlNode xn = GetGroup(group);
if (xn == null) return OnLookInAncestor(this,new XMLPropertiesArgs(group,item));
XmlNode xa = GetItem(xn, item);
if (xa == null) return OnLookInAncestor(this, new XMLPropertiesArgs(group, item));
return xa.InnerText;
}
set
{
if (value == null) value = string.Empty;
XmlNode xn = GetGroup(group);
if (xn == null)
{
if (value != string.Empty)// Add Group and Item
{
xn = _XmlContents.DocumentElement.AppendChild(_XmlContents.CreateElement(group));
XmlAttribute xa = xn.Attributes.Append(_XmlContents.CreateAttribute(item));
xa.Value = value;
}
}
else
{
XmlAttribute xa = GetItem(xn, item);
if (xa == null)
{
if (value != string.Empty) // Add Item
{
xa = xn.Attributes.Append(_XmlContents.CreateAttribute(item));
xa.Value = value;
}
}
else
{
if (value != string.Empty) // Add Item
{
xa.Value = value;
}
else
{
xn.Attributes.Remove(xa);
if (xn.Attributes.Count == 0)
_XmlContents.DocumentElement.RemoveChild(xn);
}
}
}
}
}
public override string ToString()
{
if (XmlContents == null) return null;
return XmlContents.OuterXml;
}
#endregion
#region XmlPropertiesException
public class XmlPropertiesException : Exception
{
public XmlPropertiesException() : base() { ;}
public XmlPropertiesException(string message) : base(message) { ;}
public XmlPropertiesException(string messageFormat,params object [] args) : base(string.Format(messageFormat,args)) { ;}
public XmlPropertiesException(SerializationInfo info, StreamingContext context) : base(info, context) { ;}
public XmlPropertiesException(string message,Exception innerException) : base(message, innerException) { ;}
}
#endregion
}
public partial class XMLPropertiesArgs
{
#region Business Methods
private string _Group;
public string Group
{
get { return _Group; }
set { _Group = value; }
}
private string _Item;
public string Item
{
get { return _Item; }
set { _Item = value; }
}
#endregion
#region Factory Methods
private XMLPropertiesArgs() { ;}
public XMLPropertiesArgs(string group, string item)
{
_Group=group;
_Item=item;
}
#endregion
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public partial class AnnotationInfo
{
public override string ToString()
{
return _SearchText;
}
}
public partial class AnnotationType
{
public override string ToString()
{
return _Name;
}
}
public partial class AnnotationTypeInfo
{
public override string ToString()
{
return _Name;
}
}
}

View File

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public static class ColorTab
{
private static Dictionary<string, int> ColorIndx = null;
// This dictionary takes a color name and converts it to the rtf string:
private static Dictionary<string, string> ColorRtf = null;
public enum E_Colors : int
{
black = 1, blue, green, cyan, red, magenta, brown, lightgray, darkgray, lightblue, lightgreen,
lightcyan, lightred, lightmagenta, yellow, white, ro, editbackground
}
#region ColorIndex
// Do I need this anymore.... I was using it when entire color table was in the rtf box.
public static int GetIndex(string color)
{
// if the dictionary hasn't been set yet,
if (ColorIndx==null)
{
ColorIndx = new Dictionary<string, int>();
ColorIndx["black"] = 1;
ColorIndx["blue"] = 2;
ColorIndx["green"] = 3;
ColorIndx["cyan"] = 4;
ColorIndx["red"] = 5;
ColorIndx["magenta"] = 6;
ColorIndx["brown"] = 7;
ColorIndx["lightgray"] = 8;
ColorIndx["darkgray"] = 9;
ColorIndx["lightblue"] = 10;
ColorIndx["lightgreen"] = 11;
ColorIndx["lightcyan"] = 12;
ColorIndx["lightred"] = 13;
ColorIndx["lightmagenta"] = 14;
ColorIndx["yellow"] = 15;
ColorIndx["white"] = 16;
ColorIndx["ro"] = 17;
ColorIndx["trans"] = 18;
ColorIndx["editbackground"] = 19;
}
return ColorIndx[color];
}
#endregion
#region ColorRtf
// This gets the rtf color table string for the input color.
public static string GetTableString(string color)
{
Dictionary<string, int> ColorIndx = new Dictionary<string, int>();
if (ColorRtf == null)
{
ColorRtf = new Dictionary<string, string>();
// color table, from 16-bit code, is defined as (in order):
// black=0,0,0
// blue=0,0,255
// green=0,155,12
// cyan=0,136,159
// red=255,0,0
// magenta=202,28,175
// brown=128,64,0
// lightgray=0,0,0
// darkgray=0,0,0
// lightblue=0,0,255
// lightgreen=0,255,0
// lightcyan=0,0,255
// lightred=209,29,183
// lightmagenta=255,0,255
// yellow=255,0,0
// white=128,128,128
// ro=255,128,0
// editbackground=192,192,192
ColorRtf["black"] = "\\red0\\green0\\blue0;";
ColorRtf["blue"] = "\\red0\\green0\\blue255;";
ColorRtf["green"] = "\\red0\\green155\\blue12;";
ColorRtf["cyan"] = "\\red0\\green136\\blue159;";
ColorRtf["red"] = "\\red255\\green0\\blue0;";
ColorRtf["magenta"] = "\\red202\\green28\\blue175;";
ColorRtf["brown"] = "\\red128\\green64\\blue0;";
ColorRtf["lightgray"] = "\\red100\\green100\\blue100;";
ColorRtf["darkgray"] = "\\red10\\green10\\blue10;";
ColorRtf["lightblue"] = "\\red0\\green0\\blue255;";
ColorRtf["lightgreen"] = "\\red0\\green255\\blue0;";
ColorRtf["lightcyan"] = "\\red0\\green0\\blue255;";
ColorRtf["lightred"] = "\\red209\\green29\\blue183;";
ColorRtf["lightmagenta"] = "\\red255\\green0\\blue255;";
ColorRtf["yellow"] = "\\red255\\green0\\blue0;";
ColorRtf["white"] = "\\red128\\green128\\blue128;";
ColorRtf["ro"] = "\\red255\\green128\\blue0;";
ColorRtf["trans"] = "\\red255\\green128\\blue0;";
ColorRtf["editbackground"] = "\\red192\\green192\\blue192;";
}
return ColorRtf[color];
}
#endregion
}
}

View File

@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
namespace VEPROMS.CSLA.Library
{
public partial class Content
{
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
}
public partial class ContentInfo
{
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
//public XmlNode ToXml(XmlNode xn)
//{
// XmlNode nd = xn.OwnerDocument.CreateElement("Content");
// xn.AppendChild(nd);
// AddAttribute(nd, "Number", _Number);
// AddAttribute(nd, "Text", _Text);
// AddAttribute(nd, "FormatID", _FormatID);
// AddAttribute(nd, "Config", _Config);
// return nd;
//}
//public void AddAttribute(XmlNode xn, string name, object o)
//{
// if (o != null && o.ToString() != "")
// {
// XmlAttribute xa = xn.OwnerDocument.CreateAttribute(name);
// xa.Value = o.ToString();
// xn.Attributes.Append(xa);
// }
//}
}
public partial class ContentInfoList
{
public static ContentInfoList GetList(int? itemID)
{
try
{
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ContentListCriteria(itemID));
ContentInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemInfoList.GetChildren", ex);
}
}
[Serializable()]
private class ContentListCriteria
{
public ContentListCriteria(int? itemID)
{
_ItemID = itemID;
}
private int? _ItemID;
public int? ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
private void DataPortal_Fetch(ContentListCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_ListContentsByItemID";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
}

View File

@ -0,0 +1,735 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Drawing;
namespace VEPROMS.CSLA.Library
{
public class DisplayText
{
#region Properties
private ItemInfo _itemInfo;
// list of 'pieces of text' for this item. Pieces include symbols, ros,
// transitions & plain text.
private List<displayTextElement> _DisplayTextElementList;
public List<displayTextElement> DisplayTextElementList
{
get { return _DisplayTextElementList; }
set { _DisplayTextElementList = value; }
}
// dictionary for the font table for this item. Note that this may
// go away (it is not really used).
private Dictionary<int, string> _dicRtfFontTable;
public Dictionary<int, string> dicRtfFontTable
{
get { return _dicRtfFontTable; }
set { _dicRtfFontTable = value; }
}
private VE_Font _textFont; // Font from format for this item
public VE_Font TextFont
{
get { return _textFont; }
set { _textFont = value; }
}
public string OriginalText; // compare for save to see if change.
#endregion
#region Constructors
/// <summary>
/// DisplayText constructor:
/// Creates a DisplayText object that converts the database text into a list of
/// displayTextElement elements.
/// Arguments are:
/// ItemInfo itemInfo - the item whose text will be resolved
/// E_EditPrintMode ep_mode - edit or print.
/// E_ViewMode vw_mode - view or edit.
/// </summary>
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode)
{
_itemInfo = itemInfo;
DisplayTextElementList = new List<displayTextElement>();
OriginalText = itemInfo.MyContent.Text;
TextFont = GetItemFont();
string text = InsertRtfStyles();
// if in print mode or view mode, do replace words. Only if in edit mode are replace
// words left as is.
FormatInfo format = itemInfo.ActiveFormat;
if (epMode == E_EditPrintMode.PRINT || vwMode == E_ViewMode.VIEW) text = DoReplaceWords(text, format);
// displayTextElement List items are created for anything that is handled differently in RTB, i.e.
// symbols, ros, trans, text.
int startIndex = 0;
int index = -1;
while ((index = FindTokenChar(text, startIndex))>-1)
{
// Do any 'plain' text that preceeds the token.
if (index > startIndex) DoTextElement(text, startIndex, index);
// Now do any other types
if (text[index] == '\x15')
index = DoRO(text, index);
else if (text[index] == '\x252C' || text[index]=='\x2566')
index = DoTran(text, index);
else
index = DoSymbol(text, startIndex, index);
startIndex = index; // +1;
if (startIndex >= text.Length) break;
}
// Add any remaining text.
if (startIndex < text.Length) DoTextElement(text, startIndex, index);
}
#endregion
#region SaveData
public bool Save(RichTextBox rtb)
{
try
{
List<displayLinkElement> origList = GetLinkList(DisplayTextElementList);
// massage string to store in DisplayTextElementList...
RtfToDisplayTextElements(rtb);
// take the list & convert to data in the format to save to the database.
StringBuilder sret = new StringBuilder();
foreach (displayTextElement vte in DisplayTextElementList)
{
if (vte.Type == E_TextElementType.TEXT || vte.Type == E_TextElementType.SYMBOL)
sret.Append(vte.Text);
else if (vte.Type == E_TextElementType.RO)
sret.Append(ToData_RO((displayLinkElement)vte));
else if (vte.Type == E_TextElementType.TRANS_Single)
sret.Append(ToData_Trans((displayLinkElement)vte));
}
string modtext = sret.ToString();
if (modtext != OriginalText)
{
Item itm = _itemInfo.Get();
// check for different text, i.e. text from this itm doesn't match
// original text.
if (OriginalText != itm.MyContent.Text)
{
Console.WriteLine("Save Failed because text changed outside of this edit session.");
return false;
}
// Compare ro/transition lists and delete or add any to the item for any ros/transitions that have been
// added/deleted or modified.
ProcessRoTranChanges(itm, origList);
itm.MyContent.Text = modtext;
itm.Save();
}
else
return true; // no text changed, but did not fail so return true.
}
catch (Exception ex)
{
Console.WriteLine("Save Failed with error: {0}", ex.Message);
return false;
}
return true;
}
private void ProcessRoTranChanges(Item itm, List<displayLinkElement> origList)
{
// go through list. Note that only linked items are in the origList.
// 1) delete any that are in origList but not in the DisplayTextElementList
// (that represents the current text & links)
// 2) add any that are only in DisplayTextElementList
// 3) delete/add for modify?
// delete first - if in original, but not in current list, delete the one
// in the original list.
foreach (displayLinkElement odte in origList)
{
bool found = false;
foreach (displayTextElement dte in DisplayTextElementList)
{
if (dte.Type == odte.Type)
{
displayLinkElement l_dte = (displayLinkElement)dte;
if (odte.Link == l_dte.Link)
{
found = true;
break;
}
}
}
// remove the link element from the item.
if (!found)
{
// Get record id for ro or trans and then find the associated ro or transition
// in the item's list. remove it.
int recid = -1;
if (odte.Type != E_TextElementType.RO)
{
int sp = odte.Link.IndexOf(" ") + 1; // get past tran type
string srecid = odte.Link.Substring(sp, odte.Link.IndexOf(" ", sp) - sp);
recid = System.Convert.ToInt32(srecid);
foreach (ContentTransition ct in itm.MyContent.ContentTransitions)
{
if (ct.TransitionID == recid)
{
itm.MyContent.ContentTransitions.Remove(ct);
break;
}
}
}
else
{
int sp = odte.Link.IndexOf(" ");
//rousageid starts after "#Link:ReferencedObject:", i.e. index in link of 23
string srecid = odte.Link.Substring(23, sp-23);
recid = System.Convert.ToInt32(srecid);
foreach (ContentRoUsage cr in itm.MyContent.ContentRoUsages)
{
if (cr.ROUsageID == recid)
{
itm.MyContent.ContentRoUsages.Remove(cr);
break;
}
}
}
}
}
// now do insert, i.e. in new list, but not in old.
foreach (displayTextElement dte in DisplayTextElementList)
{
bool found = false;
if (dte.Type == E_TextElementType.RO || dte.Type == E_TextElementType.TRANS_Single || dte.Type == E_TextElementType.TRANS_Range)
{
foreach (displayLinkElement odte in origList)
{
if (dte.Type == odte.Type)
{
// if the link is the same, it exists, so no action is required.
displayLinkElement l_dte = (displayLinkElement)dte;
if (odte.Link == l_dte.Link)
{
found = true;
break;
}
}
}
// Insert the link (ro or transition) to the item
if (!found)
{
Console.WriteLine("New ro or trans");
}
}
}
}
private List<displayLinkElement> GetLinkList(List<displayTextElement> locDisplayTextElementList)
{
List<displayLinkElement> retList = new List<displayLinkElement>();
foreach (displayTextElement vte in locDisplayTextElementList)
{
if (vte.Type == E_TextElementType.RO || vte.Type == E_TextElementType.TRANS_Range || vte.Type == E_TextElementType.TRANS_Single)
{
displayLinkElement tmp = (displayLinkElement)vte;
displayLinkElement copy_vte = new displayLinkElement();
copy_vte.Type = tmp.Type;
copy_vte.Link = tmp.Link;
copy_vte.Text = tmp.Text;
retList.Add(copy_vte);
}
}
return retList;
}
private void RtfToDisplayTextElements(RichTextBox rtb)
{
// GetFontTable returns a non-negative number font number in the
// font table for the unicode font, if it is used (otherwise -1)
//int unicodeFont = GetFontTable(rtb.Rtf);
// strip off all rtf commands...
string noExtraRtfStr = StripRtfCommands(rtb.Rtf);
//Console.WriteLine("StripRtf: {0}", noExtraRtfStr);
DisplayTextElementList.Clear();
int startIndex = 0;
int index = -1;
while ((index = FindRtfChar(noExtraRtfStr, startIndex)) > -1)
{
int fndindx = -1;
// Do any 'plain' text that preceeds the token.
if (index > startIndex)
index = SaveTextElement(noExtraRtfStr, startIndex, index);
if ((fndindx = noExtraRtfStr.IndexOf("\\protect")) == index)
index = SaveLink(noExtraRtfStr, index);
else
index = SaveSymbolTE(noExtraRtfStr, index);
startIndex = index + 1;
if (startIndex >= noExtraRtfStr.Length) break;
}
// Add any remaining text.
if (startIndex < noExtraRtfStr.Length) DoTextElement(noExtraRtfStr, startIndex, index);
//Console.WriteLine(noExtraRtfStr);
}
private int SaveTextElement(string data, int startIndex, int index)
{
displayTextElement vte = new displayTextElement();
vte.Type = E_TextElementType.TEXT;
int len = (index == -1) ? data.Length - startIndex : index - startIndex;
vte.Text = data.Substring(startIndex, len);
DisplayTextElementList.Add(vte);
return index;
}
private int SaveSymbolTE(string data, int startIndex)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = E_TextElementType.SYMBOL;
// symbols are just the unicode/rtf command, no font associated with it
// by the time it gets here... A symbol can be represented by \'xy or \uxyz?
// if the \'xy is used the length of the symbol number will always be two,
// otherwise find the index of the '?' to find the end.
int endindx = -1;
if (data[startIndex + 1] == '\'') endindx = startIndex + 3;
else endindx = data.IndexOf("?", startIndex);
if (endindx == -1) return startIndex; // not found - error
vte.Text = data.Substring(startIndex, endindx - startIndex + 1);
DisplayTextElementList.Add(vte);
return endindx + 1;
}
private int SaveLink(string data, int startIndex)
{
displayLinkElement vte = new displayLinkElement();
// first find if RO or trans, the RO has a #R.
int istart = data.IndexOf("#Link:", startIndex);
if (data[istart + 6] == 'R') return SaveROTE(data, startIndex);
else if (data.Substring(istart+6,11) == "TransitionR")
return SaveTranTE(data, startIndex, E_TextElementType.TRANS_Range);
return SaveTranTE(data, startIndex, E_TextElementType.TRANS_Single);
}
private int SaveTranTE(string data, int startIndex, E_TextElementType type)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = type;
// \protect {transition text} \v #Link:Transition(Range): 1 2 3\protect0\v0 where 1 2 3 are transition type and ids
int indx = data.IndexOf("\\v #Link:Transition", startIndex);
vte.Text = data.Substring(startIndex + 9, indx - startIndex - 9); // get past \protect
int iend = data.IndexOf("\\protect0\\v0", indx);
if (iend == -1) iend = data.IndexOf("\\v0\\protect0", indx);
// get past \v #Link:Transition or \v #Link:TransitionRange
int bindx = indx + 3;
//if (type == E_TextElementType.TRANS_Range) bindx += 5;
vte.Link = data.Substring(bindx, iend - bindx);
DisplayTextElementList.Add(vte);
return iend + 11; // get past the \protect0\vo
}
private int SaveROTE(string data, int startIndex)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = E_TextElementType.RO;
// \protect {rovalue} \v #Link:ReferencedObject (RoUsageId) {ROID}\protect0\v0
int indx = data.IndexOf("\\v #Link:ReferencedObject", startIndex);
vte.Text = data.Substring(startIndex + 9, indx - startIndex - 9); // get past \protect
int iend = data.IndexOf("\\protect0\\v0", indx);
if (iend == -1) iend = data.IndexOf("\\v0\\protect0", indx);
vte.Link = data.Substring(indx + 3, iend - indx - 3); // get past \v #Link:ReferencedObject
DisplayTextElementList.Add(vte);
return iend + 11; // get past the \protect0\vo
}
private int FindRtfChar(string text, int startIndex)
{
int prindx = text.IndexOf("\\protect", startIndex);
int symindx1 = text.IndexOf("\\'", startIndex);
int symindx2 = text.IndexOf("\\u", startIndex);
if (symindx2 > -1)
{
if (text[symindx2+2] == 'l') symindx2 = -1; // don't process underlines
}
if (prindx == -1 && symindx1 == -1 && symindx2 == -1) return -1;
if (prindx == -1) prindx = text.Length + 1;
if (symindx1 == -1) symindx1 = text.Length + 1;
if (symindx2 == -1) symindx2 = text.Length + 1;
// Which token has smallest number, to determine which item is next
// in the string. If it is a symbol - see if it has a font specifier
// first.
int symindx = symindx1 < symindx2 ? symindx1 : symindx2;
int smallest = (prindx < symindx ? prindx : symindx);
return smallest;
}
private int GetFontTable(string rtf)
{
dicRtfFontTable = new Dictionary<int, string>();
// return unicode (symbol) font number, if it exists, to expedite finding
// the font for symbols.
int unicodeFont = -1;
int bindx = rtf.IndexOf(@"{\fonttbl");
if (bindx < -1) return -1;
int eindx = rtf.IndexOf("}}", bindx);
// get font table string and then do regular expressions to get font number
// with font name.
string tbl = rtf.Substring(bindx + 9, eindx - bindx - 8);
tbl = tbl.Replace("{", "<");
tbl = tbl.Replace("}", ">");
string pat = @"(?:<\\f)([0-9]+)(?:[\S]+ )([\w ]+)";
StringBuilder sb = new StringBuilder();
foreach (Match m in Regex.Matches(tbl, pat))
{
int num = Convert.ToInt32(m.Result("${1}"));
string nam = m.Result("${2}");
dicRtfFontTable.Add(num, nam);
if ((unicodeFont == -1) && (nam == "Arial Unicode MS")) unicodeFont = num;
}
return unicodeFont;
}
private string RemoveRtfStyles(string rtf)
{
string retval = rtf;
// remove rtf commands for any styles that were added. Note that if
// the entire item has a style, and also contains 'pieces' of text with
// the same style, the underlying rtf box removes the embedded rtf commands,
// for example, if the entire step is bolded, and 'THEN' has bold on/off
// surrounding it, the rtf box removes the bold around the 'THEN'
// These remove the command with a following space or the command alone,
// either case may exist, because if there are rtf commands following the
// style command, there will be no space character following the style command.
if ((TextFont.Style & E_Style.BOLD) > 0)
{
retval = Regex.Replace(retval, @"\\b0 ?", "");
retval = Regex.Replace(retval, @"\\b ?","");
}
if ((TextFont.Style & E_Style.UNDERLINE) > 0)
{
retval = Regex.Replace(retval, @"\\ul0 ?", "");
retval = Regex.Replace(retval, @"\\ul ?", "");
}
if ((TextFont.Style & E_Style.ITALICS) > 0)
{
retval = Regex.Replace(retval, @"\\i0 ?", "");
retval = Regex.Replace(retval, @"\\i ?", "");
}
return retval;
}
public string ReplaceRTFClause(Match m)
{
switch (m.Value[1])
{
case 'u':
if (Regex.IsMatch(m.Value, @"\\u[0-9]+"))
return m.Value; // Special Charcaters
if (Regex.IsMatch(m.Value, @"\\ulnone"))
return m.Value;
if (Regex.IsMatch(m.Value, @"\\ul.*"))
return m.Value; // Underline
break;
case '\'': // Special Character
return m.Value;
case 'b': // Bold
return m.Value;
case 's': // sub or super....
if (m.Value == @"\sub") return m.Value;
if (m.Value == @"\super") return m.Value;
break;
case 'n': // nosubsuper...
if (m.Value == @"\nosupersub") return m.Value;
break;
case 'i': // Italics
return m.Value;
case 'v': // save link hidden info
if (m.Value == @"\v") return m.Value; // part of link
if (Regex.IsMatch(m.Value, @"\\v0"))
return m.Value; // hidden info off
break;
case 'p':
if (m.Value == @"\par") return "\r\n";
if (m.Value == @"\protect")
return m.Value;
if (m.Value == @"\protect0")
return m.Value;
break;
}
return "";//Strip All
}
private string StripRtfCommands(string rtf)
{
string retval = Regex.Replace(rtf, @"[\r\n]", "", RegexOptions.Singleline); // Strip Carriage Returns and Newlines
retval = Regex.Replace(retval, @"^\{(.*)\}$", "$1", RegexOptions.Singleline); // Strip Opening and Closing Braces
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
retval = Regex.Replace(retval, @"\\[^ \\?]+", new MatchEvaluator(ReplaceRTFClause)); // take backslash xyz and evaluates them
// remove a space if there is one as the first character..
if (retval[0]==' ')retval = retval.Remove(0, 1);
// remove \r\n at end of string - this was added with the \par at the end of string by the rtf box
if (retval.Substring(retval.Length - 2, 2) == "\r\n") retval = retval.Remove(retval.Length - 2, 2);
retval = RemoveRtfStyles(retval);
return retval;
}
private string ToData_RO(displayLinkElement vte)
{
// get past the #Link:ReferencedObject part of the link.
return String.Format("\x15\\v RO\\v0 {0}\\v #{1}\\v0", vte.Text, vte.Link.Substring(23, vte.Link.Length-23));
}
private string ToData_Trans(displayLinkElement vte)
{
char trchar = vte.Type == E_TextElementType.TRANS_Single ? '\x252C' : '\x2566';
int indx = vte.Type == E_TextElementType.TRANS_Single ? 16 : 21;
return String.Format("{0}\\v TRAN\\v0 {1}\\v {2}\\v0", trchar, vte.Text, vte.Link.Substring(indx, vte.Link.Length-indx));
}
#endregion
#region StyleData
private VE_Font GetItemFont()
{
VE_Font font = null;
FormatInfo format = _itemInfo.ActiveFormat;
int type = (int)_itemInfo.MyContent.Type;
switch (type/10000)
{
case 0: // procedure
font = format.PlantFormat.FormatData.Font;
break;
case 1: // section
font = format.PlantFormat.FormatData.SectData.SectionHeader.Font;
break;
case 2: // step types
int typindx = type - 20000; // what to do for other types rather than steps
font = format.PlantFormat.FormatData.StepDataList[typindx].Font;
break;
}
TextFont = font;
return font;
}
private string InsertRtfStyles()
{
StringBuilder sb = new StringBuilder(_itemInfo.MyContent.Text);
if ((TextFont.Style & E_Style.BOLD)>0)
{
sb.Insert(0, "\\b ");
sb.Append("\\b0 ");
}
if ((TextFont.Style & E_Style.UNDERLINE) > 0)
{
sb.Insert(0, "\\ul ");
sb.Append("\\ul0 ");
}
if ((TextFont.Style & E_Style.ITALICS) > 0)
{
sb.Insert(0, "\\i ");
sb.Append("\\i0 ");
}
return sb.ToString();
}
#endregion
#region DoListElements
private int FindTokenChar(string txt, int startIndex)
{
// tokens are ro, transitions and possible symbol
char[] tok = { '\x15', '\x252C', '\x2566', '\\' };
bool done = false;
// If there is only an rtf token from the indexed position on, don't return the
// IndexOfAny index value, because it will by one character past the '\' and throw
// of the return value of where in the string the text should be saved. For example
// for the string '\b text \v somevalue \v0\b0', the first time through the while
// loop has the index at the '\b' char of the b0.
//int savstartIndex = startIndex;
while (!done)
{
int indx = txt.IndexOfAny(tok, startIndex);
if (indx < 0) return indx;
if (txt[indx] != '\\') return indx;
// see if symbol (but not underline) or another rtf command: has a 'u'
// followed by a non-underline or single quote, and if so, return it.
// Otherwise, get next index, must have been a slash or other rtf command.
if (((txt[indx + 1] == 'u' && txt[indx + 2] != 'l')) || (txt[indx + 1] == '\'')) return indx;
startIndex=indx+1;
}
return -1;
}
private int DoTextElement(string text, int startIndex, int index)
{
displayTextElement vte = new displayTextElement();
vte.Type = E_TextElementType.TEXT;
int len = (index == -1) ? text.Length - startIndex : index - startIndex;
vte.Text = text.Substring(startIndex, len);
DisplayTextElementList.Add(vte);
return index+1;
}
private string CreateLink(E_TextElementType type, string linktxt)
{
string retlink = "";
if (type == E_TextElementType.RO)
retlink = "#Link:ReferencedObject:" + linktxt;
else if (type == E_TextElementType.TRANS_Single)
retlink = "#Link:Transition:" + linktxt;
else
retlink = "#Link:TransitionRange:" + linktxt;
return retlink;
}
private int DoRO(string text, int index)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = E_TextElementType.RO;
// ro has form \v RO\v0 9.5 psig\v #1 0001000000ec0000 \v0 - so find second
// \v0 to end the string.
int istart = text.IndexOf("\\v0",index) + 4;
int iend = text.IndexOf("\\v", istart);
vte.Text = text.Substring(istart, iend - istart);
istart = text.IndexOf("#", iend) + 1;
iend = text.IndexOf("\\v0", istart);
vte.Link = CreateLink(vte.Type, text.Substring(istart, iend - istart));
DisplayTextElementList.Add(vte);
// return the position past the end of the \v0. There is a space after the
// \v0 so account for that.
return iend + 4;
}
private string FixTransition(string link, string text)
{
int transitionID = Convert.ToInt32(link.Split(" ".ToCharArray())[1]);
// Find the transition
foreach (TransitionInfo ti in _itemInfo.MyContent.ContentTransitions)
{
if (ti.TransitionID == transitionID)
{
string path = ti.PathTo.Replace(" Section PROCEDURE STEPS ", ", ");
path = path.Replace(" Section PROCEDURE STEPS", "");
return path;
}
}
return text;
}
private int DoTran(string text,int index)
{
displayLinkElement vte = new displayLinkElement();
// transition (not range) has form \v TRAN\v0 (resolved transition text)\v type fromid toid [rangeid, if range]\v0
int istart = text.IndexOf("\\v0", index) + 4;
int iend = text.IndexOf("\\v", istart);
vte.Text = text.Substring(istart, iend - istart); // this stores the resolved transition text
istart = iend + 3; // get to transition type.
iend = text.IndexOf("\\v0", istart);
vte.Text = FixTransition(text.Substring(istart, iend - istart), vte.Text);
// Determine whether it is single or range transition. Can tell by number of spaces in
// link string.
string[] parts = text.Substring(istart, iend - istart).Split(" ".ToCharArray());
if (parts.Length == 3) vte.Type = E_TextElementType.TRANS_Single;
else vte.Type = E_TextElementType.TRANS_Range;
vte.Link = CreateLink(vte.Type, text.Substring(istart, iend - istart));
DisplayTextElementList.Add(vte);
// return the position past the end of the \v0. There is a space after the
// \v0 so account for that.
return iend + 4;
}
private int DoSymbol(string text, int startIndex, int index)
{
displayTextElement vte = new displayTextElement();
vte.Type = E_TextElementType.SYMBOL;
// symbols are the unicode/rtf command. A symbol can be represented by \'xy or
// in the text from the database \uxyz?. If the \'xy is used the length of the
// symbol number will always be two, otherwise find the index of the '?' to
// find the end.
int endindx = -1;
if (text[index + 1] == '\'') endindx = index + 3;
else endindx = text.IndexOf("?", index);
vte.Text = text.Substring(index, endindx - index + 1);
DisplayTextElementList.Add(vte);
// return the position just past the symbol.
return endindx+1;
}
#endregion
#region ReplaceWords
private ReplaceStr _rs;
private string ReplaceIt(Match m)
{
string s = m.ToString();
string t = s.Replace(_rs.ReplaceWord, _rs.ReplaceWith);
return m.ToString().Replace(_rs.ReplaceWord, _rs.ReplaceWith);
}
private string DoReplaceWords(string Text, FormatInfo format)
{
ReplaceStrList rsl = format.PlantFormat.FormatData.SectData.ReplaceStrList;
foreach (ReplaceStr rs in rsl)
{
if (_itemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps.
bool replaceit = false;
// note that the order of this check is important. Check in this order...
// background here
if (_itemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.HIGH)>0) replaceit = true;
else if ((_itemInfo.IsTable || _itemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.TABLE) > 0) replaceit = true;
else if (_itemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
else if (_itemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.CAUTION) > 0) replaceit = true;
else if (_itemInfo.IsNote && (rs.Flag & E_ReplaceFlags.NOTE) > 0) replaceit = true;
else if (_itemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.SUBSTEP) > 0) replaceit = true;
else if (_itemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.ATTACH) > 0) replaceit = true;
if (replaceit)
{
// CASEINSENS: Do ReplaceWords for all words that match, regardless of case, and replace
// with the ReplaceWith string as is
if ((rs.Flag & E_ReplaceFlags.CASEINSENS) > 0)
{
string res = "";
string fortest = Text.ToUpper();
string pat = @"(?<=\W|^)" + rs.ReplaceWord.ToUpper() + @"(?=\W|$)";
int cpindx = 0;
foreach (Match m in Regex.Matches(fortest, pat))
{
res += Text.Substring(cpindx, m.Index-cpindx);
cpindx += (m.Index - cpindx);
res += rs.ReplaceWith;
cpindx += rs.ReplaceWord.Length;
}
if (cpindx < Text.Length) res += Text.Substring(cpindx, Text.Length - cpindx);
Text = res;
}
// CASEINSENSALL: Do ReplaceWords for all words that match the ReplaceWord, regardless of case
else if ((rs.Flag & E_ReplaceFlags.CASEINSENSALL) > 0)
{
// not in hlp
}
// CASEINSENSFIRST: Do ReplaceWords for all words that exactly match the ReplaceWord,
// except the case where the first character may be different
else if ((rs.Flag & E_ReplaceFlags.CASEINSENSFIRST) > 0)
{
// not in hlp
}
else
{
string pat = @"(?<=\W|^)" + rs.ReplaceWord + @"(?=\W|$)";
Text = Regex.Replace(Text, pat, rs.ReplaceWith);
}
}
}
return Text;
}
#endregion
}
#region displayTextElementClass
public enum E_TextElementType : uint
{
TEXT = 0,
SYMBOL = 1,
RO = 2,
TRANS_Single = 3,
TRANS_Range = 4
};
public class displayTextElement
{
private E_TextElementType _Type;
public E_TextElementType Type
{
get { return _Type; }
set { _Type = value; }
}
private string _Text;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
}
public class displayLinkElement : displayTextElement
{
private string _Link;
public string Link
{
get { return _Link; }
set { _Link = value; }
}
}
#endregion
}

View File

@ -0,0 +1,155 @@
// ========================================================================
// Copyright 2006 - 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.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public partial class DocVersion: IVEDrillDown
{
#region VersionType
public VersionTypeEnum eVersionType
{
get { return (VersionTypeEnum)_VersionType; }
set { _VersionType = (int)value; }
}
#endregion
#region DocVersion Config
[NonSerialized]
private DocVersionConfig _DocVersionConfig;
public DocVersionConfig DocVersionConfig
{
get
{
if (_DocVersionConfig == null)
{
_DocVersionConfig = new DocVersionConfig(this);
_DocVersionConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_DocVersionConfig_PropertyChanged);
}
return _DocVersionConfig;
}
}
private void _DocVersionConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Config = _DocVersionConfig.ToString();
}
#endregion
public override string ToString()
{
return string.Format("{0} - {1}", Name, Title);
}
#region IVEDrillDown
public System.Collections.IList GetChildren()
{
return null;
}
public bool HasChildren
{
get { return _ItemID > 0; }
}
public IVEDrillDown ActiveParent
{
get
{
return MyFolder;
}
}
public Format ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
}
public Format LocalFormat
{
get { return MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return DocVersionConfig; }
}
#endregion
}
public partial class DocVersionInfo:IVEDrillDownReadOnly
{
#region DocVersion Config
[NonSerialized]
private DocVersionConfig _DocVersionConfig;
public DocVersionConfig DocVersionConfig
{ get { return (_DocVersionConfig != null ? _DocVersionConfig : _DocVersionConfig = new DocVersionConfig(this));} }
private void DocVersionConfigRefresh()
{
_DocVersionConfig = null;
}
#endregion
ItemInfoList _iil = null;
public ItemInfoList Procedures
{ get { return (_iil != null ? _iil: _iil = ItemInfoList.GetList(_ItemID,(int)E_FromType.Procedure)); } }
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
return Procedures;
}
//public bool ChildrenAreLoaded
//{
// get { return _iil == null; }
//}
public bool HasChildren
{
get { return _ItemID > 0; }
}
public IVEDrillDownReadOnly ActiveParent
{
get
{
return MyFolder;
}
}
public FormatInfo ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
}
public FormatInfo LocalFormat
{
get { return MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return Get().DocVersionConfig; }
}
//public bool HasStandardSteps()
//{ return false; }
public override string ToString()
{
return string.Format("{0} - {1}", Name, Title);
}
//public string ToString(string str,System.IFormatProvider ifp)
//{
// return ToString();
//}
#endregion
#region Extension
partial class DocVersionInfoExtension : extensionBase
{
public override void Refresh(DocVersionInfo tmp)
{
tmp.DocVersionConfigRefresh();
}
}
#endregion
}
public enum VersionTypeEnum : int
{
WorkingDraft = 0, Temporary = 1, Revision = 128, Approved = 129
}
}

View File

@ -0,0 +1,138 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace VEPROMS.CSLA.Library
{
public partial class DocumentInfo
{
public string DocumentTitle
{
get
{
if (_LibTitle == "") return string.Format("Document {0}", _DocID);
return _LibTitle;
}
}
}
public class DSOFile : IDisposable
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Fields
private bool _IsDisposed;
private static string _TemporaryFolder = null;
private DocumentInfo _MyDocument = null;
private FileInfo _MyFile = null;
private string _Extension = "DOC";
#endregion
#region Properties
public static string TemporaryFolder
{
get
{
if (_TemporaryFolder == null)
{
_TemporaryFolder = string.Format(@"C:\Documents and Settings\{0}\Local Settings\Temp", Environment.UserName);
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
_TemporaryFolder += @"\VE-PROMS";
if (!Directory.Exists(TemporaryFolder)) Directory.CreateDirectory(TemporaryFolder);
}
return _TemporaryFolder;
}
}
public DocumentInfo MyDocument
{
get { return _MyDocument; }
set
{
TryDelete();
_MyDocument = value;
CreateFile();
}
}
public FileInfo MyFile
{
get { return _MyFile; }
}
public string Extension
{
get { return _Extension; }
set { _Extension = value; }
}
#endregion
#region Private Methods
private void TryDelete()
{
if (_MyDocument == null) return;
if (_MyFile == null) return;
if (_MyFile.Exists)
{
try
{
_MyFile.Delete();
}
catch (IOException ex)
{
_MyLog.Error("TryDelete",ex);
}
finally
{
_MyFile = null;
_MyDocument = null;
}
}
}
private void CreateFile()
{
if (_MyDocument == null) return;
_MyFile = new FileInfo(string.Format(@"{0}\tmp_{1}." + Extension , TemporaryFolder, MyDocument.DocID));
FileStream fs = _MyFile.Create();
fs.Write(MyDocument.DocContent, 0, MyDocument.DocContent.Length);
fs.Close();
_MyFile.CreationTime = _MyDocument.DTS;
_MyFile.LastWriteTime = _MyDocument.DTS;
}
public void SaveFile()
{
// TODO: Add Try & Catch logic
if (_MyDocument == null) return;
Document doc = _MyDocument.Get();
FileStream fs = _MyFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Byte[] buf = new byte[_MyFile.Length];
fs.Read(buf,0,buf.Length);
fs.Close();
doc.DocContent = buf;
doc.UserID = Environment.UserName;
doc.DTS = _MyFile.LastWriteTime;
doc.Save();
}
#endregion
#region Constructors
public DSOFile(DocumentInfo myDocument)
{
MyDocument = myDocument;
}
#endregion
#region Destructor
~DSOFile()
{
Dispose(false);
}
public void Dispose()
{
Dispose(false);
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
{
if (!_IsDisposed)
{
_IsDisposed = true;
TryDelete();
}
}
#endregion
}
}

View File

@ -0,0 +1,154 @@
// ========================================================================
// Copyright 2006 - 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.Drawing;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public partial class Folder : IVEDrillDown
{
#region Folder Config
[NonSerialized]
private FolderConfig _FolderConfig;
public FolderConfig FolderConfig
{
get
{
if (_FolderConfig == null)
{
_FolderConfig = new FolderConfig(this);
_FolderConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_FolderConfig_PropertyChanged);
}
return _FolderConfig;
}
}
public void FolderConfigRefresh()
{
_FolderConfig = null;
}
private void _FolderConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Config = _FolderConfig.ToString();
}
#endregion
public override string ToString()
{
return _Title;
}
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
if (FolderDocVersionCount != 0) return FolderDocVersions;
if (ChildFolderCount != 0) return ChildFolders;
return null;
}
public bool HasChildren
{
get { return _FolderDocVersionCount > 0 || _ChildFolderCount > 0; }
}
public IVEDrillDown ActiveParent
{
get
{
return MyParent;
}
}
public Format ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : (ActiveParent != null ? ActiveParent.ActiveFormat : null); }
}
public Format LocalFormat
{
get { return MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return FolderConfig; }
}
#endregion
}
public partial class FolderInfo:IVEDrillDownReadOnly
{
#region Folder Config (Read-Only)
[NonSerialized]
private FolderConfig _FolderConfig;
public FolderConfig FolderConfig
{ get {
return (_FolderConfig != null ? _FolderConfig : _FolderConfig = new FolderConfig(this));
} }
private void FolderConfigRefresh()
{
_FolderConfig = null;
}
#endregion
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
if(FolderDocVersionCount != 0)return FolderDocVersions;
if (ChildFolderCount != 0) return ChildFolders;
return null;
}
//public bool ChildrenAreLoaded
//{
// get { return _FolderDocVersions != null || _ChildFolders != null; }
//}
public bool HasChildren
{
get { return _FolderDocVersionCount > 0 || _ChildFolderCount > 0; }
}
public IVEDrillDownReadOnly ActiveParent
{
get
{
return MyParent;
}
}
public FormatInfo ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ( ActiveParent != null ? ActiveParent.ActiveFormat : null); }
}
public FormatInfo LocalFormat
{
get { return MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return Get().FolderConfig; }
}
public override string ToString()
{
return string.Format("{0} - {1}", Name, Title);
}
//public string ToString(string str, System.IFormatProvider ifp)
//{
// return ToString();
//}
#endregion
public Color BackColor
{ get { return FolderConfig.Default_BkColor; } }
#region Extension
partial class FolderInfoExtension : extensionBase
{
public override void Refresh(FolderInfo tmp)
{
tmp.FolderConfigRefresh();
}
}
#endregion
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public static class FontTab
{
private static Dictionary<string, int> FontIndx = null;
// This dictionary takes a color name and converts it to the rtf string:
private static Dictionary<string, string> FontRtf = null;
public enum E_Fonts : int
{
None = 0, PrestigeEliteTall = 64, CourierNew = 2, TimesNewRoman = 0, LetterGothic = 66, Arial = 202, VolianDraw = 70, GothicUltra = 63, LetterGothicTall = 67, VolianScript = 71, ArialUnicode = 35
}
#region FontIndex
/// <summary>
/// GetIndex - Use this to get the number of the font in the font table based on the input
/// string.
/// </summary>
/// <param name="font"></param>
/// <returns></returns>
public static int GetIndex(string font)
{
// if the dictionary hasn't been set yet,
if (FontIndx==null)
{
FontIndx = new Dictionary<string, int>();
FontIndx["Prestige Elite Tall"] = 64;
FontIndx["Courier New"] = 2;
FontIndx["Times New Roman"] = 0;
FontIndx["Letter Gothic"] = 66;
FontIndx["Arial"] = 202;
FontIndx["Volian Draw"] = 70;
FontIndx["Gothic Ultra"] = 63;
FontIndx["Letter Gothic Tall"] = 67;
FontIndx["VolianScript"] = 71;
FontIndx["Arial Unicode"] = 35;
}
return FontIndx[font];
}
#endregion
#region ColorRtf
/// <summary>
/// GetTableString - Use this to get the string to add to font table based on the input
/// string.
/// </summary>
public static string GetTableString(string font)
{
if (FontRtf == null)
{
FontRtf = new Dictionary<string, string>();
FontRtf["Prestige Elite Tall"] = "{\\f64\\fmodern\\fcharset2\\fprq1 Prestige Elite Tall;}";
FontRtf["Courier New"] = "{\\f2\\fmodern\\fcharset0\\fprq1 Courier New;}";
FontRtf["Times New Roman"] = "{\\f0\\froman\\fcharset0\\fprq2 Times New Roman;}";
FontRtf["Letter Gothic"] = "{\\f66\\fmodern\\fcharset2\\fprq1 Letter Gothic;}";
FontRtf["Arial"] = "{\\f1\\fswiss\\fcharset0\\fprq2 Arial;}";
FontRtf["Volian Draw"] = "{\\f70\\fmodern\\fcharset2\\fprq1 VolianDraw;}";
FontRtf["Gothic Ultra"] = "{\\f63\\fmodern\\fcharset2\\fprq1 Gothic Ultra;}";
FontRtf["Letter Gothic Tall"] = "{\\f67\\fmodern\\fcharset2\\fprq1 Letter Gothic Tall;}";
FontRtf["VolianScript"] = "{\\f71\\fswiss\\fcharset2\\fprq2 VolianScript;}";
FontRtf["Arial Unicode"] = "{\\f35\\fswiss\\fcharset128\\fprq2 Arial Unicode MS;}";
}
return FontRtf[font];
}
#endregion
}
}

View File

@ -0,0 +1,51 @@
// ========================================================================
// Copyright 2006 - 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.Xml;
using System.Drawing;
namespace VEPROMS.CSLA.Library
{
public partial class Format
{
#region PlantFormat
//[NonSerialized]
private PlantFormat _PlantFormat;
public PlantFormat PlantFormat
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this)); } }
#endregion
public override string ToString()
{
//return Name;
return PlantFormat.FormatData.Name;
}
}
public partial class FormatInfo
{
#region PlantFormat
//[NonSerialized]
private PlantFormat _PlantFormat;
public PlantFormat PlantFormat
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this.Get())); } }
#endregion
public override string ToString()
{
//return Name;
return PlantFormat.FormatData.Name;
}
}
}

View File

@ -0,0 +1,785 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Drawing;
namespace VEPROMS.CSLA.Library
{
#region Item
public partial class Item:IVEDrillDown
{
public override string ToString()
{
return string.Format("{0} {1}", MyContent.Number, MyContent.Text);
}
#region IVEDrillDown
public System.Collections.IList GetChildren()
{
return this.MyContent.ContentParts;
}
public bool HasChildren
{
get { return this.MyContent.ContentPartCount > 0; }
}
private IVEDrillDown _ActiveParent=null;
public IVEDrillDown ActiveParent
{
get
{
if (_ActiveParent == null)
{
if (MyPrevious != null)
_ActiveParent = _MyPrevious.ActiveParent;
else
{
if (ItemDocVersionCount > 0)
_ActiveParent = this.ItemDocVersions[0].MyDocVersion;
else
{
if (this.ItemParts == null || this.ItemPartCount == 0)
_ActiveParent = this;
else
_ActiveParent = this.ItemParts[0].MyContent.ContentItems[0].MyItem;
}
}
}
return _ActiveParent==this ? null : _ActiveParent;
}
}
private Format _ActiveFormat=null;// Added to cache ActiveFormat
public Format ActiveFormat
{
get
{
if(_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
return _ActiveFormat;
}
}
public Format LocalFormat
{
get { return MyContent.MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return null; }
}
#endregion
}
#endregion
#region ItemInfo
public partial class ItemInfo:IVEDrillDownReadOnly
{
public bool IsType(string type)
{
int stepType = ((int)MyContent.Type) % 10000;
StepDataList sdlist = ActiveFormat.PlantFormat.FormatData.StepDataList;
StepData sd = sdlist[stepType];
// TODO: RHM20071115 while (sd.Index != 0)
// TODO: RHM20071115 {
// TODO: RHM20071115 if (sd.Type == type) return true;
// TODO: RHM20071115 sd = sdlist[sd.ParentType];
// TODO: RHM20071115 }
return false;
}
public bool IsCaution
{
get
{
return IsType("CAUTION");
}
}
public bool IsNote
{
get
{
return IsType("NOTE");
}
}
public bool IsTable
{
get
{
return IsType("TABLE");
}
}
public bool IsFigure
{
get
{
return IsType("FIGURE");
}
}
public bool IsOr
{
get
{
return IsType("OR");
}
}
public bool IsAnd
{
get
{
return IsType("AND");
}
}
public bool IsEquipmentList
{
get
{
return IsType("EQUIPMENTLIST");
}
}
public bool IsTitle
{
get
{
return IsType("TITLE");
}
}
public bool IsAccPages
{
get
{
return IsType("ACCPAGES");
}
}
public bool IsParagraph
{
get
{
return IsType("PARAGRAPH");
}
}
public bool IsDefault
{
get
{
return IsType("DEFAULT");
}
}
public bool IsContAcSequential
{
get
{
return IsType("CONTACSEQUENTIAL");
}
}
public bool IsHigh
{
get
{
// check to see if ActiveParent is a section, if so it is a high level step
if (MyContent.Type / 10000 != 2) return false;
ItemInfo parent = (ItemInfo)ActiveParent;
if ((parent.MyContent.Type / 10000) == 1)
return true;
return false;
}
}
public bool IsSequential
{
get
{
if (((MyContent.Type / 10000) == 2) && ((((int)MyContent.Type) % 10000) == 0)) return true;
return false;
}
}
public bool IsRNO
{
get
{
return ((ItemPartCount > 0) && (ItemParts[0].PartType == E_FromType.RNO));
}
}
public bool IsInRNO
{
get
{
if (IsHigh) return false;
if (IsRNO) return true;
return ((ItemInfo)ActiveParent).IsInRNO;
}
}
public ItemInfo FirstSibling
{
get
{
ItemInfo temp = this;
while (temp.MyPrevious != null) temp = temp.MyPrevious;
return temp;
}
}
public bool IsSubStep
{
get
{
ItemInfo temp = FirstSibling;
return ((temp.ItemPartCount > 0) && (temp.ItemParts[0].PartType == E_FromType.Step));
}
}
public bool IsInSubStep
{
get
{
if (IsHigh) return false;
if (IsSubStep) return true;
return ((ItemInfo)ActiveParent).IsInSubStep;
}
}
public bool IsInFirstLevelSubStep
{
get
{
ItemInfo temp = FirstSibling;
while (((ItemInfo)temp.ActiveParent).IsHigh == false) temp = ((ItemInfo)temp.ActiveParent).FirstSibling;
return temp.IsSubStep;
}
}
private E_FromType ItemType
{
get
{
if (MyContent.Type == 0) return E_FromType.Procedure;
if (MyContent.Type < 20000) return E_FromType.Section;
return E_FromType.Step;
}
}
public Item GetByType()
{
Item tmp = null;
switch (ItemType)
{
case E_FromType.Procedure:
tmp = Procedure.Get(_ItemID);
break;
//case E_FromType.Section:
// itemInfo = new Section(dr);
// break;
//default:
// itemInfo = new Step(dr);
// break;
}
return tmp;
}
private int? _Ordinal;
public int Ordinal
{
get
{
//int retval = 1;
//for (ItemInfo ii = MyParent; ii != null; ii = ii.MyParent) retval++;
//return retval;
//if (_Ordinal != null) return (int)_Ordinal; // Cache Ordinal
if (MyPrevious != null) return (int)(_Ordinal = MyPrevious.Ordinal + 1);
return (int)(_Ordinal = 1);
}
}
public string CslaType
{ get { return this.GetType().FullName; } }
public override string ToString()
{
//Item editable = Item.GetExistingByPrimaryKey(_ItemID);
//return string.Format("{0}{1} {2}", (editable == null ? "" : (editable.IsDirty ? "* " : "")),
// (MyContent.Type >= 20000 ? Ordinal.ToString() + "." : MyContent.Number), MyContent.Text);
ContentInfo cont = MyContent;
string number = cont.Number;
if (cont.Type >= 20000) number = Ordinal.ToString() + ".";
return string.Format("{0} {1}", number, cont.Text);
//return string.Format("{0} {1}", cont.Number, cont.Text);
//return "Now is the time for all good men to come to the aid of their country!";
}
//public string ToString(string str,System.IFormatProvider ifp)
//{
// return ToString();
//}
public string nz(string str, string def)
{
return (str == null ? def : str);
}
public string Path
{
get
{
string number = (MyContent.Type >= 20000 ? Ordinal.ToString() + "." : (nz(MyContent.Number,"")==""? MyContent.Text: MyContent.Number));
ItemInfo parent = this;
while (parent.MyPrevious != null) parent = parent.MyPrevious;
if (parent.ItemPartCount == 0)
return number + ", " + MyContent.Text;
else
{
PartInfo partInfo = parent.ItemParts[0];
return partInfo.MyContent.ContentItems.Items[0].Path + " " + ((E_FromType)partInfo.FromType).ToString() + " " + number;
}
}
}
public ContentInfo ParentContent
{
get
{
string number = (MyContent.Type >= 20000 ? Ordinal.ToString() + "." : (nz(MyContent.Number, "") == "" ? MyContent.Text : MyContent.Number));
ItemInfo parent = this;
while (parent.MyPrevious != null) parent = parent.MyPrevious;
if (parent.ItemPartCount == 0)
return null;
else
{
return parent.ItemParts[0].MyContent;
}
}
}
public ItemInfo MyParent
{
get
{
//if (ItemDocVersionCount > 0) return ItemDocVersions[0]; Need to create one interface to support Folders, DocVersions and Items
ContentInfo parentContent = ParentContent;
if (parentContent == null || parentContent.ContentItemCount == 0) return null;
return parentContent.ContentItems[0];
}
}
private ItemInfoList Lookup(int fromType, ref ItemInfoList itemInfoList)
{
if (itemInfoList != null) return itemInfoList;
if (MyContent.ContentPartCount != 0)
foreach (PartInfo partInfo in MyContent.ContentParts)
if (partInfo.FromType == fromType)
{
itemInfoList = partInfo._MyItems = ItemInfoList.GetList(partInfo.ItemID,partInfo.FromType);
return itemInfoList;
}
return null;
}
private ItemInfoList _Procedures;
public ItemInfoList Procedures
{ get { return Lookup(1,ref _Procedures); } }
private ItemInfoList _Sections;
public ItemInfoList Sections
{ get { return Lookup(2,ref _Sections); } }
private ItemInfoList _Cautions;
public ItemInfoList Cautions
{ get { return Lookup(3,ref _Cautions); } }
private ItemInfoList _Notes;
public ItemInfoList Notes
{ get { return Lookup(4,ref _Notes); } }
private ItemInfoList _RNOs;
public ItemInfoList RNOs
{ get { return Lookup(5,ref _RNOs); } }
private ItemInfoList _Steps;
public ItemInfoList Steps
{ get { return Lookup(6,ref _Steps); } }
private ItemInfoList _Tables;
public ItemInfoList Tables
{ get { return Lookup(7,ref _Tables); } }
//public XmlDocument ToXml()
//{
// XmlDocument retval = new XmlDocument();
// retval.LoadXml("<root/>");
// return ToXml(retval.DocumentElement);
//}
//public void AddList(XmlNode xn,string name, ItemInfoList itemInfoList)
//{
// if (itemInfoList != null)
// {
// XmlNode nd = xn.OwnerDocument.CreateElement(name);
// xn.AppendChild(nd);
// itemInfoList.ToXml(xn);
// }
//}
//public XmlDocument ToXml(XmlNode xn)
//{
// XmlNode nd = MyContent.ToXml(xn);
// // Now add the children
// AddList(nd, "Procedures", Procedures);
// AddList(nd, "Sections", Sections);
// AddList(nd, "Cautions", Cautions);
// AddList(nd, "Notes", Notes);
// AddList(nd, "RNOs", RNOs);
// AddList(nd, "Steps", SubItems);
// AddList(nd, "Tables", Tables);
// return xn.OwnerDocument;
//}
#region IVEReadOnlyItem
PartInfoList _PartInfoList;
public System.Collections.IList GetChildren()
{
_PartInfoList = this.MyContent.ContentParts;
return _PartInfoList;
}
//public bool ChildrenAreLoaded
//{
// get { return _PartInfoList == null; }
//}
public bool HasChildren
{
get { return this.MyContent.ContentPartCount > 0; }
}
private IVEDrillDownReadOnly _ActiveParent = null;
public IVEDrillDownReadOnly ActiveParent
{
get
{
if (_ActiveParent == null)
{
if (MyPrevious != null)
_ActiveParent = _MyPrevious.ActiveParent;
else
{
if (ItemDocVersionCount > 0)
_ActiveParent = this.ItemDocVersions[0];
else
{
ContentInfo parentContent = ParentContent;
if (parentContent == null || parentContent.ContentItemCount == 0)
_ActiveParent = this;
else
_ActiveParent = parentContent.ContentItems[0];
}
}
}
return _ActiveParent==this ? null : _ActiveParent;
}
//get
//{
// if (MyPrevious != null) return _MyPrevious.ActiveParent;
// if (ItemDocVersionCount > 0) return ItemDocVersions[0];
// ContentInfo parentContent = ParentContent;
// if (parentContent == null || parentContent.ContentItemCount == 0) return null;
// return parentContent.ContentItems[0];
//}
}
private FormatInfo _ActiveFormat = null;
public FormatInfo ActiveFormat
{
get
{
if(_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat);
return _ActiveFormat;
}
//get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
}
public FormatInfo LocalFormat
{
get { return MyContent.MyFormat; }
}
public DynamicTypeDescriptor MyConfig
{
get { return null; }
}
//public bool HasStandardSteps()
//{ return MyContent.ContentItemCount > 1; }
public Color ForeColor
{ get { return (HasBrokenRules != null ? Color.Red : (MyContent.ContentItemCount > 1 ? Color.Blue : Color.Black)); } }
public Color BackColor
{ get { return (ItemAnnotationCount > 0 ? Color.Yellow : Color.White); } }
#endregion
}
#endregion ItemInfo
#region ItemInfoList
public partial class ItemInfoList
{
//public void ToXml(XmlNode xn)
//{
// foreach (ItemInfo itemInfo in this)
// {
// itemInfo.ToXml(xn);
// }
//}
public static ItemInfoList GetList(int? itemID,int type)
{
try
{
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListCriteria(itemID,type));
ItemInfo.AddList(tmp);
tmp.AddEvents();
ContentInfoList.GetList(itemID);
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemInfoList.GetChildren", ex);
}
}
[Serializable()]
private class ItemListCriteria
{
public ItemListCriteria(int? itemID,int type)
{
_ItemID = itemID;
_Type = type;
}
private int? _ItemID;
public int? ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private int _Type;
public int Type
{
get { return _Type; }
set { _Type = value; }
}
}
private void DataPortal_Fetch(ItemListCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_ListItems";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ItemInfo itemInfo = null;
switch ((E_FromType)criteria.Type)
{
case E_FromType.Procedure:
itemInfo = new ProcedureInfo(dr);
break;
case E_FromType.Section:
itemInfo = new SectionInfo(dr);
break;
default:
itemInfo = new StepInfo(dr);
break;
}
this.Add(itemInfo);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ItemInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
#endregion
#region ProcedureInfo
[Serializable()]
public partial class ProcedureInfo : ItemInfo, IVEDrillDownReadOnly
{
public ProcedureInfo(SafeDataReader dr) : base(dr) { }
public new Procedure Get()
{
return (Procedure) (_Editable = Procedure.Get(ItemID));
}
#region ProcedureConfig
[NonSerialized]
private ProcedureConfig _ProcedureConfig;
public ProcedureConfig ProcedureConfig
{ get { return (_ProcedureConfig != null ? _ProcedureConfig : _ProcedureConfig = new ProcedureConfig(this)); } }
#endregion
public new DynamicTypeDescriptor MyConfig
{
get { return ProcedureConfig ; }
}
}
#endregion
#region Procedure
[Serializable()]
public partial class Procedure : Item
{
public new static Procedure Get(int itemID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Procedure tmp = (Procedure)GetExistingByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Procedure>(new PKCriteria(itemID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
public new Procedure Save()
{
return (Procedure)base.Save();
}
#region ProcedureConfig
[NonSerialized]
private ProcedureConfig _ProcedureConfig;
public ProcedureConfig ProcedureConfig
{
get
{
if (_ProcedureConfig == null)
{
_ProcedureConfig = new ProcedureConfig(this);
_ProcedureConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_ProcedureConfig_PropertyChanged);
}
return _ProcedureConfig;
}
}
private void _ProcedureConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
MyContent.Config = _ProcedureConfig.ToString();
}
#endregion
}
#endregion
#region SectionInfo
[Serializable()]
public partial class SectionInfo : ItemInfo, IVEDrillDownReadOnly
{
public SectionInfo(SafeDataReader dr) : base(dr) { }
public new Section Get()
{
return (Section)(_Editable = Section.Get(ItemID));
}
#region SectionConfig
[NonSerialized]
private SectionConfig _SectionConfig;
public SectionConfig SectionConfig
{ get { return (_SectionConfig != null ? _SectionConfig : _SectionConfig = new SectionConfig(this)); } }
#endregion
public new DynamicTypeDescriptor MyConfig
{
get { return SectionConfig; }
}
}
#endregion
#region Section
[Serializable()]
public partial class Section : Item
{
public new static Section Get(int itemID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Section tmp = (Section)GetExistingByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Section>(new PKCriteria(itemID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
public new Section Save()
{
return (Section)base.Save();
}
#region SectionConfig
[NonSerialized]
private SectionConfig _SectionConfig;
public SectionConfig SectionConfig
{
get
{
if (_SectionConfig == null)
{
_SectionConfig = new SectionConfig(this);
_SectionConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_SectionConfig_PropertyChanged);
}
return _SectionConfig;
}
}
private void _SectionConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
MyContent.Config = _SectionConfig.ToString();
}
#endregion
}
#endregion
#region StepInfo
[Serializable()]
public partial class StepInfo : ItemInfo
{
//public override string ToString()
//{
// return "Step " + base.ToString();
//}
public StepInfo(SafeDataReader dr) : base(dr) { }
public new Step Get()
{
return (Step)(_Editable = Step.Get(ItemID));
}
//public E_FromType FromType
//{ get { return E_FromType.Step; } }
}
#endregion
#region Step
[Serializable()]
public partial class Step : Item
{
public new static Step Get(int itemID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
Step tmp = (Step)GetExistingByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Step>(new PKCriteria(itemID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Item.Get", ex);
}
}
//#region StepConfig
//[NonSerialized]
//private StepConfig _StepConfig;
//public StepConfig StepConfig
//{
// get
// {
// if (_StepConfig == null)
// {
// _StepConfig = new StepConfig(this);
// _StepConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_StepConfig_PropertyChanged);
// }
// return _SectionConfig;
// }
//}
//private void _StepConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
//{
// MyContent.Config = _StepConfig.ToString();
//}
//#endregion
}
#endregion
}

View File

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
namespace VEPROMS.CSLA.Library
{
public partial class ContentPart
{
public override string ToString()
{
return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
}
}
public partial class ItemPart
{
public override string ToString()
{
return string.Format("{0} {1}", _MyContent.Number, MyContent.Text);
}
}
public partial class Part
{
public override string ToString()
{
return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
}
}
public partial class PartInfo : IVEDrillDownReadOnly
{
public E_FromType PartType
{ get { return (E_FromType)_FromType; } }
public E_FromTypes PartTypes
{ get { return (E_FromTypes)_FromType; } }
public override string ToString()
{
return string.Format("{0}", PartTypes);
}
//public string ToString(string str, System.IFormatProvider ifp)
//{
// return ToString();
//}
#region IVEDrillDownReadOnly
public ItemInfoList _MyItems;
public ItemInfoList MyItems
{ get { return (_MyItems != null? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID,_FromType)); } }
public System.Collections.IList GetChildren()
{
return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType));
}
//public bool ChildrenAreLoaded
//{
// get { return _MyItems == null; }
//}
public bool HasChildren
{
get { return this.MyContent.ContentPartCount > 0; }
}
public IVEDrillDownReadOnly ActiveParent
{
get
{
ContentInfo parentContent = MyContent;
if (parentContent == null || parentContent.ContentItemCount == 0) return null;
return parentContent.ContentItems[0];
}
}
public FormatInfo ActiveFormat
{
get { return ActiveParent.ActiveFormat; }
}
public FormatInfo LocalFormat
{
get { return null; }
}
public DynamicTypeDescriptor MyConfig
{
get { return null; }
}
//public bool HasStandardSteps()
//{ return false; }
#endregion
}
public enum E_FromType : int
{
Procedure = 1, Section = 2, Caution = 3, Note = 4, RNO = 5, Step = 6, Table = 7
}
public enum E_FromTypes : int
{
Procedures = 1, Sections = 2, Cautions = 3, Notes = 4, RNOs = 5, Steps = 6, Tables = 7
}
}

View File

@ -0,0 +1,95 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections;
namespace VEPROMS.CSLA.Library
{
public partial class ChildFoldersPropertyDescriptor
{
public override string DisplayName
{ get { return Item.Name; } }
public override string Description
{ get { return Item.Title; } }
public override string Name
{ get { return Item.Name; } }
}
public partial class FolderDocVersionsPropertyDescriptor
{
public override string DisplayName
{ get { return Item.Name; } }
public override string Description
{ get { return Item.Name; } }
public override string Name
{ get { return Item.Name; } }
}
public class FormatList : System.ComponentModel.StringConverter
{
private static SortedList<string,FormatInfo> _FormatInfoList;
private static void LoadSortedList()
{
if (_FormatInfoList == null)
{
_FormatInfoList = new SortedList<string, FormatInfo>();
foreach (FormatInfo formatInfo in FormatInfoList.Get())
{
_FormatInfoList.Add(formatInfo.Name, formatInfo);
}
_FormatInfoList.Add("", null);
}
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
LoadSortedList();
return new StandardValuesCollection((ICollection)_FormatInfoList.Values);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
public static int? ToInt(string formatName)
{
if (formatName == null || formatName == string.Empty) return null;
LoadSortedList();
foreach (FormatInfo formatInfo in _FormatInfoList.Values)
if (formatInfo != null && formatInfo.Name == formatName) return formatInfo.FormatID;
return null;
}
public static string ToString(int? formatID)
{
if (formatID == null) return null;
LoadSortedList();
foreach (FormatInfo formatInfo in _FormatInfoList.Values)
if (formatInfo != null && formatInfo.FormatID == formatID) return formatInfo.ToString();
return null;
}
public static Format ToFormat(string formatName)
{
if (formatName == null || formatName == string.Empty) return null;
LoadSortedList();
foreach (FormatInfo formatInfo in _FormatInfoList.Values)
if (formatInfo != null && formatInfo.ToString() == formatName) return formatInfo.Get();
return null;
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public partial class TransitionInfo
{
public string PathTo
{
get
{
//return "To " + MyItemToID.Path;
return MyItemToID.Path;
}
}
public string PathFrom
{
get
{
//return "From " + MyContent.ContentItems[0].Path;
return MyContent.ContentItems[0].Path;
}
}
}
}

View File

@ -0,0 +1,483 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
#region DocStyles
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DocStyles : vlnFormatItem
{
[Description("Document Styles Name")]
private LazyLoad<string> _Name;
public string Name
{
get
{
return LazyLoad(ref _Name, "@Name");
}
}
private DocStyleList _DocStyleList;
public DocStyleList DocStyleList
{
get
{
return (_DocStyleList == null) ? _DocStyleList = new DocStyleList(SelectNodes("DocStyle")): _DocStyleList;
}
set { _DocStyleList = value; }
}
public DocStyles(XmlNode xmlNode) : base(xmlNode) { }
}
#endregion
#region DocStyleAll
#region DocStyle
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DocStyle : vlnFormatItem
{
public DocStyle(XmlNode xmlNode) : base(xmlNode) { }
public DocStyle() : base() { }
#region IndexName
private LazyLoad<int?> _Index;
public int? Index
{
get
{
return LazyLoad(ref _Index, "@Index");
}
}
[Description("Document Styles Name")]
private LazyLoad<string> _Name;
public string Name
{
get
{
return LazyLoad(ref _Name, "@Name");
}
}
#endregion
#region Font
private VE_Font _Font;
[Category("Font")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font
{
get
{
return(_Font == null) ?_Font = new VE_Font(XmlNode): _Font;
}
}
#endregion
#region numberingsequence
[Category("Miscellaneous")]
[Description("Numbering Sequence")]
private LazyLoad<E_NumberingSequence?> _NumberingSequence;
public E_NumberingSequence? NumberingSequence
{
get
{
return LazyLoad<E_NumberingSequence>(ref _NumberingSequence, "@NumberingSequence");
}
}
#endregion
#region Oldtonew
[Category("Miscellaneous")]
[Description("Convert from old to new")]
private LazyLoad<int?> _OldToNew;
public int? OldToNew
{
get
{
return LazyLoad(ref _OldToNew, "@OldToNew");
}
}
#endregion
#region pagestyle
private PageStyle _pagestyle;
[Category("Miscellaneous")]
[DisplayName("Page Style")]
[Description("Page Style")]
public PageStyle pagestyle
{
get
{
string str = "//PageStyles/PageStyle[" + (IntLookup("@PageStyle") + 1).ToString() + "]";
XmlNode xn = SelectSingleNode(str);
if (_pagestyle == null) _pagestyle = new PageStyle(SelectSingleNode("//PageStyles/PageStyle[" + (IntLookup("@PageStyle") + 1).ToString() + "]"));
return _pagestyle;
}
}
#endregion
#region SubElements
private Layout _Layout;
public Layout Layout
{
get
{
return (_Layout == null ? _Layout = new Layout(SelectSingleNode("Layout")) : _Layout);
}
}
private Continue _Continue;
public Continue Continue
{
get
{
return (_Continue == null ? _Continue = new Continue(SelectSingleNode("Continue")) : _Continue);
}
}
private End _End;
public End End
{
get
{
return (_End == null ? _End = new End(SelectSingleNode("End")) : _End);
}
}
private Final _Final;
public Final Final
{
get
{
return (_Final == null ? _Final = new Final(SelectSingleNode("Final")) : _Final);
}
}
private StructureStyle _StructureStyle;
public StructureStyle StructureStyle
{
get
{
return (_StructureStyle == null ? _StructureStyle = new StructureStyle(SelectSingleNode("StructureStyle")) : _StructureStyle);
}
}
#endregion
public override string ToString()
{
return String.Format("{0:D2} - {1}", Index, Name);
}
}
#endregion
#region DocStyleList
[TypeConverter(typeof(vlnListConverter<DocStyleList, DocStyle>))]
public class DocStyleList : vlnFormatList<DocStyle>
{
public DocStyleList(XmlNodeList xmlNodeList) : base(xmlNodeList) { }
}
#endregion
#region Layout
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Layout : vlnFormatItem
{
public Layout(XmlNode xmlNode) : base(xmlNode) { }
public Layout() : base() { }
#region TopRow
private LazyLoad<int?> _TopRow;
[Category("Layout")]
[DisplayName("Top Row on Printed Page")]
[Description("Top Row on Printed Page")]
public int? TopRow
{
get
{
return LazyLoad(ref _TopRow, "@TopRow");
}
}
#endregion
#region FooterLength
private LazyLoad<int?> _FooterLength;
[Category("Location")]
[DisplayName("Number of lines required for footer")]
[Description("Number of lines required for footer")]
public int? FooterLength
{
get
{
return LazyLoad(ref _FooterLength, "@FooterLength");
}
}
#endregion
#region LeftMargin
private LazyLoad<int?> _LeftMargin;
[Category("Location")]
[DisplayName("Size of left margin")]
[Description("Size of left margin")]
public int? LeftMargin
{
get
{
return LazyLoad(ref _LeftMargin, "@LeftMargin");
}
}
#endregion
#region PageLength
private LazyLoad<int?> _PageLength;
[Category("Location")]
[DisplayName("Length of Page")]
[Description("Length of Page")]
public int? PageLength
{
get
{
return LazyLoad(ref _PageLength, "@PageLength");
}
}
#endregion
#region PageWidth
private LazyLoad<int?> _PageWidth;
[Category("Location")]
[DisplayName("Width of Page")]
[Description("Width of Page")]
public int? PageWidth
{
get
{
return LazyLoad(ref _PageWidth, "@PageWidth");
}
}
#endregion
}
#endregion
#region ContinueAll
#region Continue
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Continue : vlnFormatItem
{
public Continue(XmlNode xmlNode) : base(xmlNode) { }
public Continue() : base() { }
#region Font
private VE_Font _Font;
[Category("Continue Msg")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font
{
get
{
return (_Font == null ? _Font = new VE_Font(base.XmlNode) : _Font);
}
}
#endregion
#region SubElements
private Top _Top;
public Top Top
{
get
{
return (_Top == null? _Top = new Top(SelectSingleNode("Top")): _Top);
}
}
private Bottom _Bottom;
public Bottom Bottom
{
get
{
return (_Bottom == null ? _Bottom = new Bottom(SelectSingleNode("Bottom")) : _Bottom);
}
}
#endregion
}
#endregion
#region Top
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Top : vlnFormatItem
{
public Top(XmlNode xmlNode) : base(xmlNode) { }
public Top() : base() { }
#region Margin
private LazyLoad<int?> _Margin;
[Category("Continue Msg")]
[DisplayName("Margin for top msg")]
[Description("Margin for top msg")]
public int? Margin
{
get
{
return LazyLoad(ref _Margin, "@Margin");
}
}
#endregion
#region HLS
private LazyLoad<int?> _HLS;
[Category("Continue Msg")]
[DisplayName("Include HLS in top continue msg")]
[Description("Include HLS in top continue msg")]
public int? HLS
{
get
{
return LazyLoad(ref _HLS, "@HLS");
}
}
#endregion
#region Message
private LazyLoad<string> _Message;
[Category("Continue Msg")]
[DisplayName("Top Continue Msg")]
[Description("Top Continue Msg")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
#endregion
}
#endregion
#region Bottom
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Bottom : vlnFormatItem
{
public Bottom(XmlNode xmlNode) : base(xmlNode) { }
public Bottom() : base() { }
#region Margin
private LazyLoad<int?> _Margin;
[Category("Continue Msg")]
[DisplayName("Margin for bottom msg")]
[Description("Margin for bottom msg")]
public int? Margin
{
get
{
return LazyLoad(ref _Margin, "@Margin");
}
}
#endregion
#region Location
[Category("Continue Msg")]
[Description("Bottom Continue Location")]
private LazyLoad<E_NumberingSequence?> _NumberingSequence;
public E_NumberingSequence? NumberingSequence
{
get
{
return LazyLoad<E_NumberingSequence>(ref _NumberingSequence, "@NumberingSequence");
}
}
private LazyLoad<E_ContBottomLoc?> _Location;
public E_ContBottomLoc? Location
{
get
{
return LazyLoad<E_ContBottomLoc>(ref _Location, "@Location");
}
}
#endregion
#region Message
private LazyLoad<string> _Message;
[Category("Continue Msg")]
[DisplayName("Bottom Continue Msg")]
[Description("Bottom Continue Msg")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
#endregion
}
#endregion
#endregion
#region End
[TypeConverter(typeof(ExpandableObjectConverter))]
public class End : vlnFormatItem
{
public End(XmlNode xmlNode) : base(xmlNode) { }
public End() : base() { }
#region Font
private VE_Font _Font;
[Category("End Msg")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font
{
get
{
return (_Font == null ? _Font = new VE_Font(XmlNode) : _Font);
}
}
#endregion
#region Flag
private LazyLoad<int?> _Flag;
[Category("End Msg")]
[DisplayName("End Msg Exists")]
[Description("End Msg Exists")]
public int? Flag
{
get
{
return LazyLoad(ref _Flag, "@Flag");
}
}
#endregion
#region Message
private LazyLoad<string> _Message;
[Category("End Msg")]
[DisplayName("End Message")]
[Description("End Message")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
#endregion
}
#endregion
#region Final
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Final : vlnFormatItem
{
public Final(XmlNode xmlNode) : base(xmlNode) { }
public Final() : base() { }
private LazyLoad<string> _Message;
[Category("Final Msg")]
[DisplayName("Final Message")]
[Description("Final Message")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
}
#endregion
#region StructureStyle
[TypeConverter(typeof(ExpandableObjectConverter))]
public class StructureStyle : vlnFormatItem
{
public StructureStyle(XmlNode xmlNode) : base(xmlNode) { }
public StructureStyle() : base() { }
#region Where
[Category("Structure Style")]
[Description("Where Used")]
private LazyLoad<E_DocStyleUse?> _Where;
public E_DocStyleUse? Where
{
get
{
return LazyLoad<E_DocStyleUse>(ref _Where, "@Where");
}
}
#endregion
#region Style
[Category("Structure Style")]
[Description("Style")]
private LazyLoad<E_DocStructStyle?> _Style;
public E_DocStructStyle? Style
{
get
{
return LazyLoad<E_DocStructStyle>(ref _Style, "@Style");
}
}
#endregion
}
#endregion
#endregion
}

View File

@ -0,0 +1,199 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
#region ENums
[Flags]
public enum E_PurchaseOptions : uint
{
APPROVEONE = 0x0001,
ACCPAGINATION = 0x0002,
LIBMAINT = 0x0004,
TRANSFER = 0x0008,
STREES = 0x0010,
DATECHGSUMRPT = 0x0020,
SETPOINTUSAGE = 0x0040,
REPLACE = 0x0080,
FLOPPYTRANSFER = 0x0100,
APPROVEGENERICBACK = 0x0200,
DISTRIBUTEAPPROVED = 0x0400,
OUTSIDETRANSITIONS = 0x0800,
ENHANCEDBACKGROUNDS = 0x1000,
ENHANCEDDEVIATIONS = 0x2000,
AUTOTABLEOFCONTENTS = 0x4000,
AUTOPLACEKEEPER = 0x8000
}
[Flags]
public enum E_Style : uint
{
// Fonts removed, not used here.
NONE = 0,
UNDERLINE = 64, BOLD = 128, LANDSCAPE = 256, ITALICS = 512, BOXED = 1024, BOXELEMENT = 0x00000800,
TBCENTERED = 4096, RTCHECKOFF = 8192, LTCHECKOFF = 16384, BIGSCRIPT = 32768, HLTEXTHL = 65536,
RTCHECKOFFWITHASTERISK = 131072, DB_UNDERLINE = 262144, COLDOTS = 524288,
MMBOLD = 1048576, RIGHTJUSTIFY = 2097152, SUBSCRIPT = 4194304, SUPERSCRIPT = 8388608,
PAGELISTITEM = 16777216, PRINTONTOPOFLINE = 33554432, HORZCENTER = 67108864,
CIRCLESTRING2 = 0x08000000, ALIGNWITHUP1 = 0x10000000, ALIGNWSECNUM = 0x20000000,
MATCHCOLUMNMODE = 0x40000000, KEEPRNOSUBSTYLE = 0x80000000
};
public enum E_ChangeBarMessage : uint
{
DATEANDUSERID = 0,
REVNUMBER = 1,
USERID = 2,
NOTHING = 3
}
public enum E_EMode : uint
{
INSERT = 0,
OVERRIDE = 1
}
public enum E_ViewMode : uint
{
VIEW = 0,
EDIT = 1
}
public enum E_EditPrintMode : uint
{
EDIT = 0,
PRINT = 1
}
[Flags]
public enum E_Justify : uint
{
PSCENTER = 0, // Page style, center field
PSLEFT = 1, // Page style, left justify
PSRIGHT = 2, // Page style, right justify
// *** PS modifiers: ***
PSBOTTOM = 4, // Page style, always use bottom half line
PSTOP = 8, // Page style, always use top half line
PSTRUE = 16, // page style, don't adjust per CPI* (not needed after 4.0)
PSNOTFIRST = 32, // page style, don't put this token on the first page of section
PSONLYFIRST = 64, // page style, only put this token on the first page of section
PSRELROW = 128, // place in RelPageList
PSNOHALFLINE = 256, // DontDoHalflines for his paglist row item
PSNOTLAST = 0x200, // 512 - use this token on all but the last page of this section
PSRTFONLY = 0x400, // Only use this token when the driver is rtf
PSRTFNOT = 0x800, // Do NOT use token when driver is rtf
PSGDIONLY = 0X1000, // Only use this token when the driver is GDI
PSGDINOT = 0x2000, // Do NOT use token when driver is GDI
PSADJBNGROW = 0x4000 // If the pagelist item exceeds the row it's printed on,
// then adjust the starting row for the procedure body
};
public enum E_NumberingSequence : uint
{
NOPAGENUM = 0,
INCLUDEWOTHSTEPS = 1,
WITHINSECTIONS = 2,
WITHINACCESSORY = 3
};
public enum E_ContBottomLoc : uint
{
ENDOFTEXT = 0,
BTWNTEXTANDBOTTOM = 1,
BOTTOMOFPAGE = 2
};
[Flags]
public enum E_DocStructStyle : uint
{
//USEONALLPAGES = 0, // Default
//USEONFIRSTPAGE = 1, // Use only on the first page
//USEONALLBUTFIRSTPAGE = 2, // Use on all but the first page
//USEONLASTPAGE = 4, // NO LOGIC exists for this selection. Use only on the last page
NONE = 0,
USESECTIONFOLDOUT = 8, // Attach section foldouts (only active if using SectionLevelFoldouts_ON
DONTCOUNTFOLDOUTPGS = 16, // Used with the USESECTIONFOLDOUT flag. Keeps foldout pages from
// being included in the section total page count.
TABLEOFCONTENTS = 32,
DONTCOUNTINTABOFCONT = 64,
PLACEKEEPER = 128,
ALIGN1STLEVSUBWHLS = 0x00000100, // guess?
DOUBLEBOXHLS = 0x00000200,
USEALTCNTRLINE = 0x00000400,
DONTNUMBERINTOC = 0x00000800, // Don't include page number for this section in the Table of Contents
USESPECIALFIGFRAME = 0x00001000, // for use with stp55 and 55a in bge
HLSUSELETTERS = 0x00002000, // docstyles with this bit set in the DocStructStyle will
// default to using letters for HLSteps
NOSECTIONINSTEPCONTINUE = 0x00004000, // don't include the section number in the step continue
BOTTOMSECTIONCONTINUE = 0x00008000, // print the continue message if the section continues
ALWAYSDOTSTEP = 0x00010000, // put the period after step number in the continue message
XBLANKW1STLEVSUB = 0x00020000, // insert an extra blank line before a 1st level substep
AFFECTEDPAGES = 0x00040000,
DSS_TREATASTRUESECTNUM = 0x00080000, // in conjunction with tietabtolevel, takes section number
// from the last space and appends a period
SAMPLEWATERMARK = 0x00100000, // Will force "SAMPLE" to be printed across the page
// on all pages in this section
DSS_PAGEBREAKHLS = 0x00200000, // Page Breaks on all high level steps
DSS_NOCHKIFCONTTYPEHIGH = 0x00400000, // Will suppress the checkoff if type is HIGH and the
// step is continued on the next page
DSS_WIDTHOVRDSTDHLS = 0x00800000, // Width Override for Standard HLStep in this section
DSS_ADDDOTZEROSTDHLS = 0x01000000, // Append .0 to the Standard HLStep for this section
DSS_SECTIONCOMPRESS = 0x02000000, // Compress all the steps of this section (i.e. use 7 LPI)
DSS_PRINTSECTONFIRST = 0x04000000, // Prints section title/number <SECTIONLEVELTITLE> only on the first
// page of an attachment section, assuming numberingsequence is not 1
DSS_UNNUMLIKEROMAN = 0x08000000, // the substeps underneath unnumbered HLSteps will have same tabs as romans
DSS_DONTCHANGEROMANLEVEL = 0x10000000, // Dont alter the the substep level for roman-numeral-tabbed hlsteps
DSS_SKIPTWOSTEPLEVELS = 0x20000000, // Skip two step levels for this doc style
DSS_SKIPONESTEPLEVEL = 0x40000000, // Skip one step level for this doc style
DSS_SIMPLETOPSECTIONCONTINUE = 0x80000000, // Use the Top continue message as the section continue */
};
public enum E_DocStyleUse : uint
{
USEONALLPAGES = 0, USEONFIRSTPAGE = 1, USEONALLBUTFIRSTPAGE = 2, USEONLASTPAGE = 4
};
[Flags]
// acceptence list for adding Tables, Cautions, Notes, Substeps, Next, Previous and RNO
public enum E_AccStep : uint
{
ADDING_CAUTION = 1,
ADDING_NOTE = 2,
ADDING_RNO = 4,
ADDING_SUB = 8,
ADDING_TABLE = 16,
ADDING_NEXT = 32,
ADDING_PREV = 64
}
[Flags]
public enum E_ReplaceFlags : uint
{
// Generally used: HIGH, RNO, CAUTION, NOTE, TABLE, SUBSTEP, ATTACH
// ANONOP: BKGD, TOC, INSECTITLE, TRAN
// BGEEOP: BKGD, PLACKEEP, TOC, PARTIALS
// CAL1 & WCN & WEP (various): STATTREE, HLSSETPNT
// CAL2 & CPL: SETPOINT
// HLP: CASEINSENS
// CPLSSD: DIFFUNIT, TOC, STATTREE, HLSSETPNT
// CWE: CASEINSENS, DIFFUNIT
// MYA: CASEINSENSALL
HIGH = 0x0001, // Do ReplaceWords in HIGH LEVEL STEPS
RNO = 0x0002, // Do ReplaceWords in RNOS
CAUTION = 0x0004, // Do ReplaceWords in CAUTIONS
NOTE = 0x0008, // Do ReplaceWords in NOTES
TABLE = 0x0010, // Do ReplaceWords in TABLES
SUBSTEP = 0x0020, // Do ReplaceWords in SUBSTEPS
ATTACH = 0x0040, // Do ReplaceWords in ATTACHMENTS
BKGD = 0x0080, // Do ReplaceWords in BACKGROUNDS
DIFFUNIT = 0x0100, // Do ReplaceWords ONLY for different UNIT #
TOC = 0x0200, // Do in auto table-of-contents
STATTREE = 0x0400,
HLSSETPNT = 0x0800, // Do ReplaceWords in HighLevelStep SETPoiNTs
TRAN = 0x1000, // Do ReplaceWords in TRANSITIONS
SETPOINT = 0x2000, // Do ReplaceWords in SETPOINTS
// Case Sensitivity Flags - default is off (Case Sensitive Replace)
CASEINSENS = 0x0000C000, // Do ReplaceWords for all words thatmatch, regardless of case,
// and replace with the ReplaceWith string as is
CASEINSENSFIRST = 0x4000, // Do ReplaceWords for all words thatexactly match the ReplaceWord,
// except the case of the first character may be different
CASEINSENSALL = 0x8000, // Do ReplaceWords for all words that match the ReplaceWord, regardless of case
PARTIALS = 0x10000, // Do replace even on partial matches
PLACKEEP = 0x20000, // Do replace in PlaceKeepers
INSECTITLE = 0x40000
}
#endregion
}

View File

@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml;
namespace VEPROMS.CSLA.Library
{
#region PageStyles
[TypeConverter(typeof(vlnListConverter<PageStyles, PageStyle>))]
public class PageStyles : vlnFormatList<PageStyle>
{
public PageStyles(XmlNodeList xmlNodeList) : base(xmlNodeList) { }
}
#endregion
#region PageStyle
public class PageStyle : vlnFormatItem
{
#region Constructor
public PageStyle(XmlNode xmlNode) : base(xmlNode) { }
public PageStyle() : base() { }
#endregion
#region Business Methods
private LazyLoad<string> _Name;
[DisplayName("Name")]
[Description("Page Style Name")]
public string Name
{
get
{
return LazyLoad(ref _Name, "@Name");
}
}
private LazyLoad<int?> _Index;
[DisplayName("Index")]
[Description("Page Style Index")]
public int? Index
{
get
{
return LazyLoad(ref _Index, "@Index");
}
}
private PageItems _PageItems;
public PageItems PageItems
{
get
{
return (_PageItems == null)? _PageItems = new PageItems(SelectNodes("Item")): _PageItems;
}
}
#endregion
#region Override ToString
public override string ToString()
{
return string.Format("{0:D2} - {1}", Index, Name);
}
#endregion
}
#endregion
#region PageItems
[TypeConverter(typeof(vlnListConverter<PageItems, PageItem>))]
public class PageItems : vlnFormatList<PageItem>
{
public PageItems(XmlNodeList xmlNodeList) : base(xmlNodeList) { }
}
#endregion
#region PageItem
public class PageItem : vlnFormatItem
{
#region Constructor
public PageItem(XmlNode xmlNode) : base(xmlNode) { }
public PageItem() : base() { }
#endregion
#region Business Methods
private VE_Font _Font;
[Category("Font")]
[DisplayName("Font")]
[Description("Font")]
public VE_Font Font
{
get
{
return (_Font == null) ?_Font = new VE_Font(XmlNode): _Font;
}
}
private LazyLoad<string> _Token;
[Category("Content")]
[DisplayName("Content")]
[Description("Item Content")]
public string Token
{
get
{
return LazyLoad(ref _Token, "@Token");
}
}
private LazyLoad<int?> _Row;
[Category("Location")]
[DisplayName("Vertical Position")]
[Description("Vertical Position")]
public int? Row
{
get
{
return LazyLoad(ref _Row, "@Row");
}
}
private LazyLoad<int?> _Col;
[Category("Location")]
[DisplayName("Horizontal Position")]
[Description("Horizontal Position")]
public int? Col
{
get
{
return LazyLoad(ref _Col, "@Col");
}
}
private LazyLoad<E_Justify?> _Justify;
public E_Justify? Justify
{
get
{
return LazyLoad<E_Justify>(ref _Justify, "@Justify");
}
}
#endregion
#region Override ToString
public override string ToString()
{
//return string.Format("({0:D5},{1:D5}) - {2}",Row,Col,Token);
return Token;
}
public override string GetPDDisplayName()
{ return string.Format("({0},{1})",Row,Col); }
#endregion
}
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,428 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
#region vlnFormatDocument
public class vlnFormatDocument:XmlDocument
{
private static XmlElement mydocele;
public vlnFormatDocument(Format myFormat)
{
_MyFormat = myFormat;
LoadXml(MyFormat.Data);
mydocele = this.DocumentElement;
}
private Format _MyFormat;
public Format MyFormat
{
get { return _MyFormat; }
set { _MyFormat = value; }
}
public static XmlNode LookupSingleNode(XmlNode xmlNode, string path)
{
//original:
//if (xmlNode == null) return null;
//XmlNode xn = xmlNode.SelectSingleNode(path);
//if (xn != null) return xn;
//if (xmlNode.Name == "Step") xn = LookupSingleStepNode(xmlNode, path);
//if (xn != null) return xn;
//if (path.StartsWith("Font")) return LookupSingleFontNode(xmlNode, path);
//return InheritLookup(xmlNode, path);
if (path.StartsWith("Font"))
{
XmlNode xn = null;
if (xmlNode != null)
{
xn = xmlNode.SelectSingleNode(path);
if (xn != null) return xn;
}
else
{
xmlNode = LookupSingleNode(mydocele.FirstChild, "/PlantFormat/FormatData");
}
return LookupSingleFontNode(xmlNode, path);
}
else
{
if (xmlNode == null) return null;
XmlNode xn = xmlNode.SelectSingleNode(path);
if (xn != null) return xn;
if (xmlNode.Name == "Step") xn = LookupSingleStepNode(xmlNode, path);
if (xn != null) return xn;
if (path.StartsWith("Font")) return LookupSingleFontNode(xmlNode, path);
return InheritLookup(xmlNode, path, false);
}
}
public static XmlNode LookupSingleFontNode(XmlNode xmlNode, string path)
{
if (xmlNode == null) return null;
XmlNode tmpNode = xmlNode;
XmlNode xn = xmlNode.SelectSingleNode(path);
while (xn == null)//Walk-up the format tree to find a font node
{
if (xmlNode.NodeType == XmlNodeType.Document)
{
return LookupSingleNode(tmpNode, "/PlantFormat/FormatData/" + path);
}
xmlNode = xmlNode.ParentNode;
xn = xmlNode.SelectSingleNode(path);
}
return xn;
}
public static XmlNode LookupSingleStepNode(XmlNode xmlNode, string path)
{
if (xmlNode == null) return null;
XmlNode xn = xmlNode.SelectSingleNode(path);
XmlNode tmpNode = xmlNode;
XmlNode tmpNode2 = xmlNode;
while (xn == null) //Walk-up the format tree to find a step node
{
tmpNode = xmlNode;
xmlNode = xmlNode.ParentNode.SelectSingleNode(string.Format("Step[@Type='{0}']",xmlNode.Attributes["ParentType"].InnerText));
if (xmlNode == null && path.StartsWith("Font")) return LookupSingleFontNode(tmpNode, path);
if (xmlNode == null)
return InheritLookup(tmpNode2, path, true);
xn = xmlNode.SelectSingleNode(path);
}
return xn;
}
public static XmlNodeList LookupNodes(XmlNode xmlNode, string path)
{
if (xmlNode == null) return null;
XmlNodeList xl = xmlNode.SelectNodes(path);
if (xl == null) xl = InheritLookupNodes(xmlNode, path);
if (xl == null) return null;
return xl;
}
public static string Lookup(XmlNode xmlNode, string path)
{
//if (xmlNode == null) return null;
XmlNode xn = LookupSingleNode(xmlNode, path);
//if (xn == null) xn = InheritLookup(xmlNode, path);
if (xn == null) return null;
return xn.InnerText;
}
//public static string StepLookup(XmlNode xmlNode, string path)
//{
// //if (xmlNode == null) return null;
// XmlNode xn = LookupSingleStepNode(xmlNode, path);
// //if (xn == null) xn = InheritLookup(xmlNode, path);
// if (xn == null) return null;
// return xn.InnerText;
//}
public static T EnumLookup<T>(XmlNode xmlNode, string path)
{
string str = Lookup(xmlNode,path);
if (str == null) return default(T);
return (T)Enum.Parse(typeof(T), str);
}
public static int? IntLookup(XmlNode xmlNode, string path)
{
//if (xmlNode == null) return null;
//XmlNode xn = LookupSingleNode(xmlNode, path);
//if (xn == null) xn = InheritLookup(xmlNode, path);
//if (xn == null) return null;
//return int.Parse(xn.InnerText);
string str = Lookup(xmlNode, path);
if (str == null) return null;
return int.Parse(str);
}
public static int SiblingCount(XmlNode xmlNode)
{
int retval = 0;
string nodeName = xmlNode.Name;
for (XmlNode xn = xmlNode; xn != null; xn = xn.PreviousSibling)
{
if (xn.Name == nodeName) retval++;
}
return retval;
}
public static string Path(XmlNode xmlNode)
{
// Walk the path
string parentPath = (xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode));
// Count Siblings with the Same Name
int sibCount = SiblingCount(xmlNode);
return string.Format("{0}/{1}[{2}]", parentPath, xmlNode.Name, sibCount);
}
public static XmlNode InheritLookup(XmlNode xmlNode, string path, bool stepLookup)
{
stepLookup = false; // 8/2 change for inheritance
if (xmlNode == null) return null;// No path to match
string xPath = Path(xmlNode);// Build xPath from xmlNode
vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument
while(fd.MyFormat.MyParent != null)
{
fd = fd.MyFormat.MyParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
if (fd != null)
{
XmlNode xp;
if (path.StartsWith("/")) xp = fd.DocumentElement;
else xp = fd.SelectSingleNode(xPath);// Get the related node
if (xp != null)
{
XmlNode xn = null;
if (stepLookup)
xn = LookupSingleStepNode(xp, path);
else
xn = xp.SelectSingleNode(path);
if(xn != null) return xn;
}
}
}
return null;
}
public static XmlNodeList InheritLookupNodes(XmlNode xmlNode, string path)
{
if (xmlNode == null) return null;// No path to match
string xPath = Path(xmlNode);// Build xPath from xmlNode
vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument
while (fd.MyFormat.MyParent != null)
{
fd = fd.MyFormat.MyParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument
if (fd != null)
{
XmlNode xp = fd.SelectSingleNode(xPath);// Get the related node
if (xp != null)
{
XmlNodeList xl = xp.SelectNodes(path);
if (xl != null) return xl;
}
}
}
return null;
}
}
#endregion
#region vlnFormatItem
[TypeConverter(typeof(ExpandableObjectConverter))]
public class vlnFormatItem
{
public vlnFormatItem(XmlNode xmlNode)
{
_XmlNode = xmlNode;
}
public vlnFormatItem() { }
XmlNode _XmlNode;
internal XmlNode XmlNode
{
get { return _XmlNode; }
set { _XmlNode = value; }
}
public virtual string GetPDDisplayName()
{ return ToString(); }
public virtual string GetPDName()
{ return ToString(); }
public virtual string GetPDDescription()
{ return ToString(); }
public virtual string GetPDCategory()
{ return ToString(); }
public XmlNodeList SelectNodes(string path)
{
return vlnFormatDocument.LookupNodes(_XmlNode, path);
}
public XmlNode SelectSingleNode(string path)
{
return vlnFormatDocument.LookupSingleNode(_XmlNode, path);
}
public XmlNode SelectSingleFontNode(string path)
{
return vlnFormatDocument.LookupSingleFontNode(_XmlNode, path);
}
public string Lookup(string path)
{
return vlnFormatDocument.Lookup(_XmlNode, path);
}
public string Lookup(string path, ref string local)
{
return (local != null? local : local = Lookup(path));
}
//public string StepLookup(string path)
//{
// return vlnFormatDocument.StepLookup(_XmlNode, path);
//}
public int? IntLookup(string path)
{
return vlnFormatDocument.IntLookup(_XmlNode, path);
}
public int? IntLookup(string path, ref int? local)
{
return (local != null ? local : local = IntLookup(path));
}
public T EnumLookup<T>(string path)
{
return vlnFormatDocument.EnumLookup<T>(_XmlNode, path);
}
public string LazyLoad(ref LazyLoad<string> ll, string xPath)
{
if (ll == null)
{
XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<string>(xn != null ? xn.InnerText : null);
}
return ll.Value;
}
public int? LazyLoad(ref LazyLoad<int?> ll, string xPath)
{
if (ll == null)
{
XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<int?>(xn != null ? (int?)int.Parse(xn.InnerText) : null);
}
return ll.Value;
}
public Nullable<T> LazyLoad<T>(ref LazyLoad<Nullable<T>> ll, string xPath)
where T:struct
{
if (ll == null)
{
XmlNode xn = SelectSingleNode(xPath);
ll = new LazyLoad<Nullable<T>>(xn != null ? (Nullable<T>)Enum.Parse(typeof(T), xn.InnerText) : null);
}
return ll.Value;
}
}
#endregion
#region LazyLoad
public class LazyLoad<T>
{
public LazyLoad(T value)
{
_Value = value;
}
private T _Value;
public T Value
{
get { return _Value; }
set { _Value = value; }
}
}
#endregion
#region vlnFormatList, new()
public class vlnFormatList<T> : List<T>, ICustomTypeDescriptor
where T : vlnFormatItem, new()
{
private XmlNodeList _XmlNodeList;
internal XmlNodeList XmlNodeList
{
get { return _XmlNodeList; }
set { _XmlNodeList = value; }
}
public vlnFormatList(XmlNodeList xmlNodeList)
{
_XmlNodeList = xmlNodeList;
foreach (XmlNode xn in _XmlNodeList)
{
T tt = new T();
tt.XmlNode = xn;
Add(tt);
}
}
#region ICustomTypeDescriptor
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; }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); }
public virtual PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list
int i = 0;
for (i = 0; i < this.Count; i++)
{
// Create a property descriptor for the item and add to the property descriptor collection
pds.Add(new vlnPropertyDescriptor<vlnFormatList<T>, T>(this, i));
}
// return the property descriptor collection
return pds;
}
#endregion
}
#endregion
#region vlnListConverter
internal class vlnListConverter<T, C> : ExpandableObjectConverter
where T : vlnFormatList<C>
where C : vlnFormatItem, new()
{
private string Plural(string name)
{
if (name.EndsWith("y")) return name.Substring(0, name.Length - 1) + "ies";
if (name.EndsWith("ss")) return name + "es";
else return name + "s";
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is T)
{
// Return department and department role separated by comma.
return ((T)value).Count.ToString() + " " + (((T)value).Count == 1 ? typeof(C).Name : Plural(typeof(C).Name));
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
#region vlnPropertyDescriptor
public class vlnPropertyDescriptor<T, C> : PropertyDescriptor
where T : vlnFormatList<C>
where C : vlnFormatItem, new()
{
protected C _Item = null;
public vlnPropertyDescriptor(T itemList, int index)
: base("#" + index.ToString(), null)
{
_Item = itemList[index];
}
public override bool CanResetValue(object component)
{ return true; }
public override Type ComponentType
{ get { return _Item.GetType(); } }
public override object GetValue(object component)
{ return _Item; }
public override bool IsReadOnly
{ get { return true; } }
public override Type PropertyType
{ get { return _Item.GetType(); } }
public override void ResetValue(object component)
{ ;}
public override bool ShouldSerializeValue(object component)
{ return true; }
public override void SetValue(object component, object value)
{ /*_Item = value*/;}
//public override AttributeCollection Attributes
//{ get { return new AttributeCollection(null); } }
public override string DisplayName
{ get { return _Item.GetPDDisplayName(); } }
public override string Description
{ get { return _Item.GetPDDescription(); } }
public override string Name
{ get { return _Item.GetPDName(); } }
public override string Category
{ get { return _Item.GetPDCategory(); } }
} // Class
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,407 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void AnnotationInfoEvent(object sender);
/// <summary>
/// AnnotationInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationInfoConverter))]
public partial class AnnotationInfo : ReadOnlyBase<AnnotationInfo>, IDisposable
{
public event AnnotationInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<AnnotationInfo> _AllList = new List<AnnotationInfo>();
private static Dictionary<string, AnnotationInfo> _AllByPrimaryKey = new Dictionary<string, AnnotationInfo>();
private static void ConvertListToDictionary()
{
List<AnnotationInfo> remove = new List<AnnotationInfo>();
foreach (AnnotationInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.AnnotationID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (AnnotationInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(AnnotationInfoList lst)
{
foreach (AnnotationInfo item in lst) _AllList.Add(item);
}
public static AnnotationInfo GetExistingByPrimaryKey(int annotationID)
{
ConvertListToDictionary();
string key = annotationID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Annotation _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationID",true);
return _AnnotationID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private ItemInfo _MyItem;
public ItemInfo MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem",true);
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID",true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID;
}
}
private AnnotationTypeInfo _MyAnnotationType;
public AnnotationTypeInfo MyAnnotationType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotationType",true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID);
return _MyAnnotationType;
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText",true);
return _RtfText;
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText",true);
return _SearchText;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
}
// TODO: Replace base AnnotationInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AnnotationInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current AnnotationInfo</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
#endregion
#region Factory Methods
private AnnotationInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(AnnotationID.ToString());
}
public virtual Annotation Get()
{
return _Editable = Annotation.Get(_AnnotationID);
}
public static void Refresh(Annotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Annotation tmp)
{
_ItemID = tmp.ItemID;
_TypeID = tmp.TypeID;
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
_MyItem = null;
_MyAnnotationType = null;
OnChange();// raise an event
}
public static void Refresh(AnnotationTypeAnnotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(AnnotationTypeAnnotation tmp)
{
_ItemID = tmp.ItemID;
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
_MyItem = null;
_MyAnnotationType = null;
OnChange();// raise an event
}
public static void Refresh(ItemAnnotation tmp)
{
AnnotationInfo tmpInfo = GetExistingByPrimaryKey(tmp.AnnotationID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ItemAnnotation tmp)
{
_TypeID = tmp.TypeID;
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
_MyItem = null;
_MyAnnotationType = null;
OnChange();// raise an event
}
public static AnnotationInfo Get(int annotationID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Annotation");
try
{
AnnotationInfo tmp = GetExistingByPrimaryKey(annotationID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.Constructor", ex);
throw new DbCslaException("AnnotationInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _AnnotationID;
public int AnnotationID
{ get { return _AnnotationID; } }
public PKCriteria(int annotationID)
{
_AnnotationID = annotationID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_ItemID = dr.GetInt32("ItemID");
_TypeID = dr.GetInt32("TypeID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotation";
cm.Parameters.AddWithValue("@AnnotationID", criteria.AnnotationID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension();
[Serializable()]
partial class AnnotationInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationInfo)
{
// Return the ToString value
return ((AnnotationInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,569 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// AnnotationTypeAnnotation Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationTypeAnnotationConverter))]
public partial class AnnotationTypeAnnotation : BusinessBase<AnnotationTypeAnnotation>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationID",true);
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID;
}
}
private Annotation _MyAnnotation;
[System.ComponentModel.DataObjectField(true, true)]
public Annotation MyAnnotation
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotation",true);
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem",true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItem",true);
if (_MyItem != value)
{
_MyItem = value;
PropertyHasChanged();
}
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText",true);
return _RtfText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("RtfText",true);
if (value == null) value = string.Empty;
if (_RtfText != value)
{
_RtfText = value;
PropertyHasChanged();
}
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText",true);
return _SearchText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("SearchText",true);
if (value == null) value = string.Empty;
if (_SearchText != value)
{
_SearchText = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int? _Item_PreviousID;
public int? Item_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_PreviousID",true);
return _Item_PreviousID;
}
}
private int _Item_ContentID;
public int Item_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ContentID",true);
return _Item_ContentID;
}
}
private DateTime _Item_DTS = new DateTime();
public DateTime Item_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_DTS",true);
return _Item_DTS;
}
}
private string _Item_UserID = string.Empty;
public string Item_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_UserID",true);
return _Item_UserID;
}
}
// TODO: Check AnnotationTypeAnnotation.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current AnnotationTypeAnnotation</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
// TODO: Replace base AnnotationTypeAnnotation.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationTypeAnnotation</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<AnnotationTypeAnnotation>(MyItemRequired, "MyItem");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("RtfText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("SearchText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyItemRequired(AnnotationTypeAnnotation target, Csla.Validation.RuleArgs e)
{
if (target._ItemID == 0 && target._MyItem == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static AnnotationTypeAnnotation New(Item myItem)
{
return new AnnotationTypeAnnotation(myItem);
}
internal static AnnotationTypeAnnotation Get(SafeDataReader dr)
{
return new AnnotationTypeAnnotation(dr);
}
public AnnotationTypeAnnotation()
{
MarkAsChild();
_AnnotationID = Annotation.NextAnnotationID;
_DTS = _AnnotationTypeAnnotationExtension.DefaultDTS;
_UserID = _AnnotationTypeAnnotationExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private AnnotationTypeAnnotation(Item myItem)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _AnnotationTypeAnnotationExtension.DefaultDTS;
_UserID = _AnnotationTypeAnnotationExtension.DefaultUserID;
_MyItem = myItem;
ValidationRules.CheckRules();
}
internal AnnotationTypeAnnotation(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeAnnotation.FetchDR", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_ItemID = dr.GetInt32("ItemID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_PreviousID = (int?)dr.GetValue("Item_PreviousID");
_Item_ContentID = dr.GetInt32("Item_ContentID");
_Item_DTS = dr.GetDateTime("Item_DTS");
_Item_UserID = dr.GetString("Item_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeAnnotation.FetchDR", ex);
throw new DbCslaException("AnnotationTypeAnnotation.Fetch", ex);
}
MarkOld();
}
internal void Insert(AnnotationType myAnnotationType)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Add(cn, ref _AnnotationID, _MyItem, myAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(AnnotationType myAnnotationType)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Update(cn, ref _AnnotationID, _MyItem, myAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(AnnotationType myAnnotationType)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Annotation.Remove(cn, _AnnotationID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
AnnotationTypeAnnotationExtension _AnnotationTypeAnnotationExtension = new AnnotationTypeAnnotationExtension();
[Serializable()]
partial class AnnotationTypeAnnotationExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class AnnotationTypeAnnotationConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationTypeAnnotation)
{
// Return the ToString value
return ((AnnotationTypeAnnotation)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create AnnotationTypeAnnotationExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class AnnotationTypeAnnotation
// {
// partial class AnnotationTypeAnnotationExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

@ -0,0 +1,334 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void AnnotationTypeInfoEvent(object sender);
/// <summary>
/// AnnotationTypeInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationTypeInfoConverter))]
public partial class AnnotationTypeInfo : ReadOnlyBase<AnnotationTypeInfo>, IDisposable
{
public event AnnotationTypeInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<AnnotationTypeInfo> _AllList = new List<AnnotationTypeInfo>();
private static Dictionary<string, AnnotationTypeInfo> _AllByPrimaryKey = new Dictionary<string, AnnotationTypeInfo>();
private static void ConvertListToDictionary()
{
List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>();
foreach (AnnotationTypeInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.TypeID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (AnnotationTypeInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(AnnotationTypeInfoList lst)
{
foreach (AnnotationTypeInfo item in lst) _AllList.Add(item);
}
public static AnnotationTypeInfo GetExistingByPrimaryKey(int typeID)
{
ConvertListToDictionary();
string key = typeID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected AnnotationType _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _TypeID;
[System.ComponentModel.DataObjectField(true, true)]
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID",true);
return _TypeID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
}
private int _AnnotationTypeAnnotationCount = 0;
/// <summary>
/// Count of AnnotationTypeAnnotations for this AnnotationType
/// </summary>
public int AnnotationTypeAnnotationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationTypeAnnotationCount",true);
return _AnnotationTypeAnnotationCount;
}
}
private AnnotationInfoList _AnnotationTypeAnnotations = null;
[TypeConverter(typeof(AnnotationInfoListConverter))]
public AnnotationInfoList AnnotationTypeAnnotations
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationTypeAnnotations",true);
if (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null)
_AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID);
return _AnnotationTypeAnnotations;
}
}
// TODO: Replace base AnnotationTypeInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationTypeInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AnnotationTypeInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current AnnotationTypeInfo</returns>
protected override object GetIdValue()
{
return _TypeID;
}
#endregion
#region Factory Methods
private AnnotationTypeInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(TypeID.ToString());
}
public virtual AnnotationType Get()
{
return _Editable = AnnotationType.Get(_TypeID);
}
public static void Refresh(AnnotationType tmp)
{
AnnotationTypeInfo tmpInfo = GetExistingByPrimaryKey(tmp.TypeID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(AnnotationType tmp)
{
_Name = tmp.Name;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationTypeInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static AnnotationTypeInfo Get(int typeID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
try
{
AnnotationTypeInfo tmp = GetExistingByPrimaryKey(typeID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationTypeInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfo.Constructor", ex);
throw new DbCslaException("AnnotationTypeInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _TypeID;
public int TypeID
{ get { return _TypeID; } }
public PKCriteria(int typeID)
{
_TypeID = typeID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode());
try
{
_TypeID = dr.GetInt32("TypeID");
_Name = dr.GetString("Name");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_AnnotationTypeAnnotationCount = dr.GetInt32("AnnotationCount");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] AnnotationTypeInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationType";
cm.Parameters.AddWithValue("@TypeID", criteria.TypeID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("AnnotationTypeInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension();
[Serializable()]
partial class AnnotationTypeInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationTypeInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationTypeInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationTypeInfo)
{
// Return the ToString value
return ((AnnotationTypeInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,613 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ConnectionFolder Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ConnectionFolderConverter))]
public partial class ConnectionFolder : BusinessBase<ConnectionFolder>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _FolderID;
[System.ComponentModel.DataObjectField(true, true)]
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
[System.ComponentModel.DataObjectField(true, true)]
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
}
private int _ParentID;
public int ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ParentID",true);
if (_MyParent != null) _ParentID = _MyParent.FolderID;
return _ParentID;
}
}
private Folder _MyParent;
public Folder MyParent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyParent",true);
if (_MyParent == null && _ParentID != _FolderID) _MyParent = Folder.Get(_ParentID);
return _MyParent;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyParent",true);
if (_MyParent != value)
{
_MyParent = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Name",true);
if (value == null) value = string.Empty;
if (_Name != value)
{
_Name = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Title",true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private string _ShortName = string.Empty;
public string ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ShortName",true);
return _ShortName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ShortName",true);
if (value == null) value = string.Empty;
if (_ShortName != value)
{
_ShortName = value;
PropertyHasChanged();
}
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
}
private Format _MyFormat;
public Format MyFormat
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFormat",true);
if (_MyFormat != value)
{
_MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID);
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID",true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check ConnectionFolder.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ConnectionFolder</returns>
protected override object GetIdValue()
{
return _FolderID;
}
// TODO: Replace base ConnectionFolder.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ConnectionFolder</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.IsValid); }
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<ConnectionFolder>(MyFolderRequired, "MyFolder");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "ShortName");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ShortName", 20));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private static bool MyFolderRequired(ConnectionFolder target, Csla.Validation.RuleArgs e)
{
if (target._ParentID == 0 && target._MyFolder == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ShortName, "<Role(s)>");
//AuthorizationRules.AllowWrite(ShortName, "<Role(s)>");
//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FormatID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ConnectionFolder New(Folder myParent, string name, string shortName)
{
return new ConnectionFolder(myParent, name, shortName);
}
internal static ConnectionFolder Get(SafeDataReader dr)
{
return new ConnectionFolder(dr);
}
public ConnectionFolder()
{
MarkAsChild();
_FolderID = Folder.NextFolderID;
_ParentID = _ConnectionFolderExtension.DefaultParentID;
_DTS = _ConnectionFolderExtension.DefaultDTS;
_UsrID = _ConnectionFolderExtension.DefaultUsrID;
ValidationRules.CheckRules();
}
private ConnectionFolder(Folder myParent, string name, string shortName)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_ParentID = _ConnectionFolderExtension.DefaultParentID;
_DTS = _ConnectionFolderExtension.DefaultDTS;
_UsrID = _ConnectionFolderExtension.DefaultUsrID;
_MyParent = myParent;
_Name = name;
_ShortName = shortName;
ValidationRules.CheckRules();
}
internal ConnectionFolder(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionFolder.FetchDR", GetHashCode());
try
{
_FolderID = dr.GetInt32("FolderID");
_ParentID = dr.GetInt32("ParentID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ShortName = dr.GetString("ShortName");
_FormatID = (int?)dr.GetValue("FormatID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionFolder.FetchDR", ex);
throw new DbCslaException("ConnectionFolder.Fetch", ex);
}
MarkOld();
}
internal void Insert(Connection myConnection)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Folder.Add(cn, ref _FolderID, Folder.Get(_ParentID), myConnection, _Name, _Title, _ShortName, _MyFormat, _Config, _DTS, _UsrID);
MarkOld();
}
internal void Update(Connection myConnection)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Folder.Update(cn, ref _FolderID, Folder.Get(_ParentID), myConnection, _Name, _Title, _ShortName, _MyFormat, _Config, _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Connection myConnection)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Folder.Remove(cn, _FolderID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ConnectionFolderExtension _ConnectionFolderExtension = new ConnectionFolderExtension();
[Serializable()]
partial class ConnectionFolderExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultParentID
{
get { return 1; }
}
public virtual int DefaultDBID
{
get { return 1; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ConnectionFolderConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ConnectionFolder)
{
// Return the ToString value
return ((ConnectionFolder)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ConnectionFolderExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ConnectionFolder
// {
// partial class ConnectionFolderExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultParentID
// {
// get { return 1; }
// }
// public virtual int DefaultDBID
// {
// get { return 1; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

@ -0,0 +1,373 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ConnectionInfoEvent(object sender);
/// <summary>
/// ConnectionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ConnectionInfoConverter))]
public partial class ConnectionInfo : ReadOnlyBase<ConnectionInfo>, IDisposable
{
public event ConnectionInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<ConnectionInfo> _AllList = new List<ConnectionInfo>();
private static Dictionary<string, ConnectionInfo> _AllByPrimaryKey = new Dictionary<string, ConnectionInfo>();
private static void ConvertListToDictionary()
{
List<ConnectionInfo> remove = new List<ConnectionInfo>();
foreach (ConnectionInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.DBID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (ConnectionInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(ConnectionInfoList lst)
{
foreach (ConnectionInfo item in lst) _AllList.Add(item);
}
public static ConnectionInfo GetExistingByPrimaryKey(int dbid)
{
ConvertListToDictionary();
string key = dbid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Connection _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DBID;
[System.ComponentModel.DataObjectField(true, true)]
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DBID",true);
return _DBID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
}
private string _ConnectionString = string.Empty;
public string ConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionString",true);
return _ConnectionString;
}
}
private int _ServerType;
/// <summary>
/// 0 SQL Server
/// </summary>
public int ServerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ServerType",true);
return _ServerType;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
}
private int _ConnectionFolderCount = 0;
/// <summary>
/// Count of ConnectionFolders for this Connection
/// </summary>
public int ConnectionFolderCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionFolderCount",true);
return _ConnectionFolderCount;
}
}
private FolderInfoList _ConnectionFolders = null;
[TypeConverter(typeof(FolderInfoListConverter))]
public FolderInfoList ConnectionFolders
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionFolders",true);
if (_ConnectionFolderCount > 0 && _ConnectionFolders == null)
_ConnectionFolders = FolderInfoList.GetByDBID(_DBID);
return _ConnectionFolders;
}
}
// TODO: Replace base ConnectionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ConnectionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ConnectionInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ConnectionInfo</returns>
protected override object GetIdValue()
{
return _DBID;
}
#endregion
#region Factory Methods
private ConnectionInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(DBID.ToString());
}
public virtual Connection Get()
{
return _Editable = Connection.Get(_DBID);
}
public static void Refresh(Connection tmp)
{
ConnectionInfo tmpInfo = GetExistingByPrimaryKey(tmp.DBID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Connection tmp)
{
_Name = tmp.Name;
_Title = tmp.Title;
_ConnectionString = tmp.ConnectionString;
_ServerType = tmp.ServerType;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_ConnectionInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static ConnectionInfo Get(int dbid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Connection");
try
{
ConnectionInfo tmp = GetExistingByPrimaryKey(dbid);
if (tmp == null)
{
tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ConnectionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ConnectionInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfo.Constructor", ex);
throw new DbCslaException("ConnectionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DBID;
public int DBID
{ get { return _DBID; } }
public PKCriteria(int dbid)
{
_DBID = dbid;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode());
try
{
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ConnectionString = dr.GetString("ConnectionString");
_ServerType = dr.GetInt32("ServerType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_ConnectionFolderCount = dr.GetInt32("FolderCount");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ConnectionInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getConnection";
cm.Parameters.AddWithValue("@DBID", criteria.DBID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ConnectionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension();
[Serializable()]
partial class ConnectionInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ConnectionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ConnectionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ConnectionInfo)
{
// Return the ToString value
return ((ConnectionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,470 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentDetail Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentDetailConverter))]
public partial class ContentDetail : BusinessBase<ContentDetail>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _DetailID;
[System.ComponentModel.DataObjectField(true, true)]
public int DetailID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DetailID",true);
if (_MyDetail != null) _DetailID = _MyDetail.DetailID;
return _DetailID;
}
}
private Detail _MyDetail;
[System.ComponentModel.DataObjectField(true, true)]
public Detail MyDetail
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDetail",true);
if (_MyDetail == null && _DetailID != 0) _MyDetail = Detail.Get(_DetailID);
return _MyDetail;
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemType",true);
return _ItemType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ItemType",true);
if (_ItemType != value)
{
_ItemType = value;
PropertyHasChanged();
}
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text",true);
return _Text;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Text",true);
if (value == null) value = string.Empty;
if (_Text != value)
{
_Text = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check ContentDetail.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ContentDetail</returns>
protected override object GetIdValue()
{
return _DetailID;
}
// TODO: Replace base ContentDetail.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentDetail</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Text");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(DetailID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemType, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemType, "<Role(s)>");
//AuthorizationRules.AllowRead(Text, "<Role(s)>");
//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentDetail New(int itemType, string text)
{
return new ContentDetail(itemType, text);
}
internal static ContentDetail Get(SafeDataReader dr)
{
return new ContentDetail(dr);
}
public ContentDetail()
{
MarkAsChild();
_DetailID = Detail.NextDetailID;
_DTS = _ContentDetailExtension.DefaultDTS;
_UserID = _ContentDetailExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentDetail(int itemType, string text)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentDetailExtension.DefaultDTS;
_UserID = _ContentDetailExtension.DefaultUserID;
_ItemType = itemType;
_Text = text;
ValidationRules.CheckRules();
}
internal ContentDetail(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode());
try
{
_DetailID = dr.GetInt32("DetailID");
_ItemType = dr.GetInt32("ItemType");
_Text = dr.GetString("Text");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentDetail.FetchDR", ex);
throw new DbCslaException("ContentDetail.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Detail.Add(cn, ref _DetailID, myContent, _ItemType, _Text, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Detail.Update(cn, ref _DetailID, myContent, _ItemType, _Text, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Detail.Remove(cn, _DetailID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentDetailExtension _ContentDetailExtension = new ContentDetailExtension();
[Serializable()]
partial class ContentDetailExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ContentDetailConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentDetail)
{
// Return the ToString value
return ((ContentDetail)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ContentDetailExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentDetail
// {
// partial class ContentDetailExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,418 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentItem Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentItemConverter))]
public partial class ContentItem : BusinessBase<ContentItem>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _ItemID;
[System.ComponentModel.DataObjectField(true, true)]
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
[System.ComponentModel.DataObjectField(true, true)]
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem",true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
}
private int? _PreviousID;
public int? PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PreviousID",true);
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID;
}
}
private Item _MyPrevious;
public Item MyPrevious
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyPrevious",true);
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID);
return _MyPrevious;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyPrevious",true);
if (_MyPrevious != value)
{
_MyPrevious = value;
_PreviousID = (value == null ? null : (int?) value.ItemID);
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check ContentItem.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ContentItem</returns>
protected override object GetIdValue()
{
return _ItemID;
}
// TODO: Replace base ContentItem.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentItem</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(PreviousID, "<Role(s)>");
//AuthorizationRules.AllowWrite(PreviousID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentItem New()
{
return new ContentItem();
}
internal static ContentItem Get(SafeDataReader dr)
{
return new ContentItem(dr);
}
public ContentItem()
{
MarkAsChild();
_ItemID = Item.NextItemID;
_DTS = _ContentItemExtension.DefaultDTS;
_UserID = _ContentItemExtension.DefaultUserID;
ValidationRules.CheckRules();
}
internal ContentItem(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode());
try
{
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentItem.FetchDR", ex);
throw new DbCslaException("ContentItem.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Item.Add(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Item.Update(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Item.Remove(cn, _ItemID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentItemExtension _ContentItemExtension = new ContentItemExtension();
[Serializable()]
partial class ContentItemExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ContentItemConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentItem)
{
// Return the ToString value
return ((ContentItem)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ContentItemExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentItem
// {
// partial class ContentItemExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

@ -0,0 +1,476 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentPart Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentPartConverter))]
public partial class ContentPart : BusinessBase<ContentPart>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _FromType;
[System.ComponentModel.DataObjectField(true, true)]
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FromType",true);
return _FromType;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem",true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItem",true);
if (_MyItem != value)
{
_MyItem = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int? _Item_PreviousID;
public int? Item_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_PreviousID",true);
return _Item_PreviousID;
}
}
private int _Item_ContentID;
public int Item_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ContentID",true);
return _Item_ContentID;
}
}
private DateTime _Item_DTS = new DateTime();
public DateTime Item_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_DTS",true);
return _Item_DTS;
}
}
private string _Item_UserID = string.Empty;
public string Item_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_UserID",true);
return _Item_UserID;
}
}
// TODO: Check ContentPart.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ContentPart</returns>
protected override object GetIdValue()
{
return _FromType;
}
// TODO: Replace base ContentPart.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentPart</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValid); }
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<ContentPart>(MyItemRequired, "MyItem");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyItemRequired(ContentPart target, Csla.Validation.RuleArgs e)
{
if (target._ItemID == 0 && target._MyItem == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(FromType, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentPart New(int fromType, Item myItem)
{
return new ContentPart(fromType, myItem);
}
internal static ContentPart Get(SafeDataReader dr)
{
return new ContentPart(dr);
}
public ContentPart()
{
MarkAsChild();
_DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentPart(int fromType, Item myItem)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID;
_FromType = fromType;
_MyItem = myItem;
ValidationRules.CheckRules();
}
internal ContentPart(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode());
try
{
_FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_PreviousID = (int?)dr.GetValue("Item_PreviousID");
_Item_ContentID = dr.GetInt32("Item_ContentID");
_Item_DTS = dr.GetDateTime("Item_DTS");
_Item_UserID = dr.GetString("Item_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentPart.FetchDR", ex);
throw new DbCslaException("ContentPart.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Add(cn, myContent, _FromType, _MyItem, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Update(cn, myContent, _FromType, _MyItem, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Part.Remove(cn, myContent.ContentID, _FromType);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentPartExtension _ContentPartExtension = new ContentPartExtension();
[Serializable()]
partial class ContentPartExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ContentPartConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentPart)
{
// Return the ToString value
return ((ContentPart)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ContentPartExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentPart
// {
// partial class ContentPartExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

@ -0,0 +1,454 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentRoUsage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentRoUsageConverter))]
public partial class ContentRoUsage : BusinessBase<ContentRoUsage>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _ROUsageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROUsageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROUsageID",true);
if (_MyRoUsage != null) _ROUsageID = _MyRoUsage.ROUsageID;
return _ROUsageID;
}
}
private RoUsage _MyRoUsage;
[System.ComponentModel.DataObjectField(true, true)]
public RoUsage MyRoUsage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRoUsage",true);
if (_MyRoUsage == null && _ROUsageID != 0) _MyRoUsage = RoUsage.Get(_ROUsageID);
return _MyRoUsage;
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROID",true);
return _ROID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROID",true);
if (value == null) value = string.Empty;
if (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check ContentRoUsage.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ContentRoUsage</returns>
protected override object GetIdValue()
{
return _ROUsageID;
}
// TODO: Replace base ContentRoUsage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentRoUsage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "ROID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ROID", 16));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROUsageID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentRoUsage New(string roid)
{
return new ContentRoUsage(roid);
}
internal static ContentRoUsage Get(SafeDataReader dr)
{
return new ContentRoUsage(dr);
}
public ContentRoUsage()
{
MarkAsChild();
_ROUsageID = RoUsage.NextROUsageID;
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentRoUsage(string roid)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
_ROID = roid;
ValidationRules.CheckRules();
}
internal ContentRoUsage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentRoUsage.FetchDR", GetHashCode());
try
{
_ROUsageID = dr.GetInt32("ROUsageID");
_ROID = dr.GetString("ROID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentRoUsage.FetchDR", ex);
throw new DbCslaException("ContentRoUsage.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Add(cn, ref _ROUsageID, myContent, _ROID, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Update(cn, ref _ROUsageID, myContent, _ROID, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
RoUsage.Remove(cn, _ROUsageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentRoUsageExtension _ContentRoUsageExtension = new ContentRoUsageExtension();
[Serializable()]
partial class ContentRoUsageExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultContentID
{
get { return 0; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ContentRoUsageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentRoUsage)
{
// Return the ToString value
return ((ContentRoUsage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ContentRoUsageExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentRoUsage
// {
// partial class ContentRoUsageExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultContentID
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

@ -0,0 +1,642 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentTransition Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentTransitionConverter))]
public partial class ContentTransition : BusinessBase<ContentTransition>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _TransitionID;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TransitionID",true);
if (_MyTransition != null) _TransitionID = _MyTransition.TransitionID;
return _TransitionID;
}
}
private Transition _MyTransition;
[System.ComponentModel.DataObjectField(true, true)]
public Transition MyTransition
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyTransition",true);
if (_MyTransition == null && _TransitionID != 0) _MyTransition = Transition.Get(_TransitionID);
return _MyTransition;
}
}
private int _ToID;
/// <summary>
/// StructureID
/// </summary>
public int ToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ToID",true);
if (_MyItemToID != null) _ToID = _MyItemToID.ItemID;
return _ToID;
}
}
private Item _MyItemToID;
public Item MyItemToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItemToID",true);
if (_MyItemToID == null && _ToID != 0) _MyItemToID = Item.Get(_ToID);
return _MyItemToID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItemToID",true);
if (_MyItemToID != value)
{
_MyItemToID = value;
PropertyHasChanged();
}
}
}
private int _RangeID;
public int RangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RangeID",true);
if (_MyItemRangeID != null) _RangeID = _MyItemRangeID.ItemID;
return _RangeID;
}
}
private Item _MyItemRangeID;
public Item MyItemRangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItemRangeID",true);
if (_MyItemRangeID == null && _RangeID != 0) _MyItemRangeID = Item.Get(_RangeID);
return _MyItemRangeID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItemRangeID",true);
if (_MyItemRangeID != value)
{
_MyItemRangeID = value;
PropertyHasChanged();
}
}
}
private int _TranType;
public int TranType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TranType",true);
return _TranType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("TranType",true);
if (_TranType != value)
{
_TranType = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int? _Item_RangeID_PreviousID;
public int? Item_RangeID_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_RangeID_PreviousID",true);
return _Item_RangeID_PreviousID;
}
}
private int _Item_RangeID_ContentID;
public int Item_RangeID_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_RangeID_ContentID",true);
return _Item_RangeID_ContentID;
}
}
private DateTime _Item_RangeID_DTS = new DateTime();
public DateTime Item_RangeID_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_RangeID_DTS",true);
return _Item_RangeID_DTS;
}
}
private string _Item_RangeID_UserID = string.Empty;
public string Item_RangeID_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_RangeID_UserID",true);
return _Item_RangeID_UserID;
}
}
private int? _Item_ToID_PreviousID;
public int? Item_ToID_PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ToID_PreviousID",true);
return _Item_ToID_PreviousID;
}
}
private int _Item_ToID_ContentID;
public int Item_ToID_ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ToID_ContentID",true);
return _Item_ToID_ContentID;
}
}
private DateTime _Item_ToID_DTS = new DateTime();
public DateTime Item_ToID_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ToID_DTS",true);
return _Item_ToID_DTS;
}
}
private string _Item_ToID_UserID = string.Empty;
public string Item_ToID_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Item_ToID_UserID",true);
return _Item_ToID_UserID;
}
}
// TODO: Check ContentTransition.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ContentTransition</returns>
protected override object GetIdValue()
{
return _TransitionID;
}
// TODO: Replace base ContentTransition.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentTransition</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyItemToID == null ? false : _MyItemToID.IsDirty) || (_MyItemRangeID == null ? false : _MyItemRangeID.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyItemToID == null ? true : _MyItemToID.IsValid) && (_MyItemRangeID == null ? true : _MyItemRangeID.IsValid); }
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyItemToID != null && (hasBrokenRules = _MyItemToID.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItemRangeID != null && (hasBrokenRules = _MyItemRangeID.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<ContentTransition>(MyItemToIDRequired, "MyItemToID");
ValidationRules.AddRule<ContentTransition>(MyItemRangeIDRequired, "MyItemRangeID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyItemToIDRequired(ContentTransition target, Csla.Validation.RuleArgs e)
{
if (target._ToID == 0 && target._MyItemToID == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
private static bool MyItemRangeIDRequired(ContentTransition target, Csla.Validation.RuleArgs e)
{
if (target._RangeID == 0 && target._MyItemRangeID == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(TransitionID, "<Role(s)>");
//AuthorizationRules.AllowRead(ToID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ToID, "<Role(s)>");
//AuthorizationRules.AllowRead(RangeID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RangeID, "<Role(s)>");
//AuthorizationRules.AllowRead(TranType, "<Role(s)>");
//AuthorizationRules.AllowWrite(TranType, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentTransition New(Item myItemToID, Item myItemRangeID)
{
return new ContentTransition(myItemToID, myItemRangeID);
}
internal static ContentTransition Get(SafeDataReader dr)
{
return new ContentTransition(dr);
}
public ContentTransition()
{
MarkAsChild();
_TransitionID = Transition.NextTransitionID;
_TranType = _ContentTransitionExtension.DefaultTranType;
_DTS = _ContentTransitionExtension.DefaultDTS;
_UserID = _ContentTransitionExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentTransition(Item myItemToID, Item myItemRangeID)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_TranType = _ContentTransitionExtension.DefaultTranType;
_DTS = _ContentTransitionExtension.DefaultDTS;
_UserID = _ContentTransitionExtension.DefaultUserID;
_MyItemToID = myItemToID;
_MyItemRangeID = myItemRangeID;
ValidationRules.CheckRules();
}
internal ContentTransition(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ContentTransition.FetchDR", GetHashCode());
try
{
_TransitionID = dr.GetInt32("TransitionID");
_ToID = dr.GetInt32("ToID");
_RangeID = dr.GetInt32("RangeID");
_TranType = dr.GetInt32("TranType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_RangeID_PreviousID = (int?)dr.GetValue("Item_RangeID_PreviousID");
_Item_RangeID_ContentID = dr.GetInt32("Item_RangeID_ContentID");
_Item_RangeID_DTS = dr.GetDateTime("Item_RangeID_DTS");
_Item_RangeID_UserID = dr.GetString("Item_RangeID_UserID");
_Item_ToID_PreviousID = (int?)dr.GetValue("Item_ToID_PreviousID");
_Item_ToID_ContentID = dr.GetInt32("Item_ToID_ContentID");
_Item_ToID_DTS = dr.GetDateTime("Item_ToID_DTS");
_Item_ToID_UserID = dr.GetString("Item_ToID_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ContentTransition.FetchDR", ex);
throw new DbCslaException("ContentTransition.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Transition.Add(cn, ref _TransitionID, myContent, _MyItemToID, _MyItemRangeID, _TranType, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Transition.Update(cn, ref _TransitionID, myContent, _MyItemToID, _MyItemRangeID, _TranType, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Transition.Remove(cn, _TransitionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentTransitionExtension _ContentTransitionExtension = new ContentTransitionExtension();
[Serializable()]
partial class ContentTransitionExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultTranType
{
get { return 0; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ContentTransitionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentTransition)
{
// Return the ToString value
return ((ContentTransition)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ContentTransitionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ContentTransition
// {
// partial class ContentTransitionExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultTranType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,361 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void DetailInfoEvent(object sender);
/// <summary>
/// DetailInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DetailInfoConverter))]
public partial class DetailInfo : ReadOnlyBase<DetailInfo>, IDisposable
{
public event DetailInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<DetailInfo> _AllList = new List<DetailInfo>();
private static Dictionary<string, DetailInfo> _AllByPrimaryKey = new Dictionary<string, DetailInfo>();
private static void ConvertListToDictionary()
{
List<DetailInfo> remove = new List<DetailInfo>();
foreach (DetailInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.DetailID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (DetailInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(DetailInfoList lst)
{
foreach (DetailInfo item in lst) _AllList.Add(item);
}
public static DetailInfo GetExistingByPrimaryKey(int detailID)
{
ConvertListToDictionary();
string key = detailID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Detail _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DetailID;
[System.ComponentModel.DataObjectField(true, true)]
public int DetailID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DetailID",true);
return _DetailID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID",true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent",true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemType",true);
return _ItemType;
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text",true);
return _Text;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
}
// TODO: Replace base DetailInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DetailInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DetailInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current DetailInfo</returns>
protected override object GetIdValue()
{
return _DetailID;
}
#endregion
#region Factory Methods
private DetailInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(DetailID.ToString());
}
public virtual Detail Get()
{
return _Editable = Detail.Get(_DetailID);
}
public static void Refresh(Detail tmp)
{
DetailInfo tmpInfo = GetExistingByPrimaryKey(tmp.DetailID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Detail tmp)
{
_ContentID = tmp.ContentID;
_ItemType = tmp.ItemType;
_Text = tmp.Text;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DetailInfoExtension.Refresh(this);
_MyContent = null;
OnChange();// raise an event
}
public static void Refresh(ContentDetail tmp)
{
DetailInfo tmpInfo = GetExistingByPrimaryKey(tmp.DetailID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(ContentDetail tmp)
{
_ItemType = tmp.ItemType;
_Text = tmp.Text;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DetailInfoExtension.Refresh(this);
_MyContent = null;
OnChange();// raise an event
}
public static DetailInfo Get(int detailID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Detail");
try
{
DetailInfo tmp = GetExistingByPrimaryKey(detailID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DetailInfo>(new PKCriteria(detailID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DetailInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DetailInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfo.Constructor", ex);
throw new DbCslaException("DetailInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DetailID;
public int DetailID
{ get { return _DetailID; } }
public PKCriteria(int detailID)
{
_DetailID = detailID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode());
try
{
_DetailID = dr.GetInt32("DetailID");
_ContentID = dr.GetInt32("ContentID");
_ItemType = dr.GetInt32("ItemType");
_Text = dr.GetString("Text");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DetailInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DetailInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDetail";
cm.Parameters.AddWithValue("@DetailID", criteria.DetailID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DetailInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DetailInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
[Serializable()]
partial class DetailInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DetailInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DetailInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DetailInfo)
{
// Return the ToString value
return ((DetailInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,470 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// DocumentEntry Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentEntryConverter))]
public partial class DocumentEntry : BusinessBase<DocumentEntry>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID",true);
if (_MyEntry != null) _ContentID = _MyEntry.ContentID;
return _ContentID;
}
}
private Entry _MyEntry;
[System.ComponentModel.DataObjectField(true, true)]
public Entry MyEntry
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyEntry",true);
if (_MyEntry == null && _ContentID != 0) _MyEntry = Entry.Get(_ContentID);
return _MyEntry;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Content_Number = string.Empty;
public string Content_Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Number",true);
return _Content_Number;
}
}
private string _Content_Text = string.Empty;
public string Content_Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Text",true);
return _Content_Text;
}
}
private int? _Content_Type;
/// <summary>
/// 0 - Procedure, 10000 - Section, 20000 Step
/// </summary>
public int? Content_Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Type",true);
return _Content_Type;
}
}
private int? _Content_FormatID;
public int? Content_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_FormatID",true);
return _Content_FormatID;
}
}
private string _Content_Config = string.Empty;
public string Content_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_Config",true);
return _Content_Config;
}
}
private DateTime _Content_DTS = new DateTime();
public DateTime Content_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_DTS",true);
return _Content_DTS;
}
}
private string _Content_UserID = string.Empty;
public string Content_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Content_UserID",true);
return _Content_UserID;
}
}
// TODO: Check DocumentEntry.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current DocumentEntry</returns>
protected override object GetIdValue()
{
return _ContentID;
}
// TODO: Replace base DocumentEntry.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentEntry</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static DocumentEntry New(Entry myEntry)
{
return new DocumentEntry(myEntry);
}
internal static DocumentEntry Get(SafeDataReader dr)
{
return new DocumentEntry(dr);
}
public DocumentEntry()
{
MarkAsChild();
_DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private DocumentEntry(Entry myEntry)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID;
_MyEntry = myEntry;
ValidationRules.CheckRules();
}
internal DocumentEntry(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Content_Number = dr.GetString("Content_Number");
_Content_Text = dr.GetString("Content_Text");
_Content_Type = (int?)dr.GetValue("Content_Type");
_Content_FormatID = (int?)dr.GetValue("Content_FormatID");
_Content_Config = dr.GetString("Content_Config");
_Content_DTS = dr.GetDateTime("Content_DTS");
_Content_UserID = dr.GetString("Content_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentEntry.FetchDR", ex);
throw new DbCslaException("DocumentEntry.Fetch", ex);
}
MarkOld();
}
internal void Insert(Document myDocument)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Entry.Add(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID);
MarkOld();
}
internal void Update(Document myDocument)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Entry.Update(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Document myDocument)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Entry.Remove(cn, _ContentID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
DocumentEntryExtension _DocumentEntryExtension = new DocumentEntryExtension();
[Serializable()]
partial class DocumentEntryExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class DocumentEntryConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentEntry)
{
// Return the ToString value
return ((DocumentEntry)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create DocumentEntryExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class DocumentEntry
// {
// partial class DocumentEntryExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

@ -0,0 +1,364 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void DocumentInfoEvent(object sender);
/// <summary>
/// DocumentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentInfoConverter))]
public partial class DocumentInfo : ReadOnlyBase<DocumentInfo>, IDisposable
{
public event DocumentInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<DocumentInfo> _AllList = new List<DocumentInfo>();
private static Dictionary<string, DocumentInfo> _AllByPrimaryKey = new Dictionary<string, DocumentInfo>();
private static void ConvertListToDictionary()
{
List<DocumentInfo> remove = new List<DocumentInfo>();
foreach (DocumentInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.DocID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (DocumentInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(DocumentInfoList lst)
{
foreach (DocumentInfo item in lst) _AllList.Add(item);
}
public static DocumentInfo GetExistingByPrimaryKey(int docID)
{
ConvertListToDictionary();
string key = docID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Document _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DocID;
[System.ComponentModel.DataObjectField(true, true)]
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID",true);
return _DocID;
}
}
private string _LibTitle = string.Empty;
public string LibTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("LibTitle",true);
return _LibTitle;
}
}
private byte[] _DocContent;
/// <summary>
/// Actual content of a Word Document (RTF, DOC or XML Format)
/// </summary>
public byte[] DocContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocContent",true);
return _DocContent;
}
}
private string _DocAscii = string.Empty;
/// <summary>
/// Used for searching
/// </summary>
public string DocAscii
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocAscii",true);
return _DocAscii;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
}
private int _DocumentEntryCount = 0;
/// <summary>
/// Count of DocumentEntries for this Document
/// </summary>
public int DocumentEntryCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocumentEntryCount",true);
return _DocumentEntryCount;
}
}
private EntryInfoList _DocumentEntries = null;
[TypeConverter(typeof(EntryInfoListConverter))]
public EntryInfoList DocumentEntries
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocumentEntries",true);
if (_DocumentEntryCount > 0 && _DocumentEntries == null)
_DocumentEntries = EntryInfoList.GetByDocID(_DocID);
return _DocumentEntries;
}
}
// TODO: Replace base DocumentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocumentInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current DocumentInfo</returns>
protected override object GetIdValue()
{
return _DocID;
}
#endregion
#region Factory Methods
private DocumentInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(DocID.ToString());
}
public virtual Document Get()
{
return _Editable = Document.Get(_DocID);
}
public static void Refresh(Document tmp)
{
DocumentInfo tmpInfo = GetExistingByPrimaryKey(tmp.DocID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Document tmp)
{
_LibTitle = tmp.LibTitle;
_DocContent = tmp.DocContent;
_DocAscii = tmp.DocAscii;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DocumentInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static DocumentInfo Get(int docID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Document");
try
{
DocumentInfo tmp = GetExistingByPrimaryKey(docID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocumentInfo>(new PKCriteria(docID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DocumentInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfo.Constructor", ex);
throw new DbCslaException("DocumentInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DocID;
public int DocID
{ get { return _DocID; } }
public PKCriteria(int docID)
{
_DocID = docID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode());
try
{
_DocID = dr.GetInt32("DocID");
_LibTitle = dr.GetString("LibTitle");
_DocContent = (byte[])dr.GetValue("DocContent");
_DocAscii = dr.GetString("DocAscii");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DocumentEntryCount = dr.GetInt32("EntryCount");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] DocumentInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocument";
cm.Parameters.AddWithValue("@DocID", criteria.DocID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("DocumentInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
[Serializable()]
partial class DocumentInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DocumentInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DocumentInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentInfo)
{
// Return the ToString value
return ((DocumentInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

View File

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

View File

@ -0,0 +1,340 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void EntryInfoEvent(object sender);
/// <summary>
/// EntryInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(EntryInfoConverter))]
public partial class EntryInfo : ReadOnlyBase<EntryInfo>, IDisposable
{
public event EntryInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<EntryInfo> _AllList = new List<EntryInfo>();
private static Dictionary<string, EntryInfo> _AllByPrimaryKey = new Dictionary<string, EntryInfo>();
private static void ConvertListToDictionary()
{
List<EntryInfo> remove = new List<EntryInfo>();
foreach (EntryInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.ContentID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (EntryInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(EntryInfoList lst)
{
foreach (EntryInfo item in lst) _AllList.Add(item);
}
public static EntryInfo GetExistingByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Entry _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID",true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent",true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private int _DocID;
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID",true);
if (_MyDocument != null) _DocID = _MyDocument.DocID;
return _DocID;
}
}
private DocumentInfo _MyDocument;
public DocumentInfo MyDocument
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDocument",true);
if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID);
return _MyDocument;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
}
// TODO: Replace base EntryInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current EntryInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check EntryInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current EntryInfo</returns>
protected override object GetIdValue()
{
return _ContentID;
}
#endregion
#region Factory Methods
private EntryInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(ContentID.ToString());
}
public virtual Entry Get()
{
return _Editable = Entry.Get(_ContentID);
}
public static void Refresh(Entry tmp)
{
EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Entry tmp)
{
_DocID = tmp.DocID;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
_MyContent = null;
_MyDocument = null;
OnChange();// raise an event
}
public static void Refresh(DocumentEntry tmp)
{
EntryInfo tmpInfo = GetExistingByPrimaryKey(tmp.ContentID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(DocumentEntry tmp)
{
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_EntryInfoExtension.Refresh(this);
_MyContent = null;
_MyDocument = null;
OnChange();// raise an event
}
public static EntryInfo Get(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Entry");
try
{
EntryInfo tmp = GetExistingByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp._ContentID = contentID;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal EntryInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.Constructor", ex);
throw new DbCslaException("EntryInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ContentID;
public int ContentID
{ get { return _ContentID; } }
public PKCriteria(int contentID)
{
_ContentID = contentID;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_DocID = dr.GetInt32("DocID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] EntryInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getEntry";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("EntryInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
[Serializable()]
partial class EntryInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(EntryInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class EntryInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is EntryInfo)
{
// Return the ToString value
return ((EntryInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -0,0 +1,583 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FolderDocVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FolderDocVersionConverter))]
public partial class FolderDocVersion : BusinessBase<FolderDocVersion>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionID",true);
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID;
}
}
private DocVersion _MyDocVersion;
[System.ComponentModel.DataObjectField(true, true)]
public DocVersion MyDocVersion
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDocVersion",true);
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID);
return _MyDocVersion;
}
}
private int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionType",true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("VersionType",true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Name",true);
if (value == null) value = string.Empty;
if (_Name != value)
{
_Name = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Title",true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private int? _ItemID;
public int? ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem",true);
if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItem",true);
if (_MyItem != value)
{
_MyItem = value;
_ItemID = (value == null ? null : (int?) value.ItemID);
PropertyHasChanged();
}
}
}
private int? _FormatID;
public int? FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FormatID",true);
if (_MyFormat != null) _FormatID = _MyFormat.FormatID;
return _FormatID;
}
}
private Format _MyFormat;
public Format MyFormat
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFormat",true);
if (_MyFormat == null && _FormatID != null) _MyFormat = Format.Get((int)_FormatID);
return _MyFormat;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFormat",true);
if (_MyFormat != value)
{
_MyFormat = value;
_FormatID = (value == null ? null : (int?) value.FormatID);
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check FolderDocVersion.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current FolderDocVersion</returns>
protected override object GetIdValue()
{
return _VersionID;
}
// TODO: Replace base FolderDocVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FolderDocVersion</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
if (_MyFormat != null && (hasBrokenRules = _MyFormat.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(FormatID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FormatID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static FolderDocVersion New(string name)
{
return new FolderDocVersion(name);
}
internal static FolderDocVersion Get(SafeDataReader dr)
{
return new FolderDocVersion(dr);
}
public FolderDocVersion()
{
MarkAsChild();
_VersionID = DocVersion.NextVersionID;
_VersionType = _FolderDocVersionExtension.DefaultVersionType;
_DTS = _FolderDocVersionExtension.DefaultDTS;
_UserID = _FolderDocVersionExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private FolderDocVersion(string name)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_VersionType = _FolderDocVersionExtension.DefaultVersionType;
_DTS = _FolderDocVersionExtension.DefaultDTS;
_UserID = _FolderDocVersionExtension.DefaultUserID;
_Name = name;
ValidationRules.CheckRules();
}
internal FolderDocVersion(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FolderDocVersion.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ItemID = (int?)dr.GetValue("ItemID");
_FormatID = (int?)dr.GetValue("FormatID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FolderDocVersion.FetchDR", ex);
throw new DbCslaException("FolderDocVersion.Fetch", ex);
}
MarkOld();
}
internal void Insert(Folder myFolder)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersion.Add(cn, ref _VersionID, myFolder, _VersionType, _Name, _Title, _MyItem, _MyFormat, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Folder myFolder)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersion.Update(cn, ref _VersionID, myFolder, _VersionType, _Name, _Title, _MyItem, _MyFormat, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Folder myFolder)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
DocVersion.Remove(cn, _VersionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FolderDocVersionExtension _FolderDocVersionExtension = new FolderDocVersionExtension();
[Serializable()]
partial class FolderDocVersionExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultVersionType
{
get { return 0; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class FolderDocVersionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FolderDocVersion)
{
// Return the ToString value
return ((FolderDocVersion)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create FolderDocVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class FolderDocVersion
// {
// partial class FolderDocVersionExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultVersionType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,488 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FormatContent Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatContentConverter))]
public partial class FormatContent : BusinessBase<FormatContent>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID",true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private Content _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public Content MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent",true);
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Number",true);
return _Number;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Number",true);
if (value == null) value = string.Empty;
if (_Number != value)
{
_Number = value;
PropertyHasChanged();
}
}
}
private string _Text = string.Empty;
public string Text
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Text",true);
return _Text;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Text",true);
if (value == null) value = string.Empty;
if (_Text != value)
{
_Text = value;
PropertyHasChanged();
}
}
}
private int? _Type;
/// <summary>
/// 0 - Procedure, 10000 - Section, 20000 Step
/// </summary>
public int? Type
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Type",true);
return _Type;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Type",true);
if (_Type != value)
{
_Type = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check FormatContent.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current FormatContent</returns>
protected override object GetIdValue()
{
return _ContentID;
}
// TODO: Replace base FormatContent.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FormatContent</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 30));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(Number, "<Role(s)>");
//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
//AuthorizationRules.AllowRead(Text, "<Role(s)>");
//AuthorizationRules.AllowWrite(Text, "<Role(s)>");
//AuthorizationRules.AllowRead(Type, "<Role(s)>");
//AuthorizationRules.AllowWrite(Type, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static FormatContent New()
{
return new FormatContent();
}
internal static FormatContent Get(SafeDataReader dr)
{
return new FormatContent(dr);
}
public FormatContent()
{
MarkAsChild();
_ContentID = Content.NextContentID;
_DTS = _FormatContentExtension.DefaultDTS;
_UserID = _FormatContentExtension.DefaultUserID;
ValidationRules.CheckRules();
}
internal FormatContent(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode());
try
{
_ContentID = dr.GetInt32("ContentID");
_Number = dr.GetString("Number");
_Text = dr.GetString("Text");
_Type = (int?)dr.GetValue("Type");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatContent.FetchDR", ex);
throw new DbCslaException("FormatContent.Fetch", ex);
}
MarkOld();
}
internal void Insert(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Content.Add(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Content.Update(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Content.Remove(cn, _ContentID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FormatContentExtension _FormatContentExtension = new FormatContentExtension();
[Serializable()]
partial class FormatContentExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class FormatContentConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatContent)
{
// Return the ToString value
return ((FormatContent)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create FormatContentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class FormatContent
// {
// partial class FormatContentExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

@ -0,0 +1,700 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// FormatDocVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FormatDocVersionConverter))]
public partial class FormatDocVersion : BusinessBase<FormatDocVersion>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionID",true);
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
return _VersionID;
}
}
private DocVersion _MyDocVersion;
[System.ComponentModel.DataObjectField(true, true)]
public DocVersion MyDocVersion
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyDocVersion",true);
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersion.Get(_VersionID);
return _MyDocVersion;
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID",true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder",true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFolder",true);
if (_MyFolder != value)
{
_MyFolder = value;
PropertyHasChanged();
}
}
}
private int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("VersionType",true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("VersionType",true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name",true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Name",true);
if (value == null) value = string.Empty;
if (_Name != value)
{
_Name = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title",true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Title",true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private int? _ItemID;
public int? ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID",true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem",true);
if (_MyItem == null && _ItemID != null) _MyItem = Item.Get((int)_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyItem",true);
if (_MyItem != value)
{
_MyItem = value;
_ItemID = (value == null ? null : (int?) value.ItemID);
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _Folder_ParentID;
public int Folder_ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ParentID",true);
return _Folder_ParentID;
}
}
private int _Folder_DBID;
public int Folder_DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DBID",true);
return _Folder_DBID;
}
}
private string _Folder_Name = string.Empty;
public string Folder_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Name",true);
return _Folder_Name;
}
}
private string _Folder_Title = string.Empty;
public string Folder_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Title",true);
return _Folder_Title;
}
}
private string _Folder_ShortName = string.Empty;
public string Folder_ShortName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_ShortName",true);
return _Folder_ShortName;
}
}
private int? _Folder_FormatID;
public int? Folder_FormatID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_FormatID",true);
return _Folder_FormatID;
}
}
private string _Folder_Config = string.Empty;
public string Folder_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_Config",true);
return _Folder_Config;
}
}
private DateTime _Folder_DTS = new DateTime();
public DateTime Folder_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_DTS",true);
return _Folder_DTS;
}
}
private string _Folder_UsrID = string.Empty;
public string Folder_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Folder_UsrID",true);
return _Folder_UsrID;
}
}
// TODO: Check FormatDocVersion.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current FormatDocVersion</returns>
protected override object GetIdValue()
{
return _VersionID;
}
// TODO: Replace base FormatDocVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FormatDocVersion</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.IsValid); }
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyFolder != null && (hasBrokenRules = _MyFolder.HasBrokenRules) != null) return hasBrokenRules;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<FormatDocVersion>(MyFolderRequired, "MyFolder");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyFolderRequired(FormatDocVersion target, Csla.Validation.RuleArgs e)
{
if (target._FolderID == 0 && target._MyFolder == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static FormatDocVersion New(Folder myFolder, string name)
{
return new FormatDocVersion(myFolder, name);
}
internal static FormatDocVersion Get(SafeDataReader dr)
{
return new FormatDocVersion(dr);
}
public FormatDocVersion()
{
MarkAsChild();
_VersionID = DocVersion.NextVersionID;
_VersionType = _FormatDocVersionExtension.DefaultVersionType;
_DTS = _FormatDocVersionExtension.DefaultDTS;
_UserID = _FormatDocVersionExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private FormatDocVersion(Folder myFolder, string name)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_VersionType = _FormatDocVersionExtension.DefaultVersionType;
_DTS = _FormatDocVersionExtension.DefaultDTS;
_UserID = _FormatDocVersionExtension.DefaultUserID;
_MyFolder = myFolder;
_Name = name;
ValidationRules.CheckRules();
}
internal FormatDocVersion(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] FormatDocVersion.FetchDR", GetHashCode());
try
{
_VersionID = dr.GetInt32("VersionID");
_FolderID = dr.GetInt32("FolderID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ItemID = (int?)dr.GetValue("ItemID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Folder_ParentID = dr.GetInt32("Folder_ParentID");
_Folder_DBID = dr.GetInt32("Folder_DBID");
_Folder_Name = dr.GetString("Folder_Name");
_Folder_Title = dr.GetString("Folder_Title");
_Folder_ShortName = dr.GetString("Folder_ShortName");
_Folder_FormatID = (int?)dr.GetValue("Folder_FormatID");
_Folder_Config = dr.GetString("Folder_Config");
_Folder_DTS = dr.GetDateTime("Folder_DTS");
_Folder_UsrID = dr.GetString("Folder_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("FormatDocVersion.FetchDR", ex);
throw new DbCslaException("FormatDocVersion.Fetch", ex);
}
MarkOld();
}
internal void Insert(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersion.Add(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, _MyItem, myFormat, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = DocVersion.Update(cn, ref _VersionID, _MyFolder, _VersionType, _Name, _Title, _MyItem, myFormat, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Format myFormat)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
DocVersion.Remove(cn, _VersionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
FormatDocVersionExtension _FormatDocVersionExtension = new FormatDocVersionExtension();
[Serializable()]
partial class FormatDocVersionExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultVersionType
{
get { return 0; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class FormatDocVersionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatDocVersion)
{
// Return the ToString value
return ((FormatDocVersion)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create FormatDocVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class FormatDocVersion
// {
// partial class FormatDocVersionExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultVersionType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -0,0 +1,373 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void GroupInfoEvent(object sender);
/// <summary>
/// GroupInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GroupInfoConverter))]
public partial class GroupInfo : ReadOnlyBase<GroupInfo>, IDisposable
{
public event GroupInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
protected static List<GroupInfo> _AllList = new List<GroupInfo>();
private static Dictionary<string, GroupInfo> _AllByPrimaryKey = new Dictionary<string, GroupInfo>();
private static void ConvertListToDictionary()
{
List<GroupInfo> remove = new List<GroupInfo>();
foreach (GroupInfo tmp in _AllList)
{
_AllByPrimaryKey[tmp.GID.ToString()]=tmp; // Primary Key
remove.Add(tmp);
}
foreach (GroupInfo tmp in remove)
_AllList.Remove(tmp);
}
internal static void AddList(GroupInfoList lst)
{
foreach (GroupInfo item in lst) _AllList.Add(item);
}
public static GroupInfo GetExistingByPrimaryKey(int gid)
{
ConvertListToDictionary();
string key = gid.ToString();
if (_AllByPrimaryKey.ContainsKey(key)) return _AllByPrimaryKey[key];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Group _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _GID;
[System.ComponentModel.DataObjectField(true, true)]
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GID",true);
return _GID;
}
}
private string _GroupName = string.Empty;
public string GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupName",true);
return _GroupName;
}
}
private int? _GroupType;
public int? GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupType",true);
return _GroupType;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
}
private int _GroupAssignmentCount = 0;
/// <summary>
/// Count of GroupAssignments for this Group
/// </summary>
public int GroupAssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupAssignmentCount",true);
return _GroupAssignmentCount;
}
}
private AssignmentInfoList _GroupAssignments = null;
[TypeConverter(typeof(AssignmentInfoListConverter))]
public AssignmentInfoList GroupAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupAssignments",true);
if (_GroupAssignmentCount > 0 && _GroupAssignments == null)
_GroupAssignments = AssignmentInfoList.GetByGID(_GID);
return _GroupAssignments;
}
}
private int _GroupMembershipCount = 0;
/// <summary>
/// Count of GroupMemberships for this Group
/// </summary>
public int GroupMembershipCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupMembershipCount",true);
return _GroupMembershipCount;
}
}
private MembershipInfoList _GroupMemberships = null;
[TypeConverter(typeof(MembershipInfoListConverter))]
public MembershipInfoList GroupMemberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GroupMemberships",true);
if (_GroupMembershipCount > 0 && _GroupMemberships == null)
_GroupMemberships = MembershipInfoList.GetByGID(_GID);
return _GroupMemberships;
}
}
// TODO: Replace base GroupInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check GroupInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current GroupInfo</returns>
protected override object GetIdValue()
{
return _GID;
}
#endregion
#region Factory Methods
private GroupInfo()
{/* require use of factory methods */
_AllList.Add(this);
}
public void Dispose()
{
_AllList.Remove(this);
_AllByPrimaryKey.Remove(GID.ToString());
}
public virtual Group Get()
{
return _Editable = Group.Get(_GID);
}
public static void Refresh(Group tmp)
{
GroupInfo tmpInfo = GetExistingByPrimaryKey(tmp.GID);
if (tmpInfo == null) return;
tmpInfo.RefreshFields(tmp);
}
private void RefreshFields(Group tmp)
{
_GroupName = tmp.GroupName;
_GroupType = tmp.GroupType;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_GroupInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static GroupInfo Get(int gid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Group");
try
{
GroupInfo tmp = GetExistingByPrimaryKey(gid);
if (tmp == null)
{
tmp = DataPortal.Fetch<GroupInfo>(new PKCriteria(gid));
_AllList.Add(tmp);
}
if (tmp.ErrorMessage == "No Record Found") tmp = null;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on GroupInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal GroupInfo(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfo.Constructor", ex);
throw new DbCslaException("GroupInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _GID;
public int GID
{ get { return _GID; } }
public PKCriteria(int gid)
{
_GID = gid;
}
}
private void ReadData(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode());
try
{
_GID = dr.GetInt32("GID");
_GroupName = dr.GetString("GroupName");
_GroupType = (int?)dr.GetValue("GroupType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_GroupAssignmentCount = dr.GetInt32("AssignmentCount");
_GroupMembershipCount = dr.GetInt32("MembershipCount");
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("GroupInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getGroup";
cm.Parameters.AddWithValue("@GID", criteria.GID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("GroupInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
[Serializable()]
partial class GroupInfoExtension : extensionBase {}
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(GroupInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class GroupInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupInfo)
{
// Return the ToString value
return ((GroupInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace

View File

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

View File

@ -0,0 +1,720 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// GroupMembership Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(GroupMembershipConverter))]
public partial class GroupMembership : BusinessBase<GroupMembership>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _UGID;
[System.ComponentModel.DataObjectField(true, true)]
public int UGID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UGID",true);
if (_MyMembership != null) _UGID = _MyMembership.UGID;
return _UGID;
}
}
private Membership _MyMembership;
[System.ComponentModel.DataObjectField(true, true)]
public Membership MyMembership
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyMembership",true);
if (_MyMembership == null && _UGID != 0) _MyMembership = Membership.Get(_UGID);
return _MyMembership;
}
}
private int _UID;
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UID",true);
if (_MyUser != null) _UID = _MyUser.UID;
return _UID;
}
}
private User _MyUser;
public User MyUser
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyUser",true);
if (_MyUser == null && _UID != 0) _MyUser = User.Get(_UID);
return _MyUser;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyUser",true);
if (_MyUser != value)
{
_MyUser = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StartDate",true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("StartDate",true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("EndDate",true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("EndDate",true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID",true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID",true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _User_UserID = string.Empty;
public string User_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_UserID",true);
return _User_UserID;
}
}
private string _User_FirstName = string.Empty;
public string User_FirstName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_FirstName",true);
return _User_FirstName;
}
}
private string _User_MiddleName = string.Empty;
public string User_MiddleName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_MiddleName",true);
return _User_MiddleName;
}
}
private string _User_LastName = string.Empty;
public string User_LastName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_LastName",true);
return _User_LastName;
}
}
private string _User_Suffix = string.Empty;
public string User_Suffix
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_Suffix",true);
return _User_Suffix;
}
}
private string _User_CourtesyTitle = string.Empty;
public string User_CourtesyTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_CourtesyTitle",true);
return _User_CourtesyTitle;
}
}
private string _User_PhoneNumber = string.Empty;
public string User_PhoneNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_PhoneNumber",true);
return _User_PhoneNumber;
}
}
private string _User_CFGName = string.Empty;
public string User_CFGName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_CFGName",true);
return _User_CFGName;
}
}
private string _User_UserLogin = string.Empty;
public string User_UserLogin
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_UserLogin",true);
return _User_UserLogin;
}
}
private string _User_UserName = string.Empty;
public string User_UserName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_UserName",true);
return _User_UserName;
}
}
private string _User_Config = string.Empty;
public string User_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_Config",true);
return _User_Config;
}
}
private DateTime _User_DTS = new DateTime();
public DateTime User_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_DTS",true);
return _User_DTS;
}
}
private string _User_UsrID = string.Empty;
public string User_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("User_UsrID",true);
return _User_UsrID;
}
}
// TODO: Check GroupMembership.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current GroupMembership</returns>
protected override object GetIdValue()
{
return _UGID;
}
// TODO: Replace base GroupMembership.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupMembership</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyUser == null ? false : _MyUser.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyUser == null ? true : _MyUser.IsValid); }
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyUser != null && (hasBrokenRules = _MyUser.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<GroupMembership>(MyUserRequired, "MyUser");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule<GroupMembership>(StartDateValid, "StartDate");
ValidationRules.AddRule<GroupMembership>(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private static bool StartDateValid(GroupMembership target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool EndDateValid(GroupMembership target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._EndDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private static bool MyUserRequired(GroupMembership target, Csla.Validation.RuleArgs e)
{
if (target._UID == 0 && target._MyUser == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(UGID, "<Role(s)>");
//AuthorizationRules.AllowRead(UID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static GroupMembership New(User myUser)
{
return new GroupMembership(myUser);
}
internal static GroupMembership Get(SafeDataReader dr)
{
return new GroupMembership(dr);
}
public GroupMembership()
{
MarkAsChild();
_UGID = Membership.NextUGID;
_StartDate = _GroupMembershipExtension.DefaultStartDate;
_DTS = _GroupMembershipExtension.DefaultDTS;
_UsrID = _GroupMembershipExtension.DefaultUsrID;
ValidationRules.CheckRules();
}
private GroupMembership(User myUser)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = _GroupMembershipExtension.DefaultStartDate;
_DTS = _GroupMembershipExtension.DefaultDTS;
_UsrID = _GroupMembershipExtension.DefaultUsrID;
_MyUser = myUser;
ValidationRules.CheckRules();
}
internal GroupMembership(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] GroupMembership.FetchDR", GetHashCode());
try
{
_UGID = dr.GetInt32("UGID");
_UID = dr.GetInt32("UID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_User_UserID = dr.GetString("User_UserID");
_User_FirstName = dr.GetString("User_FirstName");
_User_MiddleName = dr.GetString("User_MiddleName");
_User_LastName = dr.GetString("User_LastName");
_User_Suffix = dr.GetString("User_Suffix");
_User_CourtesyTitle = dr.GetString("User_CourtesyTitle");
_User_PhoneNumber = dr.GetString("User_PhoneNumber");
_User_CFGName = dr.GetString("User_CFGName");
_User_UserLogin = dr.GetString("User_UserLogin");
_User_UserName = dr.GetString("User_UserName");
_User_Config = dr.GetString("User_Config");
_User_DTS = dr.GetDateTime("User_DTS");
_User_UsrID = dr.GetString("User_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("GroupMembership.FetchDR", ex);
throw new DbCslaException("GroupMembership.Fetch", ex);
}
MarkOld();
}
internal void Insert(Group myGroup)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Membership.Add(cn, ref _UGID, _MyUser, myGroup, new SmartDate(_StartDate), new SmartDate(_EndDate), _Config, _DTS, _UsrID);
MarkOld();
}
internal void Update(Group myGroup)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Membership.Update(cn, ref _UGID, _MyUser, myGroup, new SmartDate(_StartDate), new SmartDate(_EndDate), _Config, _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Group myGroup)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Membership.Remove(cn, _UGID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
GroupMembershipExtension _GroupMembershipExtension = new GroupMembershipExtension();
[Serializable()]
partial class GroupMembershipExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class GroupMembershipConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupMembership)
{
// Return the ToString value
return ((GroupMembership)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create GroupMembershipExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class GroupMembership
// {
// partial class GroupMembershipExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,569 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ItemAnnotation Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemAnnotationConverter))]
public partial class ItemAnnotation : BusinessBase<ItemAnnotation>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationID",true);
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID;
}
}
private Annotation _MyAnnotation;
[System.ComponentModel.DataObjectField(true, true)]
public Annotation MyAnnotation
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotation",true);
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID",true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID;
}
}
private AnnotationType _MyAnnotationType;
public AnnotationType MyAnnotationType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotationType",true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID);
return _MyAnnotationType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyAnnotationType",true);
if (_MyAnnotationType != value)
{
_MyAnnotationType = value;
PropertyHasChanged();
}
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText",true);
return _RtfText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("RtfText",true);
if (value == null) value = string.Empty;
if (_RtfText != value)
{
_RtfText = value;
PropertyHasChanged();
}
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText",true);
return _SearchText;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("SearchText",true);
if (value == null) value = string.Empty;
if (_SearchText != value)
{
_SearchText = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config",true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config",true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS",true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS",true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID",true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID",true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _AnnotationType_Name = string.Empty;
public string AnnotationType_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationType_Name",true);
return _AnnotationType_Name;
}
}
private string _AnnotationType_Config = string.Empty;
public string AnnotationType_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationType_Config",true);
return _AnnotationType_Config;
}
}
private DateTime _AnnotationType_DTS = new DateTime();
public DateTime AnnotationType_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationType_DTS",true);
return _AnnotationType_DTS;
}
}
private string _AnnotationType_UserID = string.Empty;
public string AnnotationType_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationType_UserID",true);
return _AnnotationType_UserID;
}
}
// TODO: Check ItemAnnotation.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ItemAnnotation</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
// TODO: Replace base ItemAnnotation.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemAnnotation</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyAnnotationType == null ? false : _MyAnnotationType.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyAnnotationType == null ? true : _MyAnnotationType.IsValid); }
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules=false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if(_CheckingBrokenRules)return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules=true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyAnnotationType != null && (hasBrokenRules = _MyAnnotationType.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules=false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule<ItemAnnotation>(MyAnnotationTypeRequired, "MyAnnotationType");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("RtfText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("SearchText", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
private static bool MyAnnotationTypeRequired(ItemAnnotation target, Csla.Validation.RuleArgs e)
{
if (target._TypeID == 0 && target._MyAnnotationType == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AnnotationID, "<Role(s)>");
//AuthorizationRules.AllowRead(TypeID, "<Role(s)>");
//AuthorizationRules.AllowWrite(TypeID, "<Role(s)>");
//AuthorizationRules.AllowRead(RtfText, "<Role(s)>");
//AuthorizationRules.AllowWrite(RtfText, "<Role(s)>");
//AuthorizationRules.AllowRead(SearchText, "<Role(s)>");
//AuthorizationRules.AllowWrite(SearchText, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ItemAnnotation New(AnnotationType myAnnotationType)
{
return new ItemAnnotation(myAnnotationType);
}
internal static ItemAnnotation Get(SafeDataReader dr)
{
return new ItemAnnotation(dr);
}
public ItemAnnotation()
{
MarkAsChild();
_AnnotationID = Annotation.NextAnnotationID;
_DTS = _ItemAnnotationExtension.DefaultDTS;
_UserID = _ItemAnnotationExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ItemAnnotation(AnnotationType myAnnotationType)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ItemAnnotationExtension.DefaultDTS;
_UserID = _ItemAnnotationExtension.DefaultUserID;
_MyAnnotationType = myAnnotationType;
ValidationRules.CheckRules();
}
internal ItemAnnotation(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("[{0}] ItemAnnotation.FetchDR", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_TypeID = dr.GetInt32("TypeID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_AnnotationType_Name = dr.GetString("AnnotationType_Name");
_AnnotationType_Config = dr.GetString("AnnotationType_Config");
_AnnotationType_DTS = dr.GetDateTime("AnnotationType_DTS");
_AnnotationType_UserID = dr.GetString("AnnotationType_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if(_MyLog.IsErrorEnabled)_MyLog.Error("ItemAnnotation.FetchDR", ex);
throw new DbCslaException("ItemAnnotation.Fetch", ex);
}
MarkOld();
}
internal void Insert(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Add(cn, ref _AnnotationID, myItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Annotation.Update(cn, ref _AnnotationID, myItem, _MyAnnotationType, _RtfText, _SearchText, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Item myItem)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Annotation.Remove(cn, _AnnotationID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ItemAnnotationExtension _ItemAnnotationExtension = new ItemAnnotationExtension();
[Serializable()]
partial class ItemAnnotationExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ItemAnnotationConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemAnnotation)
{
// Return the ToString value
return ((ItemAnnotation)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create ItemAnnotationExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class ItemAnnotation
// {
// partial class ItemAnnotationExtension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}

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