CSLA - Generated - C Items
This commit is contained in:
@@ -9,12 +9,9 @@
|
||||
// ========================================================================
|
||||
|
||||
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;
|
||||
@@ -31,11 +28,8 @@ namespace VEPROMS.CSLA.Library
|
||||
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 readonly string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage => _ErrorMessage;
|
||||
private int _FolderID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int FolderID
|
||||
@@ -255,19 +249,8 @@ namespace VEPROMS.CSLA.Library
|
||||
/// 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 MyConnectionFolderUnique; // Absolutely Unique ID
|
||||
}
|
||||
// CSLATODO: 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();
|
||||
//}
|
||||
protected override object GetIdValue() => MyConnectionFolderUnique; // Absolutely Unique ID
|
||||
|
||||
public override bool IsDirty
|
||||
{
|
||||
get
|
||||
@@ -282,18 +265,15 @@ namespace VEPROMS.CSLA.Library
|
||||
if (base.IsDirty || list.Contains(this))
|
||||
return base.IsDirty;
|
||||
list.Add(this);
|
||||
return base.IsDirty || (_MyFolder == null ? false : _MyFolder.IsDirtyList(list));
|
||||
}
|
||||
public override bool IsValid
|
||||
{
|
||||
get { return IsValidList(new List<object>()); }
|
||||
return base.IsDirty || (_MyFolder != null && _MyFolder.IsDirtyList(list));
|
||||
}
|
||||
|
||||
public bool IsValidList(List<object> list)
|
||||
{
|
||||
if (list.Contains(this))
|
||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
||||
return (IsNew && !IsDirty) || base.IsValid;
|
||||
list.Add(this);
|
||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyFolder == null ? true : _MyFolder.IsValidList(list));
|
||||
return ((IsNew && !IsDirty) || base.IsValid) && (_MyFolder == null || _MyFolder.IsValidList(list));
|
||||
}
|
||||
#endregion
|
||||
#region ValidationRules
|
||||
@@ -324,8 +304,8 @@ namespace VEPROMS.CSLA.Library
|
||||
get
|
||||
{
|
||||
IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
|
||||
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
|
||||
if (Equals(hasBrokenRules)) return BrokenRulesCollection;
|
||||
return hasBrokenRules?.BrokenRules;
|
||||
}
|
||||
}
|
||||
protected override void AddBusinessRules()
|
||||
@@ -363,86 +343,16 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
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(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()
|
||||
{
|
||||
// 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; } }
|
||||
public int CurrentEditLevel => EditLevel;
|
||||
private static int _ConnectionFolderUnique = 0;
|
||||
private static int ConnectionFolderUnique
|
||||
{ get { return ++_ConnectionFolderUnique; } }
|
||||
private int _MyConnectionFolderUnique = ConnectionFolderUnique;
|
||||
public int MyConnectionFolderUnique // Absolutely Unique ID - Editable FK
|
||||
{ get { return _MyConnectionFolderUnique; } }
|
||||
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);
|
||||
}
|
||||
private static int ConnectionFolderUnique => ++_ConnectionFolderUnique;
|
||||
private readonly int _MyConnectionFolderUnique = ConnectionFolderUnique;
|
||||
// Absolutely Unique ID - Editable FK
|
||||
public int MyConnectionFolderUnique => _MyConnectionFolderUnique;
|
||||
internal static ConnectionFolder New(Folder myParent, string name, string shortName) => new ConnectionFolder(myParent, name, shortName);
|
||||
internal static ConnectionFolder Get(SafeDataReader dr) => new ConnectionFolder(dr);
|
||||
public ConnectionFolder()
|
||||
{
|
||||
MarkAsChild();
|
||||
@@ -474,15 +384,11 @@ namespace VEPROMS.CSLA.Library
|
||||
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; } }
|
||||
private static int IncrementCountCreated => ++_CountCreated;
|
||||
private readonly int _CountWhenCreated = IncrementCountCreated;
|
||||
public static int CountCreated => _CountCreated;
|
||||
public static int CountNotDisposed => _CountCreated - _CountDisposed;
|
||||
public static int CountNotFinalized => _CountCreated - _CountFinalized;
|
||||
~ConnectionFolder()
|
||||
{
|
||||
_CountFinalized++;
|
||||
@@ -522,33 +428,43 @@ namespace VEPROMS.CSLA.Library
|
||||
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);
|
||||
if (!IsDirty) return;
|
||||
using (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, _ParentID, myConnection.DBID, _Name, _Title, _ShortName, _FormatID, _ManualOrder, _Config, _DTS, _UsrID, ref _LastChanged);
|
||||
if (!IsDirty) return;
|
||||
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||
{
|
||||
_LastChanged = Folder.Update(cn, ref _FolderID, _ParentID, myConnection.DBID, _Name, _Title, _ShortName, _FormatID, _ManualOrder, _Config, _DTS, _UsrID, ref _LastChanged);
|
||||
}
|
||||
|
||||
MarkOld();
|
||||
}
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping myConnection for CSLA compliance")]
|
||||
internal void DeleteSelf(Connection myConnection)
|
||||
{
|
||||
// if we're not dirty then don't update the database
|
||||
if (!this.IsDirty) return;
|
||||
if (!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);
|
||||
if (IsNew) return;
|
||||
using (SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"])
|
||||
{
|
||||
Folder.Remove(cn, _FolderID);
|
||||
}
|
||||
|
||||
MarkNew();
|
||||
}
|
||||
#endregion
|
||||
// Standard Default Code
|
||||
#region extension
|
||||
ConnectionFolderExtension _ConnectionFolderExtension = new ConnectionFolderExtension();
|
||||
readonly ConnectionFolderExtension _ConnectionFolderExtension = new ConnectionFolderExtension();
|
||||
[Serializable()]
|
||||
partial class ConnectionFolderExtension : extensionBase
|
||||
{
|
||||
@@ -557,22 +473,10 @@ namespace VEPROMS.CSLA.Library
|
||||
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 Volian.Base.Library.VlnSettings.UserID; }
|
||||
}
|
||||
public virtual int DefaultParentID => 1;
|
||||
public virtual int DefaultDBID => 1;
|
||||
public virtual DateTime DefaultDTS => DateTime.Now;
|
||||
public virtual string DefaultUsrID => Volian.Base.Library.VlnSettings.UserID;
|
||||
// Authorization Rules
|
||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||
{
|
||||
@@ -601,65 +505,13 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
|
||||
{
|
||||
if (destType == typeof(string) && value is ConnectionFolder)
|
||||
if (destType == typeof(string) && value is ConnectionFolder folder)
|
||||
{
|
||||
// Return the ToString value
|
||||
return ((ConnectionFolder)value).ToString();
|
||||
return folder.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
|
||||
// {
|
||||
// // CSLATODO: 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 */);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user