Commit for development environment setup

This commit is contained in:
2023-06-19 16:12:33 -04:00
parent be72063a3c
commit bbce2ad0a6
2209 changed files with 1171775 additions and 625 deletions
@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class AssociationConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged
{
#region DynamicTypeDescriptor
internal override bool IsReadOnly
{
get { return _Association == null; }
}
#endregion
#region XML
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
#endregion
#region Constructors
private Association _Association;
public AssociationConfig(Association association)
{
_Association = association;
string xml = association.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
private AssociationInfo _AssociationInfo;
public AssociationConfig(AssociationInfo association)
{
_AssociationInfo = association;
string xml = association.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
public AssociationConfig(string xml)
{
_Xp = new XMLProperties(xml);
}
public AssociationConfig()
{
string xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
internal string GetValue(string group, string item)
{
return _Xp[group, item];
}
#endregion
public Association MyAssociation
{ get { return _Association; } }
#region RODefaults // From proc.ini
[Category("Referenced Objects")]
[DisplayName("Default RO Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Setpoint Prefix")]
public string RODefaults_setpointprefix
{
get
{
string s = _Xp["RODefaults", "Setpoint"];// get the saved value
return s;
}
set
{
_Xp["RODefaults", "Setpoint"] = value; // save selected value
OnPropertyChanged("RODefaults_setpointprefix");
}
}
[Category("Referenced Objects")]
[DisplayName("Default Graphics Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Graphics Prefix")]
public string RODefaults_graphicsprefix
{
get
{
string s = _Xp["RODefaults", "Graphics"];// get the saved value
return s;
}
set
{
_Xp["RODefaults", "Graphics"] = value; // save selected value
}
}
#endregion
#region ROUpdate
[Category("RO Update")]
[DisplayName("Last Completed")]
[RefreshProperties(RefreshProperties.All)]
[Description("Last RO Update Completed")]
public string ROUpdate_LastCompleted
{
get
{
string s = _Xp["ROUpdate", "LastCompleted"];// get the saved value
return s;
}
set
{
_Xp["ROUpdate", "LastCompleted"] = value; // save selected value
}
}
#endregion // ROUpdate
#region ToString
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<Config/>" || s == "<Config></config>") return string.Empty;
return s;
}
#endregion
}
}
@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class AssociationConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged
{
#region DynamicTypeDescriptor
internal override bool IsReadOnly
{
get { return _Association == null; }
}
#endregion
#region XML
private XMLProperties _Xp;
private XMLProperties Xp
{
get { return _Xp; }
}
#endregion
#region Constructors
private Association _Association;
public AssociationConfig(Association association)
{
_Association = association;
string xml = association.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
private AssociationInfo _AssociationInfo;
public AssociationConfig(AssociationInfo association)
{
_AssociationInfo = association;
string xml = association.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
public AssociationConfig(string xml)
{
_Xp = new XMLProperties(xml);
}
public AssociationConfig()
{
string xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
internal string GetValue(string group, string item)
{
return _Xp[group, item];
}
#endregion
public Association MyAssociation
{ get { return _Association; } }
#region RODefaults // From proc.ini
[Category("Referenced Objects")]
[DisplayName("Default RO Prefix")]
[RefreshProperties(RefreshProperties.All)]
[Description("Setpoint Prefix")]
public string RODefaults_setpointprefix
{
get
{
string s = _Xp["RODefaults", "Setpoint"];// get the saved value
return s;
}
set
{
_Xp["RODefaults", "Setpoint"] = value; // save selected value
OnPropertyChanged("RODefaults_setpointprefix");
}
}
#endregion
#region ROUpdate
[Category("RO Update")]
[DisplayName("Last Completed")]
[RefreshProperties(RefreshProperties.All)]
[Description("Last RO Update Completed")]
public string ROUpdate_LastCompleted
{
get
{
string s = _Xp["ROUpdate", "LastCompleted"];// get the saved value
return s;
}
set
{
_Xp["ROUpdate", "LastCompleted"] = value; // save selected value
}
}
#endregion // ROUpdate
#region ToString
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<Config/>" || s == "<Config></config>") return string.Empty;
return s;
}
#endregion
}
}
@@ -0,0 +1,798 @@
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 : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig
{
#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
//PROPGRID: Hide ParentLookup
[Browsable(false)]
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
//PROPGRID: Needed to comment out [NonSerialized] in order to hide AncestorLookup from property grid
//[NonSerialized]
//private bool _AncestorLookup;
////PROPGRID: Hide AncestorLookup
//[Browsable(false)]
//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.MyProcedureInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
{
if (args.AncestorLookup || ParentLookup)
{
string retval;
// There may be levels of procedures, i.e. procedures within a procedure.
ProcedureInfo proc = _Procedure != null ? _Procedure.MyProcedureInfo : _ProcedureInfo;
while (proc.ActiveParent.IsProcedure)
{
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
proc = (ProcedureInfo)proc.ActiveParent;
}
DocVersionInfo docVersion = proc.ActiveParent as DocVersionInfo;
if (docVersion == null) return string.Empty;
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;
}
//private string Xp_LookInAncestorFolderInfo(object sender, XMLPropertiesArgs args)
//{
// if (args.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);
_Xp.AncestorLookup = true;
if (procedureInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private int _SelectedSlave = 0;
//[Browsable(false)]
public int SelectedSlave
{
get { return _SelectedSlave; }
set { _SelectedSlave = value; }
}
public ProcedureConfig(string xml)
{
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
//public ProcedureConfig()
//{
// _Xp = new XMLProperties();
//}
public string GetValue(string group, string item)
{
return _Xp[group, item];
}
public void SetValue(string group, string item, string newvalue)
{
_Xp[group, item] = newvalue;
}
#endregion
#region Local Properties
[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("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")]
//PROPGRID: Hide Old Sequence
[Browsable(false)]
[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")]
//PROPGRID: Hide Dirty
[Browsable(false)]
[DisplayName("Dirty")]
[Description("Dirty")]
public bool Dirty
{
get { return (_Procedure != null ? _Procedure.IsDirty : false); }
}
[Category("Format Settings")]
[DisplayName("Format")]
[Description("Format")]
[TypeConverter(typeof(FormatList))]
public string FormatSelection
{
get
{
if (_Procedure != null && _Procedure.MyContent.MyFormat != null) return _Procedure.MyContent.MyFormat.FullName; //.PlantFormat.FormatData.Name;
if (_ProcedureInfo != null && _ProcedureInfo.MyContent.MyFormat != null) return _ProcedureInfo.MyContent.MyFormat.FullName;//.PlantFormat.FormatData.Name;
return null;
}
set
{
if (_Procedure != null)
{
_Procedure.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
//_Procedure.ActiveFormat = null;
}
}
}
[Category("Format Settings")]
[DisplayName("Default Format")]
[Description("Default Format")]
[TypeConverter(typeof(FormatList))]
public string DefaultFormatSelection
{
get
{
if (_Procedure != null && _Procedure.MyProcedureInfo.ActiveParent != null && _Procedure.MyProcedureInfo.ActiveParent.ActiveFormat != null) return _Procedure.MyProcedureInfo.ActiveParent.ActiveFormat.FullName;
if (_ProcedureInfo != null && _ProcedureInfo.MyParent != null && _ProcedureInfo.MyParent.ActiveFormat != null) return _ProcedureInfo.MyParent.ActiveFormat.FullName;
return null;
}
}
public Procedure MyProcedure
{ get { return _Procedure; } }
#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("Dual Column")]
// TwoColumn,
// [Description("Triple Column")]
// ThreeColumn,
// [Description("Quad Column")]
// FourColumns
//}
[Category("General")]
[DisplayName("Default Column Mode")]
[RefreshProperties(RefreshProperties.All)]
[Description("Column Layout")]
public FormatColumns Format_Columns
{
get
{
string s = _Xp["Format", "Columns"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("Format", "Columns"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return FormatColumns.TwoColumn;// At the procedure level, default to Two column
return (FormatColumns)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("Format", "Columns"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(FormatColumns.Default)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["Format", "Columns"] = string.Empty; // reset to parent value
else
_Xp["Format", "Columns"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Format_Columns");
}
}
[Category("Format")]
//PROPGRID: Hide Plant Format Name (using Format and Default Format)
[Browsable(false)]
[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 // originally from first entry in fix file and curset.dat
[Category("Print Settings")] //Note that this print setting is stored under 'Procedure' element
[Browsable(false)]
[DisplayName("Revision Number")]
[RefreshProperties(RefreshProperties.All)]
[Description("Revision Number")]
public string Print_Rev
{
get
{
string s = _Xp["Procedure", "Rev"];
if (SelectedSlave > 0)
s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Rev"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "Rev"] = value; // save selected value
else
_Xp["Procedure", "Rev"] = value;
OnPropertyChanged("Print_Rev");
}
}
[Category("Print Settings")] //Note that this print setting is stored under 'Procedure' element
[Browsable(false)]
[DisplayName("Revision Date")]
[RefreshProperties(RefreshProperties.All)]
[Description("Revision Date")]
public string Print_RevDate
{
get
{
string s = _Xp["Procedure", "RevDate"];
if (SelectedSlave > 0)
s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "RevDate"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "RevDate"] = value; // save selected value
else
_Xp["Procedure", "RevDate"] = value;
OnPropertyChanged("Print_RevDate");
}
}
[Category("Print Settings")] //Note that this print setting is stored under 'Procedure' element
[Browsable(false)]
[DisplayName("Review Date")]
[RefreshProperties(RefreshProperties.All)]
[Description("Review Date")]
public string Print_ReviewDate
{
get
{
string s = _Xp["Procedure", "ReviewDate"];
if (SelectedSlave > 0)
s = _Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ReviewDate"];
return s;
}
set
{
if (SelectedSlave > 0)
_Xp["Slave[@index='" + SelectedSlave.ToString() + "']", "ReviewDate"] = value; // save selected value
else
_Xp["Procedure", "ReviewDate"] = value;
OnPropertyChanged("Print_ReviewDate");
}
}
[Category("Print Settings")]
//PROPGRID: Hide Number of Copies
[Browsable(false)]
[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 there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "Pagination"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintPagination.Auto;// default to volian default
return (PrintPagination)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "Pagination"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintPagination.Auto)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "Pagination"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "Pagination"] = ((int)value).ToString(); // save selected value
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 there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "Watermark"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintWatermark.Draft;// default to volian default
return (PrintWatermark)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "Watermark"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintWatermark.Draft)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "Watermark"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "Watermark"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_Watermark");
}
}
[Category("Print Settings")]
[DisplayName("Disable Automatic Duplexing")]
[RefreshProperties(RefreshProperties.All)]
[Description("Disable Duplex Printing")]
public bool Print_DisableDuplex
{
get
{
string s = _Xp["PrintSettings", "disableduplex"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "disableduplex"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "false";// default to volian default
return bool.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "disableduplex"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "false";
if (parval.Equals(value.ToString()))
_Xp["PrintSettings", "disableduplex"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "disableduplex"] = value.ToString(); // save selected value
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
//}
[Category("Format Settings")]
[DisplayName("Change Bar")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Use")]
public PrintChangeBar Print_ChangeBar
{
get
{
string s = _Xp["PrintSettings", "ChangeBar"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBar"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBar.SelectBeforePrinting;// default to volian default
return (PrintChangeBar)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBar"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBar.SelectBeforePrinting)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBar"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString(); // save selected value
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("Format Settings")]
[DisplayName("Change Bar Position")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Specified Change Bar Location")]
public PrintChangeBarLoc Print_ChangeBarLoc
{
get
{
string s = _Xp["PrintSettings", "ChangeBarLoc"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBarLoc"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBarLoc.WithText;// default to volian default
return (PrintChangeBarLoc)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBarLoc"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBarLoc.WithText)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBarLoc"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString(); // save selected value
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("Format Settings")]
[DisplayName("Change Bar Text Type")]
[RefreshProperties(RefreshProperties.All)]
[Description("Change Bar Text")]
public PrintChangeBarText Print_ChangeBarText
{
get
{
string s = _Xp["PrintSettings", "ChangeBarText"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "ChangeBarText"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
return PrintChangeBarText.DateChgID;// default to volian default
return (PrintChangeBarText)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "ChangeBarText"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = ((int)(PrintChangeBarText.DateChgID)).ToString();
if (parval.Equals(((int)value).ToString()))
_Xp["PrintSettings", "ChangeBarText"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_ChangeBarText");
}
}
[Category("Print Settings")]
//PROPGRID: Hide User Format
[Browsable(false)]
[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("Format Settings")]
[DisplayName("Custom Change Bar Message Line One")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message1")]
public string Print_UserCBMess1
{
get
{
string s = _Xp["PrintSettings", "usercbmess1"];// get the saved value
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "usercbmess1"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "";// default to volian default
return s;
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "usercbmess1"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "";
if (parval.Equals(value))
_Xp["PrintSettings", "usercbmess1"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "usercbmess1"] = value; // save selected value
OnPropertyChanged("Print_UserCBMess1");
}
}
[Category("Format Settings")]
[DisplayName("Custom Change Bar Message Line Two")]
[RefreshProperties(RefreshProperties.All)]
[Description("User Change Bar Message2")]
public string Print_UserCBMess2
{
get
{
string s = _Xp["PrintSettings", "usercbmess2"];// get the saved value
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("PrintSettings", "usercbmess2"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
s = "";// default to volian default
return s;
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("PrintSettings", "usercbmess2"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
parval = "";
if (parval.Equals(value))
_Xp["PrintSettings", "usercbmess2"] = string.Empty; // reset to parent value
else
_Xp["PrintSettings", "usercbmess2"] = value; // save selected value
OnPropertyChanged("Print_UserCBMess2");
}
}
// the following is for internal use only:
[Browsable(false)]
public string SectionStart
{
get
{
return _Xp["Procedure", "SectionStart"];
}
set
{
_Xp["Procedure", "SectionStart"] = value;
OnPropertyChanged("Proceduret_SectionStart");
}
}
#endregion
#region IItemConfig Members
[Category("Master/Slave Settings")]
[DisplayName("Applicability")]
[RefreshProperties(RefreshProperties.All)]
[Description("Scope Applicability")]
public Volian.Base.Library.BigNum MasterSlave_Applicability
{
get
{
string s = _Xp["MasterSlave", "Applicability"];
return new Volian.Base.Library.BigNum(s);
}
set
{
_Xp["MasterSlave", "Applicability"] = value.FlagList;
OnPropertyChanged("MasterSlave_Applicability");
}
}
#endregion
}
public interface IItemConfig
{
Volian.Base.Library.BigNum MasterSlave_Applicability { get; set;}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,777 @@
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 : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig
{
#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
//PROPGRID: Hide ParentLookup
[Browsable(false)]
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
//PROPGRID: Had to comment out NonSerialized to hide AncestorLookup from Property Grid
//[NonSerialized]
private bool _AncestorLookup;
//PROPGRID: Hide AncestorLookup
//[Browsable(false)]
//public bool AncestorLookup
//{
// get { return _AncestorLookup; }
// set { _AncestorLookup = value; }
//}
private Section _Section;
private SectionInfo _SectionInfo;
private static int _SectionConfigUnique = 0;
private static int SectionConfigUnique
{ get { return ++_SectionConfigUnique; } }
private int _MySectionConfigUnique = SectionConfigUnique;
public int MySectionConfigUnique // Absolutely Unique ID - Info
{ get { return _MySectionConfigUnique; } }
public SectionConfig(Section section)
{
_Section = section;
string xml = section.MyContent.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
if (section.MySectionInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
{
if (args.AncestorLookup || ParentLookup)
{
string retval;
// There may be levels of sections, i.e. sections within a section.
SectionInfo sect = _Section != null ? _Section.MySectionInfo : _SectionInfo;
while (sect.ActiveParent.IsSection)
{
retval = sect.SectionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
sect = (sect.ActiveParent as SectionInfo) ?? SectionInfo.Get((sect.ActiveParent as ItemInfo).ItemID);
}
// There may be levels of procedures, i.e. procedures within a procedure.
ProcedureInfo proc = sect.MyProcedure;
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
while (proc.ActiveParent.IsProcedure)
{
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
proc = (ProcedureInfo)proc.ActiveParent;
}
DocVersionInfo docVersion = proc.ActiveParent as DocVersionInfo;
if (docVersion == null) return string.Empty;
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);
if (_SectionInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
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")]
//PROPGRID: Hide Old Sequence
[Browsable(false)]
[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")]
//PROPGRID: Hide Dirty
[Browsable(false)]
[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 (_Section != null && _Section.MyContent.MyFormat != null) return _Section.MyContent.MyFormat.FullName;
if (_SectionInfo != null && _SectionInfo.MyContent.MyFormat != null) return _SectionInfo.MyContent.MyFormat.FullName;
return null;
}
set
{
if (_Section != null)
{
_Section.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
//_Section.ActiveFormat = null;
DocStyleListConverter.MySection = _Section;
}
}
}
[Browsable(false)]
public FormatInfo MyFormat
{
get
{
if (_Section != null)
{
SectionInfo sectionInfo = SectionInfo.Get(_Section.ItemID);
return sectionInfo.LocalFormat;
}
if (_SectionInfo != null)return _SectionInfo.LocalFormat;
return null;
}
set
{
if (_Section != null)
_Section.MyContent.MyFormat = value == null ? null : value.GetJustFormat();
}
}
[Category("Format")]
[DisplayName("Default Format")]
[Description("Default Format")]
[TypeConverter(typeof(FormatList))]
public string DefaultFormatSelection
{
get
{
if (_Section != null && _Section.MySectionInfo.ActiveParent != null && _Section.MySectionInfo.ActiveParent.ActiveFormat != null) return _Section.MySectionInfo.ActiveParent.ActiveFormat.FullName;
if (_SectionInfo != null && _SectionInfo.MyParent != null && _SectionInfo.MyParent.ActiveFormat != null) return _SectionInfo.MyParent.ActiveFormat.FullName;
return null;
}
}
[Browsable(false)]
public FormatInfo MyDefaultFormat
{
get
{
if (_Section != null) return _Section.MySectionInfo.ActiveParent.ActiveFormat;
return _SectionInfo.ActiveParent.ActiveFormat;
}
}
//[Browsable(false)]
[Category("Format")]
[DisplayName("Section Type")]
[Description("Section Type")]
[TypeConverter(typeof(DocStyleListConverter))]
public string MySectionType
{
get
{
if (_Section != null)
{
return DocStyleListConverter.ToString(_Section.MyContent.Type);
}
return string.Empty;
}
set
{
if (_Section != null)
_Section.MyContent.Type = DocStyleListConverter.ToSectionType(value);
}
}
[Browsable(false)]
public int? SectionType
{
get
{
if (_Section != null)
{
return _Section.MyContent.Type-10000;
}
return null;
}
set
{
if (_Section != null)
_Section.MyContent.Type = value+10000;
}
}
public Section MySection
{ get { return _Section; } }
[Category("Format")]
[DisplayName("Keep Word Document Margins")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section WordMargin")]
public string Section_WordMargin
{
get
{
string tmp = _Xp["Section", "WordMargin"];
return tmp == null || tmp == "" ? "N" : tmp;
}
set
{
_Xp["Section", "WordMargin"] = value;
OnPropertyChanged("Section_WordMargin");
}
}
#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.
[TypeConverter(typeof(EnumDescConverter))]
public enum SectionPagination : int
{
//Default = 0, Continuous, Separate
Continuous = 1, Separate = 2
}
[Category("Format")]
[DisplayName("Section Pagination")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section Pagination")]
public SectionPagination Section_Pagination
{
get
{
string s = _Xp["Section", "Pagination"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("Section", "Pagination"); // get the parent value
//If there is no parent value, then use the volian default
if (s == string.Empty)
{
if (MyFormat != null)
{
bool rval = MyFormat.MyStepSectionLayoutData.BreakOnSections;
return (rval) ? SectionPagination.Separate : SectionPagination.Continuous;// default to volian default
}
else
{
bool rval = MyDefaultFormat.MyStepSectionLayoutData.BreakOnSections;
return (rval) ? SectionPagination.Separate : SectionPagination.Continuous;// default to volian default
}
}
return (SectionPagination)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("Section", "Pagination"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
{
bool rval = _Section.MySectionInfo.ActiveFormat.MyStepSectionLayoutData.BreakOnSections;
parval = (rval) ? ((int)(SectionPagination.Separate)).ToString() : ((int)(SectionPagination.Continuous)).ToString();
//parval = ((int)(SectionPagination.Default)).ToString();
}
if (parval.Equals(((int)value).ToString()))
_Xp["Section", "Pagination"] = string.Empty; // reset to parent value
else
_Xp["Section", "Pagination"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Section_Pagination");
}
}
[Category("View Settings")]
//PROPGRID: Hide Include in Background/Deviation
[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("General")]
//PROPGRID: Hide Include On Table Of Contents
[DisplayName("Include On Table Of Contents")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section TOC")]
public string Section_TOC
{
get
{
string tmp = _Xp["Section", "TOC"];
return tmp == null || tmp == "" ? "N" : tmp;
}
set
{
_Xp["Section", "TOC"] = value;
OnPropertyChanged("Section_TOC");
}
}
[Category("Section")]
//PROPGRID: Hide AutoGen
[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")]
//PROPGRID: Hide Subsection PH
[DisplayName("Section PrintHdr")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section PrintHdr")]
public string Section_PrintHdr
{
get
{
// if null - return a "Y"
string tmp = _Xp["Section", "PrintHdr"];
return tmp == null || tmp == "" ? "Y" : tmp;
}
set
{
_Xp["Section", "PrintHdr"] = value;
OnPropertyChanged("Section_PrintHdr");
}
}
[Browsable(false)]
[DisplayName("Section OriginalSteps")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section OriginalSteps")]
public string Section_OriginalSteps
{
get
{
return _Xp["Section", "OriginalSteps"];
}
set
{
_Xp["Section", "OriginalSteps"] = value;
OnPropertyChanged("Section_OriginalSteps");
}
}
[Category("Section")]
//PROPGRID: Hide Section NumPages
[Browsable(false)]
[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");
}
}
[TypeConverter(typeof(EnumDescConverter))]
public enum SectionColumnMode : int
{
//[Description("Format Default")]
//Default = 0,
[Description("Single Column")]
One = 1,
[Description("Dual Column")]
Two = 2,
[Description("Triple Column")]
Three = 3,
[Description("Quad Column")]
Four = 4
}
[Category("Format")]
[DisplayName("Columns")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section ColumnMode")]
public SectionColumnMode Section_ColumnMode
{
get
{
string s = _Xp["Section", "ColumnMode"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("Section", "ColumnMode"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
{
int rval = 0;
if (MyFormat != null)
{
rval = (int)MyFormat.MyStepSectionLayoutData.PMode;
//int rval = (int)MyFormat.MyStepSectionLayoutData.PMode;
//return (SectionColumnMode)rval;//SectionColumnMode.Two; //SectionColumnMode.Default;// default to volian default
}
else
{
//int rval = (int)MyDefaultFormat.MyStepSectionLayoutData.PMode;
rval = (int)MyDefaultFormat.MyStepSectionLayoutData.PMode;
//return (SectionColumnMode)rval;
}
// if no pmode is defined, i.e. rval = 0, then go up to the procedure level & get
// it's format column.
if (rval == 0)
{
SectionInfo si = _SectionInfo != null? _SectionInfo: SectionInfo.Get(_Section.ItemID);
if (si != null)
{
switch (si.MyProcedure.ProcedureConfig.Format_Columns)
{
case FormatColumns.OneColumn:
return SectionColumnMode.One;
break;
case FormatColumns.TwoColumn:
return SectionColumnMode.Two;
break;
default:
return SectionColumnMode.One;
break;
}
}
else
return SectionColumnMode.One; // 16bit's default if nothing defined
}
return (SectionColumnMode)rval;
}
else
return (SectionColumnMode)int.Parse(s);
//if (s == string.Empty)
// return SectionColumnMode.Default;
//return (SectionColumnMode)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("Section", "ColumnMode"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
{
int rval = 0;
// Use Inherited Format (ActiveFormat for Section) if MyFormat is Null
if (MyFormat == null)
{
FormatInfo myFormat = _Section == null ? _SectionInfo.ActiveFormat : SectionInfo.Get(_Section.ItemID).ActiveFormat;
rval = (int)myFormat.MyStepSectionLayoutData.PMode;
}
else
rval =(int)MyFormat.MyStepSectionLayoutData.PMode;
parval = ((rval > 0)?((SectionColumnMode)rval).ToString() : "2"); // if PMode is zero default to 2 column mode
//parval = ((SectionColumnMode)rval).ToString();
//parval = ((int)(SectionColumnMode.Default)).ToString();
}
if (parval.Equals(((int)value).ToString()))
_Xp["Section", "ColumnMode"] = string.Empty; // reset to parent value
else
_Xp["Section", "ColumnMode"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Section_ColumnMode");
}
}
//char * far printtypes[] = {
// "Compressed, 8 lines per inch",
// "Elite, 6 lines per inch",
// "Pica, 6 lines per inch",
// "Default font, 4 Lines Per Inch",
// "Default font, 6 Lines Per Inch",
// "Compressed 6 LPI",
// "Default font, 7 Lines Per Inch",
// "Special Landscape, Elite, 6 lines per inch"
//};
//[TypeConverter(typeof(EnumDescConverter))]
//public enum AttPrintSize : int
//{
// [Description("Compressed, 8 lines per inch")]
// Cmp8lpi = 0,
// [Description("Elite, 6 lines per inch")]
// Elite6lpi = 1,
// [Description("Pica, 6 lines per inch")]
// Pica6lpi = 2,
// [Description("Default font, 4 Lines Per Inch")]
// Def4lpi = 3,
// [Description("Default font, 6 Lines Per Inch")]
// Def6lpi = 4,
// [Description("Compressed 6 LPI")]
// Cmp6lpi = 5,
// [Description("Default font, 7 Lines Per Inch")]
// Def7lpi = 6,
// [Description("Landscape, Elite, 6 lines per inch")]
// landElite6lpi = 7
//}
//[Category("Format")]
//[DisplayName("Attachment PrintSize")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Attachment Print Size")]
//public AttPrintSize Section_AttachmentPrintSize
//{
// get
// {
// string lpiSettings = "*pP46f7L";
// string s = _Xp["Section", "OldType"];
// int idx = -1;
// //If there is no value to get, then get the parent value (a.k.a. default value).
// if (s == string.Empty)
// s = _Xp.ParentValue("Section", "OldType"); // get the parent value
// // If there is no parent value, then use the volian default
// if (s == string.Empty)
// return AttPrintSize.Def6lpi;// default to volian default
// idx = lpiSettings.IndexOf(s[1]);
// if (idx == -1) idx = 4;
// return (AttPrintSize)idx;
// //return (AttPrintSize)int.Parse(s);
// }
// set
// {
// // if value being saved is same as the parent value, then clear the value (save blank). This will
// // reset the data to use the parent value.
// string lpiSettings = "*pP46f7L";
// string parval = _Xp.ParentValue("Section", "OldType"); // get the parent value
// StringBuilder sb = new StringBuilder();
// string curval = parval[1].ToString();
// sb.Append(parval[0]); // save first part of OldType
// if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
// {
// //parval = ((int)(AttPrintSize.Def6lpi)).ToString();
// //sb.Append(((int)(AttPrintSize.Def6lpi)).ToString());
// sb.Append(lpiSettings[(int)(AttPrintSize.Def6lpi)]);
// }
// if (curval.Equals(((int)value).ToString()))
// _Xp["Section", "OldType"] = string.Empty; // reset to parent value
// else
// {
// //sb.Append(((int)value).ToString());
// sb.Append(lpiSettings[(int)value]);
// _Xp["Section", "OldType"] = sb.ToString(); // save selected value
// }
// OnPropertyChanged("Section_AttachmentPrintSize");
// }
//}
/*
int chkOffType = (rid[0] & 0x007F) - '0';
if (chkOffType > 0)
ci.AddItem("Section", "CheckoffSelection", chkOffType.ToString());
if (stype.Length > 1)
{
int chkOffHeading = (stype[1] & 0x007F) - '0';
if (chkOffHeading > 0)
ci.AddItem("Section", "CheckoffHeading", chkOffHeading.ToString());
*/
[Category("Format")]
[DisplayName("Checkoff List Selection")]
[Description("Checkoff List Selection")]
public int Section_CheckoffListSelection
{
get
{
string s = _Xp["Section", "CheckoffSelection"];
if (s != null && !s.Equals(string.Empty))
return Convert.ToInt32(s);
return 0;
}
set
{
string s = value.ToString();
_Xp["Section", "CheckoffSelection"] = s;
}
}
[Category("Format")]
[DisplayName("Checkoff Header Selection")]
[RefreshProperties(RefreshProperties.All)]
[Description("Checkoff Header Selection")]
public int Section_CheckoffHeaderSelection
{
get
{
string s = _Xp["Section", "CheckoffHeading"];
if (s != null && !s.Equals(string.Empty))
return Convert.ToInt32(s);
return 0;
}
set
{
string s = value.ToString();
_Xp["Section", "CheckoffHeading"] = s;
}
}
#endregion
#region SubSectionCategory // from sequence number in 16-bit database.
[Category("SubSection")]
//PROPGRID: Hide SubSection Edit
[Browsable(false)]
[DisplayName("SubSection Edit")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection Edit")]
public string SubSection_Edit
{
get
{
// if null - return a "Y"
string tmp = _Xp["SubSection", "Edit"];
return tmp == null || tmp == "" ? "N" : tmp;
}
set
{
_Xp["SubSection", "Edit"] = value;
OnPropertyChanged("SubSection_Edit");
}
}
[Category("SubSection")]
//PROPGRID: Hide Subsection AutoIndent
[Browsable(false)]
[DisplayName("SubSection AutoIndent")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection AutoIndent")]
public string SubSection_AutoIndent
{
get
{
// if null - return a "Y"
string tmp = _Xp["SubSection", "AutoIndent"];
return tmp==null||tmp==""?"Y":tmp;
}
set
{
_Xp["SubSection", "AutoIndent"] = value;
OnPropertyChanged("SubSection_AutoIndent");
}
}
#endregion
#region LibDocCategory // from library document file during migration
[Category("LibraryDocument")]
//PROPGRID: Hide Libary Document Comment
[Browsable(false)]
[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
#region IItemConfig Members
[Category("Master/Slave Settings")]
[DisplayName("Applicability")]
[RefreshProperties(RefreshProperties.All)]
[Description("Scope Applicability")]
public Volian.Base.Library.BigNum MasterSlave_Applicability
{
get
{
string s = _Xp["MasterSlave", "Applicability"];
return new Volian.Base.Library.BigNum(s);
}
set
{
_Xp["MasterSlave", "Applicability"] = value.FlagList;
OnPropertyChanged("MasterSlave_Applicability");
}
}
#endregion
}
}
@@ -0,0 +1,753 @@
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 : ConfigDynamicTypeDescriptor, INotifyPropertyChanged
{
#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
//PROPGRID: Hide ParentLookup
[Browsable(false)]
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
//PROPGRID: Had to comment out NonSerialized to hide AncestorLookup from Property Grid
//[NonSerialized]
private bool _AncestorLookup;
//PROPGRID: Hide AncestorLookup
//[Browsable(false)]
//public bool AncestorLookup
//{
// get { return _AncestorLookup; }
// set { _AncestorLookup = value; }
//}
private Section _Section;
private SectionInfo _SectionInfo;
private static int _SectionConfigUnique = 0;
private static int SectionConfigUnique
{ get { return ++_SectionConfigUnique; } }
private int _MySectionConfigUnique = SectionConfigUnique;
public int MySectionConfigUnique // Absolutely Unique ID - Info
{ get { return _MySectionConfigUnique; } }
public SectionConfig(Section section)
{
_Section = section;
string xml = section.MyContent.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
if (section.MySectionInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
private string Xp_LookInAncestorFolder(object sender, XMLPropertiesArgs args)
{
if (args.AncestorLookup || ParentLookup)
{
string retval;
SectionInfo sect = _Section != null ? _Section.MySectionInfo : _SectionInfo;
while (sect.ActiveParent.GetType() == typeof(SectionInfo))
{
retval = sect.SectionConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
sect = (SectionInfo)sect.ActiveParent;
}
ProcedureInfo proc = ProcedureInfo.Get(((ItemInfo)sect.ActiveParent).ItemID);
//ProcedureInfo proc = (ProcedureInfo)sect.ActiveParent;
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
while (proc.ActiveParent.GetType() == typeof(ProcedureInfo))
{
retval = proc.ProcedureConfig.GetValue(args.Group, args.Item);
if (retval != string.Empty) return retval;
proc = (ProcedureInfo)proc.ActiveParent;
}
DocVersionInfo docVersion = proc.ActiveParent as DocVersionInfo;
if (docVersion == null) return string.Empty;
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);
if (_SectionInfo.ActiveParent != null) _Xp.LookInAncestor += new XMLPropertiesEvent(Xp_LookInAncestorFolder);
}
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")]
//PROPGRID: Hide Old Sequence
[Browsable(false)]
[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")]
//PROPGRID: Hide Dirty
[Browsable(false)]
[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 (_Section != null && _Section.MyContent.MyFormat != null) return _Section.MyContent.MyFormat.FullName;
if (_SectionInfo != null && _SectionInfo.MyContent.MyFormat != null) return _SectionInfo.MyContent.MyFormat.FullName;
return null;
}
set
{
if (_Section != null)
{
_Section.MyContent.MyFormat = FormatList.ToFormat(value); // Can only be set if _DocVersion is set
//_Section.ActiveFormat = null;
DocStyleListConverter.MySection = _Section;
}
}
}
[Browsable(false)]
public FormatInfo MyFormat
{
get
{
if (_Section != null)
{
SectionInfo sectionInfo = SectionInfo.Get(_Section.ItemID);
return sectionInfo.LocalFormat;
}
if (_SectionInfo != null)return _SectionInfo.LocalFormat;
return null;
}
set
{
if (_Section != null)
_Section.MyContent.MyFormat = value == null ? null : value.Get();
}
}
[Category("Format")]
[DisplayName("Default Format")]
[Description("Default Format")]
[TypeConverter(typeof(FormatList))]
public string DefaultFormatSelection
{
get
{
if (_Section != null && _Section.MySectionInfo.ActiveParent != null && _Section.MySectionInfo.ActiveParent.ActiveFormat != null) return _Section.MySectionInfo.ActiveParent.ActiveFormat.FullName;
if (_SectionInfo != null && _SectionInfo.MyParent != null && _SectionInfo.MyParent.ActiveFormat != null) return _SectionInfo.MyParent.ActiveFormat.FullName;
return null;
}
}
[Browsable(false)]
public FormatInfo MyDefaultFormat
{
get
{
if (_Section != null) return _Section.MySectionInfo.ActiveParent.ActiveFormat;
return _SectionInfo.ActiveParent.ActiveFormat;
}
}
//[Browsable(false)]
[Category("Format")]
[DisplayName("Section Type")]
[Description("Section Type")]
[TypeConverter(typeof(DocStyleListConverter))]
public string MySectionType
{
get
{
if (_Section != null)
{
return DocStyleListConverter.ToString(_Section.MyContent.Type);
}
return string.Empty;
}
set
{
if (_Section != null)
_Section.MyContent.Type = DocStyleListConverter.ToSectionType(value);
}
}
[Browsable(false)]
public int? SectionType
{
get
{
if (_Section != null)
{
return _Section.MyContent.Type-10000;
}
return null;
}
set
{
if (_Section != null)
_Section.MyContent.Type = value+10000;
}
}
public Section MySection
{ get { return _Section; } }
[Category("Format")]
[DisplayName("Keep Word Document Margins")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section WordMargin")]
public string Section_WordMargin
{
get
{
string tmp = _Xp["Section", "WordMargin"];
return tmp == null || tmp == "" ? "N" : tmp;
}
set
{
_Xp["Section", "WordMargin"] = value;
OnPropertyChanged("Section_WordMargin");
}
}
#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.
[TypeConverter(typeof(EnumDescConverter))]
public enum SectionPagination : int
{
//Default = 0, Continuous, Separate
Continuous = 1, Separate = 2
}
[Category("Format")]
[DisplayName("Section Pagination")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section Pagination")]
public SectionPagination Section_Pagination
{
get
{
string s = _Xp["Section", "Pagination"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("Section", "Pagination"); // get the parent value
//If there is no parent value, then use the volian default
if (s == string.Empty)
{
if (MyFormat != null)
{
bool rval = MyFormat.MyStepSectionLayoutData.BreakOnSections;
return (rval) ? SectionPagination.Separate : SectionPagination.Continuous;// default to volian default
}
else
{
bool rval = MyDefaultFormat.MyStepSectionLayoutData.BreakOnSections;
return (rval) ? SectionPagination.Separate : SectionPagination.Continuous;// default to volian default
}
}
return (SectionPagination)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("Section", "Pagination"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
{
bool rval = _Section.MySectionInfo.ActiveFormat.MyStepSectionLayoutData.BreakOnSections;
parval = (rval) ? ((int)(SectionPagination.Separate)).ToString() : ((int)(SectionPagination.Continuous)).ToString();
//parval = ((int)(SectionPagination.Default)).ToString();
}
if (parval.Equals(((int)value).ToString()))
_Xp["Section", "Pagination"] = string.Empty; // reset to parent value
else
_Xp["Section", "Pagination"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Section_Pagination");
}
}
[Category("View Settings")]
//PROPGRID: Hide Include in Background/Deviation
[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("General")]
//PROPGRID: Hide Include On Table Of Contents
[DisplayName("Include On Table Of Contents")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section TOC")]
public string Section_TOC
{
get
{
string tmp = _Xp["Section", "TOC"];
return tmp == null || tmp == "" ? "N" : tmp;
}
set
{
_Xp["Section", "TOC"] = value;
OnPropertyChanged("Section_TOC");
}
}
[Category("Section")]
//PROPGRID: Hide AutoGen
[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")]
//PROPGRID: Hide Subsection PH
[DisplayName("Section PrintHdr")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section PrintHdr")]
public string Section_PrintHdr
{
get
{
// if null - return a "Y"
string tmp = _Xp["Section", "PrintHdr"];
return tmp == null || tmp == "" ? "Y" : tmp;
}
set
{
_Xp["Section", "PrintHdr"] = value;
OnPropertyChanged("Section_PrintHdr");
}
}
[Browsable(false)]
[DisplayName("Section OriginalSteps")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section OriginalSteps")]
public string Section_OriginalSteps
{
get
{
return _Xp["Section", "OriginalSteps"];
}
set
{
_Xp["Section", "OriginalSteps"] = value;
OnPropertyChanged("Section_OriginalSteps");
}
}
[Category("Section")]
//PROPGRID: Hide Section NumPages
[Browsable(false)]
[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");
}
}
[TypeConverter(typeof(EnumDescConverter))]
public enum SectionColumnMode : int
{
//[Description("Format Default")]
//Default = 0,
[Description("Single Column")]
One = 1,
[Description("Dual Column")]
Two = 2,
[Description("Triple Column")]
Three = 3,
[Description("Quad Column")]
Four = 4
}
[Category("Format")]
[DisplayName("Columns")]
[RefreshProperties(RefreshProperties.All)]
[Description("Section ColumnMode")]
public SectionColumnMode Section_ColumnMode
{
get
{
string s = _Xp["Section", "ColumnMode"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty)
s = _Xp.ParentValue("Section", "ColumnMode"); // get the parent value
// If there is no parent value, then use the volian default
if (s == string.Empty)
{
int rval = 0;
if (MyFormat != null)
{
rval = (int)MyFormat.MyStepSectionLayoutData.PMode;
//int rval = (int)MyFormat.MyStepSectionLayoutData.PMode;
//return (SectionColumnMode)rval;//SectionColumnMode.Two; //SectionColumnMode.Default;// default to volian default
}
else
{
//int rval = (int)MyDefaultFormat.MyStepSectionLayoutData.PMode;
rval = (int)MyDefaultFormat.MyStepSectionLayoutData.PMode;
//return (SectionColumnMode)rval;
}
// if no pmode is defined, i.e. rval = 0, then go up to the procedure level & get
// it's format column.
if (rval == 0)
{
SectionInfo si = _SectionInfo != null? _SectionInfo: SectionInfo.Get(_Section.ItemID);
if (si != null)
{
switch (si.MyProcedure.ProcedureConfig.Format_Columns)
{
case FormatColumns.OneColumn:
return SectionColumnMode.One;
break;
case FormatColumns.TwoColumn:
return SectionColumnMode.Two;
break;
default:
return SectionColumnMode.One;
break;
}
}
else
return SectionColumnMode.One; // 16bit's default if nothing defined
}
return (SectionColumnMode)rval;
}
else
return (SectionColumnMode)int.Parse(s);
//if (s == string.Empty)
// return SectionColumnMode.Default;
//return (SectionColumnMode)int.Parse(s);
}
set
{
// if value being saved is same as the parent value, then clear the value (save blank). This will
// reset the data to use the parent value.
string parval = _Xp.ParentValue("Section", "ColumnMode"); // get the parent value
if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
{
int rval = 0;
// Use Inherited Format (ActiveFormat for Section) if MyFormat is Null
if (MyFormat == null)
{
FormatInfo myFormat = _Section == null ? _SectionInfo.ActiveFormat : SectionInfo.Get(_Section.ItemID).ActiveFormat;
rval = (int)myFormat.MyStepSectionLayoutData.PMode;
}
else
rval =(int)MyFormat.MyStepSectionLayoutData.PMode;
parval = ((rval > 0)?((SectionColumnMode)rval).ToString() : "2"); // if PMode is zero default to 2 column mode
//parval = ((SectionColumnMode)rval).ToString();
//parval = ((int)(SectionColumnMode.Default)).ToString();
}
if (parval.Equals(((int)value).ToString()))
_Xp["Section", "ColumnMode"] = string.Empty; // reset to parent value
else
_Xp["Section", "ColumnMode"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Section_ColumnMode");
}
}
//char * far printtypes[] = {
// "Compressed, 8 lines per inch",
// "Elite, 6 lines per inch",
// "Pica, 6 lines per inch",
// "Default font, 4 Lines Per Inch",
// "Default font, 6 Lines Per Inch",
// "Compressed 6 LPI",
// "Default font, 7 Lines Per Inch",
// "Special Landscape, Elite, 6 lines per inch"
//};
//[TypeConverter(typeof(EnumDescConverter))]
//public enum AttPrintSize : int
//{
// [Description("Compressed, 8 lines per inch")]
// Cmp8lpi = 0,
// [Description("Elite, 6 lines per inch")]
// Elite6lpi = 1,
// [Description("Pica, 6 lines per inch")]
// Pica6lpi = 2,
// [Description("Default font, 4 Lines Per Inch")]
// Def4lpi = 3,
// [Description("Default font, 6 Lines Per Inch")]
// Def6lpi = 4,
// [Description("Compressed 6 LPI")]
// Cmp6lpi = 5,
// [Description("Default font, 7 Lines Per Inch")]
// Def7lpi = 6,
// [Description("Landscape, Elite, 6 lines per inch")]
// landElite6lpi = 7
//}
//[Category("Format")]
//[DisplayName("Attachment PrintSize")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Attachment Print Size")]
//public AttPrintSize Section_AttachmentPrintSize
//{
// get
// {
// string lpiSettings = "*pP46f7L";
// string s = _Xp["Section", "OldType"];
// int idx = -1;
// //If there is no value to get, then get the parent value (a.k.a. default value).
// if (s == string.Empty)
// s = _Xp.ParentValue("Section", "OldType"); // get the parent value
// // If there is no parent value, then use the volian default
// if (s == string.Empty)
// return AttPrintSize.Def6lpi;// default to volian default
// idx = lpiSettings.IndexOf(s[1]);
// if (idx == -1) idx = 4;
// return (AttPrintSize)idx;
// //return (AttPrintSize)int.Parse(s);
// }
// set
// {
// // if value being saved is same as the parent value, then clear the value (save blank). This will
// // reset the data to use the parent value.
// string lpiSettings = "*pP46f7L";
// string parval = _Xp.ParentValue("Section", "OldType"); // get the parent value
// StringBuilder sb = new StringBuilder();
// string curval = parval[1].ToString();
// sb.Append(parval[0]); // save first part of OldType
// if (parval.Equals(string.Empty)) // if the parent value is empty, then use the volian default
// {
// //parval = ((int)(AttPrintSize.Def6lpi)).ToString();
// //sb.Append(((int)(AttPrintSize.Def6lpi)).ToString());
// sb.Append(lpiSettings[(int)(AttPrintSize.Def6lpi)]);
// }
// if (curval.Equals(((int)value).ToString()))
// _Xp["Section", "OldType"] = string.Empty; // reset to parent value
// else
// {
// //sb.Append(((int)value).ToString());
// sb.Append(lpiSettings[(int)value]);
// _Xp["Section", "OldType"] = sb.ToString(); // save selected value
// }
// OnPropertyChanged("Section_AttachmentPrintSize");
// }
//}
/*
int chkOffType = (rid[0] & 0x007F) - '0';
if (chkOffType > 0)
ci.AddItem("Section", "CheckoffSelection", chkOffType.ToString());
if (stype.Length > 1)
{
int chkOffHeading = (stype[1] & 0x007F) - '0';
if (chkOffHeading > 0)
ci.AddItem("Section", "CheckoffHeading", chkOffHeading.ToString());
*/
[Category("Format")]
[DisplayName("Checkoff List Selection")]
[Description("Checkoff List Selection")]
public int Section_CheckoffListSelection
{
get
{
string s = _Xp["Section", "CheckoffSelection"];
if (s != null && !s.Equals(string.Empty))
return Convert.ToInt32(s);
return 0;
}
set
{
string s = value.ToString();
_Xp["Section", "CheckoffSelection"] = s;
}
}
[Category("Format")]
[DisplayName("Checkoff Header Selection")]
[RefreshProperties(RefreshProperties.All)]
[Description("Checkoff Header Selection")]
public int Section_CheckoffHeaderSelection
{
get
{
string s = _Xp["Section", "CheckoffHeading"];
if (s != null && !s.Equals(string.Empty))
return Convert.ToInt32(s);
return 0;
}
set
{
string s = value.ToString();
_Xp["Section", "CheckoffHeading"] = s;
}
}
#endregion
#region SubSectionCategory // from sequence number in 16-bit database.
[Category("SubSection")]
//PROPGRID: Hide SubSection Edit
[Browsable(false)]
[DisplayName("SubSection Edit")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection Edit")]
public string SubSection_Edit
{
get
{
// if null - return a "Y"
string tmp = _Xp["SubSection", "Edit"];
return tmp == null || tmp == "" ? "N" : tmp;
}
set
{
_Xp["SubSection", "Edit"] = value;
OnPropertyChanged("SubSection_Edit");
}
}
[Category("SubSection")]
//PROPGRID: Hide Subsection AutoIndent
[Browsable(false)]
[DisplayName("SubSection AutoIndent")]
[RefreshProperties(RefreshProperties.All)]
[Description("SubSection AutoIndent")]
public string SubSection_AutoIndent
{
get
{
// if null - return a "Y"
string tmp = _Xp["SubSection", "AutoIndent"];
return tmp==null||tmp==""?"Y":tmp;
}
set
{
_Xp["SubSection", "AutoIndent"] = value;
OnPropertyChanged("SubSection_AutoIndent");
}
}
#endregion
#region LibDocCategory // from library document file during migration
[Category("LibraryDocument")]
//PROPGRID: Hide Libary Document Comment
[Browsable(false)]
[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
}
}
@@ -0,0 +1,240 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DescriptiveEnum;
namespace VEPROMS.CSLA.Library
{
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class StepConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged, IItemConfig
{
#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
//PROPGRID: Hide ParentLookup
[Browsable(false)]
public bool ParentLookup
{
get { return _Xp.ParentLookup; }
set { _Xp.ParentLookup = value; }
}
//PROPGRID: Had to comment out NonSerialized to hide AncestorLookup from Property Grid
//[NonSerialized]
//private bool _AncestorLookup;
////PROPGRID: Hide AncestorLookup
//[Browsable(false)]
//public bool AncestorLookup
//{
// get { return _AncestorLookup; }
// set { _AncestorLookup = value; }
//}
private Step _Step;
private StepInfo _StepInfo;
public StepConfig(Step step)
{
_Step = step;
string xml = step.MyContent.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
public StepConfig(StepInfo stepInfo)
{
_StepInfo = stepInfo;
string xml = stepInfo.MyContent.Config;
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
public StepConfig(string xml)
{
if (xml == string.Empty) xml = "<Config/>";
_Xp = new XMLProperties(xml);
}
public StepConfig()
{
_Xp = new XMLProperties();
}
internal string GetValue(string group, string item)
{
return _Xp[group, item];
}
#endregion
#region Local Properties
#endregion
#region ToString
public override string ToString()
{
string s = _Xp.ToString();
if (s == "<Config/>" || s == "<Config></Config>") return string.Empty;
return s;
}
#endregion
#region StepAttr
//[Category("Step Attributes")]
//[DisplayName("Step Continuous Action Summary")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Step Continuous Action Summary")]
public bool Step_CAS
{
get
{
string s = _Xp["Step", "ContActSum"];
//If there is no value to get, then get the parent value (a.k.a. default value).
if (s == string.Empty) return false;
if (s == "True") return true;
return false;
}
set
{
string s = _Xp["Step", "ContActSum"];
if (value.ToString() == s) return;
_Xp["Step", "ContActSum"] = value.ToString();
OnPropertyChanged("Step_CAS");
}
}
//[Category("Step Attributes")]
//[DisplayName("Step Check Off Index")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Step Check Off Index")]
public int Step_CheckOffIndex
{
get
{
string s = _Xp["Step", "CheckOffIndex"];
if (s == string.Empty) return 0;
return int.Parse(s);
}
set
{
string s = _Xp["Step", "CheckOffIndex"];
if (value.ToString() == s) return;
_Xp["Step", "CheckOffIndex"] = value.ToString();
OnPropertyChanged("Step_CheckOffIndex");
}
}
//[Category("Step Attributes")]
//[DisplayName("Step Manual Pagebreak")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Step Manual Pagebreak")]
public bool Step_ManualPagebreak
{
get
{
string s = _Xp["Step", "ManualPagebreak"];
if (s == string.Empty) return false;
if (s == "True") return true;
return false;
}
set
{
string s = _Xp["Step", "ManualPagebreak"];
if (value.ToString() == s) return;
_Xp["Step", "ManualPagebreak"] = value.ToString();
OnPropertyChanged("Step_ManualPagebreak");
}
}
public bool Step_NewManualPagebreak
{
get
{
string s = _Xp["Step", "NewManualPagebreak"];
if (s == string.Empty) return false;
if (s == "True") return true;
return false;
}
set
{
string s = _Xp["Step", "NewManualPagebreak"];
if (value.ToString() == s) return;
_Xp["Step", "NewManualPagebreak"] = value.ToString();
OnPropertyChanged("Step_NewManualPagebreak");
}
}
//[Category("Step Attributes")]
//[DisplayName("Step Change Bar Override")]
//[RefreshProperties(RefreshProperties.All)]
//[Description("Step Change Bar Override")]
public string Step_CBOverride
{
get
{
string s = _Xp["Step", "CBOverride"];
if (s == string.Empty) return null;
return s;
}
set
{
string s = _Xp["Step", "CBOverride"];
if (value != null && value.ToString() == s) return;
if (value == null && s != null) _Xp["Step", "CBOverride"] = null;
else _Xp["Step", "CBOverride"] = value.ToString();
OnPropertyChanged("Step_CBOverride");
}
}
public string Step_MultipleChangeID
{
get
{
string s = _Xp["Step", "MultipleChangeID"];
if (s == string.Empty) return null;
return s;
}
set
{
string s = _Xp["Step", "MultipleChangeID"];
if (value != null && value.ToString() == s) return;
if (value == null && s != null) _Xp["Step", "MultipleChangeID"] = null;
else _Xp["Step", "MultipleChangeID"] = value.ToString();
OnPropertyChanged("Step_MultipleChangeID");
}
}
#endregion
#region IItemConfig Members
[Category("Master/Slave Settings")]
[DisplayName("Applicability")]
[RefreshProperties(RefreshProperties.All)]
[Description("Scope Applicability")]
public Volian.Base.Library.BigNum MasterSlave_Applicability
{
get
{
string s = _Xp["MasterSlave", "Applicability"];
return new Volian.Base.Library.BigNum(s);
}
set
{
if (value != null)
_Xp["MasterSlave", "Applicability"] = value.FlagList;
else
_Xp["MasterSlave", "Applicability"] = null;
OnPropertyChanged("MasterSlave_Applicability");
}
}
#endregion
}
}
Binary file not shown.
@@ -0,0 +1,326 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using Csla;
using Csla.Data;
namespace VEPROMS.CSLA.Library
{
public partial class AnnotationInfo
{
public override string ToString()
{
return _SearchText;
}
#region JCB Annotation Status
private bool _IsAnnotationNew = false;
public bool IsAnnotationNew
{
get
{
ProcedureInfo pi = this.MyItem.MyProcedure;
if (pi != null)
//todo figure out audit count
_IsAnnotationNew = (this.DTS > pi.DTS);
return _IsAnnotationNew;
}
}
private bool _IsAnnotationChanged;
public bool IsAnnotationChanged
{
get
{
ProcedureInfo pi = this.MyItem.MyProcedure;
if (pi != null)
{
//todo figure out audit count
_IsAnnotationChanged = (this.DTS > pi.DTS);
}
return _IsAnnotationChanged;
}
}
#endregion
}
public partial class AnnotationType
{
public override string ToString()
{
return _Name;
}
public static AnnotationType GetByName2(string name)
{
try
{
AnnotationType tmp = DataPortal.Fetch<AnnotationType>(new GetByNameCriteria(name));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationType
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationType.GetByName", ex);
}
}
[Serializable()]
protected class GetByNameCriteria
{
private string _Name;
public string Name { get { return _Name; } }
public GetByNameCriteria(string name)
{
_Name = name;
}
}
private void DataPortal_Fetch(GetByNameCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.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 = "getAnnotationTypeByName";
cm.Parameters.AddWithValue("@Name", criteria.Name);
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("AnnotationType.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationType.DataPortal_Fetch", ex);
}
}
}
public partial class AnnotationTypeInfo
{
public static List<AnnotationTypeInfo> AllList()
{
//return _AllList;
return AnnotationTypeInfo._CacheList;
}
public override string ToString()
{
return _Name;
}
public static AnnotationTypeInfo GetByName(string name)
{
try
{
AnnotationTypeInfo tmp = DataPortal.Fetch<AnnotationTypeInfo>(new GetByNameCriteria(name));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationTypeInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfo.GetByName", ex);
}
}
[Serializable()]
protected class GetByNameCriteria
{
private string _Name;
public string Name { get { return _Name; } }
public GetByNameCriteria(string name)
{
_Name = name;
}
}
private void DataPortal_Fetch(GetByNameCriteria 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 = "getAnnotationTypeByName";
cm.Parameters.AddWithValue("@Name", criteria.Name);
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);
}
}
}
public partial class AnnotationTypeInfoList
{
public static void Refresh()
{
Reset();
_AnnotationTypeInfoList = Get();
}
}
public partial class Annotation
{
/// <summary>
/// Change the annotation type and update the Annotation record
/// </summary>
/// <param name="anotypeid"></param>
public void Update(int anotypeid)
{
if (_TypeID != anotypeid)
{
_TypeID = anotypeid;
MarkDirty(); // force the record update
Save();
//Update(); // commit record to database
}
}
public void CommitChanges()
{
MarkDirty(); // force the record update
Save(true);
//Update();
}
public static void DeleteAnnotation(AnnotationInfo obj)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
try
{
// ItemInfo nextItem = item.NextItem;
// ItemInfo prevItem = item.MyPrevious;
// item.OnBeforeDelete();
DataPortal.Delete(new DeleteCriteria(obj.AnnotationID, Volian.Base.Library.VlnSettings.UserID));
AnnotationInfo.StaticOnInfoChanged();
// if (nextItem != null) // Adjust PreviousID for NextItem
// {
// ItemInfo.RefreshPrevious(nextItem.ItemID, item.PreviousID);
// // The order of the next two methods was required to fix a null reference
// // when getting myparent. This bug was found when deleting a node from the
// // tree when the RTBItem was not open (i.e. in the step editor window).
// nextItem.RefreshItemParts();
// //nextItem.ResetOrdinal(); - UpdateTransitionText calls ResetOrdinal
// nextItem.UpdateTransitionText();
// }
// else if (prevItem != null)
// {
// prevItem.RefreshNextItems();
// if (prevItem.IsCaution || prevItem.IsNote) prevItem.ResetOrdinal();
// prevItem.UpdateTransitionText();
// }
// ItemInfo.DeleteItemInfoAndChildren(item.ItemID); // Dispose ItemInfo and Children
}
catch (Exception ex)
{
Console.WriteLine("AnnotationExt: Stacktrace = {0}", ex.StackTrace);
System.Data.SqlClient.SqlException exSQL = SqlException(ex);
if (exSQL != null && exSQL.Message.Contains("###Cannot Delete Item###"))
//return false;
throw exSQL;
else
throw new DbCslaException("Error on Annotation.Delete", ex);
}
}
private static System.Data.SqlClient.SqlException SqlException(Exception ex)
{
Type sqlExType = typeof(System.Data.SqlClient.SqlException);
while (ex != null)
{
if (ex.GetType() == sqlExType) return ex as System.Data.SqlClient.SqlException;
ex = ex.InnerException;
}
return null;
}
[Serializable()]
protected class DeleteCriteria
{
private int _AnnotationID;
public int AnnotationID
{ get { return _AnnotationID; } }
private string _UserID;
public string UserID
{
get { return _UserID; }
set { _UserID = value; }
}
public DeleteCriteria(int annotationID, String userID)
{
_AnnotationID = annotationID;
_UserID = userID;
}
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(DeleteCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteAnnotationWithUserID";
cm.Parameters.AddWithValue("@AnnotationID", criteria.AnnotationID);
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Item.DataPortal_Delete", ex);
}
}
}
//public partial class AnnotationTypeAnnotations
//{
// public static int GetAnnotationID()
// {
// return AnnotationTypeAnnotat
// }
//}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,509 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
using System.Text.RegularExpressions;
namespace VEPROMS.CSLA.Library
{
public partial class Content
{
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
public void FixTransitionText(TransitionInfo tran)
{
string transText = tran.ResolvePathTo();
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != transText)
Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
{
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
if (g.ToString() != transText)
MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
}
}
}
private string GetMySuffix(int start)
{
string txt = Text.Substring(start);
int firstSlashVeeZero = txt.IndexOf(@"\v0");
if (firstSlashVeeZero == 0 && txt.Length > 3 && txt[3] == ' ') //"\v0 "
return Text.Substring(start, 4);
return Text.Substring(start, firstSlashVeeZero + 3); //everything upto \v0"
}
private string GetMyPrefix(int start, int lastIndex)
{
string defPrefix = Text.Substring(start - 3, 3);
if (defPrefix != @"\v ") throw new Exception(string.Format("rtf string {0} does not match expected format", defPrefix));
string txt = Text.Substring(lastIndex, start - lastIndex - 3);
int lastSlash = txt.LastIndexOf(@"\");
int lastSpace = txt.LastIndexOf(" ");
int lastCR = txt.LastIndexOf("\r");
if (lastSpace < lastCR)
lastSpace = lastCR;
if (lastSlash <= lastSpace) //this will return "\v "
return defPrefix;
txt = txt.Substring(lastSlash);
if(txt.StartsWith(@"\'")) //this is a hex
return defPrefix;
if (Regex.IsMatch(txt, @"\\u[0-9].*")) //this is unicode
return defPrefix;
return @"\v";
}
public string ConvertROToText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo)
{
string retval = null;
string newvalue = value;
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
int lastIndex = 0;
string newText = Text;
foreach (Match mm in ms)
{
int offset = mm.Index;
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
{
string prefix = GetMyPrefix(mm.Index, lastIndex);
string suffix = GetMySuffix(mm.Index + mm.Length);
System.Text.RegularExpressions.Group g = m.Groups[3];
string part1 = newText.Substring(0, mm.Index);
string part2 = g.Value;
string part3 = newText.Substring(mm.Index + mm.Length);
//modify part1 based on prefix
if (prefix == @"\v ")
part1 = part1.Substring(0, part1.Length - 3);
else
part1 = part1.Substring(0, part1.Length - 3) + " ";
//modify part3 based on suffix
if (suffix == @"\v0 ")
part3 = part3.Substring(4);
else
part3 = suffix.Replace(@"\v0","") + part3.Substring(suffix.Length);
System.Text.RegularExpressions.Group g2 = m.Groups[2];
if (g2.Value.StartsWith(@"\u8209?"))
{
string gg = g2.Value + " " + g.Value;
retval = gg;
part2 = retval;
}
else
//else if (g.ToString() != newvalue)
{
retval = g.Value;
part2 = retval;
}
Text = part1 + part2 + part3;
break; // Text has been processed
}
lastIndex = mm.Index + mm.Length;
}
Console.WriteLine("Text: {0} NewText: {1}", Text, newText);
// see if there is a grid to update too.
if (rousg.MyContent.MyGrid != null)
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
if (origROFstInfo != null)
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (MyGrid.Data != retlist[1])
{
MyGrid.Data = retlist[1];
retval = Text;
if (Text != retlist[0])
Text = retlist[0];
}
}
}
else
{
// if it's an ro within a table, need to process into an flex grid to save the grid data:
string findLinkXml = @"&lt;START\].*?\[END&gt;";
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
int nmsg = msg.Count;
for (int i = nmsg - 1; i >= 0; i--)
{
Match mmg = msg[i];
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
if (g.ToString() != newvalue)
{
retval = g.Value;
MyGrid.Data = MyGrid.Data.Substring(0, offset + mmg.Index + g.Index) + newvalue + MyGrid.Data.Substring(offset + mmg.Index + g.Index + g.Length);
}
}
}
}
}
return retval;
}
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
{
return FixContentText(rousg, value, rotype, origROFstInfo, null);
}
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo,string fileNameOnly) // string newvalue)
{
string retval = null;
string newvalue = value;
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
string lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{}\\]+)*( |\\u[0-9]{1,4}?|\\'[0-9a-fA-F]{2})(.*?)(\\[^v'?{} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>$", rousg.ROUsageID);
foreach (Match mm in ms)
{
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
{
int myIndex = m.Groups[4].Index + mm.Index;
int myLength = m.Groups[4].Length;
if(m.Groups[3] != " ")
{
myIndex = m.Groups[3].Index + mm.Index;
myLength += m.Groups[3].Length;
}
string gg = Text.Substring(myIndex,myLength);
if ((gg.Replace(@"\'b0", @"\'B0") != newvalue.Replace(@"\'b0", @"\'B0")) && ((fileNameOnly == null) || (gg != fileNameOnly)))
{
retval = gg;
Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
break; // Text has been processed
}
}
}
// see if there is a grid to update too.
if (rousg.MyContent.MyGrid != null)
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
if (origROFstInfo != null)
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (MyGrid.Data != retlist[1])
{
MyGrid.Data = retlist[1];
retval = Text;
if (Text != retlist[0])
Text = retlist[0];
}
}
}
else
{
// if it's an ro within a table, need to process into an flex grid to save the grid data:
string findLinkXml = @"&lt;START\].*?\[END&gt;";
//string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
string lookFor = string.Format(@"^&lt;START\](\\[^v \\]+)*\\v0(\\[^v '?{}\\]+)*( |\\u[0-9]{1,4}?|\\'[0-9a-fA-F]{2})(.*?)(\\[^v'?{} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;$", rousg.ROUsageID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
int myIndex = m.Groups[4].Index + mmg.Index;
int myLength = m.Groups[4].Length;
if (m.Groups[3] != " ")
{
myIndex = m.Groups[3].Index + mmg.Index;
myLength += m.Groups[3].Length;
}
string gg = Text.Substring(myIndex, myLength);
if (gg != newvalue)
{
retval = gg;
MyGrid.Data = MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength);
}
}
}
}
}
return retval;
}
}
public partial class ContentInfo
{
public void FixTransitionText(TransitionInfo tran)
{
string transText = tran.ResolvePathTo();
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != transText)
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
{
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != transText)
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
}
}
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup)
{
string transText = tran.ResolvePathTo(tranLookup);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != transText)
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (MyGrid != null)
{
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
if (g.ToString() != transText)
MyGrid.SetData(MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length));
}
}
}
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
{
string newvalue = value;
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
foreach (Match mm in ms)
{
int offset = mm.Index;
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != newvalue)
{
_Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
break; // Text has been processed
}
}
}
// see if there is a grid to update too.
if (MyGrid != null)
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (Text != retlist[0]) _Text = retlist[0];
//if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
}
else
{
// if it's an ro within a table, need to process into an flex grid to save the grid data:
string findLinkXml = @"&lt;START\].*?\[END&gt;";
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
//int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
Match mg = Regex.Match(mmg.Value, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
if (g.ToString() != newvalue)
{
string prefix1 = MyGrid.Data.Substring(0,mmg.Index);
string prefix2 = mmg.Value.Substring(0,g.Index);
string suffix1 = MyGrid.Data.Substring(mmg.Index + mmg.Length);
string suffix2 = mmg.Value.Substring(g.Index + g.Length);
MyGrid.SetData(prefix1 + prefix2 + newvalue + suffix2 + suffix1);
break;
}
}
}
}
}
if (_Text == string.Empty)
_Text = "?";
}
public void LoadNonCachedGrid()
{
_MyGrid = GridInfo.GetNonCached(ContentID);
//Console.WriteLine("LoadNonCachedGrid {0},{1},{2}",ContentID,_MyGrid==null,_MyContentInfoUnique);
}
public PartInfoList LocalContentParts
{
get { return _ContentParts; }
}
public void AddPart(SafeDataReader dr, ItemInfo itemInfo)
{
if (_ContentParts == null)
_ContentParts = new PartInfoList(dr, itemInfo);
else
_ContentParts.AddPartInfo(dr, itemInfo);
}
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
public void ShowChange()
{
OnChange();
}
//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);
// }
//}
internal ContentInfo(SafeDataReader dr,bool ForItem)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
try
{
ReadDataItemList(dr);
_CacheList.Add(this);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.Constructor", ex);
throw new DbCslaException("ContentInfo.Constructor", ex);
}
}
private void ReadDataItemList(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.ReadDataItemList", 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("cDTS");
_UserID = dr.GetString("cUserID");
_ContentDetailCount = dr.GetInt32("DetailCount");
_ContentEntryCount = dr.GetInt32("EntryCount");
_ContentGridCount = dr.GetInt32("GridCount");
_ContentImageCount = dr.GetInt32("ImageCount");
_ContentItemCount = dr.GetInt32("ItemCount");
_ContentPartCount = dr.GetInt32("cPartCount");
_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);
}
}
}
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);
cm.CommandTimeout = Database.DefaultTimeout;
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;
}
}
}
@@ -0,0 +1,343 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
using System.Text.RegularExpressions;
namespace VEPROMS.CSLA.Library
{
public partial class Content
{
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
public void FixTransitionText(TransitionInfo tran)
{
string transText = tran.ResolvePathTo();
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != transText)
Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
{
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
if (g.ToString() != transText)
MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
}
}
}
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
{
string newvalue = value;
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
foreach (Match mm in ms)
{
int offset = mm.Index;
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != newvalue)
{
Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
break; // Text has been processed
}
}
}
// see if there is a grid to update too.
if (rousg.MyContent.MyGrid != null)
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (Text != retlist[0]) Text = retlist[0];
if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
}
else
{
// if it's an ro within a table, need to process into an flex grid to save the grid data:
string findLinkXml = @"&lt;START\].*?\[END&gt;";
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
if (g.ToString() != newvalue)
MyGrid.Data = MyGrid.Data.Substring(0, offset + g.Index) + newvalue + MyGrid.Data.Substring(offset + g.Index + g.Length);
}
}
}
}
}
}
public partial class ContentInfo
{
public void FixTransitionText(TransitionInfo tran)
{
string transText = tran.ResolvePathTo();
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != transText)
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
{
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != transText)
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
}
}
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup)
{
string transText = tran.ResolvePathTo(tranLookup);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != transText)
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
{
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != transText)
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
}
}
}
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
{
string newvalue = value;
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
foreach (Match mm in ms)
{
int offset = mm.Index;
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != newvalue)
{
_Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
break; // Text has been processed
}
}
}
// see if there is a grid to update too.
if (rousg.MyContent.MyGrid != null)
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (Text != retlist[0]) _Text = retlist[0];
//if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
}
else
{
// if it's an ro within a table, need to process into an flex grid to save the grid data:
string findLinkXml = @"&lt;START\].*?\[END&gt;";
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != newvalue)
// MyGrid.Data = MyGrid.Data.Substring(0, offset + g.Index) + newvalue + MyGrid.Data.Substring(offset + g.Index + g.Length);
}
}
}
}
}
public PartInfoList LocalContentParts
{
get { return _ContentParts; }
}
public void AddPart(SafeDataReader dr, ItemInfo itemInfo)
{
if (_ContentParts == null)
_ContentParts = new PartInfoList(dr, itemInfo);
else
_ContentParts.AddPartInfo(dr, itemInfo);
}
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
public void ShowChange()
{
OnChange();
}
//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);
// }
//}
internal ContentInfo(SafeDataReader dr,bool ForItem)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
try
{
ReadDataItemList(dr);
_CacheList.Add(this);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.Constructor", ex);
throw new DbCslaException("ContentInfo.Constructor", ex);
}
}
private void ReadDataItemList(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.ReadDataItemList", 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("cDTS");
_UserID = dr.GetString("cUserID");
_ContentDetailCount = dr.GetInt32("DetailCount");
_ContentEntryCount = dr.GetInt32("EntryCount");
_ContentGridCount = dr.GetInt32("GridCount");
_ContentImageCount = dr.GetInt32("ImageCount");
_ContentItemCount = dr.GetInt32("ItemCount");
_ContentPartCount = dr.GetInt32("cPartCount");
_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);
}
}
}
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);
cm.CommandTimeout = Database.DefaultTimeout;
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;
}
}
}
@@ -0,0 +1,824 @@
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 _MyItemInfo;
// 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 StartText;
public string OriginalText; // compare for save to see if change.
private FormatInfo _MyFormat;
#endregion
#region Constructors
/// <summary>
/// DisplayText constructor:
/// Creates a DisplayText object that converts the database text into rtf text
/// 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.
/// bool noEdit - flags whether to edit or not (used to set data in
/// rtb as resolved replacewords for non-active rtb.
/// </summary>
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit)
{
_MyItemInfo = itemInfo;
OriginalText = itemInfo.MyContent.Text;
TextFont = GetItemFont();
string text = _MyItemInfo.MyContent.Text;
// if in print mode, view mode, or non-active richtextbox do replace words. Only if in
// actual edit mode are replace words left as is.
_MyFormat = itemInfo.ActiveFormat;
if (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) text = DoReplaceWords(text);
// adjust formatting of exponents
if (!_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers && (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit)) text = DoFortranFormat(text);
// as a precaution, convert any \~ to \u160?. This is for Hard spaces. see the commentary in the
// save portion of this code for an explanation.
text = text.Replace(@"\~", @"\u160?");
text = text.Replace(@"\r\n", @"\par ");
text = text.Replace(@"\line", @"\par");
// add colors around links:
text = Regex.Replace(text, @"(<START\].*?\\v0) ", @"$1\cf1 ");
//text = Regex.Replace(text, @"<START]\b0\v0 ", @"<START]\b0\v0\cf1 ");
int indxcf = text.IndexOf("cf1");
while (indxcf != -1)
{
int indxend = text.IndexOf(@"\v", indxcf);
text = text.Insert(indxend, @"\cf0 ");
indxcf = text.IndexOf(@"cf1", indxend);
}
// Now put symbol (for fixed fonts) or unicode font (proportional) around symbols
// These fonts are VESymbFix & Arial Unicode MS respectively, and the font table
// is actually defined in the StepRTB code.
int indxsym = text.IndexOf(@"\u");
while (indxsym != -1)
{
int incrindx = 3;
if (text[indxsym + 2] != 'l')
{
text = text.Insert(indxsym, @"\f1 ");
int indxendsym = text.IndexOfAny(@"\ ?".ToCharArray(),indxsym+5);
if (indxendsym == -1) // must be end of line:
text = text.Insert(text.Length-1,@"\f0 ");
else
{
if (text[indxendsym]=='?') indxendsym++;
text = text.Insert(indxendsym, @"\f0 "); // TODO: do I need a space??
}
incrindx = 5;
}
indxsym = text.IndexOf(@"\u",indxsym + incrindx);
}
StartText = text;
}
private string DoFortranFormat(string text)
{
if (text.IndexOf(@".E") < 0) return text;
// Look for text as n.Ey, where n can be null or a number, and y can be
// positive or negative. This translates into nx10x10y where y is
// superscripted. For example, .E3 -> x103 where 3 is superscripted
// and 10.E5 -> 10x10-5 where 5 is superscripted
string pat = @"(\d*).E([+-]*\d+)";
string retstr = text;
// for each one that needs translated:
foreach (Match m in Regex.Matches(text, pat))
{
string fnum = m.Groups[1].Value;
string supnum = m.Groups[2].Value;
string newstr = string.Format(@"{0}x10\super {1}\nosupersub ", fnum, supnum);
retstr = retstr.Replace(m.Value, newstr);
}
return retstr;
}
#endregion
#region SaveData
public bool Save(RichTextBox rtb)
{
try
{
Item itm = _MyItemInfo.Get();
// check for different text, i.e. text from this itm doesn't match
// original text, a change occurred in database, but not from this user.
if (OriginalText != itm.MyContent.Text)
{
Console.WriteLine("Save Failed because text changed outside of this edit session.");
return false;
}
// remove rtf codes that aren't defining attributes, symbols, or links
string modtext = RtfToDbText(rtb.Rtf);
if (modtext != OriginalText)
{
// if there are links, we'll need to do extra processing to see if
// there were additions, deletions or modifications.
bool haslinks = ((modtext.IndexOf(@"<START]") > -1) || (OriginalText != null && OriginalText != "" && OriginalText.IndexOf(@"<START]") > -1));
if (haslinks)
{
// Get all links in original list
RtfToDisplayTextElements(OriginalText);
List<displayLinkElement> origList = GetLinkList(DisplayTextElementList);
// now get new text into displaytext elements for comparison for links:
RtfToDisplayTextElements(rtb.Rtf);
// 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 = DteToString();
}
else
{
itm.MyContent.Text = modtext;
itm.Save();
}
if (haslinks)
{
// if new transitions/ros, we need to 'fix' the string in the embedded link to contain the
// transition or usage record.
Dictionary<int, ContentTransition> ctReplacements = BuildCtReplacements(itm.MyContent.ContentTransitions);
Dictionary<int, ContentRoUsage> roUsgReplacements = BuildRoUsgReplacements(itm.MyContent.ContentRoUsages);
itm.Save();
if (ctReplacements.Count > 0)
{
itm.MyContent.Text = FixCtReplacements(itm.MyContent.Text, ctReplacements);
itm.Save();
}
if (roUsgReplacements.Count > 0)
{
itm.MyContent.Text = FixRoUsgReplacements(itm.MyContent.Text, roUsgReplacements);
itm.Save();
}
modtext = itm.MyContent.Text;
}
OriginalText = modtext;
}
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 string DteToString()
{
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
{
displayLinkElement dle = vte as displayLinkElement;
if (vte != null) sret.Append(dle.TextAndLink);
}
}
string modtext = sret.ToString();
return modtext;
}
private string FixRoUsgReplacements(string p, Dictionary<int, ContentRoUsage> roUsgReplacements)
{
foreach (int oldid in roUsgReplacements.Keys)
{
p = p.Replace(string.Format("<CROUSGID={0}>", oldid), roUsgReplacements[oldid].ROUsageID.ToString());
}
return p;
}
private Dictionary<int, ContentRoUsage> BuildRoUsgReplacements(ContentRoUsages contentRoUsages)
{
Dictionary<int, ContentRoUsage> retval = new Dictionary<int, ContentRoUsage>();
foreach (ContentRoUsage rou in contentRoUsages)
{
if (rou.ROUsageID < 0) retval.Add(rou.ROUsageID, rou);
}
return retval;
}
private string FixCtReplacements(string p, Dictionary<int, ContentTransition> ctReplacements)
{
foreach (int oldid in ctReplacements.Keys)
{
p = p.Replace(string.Format("<CTID={0}>",oldid),ctReplacements[oldid].TransitionID.ToString());
}
return p;
}
private Dictionary<int, ContentTransition> BuildCtReplacements(ContentTransitions contentTransitions)
{
Dictionary<int, ContentTransition> retval = new Dictionary<int, ContentTransition>();
foreach (ContentTransition ct in contentTransitions)
{
if (ct.TransitionID < 0) retval.Add(ct.TransitionID, ct);
}
return retval;
}
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.ReferencedObject)
{
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 "ReferencedObject:", i.e. index in link of 17
string srecid = odte.Link.Substring(17, sp-17);
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.ReferencedObject || dte.Type == E_TextElementType.Transition || dte.Type == E_TextElementType.TransitionRange)
{
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)
{
if (dte.Type == E_TextElementType.ReferencedObject) // do ro
{
displayLinkElement l_dte = (displayLinkElement)dte;
Match m = Regex.Match(l_dte.Link, "([A-Za-z]*):(.*)");
string linkstr = m.Groups[2].Value;
string[] roparts = linkstr.Split(" ".ToCharArray());
ContentRoUsage rousg = null;
using (RODb rodb = RODb.Get(Convert.ToInt32(roparts[2])))
{
rousg = itm.MyContent.ContentRoUsages.Add(roparts[1], rodb);
}
l_dte.Link = l_dte.Link.Replace("<NewID>", string.Format("<CROUSGID={0}>", rousg.ROUsageID));
l_dte.TextAndLink = l_dte.TextAndLink.Replace("<NewID>", string.Format("<CROUSGID={0}>", rousg.ROUsageID));
break;
}
else if (dte.Type == E_TextElementType.TransitionRange || dte.Type == E_TextElementType.Transition)
{
displayLinkElement l_dte = (displayLinkElement)dte;
Match m = Regex.Match(l_dte.Link, "([A-Za-z]*):(.*)");
string linkstr = m.Groups[2].Value;
string[] tparts = linkstr.Split(" ".ToCharArray());
int type = System.Convert.ToInt32(tparts[0]);
int tr1 = System.Convert.ToInt32(tparts[2]); // tparts[1] is token for tranid
Item itm1 = Item.Get(tr1);
Item itm2 = null;
if (dte.Type == E_TextElementType.TransitionRange)
{
itm2 = Item.Get(System.Convert.ToInt32(tparts[2]));
}
else
itm2 = itm1;
ContentTransition ct = itm.MyContent.ContentTransitions.Add(itm1, itm2);
ct.TranType = type;
l_dte.Link = l_dte.Link.Replace("<NewID>", string.Format("<CTID={0}>", ct.TransitionID));
l_dte.TextAndLink = l_dte.TextAndLink.Replace("<NewID>", string.Format("<CTID={0}>", ct.TransitionID));
}
}
}
}
}
private List<displayLinkElement> GetLinkList(List<displayTextElement> locDisplayTextElementList)
{
List<displayLinkElement> retList = new List<displayLinkElement>();
foreach (displayTextElement vte in locDisplayTextElementList)
{
if (vte.Type == E_TextElementType.ReferencedObject || vte.Type == E_TextElementType.TransitionRange || vte.Type == E_TextElementType.Transition)
{
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(string text)
{
// get original text into displaytext elements for comparison for links:
if (DisplayTextElementList == null)
DisplayTextElementList = new List<displayTextElement>();
else
DisplayTextElementList.Clear();
if (text == null || text == "") return;
string noExtraRtfStr = RtfToDbText(text);
int startIndex = 0;
int index = -1;
while ((index = FindTokenChar(noExtraRtfStr, startIndex)) > -1)
{
// Do any 'plain' text that preceeds the token.
if (index > startIndex) DoTextElement(noExtraRtfStr, startIndex, index);
if (noExtraRtfStr[index + 1] == 'v')
index = DoLink(noExtraRtfStr, index);
else
index = DoSymbol(noExtraRtfStr, startIndex, index);
startIndex = index; // +1;
if (startIndex >= noExtraRtfStr.Length) break;
}
// Add any remaining text.
if (startIndex < noExtraRtfStr.Length) DoTextElement(noExtraRtfStr, startIndex, index);
}
private string RtfToDbText(string text)
{
// For hardspaces, the windows richtextbox does some 'quirky' things:
// A unicode representation of \u160? is sent INTO the rtb. Coming out,
// that \u160? was translated to a \~ (by the underlying windows rtb).
// Note that if the \~ is sent to the rtb, it is treated as a regular space,
// i.e. no longer a hardspace, and actually is converted to a regular space.
// SO, on the way out, convert any \~ to \u160?
string noExtraRtfStr = text.Replace(@"\~", @"\u160?");
// Check for two links in a row & if found, add separating rtf comment
// commands (these get removed in the richtextbox:
noExtraRtfStr = noExtraRtfStr.Replace(@"[END><START]", @"[END>\v0 \v <START]");
// 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...
noExtraRtfStr = StripRtfCommands(noExtraRtfStr);
// the indent character was translated in the richtextbox, change it back:
if (noExtraRtfStr.IndexOf(@"\'05") > -1) noExtraRtfStr = noExtraRtfStr.Replace(@"\'05", "\x05");
return noExtraRtfStr;
}
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) || ((TextFont.Style & E_Style.MmBold) > 0))
{
retval = Regex.Replace(retval, @"\\b0 ?", "");
retval = Regex.Replace(retval, @"\\b ?","");
}
if ((TextFont.Style & E_Style.Underline) > 0)
{
retval = Regex.Replace(retval, @"\\ulnone ?", "");
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 '{': // look for escape for curly braces:
return m.Value;
case '}':
return m.Value;
case 'v': // save link hidden info
if (m.Value == @"\v") return m.Value; // comment part of link
// end comment may end in space or may end in '\' if another rtf command,
// or may end at end of string. First check for space, keep it in string
// if it is there.
if (Regex.IsMatch(m.Value, @"\\v0 "))
return m.Value;
if (Regex.IsMatch(m.Value, @"\\v0"))
return m.Value;
break;
case 'l':
if (m.Value == @"\line") return m.Value;
break;
case 'p':
if (m.Value == @"\par") return @"\par";
//if (m.Value == @"\protect")
// return m.Value;
//if (m.Value == @"\protect0")
// return m.Value;
if (m.Value.Length>=6 && m.Value.Substring(0,6) == "\\par\r\n") return m.Value.Replace("\r\n", " ");
break;
case 'f': // handle fonts separately because they may or may not have a space after them
if (m.Value[2]>='0' && m.Value[2]<='9')return m.Value;
break;
}
return "";//Strip All
}
private string StripRtfCommands(string rtf)
{
// replace \{ & \} with (![ & (!] respectively and then redo at end. The curly braces
// are rtf so were getting removed and/or not handled correctly.
string retval = rtf.Replace(@"\{", @"(![");
retval = retval.Replace(@"\}", @"(!]");
// remove carriage return/newlines after \par commands (these are introduced by rtb
// for hard returns, goes into rtb as \par and comes out as \par\r\n):
retval = Regex.Replace(retval, @"\\par\r\n([^\\.*?])", "\\par $1");
retval = Regex.Replace(retval, @"\\par\r\n([\\.*?])", "\\par$1");
retval = Regex.Replace(retval, @"[\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, @"\\f[0-9] ", ""); // remove font command with ending space
retval = Regex.Replace(retval, @"\\f[0-9]", ""); // remove font command without ending space
retval = Regex.Replace(retval, @"\\[^ \\?]+", new MatchEvaluator(ReplaceRTFClause)); // take backslash xyz and evaluates them
// remove a space if there is one as the first character or the last character
if (retval[0]==' ')retval = retval.Remove(0, 1);
retval = retval.TrimEnd(' ');
// remove \r\n and \par at end of string.
if (retval.Substring(retval.Length - 2, 2) == "\r\n") retval = retval.Remove(retval.Length - 2, 2);
if (retval.Substring(retval.Length - 4, 4) == @"\par") retval = retval.Remove(retval.Length - 4, 4);
if (retval.Length == 0) return "";
if (retval.Substring(retval.Length - 2, 2) == @"\v") retval = retval.Remove(retval.Length - 2, 2);
retval = RemoveRtfStyles(retval);
retval = retval.Replace(@"(![", @"\{");
retval = retval.Replace(@"(!]", @"\}");
return retval;
}
#endregion
#region StyleData
private VE_Font GetItemFont()
{
VE_Font font = null;
FormatInfo format = _MyItemInfo.ActiveFormat;
int type = (int)_MyItemInfo.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;
}
#endregion
#region DoListElements
private int FindTokenChar(string txt, int startIndex)
{
// 'tokens' are for symbols and links (ro & transitions). symbols are represented by \u<num>
// and links are represented by \v <START]\v0 'link text'\v #'link info'[END>\v0
bool done = false;
while (!done)
{
int indx = txt.IndexOf('\\', startIndex);
if (indx < 0) 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.
if (((txt[indx + 1] == 'u' && txt[indx + 2] != 'l')) || (txt[indx + 1] == '\'')) return indx;
// see if link
if (txt[indx + 1] == 'v') return indx;
// Otherwise, get next index, must have been a slash or other rtf command.
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 int DoLink(string text, int startIndex)
{
int retval = -1;
int fnd = text.IndexOf("#Link:", startIndex);
if (text.Substring(fnd + 6, 3) == "Ref")
retval = DoRO(text, startIndex);
else
retval = DoTran(text, startIndex);
return retval;
}
private int DoRO(string text, int index)
{
displayLinkElement vte = new displayLinkElement();
vte.Type = E_TextElementType.ReferencedObject;
return DoLinkElements(text, index, vte);
}
private string FixTransition(string link, string text)
{
if (link.IndexOf("<NewID>") != -1) return text;
int transitionID = Convert.ToInt32(link.Split(" ".ToCharArray())[1]);
// Find the transition
if (_MyItemInfo.MyContent.ContentTransitionCount <= 0) return "*Resolved Transition Text*";
foreach (TransitionInfo ti in _MyItemInfo.MyContent.ContentTransitions)
{
if (ti.TransitionID == transitionID)
{
string path = ti.ResolvePathTo(_MyFormat, _MyItemInfo, ItemInfo.Get(ti.ToID), ti.RangeID==0?null:ItemInfo.Get(ti.RangeID));
return path;
}
}
return text;
}
private int DoTran(string text,int index)
{
displayLinkElement vte = new displayLinkElement();
// determine if Range by checking for "R" after Transition (otherwise ":")
int linkindx = text.IndexOf(@"#Link", index);
vte.Type = (text[linkindx+16]=='R')?E_TextElementType.TransitionRange:E_TextElementType.Transition;
return DoLinkElements(text, index, vte);
}
private int DoLinkElements(string text, int index, displayLinkElement vte)
{
// Find the 'end comment' for the <START], can't count characters
// because there may be formatting characters such as \b or \ul before
// the \v0
int linkIndx = text.IndexOf(@"#Link", index);
int endStartTknIndx = text.IndexOf(@"\v0 ", index);
int endTextIndx = text.IndexOf(@"\v ", endStartTknIndx); // find end of text
vte.Text = text.Substring(endStartTknIndx + 4, endTextIndx - endStartTknIndx - 4); // 4 for \v0
// Now get the link part. It can be terminated by a '\v0' or an [END>
int endLinkIndxV = text.IndexOf(@"\v0 ", linkIndx);
if (endLinkIndxV == -1) endLinkIndxV = text.IndexOf(@"\v0", linkIndx); // at end of string
int endLinkIndxE = text.IndexOf(@"[END>", linkIndx);
int endLinkIndx = (endLinkIndxV < endLinkIndxE) ? endLinkIndxV : endLinkIndxE;
vte.Link = text.Substring(linkIndx + 6, endLinkIndx - linkIndx - 6); // 6 for #Link:
string tmptxt = null;
if (vte.Type != E_TextElementType.ReferencedObject)
{
tmptxt = FixTransition(vte.Link, vte.Text);
vte.Text = tmptxt;
}
// Now get the entire text & link. Account for various ending possibilities:
// ends with '\v0\'; ends with '\v0 '; ends with '\v0' (end of string);
// ends with '[END>' if two in a row - will have <START]
int endToken = (endLinkIndx == endLinkIndxE)?endLinkIndx+3:text.IndexOf(@"[END>", endLinkIndx + 3); // get past end of link
int endComment = text.IndexOf(@"\v0", endToken);
int rettoken = 0;
int retlen = 4;
if (endComment + 3 == text.Length) retlen = 3;
else if (text[endComment + 3] == '\\') retlen = 3;
vte.TextAndLink = text.Substring(index, endComment - index + retlen);
rettoken = endComment + retlen;
if (vte.Type != E_TextElementType.ReferencedObject) vte.TextAndLink = vte.TextAndLink = vte.TextAndLink.Replace("(Resolved Transition Text)", tmptxt);
DisplayTextElementList.Add(vte);
return rettoken;
}
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 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)
{
ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList;
foreach (ReplaceStr rs in rsl)
{
if (_MyItemInfo.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 (_MyItemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.High)>0) replaceit = true;
else if ((_MyItemInfo.IsTable || _MyItemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.Table) > 0) replaceit = true;
else if (_MyItemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
else if (_MyItemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true;
else if (_MyItemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true;
else if (_MyItemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
else if (_MyItemInfo.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,
Transition = 1,
TransitionRange = 2,
ReferencedObject = 3,
Symbol = 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; }
}
private string _TextAndLink;
public string TextAndLink
{
get { return _TextAndLink; }
set { _TextAndLink = value; }
}
}
#endregion
}
@@ -0,0 +1,512 @@
// ========================================================================
// 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;
//using VEPROMS.Properties;
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
#region UserSettings
/// <summary>
/// These settings are set on the user interface side.
/// This is used to control whether the Name and/or Title is displayed
/// next to the tree nodes in the user interface
/// </summary>
private bool _DisplayTreeNodeNames = true;
public bool DisplayTreeNodeNames
{
get { return _DisplayTreeNodeNames; }
set { _DisplayTreeNodeNames = value; }
}
private bool _DisplayTreeNodeTitles = false;
public bool DisplayTreeNodeTitles
{
get { return _DisplayTreeNodeTitles; }
set { _DisplayTreeNodeTitles = value; }
}
#endregion
public override string ToString()
{
// assume that at least one of the two options was selected
string rtnstr = "";
if (_DisplayTreeNodeNames) rtnstr = Name;
if (_DisplayTreeNodeTitles)
{
if (rtnstr.Length > 0) rtnstr += " - ";
rtnstr += Title;
}
return rtnstr;
//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;
// }
//}
//private Format _ActiveFormat = null;
//public Format ActiveFormat
//{
// get
// {
// if (_ActiveFormat == null)
// _ActiveFormat = LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat;
// return _ActiveFormat;
// }
// set
// {
// _ActiveFormat = null;
// }
//}
//public Format LocalFormat
//{
// get { return MyFormat; }
//}
public ConfigDynamicTypeDescriptor MyConfig
{
get { return DocVersionConfig; }
}
#endregion
public DocVersionInfo MyDocVersionInfo
{ get { return DocVersionInfo.Get(VersionID); } }
}
public partial class DocVersionInfo : IVEDrillDownReadOnly
{
#region SearchPaths
public string _SearchDVPath;
public string SearchDVPath
{
get
{
if (_SearchDVPath == null)
_SearchDVPath = ActiveParent.SearchDVPath + "\u0007" + Name;
return _SearchDVPath;
}
}
public string SearchPath { get { return ""; } }
#endregion
#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
#region MOVE TO DOCVERSION CONFIG
private string GetProfile(string grp, string nam)
{
return GetProfile(grp, nam, false);
}
private string GetProfile(string grp, string nam, bool flag)
{
DocVersionConfig dvcfg = DocVersionConfig;
string buff = null;
if (grp != null && !grp.Equals(string.Empty))
{
buff = dvcfg.GetValue(grp, nam); // get the value of 'nam' in 'grp'
if (buff == null || buff.Equals(string.Empty))
{
if (!flag)
buff = string.Format("<{0}-{1}>", grp, nam);
else
buff = null;
}
}
return buff;
}
public string UnitSpecific(string str, int len)
{
// This routine retrieves the procedure number format from the
// current directory and uses it to adjust the procedure number
// in the specified string
string retvalu = "";
string asis = "#";
if (str == null || str.Equals(string.Empty)) return retvalu; // return a null (empty) string
/*
* Bug fix: B2005-017 3/2/2005
* Need to use the largest procedure number length that's in the
* SET.DFF file. "LargestNumber" is the largest length after the
* procedure number is replaced via the SET.INI file "replace" list.
*
if(len==0)len=LargestNumber;
*/
// TODO: Do we need this line?-->>> if(len==0)len=LargestRawSetNumber;
//GetPrivateProfileString("unit", "procedure number", asis, mstr, MAXPATH, "proc.ini");
string pnum = asis;
//rhm/jcb stuff 20120511
//string mstr = GetProfile("Unit", "ProcedureNumber", true);
string mstr = DocVersionConfig.Unit_ProcedureNumber;
if (mstr != null && !mstr.Equals(string.Empty))
pnum = mstr;
if (pnum.Equals(asis))
retvalu = str;
else if (pnum[0] == '!')
{
// look for mstr in SET.INI
// GetPrivateProfileString("replace", mstr, mstr, tonum, 24, "set.ini");
// TODO: NOT SURE IF SET.INI AND PROC.INI HAVE UNIQUE GROUP NAMES!!!!!!!
//mstr = GetProfile("Replace", mstr);
mstr = GetProfile("Replace", mstr, true); // true allow it to return a null if not found
if (mstr == null) retvalu = str; // no replacement, use procedure number as is
}
else
{
retvalu = "";
string[] pnumsplit = pnum.Split(new Char[] { '#' });
int cnt = 0;
foreach (string s in pnumsplit)
{
if (!s.Equals(string.Empty))
{
if ((cnt == 0) && (str.StartsWith(" ")))
{
string padding = new string(' ', s.Length);
retvalu += padding;
}
else
retvalu += s;
}
else
retvalu += str.Trim();
cnt++;
}
// append trailing blanks or procedure number (str)
if (str.EndsWith(" "))
{
// count number of trailing blanks and append them to retvalu
cnt = str.Length - 1;
while (cnt > 0 && str[cnt] == ' ') cnt--;
retvalu += new string(' ', str.Length - cnt - 1);
}
}
return retvalu;
}
public string Evaluate(string str, int len)
{
string retval = null;
string swhir = "PSU"; /* order inwhich to check */
string pn;
if (str.Length > 1 && str[1] == '-')
{
int swptr = swhir.IndexOf((str.ToUpper())[0]);
//char swchar = '';
//if (swptr != -1)
// swchar = swhir[swptr];
string sav = str.Substring(len);
str = str.Substring(0, len);
string substr = str.Substring(2);
substr = substr.Replace(" ","");
while (swptr >= 0 && swptr < swhir.Length && retval == null) //retval.Equals(string.Empty))
{
switch (swhir[swptr])
{
case 'U':
//retval = GetProfile("Unit", substr, true);
if (substr.ToLower() == "id")
retval = this.DocVersionConfig.Unit_ID;
if (substr.ToLower() == "name")
retval = this.DocVersionConfig.Unit_Name;
if (substr.ToLower() == "number")
retval = this.DocVersionConfig.Unit_Number;
if (substr.ToLower() == "text")
retval = this.DocVersionConfig.Unit_Text;
//retval = this.DocVersionConfig.Other_Unit_ID;
//retval = this.DocVersionConfig.Other_Unit_Name;
//retval = this.DocVersionConfig.Other_Unit_Number;
//retval = this.DocVersionConfig.Other_Unit_Text;
break;
case 'S':
//retval = GetProfile("Procedure_Set", substr, true);
if(substr.ToLower() == "id")
retval = this.DocVersionConfig.Unit_ProcedureSetID;
if (substr.ToLower() == "name")
retval = this.DocVersionConfig.Unit_ProcedureSetName;
break;
case 'P':
//TODO: THIS IS A GLOBAL IN THE 16 BIT CODE!!!!
string procnumber = "";
pn = UnitSpecific(procnumber, 0);
retval = GetProfile(pn, substr, true);
break;
}
if (retval == null) // .Equals(string.Empty))
swptr++;
}
str += sav;
}
else if (len == 1 && (str.ToUpper())[0] == 'U')
{
retval = this.DocVersionConfig.Unit_Number;
}
else if (len == 2 && str.StartsWith("ID"))
{
retval = this.DocVersionConfig.Unit_ID;
}
// if the return value is empty, then the resulting
// evaluation should repeat the token string including
// the braces. - the beginning brace is not passed in.
//if (retval.Equals(string.Empty))
//{
// retval = (char*)mallocq(len + 3);
// strncpy(retval, str - 1, len + 2);
//}
if (retval == null)
retval = string.Format("<{0}>", str.Substring(0, len));
return retval;
}
public string ProcessDocVersionSpecificInfo(string rawvalue)
{
string str = rawvalue;
string rtnstr = "";
int l = rawvalue.Length;
while (l > 0)
{
int ptr = str.IndexOf('<'); //nextDelimiter("<", str, l);
int cptr = (ptr == -1) ? -1 : str.IndexOf('>'); //nextDelimiter(">", ptr, strlen(ptr));
// jsj 2/5/10 added "|| (ptr > cptr)" to fix bug where rawvalue = "Insert token for ->Step<- to transition back to."
if (ptr == -1 || (ptr > -1 && ((cptr == -1) || (ptr > cptr))))
{
//add(new seText(str, l));
//str += l;
rtnstr += str;
l = 0; // jump out of while loop
}
else
{
int cnt = ptr;
if (cnt > 0)
{
//add(new seText(str, cnt));
rtnstr += str.Substring(0, cnt);
l -= cnt;
str = str.Substring(ptr);
}
ptr = str.IndexOf('>')+1; //nextDelimiter(">", str, l) + 1;
cnt = ptr; //(int)(ptr - str);
//add(new seUser(str + 1, cnt - 2));
rtnstr += Evaluate(str.Substring(1, cnt - 2),cnt-2);
l -= cnt;
str = str.Substring(ptr); //ptr;
}
}
return rtnstr;
}
#endregion
ItemInfoList _Procedures = null;
public ItemInfoList Procedures
{ get { return (_Procedures != null ? _Procedures : _Procedures = ItemInfoList.GetList(_ItemID, (int)E_FromType.Procedure)); } }
public void ResetProcedures()
{
_Procedures = null;
}
#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 {
//Console.WriteLine("DV Local {0} {1} {2}", (MyFormat == null) ? "MYformat is null" : MyFormat.Name,FormatID,(MyFormat == null)?0:MyFormat.FormatID);
return MyFormat;
}
}
public ConfigDynamicTypeDescriptor MyConfig
{
get { return Get().DocVersionConfig; }
}
//public bool HasStandardSteps()
//{ return false; }
#region UserSettings
/// <summary>
/// These settings are set on the user interface side.
/// This is used to control whether the Name and/or Title is displayed
/// next to the tree nodes in the user interface
/// </summary>
private bool _DisplayTreeNodeNames = true;
public bool DisplayTreeNodeNames
{
get { return _DisplayTreeNodeNames; }
set { _DisplayTreeNodeNames = value; }
}
private bool _DisplayTreeNodeTitles = false;
public bool DisplayTreeNodeTitles
{
get { return _DisplayTreeNodeTitles; }
set { _DisplayTreeNodeTitles = value; }
}
#endregion
public override string ToString()
{
// assume that at least one of the two options was selected
string rtnstr = "";
if (_DisplayTreeNodeNames) rtnstr = Name;
if (_DisplayTreeNodeTitles)
{
if (rtnstr.Length > 0) rtnstr += " - ";
rtnstr += Title;
}
return rtnstr;
//return string.Format("{0} - {1}", Name, Title);
}
//public string ToString(string str,System.IFormatProvider ifp)
//{
// return ToString();
//}
public ItemInfo LastChild()
{
return MyItem.LastSibling;
}
public ItemInfo FirstChild()
{
return MyItem;
}
#endregion
#region Extension
partial class DocVersionInfoExtension : extensionBase
{
public override void Refresh(DocVersionInfo tmp)
{
tmp.DocVersionConfigRefresh();
}
}
#endregion
public ROFstInfo GetROFst(int rodbid)
{
foreach (AssociationInfo dva in DocVersionAssociations)
{
if (dva.MyROFst.RODbID == rodbid)
return dva.MyROFst;
}
return null;
}
public int MultiUnitCount
{
get
{
return DocVersionConfig.Unit_Count;
}
}
private string[] _UnitNames;
public string[] UnitNames
{
get
{
if (_UnitNames == null)
{
// _UnitNames = DocVersionConfig.Unit_Name.Split(',');
_UnitNames = new string[DocVersionConfig.Unit_Count];
int j = 0;
for (int k = 1; k <= DocVersionConfig.MaxSlaveIndex; k++)
{
DocVersionConfig.SelectedSlave = k;
try
{
_UnitNames[j] = DocVersionConfig.Unit_Name;
j++;
}
catch
{
}
}
}
return _UnitNames;
}
}
}
public enum VersionTypeEnum : int
{
WorkingDraft = 0, Temporary = 1, Revision = 128, Approved = 129
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace Volian.Object.Library
{
public partial class GroupMembership : BusinessBase<GroupMembership>
{
public string User_FullName
{
get { return User_LastName + ", " + User_FirstName; }
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,401 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using Csla;
using Csla.Data;
namespace VEPROMS.CSLA.Library
{
public partial class ItemInfo
{
#region Old Insert
//public ItemInfo InsertSiblingBeforeOld(string text)
//{
// return InsertSiblingBefore(text, null);
//}
//public ItemInfo InsertSiblingBeforeOld(string text, string number)
//{
// ItemInfo prevItemInfo = MyPrevious;
// ItemInfo newItemInfo = null;
// PartInfoList partInfoList = null;
// if (MyParent != null && MyParent.MyContent != null)
// {
// MyParent.MyContent.RefreshContentParts();
// partInfoList = MyParent.MyContent.ContentParts;
// }
// using (Item prevItem = prevItemInfo == null ? null : prevItemInfo.Get()) // Get the previous Item
// {
// using (Item newItem = Item.MakeItem(prevItem, Content.MakeContent(number, text, MyContent.Type, null, null))) // Create the new Item
// {
// using (Item thisItem = Get()) // Get the next item in the list
// {
// thisItem.MyPrevious = newItem; // Point to the new item
// thisItem.Save(); // Save Changes
// if (prevItem == null)
// {
// PartInfo partInfo = partInfoList.Find(this);
// using (Part part = partInfo.Get())
// {
// part.MyItem = newItem;
// part.Save();
// }
// }
// }
// // ToDo: Need change PartInfo in PartInfoList
// newItemInfo = ItemInfo.Get(newItem.ItemID);
// newItemInfo.ResetOrdinal();
// }
// }
// return newItemInfo;
//}
//public ItemInfo InsertSiblingAfterOld(string text)
//{
// return InsertSiblingAfter(text, null);
//}
//public ItemInfo InsertSiblingAfterOld(string text, string number)
//{
// return InsertSiblingAfter(text, number, MyContent.Type);
//}
//public ItemInfo InsertSiblingAfterOld(string text, string number, int? type)
//{
// ItemInfo nextItemInfo = NextItem;
// ItemInfo newItemInfo = null;
// using (Item thisItem = Get()) // Get the Current Item
// {
// using (Item newItem = Item.MakeItem(thisItem, Content.MakeContent(number, text, type, null, null))) // Create the new Item
// {
// if (nextItemInfo != null) // Simple case, adding to end of list:
// using (Item nextItem = nextItemInfo.Get()) // Get the next item in the list
// {
// nextItem.MyPrevious = newItem; // Point to the new item
// nextItem.Save(); // Save Changes
// }
// // ToDo: Need change PartInfo in PartInfoList
// newItemInfo = ItemInfo.Get(newItem.ItemID);
// newItemInfo.ResetOrdinal();
// }
// }
// return newItemInfo;
//}
//public ItemInfo InsertChildOld(E_FromType fromType, int type, string text)
//{
// return InsertChild(fromType, type, text, null);
//}
//public ItemInfo InsertChildOld(E_FromType fromType, int type, string text, string number)
//{
// ItemInfo newItemInfo = null;
// using (Item thisItem = Get()) // Get the Current Item
// {
// using (Item newItem = Item.MakeItem(null, Content.MakeContent(number, text, type, null, null))) // Create the new Item
// {
// PartInfo partInfo = MyContent.ContentParts == null ? null : MyContent.ContentParts.Find(fromType);
// if (partInfo != null)
// {
// //this could be equivalent to adding a sibling with a specific type
// using (Part part = partInfo.Get())
// {
// part.MyItem.MyPrevious = newItem;
// part.MyItem.Save();
// part.MyItem = newItem;
// part.Save();
// }
// }
// else
// {
// // This means that a part needs to be added to point to the new item
// //using (Part part = Part.MakePart(thisItem.MyContent, ))
// //{ ;}
// thisItem.MyContent.ContentParts.Add((int)fromType, newItem);
// thisItem.Save();
// }
// newItemInfo = ItemInfo.Get(newItem.ItemID);
// }
// }
// ResetParts();
// return newItemInfo;
//}
#endregion
#region Insert Before
public ItemInfo InsertSiblingBefore(string text)
{
return InsertSiblingBefore(text, null);
}
public ItemInfo InsertSiblingBefore(string text, string number)
{
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Before, number, text, null, null, null, null, DateTime.Now, Environment.UserName);
// this item is updated in SQL so we have to manually force the iteminfo updates
// Refresh ItemInfo to update Previous
using (Item item = Get()) ItemInfo.Refresh(item);
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
tmp.UpdateTransitionText();
return tmp;
}
#endregion
#region Insert After
public ItemInfo InsertSiblingAfter(string text)
{
return InsertSiblingAfter(text, null);
}
public ItemInfo InsertSiblingAfter(string text, string number)
{
return InsertSiblingAfter(text, number, MyContent.Type);
}
public ItemInfo InsertSiblingAfter(string text, string number, int? type)
{
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName);
//tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName));
// if next exists, it is updated in SQL so we have to manually force the iteminfo updates
// Refresh ItemInfo to update PreviousID field
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
tmp.UpdateTransitionText();
return tmp;
}
private ItemInfo NewItemInfoFetch(int itemID, EAddpingPart addType, string number, string text, int? type, int? fromType, int? formatID, string config, DateTime dts, string userID)
{
ItemInfo tmp;
if (addType == EAddpingPart.Child)
{
// adding children. Type is based on 'fromType'
switch ((E_FromType)fromType)
{
case E_FromType.Procedure:
tmp = DataPortal.Fetch<ProcedureInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
case E_FromType.Section:
tmp = DataPortal.Fetch<SectionInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
default:
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
break;
}
}
else
{
if (GetType() == typeof(ProcedureInfo))
tmp = DataPortal.Fetch<ProcedureInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
else if (GetType() == typeof(SectionInfo))
tmp = DataPortal.Fetch<SectionInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
else
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
}
return tmp;
}
public void UpdateTransitionText()
{
// Update Ordinals from here down
ResetOrdinal();
// This returns a list of all of the transitions that may have been affected
using(TransitionInfoList trans = TransitionInfoList.GetAffected(this.ItemID))
{
foreach (TransitionInfo tran in trans)
{
using (Content content = tran.MyContent.Get())
{
content.FixTransitionText(tran);
if (content.IsDirty)
content.Save();
}
}
}
}
#endregion
#region Insert Child
public ItemInfo InsertChild(E_FromType fromType, int type, string text)
{
return InsertChild(fromType, type, text, null);
}
public ItemInfo InsertChild(E_FromType fromType, int type, string text, string number)
{
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Child, number, text, type, (int?) fromType, null, null, DateTime.Now, Environment.UserName);
// if next exists, it is updated in SQL so we have to manually force the iteminfo updates
// Refresh ItemInfo to update PreviousID field
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
tmp.UpdateTransitionText();
return tmp;
}
#endregion
#region DataPortal
private void DataPortal_Fetch(AddingPartCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); //ABC After Before Child
cm.Parameters.AddWithValue("@Number", criteria.Number); //ABC
cm.Parameters.AddWithValue("@Text", criteria.Text); //ABC
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID); //ABC
cm.Parameters.AddWithValue("@Config", criteria.Config); //ABC
cm.Parameters.AddWithValue("@Type", criteria.Type); //ABC
cm.Parameters.AddWithValue("@DTS", criteria.DTS); //ABC
cm.Parameters.AddWithValue("@UserID", criteria.UserID); //ABC
SqlParameter param_ContentID = new SqlParameter("@newItemID", SqlDbType.Int);
param_ContentID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ContentID);
switch (criteria.AddType)
{
case EAddpingPart.Child:
cm.CommandText = "addItemChild";
cm.Parameters.AddWithValue("@FromType", criteria.FromType); //--C
break;
case EAddpingPart.Before:
cm.CommandText = "addItemSiblingBefore";
break;
case EAddpingPart.After:
cm.CommandText = "addItemSiblingAfter";
break;
}
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
//newItemID = (int)cm.Parameters["@newContentID"].Value;
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
}
}
#endregion
[Serializable()]
protected class AddingPartCriteria
{
#region Properties
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private EAddpingPart _AddType;
public EAddpingPart AddType
{
get { return _AddType; }
set { _AddType = value; }
}
private string _Number=null;
public string Number
{
get { return _Number; }
set { _Number = value; }
}
private string _Text=null;
public string Text
{
get { return _Text; }
set { _Text = value; }
}
private int? _FromType = null;
public int? FromType
{
get { return _FromType; }
set { _FromType = value; }
}
private int? _Type=null;
public int? Type
{
get { return _Type; }
set { _Type = value; }
}
private int? _FormatID=null;
public int? FormatID
{
get { return _FormatID; }
set { _FormatID = value; }
}
private string _Config=null;
public string Config
{
get { return _Config; }
set { _Config = value; }
}
private DateTime _DTS;
public DateTime DTS
{
get { return _DTS; }
set { _DTS = value; }
}
private string _UserID;
public string UserID
{
get { return _UserID; }
set { _UserID = value; }
}
#endregion
#region Constructor
public AddingPartCriteria(int itemID, EAddpingPart addType, string number, string text, int? type, int? fromType, int? formatID, string config, DateTime dts, string userID)
{
_ItemID = itemID;
_AddType = addType;
_Number = number;
_Text = text;
_Type = type;
_FromType = fromType;
_FormatID = formatID;
_Config = config;
_DTS = dts;
_UserID = userID;
}
#endregion
}
public enum EAddpingPart
{
Child=0,
Before=1,
After=2
}
public ItemInfo NextItem
{
get
{
if (NextItemCount > 0 && NextItems.Count > 0)
return NextItems[0];
return null;
}
}
private static void ResetOrdinal(int itemID)
{
ConvertListToDictionary();
string key = itemID.ToString();
while (key != null && _CacheByPrimaryKey.ContainsKey(key))
{
ItemInfo[] items = _CacheByPrimaryKey[key].ToArray();
key = null;
foreach (ItemInfo item in items)
{
//Console.WriteLine("item = {0}, ordinal = {1}",item,item.Ordinal);
item._Ordinal = null;
item._TagsSetup = false;
if (key == null && item.NextItem != null)
key = item.NextItem.ItemID.ToString();
}
}
}
private void ResetOrdinal()
{
ResetOrdinal(ItemID);
}
}
}
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace VEPROMS.CSLA.Library
{
public partial class LinkText
{
public LinkText(string linkInfoText)
{
_LinkInfoText = linkInfoText;
}
public void ParseLink()
{
if (_MyParsedLinkType == ParsedLinkType.NotParsed)
{
if (_LinkInfoText == null) return;
// First parse the string
_LinkInfoText = _LinkInfoText.Replace(@"\v ", "");
// for tran : "2, #, #, # and 4#Link:TransitionRange:2 10 173 166"
Match m = Regex.Match(_LinkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)");
_MyValue = m.Groups[1].Value;
_MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value;
switch (m.Groups[2].Value)
{
case "ReferencedObject":
_MyParsedLinkType = ParsedLinkType.ReferencedObject;
string[] subs = m.Groups[3].Value.Split(" ".ToCharArray());
if (subs[0] == "<NewID>")
_MyRoUsageInfo = null;
else
{
int roUsageid = Convert.ToInt32(subs[0]);
_MyRoUsageInfo = RoUsageInfo.Get(roUsageid);
}
break;
case "Transition":
case "TransitionRange":
_MyParsedLinkType = (ParsedLinkType)Enum.Parse(_MyParsedLinkType.GetType(), m.Groups[2].Value);
if (m.Groups[3].Value.Split(" ".ToCharArray())[1] == "<NewID>")
_MyTransitionInfo = null;
else
{
int transitionID = Convert.ToInt32(m.Groups[3].Value.Split(" ".ToCharArray())[1]);
_MyTransitionInfo = TransitionInfo.Get(transitionID);
}
break;
}
}
}
private string _LinkInfoText;
public string LinkInfoText
{
get { return _LinkInfoText; }
}
private TransitionInfo _MyTransitionInfo = null;
public TransitionInfo MyTransitionInfo
{
get { ParseLink(); return _MyTransitionInfo; }
}
public ItemInfo MyTranToItemInfo
{
get { ParseLink(); return _MyTransitionInfo.MyItemToID; }
}
public ItemInfo MyTranRangeItemInfo
{
get { ParseLink(); return _MyTransitionInfo.MyItemRangeID; }
}
private string _MyValue = null;
public string MyValue
{
get { ParseLink(); return _MyValue; }
}
private string _MyLink = null;
public string MyLink
{
get { ParseLink(); return _MyLink; }
}
private RoUsageInfo _MyRoUsageInfo;
public RoUsageInfo MyRoUsageInfo
{
get { ParseLink(); return _MyRoUsageInfo; }
}
//private string _Roid = null; // TODO: need to return Referenced Object rather than just roid
//public string Roid
//{
// get { ParseLink(); return _Roid; }
//}
//private string _RoUsageid = null; // TODO: need to return Referenced Object rather than just roid
//public string RoUsageid
//{
// get { ParseLink(); return _RoUsageid; }
//}
//private string _RoDbid = null; // TODO: need to return Referenced Object rather than just roid
//public string RoDbid
//{
// get { ParseLink(); return _RoDbid; }
//}
private ParsedLinkType _MyParsedLinkType = ParsedLinkType.NotParsed;
public ParsedLinkType MyParsedLinkType
{
get { ParseLink(); return _MyParsedLinkType; }
}
}
#region enums
public enum ParsedLinkType : int
{
NotParsed = 0,
Transition = 1,
TransitionRange = 2,
ReferencedObject = 3
}
#endregion
}
@@ -0,0 +1,890 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using Csla;
using Csla.Data;
namespace VEPROMS.CSLA.Library
{
#region Enum stuff
public enum CheckOutType : int
{
Procedure = 0, Document = 1, DocVersion = 2
}
#endregion
#region SessionInfoList stuff
public partial class SessionInfoList
{
[Serializable()]
public class CanCheckOutItemCriteria
{
private int _ObjectID;
public int ObjectID
{ get { return _ObjectID; } }
private CheckOutType _ObjectType;
public CheckOutType ObjectType
{ get { return _ObjectType; } }
public CanCheckOutItemCriteria(int objectID, CheckOutType objectType)
{
_ObjectID = objectID;
_ObjectType = objectType;
}
}
private void DataPortal_Fetch(CanCheckOutItemCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_SessionCanCheckOutItem";
cm.Parameters.AddWithValue("@ObjectID", criteria.ObjectID);
cm.Parameters.AddWithValue("@ObjectType", criteria.ObjectType);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new SessionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("SessionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
#endregion
#region SessionInfo stuff
public partial class SessionInfo
{
public static SessionInfo BeginSession(string machineName, int processID)
{
try
{
SessionInfo tmp = DataPortal.Fetch<SessionInfo>(new BeginSessionCriteria(Volian.Base.Library.VlnSettings.UserID, machineName, processID));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up SessionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on SessionInfo.BeginSession", ex);
}
}
public List<int> PingSession()
{
List<int> myList = new List<int>();
SessionPing.Execute(this.SessionID);
OwnerInfoList oil = OwnerInfoList.GetBySessionID(this.SessionID);
foreach (OwnerInfo oi in oil)
myList.Add(oi.OwnerID);
return myList;
}
public void EndSession()
{
SessionEnd.Execute(this.SessionID);
}
public bool CanCheckOutItem(int objectID, CheckOutType objectType, ref string message)
{
try
{
SessionInfoList sil = DataPortal.Fetch<SessionInfoList>(new SessionInfoList.CanCheckOutItemCriteria(objectID, objectType));
if (sil.Count == 0)
return true;
bool rv = true;
foreach (SessionInfo si in sil)
{
if (si.SessionID != this.SessionID && objectType == CheckOutType.Procedure)
{
message = string.Format("The procedure {0} is already checked out to {1}", ItemInfo.Get(objectID).MyProcedure.DisplayNumber, si.UserID);
rv = rv && false;
}
else if (si.SessionID != this.SessionID && objectType == CheckOutType.Document)
{
message = string.Format("The document {0} is already checked out to {1}", DocumentInfo.Get(objectID).DocumentEntries[0].MyContent.Text, si.UserID);
rv = rv && false;
}
else if (si.SessionID != this.SessionID && objectType == CheckOutType.DocVersion)
{
OwnerInfo oi = OwnerInfo.GetBySessionIDandVersionID(si.SessionID, objectID);
if(oi.OwnerType == 0)
message = message + string.Format("The procedure {0} is already checked out to {1}", ItemInfo.Get(oi.OwnerItemID).MyProcedure.DisplayNumber, si.UserID) + Environment.NewLine;
else if (oi.OwnerType == 1)
message = message + string.Format("The document {0} is already checked out to {1}", DocumentInfo.Get(oi.OwnerItemID).DocumentEntries[0].MyContent.Text, si.UserID) + Environment.NewLine;
else if (oi.OwnerType == 2)
message = message + string.Format("The working draft is already checked out to {0}", si.UserID);
rv = rv && false;
}
}
return rv;
}
catch (Exception ex)
{
throw new DbCslaException("Error on SessionInfo.Get", ex);
}
}
public int CheckOutItem(int itemID, CheckOutType itemType)
{
int ownerID = SessionCheckOutItem.Execute(this.SessionID, itemID, itemType);
return ownerID;
}
public void CheckInItem(int ownerID)
{
SessionCheckInItem.Execute(ownerID);
}
private void DataPortal_Fetch(BeginSessionCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.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 = "vesp_SessionBegin";
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
cm.Parameters.AddWithValue("@MachineName", criteria.MachineName);
cm.Parameters.AddWithValue("@ProcessID", criteria.ProcessID);
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("SessionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("SessionInfo.DataPortal_Fetch", ex);
}
}
//private void DataPortal_Fetch(CanCheckOutItemCriteria criteria)
//{
// if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.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 = "vesp_SessionCanCheckOutItem";
// cm.Parameters.AddWithValue("@ObjectID", criteria.ObjectID);
// cm.Parameters.AddWithValue("@ObjectType", criteria.ObjectType);
// using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
// {
// while(dr.Read())
// 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("SessionInfo.DataPortal_Fetch", ex);
// _ErrorMessage = ex.Message;
// throw new DbCslaException("SessionInfo.DataPortal_Fetch", ex);
// }
//}
[Serializable()]
protected class BeginSessionCriteria
{
private string _UserID;
public string UserID
{ get { return _UserID; } }
private string _MachineName;
public string MachineName
{ get { return _MachineName; } }
private int _ProcessID;
public int ProcessID
{ get { return _ProcessID; } }
public BeginSessionCriteria(string userID, string machineName, int processID)
{
_UserID = userID;
_MachineName = machineName;
_ProcessID = processID;
}
}
//[Serializable()]
//protected class CanCheckOutItemCriteria
//{
// private int _ObjectID;
// public int ObjectID
// { get { return _ObjectID; } }
// private CheckOutType _ObjectType;
// public CheckOutType ObjectType
// { get { return _ObjectType; } }
// public CanCheckOutItemCriteria(int objectID, CheckOutType objectType)
// {
// _ObjectID = objectID;
// _ObjectType = objectType;
// }
//}
}
public class ResetSecurity : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
public static void Execute()
{
ResetSecurity cmd = new ResetSecurity();
DataPortal.Execute<ResetSecurity>(cmd);
}
#endregion
#region Server-Side code
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_ResetSecurity", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Reset Security Error", ex);
throw new ApplicationException("Failure on Reset Security", ex);
}
}
#endregion
}
public class SessionPing : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _SessionID;
public int SessionID
{
get { return _SessionID; }
set { _SessionID = value; }
}
#region Factory Methods
public static void Execute(int sessionID)
{
SessionPing cmd = new SessionPing();
cmd.SessionID = sessionID;
DataPortal.Execute<SessionPing>(cmd);
}
#endregion
#region Server-Side code
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_SessionPing", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.Parameters.AddWithValue("@SessionID", SessionID);
cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Session Ping Error", ex);
throw new ApplicationException("Failure on Session Ping", ex);
}
}
#endregion
}
public class SessionEnd : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _SessionID;
public int SessionID
{
get { return _SessionID; }
set { _SessionID = value; }
}
#region Factory Methods
public static void Execute(int sessionID)
{
SessionEnd cmd = new SessionEnd();
cmd.SessionID = sessionID;
DataPortal.Execute<SessionEnd>(cmd);
}
#endregion
#region Server-Side code
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_SessionEnd", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.Parameters.AddWithValue("@SessionID", SessionID);
cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Session End Error", ex);
throw new ApplicationException("Failure on Session End", ex);
}
}
#endregion
}
public class SessionCheckOutItem : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _SessionID;
public int SessionID
{
get { return _SessionID; }
set { _SessionID = value; }
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private int _ItemType;
public int ItemType
{
get { return _ItemType; }
set { _ItemType = value; }
}
private int _OwnerID;
public int OwnerID
{
get { return _OwnerID; }
set { _OwnerID = value; }
}
#region Factory Methods
public static int Execute(int sessionID, int itemID, CheckOutType itemType)
{
SessionCheckOutItem cmd = new SessionCheckOutItem();
cmd.SessionID = sessionID;
cmd.ItemID = itemID;
cmd.ItemType = (int)itemType;
cmd = DataPortal.Execute<SessionCheckOutItem>(cmd);
return cmd.OwnerID;
}
#endregion
#region Server-Side code
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_SessionCheckOutItem", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.Parameters.AddWithValue("@SessionID", SessionID);
cmd.Parameters.AddWithValue("@ItemID", ItemID);
cmd.Parameters.AddWithValue("@ItemType", ItemType);
SqlParameter parm = cmd.Parameters.AddWithValue("@OwnerID", 0);
parm.Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
OwnerID = (int)cmd.Parameters["@OwnerID"].Value;
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Session End Error", ex);
throw new ApplicationException("Failure on Session End", ex);
}
}
#endregion
}
public class SessionCheckInItem : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _OwnerID;
public int OwnerID
{
get { return _OwnerID; }
set { _OwnerID = value; }
}
private int _ItemID;
#region Factory Methods
public static void Execute(int ownerID)
{
SessionCheckInItem cmd = new SessionCheckInItem();
cmd.OwnerID = ownerID;
DataPortal.Execute<SessionCheckInItem>(cmd);
}
#endregion
#region Server-Side code
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_SessionCheckInItem", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.Parameters.AddWithValue("@OwnerID", OwnerID);
cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Session End Error", ex);
throw new ApplicationException("Failure on Session End", ex);
}
}
#endregion
}
#endregion
#region OwnerInfo stuff
public partial class OwnerInfoList
{
public static OwnerInfoList GetBySessionID(int sessionID)
{
OwnerInfoList tmp = DataPortal.Fetch<OwnerInfoList>(new GetBySessionIDCriteria(sessionID));
return tmp;
}
[Serializable()]
protected class GetBySessionIDCriteria
{
private int _SessionID;
public int SessionID { get { return _SessionID; } }
public GetBySessionIDCriteria(int sessionID)
{
_SessionID = sessionID;
}
}
private void DataPortal_Fetch(GetBySessionIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getOwnersBySessionID";
cm.Parameters.AddWithValue("@SessionID", criteria.SessionID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new OwnerInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("OwberInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
}
public partial class OwnerInfo
{
public static OwnerInfo GetBySessionIDandVersionID(int sessionID, int versionID)
{
try
{
OwnerInfo tmp = DataPortal.Fetch<OwnerInfo>(new GetBySessionIDandVersionIDCriteria(sessionID, versionID));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up SessionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on OwnerInfo.GetBySessionIDandVersionID", ex);
}
}
[Serializable()]
protected class GetBySessionIDandVersionIDCriteria
{
private int _SessionID;
public int SessionID
{ get { return _SessionID; } }
private int _VersionID;
public int VersionID
{ get { return _VersionID; } }
public GetBySessionIDandVersionIDCriteria(int sessionID, int versionID)
{
_SessionID = sessionID;
_VersionID = versionID;
}
}
private void DataPortal_Fetch(GetBySessionIDandVersionIDCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.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 = "getOwnerBySessionIDandVersionID";
cm.Parameters.AddWithValue("@SessionID", criteria.SessionID);
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("OwnerInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("OwnerInfo.DataPortal_Fetch", ex);
}
}
public static OwnerInfo GetByItemID(int itemID, CheckOutType itemType)
{
try
{
OwnerInfo tmp = DataPortal.Fetch<OwnerInfo>(new GetByItemIDCriteria(itemID, itemType));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up SessionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on OwnerInfo.GetByItemID", ex);
}
}
[Serializable()]
protected class GetByItemIDCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
private CheckOutType _ItemType;
public CheckOutType ItemType
{ get { return _ItemType; } }
public GetByItemIDCriteria(int itemID, CheckOutType itemType)
{
_ItemID = itemID;
_ItemType = itemType;
}
}
private void DataPortal_Fetch(GetByItemIDCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.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 = "getOwnerByItemID";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
cm.Parameters.AddWithValue("@ItemType", (int)criteria.ItemType);
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("OwnerInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("OwnerInfo.DataPortal_Fetch", ex);
}
}
public string SessionUserID
{
get
{
SessionInfo si = SessionInfo.Get(this.SessionID);
return si.UserID;
}
}
}
#endregion
#region UserInfo stuff
public partial class UserInfo
{
public bool IsAdministrator()
{
if (this.UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
{
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
{
if (ai.FolderID == 1 && ai.MyRole.Name == "Administrator")
return true;
}
}
}
return false;
}
public bool IsSetAdministrator(FolderInfo fi)
{
if (this.UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
//FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
while (fi.FolderID > 1)
{
folders.Add(fi.FolderID, fi.FolderID);
fi = fi.MyParent;
}
folders.Add(1, 1);
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
{
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Set Administrator")
return true;
}
}
}
return false;
}
public bool IsSetAdministrator(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
while (fi.FolderID > 1)
{
folders.Add(fi.FolderID, fi.FolderID);
fi = fi.MyParent;
}
folders.Add(1, 1);
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
{
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Set Administrator")
return true;
}
}
}
return false;
}
public bool IsWriter(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
while (fi.FolderID > 1)
{
folders.Add(fi.FolderID, fi.FolderID);
fi = fi.MyParent;
}
folders.Add(1, 1);
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
{
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Writer")
return true;
}
}
}
return false;
}
public bool IsReviewer(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
while (fi.FolderID > 1)
{
folders.Add(fi.FolderID, fi.FolderID);
fi = fi.MyParent;
}
folders.Add(1, 1);
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
{
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Reviewer")
return true;
}
}
}
return false;
}
public bool IsROEditor(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
{
if (mi.EndDate == string.Empty)
{
Dictionary<int, int> folders = new Dictionary<int, int>();
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
while (fi.FolderID > 1)
{
folders.Add(fi.FolderID, fi.FolderID);
fi = fi.MyParent;
}
folders.Add(1, 1);
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
{
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "RO Editor")
return true;
}
}
}
return false;
}
public static UserInfo GetByUserID(string userID)
{
try
{
UserInfo tmp = DataPortal.Fetch<UserInfo>(new GetByUserIDCriteria(userID));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up SessionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on UserInfo.GetByUserID", ex);
}
}
[Serializable()]
protected class GetByUserIDCriteria
{
private string _UserID;
public string UserID
{ get { return _UserID; } }
public GetByUserIDCriteria(string userID)
{
_UserID = userID;
}
}
private void DataPortal_Fetch(GetByUserIDCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getUserByUserID";
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("UserInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("UserInfo.DataPortal_Fetch", ex);
}
}
}
#endregion
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace VEPROMS.CSLA.Library
{
public partial class Permission
{
private static List<vlnValueKey> _permADLookup;
private static List<vlnValueKey> _permLevelLookup;
private static void setupLookup()
{
if (_permADLookup == null)
{
_permADLookup = new List<vlnValueKey>();
_permADLookup.Add(new vlnValueKey(0,"Allow"));
_permADLookup.Add(new vlnValueKey(1, "Deny"));
}
if (_permLevelLookup == null)
{
_permLevelLookup = new List<vlnValueKey>();
_permLevelLookup.Add(new vlnValueKey(0, "Security"));
_permLevelLookup.Add(new vlnValueKey(1, "System"));
_permLevelLookup.Add(new vlnValueKey(2, "RO"));
_permLevelLookup.Add(new vlnValueKey(3, "Procedure"));
_permLevelLookup.Add(new vlnValueKey(4, "Sections"));
_permLevelLookup.Add(new vlnValueKey(5, "Steps"));
_permLevelLookup.Add(new vlnValueKey(6, "Comments"));
}
}
public static List<vlnValueKey> PermADLookup
{
get { setupLookup(); return _permADLookup; }
}
public static List<vlnValueKey> PermLevelLookup
{
get { setupLookup(); return _permLevelLookup; }
}
public bool ReadAccess
{
get { return ((PermValue & 1) == 1); }
set { PermValue = (value?PermValue|1:PermValue^(PermValue&1));}
}
public bool WriteAccess
{
get { return ((PermValue & 2) == 2); }
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
}
public bool CreateAccess
{
get { return ((PermValue & 4) == 4); }
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
}
public bool DeleteAccess
{
get { return ((PermValue & 8) == 8); }
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
}
// partial class Extension : extensionBase
// {
// TODO: Override automatic defaults
// public virtual int DefaultPermad
// {
// get { return 0; }
// }
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
}
}
@@ -0,0 +1,808 @@
// ========================================================================
// 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.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Xml;
using System.Xml.XPath;
using System.Text.RegularExpressions;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
namespace VEPROMS.CSLA.Library
{
public partial class ROFst
{
// put in for debug
//public static int CacheCountPrimaryKey
//{ get { return _CacheByPrimaryKey.Count; } }
//public static int CacheCountByRODbID_DTS
//{ get { return _CacheByRODbID_DTS.Count; } }
//public static int CacheCountList
//{ get { return _CacheList.Count; } }
[NonSerialized]
private ROFSTLookup _ROFSTLookup;
public ROFSTLookup ROFSTLookup
{
get
{
if (_ROFSTLookup == null)
{
_ROFSTLookup = new ROFSTLookup(this);
}
return _ROFSTLookup;
}
}
public static ROFst GetJustROFst(int rOFstID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFst tmp = GetCachedByPrimaryKey(rOFstID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROFst>(new PKCriteriaJustROFst(rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFst
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFst.Get", ex);
}
}
[Serializable()]
protected class PKCriteriaJustROFst
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteriaJustROFst(int rOFstID)
{
_ROFstID = rOFstID;
}
}
private void DataPortal_Fetch(PKCriteriaJustROFst criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.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 = "getJustROFst";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
// load child objects
//dr.NextResult();
//_ROFstAssociations = ROFstAssociations.Get(dr);
// load child objects
//dr.NextResult();
//_ROFstFigures = ROFstFigures.Get(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("ROFst.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFst.DataPortal_Fetch", ex);
}
}
}
public delegate List<string> ROFstInfoROTableUpdateEvent(object sender, ROFstInfoROTableUpdateEventArgs args);
public partial class ROFstInfo
{
// put in for debug
//public static int CacheCountPrimaryKey
//{ get { return _CacheByPrimaryKey.Count; } }
//public static int CacheCountList
//{ get { return _CacheList.Count; } }
#region Log4Net
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region PropertiesAndData
private DocVersionInfo _docVer;
public DocVersionInfo docVer
{
get
{
if (_docVer == null)
{
if (ROFstAssociations.Count == 0) return null;
// _docVer = DocVersion.Get(this.ROFstAssociations[0].MyDocVersion.VersionID);
_docVer = this.ROFstAssociations[0].MyDocVersion;
}
return _docVer;
}
set
{
_docVer = value;
}
}
[NonSerialized]
private ROFSTLookup _ROFSTLookup;
public ROFSTLookup ROFSTLookup
{
get
{
if (_ROFSTLookup == null)
{
_ROFSTLookup = new ROFSTLookup(this);
}
return _ROFSTLookup;
}
}
#endregion
#region AppSupport
//public static ROImageInfo Get(RODbInfo rodbinfo, string filename)
//{
// if (rodbinfo.RODbROImageCount != 0)
// {
// foreach (ROImageInfo ri in rodbinfo.RODbROImages)
// {
// if (ri.FileName == filename) return ri;
// }
// }
// return null;
//}
public string GetDefaultROPrefix()
{
if (docVer != null)
return docVer.DocVersionConfig.RODefaults_setpointprefix;
else
return "SP1"; // Not Sure about this...
}
public string GetDefaultGraphicsPrefix()
{
if (docVer != null)
return docVer.DocVersionConfig.RODefaults_graphicsprefix;
else
return "IG1"; // Not Sure about this...
}
#region Add New Ro Fst
/// <summary>
/// Adds an ro.fst into a sql database.
/// </summary>
/// <param name="rdi" - the Rodb to use as the path for updating the ro.fst, i.e.
/// import from there.
/// <param name="docver" - hook into this doc version></param>
/// <returns>ROFst: Returns the created rofst object</returns>
public static ROFst AddRoFst(RODbInfo rdi, DocVersion docver)
{
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
if (!di.Exists) return null;
if (!File.Exists(rofstfilepath)) return null;
// check if this rofst has been loaded, i.e. dts on file versus dts in db...
// if so, just make association with docversion.
ROFst rofst = ROFst.GetByRODbID_DTS(rdi.RODbID, di.LastWriteTimeUtc);
if (rofst != null)
{
docver.DocVersionAssociations.Add(rofst);
docver.Save();
return rofst;
}
// Next read in the rofst & make the rofst record.
FileStream fsIn = new FileStream(rofstfilepath, FileMode.Open, FileAccess.Read, FileShare.Read);
// Create an instance of StreamReader that can read characters from the FileStream.
BinaryReader r = new BinaryReader(fsIn);
byte[] ab = r.ReadBytes((int)fsIn.Length);
fsIn.Close();
using (RODb rodb = RODb.Get(rdi.RODbID))
{
using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbID(rdi.RODbID))
{
Dictionary<string, int> myExistingROImages = BuildROImagesList(myROImages);
List<int> myUnChangedROImages = new List<int>();
List<string> myAddedROImages = new List<string>();
rofst = ROFst.MakeROFst(rodb, ab, null, di.LastWriteTimeUtc, rdi.UserID);
// Hook this into the current docversion by replacing the rofstid field in the doc version
// association object:
docver.DocVersionAssociations.Add(rofst);
docver.Save();
// Now load any images in... type 8 - integrated graphics ro type
for (int i = 0; i < rofst.ROFSTLookup.myHdr.myDbs.Length; i++)
{
// walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8:
if (rofst.ROFSTLookup.myHdr.myDbs[i].children != null)
{
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
{
rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);// TODO: Need to add MyImages
}
}
}
if (myUnChangedROImages.Count > 0)
using (FigureInfoList fil = FigureInfoList.AddByROFstIDImageIDs(rofst.ROFstID, buildImageIDString(myUnChangedROImages))) ;
return rofst;
}
}
}
#endregion
#region Update Ro Values
/// <summary>
/// Updates an ro.fst into a sql database.
/// </summary>
/// <param name="rdi" - the Rodb to use as the path for updating the ro.fst, i.e.
/// import from there.
/// <param name="dva" - the association record to modify, i.e. make new rofst
/// the current one.
/// <param name="docver" - hook into this doc version></param>
/// <returns>ROFst: Returns the created rofst object</returns>
public static ROFst UpdateRoFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver, ROFstInfo origROFst)
{
DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
// check if this rofst has been loaded, i.e. dts on file versus dts in db...
// if so, just make association to existing with docversion.
ROFst rofst = ROFst.GetByRODbID_DTS(rdi.RODbID, di.LastWriteTimeUtc);
if (rofst != null)
{
docver.DocVersionAssociations[0].MyROFst = rofst;
docver.Save();
return rofst;
}
// Read in the rofst & make the rofst record.
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
FileStream fsIn = new FileStream(rofstfilepath, FileMode.Open, FileAccess.Read, FileShare.Read);
// Create an instance of StreamReader that can read characters from the FileStream.
BinaryReader r = new BinaryReader(fsIn);
byte[] ab = r.ReadBytes((int)fsIn.Length);
fsIn.Close();
using (RODb rodb = RODb.GetJustRoDb(rdi.RODbID))
{
rofst = ROFst.MakeROFst(rodb, ab, null, di.LastWriteTimeUtc, rdi.UserID);
// Hook this into the current docversion by replacing the rofstid field in the doc version
// association object:
dva.MyROFst = rofst;
docver.Save();
// Now load any images in... type 8 - integrated graphics ro type
using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbIDNoData(rdi.RODbID))
{
Dictionary<string, int> myExistingROImages = BuildROImagesList(myROImages);
List<int> myUnChangedROImages = new List<int>();
List<string> myAddedROImages = new List<string>();
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
{
for (int i = 0; i < rofst.ROFSTLookup.myHdr.myDbs.Length; i++)
{
// walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8:
if (rofst.ROFSTLookup.myHdr.myDbs[i].children != null)
{
rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);
}
}
}
// Add references for existing RO Images to the Figure table (Figure table relates ro.fst with its images)
if (myUnChangedROImages.Count > 0)
using (FigureInfoList fil = FigureInfoList.AddByROFstIDImageIDs(rofst.ROFstID, buildImageIDString(myUnChangedROImages))) ;
}
// Now update the usages: compare old to new rofsts and update usages accordingly, i.e. modified
// values, deleted ros, etc.
UpdateROValuesText(origROFst, rofst);
return rofst;
}
}
private static Dictionary<string,int> BuildROImagesList(ROImageInfoList myROImages)
{
Dictionary<string,int> myRoImagesList = new Dictionary<string,int>();
foreach (ROImageInfo myROImage in myROImages)
myRoImagesList.Add(ROImageKey(myROImage.FileName, myROImage.DTS),myROImage.ImageID);
return myRoImagesList;
}
private static string ROImageKey(string fileName, DateTime dts)
{
return string.Format("{0}:{1}", fileName, dts);
}
private static string buildImageIDString(List<int> myROImageIDs)
{
StringBuilder sb = new StringBuilder();
string sep = "";
foreach (int imageID in myROImageIDs)
{
sb.Append(sep + imageID.ToString());
sep = ",";
}
return sb.ToString();
}
private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst)
{
ROFSTLookup origLU = new ROFSTLookup(origROFstInfo);
ROFSTLookup newLU = new ROFSTLookup(newROFst);
List<string> delList = new List<string>();
List<string> chgList = newLU.GetValueDifferences(origLU, ref delList);
string RoidList = GetRoidList(newROFst.RODbID, chgList);
List<string> activeRoids = BuildActiveROIDsForRoUsages(RoidList);
foreach (string chg in chgList)
{
if (activeRoids.Contains(chg))
{
ROFSTLookup.rochild roch = newLU.GetRoChild(chg);
string desc = string.Format("Change in RO Values: Old value = {0}, New value = {1}", origLU.GetRoValue(chg), roch.value);
// roid's are stored in database as 16 characters long in the rousages table. They may be stored
// as 12 characters in the ro.fst.
string padroid = chg.Length <= 12 ? chg + "0000" : chg;
using (RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid, desc, "Changed"))
{
foreach (RoUsageInfo roUsg in affected)
{
using (Content content = Content.Get(roUsg.MyContent.ContentID))
{
foreach (ItemInfo ii in roUsg.MyContent.ContentItems)
{
string val = newLU.GetTranslatedRoValue(padroid, ii.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
content.FixContentText(roUsg, val, roch.type, origROFstInfo);
if (content.IsDirty)
{
// Update UserID and DTS when RO Value is updated.
content.UserID = Volian.Base.Library.VlnSettings.UserID;
content.DTS = DateTime.Now;
content.Save();
}
}
}
}
}
}
}
activeRoids = BuildActiveROIDsForDRoUsages(RoidList);
foreach (string chg in chgList)
{
if (activeRoids.Contains(chg))
{
ROFSTLookup.rochild roch = newLU.GetRoChild(chg);
string desc = string.Format("Change in RO Values: Old value = {0}, New value = {1}", origLU.GetRoValue(chg), roch.value);
// roid's are stored in database as 16 characters long in the rousages table. They may be stored
// as 12 characters in the ro.fst.
string padroid = chg.Length <= 12 ? chg + "0000" : chg;
using (DROUsageInfoList affected = DROUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid.Substring(0,12), desc, "Changed"))
{
foreach (DROUsageInfo droUsg in affected)
{
Pdf.DeleteAll(droUsg.DocID);
}
}
}
}
foreach (string del in delList)
{
string desc = string.Format("Deleted RO: Value = {0}", origLU.GetRoValue(del));
string padroiddel = del.Length <= 12 ? del + "0000" : del;
using (RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroiddel, desc, "Deleted"))
{
foreach (RoUsageInfo roUsg in affected)
{
using (Content content = Content.Get(roUsg.MyContent.ContentID))
{
content.FixContentText(roUsg, "?", 0, origROFstInfo);
if (content.IsDirty)
{
// Update UserID and DTS when RO Value is updated.
content.UserID = Volian.Base.Library.VlnSettings.UserID;
content.DTS = DateTime.Now;
content.Save();
}
}
}
}
using (DROUsageInfoList Daffected = DROUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, del.Substring(0,12), desc, "Deleted"))
{
foreach (DROUsageInfo droUsg in Daffected)
{
Pdf.DeleteAll(droUsg.DocID);
}
}
}
}
private static List<string> BuildActiveROIDsForRoUsages(string RoidList)
{
List<string> activeRoids = new List<string>();
using (RoUsageInfoList activeList = RoUsageInfoList.GetROUSagesByROIDs(RoidList))
{
foreach (RoUsageInfo roui in activeList)
{
string roid = roui.ROID.ToUpper();
if (roid.EndsWith("0000")) roid = roid.Substring(0, 12);
if (!activeRoids.Contains(roid))
activeRoids.Add(roid);
}
}
return activeRoids;
}
private static List<string> BuildActiveROIDsForDRoUsages(string RoidList)
{
List<string> activeRoids = new List<string>();
using (DROUsageInfoList activeList = DROUsageInfoList.GetDROUsagesByROIDs(RoidList))
{
foreach (DROUsageInfo roui in activeList)
{
string roid = roui.ROID;
if (roid.EndsWith("0000")) roid = roid.Substring(0, 12);
if (!activeRoids.Contains(roid))
activeRoids.Add(roid);
}
}
return activeRoids;
}
private static string GetRoidList(int dbid, List<string> chgList)
{
StringBuilder sb = new StringBuilder(string.Format("{0}", dbid));
string sep=":";
foreach (string roid in chgList)
{
sb.Append(sep + roid);
sep = ",";
}
return sb.ToString();
}
private static string NewROName(string roName)
{
string retval = roName;
int iSuffix = -1;
RODbInfoList rodblist = RODbInfoList.Get();
foreach (RODbInfo rdi in rodblist)
{
if (rdi.ROName.StartsWith(roName))
{
if (rdi.ROName == roName)
iSuffix = 0;
else if (Regex.IsMatch(rdi.ROName, roName + "[_][0-9]+"))
{
int ii = int.Parse(rdi.ROName.Substring(1 + roName.Length));
if (ii > iSuffix) iSuffix = ii;
}
}
}
if (iSuffix >= 0)
retval = string.Format("{0}_{1}", roName, iSuffix + 1);
return retval;
}
private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages)
{
for (int i = 0; i < rochild.Length; i++)
{
if (rochild[i].type == 8) this.AddGraphic(rdi, rochild[i].value, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);
if (rochild[i].children != null) this.MigrateRoFstGraphics(rdi, rochild[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);
}
}
private void AddGraphic(RODbInfo rdi, string p, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages)
{
if (p == null) return;
string imgname = p.Substring(0, p.IndexOf('\n'));
int thedot = imgname.LastIndexOf('.');
string fname = imgname;
if (thedot == -1 || (thedot != (imgname.Length - 4)))
{
RODbConfig roDbCfg = new RODbConfig(rdi.Config);
fname += string.Format(".{0}", roDbCfg.GetDefaultGraphicExtension());
}
string imgfile = rdi.FolderPath + @"\" + fname;
ROImage roImg = null;
if (File.Exists(imgfile))
{
FileInfo fi = new FileInfo(imgfile);
// if the roimage record exists, don't create a new one...
string key = ROImageKey(imgname, fi.LastWriteTimeUtc);
if (myExistingROImages.ContainsKey(key))
{
int imageID = myExistingROImages[key];
if (!myUnChangedROImages.Contains(imageID))
myUnChangedROImages.Add(imageID);
}
else
{
if (!myAddedROImages.Contains(key))
{
FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.Read);
BinaryReader r = new BinaryReader(fsIn);
byte[] ab = r.ReadBytes((int)fsIn.Length);
r.Close();
fsIn.Close();
byte[] cmp = ROImageInfo.Compress(ab);
int existingImageID = FindExisting(myExistingROImages, imgname, imgfile, cmp, ab);
if (existingImageID != 0)
{
if (!myUnChangedROImages.Contains(existingImageID))
myUnChangedROImages.Add(existingImageID);
return;
}
ROImageConfig rc = new ROImageConfig();
rc.Image_Size = ab.Length.ToString();
using (roImg = ROImage.MakeROImage(rodb, imgname, ROImageInfo.Compress(ab), rc.ToString(), fi.LastWriteTimeUtc, "Migration"))
{
using (Figure figure = Figure.GetByROFstID_ImageID(this.ROFstID, roImg.ImageID))
{
if (figure != null) return;
Figure.MakeFigure(rofst, roImg, null).Dispose();
myAddedROImages.Add(key);
}
}
}
}
}
}
private int FindExisting(Dictionary<string, int> myExistingROImages, string imgname, string imgfile, byte[] cmpFileContents, byte[] fileContents)
{
// the reason the following check is necessary is that the DTS can be off by hours
// because of the way windows handles Daylight savings time for file DTS.
FileInfo fi = new FileInfo(imgfile);
DateTime dts = fi.LastWriteTimeUtc;
// loop through myExistingROImages looking for matching name.
foreach (string key in myExistingROImages.Keys)
{
// if found, compare the date/time stamp
string part1 = Regex.Replace(key, ":.*$", "");
string part2 = Regex.Replace(key, "^.*?:", "");
if (part1.ToUpper() == imgname.ToUpper())
{
// if date/time stamps matches date, minutes & seconds, compare contents
string cmp1 = Regex.Replace(dts.ToString(), " [0-9]*:", " x:");
cmp1 = Regex.Replace(cmp1, " [AP]", " x");
string cmp2 = Regex.Replace(part2, " [0-9]*:", " x:");
cmp2 = Regex.Replace(cmp2, " [AP]", " x");
if (cmp1==cmp2)
{
// compare contents
int imgId = myExistingROImages[key];
using (ROImageInfo roii = ROImageInfo.Get(imgId))
{
ROImageConfig roicfg = new ROImageConfig(roii);
int size = Convert.ToInt32(roicfg.Image_Size);
byte[] tmpb = ROImageInfo.Decompress(roii.Content, size);
if (ByteArrayCompare(roii.Content, cmpFileContents))
return imgId;
if (ByteArrayCompare(tmpb, fileContents))
return imgId;
}
}
}
}
return 0;
}
private bool ByteArrayCompare(byte[] ba1, byte[] ba2)
{
// we wrote our own byte array comparinson because the system's 'equals' did not work!
if (ba1.Length != ba2.Length) return false;
for (int i = 0; i < ba1.Length; i++)
if (ba1[i] != ba2[i]) return false;
return true;
}
private ROImageInfo GetMyImage(Dictionary<string, ROImageInfo> myImages, string imgname, DateTime dts)
{
string key = string.Format("{0}:{1}", imgname, dts);
if(myImages.ContainsKey(key))
return myImages[key];
return null;
}
#endregion
#endregion
public bool IsSetpointDB(int id)
{
ROFSTLookup.rodbi[] dbs = ROFSTLookup.GetRODatabaseList();
foreach (ROFSTLookup.rodbi rodbi in dbs)
{
if (id == rodbi.dbiID)
return (rodbi.dbiAP.StartsWith("SP"));
}
return false;
}
public event ROFstInfoROTableUpdateEvent ROTableUpdate;
public List<string> OnROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
if (ROTableUpdate != null) return ROTableUpdate(sender, args);
return null;
}
public static ROFstInfo GetJustROFst(int rOFstID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFstInfo tmp = GetCachedByPrimaryKey(rOFstID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ROFstInfo>(new PKCriteriaJustROFst(rOFstID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ROFstInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ROFstInfo.Get", ex);
}
}
[Serializable()]
protected class PKCriteriaJustROFst
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteriaJustROFst(int rOFstID)
{
_ROFstID = rOFstID;
}
}
private void DataPortal_Fetch(PKCriteriaJustROFst criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getJustROFst";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ROFstInfo.DataPortal_Fetch", ex);
}
}
}
public class ROFstInfoROTableUpdateEventArgs
{
private string _ROText;
public string ROText
{
get { return _ROText; }
set { _ROText = value; }
}
private string _OldGridXml;
public string OldGridXml
{
get { return _OldGridXml; }
set { _OldGridXml = value; }
}
public ROFstInfoROTableUpdateEventArgs(string rotext, string oldgridxml)
{
_ROText = rotext;
_OldGridXml = oldgridxml;
}
}
public partial class ROFstInfoList
{
[Serializable()]
private class RoFstSizeCriteria
{
public RoFstSizeCriteria(int roDbID, int len)
{
_RODbID = roDbID;
_Len = len;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
private int _Len;
public int Len
{
get { return _Len; }
set { _Len = value; }
}
}
public static ROFstInfoList GetBySize(int roDbID, int len)
{
try
{
ROFstInfoList tmp = DataPortal.Fetch<ROFstInfoList>(new RoFstSizeCriteria(roDbID, len));
ROFstInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RoFstInfoList.GetBySize", ex);
}
}
private void DataPortal_Fetch(RoFstSizeCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfoList.DataPortal_FetchBySize", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRoFstBySize";
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
cm.Parameters.AddWithValue("@Len", criteria.Len);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
this.Add(new ROFstInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfoList.DataPortal_FetchBySize", ex);
throw new DbCslaException("ROFstInfoList.DataPortal_FetchBySize", ex);
}
this.RaiseListChangedEvents = true;
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace VEPROMS.CSLA.Library
{
public partial class RolePermission : BusinessBase<RolePermission>
{
public static RolePermission New()
{
return new RolePermission(1, 1, 1);
}
public bool ReadAccess
{
get { return ((PermValue & 1) == 1); }
set { PermValue = (value ? PermValue | 1 : PermValue ^ (PermValue & 1)); }
}
public bool WriteAccess
{
get { return ((PermValue & 2) == 2); }
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
}
public bool CreateAccess
{
get { return ((PermValue & 4) == 4); }
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
}
public bool DeleteAccess
{
get { return ((PermValue & 8) == 8); }
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
}
public List<vlnValueKey> PermADLookup
{
get { return Permission.PermADLookup; }
}
public List<vlnValueKey> PermLevelLookup
{
get { return Permission.PermLevelLookup; }
}
}
public class PermLookup
{
public List<vlnValueKey> PermADLookup
{
get { return Permission.PermADLookup; }
}
public List<vlnValueKey> PermLevelLookup
{
get { return Permission.PermLevelLookup; }
}
}
}
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace VEPROMS.CSLA.Library
{
public partial class Permission
{
private static List<vlnValueKey> _permADLookup;
private static List<vlnValueKey> _permLevelLookup;
private static void setupLookup()
{
if (_permADLookup == null)
{
_permADLookup = new List<vlnValueKey>();
_permADLookup.Add(new vlnValueKey(0,"Allow"));
_permADLookup.Add(new vlnValueKey(1, "Deny"));
}
if (_permLevelLookup == null)
{
_permLevelLookup = new List<vlnValueKey>();
_permLevelLookup.Add(new vlnValueKey(0, "Security"));
_permLevelLookup.Add(new vlnValueKey(1, "System"));
_permLevelLookup.Add(new vlnValueKey(2, "RO"));
_permLevelLookup.Add(new vlnValueKey(3, "Procedure"));
_permLevelLookup.Add(new vlnValueKey(4, "Sections"));
_permLevelLookup.Add(new vlnValueKey(5, "Steps"));
_permLevelLookup.Add(new vlnValueKey(6, "Comments"));
}
}
public static List<vlnValueKey> PermADLookup
{
get { setupLookup(); return _permADLookup; }
}
public static List<vlnValueKey> PermLevelLookup
{
get { setupLookup(); return _permLevelLookup; }
}
public bool ReadAccess
{
get { return ((PermValue & 1) == 1); }
set { PermValue = (value?PermValue|1:PermValue^(PermValue&1));}
}
public bool WriteAccess
{
get { return ((PermValue & 2) == 2); }
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
}
public bool CreateAccess
{
get { return ((PermValue & 4) == 4); }
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
}
public bool DeleteAccess
{
get { return ((PermValue & 8) == 8); }
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
}
// partial class Extension : extensionBase
// {
// TODO: Override automatic defaults
// public virtual int DefaultPermad
// {
// get { return 0; }
// }
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
}
}
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace VEPROMS.CSLA.Library
{
public partial class RolePermission : BusinessBase<RolePermission>
{
public static RolePermission New()
{
return new RolePermission(1, 1, 1);
}
public bool ReadAccess
{
get { return ((PermValue & 1) == 1); }
set { PermValue = (value ? PermValue | 1 : PermValue ^ (PermValue & 1)); }
}
public bool WriteAccess
{
get { return ((PermValue & 2) == 2); }
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
}
public bool CreateAccess
{
get { return ((PermValue & 4) == 4); }
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
}
public bool DeleteAccess
{
get { return ((PermValue & 8) == 8); }
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
}
public List<vlnValueKey> PermADLookup
{
get { return Permission.PermADLookup; }
}
public List<vlnValueKey> PermLevelLookup
{
get { return Permission.PermLevelLookup; }
}
}
public class PermLookup
{
public List<vlnValueKey> PermADLookup
{
get { return Permission.PermADLookup; }
}
public List<vlnValueKey> PermLevelLookup
{
get { return Permission.PermLevelLookup; }
}
}
}
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public class vlnValueKey
{
public vlnValueKey() { ;}
public vlnValueKey(int key, string value)
{
_key = key;
_value = value;
}
private int _key;
public int Key
{
get { return _key; }
}
private string _value;
public string Value
{
get { return _value; }
}
public override string ToString()
{
return _value;
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace Volian.Object.Library
{
/// <summary>
/// Extensions
/// </summary>
public partial class UserInfo : ReadOnlyBase<UserInfo>
{
public string FullName
{
get { return LastName + ", " + FirstName; }
}
}
}
@@ -0,0 +1,40 @@
Adding special flag chars to tokens:
?. means the following for !section transitions
for proc - if current, don't put out text, if !current, put out text
for sect - if curproc: if cursect, don't put out text; if !cursect, put out text
if !curproc: if default sect, don't put out text; if !default sect, put out text
DONE: "0" TransFormat="{Proc Num}, {Proc Title}, Step {First Step}" TransUI="ProcMenu, SectDefault, StepAllowNone, StepFirst"
DONE: "1" TransFormat="{First Step}" TransUI="ProcCur, SectCur, StepFirst"
DONE: "2" TransFormat="{First Step}, {.}, {.}, {.} and {Last Step}" TransUI="ProcCur, SectCur, StepFirst, StepLast"
DONE: "3" TransFormat="{First Step} thru {Last Step} of {?.Proc Num}, {?.Proc Title}, {?.Sect Hdr}" TransUI="ProcMenu, SectMenuStep, StepFirst, StepLast"
DONE: "4" TransFormat="{?.Sect Title}, Step {First Step}" TransUI="ProcCur, SectMenuAny, StepAllowNone, StepFirst"
DONE: "5" TransFormat="{Proc Num}, {Proc Title}, {?.Sect Hdr}, Step {First Step}"TransUI="ProcMenu, SectMenuAny, StepAllowNone, StepFirst"
SECTION TRANSITIONS (calloway used as test...
Menu [format] comment
"{Proc Num}, {Proc Title}, Step {Sect Num}{First Step}", same as menu
"{Sect Num}{First Step} ( Within the current section )", {Sect Num}{First Step}
"{Sect Num}{First Step}, {.}, {.}, {.} and {Sect Num}{Last Step}", same as menu current section
"{Sect Num}{First Step} thru {Sect Num}{Last Step}", same as menu step section in current proc
"{Sect Num}{First Step} ( To a different section )", {Sect Num}, Step {?.Sect Num}{?.First Step} - no stepnumber needed
"{Sect Num}{First Step}, {Sect Title} ( To a different section )" {Sect Hdr}, Step{{Sect Num}{First Step} - puts all out even if current.
"{Sect Num}" {Sect Num} - prompts for step too, but only lists sect num, Go To step though
"{Step}" {Step} - prompts for proc, step sect & step number. (sometimes gives ?)
// made up the following string so that the token processing for setting
// up the menu enums would work as expected.
private string[] DefaultSectionTransTokenStr =
{
"{Proc Num}, {Proc Title}, Step {First Step}",
"{First Step} ( Within the current section )",
"{First Step}, {.}, {.}, {.} and {Last Step}",
"{Sect Num}.{First Step} thru {Sect Num}.{Last Step}",
"{Sect Num}.{First Step} ( To a different section )",
"{Sect Num}.{First Step}, {Sect Title} ( To a different section )"
};
@@ -0,0 +1,39 @@
Adding special flag chars to tokens:
?. means the following for !section transitions
for proc - if current, don't put out text, if !current, put out text
for sect - if curproc: if cursect, don't put out text; if !cursect, put out text
if !curproc: if default sect, don't put out text; if !default sect, put out text
DONE: "0" TransFormat="{Proc Num}, {Proc Title}, Step {First Step}" TransUI="ProcMenu, SectDefault, StepAllowNone, StepFirst"
DONE: "1" TransFormat="{First Step}" TransUI="ProcCur, SectCur, StepFirst"
DONE: "2" TransFormat="{First Step}, {.}, {.}, {.} and {Last Step}" TransUI="ProcCur, SectCur, StepFirst, StepLast"
DONE: "3" TransFormat="{First Step} thru {Last Step} of {?.Proc Num}, {?.Proc Title}, {?.Sect Hdr}" TransUI="ProcMenu, SectMenuStep, StepFirst, StepLast"
DONE: "4" TransFormat="{?.Sect Title}, Step {First Step}" TransUI="ProcCur, SectMenuAny, StepAllowNone, StepFirst"
DONE: "5" TransFormat="{Proc Num}, {Proc Title}, {?.Sect Hdr}, Step {First Step}"TransUI="ProcMenu, SectMenuAny, StepAllowNone, StepFirst"
SECTION TRANSITIONS (calloway used as test...
Menu [format] comment
"{Proc Num}, {Proc Title}, Step {Sect Num}{First Step}", same as menu
"{Sect Num}{First Step} ( Within the current section )", {Sect Num}{First Step}
"{Sect Num}{First Step}, {.}, {.}, {.} and {Sect Num}{Last Step}", same as menu current section
"{Sect Num}{First Step} thru {Sect Num}{Last Step}", same as menu step section in current proc
"{Sect Num}{First Step} ( To a different section )", {Sect Num}, Step {?.Sect Num}{?.First Step} - no stepnumber needed
"{Sect Num}{First Step}, {Sect Title} ( To a different section )" {Sect Hdr}, Step{{Sect Num}{First Step} - puts all out even if current.
// made up the following string so that the token processing for setting
// up the menu enums would work as expected.
private string[] DefaultSectionTransTokenStr =
{
"{Proc Num}, {Proc Title}, Step {First Step}",
"{First Step} ( Within the current section )",
"{First Step}, {.}, {.}, {.} and {Last Step}",
"{Sect Num}.{First Step} thru {Sect Num}.{Last Step}",
"{Sect Num}.{First Step} ( To a different section )",
"{Sect Num}.{First Step}, {Sect Title} ( To a different section )"
};
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public class vlnValueKey
{
public vlnValueKey() { ;}
public vlnValueKey(int key, string value)
{
_key = key;
_value = value;
}
private int _key;
public int Key
{
get { return _key; }
}
private string _value;
public string Value
{
get { return _value; }
}
public override string ToString()
{
return _value;
}
}
}
@@ -0,0 +1,974 @@
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
{
if (_DocStyleList == null)
{
DocStyleList tmp = new DocStyleList(SelectNodes("DocStyle"));
DocStyleList retval = new DocStyleList(null);
foreach (DocStyle ds in tmp)
{
if (!ds.Inactive) retval.Add(ds);
}
_DocStyleList = retval;
}
return (_DocStyleList);
}
set { _DocStyleList = value; }
}
public DocStyles(XmlNode xmlNode) : base(xmlNode) { }
}
#endregion
#region DocStyleAll
#region DocStyle
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DocStyle : vlnFormatItem, IVlnIndexedFormatItem
{
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 IndexOtherThanFirstPage
[Category("Miscellaneous")]
[Description("IndexOtherThanFirstPage")]
private LazyLoad<int?> _IndexOtherThanFirstPage;
public int? IndexOtherThanFirstPage
{
get
{
return LazyLoad(ref _IndexOtherThanFirstPage, "@IndexOtherThanFirstPage");
}
}
#endregion
#region IsStepSection
[Category("Miscellaneous")]
[Description("Is a Step Section")]
private LazyLoad<bool> _IsStepSection;
public bool IsStepSection
{
get
{
return LazyLoad(ref _IsStepSection, "@IsStepSection");
}
}
#endregion
#region Inactive
[Category("Miscellaneous")]
[Description("Is Active Section Type")]
private LazyLoad<bool> _Inactive;
public bool Inactive
{
get
{
return LazyLoad(ref _Inactive, "@Inactive");
}
}
#endregion
#region LandscapePageList
[Category("Miscellaneous")]
[Description("Should PageList be landscape")]
private LazyLoad<bool> _LandscapePageList;
public bool LandscapePageList
{
get
{
return LazyLoad(ref _LandscapePageList, "@LandscapePageList");
}
}
#endregion
#region ShowSectionTitles
[Category("Miscellaneous")]
[Description("Should Section Titles be shown")]
private LazyLoad<bool> _ShowSectionTitles;
public bool ShowSectionTitles
{
get
{
return LazyLoad(ref _ShowSectionTitles, "@ShowSectionTitles");
}
}
#endregion
#region ResetFirstPageOnSection
[Category("Miscellaneous")]
[Description("Reset first page of section on Separate pagination section")]
private LazyLoad<bool> _ResetFirstPageOnSection;
public bool ResetFirstPageOnSection
{
get
{
return LazyLoad(ref _ResetFirstPageOnSection, "@ResetFirstPageOnSection");
}
}
#endregion
#region IncludeInTOC
[Category("Miscellaneous")]
[Description("Include in Auto Table Of Contents")]
private LazyLoad<bool> _IncludeInTOC;
public bool IncludeInTOC
{
get
{
return LazyLoad(ref _IncludeInTOC, "@IncludeInTOC");
}
}
#endregion
#region UseCheckOffs
[Category("Miscellaneous")]
[Description("Section Uses Checkoffs")]
private LazyLoad<bool> _UseCheckOffs;
public bool UseCheckOffs
{
get
{
return LazyLoad(ref _UseCheckOffs, "@UseCheckOffs");
}
}
#endregion
#region UseCheckOffs
[Category("Miscellaneous")]
[Description("Section Uses MetaSection ColSByLevel")]
private LazyLoad<bool> _UseColSByLevel;
public bool UseColSByLevel
{
get
{
return LazyLoad(ref _UseColSByLevel, "@UseColSByLevel");
}
}
#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 CancelSectTitle
[Category("Miscellaneous")]
[Description("Section Cancel Section Title")]
private LazyLoad<bool> _CancelSectTitle;
public bool CancelSectTitle
{
get
{
return LazyLoad(ref _CancelSectTitle, "@CancelSectTitle");
}
}
#endregion
#region CenterLine
//CenterLineX="261.9" CenterLineYTop="673.2" CenterLineYBottom="44.2"
private LazyLoad<float?> _CenterLineX;
[Category("CenterLine")]
[DisplayName("X Location")]
[Description("Distance from left side of page")]
public float? CenterLineX
{
get
{
return LazyLoad(ref _CenterLineX, "@CenterLineX");
}
}
private LazyLoad<float?> _CenterLineYTop;
[Category("CenterLine")]
[DisplayName("Y Top Location")]
[Description("starting vertical point of line")]
public float? CenterLineYTop
{
get
{
return LazyLoad(ref _CenterLineYTop, "@CenterLineYTop");
}
}
private LazyLoad<float?> _CenterLineYBottom;
[Category("CenterLine")]
[DisplayName("Y Bottom Location")]
[Description("ending vertical point of line")]
public float? CenterLineYBottom
{
get
{
return LazyLoad(ref _CenterLineYBottom, "@CenterLineYBottom");
}
}
private LazyLoad<float?> _CLineWidth;
[Category("CenterLine")]
[DisplayName("Line Width")]
[Description("Width of Lines Internal to Boxes")]
public float? CLineWidth
{
get
{
return LazyLoad(ref _CLineWidth, "@CLineWidth");
}
}
#endregion
#region OptionalSectionContent
[Category("Miscellaneous")]
[Description("Section Optional Content")]
private LazyLoad<bool> _OptionalSectionContent;
public bool OptionalSectionContent
{
get
{
return LazyLoad(ref _OptionalSectionContent, "@OptionalSectionContent");
}
}
#endregion
#region SpecialStepsFoldout
[Category("Miscellaneous")]
[Description("Section Special Steps Foldout")]
private LazyLoad<bool> _SpecialStepsFoldout;
public bool SpecialStepsFoldout
{
get
{
return LazyLoad(ref _SpecialStepsFoldout, "@SpecialStepsFoldout");
}
}
[Category("Miscellaneous")]
[Description("Section Extra Line Header")]
private LazyLoad<bool> _ExtraLineHeader;
public bool ExtraLineHeader
{
get
{
return LazyLoad(ref _ExtraLineHeader, "@ExtraLineHeader");
}
}
#endregion
#region UndSpecialStepsFoldout
[Category("Miscellaneous")]
[Description("Section Cancel Section Title")]
private LazyLoad<bool> _UndSpecialStepsFoldout;
public bool UndSpecialStepsFoldout
{
get
{
return LazyLoad(ref _UndSpecialStepsFoldout, "@UndSpecialStepsFoldout");
}
}
#endregion
#region AlignHLSTabWithSect
[Category("Miscellaneous")]
[Description("Align HLS Tab With Sect")]
private LazyLoad<bool> _AlignHLSTabWithSect;
public bool AlignHLSTabWithSect
{
get
{
return LazyLoad(ref _AlignHLSTabWithSect, "@AlignHLSTabWithSect");
}
}
#endregion
#region ComponentList
[Category("Miscellaneous")]
[Description("Component List")]
private LazyLoad<bool> _ComponentList;
public bool ComponentList
{
get
{
return LazyLoad(ref _ComponentList, "@ComponentList");
}
}
#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 SectTop _SectTop;
public SectTop SectTop
{
get
{
return (_SectTop == null ? _SectTop = new SectTop(SelectSingleNode("SectTop")) : _SectTop);
}
}
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 : vlnIndexedFormatList<DocStyle>
{
public DocStyleList(XmlNodeList xmlNodeList) : base(xmlNodeList, null) { }
}
#endregion
#region Layout
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Layout : vlnFormatItem
{
public Layout(XmlNode xmlNode) : base(xmlNode) { }
public Layout() : base() { }
#region TopMargin
private LazyLoad<float?> _TopMargin;
[Category("Layout")]
[DisplayName("Top Margin on Printed Page")]
[Description("Top Margin on Printed Page")]
public float? TopMargin
{
get
{
return LazyLoad(ref _TopMargin, "@TopMargin");
}
}
#endregion
#region FooterLength
private LazyLoad<float?> _FooterLength;
[Category("Location")]
[DisplayName("Number of lines required for footer")]
[Description("Number of lines required for footer")]
public float? FooterLength
{
get
{
return LazyLoad(ref _FooterLength, "@FooterLength");
}
}
#endregion
#region LeftMargin
private LazyLoad<float?> _LeftMargin;
[Category("Location")]
[DisplayName("Size of left margin")]
[Description("Size of left margin")]
public float? LeftMargin
{
get
{
return LazyLoad(ref _LeftMargin, "@LeftMargin");
}
}
#endregion
#region PageLength
private LazyLoad<float?> _PageLength;
[Category("Location")]
[DisplayName("Length of Page")]
[Description("Length of Page")]
public float? PageLength
{
get
{
return LazyLoad(ref _PageLength, "@PageLength");
}
}
#endregion
#region PageWidth
private LazyLoad<float?> _PageWidth;
[Category("Location")]
[DisplayName("Width of Page")]
[Description("Width of Page")]
public float? PageWidth
{
get
{
return LazyLoad(ref _PageWidth, "@PageWidth");
}
}
#endregion
#region TableUpperLimit
private LazyLoad<float?> _TableUpperLimit;
[Category("Location")]
[DisplayName("Table's right margin")]
[Description("Table's right margin")]
public float? TableUpperLimit
{
get
{
return LazyLoad(ref _TableUpperLimit, "@TableUpperLimit");
}
}
#endregion
#region MSWordXAdj
private LazyLoad<float?> _MSWordXAdj;
[Category("Location")]
[DisplayName("MSWord X Adjustment")]
[Description("X Placement of PDF during Print")]
public float? MSWordXAdj
{
get
{
return LazyLoad(ref _MSWordXAdj, "@MSWordXAdj");
}
}
#endregion
#region MSWordYAdj
private LazyLoad<float?> _MSWordYAdj;
[Category("Location")]
[DisplayName("MSWord Y Adjustment")]
[Description("Y Placement of PDF during Print")]
public float? MSWordYAdj
{
get
{
return LazyLoad(ref _MSWordYAdj, "@MSWordYAdj");
}
}
#endregion
#region SectionMacro
private LazyLoad<string> _SectionMacro;
[Category("Extras")]
[DisplayName("Section Macro")]
[Description("Section Macro Prints With Title")]
public string SectionMacro
{
get
{
return LazyLoad(ref _SectionMacro, "@SectionMacro");
}
}
#endregion
#region CenterToStepThenPage
[Category("Layout")]
[Description("CenterToStepThenPage")]
private LazyLoad<bool> _CenterToStepThenPage;
public bool CenterToStepThenPage
{
get
{
return LazyLoad(ref _CenterToStepThenPage, "@CenterToStepThenPage");
}
}
#endregion
}
#endregion
#region SectTop
[TypeConverter(typeof(ExpandableObjectConverter))]
public class SectTop : vlnFormatItem
{
public SectTop(XmlNode xmlNode) : base(xmlNode) { }
public SectTop() : base() { }
#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 Margin
private LazyLoad<float?> _Margin;
[Category("Section Continue Msg")]
[DisplayName("Margin for Section top msg")]
[Description("Margin for Section top msg")]
public float? Margin
{
get
{
return LazyLoad(ref _Margin, "@Margin");
}
}
#endregion
#region MaxLen
private LazyLoad<int?> _MaxLen;
[Category("Section Continue Msg")]
[DisplayName("MaxLen for text within the column")]
[Description("MaxLen for text within the column")]
public int? MaxLen
{
get
{
return LazyLoad(ref _MaxLen, "@MaxLen");
}
}
#endregion
#region Message
private LazyLoad<string> _Message;
[Category("Continue Msg")]
[DisplayName("Section Top Continue Msg")]
[Description("Section Top Continue Msg")]
public string Message
{
get
{
return LazyLoad(ref _Message, "@Message");
}
}
#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);
}
}
private SectionTitle _SectionTitle;
public SectionTitle SectionTitle
{
get
{
return (_SectionTitle == null ? _SectionTitle = new SectionTitle(SelectSingleNode("SectionTitle")) : _SectionTitle);
}
}
#endregion
}
#endregion
#region Top
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Top : vlnFormatItem
{
public Top(XmlNode xmlNode) : base(xmlNode) { }
public Top() : base() { }
#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 Margin
private LazyLoad<float?> _Margin;
[Category("Continue Msg")]
[DisplayName("Margin for top msg")]
[Description("Margin for top msg")]
public float? Margin
{
get
{
return LazyLoad(ref _Margin, "@Margin");
}
}
#endregion
#region UseStepTabs
private LazyLoad<bool> _UseStepTabs;
[Category("Continue Msg")]
[DisplayName("Flag to use step tabs")]
[Description("Flag to use step tabs")]
public bool UseStepTabs
{
get
{
return LazyLoad(ref _UseStepTabs, "@UseStepTabs");
}
}
#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 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 Margin
private LazyLoad<float?> _Margin;
[Category("Continue Msg")]
[DisplayName("Margin for bottom msg")]
[Description("Margin for bottom msg")]
public float? Margin
{
get
{
return LazyLoad(ref _Margin, "@Margin");
}
}
#endregion
#region MarginR BGE
private LazyLoad<float?> _MarginR;
[Category("Continue Msg")]
[DisplayName("Margin for bottom msg RNO Column (if in both columns)")]
[Description("Margin for bottom msg RNO Column (if in both columns)")]
public float? MarginR
{
get
{
return LazyLoad(ref _MarginR, "@MarginR");
}
}
#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");
}
}
private LazyLoad<bool> _NoOverrideSpace;
public bool NoOverrideSpace
{
get
{
return LazyLoad(ref _NoOverrideSpace, "@NoOverrideSpace");
}
}
#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
#region SectionTitle
[TypeConverter(typeof(ExpandableObjectConverter))]
public class SectionTitle : vlnFormatItem
{
public SectionTitle(XmlNode xmlNode) : base(xmlNode) { }
public SectionTitle() : base() { }
#region AppendToTitle
private LazyLoad<string> _AppendToTitle;
[Category("Section Title Continue Msg")]
[DisplayName("AppendToTitle")]
[Description("Append Text to Section Title For Continue Msg")]
public string AppendToTitle
{
get
{
return LazyLoad(ref _AppendToTitle, "@AppendToTitle");
}
}
#endregion
}
#endregion //SectionTitle - continue setting
#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");
}
}
public string FixedMessage
{
get
{
return Message == null ? null : Message.Replace("\n","\r\n").Replace(@"{par}","\r\n");
}
}
private LazyLoad<float?> _Margin;
public float? Margin
{
get
{
return LazyLoad(ref _Margin, "@Margin");
}
}
private LazyLoad<bool> _EndMessageOnEachSubSection;
public bool EndMessageOnEachSubSection
{
get
{
return LazyLoad(ref _EndMessageOnEachSubSection, "@EndMessageOnEachSubSection");
}
}
#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
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,394 @@
// ========================================================================
// 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 AnnotationAuditInfoEvent(object sender);
/// <summary>
/// AnnotationAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationAuditInfoConverter))]
public partial class AnnotationAuditInfo : ReadOnlyBase<AnnotationAuditInfo>, IDisposable
{
public event AnnotationAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<AnnotationAuditInfo> _CacheList = new List<AnnotationAuditInfo>();
protected static void AddToCache(AnnotationAuditInfo annotationAuditInfo)
{
if (!_CacheList.Contains(annotationAuditInfo)) _CacheList.Add(annotationAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(AnnotationAuditInfo annotationAuditInfo)
{
while (_CacheList.Contains(annotationAuditInfo)) _CacheList.Remove(annotationAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AnnotationAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move AnnotationAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
AnnotationAuditInfo tmp = _CacheList[0]; // Get the first AnnotationAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<AnnotationAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first AnnotationAuditInfo
}
}
internal static void AddList(AnnotationAuditInfoList lst)
{
foreach (AnnotationAuditInfo item in lst) AddToCache(item);
}
protected static AnnotationAuditInfo GetCachedByPrimaryKey(long auditID)
{
ConvertListToDictionary();
string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected AnnotationAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _AnnotationID;
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);
return _ItemID;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID", true);
return _TypeID;
}
}
private string _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;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base AnnotationAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check AnnotationAuditInfo.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 AnnotationAuditInfo</returns>
protected override object GetIdValue()
{
return MyAnnotationAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _AnnotationAuditInfoUnique = 0;
private static int AnnotationAuditInfoUnique
{ get { return ++_AnnotationAuditInfoUnique; } }
private int _MyAnnotationAuditInfoUnique = AnnotationAuditInfoUnique;
public int MyAnnotationAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyAnnotationAuditInfoUnique; } }
protected AnnotationAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<AnnotationAuditInfo> listAnnotationAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listAnnotationAuditInfo.Contains(this)) listAnnotationAuditInfo.Remove(this); // Remove the item from the list
if (listAnnotationAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual AnnotationAudit Get()
{
return _Editable = AnnotationAudit.Get(_AuditID);
}
public static void Refresh(AnnotationAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(AnnotationAudit tmp)
{
_AnnotationID = tmp.AnnotationID;
_ItemID = tmp.ItemID;
_TypeID = tmp.TypeID;
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_AnnotationAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static AnnotationAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a AnnotationAudit");
try
{
AnnotationAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.Constructor", ex);
throw new DbCslaException("AnnotationAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_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");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.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 = "getAnnotationAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("AnnotationAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationAuditInfoExtension _AnnotationAuditInfoExtension = new AnnotationAuditInfoExtension();
[Serializable()]
partial class AnnotationAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationAuditInfo)
{
// Return the ToString value
return ((AnnotationAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// AnnotationAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(AnnotationAuditInfoListConverter))]
public partial class AnnotationAuditInfoList : ReadOnlyListBase<AnnotationAuditInfoList, AnnotationAuditInfo>, 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<AnnotationAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (AnnotationAuditInfo tmp in this)
{
tmp.Changed += new AnnotationAuditInfoEvent(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 (AnnotationAuditInfo tmp in this)
{
tmp.Changed -= new AnnotationAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static AnnotationAuditInfoList _AnnotationAuditInfoList = null;
/// <summary>
/// Return a list of all AnnotationAuditInfo.
/// </summary>
public static AnnotationAuditInfoList Get()
{
try
{
if (_AnnotationAuditInfoList != null)
return _AnnotationAuditInfoList;
AnnotationAuditInfoList tmp = DataPortal.Fetch<AnnotationAuditInfoList>();
AnnotationAuditInfo.AddList(tmp);
tmp.AddEvents();
_AnnotationAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all AnnotationAuditInfo.
/// </summary>
public static void Reset()
{
_AnnotationAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static AnnotationAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<AnnotationAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on AnnotationAuditInfoList.Get", ex);
// }
//}
private AnnotationAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new AnnotationAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AnnotationAuditInfoList.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
AnnotationAuditInfoListPropertyDescriptor pd = new AnnotationAuditInfoListPropertyDescriptor(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 AnnotationAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private AnnotationAuditInfo Item { get { return (AnnotationAuditInfo)_Item; } }
public AnnotationAuditInfoListPropertyDescriptor(AnnotationAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class AnnotationAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationAuditInfoList)
{
// Return department and department role separated by comma.
return ((AnnotationAuditInfoList)value).Items.Count.ToString() + " AnnotationAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,394 @@
// ========================================================================
// 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 ContentAuditInfoEvent(object sender);
/// <summary>
/// ContentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentAuditInfoConverter))]
public partial class ContentAuditInfo : ReadOnlyBase<ContentAuditInfo>, IDisposable
{
public event ContentAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<ContentAuditInfo> _CacheList = new List<ContentAuditInfo>();
protected static void AddToCache(ContentAuditInfo contentAuditInfo)
{
if (!_CacheList.Contains(contentAuditInfo)) _CacheList.Add(contentAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(ContentAuditInfo contentAuditInfo)
{
while (_CacheList.Contains(contentAuditInfo)) _CacheList.Remove(contentAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ContentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move ContentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
ContentAuditInfo tmp = _CacheList[0]; // Get the first ContentAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<ContentAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ContentAuditInfo
}
}
internal static void AddList(ContentAuditInfoList lst)
{
foreach (ContentAuditInfo item in lst) AddToCache(item);
}
protected static ContentAuditInfo GetCachedByPrimaryKey(long auditID)
{
ConvertListToDictionary();
string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected ContentAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
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;
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);
return _FormatID;
}
}
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 _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base ContentAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ContentAuditInfo.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 ContentAuditInfo</returns>
protected override object GetIdValue()
{
return MyContentAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _ContentAuditInfoUnique = 0;
private static int ContentAuditInfoUnique
{ get { return ++_ContentAuditInfoUnique; } }
private int _MyContentAuditInfoUnique = ContentAuditInfoUnique;
public int MyContentAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyContentAuditInfoUnique; } }
protected ContentAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<ContentAuditInfo> listContentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listContentAuditInfo.Contains(this)) listContentAuditInfo.Remove(this); // Remove the item from the list
if (listContentAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual ContentAudit Get()
{
return _Editable = ContentAudit.Get(_AuditID);
}
public static void Refresh(ContentAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ContentAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentAudit tmp)
{
_ContentID = tmp.ContentID;
_Number = tmp.Number;
_Text = tmp.Text;
_Type = tmp.Type;
_FormatID = tmp.FormatID;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_DeleteStatus = tmp.DeleteStatus;
_ContentAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static ContentAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ContentAudit");
try
{
ContentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ContentAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ContentAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ContentAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.Constructor", ex);
throw new DbCslaException("ContentAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_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");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ContentAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.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 = "getContentAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("ContentAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ContentAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ContentAuditInfoExtension _ContentAuditInfoExtension = new ContentAuditInfoExtension();
[Serializable()]
partial class ContentAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ContentAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ContentAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentAuditInfo)
{
// Return the ToString value
return ((ContentAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentAuditInfoListConverter))]
public partial class ContentAuditInfoList : ReadOnlyListBase<ContentAuditInfoList, ContentAuditInfo>, 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<ContentAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (ContentAuditInfo tmp in this)
{
tmp.Changed += new ContentAuditInfoEvent(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 (ContentAuditInfo tmp in this)
{
tmp.Changed -= new ContentAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static ContentAuditInfoList _ContentAuditInfoList = null;
/// <summary>
/// Return a list of all ContentAuditInfo.
/// </summary>
public static ContentAuditInfoList Get()
{
try
{
if (_ContentAuditInfoList != null)
return _ContentAuditInfoList;
ContentAuditInfoList tmp = DataPortal.Fetch<ContentAuditInfoList>();
ContentAuditInfo.AddList(tmp);
tmp.AddEvents();
_ContentAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all ContentAuditInfo.
/// </summary>
public static void Reset()
{
_ContentAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static ContentAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<ContentAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on ContentAuditInfoList.Get", ex);
// }
//}
private ContentAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getContentAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ContentAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentAuditInfoList.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
ContentAuditInfoListPropertyDescriptor pd = new ContentAuditInfoListPropertyDescriptor(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 ContentAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private ContentAuditInfo Item { get { return (ContentAuditInfo)_Item; } }
public ContentAuditInfoListPropertyDescriptor(ContentAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class ContentAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentAuditInfoList)
{
// Return department and department role separated by comma.
return ((ContentAuditInfoList)value).Items.Count.ToString() + " ContentAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,406 @@
// ========================================================================
// 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 DocumentAuditInfoEvent(object sender);
/// <summary>
/// DocumentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentAuditInfoConverter))]
public partial class DocumentAuditInfo : ReadOnlyBase<DocumentAuditInfo>, IDisposable
{
public event DocumentAuditInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<DocumentAuditInfo> _CacheList = new List<DocumentAuditInfo>();
protected static void AddToCache(DocumentAuditInfo documentAuditInfo)
{
if (!_CacheList.Contains(documentAuditInfo)) _CacheList.Add(documentAuditInfo); // In AddToCache
}
protected static void RemoveFromCache(DocumentAuditInfo documentAuditInfo)
{
while (_CacheList.Contains(documentAuditInfo)) _CacheList.Remove(documentAuditInfo); // In RemoveFromCache
}
private static Dictionary<string, List<DocumentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAuditInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move DocumentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
DocumentAuditInfo tmp = _CacheList[0]; // Get the first DocumentAuditInfo
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<DocumentAuditInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first DocumentAuditInfo
}
}
internal static void AddList(DocumentAuditInfoList lst)
{
foreach (DocumentAuditInfo item in lst) AddToCache(item);
}
protected static DocumentAuditInfo GetCachedByPrimaryKey(long auditID)
{
ConvertListToDictionary();
string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected DocumentAudit _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _DocID;
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;
public byte[] DocContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocContent", true);
return _DocContent;
}
}
private string _DocAscii = string.Empty;
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 string _FileExtension = string.Empty;
public string FileExtension
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FileExtension", true);
return _FileExtension;
}
}
private byte[] _DocPdf;
public byte[] DocPdf
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocPdf", true);
return _DocPdf;
}
}
private int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
}
// CSLATODO: Replace base DocumentAuditInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentAuditInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check DocumentAuditInfo.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 DocumentAuditInfo</returns>
protected override object GetIdValue()
{
return MyDocumentAuditInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _DocumentAuditInfoUnique = 0;
private static int DocumentAuditInfoUnique
{ get { return ++_DocumentAuditInfoUnique; } }
private int _MyDocumentAuditInfoUnique = DocumentAuditInfoUnique;
public int MyDocumentAuditInfoUnique // Absolutely Unique ID - Info
{ get { return _MyDocumentAuditInfoUnique; } }
protected DocumentAuditInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
List<DocumentAuditInfo> listDocumentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listDocumentAuditInfo.Contains(this)) listDocumentAuditInfo.Remove(this); // Remove the item from the list
if (listDocumentAuditInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
public virtual DocumentAudit Get()
{
return _Editable = DocumentAudit.Get(_AuditID);
}
public static void Refresh(DocumentAudit tmp)
{
string key = tmp.AuditID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (DocumentAuditInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(DocumentAudit tmp)
{
_DocID = tmp.DocID;
_LibTitle = tmp.LibTitle;
_DocContent = tmp.DocContent;
_DocAscii = tmp.DocAscii;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_FileExtension = tmp.FileExtension;
_DocPdf = tmp.DocPdf;
_DeleteStatus = tmp.DeleteStatus;
_DocumentAuditInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static DocumentAuditInfo Get(long auditID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a DocumentAudit");
try
{
DocumentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<DocumentAuditInfo>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up DocumentAuditInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentAuditInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal DocumentAuditInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.Constructor", ex);
throw new DbCslaException("DocumentAuditInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_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");
_FileExtension = dr.GetString("FileExtension");
_DocPdf = (byte[])dr.GetValue("DocPdf");
_DeleteStatus = dr.GetInt32("DeleteStatus");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentAuditInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.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 = "getDocumentAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("DocumentAuditInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("DocumentAuditInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
DocumentAuditInfoExtension _DocumentAuditInfoExtension = new DocumentAuditInfoExtension();
[Serializable()]
partial class DocumentAuditInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(DocumentAuditInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class DocumentAuditInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentAuditInfo)
{
// Return the ToString value
return ((DocumentAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,205 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// DocumentAuditInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(DocumentAuditInfoListConverter))]
public partial class DocumentAuditInfoList : ReadOnlyListBase<DocumentAuditInfoList, DocumentAuditInfo>, 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<DocumentAuditInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (DocumentAuditInfo tmp in this)
{
tmp.Changed += new DocumentAuditInfoEvent(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 (DocumentAuditInfo tmp in this)
{
tmp.Changed -= new DocumentAuditInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static DocumentAuditInfoList _DocumentAuditInfoList = null;
/// <summary>
/// Return a list of all DocumentAuditInfo.
/// </summary>
public static DocumentAuditInfoList Get()
{
try
{
if (_DocumentAuditInfoList != null)
return _DocumentAuditInfoList;
DocumentAuditInfoList tmp = DataPortal.Fetch<DocumentAuditInfoList>();
DocumentAuditInfo.AddList(tmp);
tmp.AddEvents();
_DocumentAuditInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on DocumentAuditInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all DocumentAuditInfo.
/// </summary>
public static void Reset()
{
_DocumentAuditInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static DocumentAuditInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<DocumentAuditInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on DocumentAuditInfoList.Get", ex);
// }
//}
private DocumentAuditInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocumentAudits";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new DocumentAuditInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DocumentAuditInfoList.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
DocumentAuditInfoListPropertyDescriptor pd = new DocumentAuditInfoListPropertyDescriptor(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 DocumentAuditInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private DocumentAuditInfo Item { get { return (DocumentAuditInfo)_Item; } }
public DocumentAuditInfoListPropertyDescriptor(DocumentAuditInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class DocumentAuditInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentAuditInfoList)
{
// Return department and department role separated by comma.
return ((DocumentAuditInfoList)value).Items.Count.ToString() + " DocumentAudits";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,902 @@
// ========================================================================
// 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>
/// EntryAudit Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(EntryAuditConverter))]
public partial class EntryAudit : BusinessBase<EntryAudit>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<EntryAudit> _RefreshEntryAudits = new List<EntryAudit>();
private void AddToRefreshList(List<EntryAudit> refreshEntryAudits)
{
if (IsDirty)
refreshEntryAudits.Add(this);
}
private void BuildRefreshList()
{
_RefreshEntryAudits = new List<EntryAudit>();
AddToRefreshList(_RefreshEntryAudits);
}
private void ProcessRefreshList()
{
foreach (EntryAudit tmp in _RefreshEntryAudits)
{
EntryAuditInfo.Refresh(tmp);
}
}
#endregion
#region Collection
private static List<EntryAudit> _CacheList = new List<EntryAudit>();
protected static void AddToCache(EntryAudit entryAudit)
{
if (!_CacheList.Contains(entryAudit)) _CacheList.Add(entryAudit); // In AddToCache
}
protected static void RemoveFromCache(EntryAudit entryAudit)
{
while (_CacheList.Contains(entryAudit)) _CacheList.Remove(entryAudit); // In RemoveFromCache
}
private static Dictionary<string, List<EntryAudit>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAudit>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move EntryAudit(s) from temporary _CacheList to _CacheByPrimaryKey
{
EntryAudit tmp = _CacheList[0]; // Get the first EntryAudit
string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<EntryAudit>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first EntryAudit
}
}
protected static EntryAudit GetCachedByPrimaryKey(long auditID)
{
ConvertListToDictionary();
string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private static int _nextAuditID = -1;
public static int NextAuditID
{
get { return _nextAuditID--; }
}
private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)]
public long AuditID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AuditID", true);
return _AuditID;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
return _ContentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ContentID", true);
if (_ContentID != value)
{
_ContentID = value;
PropertyHasChanged();
}
}
}
private int _DocID;
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DocID", true);
return _DocID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DocID", true);
if (_DocID != value)
{
_DocID = 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 int _DeleteStatus;
public int DeleteStatus
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DeleteStatus", true);
return _DeleteStatus;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DeleteStatus", true);
if (_DeleteStatus != value)
{
_DeleteStatus = value;
PropertyHasChanged();
}
}
}
public override bool IsDirty
{
get { return base.IsDirty; }
}
public bool IsDirtyList(List<object> list)
{
return base.IsDirty;
}
public override bool IsValid
{
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
}
public bool IsValidList(List<object> list)
{
return (IsNew && !IsDirty) ? true : base.IsValid;
}
// CSLATODO: Replace base EntryAudit.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current EntryAudit</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check EntryAudit.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 EntryAudit</returns>
protected override object GetIdValue()
{
return MyEntryAuditUnique; // Absolutely Unique ID
}
#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;
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", 200));
//ValidationRules.AddDependantProperty("x", "y");
_EntryAuditExtension.AddValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_EntryAuditExtension.AddInstanceValidationRules(ValidationRules);
// CSLATODO: 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()
{
//CSLATODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AuditID, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(DocID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(DeleteStatus, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DocID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DeleteStatus, "<Role(s)>");
_EntryAuditExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
_EntryAuditExtension.AddInstanceAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// CSLATODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// CSLATODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// CSLATODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// CSLATODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _EntryAuditUnique = 0;
protected static int EntryAuditUnique
{ get { return ++_EntryAuditUnique; } }
private int _MyEntryAuditUnique = EntryAuditUnique;
public int MyEntryAuditUnique // Absolutely Unique ID - Editable
{ get { return _MyEntryAuditUnique; } }
protected EntryAudit()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(AuditID.ToString()))
{
List<EntryAudit> listEntryAudit = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
while (listEntryAudit.Contains(this)) listEntryAudit.Remove(this); // Remove the item from the list
if (listEntryAudit.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
}
}
public static EntryAudit New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a EntryAudit");
try
{
return DataPortal.Create<EntryAudit>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryAudit.New", ex);
}
}
public static EntryAudit New(int contentID, int docID, DateTime dts, string userID, int deleteStatus)
{
EntryAudit tmp = EntryAudit.New();
tmp.ContentID = contentID;
tmp.DocID = docID;
tmp.DTS = dts;
tmp.UserID = userID;
tmp.DeleteStatus = deleteStatus;
return tmp;
}
public static EntryAudit MakeEntryAudit(int contentID, int docID, DateTime dts, string userID, int deleteStatus)
{
EntryAudit tmp = EntryAudit.New(contentID, docID, dts, userID, deleteStatus);
if (tmp.IsSavable)
{
EntryAudit tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
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 EntryAudit Get(long auditID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a EntryAudit");
try
{
EntryAudit tmp = GetCachedByPrimaryKey(auditID);
if (tmp == null)
{
tmp = DataPortal.Fetch<EntryAudit>(new PKCriteria(auditID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up EntryAudit
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryAudit.Get", ex);
}
}
public static EntryAudit Get(SafeDataReader dr)
{
if (dr.Read()) return new EntryAudit(dr);
return null;
}
internal EntryAudit(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(long auditID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a EntryAudit");
try
{
DataPortal.Delete(new PKCriteria(auditID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on EntryAudit.Delete", ex);
}
}
public override EntryAudit Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a EntryAudit");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a EntryAudit");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a EntryAudit");
try
{
BuildRefreshList();
EntryAudit entryAudit = base.Save();
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(entryAudit);//Refresh the item in AllList
ProcessRefreshList();
return entryAudit;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[Serializable()]
protected class PKCriteria
{
private long _AuditID;
public long AuditID
{ get { return _AuditID; } }
public PKCriteria(long auditID)
{
_AuditID = auditID;
}
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
_AuditID = NextAuditID;
// Database Defaults
// CSLATODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.ReadData", GetHashCode());
try
{
_AuditID = dr.GetInt64("AuditID");
_ContentID = dr.GetInt32("ContentID");
_DocID = dr.GetInt32("DocID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_DeleteStatus = dr.GetInt32("DeleteStatus");
MarkOld();
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.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 = "getEntryAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
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("EntryAudit.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.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("EntryAudit.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.DataPortal_Insert", ex);
}
finally
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addEntryAudit";
// 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);
cm.Parameters.AddWithValue("@DeleteStatus", _DeleteStatus);
// Output Calculated Columns
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
param_AuditID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AuditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_AuditID = (long)cm.Parameters["@newAuditID"].Value;
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Add(SqlConnection cn, ref long auditID, int contentID, int docID, DateTime dts, string userID, int deleteStatus)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addEntryAudit";
// 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);
cm.Parameters.AddWithValue("@DeleteStatus", deleteStatus);
// Output Calculated Columns
SqlParameter param_AuditID = new SqlParameter("@newAuditID", SqlDbType.BigInt);
param_AuditID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AuditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
auditID = (long)cm.Parameters["@newAuditID"].Value;
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.Add", ex);
throw new DbCslaException("EntryAudit.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}] EntryAudit.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("EntryAudit.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}] EntryAudit.SQLUpdate", GetHashCode());
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateEntryAudit";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@AuditID", _AuditID);
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("@DeleteStatus", _DeleteStatus);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
}
}
MarkOld();
// use the open connection to update child objects
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.SQLUpdate", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
internal void Update()
{
if (!this.IsDirty) return;
if (base.IsDirty)
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (IsNew)
EntryAudit.Add(cn, ref _AuditID, _ContentID, _DocID, _DTS, _UserID, _DeleteStatus);
else
EntryAudit.Update(cn, ref _AuditID, _ContentID, _DocID, _DTS, _UserID, _DeleteStatus);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Update(SqlConnection cn, ref long auditID, int contentID, int docID, DateTime dts, string userID, int deleteStatus)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateEntryAudit";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@AuditID", auditID);
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("@DeleteStatus", deleteStatus);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.Update", ex);
throw new DbCslaException("EntryAudit.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_AuditID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteEntryAudit";
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("EntryAudit.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, long auditID)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAudit.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteEntryAudit";
// Input PK Fields
cm.Parameters.AddWithValue("@AuditID", auditID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAudit.Remove", ex);
throw new DbCslaException("EntryAudit.Remove", ex);
}
}
#endregion
// Standard Default Code
#region extension
EntryAuditExtension _EntryAuditExtension = new EntryAuditExtension();
[Serializable()]
partial class EntryAuditExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class EntryAuditConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is EntryAudit)
{
// Return the ToString value
return ((EntryAudit)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create EntryAuditExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class EntryAudit
// {
// partial class EntryAuditExtension : extensionBase
// {
// // CSLATODO: Override automatic defaults
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}
@@ -0,0 +1,210 @@
// ========================================================================
// 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));
}
private static string _ConnectionName = "VEPROMS";
public static string ConnectionName
{
get { return Database._ConnectionName; }
set { Database._ConnectionName = value; _VEPROMS_Connection = null; /* Reset Connection */ }
}
private static string _VEPROMS_Connection;
public static string VEPROMS_Connection
{
get
{
if (_VEPROMS_Connection != null) // Use Lazy Load
return _VEPROMS_Connection;
DateTime.Today.ToLongDateString();
// If DBConnection.XML exists, use the connection string from DBConnection.XML
string cnOverride = System.Windows.Forms.Application.StartupPath + @"\DBConnection.XML";
if (System.IO.File.Exists(cnOverride))
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load(cnOverride);
System.Xml.XmlNode xn = xd.SelectSingleNode("DBConnection/@string");
if (xn != null)
{
return _VEPROMS_Connection = xn.InnerText;
}
}
// Otherwise get the value from the ConfigurationManager
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings[ConnectionName];
if (cs == null)
{
throw new ApplicationException("Database.cs Could not find connection " + ConnectionName);
}
string constr = cs.ConnectionString;
if (constr.Contains("{MENU}"))
{
constr = ChooseDatabase(constr);
}
return _VEPROMS_Connection = constr;
}
}
private static string _SelectedDatabase;
public static string SelectedDatabase
{
get { return Database._SelectedDatabase; }
set { Database._SelectedDatabase = value; }
}
private static string ChooseDatabase(string constr)
{
string tmp = constr.Replace("{MENU}", "master");
SqlConnection cn = new SqlConnection(tmp);
cn.Open();
// SqlDataAdapter da = new SqlDataAdapter("select name from sysdatabases where name like 'VEP%' order by name", cn);
SqlDataAdapter da = new SqlDataAdapter("select name,case when object_id(name + '..Revisions') is not null then 'Approval' when object_id(name + '..ContentAudits') is not null then 'Change Manager' else 'Original' end functionality from sysdatabases where name like 'VEP%' order by name", cn);
DataSet ds = new DataSet();
da.Fill(ds);
cn.Close();
System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip();
cms.Items.Add("Choose Database");
System.Windows.Forms.ToolStripMenuItem tsmi = cms.Items[0] as System.Windows.Forms.ToolStripMenuItem;
tsmi.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaption);// System.Drawing.Color.Pink;
tsmi.ForeColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaptionText);
tsmi.Font = new System.Drawing.Font(tsmi.Font, System.Drawing.FontStyle.Bold);
foreach (DataRow dr in ds.Tables[0].Rows)
{
if(dr["functionality"].ToString() == "Approval")
cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
}
while (_SelectedDatabase == null)
{
cms.Show(new System.Drawing.Point((System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - cms.Width) / 2, (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - cms.Height) / 2));
System.Windows.Forms.Application.DoEvents();
}
return constr.Replace("{MENU}", _SelectedDatabase);
}
static void Database_Click(object sender, EventArgs e)
{
System.Windows.Forms.ToolStripMenuItem tsmi = sender as System.Windows.Forms.ToolStripMenuItem;
if (tsmi != null)
{
_SelectedDatabase = tsmi.Text;
}
}
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
@@ -0,0 +1,575 @@
// ========================================================================
// 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;
using System.Collections.Generic;
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
private static int _DefaultTimeout = 600; // 600 seconds, i.e. 10 minutes
public static int DefaultTimeout
{
get { return _DefaultTimeout; }
set { _DefaultTimeout = value; }
}
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));
}
private static string _ConnectionName = "VEPROMS";
public static string ConnectionName
{
get { return Database._ConnectionName; }
set { Database._ConnectionName = value; _VEPROMS_Connection = null; /* Reset Connection */ }
}
private static string _VEPROMS_Connection;
public static string VEPROMS_Connection
{
get
{
if (_VEPROMS_Connection != null) // Use Lazy Load
return _VEPROMS_Connection;
DateTime.Today.ToLongDateString();
// If DBConnection.XML exists, use the connection string from DBConnection.XML
string cnOverride = System.Windows.Forms.Application.StartupPath + @"\DBConnection.XML";
if (System.IO.File.Exists(cnOverride))
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load(cnOverride);
System.Xml.XmlNode xn = xd.SelectSingleNode("DBConnection/@string");
// bug fix: B2013-079
// If we are using the DBConnection.xml file,
// Check to see if "{MENU}" is being used and if a database was specified (ex."VEPROMS.EXE \DB=VEPROMS_xxx")
// If both conditions are true, then call the ChooseDatabases() funtion which will return a valid connection string (we hope)
// otherwise use the connection string as it is in the DBConnection.xml
if (xn != null)
{
if (xn.InnerText.Contains("{MENU}") && SelectedDatabase != null && SelectedDatabase.Length > 0)
_VEPROMS_Connection = ChooseDatabase(xn.InnerText);
else
_VEPROMS_Connection = xn.InnerText;
return _VEPROMS_Connection;
}
}
// Otherwise get the value from the ConfigurationManager
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings[ConnectionName];
if (cs == null)
{
throw new ApplicationException("Database.cs Could not find connection " + ConnectionName);
}
string constr = cs.ConnectionString;
if (constr.Contains("{MENU}"))
{
constr = ChooseDatabase(constr);
}
return _VEPROMS_Connection = constr;
}
set { _VEPROMS_Connection = value; }
}
private static string _SelectedDatabase;
public static string SelectedDatabase
{
get { return Database._SelectedDatabase; }
set { Database._SelectedDatabase = value; }
}
private static string _LastDatabase="NoDefault";
public static string LastDatabase
{
get { return Database._LastDatabase; }
set { Database._LastDatabase = value; }
}
private static string ChooseDatabase(string constr)
{
if (_SelectedDatabase == null)
{
if (LastDatabase != "NoDefault" && LastDatabase != "")
{
if (System.Windows.Forms.MessageBox.Show("Open " + LastDatabase, "Reopen Last Database", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
SelectedDatabase = LastDatabase;
return constr.Replace("{MENU}", _SelectedDatabase);
}
}
System.Windows.Forms.ContextMenuStrip cms = BuildDatabaseMenu(constr);
while (_SelectedDatabase == null)
{
cms.Show(new System.Drawing.Point((System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - cms.Width) / 2, (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - cms.Height) / 2));
System.Windows.Forms.Application.DoEvents();
}
}
return constr.Replace("{MENU}", _SelectedDatabase);
}
private static System.Windows.Forms.ContextMenuStrip BuildDatabaseMenu(string constr)
{
string tmp = constr.Replace("{MENU}", "master");
SqlConnection cn = new SqlConnection(tmp);
cn.Open();
// SqlDataAdapter da = new SqlDataAdapter("select name from sysdatabases where name like 'VEP%' order by name", cn);
//SqlDataAdapter da = new SqlDataAdapter("select name, case when object_id('[' + name + ']..Items') is null then 'Not PROMS' when object_id('[' + name + ']..Revisions') is not null then 'Approval' when object_id('[' + name + ']..ContentAudits') is not null then 'Change Manager' else 'Original' end functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
SqlDataAdapter da = new SqlDataAdapter("select name, 'Approval' functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
da.SelectCommand.CommandTimeout = 300; // 300 sec timeout
DataSet ds = new DataSet();
try
{
da.Fill(ds);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.GetType().Name, ex.Message);
throw(new Exception("Cannot Load Data List",ex));
}
cn.Close();
System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip();
cms.Items.Add("Choose Database");
System.Windows.Forms.ToolStripMenuItem tsmi = cms.Items[0] as System.Windows.Forms.ToolStripMenuItem;
tsmi.BackColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaption);// System.Drawing.Color.Pink;
tsmi.ForeColor = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.ActiveCaptionText);
tsmi.Font = new System.Drawing.Font(tsmi.Font, System.Drawing.FontStyle.Bold);
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["functionality"].ToString() == "Approval")
cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
}
return cms;
}
static void Database_Click(object sender, EventArgs e)
{
System.Windows.Forms.ToolStripMenuItem tsmi = sender as System.Windows.Forms.ToolStripMenuItem;
if (tsmi != null)
{
_SelectedDatabase = tsmi.Text;
}
}
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);
using (SqlConnection cn = VEPROMS_SqlConnection)
{
using (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
#region commandbase object jcb
[Serializable()]
public class PurgeDataCommand : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _RowsAffected;
public int RowsAffected
{
get { return _RowsAffected; }
set { _RowsAffected = value; }
}
#region Factory Methods
public static int Execute()
{
PurgeDataCommand cmd = new PurgeDataCommand();
cmd = DataPortal.Execute<PurgeDataCommand>(cmd);
return cmd.RowsAffected;
}
private PurgeDataCommand()
{ /* require use of factory methods */ }
#endregion
#region Server-Side code
protected override void DataPortal_Execute()
{
try
{
//SqlConnection cn = VEPROMS_SqlConnection;
//SqlCommand cmd = new SqlCommand("purgedata", cn);
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("purgedata", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
RowsAffected = cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Purge Error", ex);
throw new ApplicationException("Failure on Purge", ex);
}
}
#endregion
}
[Serializable()]
public class CanTransitionBeCreatedCommand : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private ProposedTransition _ProposedTransition;
public ProposedTransition ProposedTransition
{
get { return _ProposedTransition; }
set { _ProposedTransition = value; }
}
private int _FromID;
public int FromID
{
get { return _FromID; }
set { _FromID = value; }
}
private int _ToID;
public int ToID
{
get { return _ToID; }
set { _ToID = value; }
}
#region Factory Methods
public static ProposedTransition Execute(int fromID, int toID)
{
CanTransitionBeCreatedCommand cmd = new CanTransitionBeCreatedCommand();
cmd.FromID = fromID;
cmd.ToID = toID;
cmd = DataPortal.Execute<CanTransitionBeCreatedCommand>(cmd);
return cmd.ProposedTransition;
}
private CanTransitionBeCreatedCommand()
{ /* require use of factory methods */ }
#endregion
#region Server-Side code
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CanTransitionBeCreatedCommand.ReadData", GetHashCode());
try
{
_ProposedTransition = new ProposedTransition(dr.GetInt32("status"), dr.GetString("fromappl"), dr.GetString("toappl"), dr.GetString("fromstep"), dr.GetString("tostep"));
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("CanTransitionBeCreatedCommand.ReadData", ex);
}
}
protected override void DataPortal_Execute()
{
try
{
//SqlConnection cn = VEPROMS_SqlConnection;
//SqlCommand cmd = new SqlCommand("purgedata", cn);
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_CanTransitionBeCreated", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("fromItemID", _FromID);
cmd.Parameters.AddWithValue("toItemID", _ToID);
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("CanTransitionBeCreatedCommand Error", ex);
throw new ApplicationException("Failure on CanTransitionBeCreatedCommand", ex);
}
}
#endregion
}
[Serializable()]
public class WillTransitionsBeValidCommand : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private List<InvalidTransition> _InvalidTransitions;
public List<InvalidTransition> InvalidTransitions
{
get { return _InvalidTransitions; }
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private string _NewAppl;
public string NewAppl
{
get { return _NewAppl; }
set { _NewAppl = value; }
}
#region Factory Methods
public static List<InvalidTransition> Execute(int itemID, string newAppl)
{
WillTransitionsBeValidCommand cmd = new WillTransitionsBeValidCommand();
cmd.ItemID = itemID;
cmd.NewAppl = newAppl;
cmd = DataPortal.Execute<WillTransitionsBeValidCommand>(cmd);
return cmd.InvalidTransitions;
}
private WillTransitionsBeValidCommand()
{ /* require use of factory methods */ }
#endregion
#region Server-Side code
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.ReadData", GetHashCode());
try
{
do
{
_InvalidTransitions.Add(new InvalidTransition(dr.GetInt32("myitemid"), dr.GetString("srcappl"), dr.GetString("tgtappl"), dr.GetString("srcstep"), dr.GetString("tgtstep")));
} while (dr.Read());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("WillTransitionsBeValidCommand.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("WillTransitionsBeValidCommand.ReadData", ex);
}
}
protected override void DataPortal_Execute()
{
try
{
//SqlConnection cn = VEPROMS_SqlConnection;
//SqlCommand cmd = new SqlCommand("purgedata", cn);
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand("vesp_WillTransitionsBeValid", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("ItemID", _ItemID);
cmd.Parameters.AddWithValue("NewAppl", _NewAppl);
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
{
_InvalidTransitions = new List<InvalidTransition>();
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("WillTransitionsBeValidCommand Error", ex);
throw new ApplicationException("Failure on WillTransitionsBeValidCommand", ex);
}
}
#endregion
}
[Serializable()]
public class InvalidTransition
{
private int _MyItemID;
public int MyItemID
{
get { return _MyItemID; }
set { _MyItemID = value; }
}
private string _SrcAppl;
public string SrcAppl
{
get { return _SrcAppl; }
set { _SrcAppl = value; }
}
private string _TgtAppl;
public string TgtAppl
{
get { return _TgtAppl; }
set { _TgtAppl = value; }
}
private string _SrcStep;
public string SrcStep
{
get { return _SrcStep; }
set { _SrcStep = value; }
}
private string _TgtStep;
public string TgtStep
{
get { return _TgtStep; }
set { _TgtStep = value; }
}
public InvalidTransition(int myItemID, string srcAppl, string tgtAppl, string srcStep, string tgtStep)
{
_MyItemID = myItemID;
_SrcAppl = srcAppl;
_TgtAppl = tgtAppl;
_SrcStep = srcStep;
_TgtStep = tgtStep;
}
}
[Serializable()]
public class ProposedTransition
{
private int _Status;
public int Status
{
get { return _Status; }
set { _Status = value; }
}
private string _FromAppl;
public string FromAppl
{
get { return _FromAppl; }
set { _FromAppl = value; }
}
private string _ToAppl;
public string ToAppl
{
get { return _ToAppl; }
set { _ToAppl = value; }
}
private string _FromStep;
public string FromStep
{
get { return _FromStep; }
set { _FromStep = value; }
}
private string _ToStep;
public string ToStep
{
get { return _ToStep; }
set { _ToStep = value; }
}
public ProposedTransition(int status, string fromAppl, string toAppl, string fromStep, string toStep)
{
_Status = status;
_FromAppl = fromAppl;
_ToAppl = toAppl;
_FromStep = fromStep;
_ToStep = toStep;
}
}
#endregion
} // Namespace
@@ -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>
/// FigureInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(FigureInfoListConverter))]
public partial class FigureInfoList : ReadOnlyListBase<FigureInfoList, FigureInfo>, 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<FigureInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (FigureInfo tmp in this)
{
tmp.Changed += new FigureInfoEvent(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 (FigureInfo tmp in this)
{
tmp.Changed -= new FigureInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static FigureInfoList _FigureInfoList = null;
/// <summary>
/// Return a list of all projects.
/// </summary>
public static FigureInfoList Get()
{
try
{
if (_FigureInfoList != null)
return _FigureInfoList;
FigureInfoList tmp = DataPortal.Fetch<FigureInfoList>();
FigureInfo.AddList(tmp);
tmp.AddEvents();
_FigureInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FigureInfoList.Get", ex);
}
}
// TODO: Add alternative gets -
//public static FigureInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<FigureInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on FigureInfoList.Get", ex);
// }
//}
public static FigureInfoList GetByROFstID(int rOFstID)
{
try
{
FigureInfoList tmp = DataPortal.Fetch<FigureInfoList>(new ROFstIDCriteria(rOFstID));
FigureInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FigureInfoList.GetByROFstID", ex);
}
}
public static FigureInfoList GetByImageID(int imageID)
{
try
{
FigureInfoList tmp = DataPortal.Fetch<FigureInfoList>(new ImageIDCriteria(imageID));
FigureInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FigureInfoList.GetByImageID", ex);
}
}
private FigureInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFigures";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FigureInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("FigureInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ROFstIDCriteria
{
public ROFstIDCriteria(int rOFstID)
{
_ROFstID = rOFstID;
}
private int _ROFstID;
public int ROFstID
{
get { return _ROFstID; }
set { _ROFstID = value; }
}
}
private void DataPortal_Fetch(ROFstIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfoList.DataPortal_FetchROFstID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFiguresByROFstID";
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FigureInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfoList.DataPortal_FetchROFstID", ex);
throw new DbCslaException("FigureInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ImageIDCriteria
{
public ImageIDCriteria(int imageID)
{
_ImageID = imageID;
}
private int _ImageID;
public int ImageID
{
get { return _ImageID; }
set { _ImageID = value; }
}
}
private void DataPortal_Fetch(ImageIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfoList.DataPortal_FetchImageID", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFiguresByImageID";
cm.Parameters.AddWithValue("@ImageID", criteria.ImageID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FigureInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfoList.DataPortal_FetchImageID", ex);
throw new DbCslaException("FigureInfoList.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
FigureInfoListPropertyDescriptor pd = new FigureInfoListPropertyDescriptor(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 FigureInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private FigureInfo Item { get { return (FigureInfo)_Item; } }
public FigureInfoListPropertyDescriptor(FigureInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class FigureInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FigureInfoList)
{
// Return department and department role separated by comma.
return ((FigureInfoList)value).Items.Count.ToString() + " Figures";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,692 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
public delegate void ItemInfoEvent(object sender);
/// <summary>
/// ItemInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ItemInfoConverter))]
public partial class ItemInfo : ReadOnlyBase<ItemInfo>, IDisposable
{
public event ItemInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<ItemInfo> _CacheList = new List<ItemInfo>();
protected static void AddToCache(ItemInfo itemInfo)
{
if (!_CacheList.Contains(itemInfo)) _CacheList.Add(itemInfo); // In AddToCache
}
protected static void RemoveFromCache(ItemInfo itemInfo)
{
while (_CacheList.Contains(itemInfo)) _CacheList.Remove(itemInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ItemInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ItemInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move ItemInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
ItemInfo tmp = _CacheList[0]; // Get the first ItemInfo
string pKey = tmp.ItemID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<ItemInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ItemInfo
}
}
internal static void AddList(ItemInfoList lst)
{
foreach (ItemInfo item in lst) AddToCache(item);
}
protected static ItemInfo GetCachedByPrimaryKey(int itemID)
{
ConvertListToDictionary();
string key = itemID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Item _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _ItemID;
[System.ComponentModel.DataObjectField(true, true)]
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
}
private int? _PreviousID;
public int? PreviousID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("PreviousID", true);
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
return _PreviousID;
}
}
private ItemInfo _MyPrevious;
public ItemInfo MyPrevious
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyPrevious", true);
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = ItemInfo.Get((int)_PreviousID);
return _MyPrevious;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ContentID", true);
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private ContentInfo _MyContent;
public ContentInfo MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyContent", true);
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
return _MyContent;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _ItemAnnotationCount = 0;
/// <summary>
/// Count of ItemAnnotations for this Item
/// </summary>
public int ItemAnnotationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemAnnotationCount", true);
if (_ItemAnnotationCount < 0)
_ItemAnnotationCount = ItemAnnotations.Count;
return _ItemAnnotationCount;
}
}
private AnnotationInfoList _ItemAnnotations = null;
[TypeConverter(typeof(AnnotationInfoListConverter))]
public AnnotationInfoList ItemAnnotations
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemAnnotations", true);
if (_ItemAnnotationCount < 0 || (_ItemAnnotationCount > 0 && _ItemAnnotations == null))
_ItemAnnotations = AnnotationInfoList.GetByItemID(_ItemID);
if (_ItemAnnotationCount < 0)
_ItemAnnotationCount = _ItemAnnotations.Count;
return _ItemAnnotations;
}
}
public void RefreshItemAnnotations()
{
_ItemAnnotationCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemAnnotationCount = -1; // This will cause the data to be requeried
}
private int _ItemDocVersionCount = 0;
/// <summary>
/// Count of ItemDocVersions for this Item
/// </summary>
public int ItemDocVersionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemDocVersionCount", true);
if (_ItemDocVersionCount < 0)
_ItemDocVersionCount = ItemDocVersions.Count;
return _ItemDocVersionCount;
}
}
private DocVersionInfoList _ItemDocVersions = null;
[TypeConverter(typeof(DocVersionInfoListConverter))]
public DocVersionInfoList ItemDocVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemDocVersions", true);
if (_ItemDocVersionCount < 0 || (_ItemDocVersionCount > 0 && _ItemDocVersions == null))
_ItemDocVersions = DocVersionInfoList.GetByItemID(_ItemID);
if (_ItemDocVersionCount < 0)
_ItemDocVersionCount = _ItemDocVersions.Count;
return _ItemDocVersions;
}
}
public void RefreshItemDocVersions()
{
_ItemDocVersionCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemDocVersionCount = -1; // This will cause the data to be requeried
}
private int _NextItemCount = 0;
/// <summary>
/// Count of NextItems for this Item
/// </summary>
public int NextItemCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("NextItemCount", true);
if (_NextItemCount < 0)
_NextItemCount = NextItems.Count;
return _NextItemCount;
}
}
private ItemInfoList _NextItems = null;
[TypeConverter(typeof(ItemInfoListConverter))]
public ItemInfoList NextItems
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("NextItems", true);
if (_NextItemCount < 0 || (_NextItemCount > 0 && _NextItems == null))
_NextItems = ItemInfoList.GetNext(_ItemID);
if (_NextItemCount < 0)
_NextItemCount = _NextItems.Count;
return _NextItems;
}
}
public void RefreshNextItems()
{
_NextItemCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._NextItemCount = -1; // This will cause the data to be requeried
}
private int _ItemPartCount = 0;
/// <summary>
/// Count of ItemParts for this Item
/// </summary>
public int ItemPartCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemPartCount", true);
if (_ItemPartCount < 0)
_ItemPartCount = ItemParts.Count;
return _ItemPartCount;
}
}
private PartInfoList _ItemParts = null;
[TypeConverter(typeof(PartInfoListConverter))]
public PartInfoList ItemParts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemParts", true);
if (_ItemPartCount < 0 || (_ItemPartCount > 0 && _ItemParts == null))
_ItemParts = PartInfoList.GetByItemID(_ItemID);
if (_ItemPartCount < 0)
_ItemPartCount = _ItemParts.Count;
return _ItemParts;
}
}
public void RefreshItemParts()
{
_ItemPartCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemPartCount = -1; // This will cause the data to be requeried
}
private int _ItemTransition_RangeIDCount = 0;
/// <summary>
/// Count of ItemTransitions_RangeID for this Item
/// </summary>
public int ItemTransition_RangeIDCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransition_RangeIDCount", true);
if (_ItemTransition_RangeIDCount < 0)
_ItemTransition_RangeIDCount = ItemTransitions_RangeID.Count;
return _ItemTransition_RangeIDCount;
}
}
private TransitionInfoList _ItemTransitions_RangeID = null;
[TypeConverter(typeof(TransitionInfoListConverter))]
public TransitionInfoList ItemTransitions_RangeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransitions_RangeID", true);
if (_ItemTransition_RangeIDCount < 0 || (_ItemTransition_RangeIDCount > 0 && _ItemTransitions_RangeID == null))
_ItemTransitions_RangeID = TransitionInfoList.GetByRangeID(_ItemID);
if (_ItemTransition_RangeIDCount < 0)
_ItemTransition_RangeIDCount = _ItemTransitions_RangeID.Count;
return _ItemTransitions_RangeID;
}
}
public void RefreshItemTransitions_RangeID()
{
_ItemTransition_RangeIDCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemTransition_RangeIDCount = -1; // This will cause the data to be requeried
}
private int _ItemTransition_ToIDCount = 0;
/// <summary>
/// Count of ItemTransitions_ToID for this Item
/// </summary>
public int ItemTransition_ToIDCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransition_ToIDCount", true);
if (_ItemTransition_ToIDCount < 0)
_ItemTransition_ToIDCount = ItemTransitions_ToID.Count;
return _ItemTransition_ToIDCount;
}
}
private TransitionInfoList _ItemTransitions_ToID = null;
[TypeConverter(typeof(TransitionInfoListConverter))]
public TransitionInfoList ItemTransitions_ToID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemTransitions_ToID", true);
if (_ItemTransition_ToIDCount < 0 || (_ItemTransition_ToIDCount > 0 && _ItemTransitions_ToID == null))
_ItemTransitions_ToID = TransitionInfoList.GetByToID(_ItemID);
if (_ItemTransition_ToIDCount < 0)
_ItemTransition_ToIDCount = _ItemTransitions_ToID.Count;
return _ItemTransitions_ToID;
}
}
public void RefreshItemTransitions_ToID()
{
_ItemTransition_ToIDCount = -1;
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ItemID.ToString()))
foreach (ItemInfo tmp in _CacheByPrimaryKey[_ItemID.ToString()])
tmp._ItemTransition_ToIDCount = -1; // This will cause the data to be requeried
}
// CSLATODO: Replace base ItemInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ItemInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check ItemInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ItemInfo</returns>
protected override object GetIdValue()
{
return MyItemInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _ItemInfoUnique = 0;
private static int ItemInfoUnique
{ get { return ++_ItemInfoUnique; } }
private int _MyItemInfoUnique = ItemInfoUnique;
public int MyItemInfoUnique // Absolutely Unique ID - Info
{ get { return _MyItemInfoUnique; } }
protected ItemInfo()
{/* require use of factory methods */
AddToCache(this);
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~ItemInfo()
{
_CountFinalized++;
}
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ItemID.ToString())) return;
List<ItemInfo> listItemInfo = _CacheByPrimaryKey[ItemID.ToString()]; // Get the list of items
while (listItemInfo.Contains(this)) listItemInfo.Remove(this); // Remove the item from the list
if (listItemInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ItemID.ToString()); // remove the list
if (_MyContent != null)
_MyContent = null;
if (_MyPrevious != null)
_MyPrevious = null;
//if (_ActiveFormat != null)
// _ActiveFormat = null;
//if (_ActiveParent != null)
// _ActiveParent = null;
//if (_ActiveSection != null)
// _ActiveSection = null;
//if (_MyDocVersion != null)
// _MyDocVersion = null;
//if (_ParentNoteOrCaution != null)
// _ParentNoteOrCaution = null;
}
public virtual Item Get()
{
return _Editable = Item.Get(_ItemID);
}
public static void Refresh(Item tmp)
{
string key = tmp.ItemID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ItemInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Item tmp)
{
if (_PreviousID != tmp.PreviousID)
{
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value
_PreviousID = tmp.PreviousID; // Update the value
}
_MyPrevious = null; // Reset list so that the next line gets a new list
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
//if (_ContentID != tmp.ContentID)
//{
if (MyContent != null) MyContent.RefreshContentItems(); // Update List for old value
_ContentID = tmp.ContentID; // Update the value
//}
_MyContent = null; // Reset list so that the next line gets a new list
if (MyContent != null) MyContent.RefreshContentItems(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ItemInfoExtension.Refresh(this);
//RHM Removed 20090724 - Duplicates function of code above.
// - Dispose caused error when a new step was added.
// - Resequence of transitions did not work properly.
// if(_MyPrevious != null)
// {
// _MyPrevious.Dispose();// Dispose related value
// _MyPrevious = null;// Reset related value
// }
//RHM Removed 20090724 - Duplicates function of code above.
// - Dispose caused error when a new step was added.
// - Resequence of transitions did not work properly.
// if(_MyContent != null)
// {
// _MyContent.Dispose();// Dispose related value
// _MyContent = null;// Reset related value
// }
OnChange();// raise an event
}
public static void Refresh(ContentItem tmp)
{
string key = tmp.ItemID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ItemInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ContentItem tmp)
{
if (_PreviousID != tmp.PreviousID)
{
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for old value
_PreviousID = tmp.PreviousID; // Update the value
}
_MyPrevious = null; // Reset list so that the next line gets a new list
if (MyPrevious != null) MyPrevious.RefreshNextItems(); // Update List for new value
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ItemInfoExtension.Refresh(this);
//RHM Removed 20090724 - Duplicates function of code above.
// - Dispose caused error when a new step was added.
// - Resequence of transitions did not work properly.
// if(_MyPrevious != null)
// {
// _MyPrevious.Dispose();// Dispose related value
// _MyPrevious = null;// Reset related value
// }
//RHM Removed 20090724 - Duplicates function of code above.
// - Dispose caused error when a new step was added.
// - Resequence of transitions did not work properly.
// if(_MyContent != null)
// {
// _MyContent.Dispose();// Dispose related value
// _MyContent = null;// Reset related value
// }
OnChange();// raise an event
}
public static ItemInfo Get(int itemID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Item");
try
{
ItemInfo tmp = GetCachedByPrimaryKey(itemID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ItemInfo>(new PKCriteria(itemID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ItemInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ItemInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ItemInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.Constructor", ex);
throw new DbCslaException("ItemInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
public PKCriteria(int itemID)
{
_ItemID = itemID;
}
}
protected void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.ReadData", GetHashCode());
try
{
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ItemAnnotationCount = dr.GetInt32("AnnotationCount");
_ItemDocVersionCount = dr.GetInt32("DocVersionCount");
_NextItemCount = dr.GetInt32("NextCount");
_ItemPartCount = dr.GetInt32("PartCount");
_ItemTransition_RangeIDCount = dr.GetInt32("Transition_RangeIDCount");
_ItemTransition_ToIDCount = dr.GetInt32("Transition_ToIDCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getItem";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ItemInfoExtension _ItemInfoExtension = new ItemInfoExtension();
[Serializable()]
partial class ItemInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ItemInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ItemInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ItemInfo)
{
// Return the ToString value
return ((ItemInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,956 @@
// ========================================================================
// 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>
/// RevisionROCheck Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionROCheckConverter))]
public partial class RevisionROCheck : BusinessBase<RevisionROCheck>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<RevisionROCheck> _RefreshRevisionROChecks = new List<RevisionROCheck>();
private void AddToRefreshList(List<RevisionROCheck> refreshRevisionROChecks)
{
if (IsDirty)
refreshRevisionROChecks.Add(this);
}
private void BuildRefreshList()
{
_RefreshRevisionROChecks = new List<RevisionROCheck>();
AddToRefreshList(_RefreshRevisionROChecks);
}
private void ProcessRefreshList()
{
foreach (RevisionROCheck tmp in _RefreshRevisionROChecks)
{
RevisionROCheckInfo.Refresh(tmp);
}
}
#endregion
#region Collection
private static List<RevisionROCheck> _CacheList = new List<RevisionROCheck>();
protected static void AddToCache(RevisionROCheck revisionROCheck)
{
if (!_CacheList.Contains(revisionROCheck)) _CacheList.Add(revisionROCheck); // In AddToCache
}
protected static void RemoveFromCache(RevisionROCheck revisionROCheck)
{
while (_CacheList.Contains(revisionROCheck)) _CacheList.Remove(revisionROCheck); // In RemoveFromCache
}
private static Dictionary<string, List<RevisionROCheck>> _CacheByPrimaryKey = new Dictionary<string, List<RevisionROCheck>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move RevisionROCheck(s) from temporary _CacheList to _CacheByPrimaryKey
{
RevisionROCheck tmp = _CacheList[0]; // Get the first RevisionROCheck
string pKey = tmp.CheckID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<RevisionROCheck>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first RevisionROCheck
}
}
protected static RevisionROCheck GetCachedByPrimaryKey(int checkID)
{
ConvertListToDictionary();
string key = checkID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private static int _nextCheckID = -1;
public static int NextCheckID
{
get { return _nextCheckID--; }
}
private int _CheckID;
[System.ComponentModel.DataObjectField(true, true)]
public int CheckID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("CheckID", true);
return _CheckID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ItemID", true);
if (_ItemID != value)
{
_ItemID = value;
PropertyHasChanged();
}
}
}
private int _ROID;
public int 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 (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private string _RODate = string.Empty;
public string RODate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODate", true);
return _RODate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("RODate", true);
if (value == null) value = string.Empty;
_RODate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_RODate != tmp.ToString())
{
_RODate = tmp.ToString();
// CSLATODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _ROValue = string.Empty;
public string ROValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROValue", true);
return _ROValue;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROValue", true);
if (value == null) value = string.Empty;
if (_ROValue != value)
{
_ROValue = value;
PropertyHasChanged();
}
}
}
public override bool IsDirty
{
get { return base.IsDirty; }
}
public bool IsDirtyList(List<object> list)
{
return base.IsDirty;
}
public override bool IsValid
{
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
}
public bool IsValidList(List<object> list)
{
return (IsNew && !IsDirty) ? true : base.IsValid;
}
// CSLATODO: Replace base RevisionROCheck.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RevisionROCheck</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check RevisionROCheck.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 RevisionROCheck</returns>
protected override object GetIdValue()
{
return MyRevisionROCheckUnique; // Absolutely Unique ID
}
#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;
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<RevisionROCheck>(RODateValid, "RODate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ROValue", 1073741823));
//ValidationRules.AddDependantProperty("x", "y");
_RevisionROCheckExtension.AddValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_RevisionROCheckExtension.AddInstanceValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
private static bool RODateValid(RevisionROCheck target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(target._RODate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
//AuthorizationRules.AllowRead(CheckID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
//AuthorizationRules.AllowRead(RODate, "<Role(s)>");
//AuthorizationRules.AllowRead(ROValue, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RODate, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROValue, "<Role(s)>");
_RevisionROCheckExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
_RevisionROCheckExtension.AddInstanceAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// CSLATODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// CSLATODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// CSLATODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// CSLATODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _RevisionROCheckUnique = 0;
protected static int RevisionROCheckUnique
{ get { return ++_RevisionROCheckUnique; } }
private int _MyRevisionROCheckUnique = RevisionROCheckUnique;
public int MyRevisionROCheckUnique // Absolutely Unique ID - Editable
{ get { return _MyRevisionROCheckUnique; } }
protected RevisionROCheck()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(CheckID.ToString()))
{
List<RevisionROCheck> listRevisionROCheck = _CacheByPrimaryKey[CheckID.ToString()]; // Get the list of items
while (listRevisionROCheck.Contains(this)) listRevisionROCheck.Remove(this); // Remove the item from the list
if (listRevisionROCheck.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(CheckID.ToString()); // remove the list
}
}
public static RevisionROCheck New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a RevisionROCheck");
try
{
return DataPortal.Create<RevisionROCheck>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheck.New", ex);
}
}
public static RevisionROCheck New(int itemID, int roid)
{
RevisionROCheck tmp = RevisionROCheck.New();
tmp.ItemID = itemID;
tmp.ROID = roid;
return tmp;
}
public static RevisionROCheck New(int itemID, int roid, string rODate, string rOValue)
{
RevisionROCheck tmp = RevisionROCheck.New();
tmp.ItemID = itemID;
tmp.ROID = roid;
tmp.RODate = rODate;
tmp.ROValue = rOValue;
return tmp;
}
public static RevisionROCheck MakeRevisionROCheck(int itemID, int roid, string rODate, string rOValue)
{
RevisionROCheck tmp = RevisionROCheck.New(itemID, roid, rODate, rOValue);
if (tmp.IsSavable)
{
RevisionROCheck tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
}
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 RevisionROCheck Get(int checkID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a RevisionROCheck");
try
{
RevisionROCheck tmp = GetCachedByPrimaryKey(checkID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RevisionROCheck>(new PKCriteria(checkID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RevisionROCheck
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheck.Get", ex);
}
}
public static RevisionROCheck Get(SafeDataReader dr)
{
if (dr.Read()) return new RevisionROCheck(dr);
return null;
}
internal RevisionROCheck(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(int checkID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a RevisionROCheck");
try
{
DataPortal.Delete(new PKCriteria(checkID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheck.Delete", ex);
}
}
public override RevisionROCheck Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a RevisionROCheck");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a RevisionROCheck");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a RevisionROCheck");
try
{
BuildRefreshList();
RevisionROCheck revisionROCheck = base.Save();
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(revisionROCheck);//Refresh the item in AllList
ProcessRefreshList();
return revisionROCheck;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[Serializable()]
protected class PKCriteria
{
private int _CheckID;
public int CheckID
{ get { return _CheckID; } }
public PKCriteria(int checkID)
{
_CheckID = checkID;
}
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
_CheckID = NextCheckID;
// Database Defaults
// CSLATODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.ReadData", GetHashCode());
try
{
_CheckID = dr.GetInt32("CheckID");
_ItemID = dr.GetInt32("ItemID");
_ROID = dr.GetInt32("ROID");
_RODate = dr.GetSmartDate("RODate").Text;
_ROValue = dr.GetString("ROValue");
MarkOld();
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.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 = "getRevisionROCheck";
cm.Parameters.AddWithValue("@CheckID", criteria.CheckID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.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("RevisionROCheck.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.DataPortal_Insert", ex);
}
finally
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addRevisionROCheck";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", _ItemID);
cm.Parameters.AddWithValue("@ROID", _ROID);
cm.Parameters.AddWithValue("@RODate", new SmartDate(_RODate).DBValue);
cm.Parameters.AddWithValue("@ROValue", _ROValue);
// Output Calculated Columns
SqlParameter param_CheckID = new SqlParameter("@newCheckID", SqlDbType.Int);
param_CheckID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_CheckID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_CheckID = (int)cm.Parameters["@newCheckID"].Value;
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Add(SqlConnection cn, ref int checkID, int itemID, int roid, SmartDate rODate, string rOValue)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addRevisionROCheck";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ItemID", itemID);
cm.Parameters.AddWithValue("@ROID", roid);
cm.Parameters.AddWithValue("@RODate", rODate.DBValue);
cm.Parameters.AddWithValue("@ROValue", rOValue);
// Output Calculated Columns
SqlParameter param_CheckID = new SqlParameter("@newCheckID", SqlDbType.Int);
param_CheckID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_CheckID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
checkID = (int)cm.Parameters["@newCheckID"].Value;
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.Add", ex);
throw new DbCslaException("RevisionROCheck.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}] RevisionROCheck.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("RevisionROCheck.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}] RevisionROCheck.SQLUpdate", GetHashCode());
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateRevisionROCheck";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@CheckID", _CheckID);
cm.Parameters.AddWithValue("@ItemID", _ItemID);
cm.Parameters.AddWithValue("@ROID", _ROID);
cm.Parameters.AddWithValue("@RODate", new SmartDate(_RODate).DBValue);
cm.Parameters.AddWithValue("@ROValue", _ROValue);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
}
}
MarkOld();
// use the open connection to update child objects
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.SQLUpdate", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
internal void Update()
{
if (!this.IsDirty) return;
if (base.IsDirty)
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (IsNew)
RevisionROCheck.Add(cn, ref _CheckID, _ItemID, _ROID, new SmartDate(_RODate), _ROValue);
else
RevisionROCheck.Update(cn, ref _CheckID, _ItemID, _ROID, new SmartDate(_RODate), _ROValue);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Update(SqlConnection cn, ref int checkID, int itemID, int roid, SmartDate rODate, string rOValue)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateRevisionROCheck";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@CheckID", checkID);
cm.Parameters.AddWithValue("@ItemID", itemID);
cm.Parameters.AddWithValue("@ROID", roid);
cm.Parameters.AddWithValue("@RODate", rODate);
cm.Parameters.AddWithValue("@ROValue", rOValue);
// Output Calculated Columns
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
// No Timestamp value to return
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.Update", ex);
throw new DbCslaException("RevisionROCheck.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_CheckID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteRevisionROCheck";
cm.Parameters.AddWithValue("@CheckID", criteria.CheckID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheck.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int checkID)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteRevisionROCheck";
// Input PK Fields
cm.Parameters.AddWithValue("@CheckID", checkID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.Remove", ex);
throw new DbCslaException("RevisionROCheck.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int checkID)
{
ExistsCommand result;
try
{
result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(checkID));
return result.Exists;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheck.Exists", ex);
}
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _CheckID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int checkID)
{
_CheckID = checkID;
}
protected override void DataPortal_Execute()
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheck.DataPortal_Execute", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsRevisionROCheck";
cm.Parameters.AddWithValue("@CheckID", _CheckID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheck.DataPortal_Execute", ex);
throw new DbCslaException("RevisionROCheck.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
RevisionROCheckExtension _RevisionROCheckExtension = new RevisionROCheckExtension();
[Serializable()]
partial class RevisionROCheckExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class RevisionROCheckConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionROCheck)
{
// Return the ToString value
return ((RevisionROCheck)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create RevisionROCheckExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS_.CSLA.Library
//{
// public partial class RevisionROCheck
// {
// partial class RevisionROCheckExtension : extensionBase
// {
// // CSLATODO: Override automatic defaults
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowInstanceRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddInstanceRule(/* Instance Validation Rule */);
// }
// }
// }
//}
@@ -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 RevisionROCheckInfoEvent(object sender);
/// <summary>
/// RevisionROCheckInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(RevisionROCheckInfoConverter))]
public partial class RevisionROCheckInfo : ReadOnlyBase<RevisionROCheckInfo>, IDisposable
{
public event RevisionROCheckInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<RevisionROCheckInfo> _CacheList = new List<RevisionROCheckInfo>();
protected static void AddToCache(RevisionROCheckInfo revisionROCheckInfo)
{
if (!_CacheList.Contains(revisionROCheckInfo)) _CacheList.Add(revisionROCheckInfo); // In AddToCache
}
protected static void RemoveFromCache(RevisionROCheckInfo revisionROCheckInfo)
{
while (_CacheList.Contains(revisionROCheckInfo)) _CacheList.Remove(revisionROCheckInfo); // In RemoveFromCache
}
private static Dictionary<string, List<RevisionROCheckInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RevisionROCheckInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move RevisionROCheckInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
RevisionROCheckInfo tmp = _CacheList[0]; // Get the first RevisionROCheckInfo
string pKey = tmp.CheckID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<RevisionROCheckInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first RevisionROCheckInfo
}
}
internal static void AddList(RevisionROCheckInfoList lst)
{
foreach (RevisionROCheckInfo item in lst) AddToCache(item);
}
protected static RevisionROCheckInfo GetCachedByPrimaryKey(int checkID)
{
ConvertListToDictionary();
string key = checkID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected RevisionROCheck _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _CheckID;
[System.ComponentModel.DataObjectField(true, true)]
public int CheckID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("CheckID", true);
return _CheckID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
return _ItemID;
}
}
private int _ROID;
public int ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROID", true);
return _ROID;
}
}
private string _RODate = string.Empty;
public string RODate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODate", true);
return _RODate;
}
}
private string _ROValue = string.Empty;
public string ROValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROValue", true);
return _ROValue;
}
}
// CSLATODO: Replace base RevisionROCheckInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RevisionROCheckInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check RevisionROCheckInfo.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 RevisionROCheckInfo</returns>
protected override object GetIdValue()
{
return MyRevisionROCheckInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _RevisionROCheckInfoUnique = 0;
private static int RevisionROCheckInfoUnique
{ get { return ++_RevisionROCheckInfoUnique; } }
private int _MyRevisionROCheckInfoUnique = RevisionROCheckInfoUnique;
public int MyRevisionROCheckInfoUnique // Absolutely Unique ID - Info
{ get { return _MyRevisionROCheckInfoUnique; } }
protected RevisionROCheckInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(CheckID.ToString())) return;
List<RevisionROCheckInfo> listRevisionROCheckInfo = _CacheByPrimaryKey[CheckID.ToString()]; // Get the list of items
while (listRevisionROCheckInfo.Contains(this)) listRevisionROCheckInfo.Remove(this); // Remove the item from the list
if (listRevisionROCheckInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(CheckID.ToString()); // remove the list
}
public virtual RevisionROCheck Get()
{
return _Editable = RevisionROCheck.Get(_CheckID);
}
public static void Refresh(RevisionROCheck tmp)
{
string key = tmp.CheckID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (RevisionROCheckInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RevisionROCheck tmp)
{
_ItemID = tmp.ItemID;
_ROID = tmp.ROID;
_RODate = tmp.RODate;
_ROValue = tmp.ROValue;
_RevisionROCheckInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static RevisionROCheckInfo Get(int checkID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a RevisionROCheck");
try
{
RevisionROCheckInfo tmp = GetCachedByPrimaryKey(checkID);
if (tmp == null)
{
tmp = DataPortal.Fetch<RevisionROCheckInfo>(new PKCriteria(checkID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up RevisionROCheckInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on RevisionROCheckInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal RevisionROCheckInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheckInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheckInfo.Constructor", ex);
throw new DbCslaException("RevisionROCheckInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _CheckID;
public int CheckID
{ get { return _CheckID; } }
public PKCriteria(int checkID)
{
_CheckID = checkID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheckInfo.ReadData", GetHashCode());
try
{
_CheckID = dr.GetInt32("CheckID");
_ItemID = dr.GetInt32("ItemID");
_ROID = dr.GetInt32("ROID");
_RODate = dr.GetSmartDate("RODate").Text;
_ROValue = dr.GetString("ROValue");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheckInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheckInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RevisionROCheckInfo.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 = "getRevisionROCheck";
cm.Parameters.AddWithValue("@CheckID", criteria.CheckID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("RevisionROCheckInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("RevisionROCheckInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
RevisionROCheckInfoExtension _RevisionROCheckInfoExtension = new RevisionROCheckInfoExtension();
[Serializable()]
partial class RevisionROCheckInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(RevisionROCheckInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class RevisionROCheckInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is RevisionROCheckInfo)
{
// Return the ToString value
return ((RevisionROCheckInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -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;
}
}
}
@@ -0,0 +1,144 @@
// ========================================================================
// 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));
}
private static string _ConnectionName = "VEPROMS";
public static string ConnectionName
{
get { return Database._ConnectionName; }
set { Database._ConnectionName = value; }
}
public static string VEPROMS_Connection
{
get
{
DateTime.Today.ToLongDateString();
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings[ConnectionName];
if (cs == null)
{
throw new ApplicationException("Database.cs Could not find connection " + ConnectionName);
}
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
@@ -0,0 +1,995 @@
// ========================================================================
// 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>
/// Owner Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(OwnerConverter))]
public partial class Owner : BusinessBase<Owner>, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List<Owner> _RefreshOwners = new List<Owner>();
private void AddToRefreshList(List<Owner> refreshOwners)
{
if (IsDirty)
refreshOwners.Add(this);
}
private void ClearRefreshList()
{
_RefreshOwners = new List<Owner>();
}
private void BuildRefreshList()
{
ClearRefreshList();
AddToRefreshList(_RefreshOwners);
}
private void ProcessRefreshList()
{
foreach (Owner tmp in _RefreshOwners)
{
OwnerInfo.Refresh(tmp);
}
ClearRefreshList();
}
#endregion
#region Collection
private static List<Owner> _CacheList = new List<Owner>();
protected static void AddToCache(Owner owner)
{
if (!_CacheList.Contains(owner)) _CacheList.Add(owner); // In AddToCache
}
protected static void RemoveFromCache(Owner owner)
{
while (_CacheList.Contains(owner)) _CacheList.Remove(owner); // In RemoveFromCache
}
private static Dictionary<string, List<Owner>> _CacheByPrimaryKey = new Dictionary<string, List<Owner>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move Owner(s) from temporary _CacheList to _CacheByPrimaryKey
{
Owner tmp = _CacheList[0]; // Get the first Owner
string pKey = tmp.OwnerID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<Owner>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first Owner
}
}
protected static Owner GetCachedByPrimaryKey(int ownerID)
{
ConvertListToDictionary();
string key = ownerID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private static int _nextOwnerID = -1;
public static int NextOwnerID
{
get { return _nextOwnerID--; }
}
private int _OwnerID;
[System.ComponentModel.DataObjectField(true, true)]
public int OwnerID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("OwnerID", true);
return _OwnerID;
}
}
private int _SessionID;
public int SessionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SessionID", true);
return _SessionID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("SessionID", true);
if (_SessionID != value)
{
_SessionID = value;
PropertyHasChanged();
}
}
}
private byte _OwnerType;
public byte OwnerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("OwnerType", true);
return _OwnerType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("OwnerType", true);
if (_OwnerType != value)
{
_OwnerType = value;
PropertyHasChanged();
}
}
}
private int _OwnerItemID;
public int OwnerItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("OwnerItemID", true);
return _OwnerItemID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("OwnerItemID", true);
if (_OwnerItemID != value)
{
_OwnerItemID = value;
PropertyHasChanged();
}
}
}
private DateTime _DTSStart = new DateTime();
public DateTime DTSStart
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTSStart", true);
return _DTSStart;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTSStart", true);
if (_DTSStart != value)
{
_DTSStart = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty
{
get { return base.IsDirty; }
}
public bool IsDirtyList(List<object> list)
{
return base.IsDirty;
}
public override bool IsValid
{
get { return (IsNew && !IsDirty) ? true : base.IsValid; }
}
public bool IsValidList(List<object> list)
{
return (IsNew && !IsDirty) ? true : base.IsValid;
}
// CSLATODO: Replace base Owner.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Owner</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check Owner.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 Owner</returns>
protected override object GetIdValue()
{
return MyOwnerUnique; // Absolutely Unique ID
}
#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;
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.AddDependantProperty("x", "y");
_OwnerExtension.AddValidationRules(ValidationRules);
// CSLATODO: Add other validation rules
}
protected override void AddInstanceBusinessRules()
{
_OwnerExtension.AddInstanceValidationRules(ValidationRules);
// CSLATODO: 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()
{
//CSLATODO: Who can read/write which fields
//AuthorizationRules.AllowRead(OwnerID, "<Role(s)>");
//AuthorizationRules.AllowRead(SessionID, "<Role(s)>");
//AuthorizationRules.AllowRead(OwnerType, "<Role(s)>");
//AuthorizationRules.AllowRead(OwnerItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTSStart, "<Role(s)>");
//AuthorizationRules.AllowWrite(SessionID, "<Role(s)>");
//AuthorizationRules.AllowWrite(OwnerType, "<Role(s)>");
//AuthorizationRules.AllowWrite(OwnerItemID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTSStart, "<Role(s)>");
_OwnerExtension.AddAuthorizationRules(AuthorizationRules);
}
protected override void AddInstanceAuthorizationRules()
{
//CSLATODO: Who can read/write which fields
_OwnerExtension.AddInstanceAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// CSLATODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// CSLATODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// CSLATODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// CSLATODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private static int _OwnerUnique = 0;
protected static int OwnerUnique
{ get { return ++_OwnerUnique; } }
private int _MyOwnerUnique = OwnerUnique;
public int MyOwnerUnique // Absolutely Unique ID - Editable
{ get { return _MyOwnerUnique; } }
protected Owner()
{/* require use of factory methods */
AddToCache(this);
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~Owner()
{
_CountFinalized++;
}
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
RemoveFromDictionaries();
}
private void RemoveFromDictionaries()
{
RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(OwnerID.ToString()))
{
List<Owner> listOwner = _CacheByPrimaryKey[OwnerID.ToString()]; // Get the list of items
while (listOwner.Contains(this)) listOwner.Remove(this); // Remove the item from the list
if (listOwner.Count == 0) //If there are no items left in the list
_CacheByPrimaryKey.Remove(OwnerID.ToString()); // remove the list
}
}
public static Owner New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Owner");
try
{
return DataPortal.Create<Owner>();
}
catch (Exception ex)
{
throw new DbCslaException("Error on Owner.New", ex);
}
}
public static Owner New(int sessionID, byte ownerType, int ownerItemID, DateTime dTSStart)
{
Owner tmp = Owner.New();
tmp.SessionID = sessionID;
tmp.OwnerType = ownerType;
tmp.OwnerItemID = ownerItemID;
tmp.DTSStart = dTSStart;
return tmp;
}
public static Owner MakeOwner(int sessionID, byte ownerType, int ownerItemID, DateTime dTSStart)
{
Owner tmp = Owner.New(sessionID, ownerType, ownerItemID, dTSStart);
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 Owner Get(int ownerID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Owner");
try
{
Owner tmp = GetCachedByPrimaryKey(ownerID);
if (tmp == null)
{
tmp = DataPortal.Fetch<Owner>(new PKCriteria(ownerID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Owner
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Owner.Get", ex);
}
}
public static Owner Get(SafeDataReader dr)
{
if (dr.Read()) return new Owner(dr);
return null;
}
internal Owner(SafeDataReader dr)
{
ReadData(dr);
}
public static void Delete(int ownerID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Owner");
try
{
DataPortal.Delete(new PKCriteria(ownerID));
}
catch (Exception ex)
{
throw new DbCslaException("Error on Owner.Delete", ex);
}
}
public override Owner Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Owner");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Owner");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Owner");
try
{
BuildRefreshList();
Owner owner = base.Save();
RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache
AddToCache(owner);//Refresh the item in AllList
ProcessRefreshList();
return owner;
}
catch (Exception ex)
{
throw new DbCslaException("Error on CSLA Save", ex);
}
}
#endregion
#region Data Access Portal
[Serializable()]
protected class PKCriteria
{
private int _OwnerID;
public int OwnerID
{ get { return _OwnerID; } }
public PKCriteria(int ownerID)
{
_OwnerID = ownerID;
}
}
// CSLATODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create()
{
_OwnerID = NextOwnerID;
// Database Defaults
_SessionID = _OwnerExtension.DefaultSessionID;
_OwnerType = _OwnerExtension.DefaultOwnerType;
_OwnerItemID = _OwnerExtension.DefaultOwnerItemID;
_DTSStart = _OwnerExtension.DefaultDTSStart;
// CSLATODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.ReadData", GetHashCode());
try
{
_OwnerID = dr.GetInt32("OwnerID");
_SessionID = dr.GetInt32("SessionID");
_OwnerType = dr.GetByte("OwnerType");
_OwnerItemID = dr.GetInt32("OwnerItemID");
_DTSStart = dr.GetDateTime("DTSStart");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
MarkOld();
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Owner.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Owner.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.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 = "getOwner";
cm.Parameters.AddWithValue("@OwnerID", criteria.OwnerID);
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("Owner.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Owner.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("Owner.DataPortal_Insert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Owner.DataPortal_Insert", ex);
}
finally
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.DataPortal_Insert", GetHashCode());
}
}
[Transactional(TransactionalTypes.TransactionScope)]
internal void SQLInsert()
{
if (!this.IsDirty) return;
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addOwner";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@SessionID", _SessionID);
cm.Parameters.AddWithValue("@OwnerType", _OwnerType);
cm.Parameters.AddWithValue("@OwnerItemID", _OwnerItemID);
if (_DTSStart.Year >= 1753 && _DTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", _DTSStart);
// Output Calculated Columns
SqlParameter param_OwnerID = new SqlParameter("@newOwnerID", SqlDbType.Int);
param_OwnerID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_OwnerID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_OwnerID = (int)cm.Parameters["@newOwnerID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
MarkOld();
// update child objects
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.SQLInsert", GetHashCode());
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Owner.SQLInsert", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Owner.SQLInsert", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int ownerID, int sessionID, byte ownerType, int ownerItemID, DateTime dTSStart)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.Add", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addOwner";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@SessionID", sessionID);
cm.Parameters.AddWithValue("@OwnerType", ownerType);
cm.Parameters.AddWithValue("@OwnerItemID", ownerItemID);
if (dTSStart.Year >= 1753 && dTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", dTSStart);
// Output Calculated Columns
SqlParameter param_OwnerID = new SqlParameter("@newOwnerID", SqlDbType.Int);
param_OwnerID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_OwnerID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
ownerID = (int)cm.Parameters["@newOwnerID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Owner.Add", ex);
throw new DbCslaException("Owner.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}] Owner.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("Owner.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}] Owner.SQLUpdate", GetHashCode());
try
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateOwner";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@OwnerID", _OwnerID);
cm.Parameters.AddWithValue("@SessionID", _SessionID);
cm.Parameters.AddWithValue("@OwnerType", _OwnerType);
cm.Parameters.AddWithValue("@OwnerItemID", _OwnerItemID);
if (_DTSStart.Year >= 1753 && _DTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", _DTSStart);
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);
// CSLATODO: 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("Owner.SQLUpdate", ex);
_ErrorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user.")) throw ex;
}
}
internal void Update()
{
if (!this.IsDirty) return;
if (base.IsDirty)
{
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (IsNew)
_LastChanged = Owner.Add(cn, ref _OwnerID, _SessionID, _OwnerType, _OwnerItemID, _DTSStart);
else
_LastChanged = Owner.Update(cn, ref _OwnerID, _SessionID, _OwnerType, _OwnerItemID, _DTSStart, ref _LastChanged);
MarkOld();
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int ownerID, int sessionID, byte ownerType, int ownerItemID, DateTime dTSStart, ref byte[] lastChanged)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.Update", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateOwner";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@OwnerID", ownerID);
cm.Parameters.AddWithValue("@SessionID", sessionID);
cm.Parameters.AddWithValue("@OwnerType", ownerType);
cm.Parameters.AddWithValue("@OwnerItemID", ownerItemID);
if (dTSStart.Year >= 1753 && dTSStart.Year <= 9999) cm.Parameters.AddWithValue("@DTSStart", dTSStart);
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);
// CSLATODO: 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("Owner.Update", ex);
throw new DbCslaException("Owner.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_OwnerID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.DataPortal_Delete", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteOwner";
cm.Parameters.AddWithValue("@OwnerID", criteria.OwnerID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Owner.DataPortal_Delete", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("Owner.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int ownerID)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.Remove", 0);
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteOwner";
// Input PK Fields
cm.Parameters.AddWithValue("@OwnerID", ownerID);
// CSLATODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Owner.Remove", ex);
throw new DbCslaException("Owner.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int ownerID)
{
ExistsCommand result;
try
{
result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(ownerID));
return result.Exists;
}
catch (Exception ex)
{
throw new DbCslaException("Error on Owner.Exists", ex);
}
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _OwnerID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int ownerID)
{
_OwnerID = ownerID;
}
protected override void DataPortal_Execute()
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Owner.DataPortal_Execute", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsOwner";
cm.Parameters.AddWithValue("@OwnerID", _OwnerID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("Owner.DataPortal_Execute", ex);
throw new DbCslaException("Owner.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
OwnerExtension _OwnerExtension = new OwnerExtension();
[Serializable()]
partial class OwnerExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultSessionID
{
get { return 0; }
}
public virtual byte DefaultOwnerType
{
get { return 0; }
}
public virtual int DefaultOwnerItemID
{
get { return 0; }
}
public virtual DateTime DefaultDTSStart
{
get { return DateTime.Now; }
}
// 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 OwnerConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is Owner)
{
// Return the ToString value
return ((Owner)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
//// The following is a sample Extension File. You can use it to create OwnerExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace VEPROMS.CSLA.Library
//{
// public partial class Owner
// {
// partial class OwnerExtension : extensionBase
// {
// // CSLATODO: Override automatic defaults
// public virtual int DefaultSessionID
// {
// get { return 0; }
// }
// public virtual byte DefaultOwnerType
// {
// get { return 0; }
// }
// public virtual int DefaultOwnerItemID
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTSStart
// {
// get { return DateTime.Now; }
// }
// 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 */);
// }
// }
// }
//}
@@ -0,0 +1,354 @@
// ========================================================================
// 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 OwnerInfoEvent(object sender);
/// <summary>
/// OwnerInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(OwnerInfoConverter))]
public partial class OwnerInfo : ReadOnlyBase<OwnerInfo>, IDisposable
{
public event OwnerInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<OwnerInfo> _CacheList = new List<OwnerInfo>();
protected static void AddToCache(OwnerInfo ownerInfo)
{
if (!_CacheList.Contains(ownerInfo)) _CacheList.Add(ownerInfo); // In AddToCache
}
protected static void RemoveFromCache(OwnerInfo ownerInfo)
{
while (_CacheList.Contains(ownerInfo)) _CacheList.Remove(ownerInfo); // In RemoveFromCache
}
private static Dictionary<string, List<OwnerInfo>> _CacheByPrimaryKey = new Dictionary<string, List<OwnerInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move OwnerInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
OwnerInfo tmp = _CacheList[0]; // Get the first OwnerInfo
string pKey = tmp.OwnerID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<OwnerInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first OwnerInfo
}
}
internal static void AddList(OwnerInfoList lst)
{
foreach (OwnerInfo item in lst) AddToCache(item);
}
protected static OwnerInfo GetCachedByPrimaryKey(int ownerID)
{
ConvertListToDictionary();
string key = ownerID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Owner _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _OwnerID;
[System.ComponentModel.DataObjectField(true, true)]
public int OwnerID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("OwnerID", true);
return _OwnerID;
}
}
private int _SessionID;
public int SessionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SessionID", true);
return _SessionID;
}
}
private byte _OwnerType;
public byte OwnerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("OwnerType", true);
return _OwnerType;
}
}
private int _OwnerItemID;
public int OwnerItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("OwnerItemID", true);
return _OwnerItemID;
}
}
private DateTime _DTSStart = new DateTime();
public DateTime DTSStart
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTSStart", true);
return _DTSStart;
}
}
// CSLATODO: Replace base OwnerInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current OwnerInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check OwnerInfo.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 OwnerInfo</returns>
protected override object GetIdValue()
{
return MyOwnerInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _OwnerInfoUnique = 0;
private static int OwnerInfoUnique
{ get { return ++_OwnerInfoUnique; } }
private int _MyOwnerInfoUnique = OwnerInfoUnique;
public int MyOwnerInfoUnique // Absolutely Unique ID - Info
{ get { return _MyOwnerInfoUnique; } }
protected OwnerInfo()
{/* require use of factory methods */
AddToCache(this);
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~OwnerInfo()
{
_CountFinalized++;
}
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(OwnerID.ToString())) return;
List<OwnerInfo> listOwnerInfo = _CacheByPrimaryKey[OwnerID.ToString()]; // Get the list of items
while (listOwnerInfo.Contains(this)) listOwnerInfo.Remove(this); // Remove the item from the list
if (listOwnerInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(OwnerID.ToString()); // remove the list
}
public virtual Owner Get()
{
return _Editable = Owner.Get(_OwnerID);
}
public static void Refresh(Owner tmp)
{
string key = tmp.OwnerID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (OwnerInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Owner tmp)
{
_SessionID = tmp.SessionID;
_OwnerType = tmp.OwnerType;
_OwnerItemID = tmp.OwnerItemID;
_DTSStart = tmp.DTSStart;
_OwnerInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static OwnerInfo Get(int ownerID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Owner");
try
{
OwnerInfo tmp = GetCachedByPrimaryKey(ownerID);
if (tmp == null)
{
tmp = DataPortal.Fetch<OwnerInfo>(new PKCriteria(ownerID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up OwnerInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on OwnerInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal OwnerInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfo.Constructor", ex);
throw new DbCslaException("OwnerInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _OwnerID;
public int OwnerID
{ get { return _OwnerID; } }
public PKCriteria(int ownerID)
{
_OwnerID = ownerID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.ReadData", GetHashCode());
try
{
_OwnerID = dr.GetInt32("OwnerID");
_SessionID = dr.GetInt32("SessionID");
_OwnerType = dr.GetByte("OwnerType");
_OwnerItemID = dr.GetInt32("OwnerItemID");
_DTSStart = dr.GetDateTime("DTSStart");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("OwnerInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.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 = "getOwner";
cm.Parameters.AddWithValue("@OwnerID", criteria.OwnerID);
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("OwnerInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("OwnerInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
OwnerInfoExtension _OwnerInfoExtension = new OwnerInfoExtension();
[Serializable()]
partial class OwnerInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(OwnerInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class OwnerInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is OwnerInfo)
{
// Return the ToString value
return ((OwnerInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,225 @@
// ========================================================================
// 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>
/// OwnerInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(OwnerInfoListConverter))]
public partial class OwnerInfoList : ReadOnlyListBase<OwnerInfoList, OwnerInfo>, 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<OwnerInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (OwnerInfo tmp in this)
{
tmp.Changed += new OwnerInfoEvent(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));
}
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~OwnerInfoList()
{
_CountFinalized++;
}
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
foreach (OwnerInfo tmp in this)
{
tmp.Changed -= new OwnerInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static OwnerInfoList _OwnerInfoList = null;
/// <summary>
/// Return a list of all OwnerInfo.
/// </summary>
public static OwnerInfoList Get()
{
try
{
if (_OwnerInfoList != null)
return _OwnerInfoList;
OwnerInfoList tmp = DataPortal.Fetch<OwnerInfoList>();
OwnerInfo.AddList(tmp);
tmp.AddEvents();
_OwnerInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on OwnerInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all OwnerInfo.
/// </summary>
public static void Reset()
{
_OwnerInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static OwnerInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<OwnerInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on OwnerInfoList.Get", ex);
// }
//}
private OwnerInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getOwners";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new OwnerInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("OwnerInfoList.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
OwnerInfoListPropertyDescriptor pd = new OwnerInfoListPropertyDescriptor(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 OwnerInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private OwnerInfo Item { get { return (OwnerInfo)_Item; } }
public OwnerInfoListPropertyDescriptor(OwnerInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class OwnerInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is OwnerInfoList)
{
// Return department and department role separated by comma.
return ((OwnerInfoList)value).Items.Count.ToString() + " Owners";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,67 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// PropertyDescriptor Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class vlnListPropertyDescriptor : PropertyDescriptor
{
protected object _Item = null;
public vlnListPropertyDescriptor(System.Collections.IList collection, int index)
: base("#" + index.ToString(), null)
{ _Item = collection[index]; }
public override bool CanResetValue(object component)
{ return true; }
public override Type ComponentType
{ get { return _Item.GetType(); } }
public override object GetValue(object component)
{ return _Item; }
public override bool IsReadOnly
{ get { return false; } }
public override Type PropertyType
{ get { return _Item.GetType(); } }
public override void ResetValue(object component)
{ ;}
public override bool ShouldSerializeValue(object component)
{ return true; }
public override void SetValue(object component, object value)
{ /*_Item = value*/;}
//public override AttributeCollection Attributes
//{ get { return new AttributeCollection(null); } }
public override string DisplayName
{ get { return _Item.ToString(); } }
public override string Description
{ get { return _Item.ToString(); } }
public override string Name
{ get { return _Item.ToString(); } }
} // Class
public interface IVEHasBrokenRules
{
IVEHasBrokenRules HasBrokenRules { get; }
BrokenRulesCollection BrokenRules { get; }
}
} // Namespace
// The following are samples of ToString overrides
// public partial class Owner
// { public override string ToString() { return string.Format("{0}", _Name); } }
// public partial class OwnerInfo
// { public override string ToString() { return string.Format("{0}", _Name); } }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,378 @@
// ========================================================================
// 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 SessionInfoEvent(object sender);
/// <summary>
/// SessionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(SessionInfoConverter))]
public partial class SessionInfo : ReadOnlyBase<SessionInfo>, IDisposable
{
public event SessionInfoEvent Changed;
private void OnChange()
{
if (Changed != null) Changed(this);
}
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Collection
private static List<SessionInfo> _CacheList = new List<SessionInfo>();
protected static void AddToCache(SessionInfo sessionInfo)
{
if (!_CacheList.Contains(sessionInfo)) _CacheList.Add(sessionInfo); // In AddToCache
}
protected static void RemoveFromCache(SessionInfo sessionInfo)
{
while (_CacheList.Contains(sessionInfo)) _CacheList.Remove(sessionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<SessionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<SessionInfo>>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move SessionInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
SessionInfo tmp = _CacheList[0]; // Get the first SessionInfo
string pKey = tmp.SessionID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List<SessionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first SessionInfo
}
}
internal static void AddList(SessionInfoList lst)
{
foreach (SessionInfo item in lst) AddToCache(item);
}
protected static SessionInfo GetCachedByPrimaryKey(int sessionID)
{
ConvertListToDictionary();
string key = sessionID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Session _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _SessionID;
[System.ComponentModel.DataObjectField(true, true)]
public int SessionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SessionID", true);
return _SessionID;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private DateTime _DTSDtart = new DateTime();
public DateTime DTSDtart
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTSDtart", true);
return _DTSDtart;
}
}
private DateTime? _DTSEnd;
public DateTime? DTSEnd
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTSEnd", true);
return _DTSEnd;
}
}
private DateTime _DTSActivity = new DateTime();
public DateTime DTSActivity
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTSActivity", true);
return _DTSActivity;
}
}
private string _MachineName = string.Empty;
public string MachineName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MachineName", true);
return _MachineName;
}
}
private int _ProcessID;
public int ProcessID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ProcessID", true);
return _ProcessID;
}
}
// CSLATODO: Replace base SessionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current SessionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// CSLATODO: Check SessionInfo.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 SessionInfo</returns>
protected override object GetIdValue()
{
return MySessionInfoUnique; // Absolutely Unique ID
}
#endregion
#region Factory Methods
private static int _SessionInfoUnique = 0;
private static int SessionInfoUnique
{ get { return ++_SessionInfoUnique; } }
private int _MySessionInfoUnique = SessionInfoUnique;
public int MySessionInfoUnique // Absolutely Unique ID - Info
{ get { return _MySessionInfoUnique; } }
protected SessionInfo()
{/* require use of factory methods */
AddToCache(this);
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~SessionInfo()
{
_CountFinalized++;
}
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(SessionID.ToString())) return;
List<SessionInfo> listSessionInfo = _CacheByPrimaryKey[SessionID.ToString()]; // Get the list of items
while (listSessionInfo.Contains(this)) listSessionInfo.Remove(this); // Remove the item from the list
if (listSessionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(SessionID.ToString()); // remove the list
}
public virtual Session Get()
{
return _Editable = Session.Get(_SessionID);
}
public static void Refresh(Session tmp)
{
string key = tmp.SessionID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (SessionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Session tmp)
{
_UserID = tmp.UserID;
_DTSDtart = tmp.DTSDtart;
_DTSEnd = tmp.DTSEnd;
_DTSActivity = tmp.DTSActivity;
_MachineName = tmp.MachineName;
_ProcessID = tmp.ProcessID;
_SessionInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static SessionInfo Get(int sessionID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Session");
try
{
SessionInfo tmp = GetCachedByPrimaryKey(sessionID);
if (tmp == null)
{
tmp = DataPortal.Fetch<SessionInfo>(new PKCriteria(sessionID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up SessionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on SessionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal SessionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionInfo.Constructor", ex);
throw new DbCslaException("SessionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _SessionID;
public int SessionID
{ get { return _SessionID; } }
public PKCriteria(int sessionID)
{
_SessionID = sessionID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.ReadData", GetHashCode());
try
{
_SessionID = dr.GetInt32("SessionID");
_UserID = dr.GetString("UserID");
_DTSDtart = dr.GetDateTime("DTSDtart");
if (!dr.IsDBNull(dr.GetOrdinal("DTSEnd"))) _DTSEnd = dr.GetDateTime("DTSEnd");
_DTSActivity = dr.GetDateTime("DTSActivity");
_MachineName = dr.GetString("MachineName");
_ProcessID = dr.GetInt32("ProcessID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("SessionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.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 = "getSession";
cm.Parameters.AddWithValue("@SessionID", criteria.SessionID);
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("SessionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("SessionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
SessionInfoExtension _SessionInfoExtension = new SessionInfoExtension();
[Serializable()]
partial class SessionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(SessionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class SessionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is SessionInfo)
{
// Return the ToString value
return ((SessionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,225 @@
// ========================================================================
// 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>
/// SessionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(SessionInfoListConverter))]
public partial class SessionInfoList : ReadOnlyListBase<SessionInfoList, SessionInfo>, 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<SessionInfo> Items
{ get { return base.Items; } }
public void AddEvents()
{
foreach (SessionInfo tmp in this)
{
tmp.Changed += new SessionInfoEvent(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));
}
}
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~SessionInfoList()
{
_CountFinalized++;
}
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
foreach (SessionInfo tmp in this)
{
tmp.Changed -= new SessionInfoEvent(tmp_Changed);
}
}
#endregion
#region Factory Methods
public static SessionInfoList _SessionInfoList = null;
/// <summary>
/// Return a list of all SessionInfo.
/// </summary>
public static SessionInfoList Get()
{
try
{
if (_SessionInfoList != null)
return _SessionInfoList;
SessionInfoList tmp = DataPortal.Fetch<SessionInfoList>();
SessionInfo.AddList(tmp);
tmp.AddEvents();
_SessionInfoList = tmp;
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on SessionInfoList.Get", ex);
}
}
/// <summary>
/// Reset the list of all SessionInfo.
/// </summary>
public static void Reset()
{
_SessionInfoList = null;
}
// CSLATODO: Add alternative gets -
//public static SessionInfoList Get(<criteria>)
//{
// try
// {
// return DataPortal.Fetch<SessionInfoList>(new FilteredCriteria(<criteria>));
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on SessionInfoList.Get", ex);
// }
//}
private SessionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
private void DataPortal_Fetch()
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getSessions";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new SessionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("SessionInfoList.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
SessionInfoListPropertyDescriptor pd = new SessionInfoListPropertyDescriptor(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 SessionInfoListPropertyDescriptor : vlnListPropertyDescriptor
{
private SessionInfo Item { get { return (SessionInfo)_Item; } }
public SessionInfoListPropertyDescriptor(SessionInfoList collection, int index) : base(collection, index) { ;}
}
#endregion
#region Converter
internal class SessionInfoListConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is SessionInfoList)
{
// Return department and department role separated by comma.
return ((SessionInfoList)value).Items.Count.ToString() + " Sessions";
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -0,0 +1,55 @@
/****** Object: StoredProcedure [addSession] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[addSession]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [addSession];
GO
CREATE PROCEDURE [dbo].[addSession]
(
@UserID nvarchar(100),
@DTSDtart datetime,
@DTSEnd datetime=null,
@DTSActivity datetime,
@MachineName nvarchar(100),
@ProcessID int,
@newSessionID int output,
@newLastChanged timestamp output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
INSERT INTO [Sessions]
(
[UserID],
[DTSDtart],
[DTSEnd],
[DTSActivity],
[MachineName],
[ProcessID]
)
VALUES
(
@UserID,
@DTSDtart,
@DTSEnd,
@DTSActivity,
@MachineName,
@ProcessID
)
SELECT @newSessionID= SCOPE_IDENTITY()
SELECT @newLastChanged=[LastChanged]
FROM [Sessions] WHERE [SessionID]=@newSessionID
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: addSession Succeeded'
ELSE PRINT 'Procedure Creation: addSession Error on Creation'
GO
@@ -0,0 +1,29 @@
/****** Object: StoredProcedure [deleteSession] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[deleteSession]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [deleteSession];
GO
CREATE PROCEDURE [dbo].[deleteSession]
(
@SessionID int
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DELETE [Sessions]
WHERE [SessionID] = @SessionID
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: deleteSession Succeeded'
ELSE PRINT 'Procedure Creation: deleteSession Error on Creation'
GO
@@ -0,0 +1,21 @@
/****** Object: StoredProcedure [existsSession] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[existsSession]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [existsSession];
GO
CREATE PROCEDURE [dbo].[existsSession]
(
@SessionID int
)
WITH EXECUTE AS OWNER
AS
SELECT COUNT(*)
FROM [Sessions] WHERE [SessionID]=@SessionID
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: existsSession Succeeded'
ELSE PRINT 'Procedure Creation: existsSession Error on Creation'
GO
@@ -0,0 +1,30 @@
/****** Object: StoredProcedure [getSession] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getSession]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getSession];
GO
CREATE PROCEDURE [dbo].[getSession]
(
@SessionID int
)
WITH EXECUTE AS OWNER
AS
SELECT
[SessionID],
[UserID],
[DTSDtart],
[DTSEnd],
[DTSActivity],
[LastChanged],
[MachineName],
[ProcessID]
FROM [Sessions]
WHERE [SessionID]=@SessionID
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getSession Succeeded'
ELSE PRINT 'Procedure Creation: getSession Error on Creation'
GO
@@ -0,0 +1,26 @@
/****** Object: StoredProcedure [getSessions] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getSessions]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getSessions];
GO
CREATE PROCEDURE [dbo].[getSessions]
WITH EXECUTE AS OWNER
AS
SELECT
[SessionID],
[UserID],
[DTSDtart],
[DTSEnd],
[DTSActivity],
[LastChanged],
[MachineName],
[ProcessID]
FROM [Sessions]
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getSessions Succeeded'
ELSE PRINT 'Procedure Creation: getSessions Error on Creation'
GO
@@ -0,0 +1,26 @@
/****** Object: StoredProcedure [purgeData] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[purgeData]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [purgeData];
GO
CREATE PROCEDURE [dbo].[purgeData]
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
delete from [Sessions]
dbcc checkident([Sessions],reseed,0)
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: purgeData Succeeded'
ELSE PRINT 'Procedure Creation: purgeData Error on Creation'
GO
@@ -0,0 +1,55 @@
/****** Object: StoredProcedure [updateSession] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[updateSession]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [updateSession];
GO
CREATE PROCEDURE [dbo].[updateSession]
(
@SessionID int,
@UserID nvarchar(100),
@DTSDtart datetime,
@DTSEnd datetime=null,
@DTSActivity datetime,
@LastChanged timestamp,
@MachineName nvarchar(100),
@ProcessID int,
@newLastChanged timestamp output
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
UPDATE [Sessions]
SET
[UserID]=@UserID,
[DTSDtart]=@DTSDtart,
[DTSEnd]=@DTSEnd,
[DTSActivity]=@DTSActivity,
[MachineName]=@MachineName,
[ProcessID]=@ProcessID
WHERE [SessionID]=@SessionID AND [LastChanged]=@LastChanged
IF @@ROWCOUNT = 0
BEGIN
IF NOT exists(select * from [Sessions] WHERE [SessionID]=@SessionID)
RAISERROR('Session record has been deleted by another user', 16, 1)
ELSE
RAISERROR('Session has been edited by another user', 16, 1)
END
SELECT @newLastChanged=[LastChanged]
FROM [Sessions] WHERE [SessionID]=@SessionID
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: updateSession Succeeded'
ELSE PRINT 'Procedure Creation: updateSession Error on Creation'
GO
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,487 @@
// ========================================================================
// 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
private static List<AnnotationInfo> _CacheList = new List<AnnotationInfo>();
protected static void AddToCache(AnnotationInfo annotationInfo)
{
if (!_CacheList.Contains(annotationInfo)) _CacheList.Add(annotationInfo); // In AddToCache
}
protected static void RemoveFromCache(AnnotationInfo annotationInfo)
{
while (_CacheList.Contains(annotationInfo)) _CacheList.Remove(annotationInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AnnotationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationInfo>>();
private static void ConvertListToDictionary()
{
List<AnnotationInfo> remove = new List<AnnotationInfo>();
foreach (AnnotationInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.AnnotationID.ToString()))
{
_CacheByPrimaryKey[tmp.AnnotationID.ToString()] = new List<AnnotationInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.AnnotationID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (AnnotationInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(AnnotationInfoList lst)
{
foreach (AnnotationInfo item in lst) AddToCache(item);
}
protected static AnnotationInfo GetCachedByPrimaryKey(int annotationID)
{
ConvertListToDictionary();
string key = annotationID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Annotation _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _AnnotationID;
[System.ComponentModel.DataObjectField(true, true)]
public int AnnotationID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationID", true);
return _AnnotationID;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private ItemInfo _MyItem;
public ItemInfo MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem;
}
}
private int _TypeID;
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID;
}
}
private AnnotationTypeInfo _MyAnnotationType;
public AnnotationTypeInfo MyAnnotationType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID);
return _MyAnnotationType;
}
}
private string _RtfText = string.Empty;
public string RtfText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RtfText", true);
return _RtfText;
}
}
private string _SearchText = string.Empty;
public string SearchText
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("SearchText", true);
return _SearchText;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
// TODO: Replace base AnnotationInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AnnotationInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current AnnotationInfo</returns>
protected override object GetIdValue()
{
return _AnnotationID;
}
#endregion
#region Factory Methods
private static int _AnnotationInfoUnique = 0;
private static int AnnotationInfoUnique
{ get { return ++_AnnotationInfoUnique; } }
private int _MyAnnotationInfoUnique = AnnotationInfoUnique;
public int MyAnnotationInfoUnique
{ get { return _MyAnnotationInfoUnique; } }
protected AnnotationInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AnnotationID.ToString())) return;
List<AnnotationInfo> listAnnotationInfo = _CacheByPrimaryKey[AnnotationID.ToString()]; // Get the list of items
while (listAnnotationInfo.Contains(this)) listAnnotationInfo.Remove(this); // Remove the item from the list
if (listAnnotationInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AnnotationID.ToString()); // remove the list
}
public virtual Annotation Get()
{
return _Editable = Annotation.Get(_AnnotationID);
}
public static void Refresh(Annotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Annotation tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
if (_TypeID != tmp.TypeID)
{
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value
}
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if(_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(AnnotationTypeAnnotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(AnnotationTypeAnnotation tmp)
{
if (_ItemID != tmp.ItemID)
{
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for old value
_ItemID = tmp.ItemID; // Update the value
}
_MyItem = null; // Reset list so that the next line gets a new list
if (MyItem != null) MyItem.RefreshItemAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if(_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(ItemAnnotation tmp)
{
string key = tmp.AnnotationID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(ItemAnnotation tmp)
{
if (_TypeID != tmp.TypeID)
{
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for old value
_TypeID = tmp.TypeID; // Update the value
}
_MyAnnotationType = null; // Reset list so that the next line gets a new list
if (MyAnnotationType != null) MyAnnotationType.RefreshAnnotationTypeAnnotations(); // Update List for new value
_RtfText = tmp.RtfText;
_SearchText = tmp.SearchText;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationInfoExtension.Refresh(this);
if(_MyItem != null)
{
_MyItem.Dispose();// Dispose related value
_MyItem = null;// Reset related value
}
if(_MyAnnotationType != null)
{
_MyAnnotationType.Dispose();// Dispose related value
_MyAnnotationType = null;// Reset related value
}
OnChange();// raise an event
}
public static AnnotationInfo Get(int annotationID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Annotation");
try
{
AnnotationInfo tmp = GetCachedByPrimaryKey(annotationID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationInfo>(new PKCriteria(annotationID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.Constructor", ex);
throw new DbCslaException("AnnotationInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _AnnotationID;
public int AnnotationID
{ get { return _AnnotationID; } }
public PKCriteria(int annotationID)
{
_AnnotationID = annotationID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.ReadData", GetHashCode());
try
{
_AnnotationID = dr.GetInt32("AnnotationID");
_ItemID = dr.GetInt32("ItemID");
_TypeID = dr.GetInt32("TypeID");
_RtfText = dr.GetString("RtfText");
_SearchText = dr.GetString("SearchText");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotation";
cm.Parameters.AddWithValue("@AnnotationID", criteria.AnnotationID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationInfoExtension _AnnotationInfoExtension = new AnnotationInfoExtension();
[Serializable()]
partial class AnnotationInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationInfo)
{
// Return the ToString value
return ((AnnotationInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -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
@@ -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 */);
// }
// }
// }
//}
@@ -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
@@ -0,0 +1,371 @@
// ========================================================================
// 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
private static List<AnnotationTypeInfo> _CacheList = new List<AnnotationTypeInfo>();
protected static void AddToCache(AnnotationTypeInfo annotationTypeInfo)
{
if (!_CacheList.Contains(annotationTypeInfo)) _CacheList.Add(annotationTypeInfo); // In AddToCache
}
protected static void RemoveFromCache(AnnotationTypeInfo annotationTypeInfo)
{
while (_CacheList.Contains(annotationTypeInfo)) _CacheList.Remove(annotationTypeInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AnnotationTypeInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationTypeInfo>>();
private static void ConvertListToDictionary()
{
List<AnnotationTypeInfo> remove = new List<AnnotationTypeInfo>();
foreach (AnnotationTypeInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.TypeID.ToString()))
{
_CacheByPrimaryKey[tmp.TypeID.ToString()] = new List<AnnotationTypeInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.TypeID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (AnnotationTypeInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(AnnotationTypeInfoList lst)
{
foreach (AnnotationTypeInfo item in lst) AddToCache(item);
}
protected static AnnotationTypeInfo GetCachedByPrimaryKey(int typeID)
{
ConvertListToDictionary();
string key = typeID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected AnnotationType _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _TypeID;
[System.ComponentModel.DataObjectField(true, true)]
public int TypeID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("TypeID", true);
return _TypeID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name", true);
return _Name;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
}
private int _AnnotationTypeAnnotationCount = 0;
/// <summary>
/// Count of AnnotationTypeAnnotations for this AnnotationType
/// </summary>
public int AnnotationTypeAnnotationCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationTypeAnnotationCount", true);
return _AnnotationTypeAnnotationCount;
}
}
private AnnotationInfoList _AnnotationTypeAnnotations = null;
[TypeConverter(typeof(AnnotationInfoListConverter))]
public AnnotationInfoList AnnotationTypeAnnotations
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AnnotationTypeAnnotations", true);
if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null))
_AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID);
if (_AnnotationTypeAnnotationCount < 0)
_AnnotationTypeAnnotationCount = _AnnotationTypeAnnotations.Count;
return _AnnotationTypeAnnotations;
}
}
public void RefreshAnnotationTypeAnnotations()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_TypeID.ToString()))
foreach (AnnotationTypeInfo tmp in _CacheByPrimaryKey[_TypeID.ToString()])
tmp._AnnotationTypeAnnotationCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base AnnotationTypeInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AnnotationTypeInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AnnotationTypeInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current AnnotationTypeInfo</returns>
protected override object GetIdValue()
{
return _TypeID;
}
#endregion
#region Factory Methods
private static int _AnnotationTypeInfoUnique = 0;
private static int AnnotationTypeInfoUnique
{ get { return ++_AnnotationTypeInfoUnique; } }
private int _MyAnnotationTypeInfoUnique = AnnotationTypeInfoUnique;
public int MyAnnotationTypeInfoUnique
{ get { return _MyAnnotationTypeInfoUnique; } }
protected AnnotationTypeInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(TypeID.ToString())) return;
List<AnnotationTypeInfo> listAnnotationTypeInfo = _CacheByPrimaryKey[TypeID.ToString()]; // Get the list of items
while (listAnnotationTypeInfo.Contains(this)) listAnnotationTypeInfo.Remove(this); // Remove the item from the list
if (listAnnotationTypeInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(TypeID.ToString()); // remove the list
}
public virtual AnnotationType Get()
{
return _Editable = AnnotationType.Get(_TypeID);
}
public static void Refresh(AnnotationType tmp)
{
string key = tmp.TypeID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AnnotationTypeInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(AnnotationType tmp)
{
_Name = tmp.Name;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_AnnotationTypeInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static AnnotationTypeInfo Get(int typeID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
try
{
AnnotationTypeInfo tmp = GetCachedByPrimaryKey(typeID);
if (tmp == null)
{
tmp = DataPortal.Fetch<AnnotationTypeInfo>(new PKCriteria(typeID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationTypeInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal AnnotationTypeInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.Constructor", ex);
throw new DbCslaException("AnnotationTypeInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _TypeID;
public int TypeID
{ get { return _TypeID; } }
public PKCriteria(int typeID)
{
_TypeID = typeID;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.ReadData", GetHashCode());
try
{
_TypeID = dr.GetInt32("TypeID");
_Name = dr.GetString("Name");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_AnnotationTypeAnnotationCount = dr.GetInt32("AnnotationCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAnnotationType";
cm.Parameters.AddWithValue("@TypeID", criteria.TypeID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationTypeInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
AnnotationTypeInfoExtension _AnnotationTypeInfoExtension = new AnnotationTypeInfoExtension();
[Serializable()]
partial class AnnotationTypeInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(AnnotationTypeInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class AnnotationTypeInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationTypeInfo)
{
// Return the ToString value
return ((AnnotationTypeInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -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
@@ -0,0 +1,578 @@
// ========================================================================
// 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
private static List<AssignmentInfo> _CacheList = new List<AssignmentInfo>();
protected static void AddToCache(AssignmentInfo assignmentInfo)
{
if (!_CacheList.Contains(assignmentInfo)) _CacheList.Add(assignmentInfo); // In AddToCache
}
protected static void RemoveFromCache(AssignmentInfo assignmentInfo)
{
while (_CacheList.Contains(assignmentInfo)) _CacheList.Remove(assignmentInfo); // In RemoveFromCache
}
private static Dictionary<string, List<AssignmentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AssignmentInfo>>();
private static void ConvertListToDictionary()
{
List<AssignmentInfo> remove = new List<AssignmentInfo>();
foreach (AssignmentInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.AID.ToString()))
{
_CacheByPrimaryKey[tmp.AID.ToString()] = new List<AssignmentInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (AssignmentInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(AssignmentInfoList lst)
{
foreach (AssignmentInfo item in lst) AddToCache(item);
}
protected static AssignmentInfo GetCachedByPrimaryKey(int aid)
{
ConvertListToDictionary();
string key = aid.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected 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 static int _AssignmentInfoUnique = 0;
private static int AssignmentInfoUnique
{ get { return ++_AssignmentInfoUnique; } }
private int _MyAssignmentInfoUnique = AssignmentInfoUnique;
public int MyAssignmentInfoUnique
{ get { return _MyAssignmentInfoUnique; } }
protected AssignmentInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(AID.ToString())) return;
List<AssignmentInfo> listAssignmentInfo = _CacheByPrimaryKey[AID.ToString()]; // Get the list of items
while (listAssignmentInfo.Contains(this)) listAssignmentInfo.Remove(this); // Remove the item from the list
if (listAssignmentInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(AID.ToString()); // remove the list
}
public virtual Assignment Get()
{
return _Editable = Assignment.Get(_AID);
}
public static void Refresh(Assignment tmp)
{
string key = tmp.AID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Assignment tmp)
{
if (_GID != tmp.GID)
{
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
_GID = tmp.GID; // Update the value
}
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
if (_RID != tmp.RID)
{
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
_RID = tmp.RID; // Update the value
}
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
if (_FolderID != tmp.FolderID)
{
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value
}
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_AssignmentInfoExtension.Refresh(this);
if(_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
if(_MyRole != null)
{
_MyRole.Dispose();// Dispose related value
_MyRole = null;// Reset related value
}
if(_MyFolder != null)
{
_MyFolder.Dispose();// Dispose related value
_MyFolder = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(FolderAssignment tmp)
{
string key = tmp.AID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(FolderAssignment tmp)
{
if (_GID != tmp.GID)
{
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
_GID = tmp.GID; // Update the value
}
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
if (_RID != tmp.RID)
{
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
_RID = tmp.RID; // Update the value
}
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_AssignmentInfoExtension.Refresh(this);
if(_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
if(_MyRole != null)
{
_MyRole.Dispose();// Dispose related value
_MyRole = null;// Reset related value
}
if(_MyFolder != null)
{
_MyFolder.Dispose();// Dispose related value
_MyFolder = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(GroupAssignment tmp)
{
string key = tmp.AID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(GroupAssignment tmp)
{
if (_RID != tmp.RID)
{
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for old value
_RID = tmp.RID; // Update the value
}
_MyRole = null; // Reset list so that the next line gets a new list
if (MyRole != null) MyRole.RefreshRoleAssignments(); // Update List for new value
if (_FolderID != tmp.FolderID)
{
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value
}
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_AssignmentInfoExtension.Refresh(this);
if(_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
if(_MyRole != null)
{
_MyRole.Dispose();// Dispose related value
_MyRole = null;// Reset related value
}
if(_MyFolder != null)
{
_MyFolder.Dispose();// Dispose related value
_MyFolder = null;// Reset related value
}
OnChange();// raise an event
}
public static void Refresh(RoleAssignment tmp)
{
string key = tmp.AID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (AssignmentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(RoleAssignment tmp)
{
if (_GID != tmp.GID)
{
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for old value
_GID = tmp.GID; // Update the value
}
_MyGroup = null; // Reset list so that the next line gets a new list
if (MyGroup != null) MyGroup.RefreshGroupAssignments(); // Update List for new value
if (_FolderID != tmp.FolderID)
{
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for old value
_FolderID = tmp.FolderID; // Update the value
}
_MyFolder = null; // Reset list so that the next line gets a new list
if (MyFolder != null) MyFolder.RefreshFolderAssignments(); // Update List for new value
_StartDate = tmp.StartDate;
_EndDate = tmp.EndDate;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_AssignmentInfoExtension.Refresh(this);
if(_MyGroup != null)
{
_MyGroup.Dispose();// Dispose related value
_MyGroup = null;// Reset related value
}
if(_MyRole != null)
{
_MyRole.Dispose();// Dispose related value
_MyRole = null;// Reset related value
}
if(_MyFolder != null)
{
_MyFolder.Dispose();// Dispose related value
_MyFolder = null;// Reset related value
}
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 = GetCachedByPrimaryKey(aid);
if (tmp == null)
{
tmp = DataPortal.Fetch<AssignmentInfo>(new PKCriteria(aid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AssignmentInfo
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,636 @@
// ========================================================================
// 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 == null ? _FormatID : (int?)_MyFormat.FormatID) != (value == null ? null : (int?)value.FormatID))
{
_MyFormat = value;
_FormatID = (value == null ? null : (int?)value.FormatID);
PropertyHasChanged();
}
}
}
private double? _ManualOrder;
public double? ManualOrder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ManualOrder", true);
return _ManualOrder;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ManualOrder", true);
if (_ManualOrder != value)
{
_ManualOrder = 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
// 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(ManualOrder, "<Role(s)>");
//AuthorizationRules.AllowWrite(ManualOrder, "<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");
_ManualOrder = (double?)dr.GetValue("ManualOrder");
_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, _ManualOrder, _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, _ManualOrder, _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 */);
// }
// }
// }
//}
@@ -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
@@ -0,0 +1,410 @@
// ========================================================================
// 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
private static List<ConnectionInfo> _CacheList = new List<ConnectionInfo>();
protected static void AddToCache(ConnectionInfo connectionInfo)
{
if (!_CacheList.Contains(connectionInfo)) _CacheList.Add(connectionInfo); // In AddToCache
}
protected static void RemoveFromCache(ConnectionInfo connectionInfo)
{
while (_CacheList.Contains(connectionInfo)) _CacheList.Remove(connectionInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ConnectionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ConnectionInfo>>();
private static void ConvertListToDictionary()
{
List<ConnectionInfo> remove = new List<ConnectionInfo>();
foreach (ConnectionInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.DBID.ToString()))
{
_CacheByPrimaryKey[tmp.DBID.ToString()] = new List<ConnectionInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.DBID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ConnectionInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ConnectionInfoList lst)
{
foreach (ConnectionInfo item in lst) AddToCache(item);
}
protected static ConnectionInfo GetCachedByPrimaryKey(int dbid)
{
ConvertListToDictionary();
string key = dbid.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected Connection _Editable;
private IVEHasBrokenRules HasBrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules;
}
}
private int _DBID;
[System.ComponentModel.DataObjectField(true, true)]
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DBID", true);
return _DBID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Name", true);
return _Name;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Title", true);
return _Title;
}
}
private string _ConnectionString = string.Empty;
public string ConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionString", true);
return _ConnectionString;
}
}
private int _ServerType;
/// <summary>
/// 0 SQL Server
/// </summary>
public int ServerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ServerType", true);
return _ServerType;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID", true);
return _UsrID;
}
}
private int _ConnectionFolderCount = 0;
/// <summary>
/// Count of ConnectionFolders for this Connection
/// </summary>
public int ConnectionFolderCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionFolderCount", true);
return _ConnectionFolderCount;
}
}
private FolderInfoList _ConnectionFolders = null;
[TypeConverter(typeof(FolderInfoListConverter))]
public FolderInfoList ConnectionFolders
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ConnectionFolders", true);
if (_ConnectionFolderCount < 0 || (_ConnectionFolderCount > 0 && _ConnectionFolders == null))
_ConnectionFolders = FolderInfoList.GetByDBID(_DBID);
if (_ConnectionFolderCount < 0)
_ConnectionFolderCount = _ConnectionFolders.Count;
return _ConnectionFolders;
}
}
public void RefreshConnectionFolders()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_DBID.ToString()))
foreach (ConnectionInfo tmp in _CacheByPrimaryKey[_DBID.ToString()])
tmp._ConnectionFolderCount = -1; // This will cause the data to be requeried
}
// TODO: Replace base ConnectionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ConnectionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ConnectionInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ConnectionInfo</returns>
protected override object GetIdValue()
{
return _DBID;
}
#endregion
#region Factory Methods
private static int _ConnectionInfoUnique = 0;
private static int ConnectionInfoUnique
{ get { return ++_ConnectionInfoUnique; } }
private int _MyConnectionInfoUnique = ConnectionInfoUnique;
public int MyConnectionInfoUnique
{ get { return _MyConnectionInfoUnique; } }
protected ConnectionInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(DBID.ToString())) return;
List<ConnectionInfo> listConnectionInfo = _CacheByPrimaryKey[DBID.ToString()]; // Get the list of items
while (listConnectionInfo.Contains(this)) listConnectionInfo.Remove(this); // Remove the item from the list
if (listConnectionInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(DBID.ToString()); // remove the list
}
public virtual Connection Get()
{
return _Editable = Connection.Get(_DBID);
}
public static void Refresh(Connection tmp)
{
string key = tmp.DBID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ConnectionInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Connection tmp)
{
_Name = tmp.Name;
_Title = tmp.Title;
_ConnectionString = tmp.ConnectionString;
_ServerType = tmp.ServerType;
_Config = tmp.Config;
_DTS = tmp.DTS;
_UsrID = tmp.UsrID;
_ConnectionInfoExtension.Refresh(this);
OnChange();// raise an event
}
public static ConnectionInfo Get(int dbid)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Connection");
try
{
ConnectionInfo tmp = GetCachedByPrimaryKey(dbid);
if (tmp == null)
{
tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ConnectionInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ConnectionInfo.Get", ex);
}
}
#endregion
#region Data Access Portal
internal ConnectionInfo(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.Constructor", GetHashCode());
try
{
ReadData(dr);
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.Constructor", ex);
throw new DbCslaException("ConnectionInfo.Constructor", ex);
}
}
[Serializable()]
protected class PKCriteria
{
private int _DBID;
public int DBID
{ get { return _DBID; } }
public PKCriteria(int dbid)
{
_DBID = dbid;
}
}
private void ReadData(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode());
try
{
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_ConnectionString = dr.GetString("ConnectionString");
_ServerType = dr.GetInt32("ServerType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_ConnectionFolderCount = dr.GetInt32("FolderCount");
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.ReadData", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.ReadData", ex);
}
}
private void DataPortal_Fetch(PKCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
ApplicationContext.LocalContext["cn"] = cn;
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getConnection";
cm.Parameters.AddWithValue("@DBID", criteria.DBID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
if (!dr.Read())
{
_ErrorMessage = "No Record Found";
return;
}
ReadData(dr);
}
}
// removing of item only needed for local data portal
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
ApplicationContext.LocalContext.Remove("cn");
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex);
}
}
#endregion
// Standard Refresh
#region extension
ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension();
[Serializable()]
partial class ConnectionInfoExtension : extensionBase { }
[Serializable()]
class extensionBase
{
// Default Refresh
public virtual void Refresh(ConnectionInfo tmp) { }
}
#endregion
} // Class
#region Converter
internal class ConnectionInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ConnectionInfo)
{
// Return the ToString value
return ((ConnectionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace
@@ -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
@@ -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 */);
// }
// }
// }
//}
@@ -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
@@ -0,0 +1,685 @@
// ========================================================================
// 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
private static List<ContentInfo> _CacheList = new List<ContentInfo>();
protected static void AddToCache(ContentInfo contentInfo)
{
if (!_CacheList.Contains(contentInfo)) _CacheList.Add(contentInfo); // In AddToCache
}
protected static void RemoveFromCache(ContentInfo contentInfo)
{
while (_CacheList.Contains(contentInfo)) _CacheList.Remove(contentInfo); // In RemoveFromCache
}
private static Dictionary<string, List<ContentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentInfo>>();
private static void ConvertListToDictionary()
{
List<ContentInfo> remove = new List<ContentInfo>();
foreach (ContentInfo tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
{
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<ContentInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (ContentInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(ContentInfoList lst)
{
foreach (ContentInfo item in lst) AddToCache(item);
}
protected static ContentInfo GetCachedByPrimaryKey(int contentID)
{
ConvertListToDictionary();
string key = contentID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
protected 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 || (_ContentDetailCount > 0 && _ContentDetails == null))
_ContentDetails = DetailInfoList.GetByContentID(_ContentID);
if (_ContentDetailCount < 0)
_ContentDetailCount = _ContentDetails.Count;
return _ContentDetails;
}
}
public void RefreshContentDetails()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
tmp._ContentDetailCount = -1; // This will cause the data to be requeried
}
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);
_ContentEntryCount = _MyEntry == null ? 0 : 1;
}
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 || (_ContentItemCount > 0 && _ContentItems == null))
_ContentItems = ItemInfoList.GetByContentID(_ContentID);
if (_ContentItemCount < 0)
_ContentItemCount = _ContentItems.Count;
return _ContentItems;
}
}
public void RefreshContentItems()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
tmp._ContentItemCount = -1; // This will cause the data to be requeried
}
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 || (_ContentPartCount > 0 && _ContentParts == null))
_ContentParts = PartInfoList.GetByContentID(_ContentID);
if (_ContentPartCount < 0)
_ContentPartCount = _ContentParts.Count;
return _ContentParts;
}
}
public void RefreshContentParts()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
tmp._ContentPartCount = -1; // This will cause the data to be requeried
}
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 || (_ContentRoUsageCount > 0 && _ContentRoUsages == null))
_ContentRoUsages = RoUsageInfoList.GetByContentID(_ContentID);
if (_ContentRoUsageCount < 0)
_ContentRoUsageCount = _ContentRoUsages.Count;
return _ContentRoUsages;
}
}
public void RefreshContentRoUsages()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
tmp._ContentRoUsageCount = -1; // This will cause the data to be requeried
}
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 || (_ContentTransitionCount > 0 && _ContentTransitions == null))
_ContentTransitions = TransitionInfoList.GetByFromID(_ContentID);
if (_ContentTransitionCount < 0)
_ContentTransitionCount = _ContentTransitions.Count;
return _ContentTransitions;
}
}
public void RefreshContentTransitions()
{
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(_ContentID.ToString()))
foreach (ContentInfo tmp in _CacheByPrimaryKey[_ContentID.ToString()])
tmp._ContentTransitionCount = -1; // This will cause the data to be requeried
}
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);
_ContentZContentCount = _MyZContent == null ? 0 : 1;
}
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 static int _ContentInfoUnique = 0;
private static int ContentInfoUnique
{ get { return ++_ContentInfoUnique; } }
private int _MyContentInfoUnique = ContentInfoUnique;
public int MyContentInfoUnique
{ get { return _MyContentInfoUnique; } }
protected ContentInfo()
{/* require use of factory methods */
AddToCache(this);
}
public void Dispose()
{
RemoveFromCache(this);
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
List<ContentInfo> listContentInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
while (listContentInfo.Contains(this)) listContentInfo.Remove(this); // Remove the item from the list
if (listContentInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
}
public virtual Content Get()
{
return _Editable = Content.Get(_ContentID);
}
public static void Refresh(Content tmp)
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ContentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual void RefreshFields(Content tmp)
{
_Number = tmp.Number;
_Text = tmp.Text;
_Type = tmp.Type;
if (_FormatID != tmp.FormatID)
{
if (MyFormat != null) MyFormat.RefreshFormatContents(); // Update List for old value
_FormatID = tmp.FormatID; // Update the value
}
_MyFormat = null; // Reset list so that the next line gets a new list
if (MyFormat != null) MyFormat.RefreshFormatContents(); // Update List for new value
_Config = tmp.Config;
_DTS = tmp.DTS;
_UserID = tmp.UserID;
_ContentInfoExtension.Refresh(this);
if(_MyFormat != null)
{
_MyFormat.Dispose();// Dispose related value
_MyFormat = null;// Reset related value
}
if(_MyEntry != null)
{
_MyEntry.Dispose();// Dispose related value
_MyEntry = null;// Reset related value
}
_ContentEntryCount = -1;// Reset Count
if(_MyZContent != null)
{
_MyZContent.Dispose();// Dispose related value
_MyZContent = null;// Reset related value
}
_ContentZContentCount = -1;// Reset Count
OnChange();// raise an event
}
public static void Refresh(FormatContent tmp)
{
string key = tmp.ContentID.ToString();
ConvertListToDictionary();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ContentInfo tmpInfo in _CacheByPrimaryKey[key])
tmpInfo.RefreshFields(tmp);
}
protected virtual 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);
if(_MyFormat != null)
{
_MyFormat.Dispose();// Dispose related value
_MyFormat = null;// Reset related value
}
if(_MyEntry != null)
{
_MyEntry.Dispose();// Dispose related value
_MyEntry = null;// Reset related value
}
_ContentEntryCount = -1;// Reset Count
if(_MyZContent != null)
{
_MyZContent.Dispose();// Dispose related value
_MyZContent = null;// Reset related value
}
_ContentZContentCount = -1;// Reset Count
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 = GetCachedByPrimaryKey(contentID);
if (tmp == null)
{
tmp = DataPortal.Fetch<ContentInfo>(new PKCriteria(contentID));
AddToCache(tmp);
}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up ContentInfo
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
@@ -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
@@ -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 == null ? _PreviousID : (int?)_MyPrevious.ItemID) != (value == null ? null : (int?)value.ItemID))
{
_MyPrevious = value;
_PreviousID = (value == null ? null : (int?)value.ItemID);
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check ContentItem.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ContentItem</returns>
protected override object GetIdValue()
{
return _ItemID;
}
// TODO: Replace base ContentItem.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentItem</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
//AuthorizationRules.AllowRead(PreviousID, "<Role(s)>");
//AuthorizationRules.AllowWrite(PreviousID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentItem New()
{
return new ContentItem();
}
internal static ContentItem Get(SafeDataReader dr)
{
return new ContentItem(dr);
}
public ContentItem()
{
MarkAsChild();
_ItemID = Item.NextItemID;
_DTS = _ContentItemExtension.DefaultDTS;
_UserID = _ContentItemExtension.DefaultUserID;
ValidationRules.CheckRules();
}
internal ContentItem(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode());
try
{
_ItemID = dr.GetInt32("ItemID");
_PreviousID = (int?)dr.GetValue("PreviousID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentItem.FetchDR", ex);
throw new DbCslaException("ContentItem.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Item.Add(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Item.Update(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Item.Remove(cn, _ItemID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentItemExtension _ContentItemExtension = new ContentItemExtension();
[Serializable()]
partial class ContentItemExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ContentItemConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentItem)
{
// Return the ToString value
return ((ContentItem)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // 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 */);
// }
// }
// }
//}
@@ -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
@@ -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 */);
// }
// }
// }
//}
@@ -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
@@ -0,0 +1,573 @@
// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
/// <summary>
/// ContentRoUsage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
[TypeConverter(typeof(ContentRoUsageConverter))]
public partial class ContentRoUsage : BusinessBase<ContentRoUsage>, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _ROUsageID;
[System.ComponentModel.DataObjectField(true, true)]
public int ROUsageID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROUsageID", true);
if (_MyRoUsage != null) _ROUsageID = _MyRoUsage.ROUsageID;
return _ROUsageID;
}
}
private RoUsage _MyRoUsage;
[System.ComponentModel.DataObjectField(true, true)]
public RoUsage MyRoUsage
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRoUsage", true);
if (_MyRoUsage == null && _ROUsageID != 0) _MyRoUsage = RoUsage.Get(_ROUsageID);
return _MyRoUsage;
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ROID", true);
return _ROID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("ROID", true);
if (value == null) value = string.Empty;
if (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("Config", true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("Config", true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UserID", true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _RODbID;
public int RODbID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODbID", true);
if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
return _RODbID;
}
}
private RODb _MyRODb;
public RODb MyRODb
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRODb", true);
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODb.Get(_RODbID);
return _MyRODb;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyRODb", true);
if (_MyRODb != value)
{
_MyRODb = value;
PropertyHasChanged();
}
}
}
private string _RODb_ROName = string.Empty;
/// <summary>
/// Hook for future - to allow the user to select multiple RO Databases assocaiated with on DocVersion
/// </summary>
public string RODb_ROName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_ROName", true);
return _RODb_ROName;
}
}
private string _RODb_FolderPath = string.Empty;
/// <summary>
/// Path to the RO database
/// </summary>
public string RODb_FolderPath
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_FolderPath", true);
return _RODb_FolderPath;
}
}
private string _RODb_DBConnectionString = string.Empty;
/// <summary>
/// Connection String - Default could just be the full path and name of the database
/// </summary>
public string RODb_DBConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_DBConnectionString", true);
return _RODb_DBConnectionString;
}
}
private DateTime _RODb_DTS = new DateTime();
public DateTime RODb_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_DTS", true);
return _RODb_DTS;
}
}
private string _RODb_UserID = string.Empty;
public string RODb_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RODb_UserID", true);
return _RODb_UserID;
}
}
// TODO: Check ContentRoUsage.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ContentRoUsage</returns>
protected override object GetIdValue()
{
return _ROUsageID;
}
// TODO: Replace base ContentRoUsage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ContentRoUsage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
public override bool IsDirty
{
get { return base.IsDirty || (_MyRODb == null ? false : _MyRODb.IsDirty); }
}
public override bool IsValid
{
get { return (IsNew && !IsDirty ? true : base.IsValid) && (_MyRODb == null ? true : _MyRODb.IsValid); }
}
#endregion
#region ValidationRules
[NonSerialized]
private bool _CheckingBrokenRules = false;
public IVEHasBrokenRules HasBrokenRules
{
get
{
if (_CheckingBrokenRules) return null;
if (BrokenRulesCollection.Count > 0) return this;
try
{
_CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = null;
if (_MyRODb != null && (hasBrokenRules = _MyRODb.HasBrokenRules) != null) return hasBrokenRules;
return hasBrokenRules;
}
finally
{
_CheckingBrokenRules = false;
}
}
}
public BrokenRulesCollection BrokenRules
{
get
{
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
}
}
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "ROID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ROID", 16));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ValidationRules.AddRule<ContentRoUsage>(MyRODbRequired, "MyRODb");
// TODO: Add other validation rules
}
private static bool MyRODbRequired(ContentRoUsage target, Csla.Validation.RuleArgs e)
{
if (target._RODbID == 0 && target._MyRODb == null) // Required field missing
{
e.Description = "Required";
return false;
}
return true;
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROUsageID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(RODbID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RODbID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static ContentRoUsage New(string roid, RODb myRODb)
{
return new ContentRoUsage(roid, myRODb);
}
internal static ContentRoUsage Get(SafeDataReader dr)
{
return new ContentRoUsage(dr);
}
public ContentRoUsage()
{
MarkAsChild();
_ROUsageID = RoUsage.NextROUsageID;
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
ValidationRules.CheckRules();
}
private ContentRoUsage(string roid, RODb myRODb)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = _ContentRoUsageExtension.DefaultDTS;
_UserID = _ContentRoUsageExtension.DefaultUserID;
_ROID = roid;
_MyRODb = myRODb;
ValidationRules.CheckRules();
}
internal ContentRoUsage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentRoUsage.FetchDR", GetHashCode());
try
{
_ROUsageID = dr.GetInt32("ROUsageID");
_ROID = dr.GetString("ROID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_RODbID = dr.GetInt32("RODbID");
_RODb_ROName = dr.GetString("RODb_ROName");
_RODb_FolderPath = dr.GetString("RODb_FolderPath");
_RODb_DBConnectionString = dr.GetString("RODb_DBConnectionString");
_RODb_DTS = dr.GetDateTime("RODb_DTS");
_RODb_UserID = dr.GetString("RODb_UserID");
}
catch (Exception ex) // FKItem Fetch
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentRoUsage.FetchDR", ex);
throw new DbCslaException("ContentRoUsage.Fetch", ex);
}
MarkOld();
}
internal void Insert(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Add(cn, ref _ROUsageID, myContent, _ROID, _Config, _DTS, _UserID, _MyRODb);
MarkOld();
}
internal void Update(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = RoUsage.Update(cn, ref _ROUsageID, myContent, _ROID, _Config, _DTS, _UserID, ref _LastChanged, _MyRODb);
MarkOld();
}
internal void DeleteSelf(Content myContent)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
// if we're new then don't update the database
if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
RoUsage.Remove(cn, _ROUsageID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
ContentRoUsageExtension _ContentRoUsageExtension = new ContentRoUsageExtension();
[Serializable()]
partial class ContentRoUsageExtension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultContentID
{
get { return 0; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
// InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
#region Converter
internal class ContentRoUsageConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentRoUsage)
{
// Return the ToString value
return ((ContentRoUsage)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // 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 */);
// }
// }
// }
//}
@@ -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, RODb myRODb) // One to Many
{
ContentRoUsage roUsage = ContentRoUsage.New(roid, myRODb);
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

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