This commit is contained in:
2006-11-14 14:33:33 +00:00
commit a0cad33b0f
180 changed files with 40199 additions and 0 deletions

View File

@@ -0,0 +1,797 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Assignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Assignment : BusinessBase<Assignment>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextAID = -1;
public static int NextAID
{
get { return _nextAID--; }
}
private int _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _AID;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_GID != value)
{
_GID = value;
PropertyHasChanged();
}
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_RID != value)
{
_RID = value;
PropertyHasChanged();
}
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FolderID != value)
{
_FolderID = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base Assignment.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Assignment</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Assignment.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 Assignment</returns>
protected override object GetIdValue()
{
return _AID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AID, "<Role(s)>");
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Assignment()
{/* require use of factory methods */}
public static Assignment New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Assignment");
return DataPortal.Create<Assignment>();
}
public static Assignment New(int gid, int rid, int folderID, string startDate, string endDate)
{
Assignment tmp = Assignment.New();
tmp.GID = gid;
tmp.RID = rid;
tmp.FolderID = folderID;
tmp.StartDate = startDate;
tmp.EndDate = endDate;
return tmp;
}
public static Assignment MakeAssignment(int gid, int rid, int folderID, string startDate, string endDate)
{
Assignment tmp = Assignment.New(gid, rid, folderID, startDate, endDate);
tmp.Save();
return tmp;
}
public static Assignment MakeAssignment(int gid, int rid, int folderID, string startDate, string endDate, DateTime dts, string usrID)
{
Assignment tmp = Assignment.New(gid, rid, folderID, startDate, endDate);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID;
tmp.Save();
return tmp;
}
public static Assignment Get(int aid)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Assignment");
return DataPortal.Fetch<Assignment>(new PKCriteria(aid));
}
public static Assignment Get(SafeDataReader dr)
{
if (dr.Read()) return new Assignment(dr);
return null;
}
private Assignment(SafeDataReader dr)
{
_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");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int aid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Assignment");
DataPortal.Delete(new PKCriteria(aid));
}
public override Assignment Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Assignment");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Assignment");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Assignment");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _AID;
public int AID
{ get { return _AID; } }
public PKCriteria(int aid)
{
_AID = aid;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_AID = NextAID;
// Database Defaults
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
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()))
{
dr.Read();
_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");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Assignment.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Assignment.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addAssignment";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@GID", _GID);
cm.Parameters.AddWithValue("@RID", _RID);
cm.Parameters.AddWithValue("@FolderID", _FolderID);
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
// Output Calculated Columns
SqlParameter param_AID = new SqlParameter("@newAID", SqlDbType.Int);
param_AID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_AID = (int)cm.Parameters["@newAID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("Assignment.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Assignment.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int aid, int gid, int rid, int folderID, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addAssignment";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@GID", gid);
cm.Parameters.AddWithValue("@RID", rid);
cm.Parameters.AddWithValue("@FolderID", folderID);
cm.Parameters.AddWithValue("@StartDate", startDate.DBValue);
cm.Parameters.AddWithValue("@EndDate", endDate.DBValue);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
// Output Calculated Columns
SqlParameter param_AID = new SqlParameter("@newAID", SqlDbType.Int);
param_AID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_AID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
aid = (int)cm.Parameters["@newAID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Assignment.Add", ex);
throw new DbCslaException("Assignment.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateAssignment";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@AID", _AID);
cm.Parameters.AddWithValue("@GID", _GID);
cm.Parameters.AddWithValue("@RID", _RID);
cm.Parameters.AddWithValue("@FolderID", _FolderID);
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("Assignment.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int aid, int gid, int rid, int folderID, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateAssignment";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@AID", aid);
cm.Parameters.AddWithValue("@GID", gid);
cm.Parameters.AddWithValue("@RID", rid);
cm.Parameters.AddWithValue("@FolderID", folderID);
cm.Parameters.AddWithValue("@StartDate", startDate.DBValue);
cm.Parameters.AddWithValue("@EndDate", endDate.DBValue);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Assignment.Update", ex);
throw new DbCslaException("Assignment.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_AID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteAssignment";
cm.Parameters.AddWithValue("@AID", criteria.AID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Assignment.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Assignment.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int aid)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteAssignment";
// Input PK Fields
cm.Parameters.AddWithValue("@AID", aid);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Assignment.Remove", ex);
throw new DbCslaException("Assignment.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int aid)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(aid));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _AID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int aid)
{
_AID = aid;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsAssignment";
cm.Parameters.AddWithValue("@AID", _AID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Assignment.DataPortal_Execute", ex);
throw new DbCslaException("Assignment.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create AssignmentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Assignment
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,158 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// AssignmentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class AssignmentInfo : ReadOnlyBase<AssignmentInfo>
{
#region Business Methods
private int _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _AID;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RID;
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderID;
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UsrID;
}
}
// TODO: Replace base AssignmentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current AssignmentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check AssignmentInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current AssignmentInfo</returns>
protected override object GetIdValue()
{
return _AID;
}
#endregion
#region Factory Methods
private AssignmentInfo()
{ /* require use of factory methods */ }
public Assignment Get()
{
return Assignment.Get(_AID);
}
#endregion
#region Data Access Portal
internal AssignmentInfo(SafeDataReader dr)
{
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)
{
Database.LogException("AssignmentInfo.Constructor", ex);
throw new DbCslaException("AssignmentInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,214 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// AssignmentInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class AssignmentInfoList : ReadOnlyListBase<AssignmentInfoList, AssignmentInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static AssignmentInfoList Get()
{
return DataPortal.Fetch<AssignmentInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static AssignmentInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<AssignmentInfoList>(new FilteredCriteria(<criteria>));
//}
public static AssignmentInfoList GetByFolder(int folderID)
{
return DataPortal.Fetch<AssignmentInfoList>(new FolderCriteria(folderID));
}
public static AssignmentInfoList GetByGroup(int gid)
{
return DataPortal.Fetch<AssignmentInfoList>(new GroupCriteria(gid));
}
public static AssignmentInfoList GetByRole(int rid)
{
return DataPortal.Fetch<AssignmentInfoList>(new RoleCriteria(rid));
}
private AssignmentInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
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)
{
Database.LogException("AssignmentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class FolderCriteria
{
public FolderCriteria(int folderID)
{
_FolderID = folderID;
}
private int _FolderID;
public int FolderID
{
get { return _FolderID; }
set { _FolderID = value; }
}
}
private void DataPortal_Fetch(FolderCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAssignmentsByFolder";
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)
{
Database.LogException("AssignmentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class GroupCriteria
{
public GroupCriteria(int gid)
{
_GID = gid;
}
private int _GID;
public int GID
{
get { return _GID; }
set { _GID = value; }
}
}
private void DataPortal_Fetch(GroupCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAssignmentsByGroup";
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)
{
Database.LogException("AssignmentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RoleCriteria
{
public RoleCriteria(int rid)
{
_RID = rid;
}
private int _RID;
public int RID
{
get { return _RID; }
set { _RID = value; }
}
}
private void DataPortal_Fetch(RoleCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAssignmentsByRole";
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)
{
Database.LogException("AssignmentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,792 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Connection Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Connection : BusinessBase<Connection>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextDBID = -1;
public static int NextDBID
{
get { return _nextDBID--; }
}
private int _DBID;
[System.ComponentModel.DataObjectField(true, true)]
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DBID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private string _ConnectionString = string.Empty;
public string ConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ConnectionString;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_ConnectionString != value)
{
_ConnectionString = value;
PropertyHasChanged();
}
}
}
private int _ServerType;
/// <summary>
/// 0 SQL Server
/// </summary>
public int ServerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ServerType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ServerType != value)
{
_ServerType = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private ConnectionFolders _ConnectionFolders = ConnectionFolders.New();
/// <summary>
/// Related Field
/// </summary>
public ConnectionFolders ConnectionFolders
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ConnectionFolders;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _ConnectionFolders.IsDirty; }
}
public override bool IsValid
{
get { return base.IsValid && _ConnectionFolders.IsValid; }
}
// TODO: Replace base Connection.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Connection</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Connection.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 Connection</returns>
protected override object GetIdValue()
{
return _DBID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("ConnectionString", 510));
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));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(DBID, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ConnectionString, "<Role(s)>");
//AuthorizationRules.AllowRead(ServerType, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(ConnectionString, "<Role(s)>");
//AuthorizationRules.AllowWrite(ServerType, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Connection()
{/* require use of factory methods */}
public static Connection New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Connection");
return DataPortal.Create<Connection>();
}
public static Connection New(string name, string title, string connectionString, int serverType, string config)
{
Connection tmp = Connection.New();
tmp.Name = name;
tmp.Title = title;
tmp.ConnectionString = connectionString;
tmp.ServerType = serverType;
tmp.Config = config;
return tmp;
}
public static Connection MakeConnection(string name, string title, string connectionString, int serverType, string config)
{
Connection tmp = Connection.New(name, title, connectionString, serverType, config);
tmp.Save();
return tmp;
}
public static Connection MakeConnection(string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID)
{
Connection tmp = Connection.New(name, title, connectionString, serverType, config);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID;
tmp.Save();
return tmp;
}
public static Connection Get(int dbid)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Connection");
return DataPortal.Fetch<Connection>(new PKCriteria(dbid));
}
public static Connection Get(SafeDataReader dr)
{
if (dr.Read()) return new Connection(dr);
return null;
}
private Connection(SafeDataReader dr)
{
_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");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int dbid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Connection");
DataPortal.Delete(new PKCriteria(dbid));
}
public override Connection Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Connection");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Connection");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Connection");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _DBID;
public int DBID
{ get { return _DBID; } }
public PKCriteria(int dbid)
{
_DBID = dbid;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_DBID = NextDBID;
// Database Defaults
_ServerType = ext.DefaultServerType;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
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()))
{
dr.Read();
_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");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
// load child objects
dr.NextResult();
_ConnectionFolders = ConnectionFolders.Get(dr);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Connection.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Connection.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addConnection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@Name", _Name);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@ConnectionString", _ConnectionString);
cm.Parameters.AddWithValue("@ServerType", _ServerType);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
// Output Calculated Columns
SqlParameter param_DBID = new SqlParameter("@newDBID", SqlDbType.Int);
param_DBID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_DBID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_DBID = (int)cm.Parameters["@newDBID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
_ConnectionFolders.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Connection.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Connection.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int dbid, string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addConnection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@ConnectionString", connectionString);
cm.Parameters.AddWithValue("@ServerType", serverType);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
// Output Calculated Columns
SqlParameter param_DBID = new SqlParameter("@newDBID", SqlDbType.Int);
param_DBID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_DBID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
dbid = (int)cm.Parameters["@newDBID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Connection.Add", ex);
throw new DbCslaException("Connection.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateConnection";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@DBID", _DBID);
cm.Parameters.AddWithValue("@Name", _Name);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@ConnectionString", _ConnectionString);
cm.Parameters.AddWithValue("@ServerType", _ServerType);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
_ConnectionFolders.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Connection.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int dbid, string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateConnection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@DBID", dbid);
cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@ConnectionString", connectionString);
cm.Parameters.AddWithValue("@ServerType", serverType);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Connection.Update", ex);
throw new DbCslaException("Connection.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_DBID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteConnection";
cm.Parameters.AddWithValue("@DBID", criteria.DBID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Connection.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Connection.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int dbid)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteConnection";
// Input PK Fields
cm.Parameters.AddWithValue("@DBID", dbid);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Connection.Remove", ex);
throw new DbCslaException("Connection.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int dbid)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(dbid));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _DBID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int dbid)
{
_DBID = dbid;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsConnection";
cm.Parameters.AddWithValue("@DBID", _DBID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Connection.DataPortal_Execute", ex);
throw new DbCslaException("Connection.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultServerType
{
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create ConnectionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Connection
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultServerType
// {
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,432 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ConnectionFolder Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ConnectionFolder : BusinessBase<ConnectionFolder>
{
#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(true);
return _FolderID;
}
}
private int _ParentID;
/// <summary>
/// {child Folders.FolderID}
/// </summary>
public int ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ParentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ParentID != value)
{
_ParentID = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 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(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(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(string name)
{
return new ConnectionFolder(name);
}
internal static ConnectionFolder Get(SafeDataReader dr)
{
return new ConnectionFolder(dr);
}
public ConnectionFolder()
{
MarkAsChild();
_FolderID = Folder.NextFolderID;
_ParentID = ext.DefaultParentID;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
}
private ConnectionFolder(string name)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_ParentID = ext.DefaultParentID;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
_Name = name;
}
private ConnectionFolder(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_FolderID = dr.GetInt32("FolderID");
_ParentID = dr.GetInt32("ParentID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("ConnectionFolder.Fetch", ex);
throw new DbCslaException("ConnectionFolder.Fetch", ex);
}
MarkOld();
}
internal void Insert(Connection connection, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Folder.Add(cn, ref _FolderID, _ParentID, connection.DBID, _Name, _Title, _Config, _DTS, _UsrID);
MarkOld();
}
internal void Update(Connection connection, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Folder.Update(cn, ref _FolderID, _ParentID, connection.DBID, _Name, _Title, _Config, _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Connection connection, SqlConnection cn)
{
// 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;
Folder.Remove(cn, _FolderID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultParentID
{
get { return 0; }
}
public virtual int DefaultDBID
{
get { return 0; }
}
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // 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 Volian.CSLA.Library
//{
// public partial class ConnectionFolder
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultParentID
// {
// get { return 0; }
// }
// public virtual int DefaultDBID
// {
// get { return 0; }
// }
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,137 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ConnectionFolders Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ConnectionFolders : BusinessListBase<ConnectionFolders, ConnectionFolder>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// One To Many
public new ConnectionFolder this[int folderID]
{
get
{
foreach (ConnectionFolder folder in this)
if (folder.FolderID == folderID)
return folder;
return null;
}
}
public ConnectionFolder GetItem(int folderID)
{
foreach (ConnectionFolder folder in this)
if (folder.FolderID == folderID)
return folder;
return null;
}
public ConnectionFolder Add(string name)
{
ConnectionFolder folder = ConnectionFolder.New(name);
this.Add(folder);
return folder;
}
public void Remove(int folderID)
{
foreach (ConnectionFolder folder in this)
{
if (folder.FolderID == folderID)
{
Remove(folder);
break;
}
}
}
public bool Contains(int folderID)
{
foreach (ConnectionFolder folder in this)
if (folder.FolderID == folderID)
return true;
return false;
}
public bool ContainsDeleted(int folderID)
{
foreach (ConnectionFolder folder in DeletedList)
if (folder.FolderID == folderID)
return true;
return false;
}
#endregion
#region Factory Methods
internal static ConnectionFolders New()
{
return new ConnectionFolders();
}
internal static ConnectionFolders Get(SafeDataReader dr)
{
return new ConnectionFolders(dr);
}
private ConnectionFolders()
{
MarkAsChild();
}
private 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;
}
internal void Update(Connection connection, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (ConnectionFolder obj in DeletedList)
obj.DeleteSelf(connection, cn);
// 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, cn);
else
obj.Update(connection, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,187 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ConnectionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ConnectionInfo : ReadOnlyBase<ConnectionInfo>
{
#region Business Methods
private int _DBID;
[System.ComponentModel.DataObjectField(true, true)]
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DBID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Title;
}
}
private string _ConnectionString = string.Empty;
public string ConnectionString
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(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(true);
return _ServerType;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UsrID;
}
}
private int _Foldercount = 0;
/// <summary>
/// Count of Folder for this Connection
/// </summary>
public int FolderCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Foldercount;
}
}
private FolderInfoList _Folders = null;
public FolderInfoList Folders
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Folders == null)
_Folders = FolderInfoList.GetByConnection(_DBID);
return _Folders;
}
}
// TODO: Replace base ConnectionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ConnectionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ConnectionInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current ConnectionInfo</returns>
protected override object GetIdValue()
{
return _DBID;
}
#endregion
#region Factory Methods
private ConnectionInfo()
{ /* require use of factory methods */ }
public Connection Get()
{
return Connection.Get(_DBID);
}
#endregion
#region Data Access Portal
internal ConnectionInfo(SafeDataReader dr)
{
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");
_Foldercount = dr.GetInt32("FolderCount");
}
catch (Exception ex)
{
Database.LogException("ConnectionInfo.Constructor", ex);
throw new DbCslaException("ConnectionInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ConnectionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ConnectionInfoList : ReadOnlyListBase<ConnectionInfoList, ConnectionInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static ConnectionInfoList Get()
{
return DataPortal.Fetch<ConnectionInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static ConnectionInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<ConnectionInfoList>(new FilteredCriteria(<criteria>));
//}
private ConnectionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
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)
{
Database.LogException("ConnectionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ConnectionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,124 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.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 log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static log4net.ILog Log
{
get { return log; }
}
#endregion
public static string VEPROMS_Connection
{
get
{
DateTime.Today.ToLongDateString();
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings["VEPROMS"];
if (cs == null)
{
throw new ApplicationException("Database.cs Could not find connection VEPROMS");
}
return cs.ConnectionString;
}
}
public static SqlConnection VEPROMS_SqlConnection
{
get
{
string strConn = VEPROMS_Connection; // If failure - Fail (Don't try to catch)
// Attempt to make a connection
try
{
SqlConnection cn = new SqlConnection(strConn);
cn.Open();
return cn;
}
catch (SqlException exsql)
{
const string strAttachError = "An attempt to attach an auto-named database for file ";
if (exsql.Message.StartsWith(strAttachError))
{// Check to see if the file is missing
string sFile = exsql.Message.Substring(strAttachError.Length);
sFile = sFile.Substring(0, sFile.IndexOf(" failed"));
// "An attempt to attach an auto-named database for file <mdf file> failed"
if (strConn.ToLower().IndexOf("user instance=true") < 0)
{
throw new ApplicationException("Connection String missing attribute: User Instance=True");
}
if (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 (log.IsErrorEnabled) log.Error("Connection Error", ex);
throw new ApplicationException("Failure on Connect", ex);
}
}
}
public static void LogException(string s,Exception ex)
{
log.Error(s,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);
}
}
public static void PurgeData()
{
try
{
SqlConnection cn = VEPROMS_SqlConnection;
SqlCommand cmd = new SqlCommand("purgedata", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
if (log.IsErrorEnabled) log.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

View File

@@ -0,0 +1,793 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// DocVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class DocVersion : BusinessBase<DocVersion>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextVersionID = -1;
public static int NextVersionID
{
get { return _nextVersionID--; }
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionID;
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FolderID != value)
{
_FolderID = value;
PropertyHasChanged();
}
}
}
private int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private int _StructureID;
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_StructureID != value)
{
_StructureID = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base DocVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocVersion</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocVersion.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 DocVersion</returns>
protected override object GetIdValue()
{
return _VersionID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(StructureID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(StructureID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private DocVersion()
{/* require use of factory methods */}
public static DocVersion New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a DocVersion");
return DataPortal.Create<DocVersion>();
}
public static DocVersion New(int folderID, int versionType, string name, string title, int structureID, string config)
{
DocVersion tmp = DocVersion.New();
tmp.FolderID = folderID;
tmp.VersionType = versionType;
tmp.Name = name;
tmp.Title = title;
tmp.StructureID = structureID;
tmp.Config = config;
return tmp;
}
public static DocVersion MakeDocVersion(int folderID, int versionType, string name, string title, int structureID, string config)
{
DocVersion tmp = DocVersion.New(folderID, versionType, name, title, structureID, config);
tmp.Save();
return tmp;
}
public static DocVersion MakeDocVersion(int folderID, int versionType, string name, string title, int structureID, string config, DateTime dts, string userID)
{
DocVersion tmp = DocVersion.New(folderID, versionType, name, title, structureID, config);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static DocVersion Get(int versionID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a DocVersion");
return DataPortal.Fetch<DocVersion>(new PKCriteria(versionID));
}
public static DocVersion Get(SafeDataReader dr)
{
if (dr.Read()) return new DocVersion(dr);
return null;
}
private DocVersion(SafeDataReader dr)
{
_VersionID = dr.GetInt32("VersionID");
_FolderID = dr.GetInt32("FolderID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_StructureID = dr.GetInt32("StructureID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int versionID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a DocVersion");
DataPortal.Delete(new PKCriteria(versionID));
}
public override DocVersion Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a DocVersion");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a DocVersion");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a DocVersion");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _VersionID;
public int VersionID
{ get { return _VersionID; } }
public PKCriteria(int versionID)
{
_VersionID = versionID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_VersionID = NextVersionID;
// Database Defaults
_VersionType = ext.DefaultVersionType;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocVersion";
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_VersionID = dr.GetInt32("VersionID");
_FolderID = dr.GetInt32("FolderID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_StructureID = dr.GetInt32("StructureID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("DocVersion.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("DocVersion.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addDocVersion";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FolderID", _FolderID);
cm.Parameters.AddWithValue("@VersionType", _VersionType);
cm.Parameters.AddWithValue("@Name", _Name);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@StructureID", _StructureID);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_VersionID = new SqlParameter("@newVersionID", SqlDbType.Int);
param_VersionID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_VersionID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_VersionID = (int)cm.Parameters["@newVersionID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("DocVersion.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("DocVersion.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int versionID, int folderID, int versionType, string name, string title, int structureID, string config, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addDocVersion";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FolderID", folderID);
cm.Parameters.AddWithValue("@VersionType", versionType);
cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@StructureID", structureID);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_VersionID = new SqlParameter("@newVersionID", SqlDbType.Int);
param_VersionID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_VersionID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
versionID = (int)cm.Parameters["@newVersionID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("DocVersion.Add", ex);
throw new DbCslaException("DocVersion.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateDocVersion";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@VersionID", _VersionID);
cm.Parameters.AddWithValue("@FolderID", _FolderID);
cm.Parameters.AddWithValue("@VersionType", _VersionType);
cm.Parameters.AddWithValue("@Name", _Name);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@StructureID", _StructureID);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("DocVersion.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int versionID, int folderID, int versionType, string name, string title, int structureID, string config, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateDocVersion";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@VersionID", versionID);
cm.Parameters.AddWithValue("@FolderID", folderID);
cm.Parameters.AddWithValue("@VersionType", versionType);
cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@StructureID", structureID);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("DocVersion.Update", ex);
throw new DbCslaException("DocVersion.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_VersionID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteDocVersion";
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("DocVersion.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("DocVersion.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int versionID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteDocVersion";
// Input PK Fields
cm.Parameters.AddWithValue("@VersionID", versionID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("DocVersion.Remove", ex);
throw new DbCslaException("DocVersion.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int versionID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(versionID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _VersionID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int versionID)
{
_VersionID = versionID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsDocVersion";
cm.Parameters.AddWithValue("@VersionID", _VersionID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("DocVersion.DataPortal_Execute", ex);
throw new DbCslaException("DocVersion.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultVersionType
{
get { return 0; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create DocVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class DocVersion
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultVersionType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,172 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// DocVersionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class DocVersionInfo : ReadOnlyBase<DocVersionInfo>
{
#region Business Methods
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionID;
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderID;
}
}
private int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionType;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Title;
}
}
private int _StructureID;
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
// TODO: Replace base DocVersionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocVersionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocVersionInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current DocVersionInfo</returns>
protected override object GetIdValue()
{
return _VersionID;
}
#endregion
#region Factory Methods
private DocVersionInfo()
{ /* require use of factory methods */ }
public DocVersion Get()
{
return DocVersion.Get(_VersionID);
}
#endregion
#region Data Access Portal
internal DocVersionInfo(SafeDataReader dr)
{
try
{
_VersionID = dr.GetInt32("VersionID");
_FolderID = dr.GetInt32("FolderID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_StructureID = dr.GetInt32("StructureID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
Database.LogException("DocVersionInfo.Constructor", ex);
throw new DbCslaException("DocVersionInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// DocVersionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class DocVersionInfoList : ReadOnlyListBase<DocVersionInfoList, DocVersionInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static DocVersionInfoList Get()
{
return DataPortal.Fetch<DocVersionInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static DocVersionInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<DocVersionInfoList>(new FilteredCriteria(<criteria>));
//}
public static DocVersionInfoList GetByFolder(int folderID)
{
return DataPortal.Fetch<DocVersionInfoList>(new FolderCriteria(folderID));
}
private DocVersionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocVersions";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new DocVersionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("DocVersionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class FolderCriteria
{
public FolderCriteria(int folderID)
{
_FolderID = folderID;
}
private int _FolderID;
public int FolderID
{
get { return _FolderID; }
set { _FolderID = value; }
}
}
private void DataPortal_Fetch(FolderCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocVersionsByFolder";
cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new DocVersionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("DocVersionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,729 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Document Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Document : BusinessBase<Document>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextDocID = -1;
public static int NextDocID
{
get { return _nextDocID--; }
}
private int _DocID;
[System.ComponentModel.DataObjectField(true, true)]
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DocID;
}
}
private string _LibTitle = string.Empty;
public string LibTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _LibTitle;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_LibTitle != value)
{
_LibTitle = value;
PropertyHasChanged();
}
}
}
private byte[] _DocContent;
/// <summary>
/// Actual content of a Word Document (RTF, DOC or XML Format)
/// </summary>
public byte[] DocContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DocContent;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_DocContent != value)
{
_DocContent = value;
PropertyHasChanged();
}
}
}
private string _DocAscii = string.Empty;
/// <summary>
/// Used for searching
/// </summary>
public string DocAscii
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DocAscii;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_DocAscii != value)
{
_DocAscii = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base Document.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Document</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Document.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 Document</returns>
protected override object GetIdValue()
{
return _DocID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "LibTitle");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("LibTitle", 1024));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("DocAscii", 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));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(DocID, "<Role(s)>");
//AuthorizationRules.AllowRead(LibTitle, "<Role(s)>");
//AuthorizationRules.AllowRead(DocContent, "<Role(s)>");
//AuthorizationRules.AllowRead(DocAscii, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(LibTitle, "<Role(s)>");
//AuthorizationRules.AllowWrite(DocContent, "<Role(s)>");
//AuthorizationRules.AllowWrite(DocAscii, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Document()
{/* require use of factory methods */}
public static Document New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Document");
return DataPortal.Create<Document>();
}
public static Document New(string libTitle, byte[] docContent, string docAscii, string config)
{
Document tmp = Document.New();
tmp.LibTitle = libTitle;
tmp.DocContent = docContent;
tmp.DocAscii = docAscii;
tmp.Config = config;
return tmp;
}
public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config)
{
Document tmp = Document.New(libTitle, docContent, docAscii, config);
tmp.Save();
return tmp;
}
public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID)
{
Document tmp = Document.New(libTitle, docContent, docAscii, config);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static Document Get(int docID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Document");
return DataPortal.Fetch<Document>(new PKCriteria(docID));
}
public static Document Get(SafeDataReader dr)
{
if (dr.Read()) return new Document(dr);
return null;
}
private Document(SafeDataReader dr)
{
_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");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int docID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Document");
DataPortal.Delete(new PKCriteria(docID));
}
public override Document Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Document");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Document");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Document");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _DocID;
public int DocID
{ get { return _DocID; } }
public PKCriteria(int docID)
{
_DocID = docID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_DocID = NextDocID;
// Database Defaults
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocument";
cm.Parameters.AddWithValue("@DocID", criteria.DocID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_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");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Document.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Document.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addDocument";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
cm.Parameters.AddWithValue("@DocContent", _DocContent);
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
param_DocID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_DocID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_DocID = (int)cm.Parameters["@newDocID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("Document.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Document.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addDocument";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@LibTitle", libTitle);
cm.Parameters.AddWithValue("@DocContent", docContent);
cm.Parameters.AddWithValue("@DocAscii", docAscii);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
param_DocID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_DocID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
docID = (int)cm.Parameters["@newDocID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Document.Add", ex);
throw new DbCslaException("Document.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateDocument";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@DocID", _DocID);
cm.Parameters.AddWithValue("@LibTitle", _LibTitle);
cm.Parameters.AddWithValue("@DocContent", _DocContent);
cm.Parameters.AddWithValue("@DocAscii", _DocAscii);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("Document.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateDocument";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@DocID", docID);
cm.Parameters.AddWithValue("@LibTitle", libTitle);
cm.Parameters.AddWithValue("@DocContent", docContent);
cm.Parameters.AddWithValue("@DocAscii", docAscii);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Document.Update", ex);
throw new DbCslaException("Document.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_DocID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteDocument";
cm.Parameters.AddWithValue("@DocID", criteria.DocID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Document.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Document.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int docID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteDocument";
// Input PK Fields
cm.Parameters.AddWithValue("@DocID", docID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Document.Remove", ex);
throw new DbCslaException("Document.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int docID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(docID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _DocID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int docID)
{
_DocID = docID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsDocument";
cm.Parameters.AddWithValue("@DocID", _DocID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Document.DataPortal_Execute", ex);
throw new DbCslaException("Document.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create DocumentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Document
// {
// partial class Extension : 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,153 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// DocumentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class DocumentInfo : ReadOnlyBase<DocumentInfo>
{
#region Business Methods
private int _DocID;
[System.ComponentModel.DataObjectField(true, true)]
public int DocID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DocID;
}
}
private string _LibTitle = string.Empty;
public string LibTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _LibTitle;
}
}
private byte[] _DocContent;
/// <summary>
/// Actual content of a Word Document (RTF, DOC or XML Format)
/// </summary>
public byte[] DocContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DocContent;
}
}
private string _DocAscii = string.Empty;
/// <summary>
/// Used for searching
/// </summary>
public string DocAscii
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DocAscii;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
// TODO: Replace base DocumentInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current DocumentInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check DocumentInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current DocumentInfo</returns>
protected override object GetIdValue()
{
return _DocID;
}
#endregion
#region Factory Methods
private DocumentInfo()
{ /* require use of factory methods */ }
public Document Get()
{
return Document.Get(_DocID);
}
#endregion
#region Data Access Portal
internal DocumentInfo(SafeDataReader dr)
{
try
{
_DocID = dr.GetInt32("DocID");
_LibTitle = dr.GetString("LibTitle");
_DocContent = (byte[])dr.GetValue("DocContent");
_DocAscii = dr.GetString("DocAscii");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
Database.LogException("DocumentInfo.Constructor", ex);
throw new DbCslaException("DocumentInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// DocumentInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class DocumentInfoList : ReadOnlyListBase<DocumentInfoList, DocumentInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static DocumentInfoList Get()
{
return DataPortal.Fetch<DocumentInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static DocumentInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<DocumentInfoList>(new FilteredCriteria(<criteria>));
//}
private DocumentInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getDocuments";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new DocumentInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("DocumentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("DocumentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,817 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Folder Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Folder : BusinessBase<Folder>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextFolderID = -1;
public static int NextFolderID
{
get { return _nextFolderID--; }
}
private int _FolderID;
[System.ComponentModel.DataObjectField(true, true)]
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderID;
}
}
private int _ParentID;
/// <summary>
/// {child Folders.FolderID}
/// </summary>
public int ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ParentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ParentID != value)
{
_ParentID = value;
PropertyHasChanged();
}
}
}
private int _DBID;
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DBID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_DBID != value)
{
_DBID = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private FolderAssignments _FolderAssignments = FolderAssignments.New();
/// <summary>
/// Related Field
/// </summary>
public FolderAssignments FolderAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderAssignments;
}
}
private FolderDocVersions _FolderDocVersions = FolderDocVersions.New();
/// <summary>
/// Related Field
/// </summary>
public FolderDocVersions FolderDocVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderDocVersions;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _FolderAssignments.IsDirty || _FolderDocVersions.IsDirty; }
}
public override bool IsValid
{
get { return base.IsValid && _FolderAssignments.IsValid && _FolderDocVersions.IsValid; }
}
// TODO: Replace base Folder.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Folder</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Folder.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 Folder</returns>
protected override object GetIdValue()
{
return _FolderID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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.AllowRead(DBID, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DBID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Folder()
{/* require use of factory methods */}
public static Folder New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Folder");
return DataPortal.Create<Folder>();
}
public static Folder New(int parentID, int dbid, string name, string title, string config)
{
Folder tmp = Folder.New();
tmp.ParentID = parentID;
tmp.DBID = dbid;
tmp.Name = name;
tmp.Title = title;
tmp.Config = config;
return tmp;
}
public static Folder MakeFolder(int parentID, int dbid, string name, string title, string config)
{
Folder tmp = Folder.New(parentID, dbid, name, title, config);
tmp.Save();
return tmp;
}
public static Folder MakeFolder(int parentID, int dbid, string name, string title, string config, DateTime dts, string usrID)
{
Folder tmp = Folder.New(parentID, dbid, name, title, config);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID;
tmp.Save();
return tmp;
}
public static Folder Get(int folderID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Folder");
return DataPortal.Fetch<Folder>(new PKCriteria(folderID));
}
public static Folder Get(SafeDataReader dr)
{
if (dr.Read()) return new Folder(dr);
return null;
}
private Folder(SafeDataReader dr)
{
_FolderID = dr.GetInt32("FolderID");
_ParentID = dr.GetInt32("ParentID");
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int folderID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Folder");
DataPortal.Delete(new PKCriteria(folderID));
}
public override Folder Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Folder");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Folder");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Folder");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _FolderID;
public int FolderID
{ get { return _FolderID; } }
public PKCriteria(int folderID)
{
_FolderID = folderID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_FolderID = NextFolderID;
// Database Defaults
_ParentID = ext.DefaultParentID;
_DBID = ext.DefaultDBID;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFolder";
cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_FolderID = dr.GetInt32("FolderID");
_ParentID = dr.GetInt32("ParentID");
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
// load child objects
dr.NextResult();
_FolderAssignments = FolderAssignments.Get(dr);
// load child objects
dr.NextResult();
_FolderDocVersions = FolderDocVersions.Get(dr);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Folder.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Folder.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addFolder";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ParentID", _ParentID);
cm.Parameters.AddWithValue("@DBID", _DBID);
cm.Parameters.AddWithValue("@Name", _Name);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
// Output Calculated Columns
SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int);
param_FolderID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_FolderID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_FolderID = (int)cm.Parameters["@newFolderID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
_FolderAssignments.Update(this, cn);
_FolderDocVersions.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Folder.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Folder.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int folderID, int parentID, int dbid, string name, string title, string config, DateTime dts, string usrID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addFolder";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ParentID", parentID);
cm.Parameters.AddWithValue("@DBID", dbid);
cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
// Output Calculated Columns
SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int);
param_FolderID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_FolderID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
folderID = (int)cm.Parameters["@newFolderID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Folder.Add", ex);
throw new DbCslaException("Folder.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateFolder";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@FolderID", _FolderID);
cm.Parameters.AddWithValue("@ParentID", _ParentID);
cm.Parameters.AddWithValue("@DBID", _DBID);
cm.Parameters.AddWithValue("@Name", _Name);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
_FolderAssignments.Update(this, cn);
_FolderDocVersions.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Folder.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int folderID, int parentID, int dbid, string name, string title, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateFolder";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FolderID", folderID);
cm.Parameters.AddWithValue("@ParentID", parentID);
cm.Parameters.AddWithValue("@DBID", dbid);
cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Folder.Update", ex);
throw new DbCslaException("Folder.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_FolderID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteFolder";
cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Folder.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Folder.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int folderID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteFolder";
// Input PK Fields
cm.Parameters.AddWithValue("@FolderID", folderID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Folder.Remove", ex);
throw new DbCslaException("Folder.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int folderID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(folderID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _FolderID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int folderID)
{
_FolderID = folderID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsFolder";
cm.Parameters.AddWithValue("@FolderID", _FolderID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Folder.DataPortal_Execute", ex);
throw new DbCslaException("Folder.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultParentID
{
get { return 0; }
}
public virtual int DefaultDBID
{
get { return 0; }
}
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create FolderExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Folder
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultParentID
// {
// get { return 0; }
// }
// public virtual int DefaultDBID
// {
// get { return 0; }
// }
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,566 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// FolderAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class FolderAssignment : BusinessBase<FolderAssignment>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _AID;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_GID != value)
{
_GID = value;
PropertyHasChanged();
}
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_RID != value)
{
_RID = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Group_GroupName = string.Empty;
public string Group_GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_GroupName;
}
}
private int _Group_GroupType;
public int Group_GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_GroupType;
}
}
private string _Group_Config = string.Empty;
public string Group_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_Config;
}
}
private DateTime _Group_DTS = new DateTime();
public DateTime Group_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_DTS;
}
}
private string _Group_UsrID = string.Empty;
public string Group_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_UsrID;
}
}
private string _Role_Name = string.Empty;
public string Role_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Role_Name;
}
}
private string _Role_Title = string.Empty;
public string Role_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Role_Title;
}
}
private DateTime _Role_DTS = new DateTime();
public DateTime Role_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Role_DTS;
}
}
private string _Role_UsrID = string.Empty;
public string Role_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Role_UsrID;
}
}
// TODO: Check FolderAssignment.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current FolderAssignment</returns>
protected override object GetIdValue()
{
return _AID;
}
// TODO: Replace base FolderAssignment.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FolderAssignment</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AID, "<Role(s)>");
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static FolderAssignment New(int gid, int rid)
{
return new FolderAssignment(Volian.CSLA.Library.Group.Get(gid), Volian.CSLA.Library.Role.Get(rid));
}
internal static FolderAssignment Get(SafeDataReader dr)
{
return new FolderAssignment(dr);
}
public FolderAssignment()
{
MarkAsChild();
_AID = Assignment.NextAID;
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
}
private FolderAssignment(Group group, Role role)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
_GID = group.GID;
_Group_GroupName = group.GroupName;
_Group_GroupType = group.GroupType;
_Group_Config = group.Config;
_Group_DTS = group.DTS;
_Group_UsrID = group.UsrID;
_RID = role.RID;
_Role_Name = role.Name;
_Role_Title = role.Title;
_Role_DTS = role.DTS;
_Role_UsrID = role.UsrID;
}
private FolderAssignment(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_AID = dr.GetInt32("AID");
_GID = dr.GetInt32("GID");
_RID = dr.GetInt32("RID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Group_GroupName = dr.GetString("Group_GroupName");
_Group_GroupType = dr.GetInt32("Group_GroupType");
_Group_Config = dr.GetString("Group_Config");
_Group_DTS = dr.GetDateTime("Group_DTS");
_Group_UsrID = dr.GetString("Group_UsrID");
_Role_Name = dr.GetString("Role_Name");
_Role_Title = dr.GetString("Role_Title");
_Role_DTS = dr.GetDateTime("Role_DTS");
_Role_UsrID = dr.GetString("Role_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("FolderAssignment.Fetch", ex);
throw new DbCslaException("FolderAssignment.Fetch", ex);
}
MarkOld();
}
internal void Insert(Folder folder, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Assignment.Add(cn, ref _AID, _GID, _RID, folder.FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(Folder folder, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Assignment.Update(cn, ref _AID, _GID, _RID, folder.FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Folder folder, SqlConnection cn)
{
// 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;
Assignment.Remove(cn, _AID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create FolderAssignmentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class FolderAssignment
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,142 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// FolderAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class FolderAssignments : BusinessListBase<FolderAssignments, FolderAssignment>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// Many To Many
public FolderAssignment this[int gid, int rid]
{
get
{
foreach (FolderAssignment assignment in this)
if (assignment.GID == gid && assignment.RID == rid)
return assignment;
return null;
}
}
public FolderAssignment GetItem(int gid, int rid)
{
foreach (FolderAssignment assignment in this)
if (assignment.GID == gid && assignment.RID == rid)
return assignment;
return null;
}
public FolderAssignment Add(int gid, int rid)
{
if (!Contains(gid, rid))
{
FolderAssignment assignment = FolderAssignment.New(gid, rid);
this.Add(assignment);
return assignment;
}
else
throw new InvalidOperationException("assignment already exists");
}
public void Remove(int gid, int rid)
{
foreach (FolderAssignment assignment in this)
{
if (assignment.GID == gid && assignment.RID == rid)
{
Remove(assignment);
break;
}
}
}
public bool Contains(int gid, int rid)
{
foreach (FolderAssignment assignment in this)
if (assignment.GID == gid && assignment.RID == rid)
return true;
return false;
}
public bool ContainsDeleted(int gid, int rid)
{
foreach (FolderAssignment assignment in DeletedList)
if (assignment.GID == gid && assignment.RID == rid)
return true;
return false;
}
#endregion
#region Factory Methods
internal static FolderAssignments New()
{
return new FolderAssignments();
}
internal static FolderAssignments Get(SafeDataReader dr)
{
return new FolderAssignments(dr);
}
private FolderAssignments()
{
MarkAsChild();
}
private FolderAssignments(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(FolderAssignment.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Folder folder, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (FolderAssignment obj in DeletedList)
obj.DeleteSelf(folder, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (FolderAssignment obj in this)
{
if (obj.IsNew)
obj.Insert(folder, cn);
else
obj.Update(folder, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,447 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// FolderDocVersion Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class FolderDocVersion : BusinessBase<FolderDocVersion>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _VersionID;
[System.ComponentModel.DataObjectField(true, true)]
public int VersionID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionID;
}
}
private int _VersionType;
/// <summary>
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private int _StructureID;
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_StructureID != value)
{
_StructureID = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check FolderDocVersion.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current FolderDocVersion</returns>
protected override object GetIdValue()
{
return _VersionID;
}
// TODO: Replace base FolderDocVersion.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FolderDocVersion</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(VersionID, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(StructureID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StructureID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static FolderDocVersion New(string name)
{
return new FolderDocVersion(name);
}
internal static FolderDocVersion Get(SafeDataReader dr)
{
return new FolderDocVersion(dr);
}
public FolderDocVersion()
{
MarkAsChild();
_VersionID = DocVersion.NextVersionID;
_VersionType = ext.DefaultVersionType;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
}
private FolderDocVersion(string name)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_VersionType = ext.DefaultVersionType;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
_Name = name;
}
private FolderDocVersion(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_VersionID = dr.GetInt32("VersionID");
_VersionType = dr.GetInt32("VersionType");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_StructureID = dr.GetInt32("StructureID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("FolderDocVersion.Fetch", ex);
throw new DbCslaException("FolderDocVersion.Fetch", ex);
}
MarkOld();
}
internal void Insert(Folder folder, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = DocVersion.Add(cn, ref _VersionID, folder.FolderID, _VersionType, _Name, _Title, _StructureID, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(Folder folder, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = DocVersion.Update(cn, ref _VersionID, folder.FolderID, _VersionType, _Name, _Title, _StructureID, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Folder folder, SqlConnection cn)
{
// 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;
DocVersion.Remove(cn, _VersionID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultVersionType
{
get { return 0; }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create FolderDocVersionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class FolderDocVersion
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultVersionType
// {
// get { return 0; }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,137 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// FolderDocVersions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class FolderDocVersions : BusinessListBase<FolderDocVersions, FolderDocVersion>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// One To Many
public new FolderDocVersion this[int versionID]
{
get
{
foreach (FolderDocVersion docVersion in this)
if (docVersion.VersionID == versionID)
return docVersion;
return null;
}
}
public FolderDocVersion GetItem(int versionID)
{
foreach (FolderDocVersion docVersion in this)
if (docVersion.VersionID == versionID)
return docVersion;
return null;
}
public FolderDocVersion Add(string name)
{
FolderDocVersion docVersion = FolderDocVersion.New(name);
this.Add(docVersion);
return docVersion;
}
public void Remove(int versionID)
{
foreach (FolderDocVersion docVersion in this)
{
if (docVersion.VersionID == versionID)
{
Remove(docVersion);
break;
}
}
}
public bool Contains(int versionID)
{
foreach (FolderDocVersion docVersion in this)
if (docVersion.VersionID == versionID)
return true;
return false;
}
public bool ContainsDeleted(int versionID)
{
foreach (FolderDocVersion docVersion in DeletedList)
if (docVersion.VersionID == versionID)
return true;
return false;
}
#endregion
#region Factory Methods
internal static FolderDocVersions New()
{
return new FolderDocVersions();
}
internal static FolderDocVersions Get(SafeDataReader dr)
{
return new FolderDocVersions(dr);
}
private FolderDocVersions()
{
MarkAsChild();
}
private FolderDocVersions(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(FolderDocVersion.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Folder folder, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (FolderDocVersion obj in DeletedList)
obj.DeleteSelf(folder, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (FolderDocVersion obj in this)
{
if (obj.IsNew)
obj.Insert(folder, cn);
else
obj.Update(folder, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,213 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// FolderInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class FolderInfo : ReadOnlyBase<FolderInfo>
{
#region Business Methods
private int _FolderID;
[System.ComponentModel.DataObjectField(true, true)]
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderID;
}
}
private int _ParentID;
/// <summary>
/// {child Folders.FolderID}
/// </summary>
public int ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ParentID;
}
}
private int _DBID;
public int DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DBID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Title;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UsrID;
}
}
private int _Assignmentcount = 0;
/// <summary>
/// Count of Assignment for this Folder
/// </summary>
public int AssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Assignmentcount;
}
}
private AssignmentInfoList _Assignments = null;
public AssignmentInfoList Assignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Assignments == null)
_Assignments = AssignmentInfoList.GetByFolder(_FolderID);
return _Assignments;
}
}
private int _DocVersioncount = 0;
/// <summary>
/// Count of DocVersion for this Folder
/// </summary>
public int DocVersionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DocVersioncount;
}
}
private DocVersionInfoList _DocVersions = null;
public DocVersionInfoList DocVersions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_DocVersions == null)
_DocVersions = DocVersionInfoList.GetByFolder(_FolderID);
return _DocVersions;
}
}
// TODO: Replace base FolderInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current FolderInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check FolderInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current FolderInfo</returns>
protected override object GetIdValue()
{
return _FolderID;
}
#endregion
#region Factory Methods
private FolderInfo()
{ /* require use of factory methods */ }
public Folder Get()
{
return Folder.Get(_FolderID);
}
#endregion
#region Data Access Portal
internal FolderInfo(SafeDataReader dr)
{
try
{
_FolderID = dr.GetInt32("FolderID");
_ParentID = dr.GetInt32("ParentID");
_DBID = dr.GetInt32("DBID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_Assignmentcount = dr.GetInt32("AssignmentCount");
_DocVersioncount = dr.GetInt32("DocVersionCount");
}
catch (Exception ex)
{
Database.LogException("FolderInfo.Constructor", ex);
throw new DbCslaException("FolderInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// FolderInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class FolderInfoList : ReadOnlyListBase<FolderInfoList, FolderInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static FolderInfoList Get()
{
return DataPortal.Fetch<FolderInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static FolderInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<FolderInfoList>(new FilteredCriteria(<criteria>));
//}
public static FolderInfoList GetByConnection(int dbid)
{
return DataPortal.Fetch<FolderInfoList>(new ConnectionCriteria(dbid));
}
private FolderInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFolders";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FolderInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("FolderInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class ConnectionCriteria
{
public ConnectionCriteria(int dbid)
{
_DBID = dbid;
}
private int _DBID;
public int DBID
{
get { return _DBID; }
set { _DBID = value; }
}
}
private void DataPortal_Fetch(ConnectionCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getFoldersByConnection";
cm.Parameters.AddWithValue("@DBID", criteria.DBID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FolderInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("FolderInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,734 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Group Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Group : BusinessBase<Group>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextGID = -1;
public static int NextGID
{
get { return _nextGID--; }
}
private int _GID;
[System.ComponentModel.DataObjectField(true, true)]
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
}
private string _GroupName = string.Empty;
public string GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GroupName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_GroupName != value)
{
_GroupName = value;
PropertyHasChanged();
}
}
}
private int _GroupType;
public int GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GroupType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_GroupType != value)
{
_GroupType = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private GroupAssignments _GroupAssignments = GroupAssignments.New();
/// <summary>
/// Related Field
/// </summary>
public GroupAssignments GroupAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GroupAssignments;
}
}
private GroupMemberships _GroupMemberships = GroupMemberships.New();
/// <summary>
/// Related Field
/// </summary>
public GroupMemberships GroupMemberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GroupMemberships;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _GroupAssignments.IsDirty || _GroupMemberships.IsDirty; }
}
public override bool IsValid
{
get { return base.IsValid && _GroupAssignments.IsValid && _GroupMemberships.IsValid; }
}
// TODO: Replace base Group.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Group</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Group.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 Group</returns>
protected override object GetIdValue()
{
return _GID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "GroupName");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("GroupName", 50));
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));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(GID, "<Role(s)>");
//AuthorizationRules.AllowRead(GroupName, "<Role(s)>");
//AuthorizationRules.AllowRead(GroupType, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(GroupName, "<Role(s)>");
//AuthorizationRules.AllowWrite(GroupType, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Group()
{/* require use of factory methods */}
public static Group New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Group");
return DataPortal.Create<Group>();
}
public static Group New(string groupName, int groupType, string config)
{
Group tmp = Group.New();
tmp.GroupName = groupName;
tmp.GroupType = groupType;
tmp.Config = config;
return tmp;
}
public static Group MakeGroup(string groupName, int groupType, string config)
{
Group tmp = Group.New(groupName, groupType, config);
tmp.Save();
return tmp;
}
public static Group MakeGroup(string groupName, int groupType, string config, DateTime dts, string usrID)
{
Group tmp = Group.New(groupName, groupType, config);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID;
tmp.Save();
return tmp;
}
public static Group Get(int gid)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Group");
return DataPortal.Fetch<Group>(new PKCriteria(gid));
}
public static Group Get(SafeDataReader dr)
{
if (dr.Read()) return new Group(dr);
return null;
}
private Group(SafeDataReader dr)
{
_GID = dr.GetInt32("GID");
_GroupName = dr.GetString("GroupName");
_GroupType = dr.GetInt32("GroupType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int gid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Group");
DataPortal.Delete(new PKCriteria(gid));
}
public override Group Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Group");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Group");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Group");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _GID;
public int GID
{ get { return _GID; } }
public PKCriteria(int gid)
{
_GID = gid;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_GID = NextGID;
// Database Defaults
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getGroup";
cm.Parameters.AddWithValue("@GID", criteria.GID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_GID = dr.GetInt32("GID");
_GroupName = dr.GetString("GroupName");
_GroupType = dr.GetInt32("GroupType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
// load child objects
dr.NextResult();
_GroupAssignments = GroupAssignments.Get(dr);
// load child objects
dr.NextResult();
_GroupMemberships = GroupMemberships.Get(dr);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Group.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Group.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addGroup";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@GroupName", _GroupName);
cm.Parameters.AddWithValue("@GroupType", _GroupType);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
// Output Calculated Columns
SqlParameter param_GID = new SqlParameter("@newGID", SqlDbType.Int);
param_GID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_GID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_GID = (int)cm.Parameters["@newGID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
_GroupAssignments.Update(this, cn);
_GroupMemberships.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Group.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Group.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int gid, string groupName, int groupType, string config, DateTime dts, string usrID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addGroup";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@GroupName", groupName);
cm.Parameters.AddWithValue("@GroupType", groupType);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
// Output Calculated Columns
SqlParameter param_GID = new SqlParameter("@newGID", SqlDbType.Int);
param_GID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_GID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
gid = (int)cm.Parameters["@newGID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Group.Add", ex);
throw new DbCslaException("Group.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateGroup";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@GID", _GID);
cm.Parameters.AddWithValue("@GroupName", _GroupName);
cm.Parameters.AddWithValue("@GroupType", _GroupType);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
_GroupAssignments.Update(this, cn);
_GroupMemberships.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Group.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int gid, string groupName, int groupType, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateGroup";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@GID", gid);
cm.Parameters.AddWithValue("@GroupName", groupName);
cm.Parameters.AddWithValue("@GroupType", groupType);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Group.Update", ex);
throw new DbCslaException("Group.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_GID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteGroup";
cm.Parameters.AddWithValue("@GID", criteria.GID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Group.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Group.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int gid)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteGroup";
// Input PK Fields
cm.Parameters.AddWithValue("@GID", gid);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Group.Remove", ex);
throw new DbCslaException("Group.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int gid)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(gid));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _GID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int gid)
{
_GID = gid;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsGroup";
cm.Parameters.AddWithValue("@GID", _GID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Group.DataPortal_Execute", ex);
throw new DbCslaException("Group.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create GroupExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Group
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,593 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// GroupAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupAssignment : BusinessBase<GroupAssignment>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _AID;
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_RID != value)
{
_RID = value;
PropertyHasChanged();
}
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FolderID != value)
{
_FolderID = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _Folder_ParentID;
/// <summary>
/// {child Folders.FolderID}
/// </summary>
public int Folder_ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_ParentID;
}
}
private int _Folder_DBID;
public int Folder_DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_DBID;
}
}
private string _Folder_Name = string.Empty;
public string Folder_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_Name;
}
}
private string _Folder_Title = string.Empty;
public string Folder_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_Title;
}
}
private string _Folder_Config = string.Empty;
public string Folder_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_Config;
}
}
private DateTime _Folder_DTS = new DateTime();
public DateTime Folder_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_DTS;
}
}
private string _Folder_UsrID = string.Empty;
public string Folder_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_UsrID;
}
}
private string _Role_Name = string.Empty;
public string Role_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Role_Name;
}
}
private string _Role_Title = string.Empty;
public string Role_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Role_Title;
}
}
private DateTime _Role_DTS = new DateTime();
public DateTime Role_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Role_DTS;
}
}
private string _Role_UsrID = string.Empty;
public string Role_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Role_UsrID;
}
}
// TODO: Check GroupAssignment.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current GroupAssignment</returns>
protected override object GetIdValue()
{
return _AID;
}
// TODO: Replace base GroupAssignment.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupAssignment</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AID, "<Role(s)>");
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static GroupAssignment New(int rid, int folderID)
{
return new GroupAssignment(Volian.CSLA.Library.Role.Get(rid), Volian.CSLA.Library.Folder.Get(folderID));
}
internal static GroupAssignment Get(SafeDataReader dr)
{
return new GroupAssignment(dr);
}
public GroupAssignment()
{
MarkAsChild();
_AID = Assignment.NextAID;
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
}
private GroupAssignment(Role role, Folder folder)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
_FolderID = folder.FolderID;
_Folder_ParentID = folder.ParentID;
_Folder_DBID = folder.DBID;
_Folder_Name = folder.Name;
_Folder_Title = folder.Title;
_Folder_Config = folder.Config;
_Folder_DTS = folder.DTS;
_Folder_UsrID = folder.UsrID;
_RID = role.RID;
_Role_Name = role.Name;
_Role_Title = role.Title;
_Role_DTS = role.DTS;
_Role_UsrID = role.UsrID;
}
private GroupAssignment(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_AID = dr.GetInt32("AID");
_RID = dr.GetInt32("RID");
_FolderID = dr.GetInt32("FolderID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Folder_ParentID = dr.GetInt32("Folder_ParentID");
_Folder_DBID = dr.GetInt32("Folder_DBID");
_Folder_Name = dr.GetString("Folder_Name");
_Folder_Title = dr.GetString("Folder_Title");
_Folder_Config = dr.GetString("Folder_Config");
_Folder_DTS = dr.GetDateTime("Folder_DTS");
_Folder_UsrID = dr.GetString("Folder_UsrID");
_Role_Name = dr.GetString("Role_Name");
_Role_Title = dr.GetString("Role_Title");
_Role_DTS = dr.GetDateTime("Role_DTS");
_Role_UsrID = dr.GetString("Role_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("GroupAssignment.Fetch", ex);
throw new DbCslaException("GroupAssignment.Fetch", ex);
}
MarkOld();
}
internal void Insert(Group group, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Assignment.Add(cn, ref _AID, group.GID, _RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(Group group, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Assignment.Update(cn, ref _AID, group.GID, _RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Group group, SqlConnection cn)
{
// 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;
Assignment.Remove(cn, _AID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create GroupAssignmentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class GroupAssignment
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,142 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// GroupAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupAssignments : BusinessListBase<GroupAssignments, GroupAssignment>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// Many To Many
public GroupAssignment this[int folderID, int rid]
{
get
{
foreach (GroupAssignment assignment in this)
if (assignment.FolderID == folderID && assignment.RID == rid)
return assignment;
return null;
}
}
public GroupAssignment GetItem(int folderID, int rid)
{
foreach (GroupAssignment assignment in this)
if (assignment.FolderID == folderID && assignment.RID == rid)
return assignment;
return null;
}
public GroupAssignment Add(int rid, int folderID)
{
if (!Contains(rid, folderID))
{
GroupAssignment assignment = GroupAssignment.New(rid, folderID);
this.Add(assignment);
return assignment;
}
else
throw new InvalidOperationException("assignment already exists");
}
public void Remove(int folderID, int rid)
{
foreach (GroupAssignment assignment in this)
{
if (assignment.FolderID == folderID && assignment.RID == rid)
{
Remove(assignment);
break;
}
}
}
public bool Contains(int folderID, int rid)
{
foreach (GroupAssignment assignment in this)
if (assignment.FolderID == folderID && assignment.RID == rid)
return true;
return false;
}
public bool ContainsDeleted(int folderID, int rid)
{
foreach (GroupAssignment assignment in DeletedList)
if (assignment.FolderID == folderID && assignment.RID == rid)
return true;
return false;
}
#endregion
#region Factory Methods
internal static GroupAssignments New()
{
return new GroupAssignments();
}
internal static GroupAssignments Get(SafeDataReader dr)
{
return new GroupAssignments(dr);
}
private GroupAssignments()
{
MarkAsChild();
}
private GroupAssignments(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(GroupAssignment.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Group group, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (GroupAssignment obj in DeletedList)
obj.DeleteSelf(group, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (GroupAssignment obj in this)
{
if (obj.IsNew)
obj.Insert(group, cn);
else
obj.Update(group, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,188 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// GroupInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupInfo : ReadOnlyBase<GroupInfo>
{
#region Business Methods
private int _GID;
[System.ComponentModel.DataObjectField(true, true)]
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
}
private string _GroupName = string.Empty;
public string GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GroupName;
}
}
private int _GroupType;
public int GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GroupType;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UsrID;
}
}
private int _Assignmentcount = 0;
/// <summary>
/// Count of Assignment for this Group
/// </summary>
public int AssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Assignmentcount;
}
}
private AssignmentInfoList _Assignments = null;
public AssignmentInfoList Assignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Assignments == null)
_Assignments = AssignmentInfoList.GetByGroup(_GID);
return _Assignments;
}
}
private int _Membershipcount = 0;
/// <summary>
/// Count of Membership for this Group
/// </summary>
public int MembershipCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Membershipcount;
}
}
private MembershipInfoList _Memberships = null;
public MembershipInfoList Memberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Memberships == null)
_Memberships = MembershipInfoList.GetByGroup(_GID);
return _Memberships;
}
}
// TODO: Replace base GroupInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check GroupInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current GroupInfo</returns>
protected override object GetIdValue()
{
return _GID;
}
#endregion
#region Factory Methods
private GroupInfo()
{ /* require use of factory methods */ }
public Group Get()
{
return Group.Get(_GID);
}
#endregion
#region Data Access Portal
internal GroupInfo(SafeDataReader dr)
{
try
{
_GID = dr.GetInt32("GID");
_GroupName = dr.GetString("GroupName");
_GroupType = dr.GetInt32("GroupType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_Assignmentcount = dr.GetInt32("AssignmentCount");
_Membershipcount = dr.GetInt32("MembershipCount");
}
catch (Exception ex)
{
Database.LogException("GroupInfo.Constructor", ex);
throw new DbCslaException("GroupInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// GroupInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupInfoList : ReadOnlyListBase<GroupInfoList, GroupInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static GroupInfoList Get()
{
return DataPortal.Fetch<GroupInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static GroupInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<GroupInfoList>(new FilteredCriteria(<criteria>));
//}
private GroupInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getGroups";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new GroupInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("GroupInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("GroupInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,590 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// GroupMembership Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupMembership : BusinessBase<GroupMembership>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _UGID;
[System.ComponentModel.DataObjectField(true, true)]
public int UGID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UGID;
}
}
private int _UID;
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_UID != value)
{
_UID = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _User_UserID = string.Empty;
public string User_UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_UserID;
}
}
private string _User_FirstName = string.Empty;
public string User_FirstName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_FirstName;
}
}
private string _User_MiddleName = string.Empty;
public string User_MiddleName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_MiddleName;
}
}
private string _User_LastName = string.Empty;
public string User_LastName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_LastName;
}
}
private string _User_Suffix = string.Empty;
public string User_Suffix
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_Suffix;
}
}
private string _User_CourtesyTitle = string.Empty;
public string User_CourtesyTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_CourtesyTitle;
}
}
private string _User_PhoneNumber = string.Empty;
public string User_PhoneNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_PhoneNumber;
}
}
private string _User_CFGName = string.Empty;
public string User_CFGName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_CFGName;
}
}
private string _User_UserLogin = string.Empty;
public string User_UserLogin
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_UserLogin;
}
}
private string _User_UserName = string.Empty;
public string User_UserName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_UserName;
}
}
private string _User_Config = string.Empty;
public string User_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_Config;
}
}
private DateTime _User_DTS = new DateTime();
public DateTime User_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_DTS;
}
}
private string _User_UsrID = string.Empty;
public string User_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _User_UsrID;
}
}
// TODO: Check GroupMembership.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current GroupMembership</returns>
protected override object GetIdValue()
{
return _UGID;
}
// TODO: Replace base GroupMembership.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current GroupMembership</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(UGID, "<Role(s)>");
//AuthorizationRules.AllowRead(UID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static GroupMembership New(int uid)
{
return new GroupMembership(Volian.CSLA.Library.User.Get(uid));
}
internal static GroupMembership Get(SafeDataReader dr)
{
return new GroupMembership(dr);
}
public GroupMembership()
{
MarkAsChild();
_UGID = Membership.NextUGID;
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
}
private GroupMembership(User user)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
_UID = user.UID;
_User_UserID = user.UserID;
_User_FirstName = user.FirstName;
_User_MiddleName = user.MiddleName;
_User_LastName = user.LastName;
_User_Suffix = user.Suffix;
_User_CourtesyTitle = user.CourtesyTitle;
_User_PhoneNumber = user.PhoneNumber;
_User_CFGName = user.CFGName;
_User_UserLogin = user.UserLogin;
_User_UserName = user.UserName;
_User_Config = user.Config;
_User_DTS = user.DTS;
_User_UsrID = user.UsrID;
}
private GroupMembership(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_UGID = dr.GetInt32("UGID");
_UID = dr.GetInt32("UID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_User_UserID = dr.GetString("User_UserID");
_User_FirstName = dr.GetString("User_FirstName");
_User_MiddleName = dr.GetString("User_MiddleName");
_User_LastName = dr.GetString("User_LastName");
_User_Suffix = dr.GetString("User_Suffix");
_User_CourtesyTitle = dr.GetString("User_CourtesyTitle");
_User_PhoneNumber = dr.GetString("User_PhoneNumber");
_User_CFGName = dr.GetString("User_CFGName");
_User_UserLogin = dr.GetString("User_UserLogin");
_User_UserName = dr.GetString("User_UserName");
_User_Config = dr.GetString("User_Config");
_User_DTS = dr.GetDateTime("User_DTS");
_User_UsrID = dr.GetString("User_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("GroupMembership.Fetch", ex);
throw new DbCslaException("GroupMembership.Fetch", ex);
}
MarkOld();
}
internal void Insert(Group group, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Membership.Add(cn, ref _UGID, _UID, group.GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(Group group, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Membership.Update(cn, ref _UGID, _UID, group.GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Group group, SqlConnection cn)
{
// 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;
Membership.Remove(cn, _UGID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create GroupMembershipExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class GroupMembership
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,142 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// GroupMemberships Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupMemberships : BusinessListBase<GroupMemberships, GroupMembership>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// Many To Many
public new GroupMembership this[int uid]
{
get
{
foreach (GroupMembership membership in this)
if (membership.UID == uid)
return membership;
return null;
}
}
public GroupMembership GetItem(int uid)
{
foreach (GroupMembership membership in this)
if (membership.UID == uid)
return membership;
return null;
}
public GroupMembership Add(int uid)
{
if (!Contains(uid))
{
GroupMembership membership = GroupMembership.New(uid);
this.Add(membership);
return membership;
}
else
throw new InvalidOperationException("membership already exists");
}
public void Remove(int uid)
{
foreach (GroupMembership membership in this)
{
if (membership.UID == uid)
{
Remove(membership);
break;
}
}
}
public bool Contains(int uid)
{
foreach (GroupMembership membership in this)
if (membership.UID == uid)
return true;
return false;
}
public bool ContainsDeleted(int uid)
{
foreach (GroupMembership membership in DeletedList)
if (membership.UID == uid)
return true;
return false;
}
#endregion
#region Factory Methods
internal static GroupMemberships New()
{
return new GroupMemberships();
}
internal static GroupMemberships Get(SafeDataReader dr)
{
return new GroupMemberships(dr);
}
private GroupMemberships()
{
MarkAsChild();
}
private GroupMemberships(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(GroupMembership.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Group group, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (GroupMembership obj in DeletedList)
obj.DeleteSelf(group, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (GroupMembership obj in this)
{
if (obj.IsNew)
obj.Insert(group, cn);
else
obj.Update(group, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,768 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Membership Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Membership : BusinessBase<Membership>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextUGID = -1;
public static int NextUGID
{
get { return _nextUGID--; }
}
private int _UGID;
[System.ComponentModel.DataObjectField(true, true)]
public int UGID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UGID;
}
}
private int _UID;
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_UID != value)
{
_UID = value;
PropertyHasChanged();
}
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_GID != value)
{
_GID = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base Membership.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Membership</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Membership.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 Membership</returns>
protected override object GetIdValue()
{
return _UGID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(UGID, "<Role(s)>");
//AuthorizationRules.AllowRead(UID, "<Role(s)>");
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UID, "<Role(s)>");
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Membership()
{/* require use of factory methods */}
public static Membership New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Membership");
return DataPortal.Create<Membership>();
}
public static Membership New(int uid, int gid, string startDate, string endDate)
{
Membership tmp = Membership.New();
tmp.UID = uid;
tmp.GID = gid;
tmp.StartDate = startDate;
tmp.EndDate = endDate;
return tmp;
}
public static Membership MakeMembership(int uid, int gid, string startDate, string endDate)
{
Membership tmp = Membership.New(uid, gid, startDate, endDate);
tmp.Save();
return tmp;
}
public static Membership MakeMembership(int uid, int gid, string startDate, string endDate, DateTime dts, string usrID)
{
Membership tmp = Membership.New(uid, gid, startDate, endDate);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID;
tmp.Save();
return tmp;
}
public static Membership Get(int ugid)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Membership");
return DataPortal.Fetch<Membership>(new PKCriteria(ugid));
}
public static Membership Get(SafeDataReader dr)
{
if (dr.Read()) return new Membership(dr);
return null;
}
private Membership(SafeDataReader dr)
{
_UGID = dr.GetInt32("UGID");
_UID = dr.GetInt32("UID");
_GID = dr.GetInt32("GID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int ugid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Membership");
DataPortal.Delete(new PKCriteria(ugid));
}
public override Membership Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Membership");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Membership");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Membership");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _UGID;
public int UGID
{ get { return _UGID; } }
public PKCriteria(int ugid)
{
_UGID = ugid;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_UGID = NextUGID;
// Database Defaults
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getMembership";
cm.Parameters.AddWithValue("@UGID", criteria.UGID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_UGID = dr.GetInt32("UGID");
_UID = dr.GetInt32("UID");
_GID = dr.GetInt32("GID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Membership.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Membership.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addMembership";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@UID", _UID);
cm.Parameters.AddWithValue("@GID", _GID);
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
// Output Calculated Columns
SqlParameter param_UGID = new SqlParameter("@newUGID", SqlDbType.Int);
param_UGID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_UGID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_UGID = (int)cm.Parameters["@newUGID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("Membership.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Membership.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int ugid, int uid, int gid, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addMembership";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@UID", uid);
cm.Parameters.AddWithValue("@GID", gid);
cm.Parameters.AddWithValue("@StartDate", startDate.DBValue);
cm.Parameters.AddWithValue("@EndDate", endDate.DBValue);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
// Output Calculated Columns
SqlParameter param_UGID = new SqlParameter("@newUGID", SqlDbType.Int);
param_UGID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_UGID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
ugid = (int)cm.Parameters["@newUGID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Membership.Add", ex);
throw new DbCslaException("Membership.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateMembership";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@UGID", _UGID);
cm.Parameters.AddWithValue("@UID", _UID);
cm.Parameters.AddWithValue("@GID", _GID);
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("Membership.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int ugid, int uid, int gid, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateMembership";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@UGID", ugid);
cm.Parameters.AddWithValue("@UID", uid);
cm.Parameters.AddWithValue("@GID", gid);
cm.Parameters.AddWithValue("@StartDate", startDate.DBValue);
cm.Parameters.AddWithValue("@EndDate", endDate.DBValue);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Membership.Update", ex);
throw new DbCslaException("Membership.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_UGID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteMembership";
cm.Parameters.AddWithValue("@UGID", criteria.UGID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Membership.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Membership.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int ugid)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteMembership";
// Input PK Fields
cm.Parameters.AddWithValue("@UGID", ugid);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Membership.Remove", ex);
throw new DbCslaException("Membership.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int ugid)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(ugid));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _UGID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int ugid)
{
_UGID = ugid;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsMembership";
cm.Parameters.AddWithValue("@UGID", _UGID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Membership.DataPortal_Execute", ex);
throw new DbCslaException("Membership.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create MembershipExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Membership
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,147 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// MembershipInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class MembershipInfo : ReadOnlyBase<MembershipInfo>
{
#region Business Methods
private int _UGID;
[System.ComponentModel.DataObjectField(true, true)]
public int UGID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UGID;
}
}
private int _UID;
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UID;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UsrID;
}
}
// TODO: Replace base MembershipInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current MembershipInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check MembershipInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current MembershipInfo</returns>
protected override object GetIdValue()
{
return _UGID;
}
#endregion
#region Factory Methods
private MembershipInfo()
{ /* require use of factory methods */ }
public Membership Get()
{
return Membership.Get(_UGID);
}
#endregion
#region Data Access Portal
internal MembershipInfo(SafeDataReader dr)
{
try
{
_UGID = dr.GetInt32("UGID");
_UID = dr.GetInt32("UID");
_GID = dr.GetInt32("GID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
}
catch (Exception ex)
{
Database.LogException("MembershipInfo.Constructor", ex);
throw new DbCslaException("MembershipInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,168 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// MembershipInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class MembershipInfoList : ReadOnlyListBase<MembershipInfoList, MembershipInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static MembershipInfoList Get()
{
return DataPortal.Fetch<MembershipInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static MembershipInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<MembershipInfoList>(new FilteredCriteria(<criteria>));
//}
public static MembershipInfoList GetByGroup(int gid)
{
return DataPortal.Fetch<MembershipInfoList>(new GroupCriteria(gid));
}
public static MembershipInfoList GetByUser(int uid)
{
return DataPortal.Fetch<MembershipInfoList>(new UserCriteria(uid));
}
private MembershipInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getMemberships";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new MembershipInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("MembershipInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class GroupCriteria
{
public GroupCriteria(int gid)
{
_GID = gid;
}
private int _GID;
public int GID
{
get { return _GID; }
set { _GID = value; }
}
}
private void DataPortal_Fetch(GroupCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getMembershipsByGroup";
cm.Parameters.AddWithValue("@GID", criteria.GID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new MembershipInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("MembershipInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class UserCriteria
{
public UserCriteria(int uid)
{
_UID = uid;
}
private int _UID;
public int UID
{
get { return _UID; }
set { _UID = value; }
}
}
private void DataPortal_Fetch(UserCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getMembershipsByUser";
cm.Parameters.AddWithValue("@UID", criteria.UID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new MembershipInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("MembershipInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,876 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Permission Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Permission : BusinessBase<Permission>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextPID = -1;
public static int NextPID
{
get { return _nextPID--; }
}
private int _PID;
[System.ComponentModel.DataObjectField(true, true)]
public int PID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PID;
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_RID != value)
{
_RID = value;
PropertyHasChanged();
}
}
}
private int _PermLevel;
/// <summary>
/// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments
/// </summary>
public int PermLevel
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermLevel;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_PermLevel != value)
{
_PermLevel = value;
PropertyHasChanged();
}
}
}
private int _VersionType;
/// <summary>
/// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private int _PermValue;
/// <summary>
/// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All)
/// </summary>
public int PermValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermValue;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_PermValue != value)
{
_PermValue = value;
PropertyHasChanged();
}
}
}
private int _PermAD;
/// <summary>
/// 0 - Allow, 1 - Deny
/// </summary>
public int PermAD
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermAD;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_PermAD != value)
{
_PermAD = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base Permission.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Permission</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Permission.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 Permission</returns>
protected override object GetIdValue()
{
return _PID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(PID, "<Role(s)>");
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
//AuthorizationRules.AllowRead(PermLevel, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(PermValue, "<Role(s)>");
//AuthorizationRules.AllowRead(PermAD, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
//AuthorizationRules.AllowWrite(PermLevel, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(PermValue, "<Role(s)>");
//AuthorizationRules.AllowWrite(PermAD, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Permission()
{/* require use of factory methods */}
public static Permission New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Permission");
return DataPortal.Create<Permission>();
}
public static Permission New(int rid, int permLevel, int versionType, int permValue, int permAD, string startDate, string endDate)
{
Permission tmp = Permission.New();
tmp.RID = rid;
tmp.PermLevel = permLevel;
tmp.VersionType = versionType;
tmp.PermValue = permValue;
tmp.PermAD = permAD;
tmp.StartDate = startDate;
tmp.EndDate = endDate;
return tmp;
}
public static Permission MakePermission(int rid, int permLevel, int versionType, int permValue, int permAD, string startDate, string endDate)
{
Permission tmp = Permission.New(rid, permLevel, versionType, permValue, permAD, startDate, endDate);
tmp.Save();
return tmp;
}
public static Permission MakePermission(int rid, int permLevel, int versionType, int permValue, int permAD, string startDate, string endDate, DateTime dts, string usrID)
{
Permission tmp = Permission.New(rid, permLevel, versionType, permValue, permAD, startDate, endDate);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID;
tmp.Save();
return tmp;
}
public static Permission Get(int pid)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Permission");
return DataPortal.Fetch<Permission>(new PKCriteria(pid));
}
public static Permission Get(SafeDataReader dr)
{
if (dr.Read()) return new Permission(dr);
return null;
}
private Permission(SafeDataReader dr)
{
_PID = dr.GetInt32("PID");
_RID = dr.GetInt32("RID");
_PermLevel = dr.GetInt32("PermLevel");
_VersionType = dr.GetInt32("VersionType");
_PermValue = dr.GetInt32("PermValue");
_PermAD = dr.GetInt32("PermAD");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int pid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Permission");
DataPortal.Delete(new PKCriteria(pid));
}
public override Permission Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Permission");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Permission");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Permission");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _PID;
public int PID
{ get { return _PID; } }
public PKCriteria(int pid)
{
_PID = pid;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_PID = NextPID;
// Database Defaults
_PermAD = ext.DefaultPermAD;
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getPermission";
cm.Parameters.AddWithValue("@PID", criteria.PID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_PID = dr.GetInt32("PID");
_RID = dr.GetInt32("RID");
_PermLevel = dr.GetInt32("PermLevel");
_VersionType = dr.GetInt32("VersionType");
_PermValue = dr.GetInt32("PermValue");
_PermAD = dr.GetInt32("PermAD");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Permission.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Permission.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addPermission";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@RID", _RID);
cm.Parameters.AddWithValue("@PermLevel", _PermLevel);
cm.Parameters.AddWithValue("@VersionType", _VersionType);
cm.Parameters.AddWithValue("@PermValue", _PermValue);
cm.Parameters.AddWithValue("@PermAD", _PermAD);
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
// Output Calculated Columns
SqlParameter param_PID = new SqlParameter("@newPID", SqlDbType.Int);
param_PID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_PID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_PID = (int)cm.Parameters["@newPID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("Permission.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Permission.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int pid, int rid, int permLevel, int versionType, int permValue, int permAD, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addPermission";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@RID", rid);
cm.Parameters.AddWithValue("@PermLevel", permLevel);
cm.Parameters.AddWithValue("@VersionType", versionType);
cm.Parameters.AddWithValue("@PermValue", permValue);
cm.Parameters.AddWithValue("@PermAD", permAD);
cm.Parameters.AddWithValue("@StartDate", startDate.DBValue);
cm.Parameters.AddWithValue("@EndDate", endDate.DBValue);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
// Output Calculated Columns
SqlParameter param_PID = new SqlParameter("@newPID", SqlDbType.Int);
param_PID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_PID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
pid = (int)cm.Parameters["@newPID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Permission.Add", ex);
throw new DbCslaException("Permission.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updatePermission";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@PID", _PID);
cm.Parameters.AddWithValue("@RID", _RID);
cm.Parameters.AddWithValue("@PermLevel", _PermLevel);
cm.Parameters.AddWithValue("@VersionType", _VersionType);
cm.Parameters.AddWithValue("@PermValue", _PermValue);
cm.Parameters.AddWithValue("@PermAD", _PermAD);
cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue);
cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("Permission.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int pid, int rid, int permLevel, int versionType, int permValue, int permAD, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updatePermission";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@PID", pid);
cm.Parameters.AddWithValue("@RID", rid);
cm.Parameters.AddWithValue("@PermLevel", permLevel);
cm.Parameters.AddWithValue("@VersionType", versionType);
cm.Parameters.AddWithValue("@PermValue", permValue);
cm.Parameters.AddWithValue("@PermAD", permAD);
cm.Parameters.AddWithValue("@StartDate", startDate.DBValue);
cm.Parameters.AddWithValue("@EndDate", endDate.DBValue);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Permission.Update", ex);
throw new DbCslaException("Permission.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_PID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deletePermission";
cm.Parameters.AddWithValue("@PID", criteria.PID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Permission.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Permission.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int pid)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deletePermission";
// Input PK Fields
cm.Parameters.AddWithValue("@PID", pid);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Permission.Remove", ex);
throw new DbCslaException("Permission.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int pid)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(pid));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _PID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int pid)
{
_PID = pid;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsPermission";
cm.Parameters.AddWithValue("@PID", _PID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Permission.DataPortal_Execute", ex);
throw new DbCslaException("Permission.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultPermAD
{
get { return 0; }
}
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create PermissionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Permission
// {
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,192 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// PermissionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class PermissionInfo : ReadOnlyBase<PermissionInfo>
{
#region Business Methods
private int _PID;
[System.ComponentModel.DataObjectField(true, true)]
public int PID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PID;
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RID;
}
}
private int _PermLevel;
/// <summary>
/// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments
/// </summary>
public int PermLevel
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermLevel;
}
}
private int _VersionType;
/// <summary>
/// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionType;
}
}
private int _PermValue;
/// <summary>
/// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All)
/// </summary>
public int PermValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermValue;
}
}
private int _PermAD;
/// <summary>
/// 0 - Allow, 1 - Deny
/// </summary>
public int PermAD
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermAD;
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UsrID;
}
}
// TODO: Replace base PermissionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PermissionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check PermissionInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current PermissionInfo</returns>
protected override object GetIdValue()
{
return _PID;
}
#endregion
#region Factory Methods
private PermissionInfo()
{ /* require use of factory methods */ }
public Permission Get()
{
return Permission.Get(_PID);
}
#endregion
#region Data Access Portal
internal PermissionInfo(SafeDataReader dr)
{
try
{
_PID = dr.GetInt32("PID");
_RID = dr.GetInt32("RID");
_PermLevel = dr.GetInt32("PermLevel");
_VersionType = dr.GetInt32("VersionType");
_PermValue = dr.GetInt32("PermValue");
_PermAD = dr.GetInt32("PermAD");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
}
catch (Exception ex)
{
Database.LogException("PermissionInfo.Constructor", ex);
throw new DbCslaException("PermissionInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// PermissionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class PermissionInfoList : ReadOnlyListBase<PermissionInfoList, PermissionInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static PermissionInfoList Get()
{
return DataPortal.Fetch<PermissionInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static PermissionInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<PermissionInfoList>(new FilteredCriteria(<criteria>));
//}
public static PermissionInfoList GetByRole(int rid)
{
return DataPortal.Fetch<PermissionInfoList>(new RoleCriteria(rid));
}
private PermissionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getPermissions";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new PermissionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("PermissionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("PermissionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class RoleCriteria
{
public RoleCriteria(int rid)
{
_RID = rid;
}
private int _RID;
public int RID
{
get { return _RID; }
set { _RID = value; }
}
}
private void DataPortal_Fetch(RoleCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getPermissionsByRole";
cm.Parameters.AddWithValue("@RID", criteria.RID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new PermissionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("PermissionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("PermissionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,805 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Procedure Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Procedure : BusinessBase<Procedure>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextProcID = -1;
public static int NextProcID
{
get { return _nextProcID--; }
}
private int _ProcID;
[System.ComponentModel.DataObjectField(true, true)]
public int ProcID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ProcID;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Number;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Number != value)
{
_Number = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Config != value)
{
_Config = value;
PropertyHasChanged();
}
}
}
private string _Format = string.Empty;
public string Format
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Format;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Format != value)
{
_Format = value;
PropertyHasChanged();
}
}
}
private int _StructureID;
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_StructureID != value)
{
_StructureID = value;
PropertyHasChanged();
}
}
}
private int _StructureStart;
public int StructureStart
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureStart;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_StructureStart != value)
{
_StructureStart = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base Procedure.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Procedure</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Procedure.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 Procedure</returns>
protected override object GetIdValue()
{
return _ProcID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Number");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 30));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Title");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Format", 2048));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(ProcID, "<Role(s)>");
//AuthorizationRules.AllowRead(Number, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(Format, "<Role(s)>");
//AuthorizationRules.AllowRead(StructureID, "<Role(s)>");
//AuthorizationRules.AllowRead(StructureStart, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(Format, "<Role(s)>");
//AuthorizationRules.AllowWrite(StructureID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StructureStart, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Procedure()
{/* require use of factory methods */}
public static Procedure New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Procedure");
return DataPortal.Create<Procedure>();
}
public static Procedure New(string number, string title, string config, string format, int structureID, int structureStart)
{
Procedure tmp = Procedure.New();
tmp.Number = number;
tmp.Title = title;
tmp.Config = config;
tmp.Format = format;
tmp.StructureID = structureID;
tmp.StructureStart = structureStart;
return tmp;
}
public static Procedure MakeProcedure(string number, string title, string config, string format, int structureID, int structureStart)
{
Procedure tmp = Procedure.New(number, title, config, format, structureID, structureStart);
tmp.Save();
return tmp;
}
public static Procedure MakeProcedure(string number, string title, string config, string format, int structureID, int structureStart, DateTime dts, string userID)
{
Procedure tmp = Procedure.New(number, title, config, format, structureID, structureStart);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static Procedure Get(int procID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Procedure");
return DataPortal.Fetch<Procedure>(new PKCriteria(procID));
}
public static Procedure Get(SafeDataReader dr)
{
if (dr.Read()) return new Procedure(dr);
return null;
}
private Procedure(SafeDataReader dr)
{
_ProcID = dr.GetInt32("ProcID");
_Number = dr.GetString("Number");
_Title = dr.GetString("Title");
_Config = dr.GetString("Config");
_Format = dr.GetString("Format");
_StructureID = dr.GetInt32("StructureID");
_StructureStart = dr.GetInt32("StructureStart");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int procID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Procedure");
DataPortal.Delete(new PKCriteria(procID));
}
public override Procedure Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Procedure");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Procedure");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Procedure");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _ProcID;
public int ProcID
{ get { return _ProcID; } }
public PKCriteria(int procID)
{
_ProcID = procID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_ProcID = NextProcID;
// Database Defaults
_StructureID = ext.DefaultStructureID;
_StructureStart = ext.DefaultStructureStart;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getProcedure";
cm.Parameters.AddWithValue("@ProcID", criteria.ProcID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_ProcID = dr.GetInt32("ProcID");
_Number = dr.GetString("Number");
_Title = dr.GetString("Title");
_Config = dr.GetString("Config");
_Format = dr.GetString("Format");
_StructureID = dr.GetInt32("StructureID");
_StructureStart = dr.GetInt32("StructureStart");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Procedure.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Procedure.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addProcedure";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@Number", _Number);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@Format", _Format);
cm.Parameters.AddWithValue("@StructureID", _StructureID);
cm.Parameters.AddWithValue("@StructureStart", _StructureStart);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_ProcID = new SqlParameter("@newProcID", SqlDbType.Int);
param_ProcID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ProcID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_ProcID = (int)cm.Parameters["@newProcID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("Procedure.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Procedure.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int procID, string number, string title, string config, string format, int structureID, int structureStart, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addProcedure";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@Number", number);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@Format", format);
cm.Parameters.AddWithValue("@StructureID", structureID);
cm.Parameters.AddWithValue("@StructureStart", structureStart);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_ProcID = new SqlParameter("@newProcID", SqlDbType.Int);
param_ProcID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ProcID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
procID = (int)cm.Parameters["@newProcID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Procedure.Add", ex);
throw new DbCslaException("Procedure.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateProcedure";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@ProcID", _ProcID);
cm.Parameters.AddWithValue("@Number", _Number);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@Format", _Format);
cm.Parameters.AddWithValue("@StructureID", _StructureID);
cm.Parameters.AddWithValue("@StructureStart", _StructureStart);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("Procedure.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int procID, string number, string title, string config, string format, int structureID, int structureStart, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateProcedure";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ProcID", procID);
cm.Parameters.AddWithValue("@Number", number);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@Format", format);
cm.Parameters.AddWithValue("@StructureID", structureID);
cm.Parameters.AddWithValue("@StructureStart", structureStart);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Procedure.Update", ex);
throw new DbCslaException("Procedure.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_ProcID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteProcedure";
cm.Parameters.AddWithValue("@ProcID", criteria.ProcID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Procedure.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Procedure.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int procID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteProcedure";
// Input PK Fields
cm.Parameters.AddWithValue("@ProcID", procID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Procedure.Remove", ex);
throw new DbCslaException("Procedure.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int procID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(procID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _ProcID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int procID)
{
_ProcID = procID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsProcedure";
cm.Parameters.AddWithValue("@ProcID", _ProcID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Procedure.DataPortal_Execute", ex);
throw new DbCslaException("Procedure.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultStructureID
{
get { return 0; }
}
public virtual int DefaultStructureStart
{
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create ProcedureExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Procedure
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultStructureID
// {
// get { return 0; }
// }
// public virtual int DefaultStructureStart
// {
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,169 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ProcedureInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ProcedureInfo : ReadOnlyBase<ProcedureInfo>
{
#region Business Methods
private int _ProcID;
[System.ComponentModel.DataObjectField(true, true)]
public int ProcID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ProcID;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Number;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Title;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private string _Format = string.Empty;
public string Format
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Format;
}
}
private int _StructureID;
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
}
private int _StructureStart;
public int StructureStart
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureStart;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
// TODO: Replace base ProcedureInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ProcedureInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ProcedureInfo.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 ProcedureInfo</returns>
protected override object GetIdValue()
{
return _ProcID;
}
#endregion
#region Factory Methods
private ProcedureInfo()
{ /* require use of factory methods */ }
public Procedure Get()
{
return Procedure.Get(_ProcID);
}
#endregion
#region Data Access Portal
internal ProcedureInfo(SafeDataReader dr)
{
try
{
_ProcID = dr.GetInt32("ProcID");
_Number = dr.GetString("Number");
_Title = dr.GetString("Title");
_Config = dr.GetString("Config");
_Format = dr.GetString("Format");
_StructureID = dr.GetInt32("StructureID");
_StructureStart = dr.GetInt32("StructureStart");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
Database.LogException("ProcedureInfo.Constructor", ex);
throw new DbCslaException("ProcedureInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ProcedureInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ProcedureInfoList : ReadOnlyListBase<ProcedureInfoList, ProcedureInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static ProcedureInfoList Get()
{
return DataPortal.Fetch<ProcedureInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static ProcedureInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<ProcedureInfoList>(new FilteredCriteria(<criteria>));
//}
private ProcedureInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getProcedures";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ProcedureInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ProcedureInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ProcedureInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,666 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RoUsage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoUsage : BusinessBase<RoUsage>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextROUsageId = -1;
public static int NextROUsageId
{
get { return _nextROUsageId--; }
}
private int _ROUsageId;
[System.ComponentModel.DataObjectField(true, true)]
public int ROUsageId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ROUsageId;
}
}
private int _StructureID;
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_StructureID != value)
{
_StructureID = value;
PropertyHasChanged();
}
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ROID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base RoUsage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoUsage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RoUsage.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 RoUsage</returns>
protected override object GetIdValue()
{
return _ROUsageId;
}
#endregion
#region ValidationRules
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.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(StructureID, "<Role(s)>");
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StructureID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private RoUsage()
{/* require use of factory methods */}
public static RoUsage New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a RoUsage");
return DataPortal.Create<RoUsage>();
}
public static RoUsage New(int structureID, string roid)
{
RoUsage tmp = RoUsage.New();
tmp.StructureID = structureID;
tmp.ROID = roid;
return tmp;
}
public static RoUsage MakeRoUsage(int structureID, string roid)
{
RoUsage tmp = RoUsage.New(structureID, roid);
tmp.Save();
return tmp;
}
public static RoUsage MakeRoUsage(int structureID, string roid, DateTime dts, string userID)
{
RoUsage tmp = RoUsage.New(structureID, roid);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static RoUsage Get(int rOUsageId)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a RoUsage");
return DataPortal.Fetch<RoUsage>(new PKCriteria(rOUsageId));
}
public static RoUsage Get(SafeDataReader dr)
{
if (dr.Read()) return new RoUsage(dr);
return null;
}
private RoUsage(SafeDataReader dr)
{
_ROUsageId = dr.GetInt32("ROUsageId");
_StructureID = dr.GetInt32("StructureID");
_ROID = dr.GetString("ROID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int rOUsageId)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a RoUsage");
DataPortal.Delete(new PKCriteria(rOUsageId));
}
public override RoUsage Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a RoUsage");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a RoUsage");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a RoUsage");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _ROUsageId;
public int ROUsageId
{ get { return _ROUsageId; } }
public PKCriteria(int rOUsageId)
{
_ROUsageId = rOUsageId;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_ROUsageId = NextROUsageId;
// Database Defaults
_StructureID = ext.DefaultStructureID;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRoUsage";
cm.Parameters.AddWithValue("@ROUsageId", criteria.ROUsageId);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_ROUsageId = dr.GetInt32("ROUsageId");
_StructureID = dr.GetInt32("StructureID");
_ROID = dr.GetString("ROID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("RoUsage.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("RoUsage.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addRoUsage";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StructureID", _StructureID);
cm.Parameters.AddWithValue("@ROID", _ROID);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_ROUsageId = new SqlParameter("@newROUsageId", SqlDbType.Int);
param_ROUsageId.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ROUsageId);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_ROUsageId = (int)cm.Parameters["@newROUsageId"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("RoUsage.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("RoUsage.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int rOUsageId, int structureID, string roid, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addRoUsage";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StructureID", structureID);
cm.Parameters.AddWithValue("@ROID", roid);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_ROUsageId = new SqlParameter("@newROUsageId", SqlDbType.Int);
param_ROUsageId.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ROUsageId);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
rOUsageId = (int)cm.Parameters["@newROUsageId"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("RoUsage.Add", ex);
throw new DbCslaException("RoUsage.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateRoUsage";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@ROUsageId", _ROUsageId);
cm.Parameters.AddWithValue("@StructureID", _StructureID);
cm.Parameters.AddWithValue("@ROID", _ROID);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("RoUsage.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int rOUsageId, int structureID, string roid, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateRoUsage";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@ROUsageId", rOUsageId);
cm.Parameters.AddWithValue("@StructureID", structureID);
cm.Parameters.AddWithValue("@ROID", roid);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("RoUsage.Update", ex);
throw new DbCslaException("RoUsage.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_ROUsageId));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteRoUsage";
cm.Parameters.AddWithValue("@ROUsageId", criteria.ROUsageId);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("RoUsage.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("RoUsage.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int rOUsageId)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteRoUsage";
// Input PK Fields
cm.Parameters.AddWithValue("@ROUsageId", rOUsageId);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("RoUsage.Remove", ex);
throw new DbCslaException("RoUsage.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int rOUsageId)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(rOUsageId));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _ROUsageId;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int rOUsageId)
{
_ROUsageId = rOUsageId;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsRoUsage";
cm.Parameters.AddWithValue("@ROUsageId", _ROUsageId);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("RoUsage.DataPortal_Execute", ex);
throw new DbCslaException("RoUsage.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultStructureID
{
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create RoUsageExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class RoUsage
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultStructureID
// {
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,125 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RoUsageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoUsageInfo : ReadOnlyBase<RoUsageInfo>
{
#region Business Methods
private int _ROUsageId;
[System.ComponentModel.DataObjectField(true, true)]
public int ROUsageId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ROUsageId;
}
}
private int _StructureID;
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ROID;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
// TODO: Replace base RoUsageInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoUsageInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RoUsageInfo.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current RoUsageInfo</returns>
protected override object GetIdValue()
{
return _ROUsageId;
}
#endregion
#region Factory Methods
private RoUsageInfo()
{ /* require use of factory methods */ }
public RoUsage Get()
{
return RoUsage.Get(_ROUsageId);
}
#endregion
#region Data Access Portal
internal RoUsageInfo(SafeDataReader dr)
{
try
{
_ROUsageId = dr.GetInt32("ROUsageId");
_StructureID = dr.GetInt32("StructureID");
_ROID = dr.GetString("ROID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
Database.LogException("RoUsageInfo.Constructor", ex);
throw new DbCslaException("RoUsageInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RoUsageInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoUsageInfoList : ReadOnlyListBase<RoUsageInfoList, RoUsageInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static RoUsageInfoList Get()
{
return DataPortal.Fetch<RoUsageInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static RoUsageInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<RoUsageInfoList>(new FilteredCriteria(<criteria>));
//}
public static RoUsageInfoList GetByStructure(int structureID)
{
return DataPortal.Fetch<RoUsageInfoList>(new StructureCriteria(structureID));
}
private RoUsageInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRoUsages";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new RoUsageInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("RoUsageInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StructureCriteria
{
public StructureCriteria(int structureID)
{
_StructureID = structureID;
}
private int _StructureID;
public int StructureID
{
get { return _StructureID; }
set { _StructureID = value; }
}
}
private void DataPortal_Fetch(StructureCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRoUsagesByStructure";
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new RoUsageInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("RoUsageInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,707 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Role Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Role : BusinessBase<Role>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextRID = -1;
public static int NextRID
{
get { return _nextRID--; }
}
private int _RID;
[System.ComponentModel.DataObjectField(true, true)]
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private RoleAssignments _RoleAssignments = RoleAssignments.New();
/// <summary>
/// Related Field
/// </summary>
public RoleAssignments RoleAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RoleAssignments;
}
}
private RolePermissions _RolePermissions = RolePermissions.New();
/// <summary>
/// Related Field
/// </summary>
public RolePermissions RolePermissions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RolePermissions;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _RoleAssignments.IsDirty || _RolePermissions.IsDirty; }
}
public override bool IsValid
{
get { return base.IsValid && _RoleAssignments.IsValid && _RolePermissions.IsValid; }
}
// TODO: Replace base Role.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Role</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Role.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 Role</returns>
protected override object GetIdValue()
{
return _RID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Name");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 50));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Title");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 250));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(RID, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Role()
{/* require use of factory methods */}
public static Role New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Role");
return DataPortal.Create<Role>();
}
public static Role New(string name, string title)
{
Role tmp = Role.New();
tmp.Name = name;
tmp.Title = title;
return tmp;
}
public static Role MakeRole(string name, string title)
{
Role tmp = Role.New(name, title);
tmp.Save();
return tmp;
}
public static Role MakeRole(string name, string title, DateTime dts, string usrID)
{
Role tmp = Role.New(name, title);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID;
tmp.Save();
return tmp;
}
public static Role Get(int rid)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Role");
return DataPortal.Fetch<Role>(new PKCriteria(rid));
}
public static Role Get(SafeDataReader dr)
{
if (dr.Read()) return new Role(dr);
return null;
}
private Role(SafeDataReader dr)
{
_RID = dr.GetInt32("RID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int rid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Role");
DataPortal.Delete(new PKCriteria(rid));
}
public override Role Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Role");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Role");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Role");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _RID;
public int RID
{ get { return _RID; } }
public PKCriteria(int rid)
{
_RID = rid;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_RID = NextRID;
// Database Defaults
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRole";
cm.Parameters.AddWithValue("@RID", criteria.RID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_RID = dr.GetInt32("RID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
// load child objects
dr.NextResult();
_RoleAssignments = RoleAssignments.Get(dr);
// load child objects
dr.NextResult();
_RolePermissions = RolePermissions.Get(dr);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Role.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Role.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addRole";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@Name", _Name);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
// Output Calculated Columns
SqlParameter param_RID = new SqlParameter("@newRID", SqlDbType.Int);
param_RID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_RID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_RID = (int)cm.Parameters["@newRID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
_RoleAssignments.Update(this, cn);
_RolePermissions.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Role.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Role.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int rid, string name, string title, DateTime dts, string usrID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addRole";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
// Output Calculated Columns
SqlParameter param_RID = new SqlParameter("@newRID", SqlDbType.Int);
param_RID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_RID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
rid = (int)cm.Parameters["@newRID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Role.Add", ex);
throw new DbCslaException("Role.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateRole";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@RID", _RID);
cm.Parameters.AddWithValue("@Name", _Name);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
_RoleAssignments.Update(this, cn);
_RolePermissions.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Role.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int rid, string name, string title, DateTime dts, string usrID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateRole";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@RID", rid);
cm.Parameters.AddWithValue("@Name", name);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Role.Update", ex);
throw new DbCslaException("Role.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_RID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteRole";
cm.Parameters.AddWithValue("@RID", criteria.RID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Role.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Role.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int rid)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteRole";
// Input PK Fields
cm.Parameters.AddWithValue("@RID", rid);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Role.Remove", ex);
throw new DbCslaException("Role.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int rid)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(rid));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _RID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int rid)
{
_RID = rid;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsRole";
cm.Parameters.AddWithValue("@RID", _RID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Role.DataPortal_Execute", ex);
throw new DbCslaException("Role.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create RoleExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Role
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,605 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RoleAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoleAssignment : BusinessBase<RoleAssignment>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _AID;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_GID != value)
{
_GID = value;
PropertyHasChanged();
}
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FolderID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FolderID != value)
{
_FolderID = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private int _Folder_ParentID;
/// <summary>
/// {child Folders.FolderID}
/// </summary>
public int Folder_ParentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_ParentID;
}
}
private int _Folder_DBID;
public int Folder_DBID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_DBID;
}
}
private string _Folder_Name = string.Empty;
public string Folder_Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_Name;
}
}
private string _Folder_Title = string.Empty;
public string Folder_Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_Title;
}
}
private string _Folder_Config = string.Empty;
public string Folder_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_Config;
}
}
private DateTime _Folder_DTS = new DateTime();
public DateTime Folder_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_DTS;
}
}
private string _Folder_UsrID = string.Empty;
public string Folder_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Folder_UsrID;
}
}
private string _Group_GroupName = string.Empty;
public string Group_GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_GroupName;
}
}
private int _Group_GroupType;
public int Group_GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_GroupType;
}
}
private string _Group_Config = string.Empty;
public string Group_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_Config;
}
}
private DateTime _Group_DTS = new DateTime();
public DateTime Group_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_DTS;
}
}
private string _Group_UsrID = string.Empty;
public string Group_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_UsrID;
}
}
// TODO: Check RoleAssignment.GetIdValue to assure that the ID returned is unique
/// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary>
/// <returns>A Unique ID for the current RoleAssignment</returns>
protected override object GetIdValue()
{
return _AID;
}
// TODO: Replace base RoleAssignment.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoleAssignment</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(AID, "<Role(s)>");
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static RoleAssignment New(int gid, int folderID)
{
return new RoleAssignment(Volian.CSLA.Library.Group.Get(gid), Volian.CSLA.Library.Folder.Get(folderID));
}
internal static RoleAssignment Get(SafeDataReader dr)
{
return new RoleAssignment(dr);
}
public RoleAssignment()
{
MarkAsChild();
_AID = Assignment.NextAID;
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
}
private RoleAssignment(Group group, Folder folder)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
_FolderID = folder.FolderID;
_Folder_ParentID = folder.ParentID;
_Folder_DBID = folder.DBID;
_Folder_Name = folder.Name;
_Folder_Title = folder.Title;
_Folder_Config = folder.Config;
_Folder_DTS = folder.DTS;
_Folder_UsrID = folder.UsrID;
_GID = group.GID;
_Group_GroupName = group.GroupName;
_Group_GroupType = group.GroupType;
_Group_Config = group.Config;
_Group_DTS = group.DTS;
_Group_UsrID = group.UsrID;
}
private RoleAssignment(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_AID = dr.GetInt32("AID");
_GID = dr.GetInt32("GID");
_FolderID = dr.GetInt32("FolderID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Folder_ParentID = dr.GetInt32("Folder_ParentID");
_Folder_DBID = dr.GetInt32("Folder_DBID");
_Folder_Name = dr.GetString("Folder_Name");
_Folder_Title = dr.GetString("Folder_Title");
_Folder_Config = dr.GetString("Folder_Config");
_Folder_DTS = dr.GetDateTime("Folder_DTS");
_Folder_UsrID = dr.GetString("Folder_UsrID");
_Group_GroupName = dr.GetString("Group_GroupName");
_Group_GroupType = dr.GetInt32("Group_GroupType");
_Group_Config = dr.GetString("Group_Config");
_Group_DTS = dr.GetDateTime("Group_DTS");
_Group_UsrID = dr.GetString("Group_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("RoleAssignment.Fetch", ex);
throw new DbCslaException("RoleAssignment.Fetch", ex);
}
MarkOld();
}
internal void Insert(Role role, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Assignment.Add(cn, ref _AID, _GID, role.RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(Role role, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Assignment.Update(cn, ref _AID, _GID, role.RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Role role, SqlConnection cn)
{
// 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;
Assignment.Remove(cn, _AID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create RoleAssignmentExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class RoleAssignment
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,142 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RoleAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoleAssignments : BusinessListBase<RoleAssignments, RoleAssignment>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// Many To Many
public RoleAssignment this[int folderID, int gid]
{
get
{
foreach (RoleAssignment assignment in this)
if (assignment.FolderID == folderID && assignment.GID == gid)
return assignment;
return null;
}
}
public RoleAssignment GetItem(int folderID, int gid)
{
foreach (RoleAssignment assignment in this)
if (assignment.FolderID == folderID && assignment.GID == gid)
return assignment;
return null;
}
public RoleAssignment Add(int gid, int folderID)
{
if (!Contains(gid, folderID))
{
RoleAssignment assignment = RoleAssignment.New(gid, folderID);
this.Add(assignment);
return assignment;
}
else
throw new InvalidOperationException("assignment already exists");
}
public void Remove(int folderID, int gid)
{
foreach (RoleAssignment assignment in this)
{
if (assignment.FolderID == folderID && assignment.GID == gid)
{
Remove(assignment);
break;
}
}
}
public bool Contains(int folderID, int gid)
{
foreach (RoleAssignment assignment in this)
if (assignment.FolderID == folderID && assignment.GID == gid)
return true;
return false;
}
public bool ContainsDeleted(int folderID, int gid)
{
foreach (RoleAssignment assignment in DeletedList)
if (assignment.FolderID == folderID && assignment.GID == gid)
return true;
return false;
}
#endregion
#region Factory Methods
internal static RoleAssignments New()
{
return new RoleAssignments();
}
internal static RoleAssignments Get(SafeDataReader dr)
{
return new RoleAssignments(dr);
}
private RoleAssignments()
{
MarkAsChild();
}
private RoleAssignments(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
// called to load data from the database
private void Fetch(SafeDataReader dr)
{
this.RaiseListChangedEvents = false;
while (dr.Read())
this.Add(RoleAssignment.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Role role, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (RoleAssignment obj in DeletedList)
obj.DeleteSelf(role, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (RoleAssignment obj in this)
{
if (obj.IsNew)
obj.Insert(role, cn);
else
obj.Update(role, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,177 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RoleInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoleInfo : ReadOnlyBase<RoleInfo>
{
#region Business Methods
private int _RID;
[System.ComponentModel.DataObjectField(true, true)]
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RID;
}
}
private string _Name = string.Empty;
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Name;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Title;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UsrID;
}
}
private int _Assignmentcount = 0;
/// <summary>
/// Count of Assignment for this Role
/// </summary>
public int AssignmentCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Assignmentcount;
}
}
private AssignmentInfoList _Assignments = null;
public AssignmentInfoList Assignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Assignments == null)
_Assignments = AssignmentInfoList.GetByRole(_RID);
return _Assignments;
}
}
private int _Permissioncount = 0;
/// <summary>
/// Count of Permission for this Role
/// </summary>
public int PermissionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Permissioncount;
}
}
private PermissionInfoList _Permissions = null;
public PermissionInfoList Permissions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Permissions == null)
_Permissions = PermissionInfoList.GetByRole(_RID);
return _Permissions;
}
}
// TODO: Replace base RoleInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RoleInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check RoleInfo.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 RoleInfo</returns>
protected override object GetIdValue()
{
return _RID;
}
#endregion
#region Factory Methods
private RoleInfo()
{ /* require use of factory methods */ }
public Role Get()
{
return Role.Get(_RID);
}
#endregion
#region Data Access Portal
internal RoleInfo(SafeDataReader dr)
{
try
{
_RID = dr.GetInt32("RID");
_Name = dr.GetString("Name");
_Title = dr.GetString("Title");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_Assignmentcount = dr.GetInt32("AssignmentCount");
_Permissioncount = dr.GetInt32("PermissionCount");
}
catch (Exception ex)
{
Database.LogException("RoleInfo.Constructor", ex);
throw new DbCslaException("RoleInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RoleInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoleInfoList : ReadOnlyListBase<RoleInfoList, RoleInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static RoleInfoList Get()
{
return DataPortal.Fetch<RoleInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static RoleInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<RoleInfoList>(new FilteredCriteria(<criteria>));
//}
private RoleInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getRoles";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new RoleInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("RoleInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("RoleInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,527 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RolePermission Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RolePermission : BusinessBase<RolePermission>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _PID;
[System.ComponentModel.DataObjectField(true, true)]
public int PID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PID;
}
}
private int _PermLevel;
/// <summary>
/// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments
/// </summary>
public int PermLevel
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermLevel;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_PermLevel != value)
{
_PermLevel = value;
PropertyHasChanged();
}
}
}
private int _VersionType;
/// <summary>
/// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All)
/// </summary>
public int VersionType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _VersionType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_VersionType != value)
{
_VersionType = value;
PropertyHasChanged();
}
}
}
private int _PermValue;
/// <summary>
/// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All)
/// </summary>
public int PermValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermValue;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_PermValue != value)
{
_PermValue = value;
PropertyHasChanged();
}
}
}
private int _PermAD;
/// <summary>
/// 0 - Allow, 1 - Deny
/// </summary>
public int PermAD
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PermAD;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_PermAD != value)
{
_PermAD = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check RolePermission.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 RolePermission</returns>
protected override object GetIdValue()
{
return _PID;
}
// TODO: Replace base RolePermission.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current RolePermission</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(PID, "<Role(s)>");
//AuthorizationRules.AllowRead(PermLevel, "<Role(s)>");
//AuthorizationRules.AllowWrite(PermLevel, "<Role(s)>");
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
//AuthorizationRules.AllowRead(PermValue, "<Role(s)>");
//AuthorizationRules.AllowWrite(PermValue, "<Role(s)>");
//AuthorizationRules.AllowRead(PermAD, "<Role(s)>");
//AuthorizationRules.AllowWrite(PermAD, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static RolePermission New(int permLevel, int versionType, int permValue)
{
return new RolePermission(permLevel, versionType, permValue);
}
internal static RolePermission Get(SafeDataReader dr)
{
return new RolePermission(dr);
}
public RolePermission()
{
MarkAsChild();
_PID = Permission.NextPID;
_PermAD = ext.DefaultPermAD;
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
}
private RolePermission(int permLevel, int versionType, int permValue)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_PermAD = ext.DefaultPermAD;
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
_PermLevel = permLevel;
_VersionType = versionType;
_PermValue = permValue;
}
private RolePermission(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_PID = dr.GetInt32("PID");
_PermLevel = dr.GetInt32("PermLevel");
_VersionType = dr.GetInt32("VersionType");
_PermValue = dr.GetInt32("PermValue");
_PermAD = dr.GetInt32("PermAD");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("RolePermission.Fetch", ex);
throw new DbCslaException("RolePermission.Fetch", ex);
}
MarkOld();
}
internal void Insert(Role role, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Permission.Add(cn, ref _PID, role.RID, _PermLevel, _VersionType, _PermValue, _PermAD, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(Role role, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Permission.Update(cn, ref _PID, role.RID, _PermLevel, _VersionType, _PermValue, _PermAD, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Role role, SqlConnection cn)
{
// 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;
Permission.Remove(cn, _PID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultPermAD
{
get { return 0; }
}
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create RolePermissionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class RolePermission
// {
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,137 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// RolePermissions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RolePermissions : BusinessListBase<RolePermissions, RolePermission>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// One To Many
public new RolePermission this[int pid]
{
get
{
foreach (RolePermission permission in this)
if (permission.PID == pid)
return permission;
return null;
}
}
public RolePermission GetItem(int pid)
{
foreach (RolePermission permission in this)
if (permission.PID == pid)
return permission;
return null;
}
public RolePermission Add(int permLevel, int versionType, int permValue)
{
RolePermission permission = RolePermission.New(permLevel, versionType, permValue);
this.Add(permission);
return permission;
}
public void Remove(int pid)
{
foreach (RolePermission permission in this)
{
if (permission.PID == pid)
{
Remove(permission);
break;
}
}
}
public bool Contains(int pid)
{
foreach (RolePermission permission in this)
if (permission.PID == pid)
return true;
return false;
}
public bool ContainsDeleted(int pid)
{
foreach (RolePermission permission in DeletedList)
if (permission.PID == pid)
return true;
return false;
}
#endregion
#region Factory Methods
internal static RolePermissions New()
{
return new RolePermissions();
}
internal static RolePermissions Get(SafeDataReader dr)
{
return new RolePermissions(dr);
}
private RolePermissions()
{
MarkAsChild();
}
private RolePermissions(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(RolePermission.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Role role, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (RolePermission obj in DeletedList)
obj.DeleteSelf(role, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (RolePermission obj in this)
{
if (obj.IsNew)
obj.Insert(role, cn);
else
obj.Update(role, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,804 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Section Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Section : BusinessBase<Section>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextSectID = -1;
public static int NextSectID
{
get { return _nextSectID--; }
}
private int _SectID;
[System.ComponentModel.DataObjectField(true, true)]
public int SectID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SectID;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Number;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Number != value)
{
_Number = value;
PropertyHasChanged();
}
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Title;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Title != value)
{
_Title = value;
PropertyHasChanged();
}
}
}
private byte _ContentType;
/// <summary>
/// 0 Nothing, 1 Structure, 2 Document
/// </summary>
public byte ContentType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ContentType != value)
{
_ContentType = value;
PropertyHasChanged();
}
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ContentID != value)
{
_ContentID = value;
PropertyHasChanged();
}
}
}
private string _Format = string.Empty;
public string Format
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Format;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Format != value)
{
_Format = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base Section.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Section</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Section.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 Section</returns>
protected override object GetIdValue()
{
return _SectID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 30));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Format", 2048));
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));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(SectID, "<Role(s)>");
//AuthorizationRules.AllowRead(Number, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentType, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(Format, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentType, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Format, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Section()
{/* require use of factory methods */}
public static Section New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Section");
return DataPortal.Create<Section>();
}
public static Section New(string number, string title, byte contentType, int contentID, string format, string config)
{
Section tmp = Section.New();
tmp.Number = number;
tmp.Title = title;
tmp.ContentType = contentType;
tmp.ContentID = contentID;
tmp.Format = format;
tmp.Config = config;
return tmp;
}
public static Section MakeSection(string number, string title, byte contentType, int contentID, string format, string config)
{
Section tmp = Section.New(number, title, contentType, contentID, format, config);
tmp.Save();
return tmp;
}
public static Section MakeSection(string number, string title, byte contentType, int contentID, string format, string config, DateTime dts, string userID)
{
Section tmp = Section.New(number, title, contentType, contentID, format, config);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static Section Get(int sectID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Section");
return DataPortal.Fetch<Section>(new PKCriteria(sectID));
}
public static Section Get(SafeDataReader dr)
{
if (dr.Read()) return new Section(dr);
return null;
}
private Section(SafeDataReader dr)
{
_SectID = dr.GetInt32("SectID");
_Number = dr.GetString("Number");
_Title = dr.GetString("Title");
_ContentType = dr.GetByte("ContentType");
_ContentID = dr.GetInt32("ContentID");
_Format = dr.GetString("Format");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int sectID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Section");
DataPortal.Delete(new PKCriteria(sectID));
}
public override Section Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Section");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Section");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Section");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _SectID;
public int SectID
{ get { return _SectID; } }
public PKCriteria(int sectID)
{
_SectID = sectID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_SectID = NextSectID;
// Database Defaults
_ContentType = ext.DefaultContentType;
_ContentID = ext.DefaultContentID;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getSection";
cm.Parameters.AddWithValue("@SectID", criteria.SectID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_SectID = dr.GetInt32("SectID");
_Number = dr.GetString("Number");
_Title = dr.GetString("Title");
_ContentType = dr.GetByte("ContentType");
_ContentID = dr.GetInt32("ContentID");
_Format = dr.GetString("Format");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Section.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Section.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addSection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@Number", _Number);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@ContentType", _ContentType);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@Format", _Format);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_SectID = new SqlParameter("@newSectID", SqlDbType.Int);
param_SectID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_SectID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_SectID = (int)cm.Parameters["@newSectID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("Section.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Section.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int sectID, string number, string title, byte contentType, int contentID, string format, string config, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addSection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@Number", number);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@ContentType", contentType);
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@Format", format);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_SectID = new SqlParameter("@newSectID", SqlDbType.Int);
param_SectID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_SectID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
sectID = (int)cm.Parameters["@newSectID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Section.Add", ex);
throw new DbCslaException("Section.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateSection";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@SectID", _SectID);
cm.Parameters.AddWithValue("@Number", _Number);
cm.Parameters.AddWithValue("@Title", _Title);
cm.Parameters.AddWithValue("@ContentType", _ContentType);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@Format", _Format);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("Section.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int sectID, string number, string title, byte contentType, int contentID, string format, string config, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateSection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@SectID", sectID);
cm.Parameters.AddWithValue("@Number", number);
cm.Parameters.AddWithValue("@Title", title);
cm.Parameters.AddWithValue("@ContentType", contentType);
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@Format", format);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Section.Update", ex);
throw new DbCslaException("Section.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_SectID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteSection";
cm.Parameters.AddWithValue("@SectID", criteria.SectID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Section.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Section.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int sectID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteSection";
// Input PK Fields
cm.Parameters.AddWithValue("@SectID", sectID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Section.Remove", ex);
throw new DbCslaException("Section.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int sectID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(sectID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _SectID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int sectID)
{
_SectID = sectID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsSection";
cm.Parameters.AddWithValue("@SectID", _SectID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Section.DataPortal_Execute", ex);
throw new DbCslaException("Section.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual byte DefaultContentType
{
get { return 0; }
}
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create SectionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Section
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual byte DefaultContentType
// {
// get { return 0; }
// }
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,198 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// SectionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class SectionInfo : ReadOnlyBase<SectionInfo>
{
#region Business Methods
private int _SectID;
[System.ComponentModel.DataObjectField(true, true)]
public int SectID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SectID;
}
}
private string _Number = string.Empty;
public string Number
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Number;
}
}
private string _Title = string.Empty;
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Title;
}
}
private byte _ContentType;
/// <summary>
/// 0 Nothing, 1 Structure, 2 Document
/// </summary>
public byte ContentType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentType;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentID;
}
}
private string _Format = string.Empty;
public string Format
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Format;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
private int _ZSectioncount = 0;
/// <summary>
/// Count of ZSection for this Section
/// </summary>
public int ZSectionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ZSectioncount;
}
}
private ZSectionInfoList _ZSections = null;
public ZSectionInfoList ZSections
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_ZSections == null)
_ZSections = ZSectionInfoList.GetBySection(_SectID);
return _ZSections;
}
}
// TODO: Replace base SectionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current SectionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check SectionInfo.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 SectionInfo</returns>
protected override object GetIdValue()
{
return _SectID;
}
#endregion
#region Factory Methods
private SectionInfo()
{ /* require use of factory methods */ }
public Section Get()
{
return Section.Get(_SectID);
}
#endregion
#region Data Access Portal
internal SectionInfo(SafeDataReader dr)
{
try
{
_SectID = dr.GetInt32("SectID");
_Number = dr.GetString("Number");
_Title = dr.GetString("Title");
_ContentType = dr.GetByte("ContentType");
_ContentID = dr.GetInt32("ContentID");
_Format = dr.GetString("Format");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ZSectioncount = dr.GetInt32("ZSectionCount");
}
catch (Exception ex)
{
Database.LogException("SectionInfo.Constructor", ex);
throw new DbCslaException("SectionInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// SectionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class SectionInfoList : ReadOnlyListBase<SectionInfoList, SectionInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static SectionInfoList Get()
{
return DataPortal.Fetch<SectionInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static SectionInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<SectionInfoList>(new FilteredCriteria(<criteria>));
//}
private SectionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getSections";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new SectionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("SectionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("SectionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,714 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Step Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Step : BusinessBase<Step>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextStepID = -1;
public static int NextStepID
{
get { return _nextStepID--; }
}
private int _StepID;
[System.ComponentModel.DataObjectField(true, true)]
public int StepID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepID;
}
}
private string _StepType = string.Empty;
public string StepType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_StepType != value)
{
_StepType = value;
PropertyHasChanged();
}
}
}
private int _TextMID;
public int TextMID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextMID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_TextMID != value)
{
_TextMID = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private StepStepTexts _StepStepTexts = StepStepTexts.New();
/// <summary>
/// Related Field
/// </summary>
public StepStepTexts StepStepTexts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepStepTexts;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _StepStepTexts.IsDirty; }
}
public override bool IsValid
{
get { return base.IsValid && _StepStepTexts.IsValid; }
}
// TODO: Replace base Step.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Step</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Step.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 Step</returns>
protected override object GetIdValue()
{
return _StepID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("StepType", 2));
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));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(StepID, "<Role(s)>");
//AuthorizationRules.AllowRead(StepType, "<Role(s)>");
//AuthorizationRules.AllowRead(TextMID, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StepType, "<Role(s)>");
//AuthorizationRules.AllowWrite(TextMID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Step()
{/* require use of factory methods */}
public static Step New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Step");
return DataPortal.Create<Step>();
}
public static Step New(string stepType, int textMID, string config)
{
Step tmp = Step.New();
tmp.StepType = stepType;
tmp.TextMID = textMID;
tmp.Config = config;
return tmp;
}
public static Step MakeStep(string stepType, int textMID, string config)
{
Step tmp = Step.New(stepType, textMID, config);
tmp.Save();
return tmp;
}
public static Step MakeStep(string stepType, int textMID, string config, DateTime dts, string userID)
{
Step tmp = Step.New(stepType, textMID, config);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static Step Get(int stepID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Step");
return DataPortal.Fetch<Step>(new PKCriteria(stepID));
}
public static Step Get(SafeDataReader dr)
{
if (dr.Read()) return new Step(dr);
return null;
}
private Step(SafeDataReader dr)
{
_StepID = dr.GetInt32("StepID");
_StepType = dr.GetString("StepType");
_TextMID = dr.GetInt32("TextMID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int stepID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Step");
DataPortal.Delete(new PKCriteria(stepID));
}
public override Step Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Step");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Step");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Step");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _StepID;
public int StepID
{ get { return _StepID; } }
public PKCriteria(int stepID)
{
_StepID = stepID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_StepID = NextStepID;
// Database Defaults
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStep";
cm.Parameters.AddWithValue("@StepID", criteria.StepID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_StepID = dr.GetInt32("StepID");
_StepType = dr.GetString("StepType");
_TextMID = dr.GetInt32("TextMID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
// load child objects
dr.NextResult();
_StepStepTexts = StepStepTexts.Get(dr);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Step.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Step.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addStep";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepType", _StepType);
cm.Parameters.AddWithValue("@TextMID", _TextMID);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_StepID = new SqlParameter("@newStepID", SqlDbType.Int);
param_StepID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_StepID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_StepID = (int)cm.Parameters["@newStepID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
_StepStepTexts.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Step.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Step.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int stepID, string stepType, int textMID, string config, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addStep";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepType", stepType);
cm.Parameters.AddWithValue("@TextMID", textMID);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_StepID = new SqlParameter("@newStepID", SqlDbType.Int);
param_StepID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_StepID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
stepID = (int)cm.Parameters["@newStepID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Step.Add", ex);
throw new DbCslaException("Step.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateStep";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@StepID", _StepID);
cm.Parameters.AddWithValue("@StepType", _StepType);
cm.Parameters.AddWithValue("@TextMID", _TextMID);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
_StepStepTexts.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Step.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int stepID, string stepType, int textMID, string config, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateStep";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepID", stepID);
cm.Parameters.AddWithValue("@StepType", stepType);
cm.Parameters.AddWithValue("@TextMID", textMID);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Step.Update", ex);
throw new DbCslaException("Step.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_StepID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteStep";
cm.Parameters.AddWithValue("@StepID", criteria.StepID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Step.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Step.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int stepID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteStep";
// Input PK Fields
cm.Parameters.AddWithValue("@StepID", stepID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Step.Remove", ex);
throw new DbCslaException("Step.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int stepID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(stepID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _StepID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int stepID)
{
_StepID = stepID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsStep";
cm.Parameters.AddWithValue("@StepID", _StepID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Step.DataPortal_Execute", ex);
throw new DbCslaException("Step.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create StepExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Step
// {
// partial class Extension : 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,188 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StepInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StepInfo : ReadOnlyBase<StepInfo>
{
#region Business Methods
private int _StepID;
[System.ComponentModel.DataObjectField(true, true)]
public int StepID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepID;
}
}
private string _StepType = string.Empty;
public string StepType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepType;
}
}
private int _TextMID;
public int TextMID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextMID;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
private int _StepTextcount = 0;
/// <summary>
/// Count of StepText for this Step
/// </summary>
public int StepTextCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepTextcount;
}
}
private StepTextInfoList _StepTexts = null;
public StepTextInfoList StepTexts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_StepTexts == null)
_StepTexts = StepTextInfoList.GetByStep(_StepID);
return _StepTexts;
}
}
private int _ZStepcount = 0;
/// <summary>
/// Count of ZStep for this Step
/// </summary>
public int ZStepCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ZStepcount;
}
}
private ZStepInfoList _ZSteps = null;
public ZStepInfoList ZSteps
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_ZSteps == null)
_ZSteps = ZStepInfoList.GetByStep(_StepID);
return _ZSteps;
}
}
// TODO: Replace base StepInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StepInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check StepInfo.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 StepInfo</returns>
protected override object GetIdValue()
{
return _StepID;
}
#endregion
#region Factory Methods
private StepInfo()
{ /* require use of factory methods */ }
public Step Get()
{
return Step.Get(_StepID);
}
#endregion
#region Data Access Portal
internal StepInfo(SafeDataReader dr)
{
try
{
_StepID = dr.GetInt32("StepID");
_StepType = dr.GetString("StepType");
_TextMID = dr.GetInt32("TextMID");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_StepTextcount = dr.GetInt32("StepTextCount");
_ZStepcount = dr.GetInt32("ZStepCount");
}
catch (Exception ex)
{
Database.LogException("StepInfo.Constructor", ex);
throw new DbCslaException("StepInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StepInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StepInfoList : ReadOnlyListBase<StepInfoList, StepInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static StepInfoList Get()
{
return DataPortal.Fetch<StepInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static StepInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<StepInfoList>(new FilteredCriteria(<criteria>));
//}
public static StepInfoList GetByTextM(int textMID)
{
return DataPortal.Fetch<StepInfoList>(new TextMCriteria(textMID));
}
private StepInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getSteps";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new StepInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("StepInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("StepInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class TextMCriteria
{
public TextMCriteria(int textMID)
{
_TextMID = textMID;
}
private int _TextMID;
public int TextMID
{
get { return _TextMID; }
set { _TextMID = value; }
}
}
private void DataPortal_Fetch(TextMCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStepsByTextM";
cm.Parameters.AddWithValue("@TextMID", criteria.TextMID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new StepInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("StepInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("StepInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,358 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StepStepText Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StepStepText : BusinessBase<StepStepText>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _StepTextMID;
[System.ComponentModel.DataObjectField(true, true)]
public int StepTextMID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepTextMID;
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ItemType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ItemType != value)
{
_ItemType = value;
PropertyHasChanged();
}
}
}
private string _TextM = string.Empty;
public string TextM
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextM;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_TextM != value)
{
_TextM = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check StepStepText.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 StepStepText</returns>
protected override object GetIdValue()
{
return _StepTextMID;
}
// TODO: Replace base StepStepText.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StepStepText</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "TextM");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("TextM", 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(StepTextMID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemType, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemType, "<Role(s)>");
//AuthorizationRules.AllowRead(TextM, "<Role(s)>");
//AuthorizationRules.AllowWrite(TextM, "<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 StepStepText New(int itemType, string textM)
{
return new StepStepText(itemType, textM);
}
internal static StepStepText Get(SafeDataReader dr)
{
return new StepStepText(dr);
}
public StepStepText()
{
MarkAsChild();
_StepTextMID = StepText.NextStepTextMID;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
}
private StepStepText(int itemType, string textM)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
_ItemType = itemType;
_TextM = textM;
}
private StepStepText(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_StepTextMID = dr.GetInt32("StepTextMID");
_ItemType = dr.GetInt32("ItemType");
_TextM = dr.GetString("TextM");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("StepStepText.Fetch", ex);
throw new DbCslaException("StepStepText.Fetch", ex);
}
MarkOld();
}
internal void Insert(Step step, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = StepText.Add(cn, ref _StepTextMID, step.StepID, _ItemType, _TextM, _DTS, _UserID);
MarkOld();
}
internal void Update(Step step, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = StepText.Update(cn, ref _StepTextMID, step.StepID, _ItemType, _TextM, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Step step, SqlConnection cn)
{
// 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;
StepText.Remove(cn, _StepTextMID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create StepStepTextExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class StepStepText
// {
// partial class Extension : 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,137 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StepStepTexts Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StepStepTexts : BusinessListBase<StepStepTexts, StepStepText>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// One To Many
public new StepStepText this[int stepTextMID]
{
get
{
foreach (StepStepText stepText in this)
if (stepText.StepTextMID == stepTextMID)
return stepText;
return null;
}
}
public StepStepText GetItem(int stepTextMID)
{
foreach (StepStepText stepText in this)
if (stepText.StepTextMID == stepTextMID)
return stepText;
return null;
}
public StepStepText Add(int itemType, string textM)
{
StepStepText stepText = StepStepText.New(itemType, textM);
this.Add(stepText);
return stepText;
}
public void Remove(int stepTextMID)
{
foreach (StepStepText stepText in this)
{
if (stepText.StepTextMID == stepTextMID)
{
Remove(stepText);
break;
}
}
}
public bool Contains(int stepTextMID)
{
foreach (StepStepText stepText in this)
if (stepText.StepTextMID == stepTextMID)
return true;
return false;
}
public bool ContainsDeleted(int stepTextMID)
{
foreach (StepStepText stepText in DeletedList)
if (stepText.StepTextMID == stepTextMID)
return true;
return false;
}
#endregion
#region Factory Methods
internal static StepStepTexts New()
{
return new StepStepTexts();
}
internal static StepStepTexts Get(SafeDataReader dr)
{
return new StepStepTexts(dr);
}
private StepStepTexts()
{
MarkAsChild();
}
private StepStepTexts(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(StepStepText.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Step step, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (StepStepText obj in DeletedList)
obj.DeleteSelf(step, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (StepStepText obj in this)
{
if (obj.IsNew)
obj.Insert(step, cn);
else
obj.Update(step, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,686 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StepText Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StepText : BusinessBase<StepText>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextStepTextMID = -1;
public static int NextStepTextMID
{
get { return _nextStepTextMID--; }
}
private int _StepTextMID;
[System.ComponentModel.DataObjectField(true, true)]
public int StepTextMID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepTextMID;
}
}
private int _StepID;
public int StepID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_StepID != value)
{
_StepID = value;
PropertyHasChanged();
}
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ItemType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ItemType != value)
{
_ItemType = value;
PropertyHasChanged();
}
}
}
private string _TextM = string.Empty;
public string TextM
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextM;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_TextM != value)
{
_TextM = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base StepText.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StepText</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check StepText.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 StepText</returns>
protected override object GetIdValue()
{
return _StepTextMID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "TextM");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("TextM", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(StepTextMID, "<Role(s)>");
//AuthorizationRules.AllowRead(StepID, "<Role(s)>");
//AuthorizationRules.AllowRead(ItemType, "<Role(s)>");
//AuthorizationRules.AllowRead(TextM, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(StepID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ItemType, "<Role(s)>");
//AuthorizationRules.AllowWrite(TextM, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private StepText()
{/* require use of factory methods */}
public static StepText New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a StepText");
return DataPortal.Create<StepText>();
}
public static StepText New(int stepID, int itemType, string textM)
{
StepText tmp = StepText.New();
tmp.StepID = stepID;
tmp.ItemType = itemType;
tmp.TextM = textM;
return tmp;
}
public static StepText MakeStepText(int stepID, int itemType, string textM)
{
StepText tmp = StepText.New(stepID, itemType, textM);
tmp.Save();
return tmp;
}
public static StepText MakeStepText(int stepID, int itemType, string textM, DateTime dts, string userID)
{
StepText tmp = StepText.New(stepID, itemType, textM);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static StepText Get(int stepTextMID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a StepText");
return DataPortal.Fetch<StepText>(new PKCriteria(stepTextMID));
}
public static StepText Get(SafeDataReader dr)
{
if (dr.Read()) return new StepText(dr);
return null;
}
private StepText(SafeDataReader dr)
{
_StepTextMID = dr.GetInt32("StepTextMID");
_StepID = dr.GetInt32("StepID");
_ItemType = dr.GetInt32("ItemType");
_TextM = dr.GetString("TextM");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int stepTextMID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a StepText");
DataPortal.Delete(new PKCriteria(stepTextMID));
}
public override StepText Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a StepText");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a StepText");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a StepText");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _StepTextMID;
public int StepTextMID
{ get { return _StepTextMID; } }
public PKCriteria(int stepTextMID)
{
_StepTextMID = stepTextMID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_StepTextMID = NextStepTextMID;
// Database Defaults
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStepText";
cm.Parameters.AddWithValue("@StepTextMID", criteria.StepTextMID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_StepTextMID = dr.GetInt32("StepTextMID");
_StepID = dr.GetInt32("StepID");
_ItemType = dr.GetInt32("ItemType");
_TextM = dr.GetString("TextM");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("StepText.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("StepText.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addStepText";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepID", _StepID);
cm.Parameters.AddWithValue("@ItemType", _ItemType);
cm.Parameters.AddWithValue("@TextM", _TextM);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_StepTextMID = new SqlParameter("@newStepTextMID", SqlDbType.Int);
param_StepTextMID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_StepTextMID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_StepTextMID = (int)cm.Parameters["@newStepTextMID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("StepText.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("StepText.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int stepTextMID, int stepID, int itemType, string textM, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addStepText";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepID", stepID);
cm.Parameters.AddWithValue("@ItemType", itemType);
cm.Parameters.AddWithValue("@TextM", textM);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_StepTextMID = new SqlParameter("@newStepTextMID", SqlDbType.Int);
param_StepTextMID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_StepTextMID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
stepTextMID = (int)cm.Parameters["@newStepTextMID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("StepText.Add", ex);
throw new DbCslaException("StepText.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateStepText";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@StepTextMID", _StepTextMID);
cm.Parameters.AddWithValue("@StepID", _StepID);
cm.Parameters.AddWithValue("@ItemType", _ItemType);
cm.Parameters.AddWithValue("@TextM", _TextM);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("StepText.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int stepTextMID, int stepID, int itemType, string textM, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateStepText";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepTextMID", stepTextMID);
cm.Parameters.AddWithValue("@StepID", stepID);
cm.Parameters.AddWithValue("@ItemType", itemType);
cm.Parameters.AddWithValue("@TextM", textM);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("StepText.Update", ex);
throw new DbCslaException("StepText.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_StepTextMID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteStepText";
cm.Parameters.AddWithValue("@StepTextMID", criteria.StepTextMID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("StepText.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("StepText.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int stepTextMID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteStepText";
// Input PK Fields
cm.Parameters.AddWithValue("@StepTextMID", stepTextMID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("StepText.Remove", ex);
throw new DbCslaException("StepText.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int stepTextMID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(stepTextMID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _StepTextMID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int stepTextMID)
{
_StepTextMID = stepTextMID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsStepText";
cm.Parameters.AddWithValue("@StepTextMID", _StepTextMID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("StepText.DataPortal_Execute", ex);
throw new DbCslaException("StepText.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create StepTextExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class StepText
// {
// partial class Extension : 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,136 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StepTextInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StepTextInfo : ReadOnlyBase<StepTextInfo>
{
#region Business Methods
private int _StepTextMID;
[System.ComponentModel.DataObjectField(true, true)]
public int StepTextMID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepTextMID;
}
}
private int _StepID;
public int StepID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepID;
}
}
private int _ItemType;
public int ItemType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ItemType;
}
}
private string _TextM = string.Empty;
public string TextM
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextM;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
// TODO: Replace base StepTextInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StepTextInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check StepTextInfo.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 StepTextInfo</returns>
protected override object GetIdValue()
{
return _StepTextMID;
}
#endregion
#region Factory Methods
private StepTextInfo()
{ /* require use of factory methods */ }
public StepText Get()
{
return StepText.Get(_StepTextMID);
}
#endregion
#region Data Access Portal
internal StepTextInfo(SafeDataReader dr)
{
try
{
_StepTextMID = dr.GetInt32("StepTextMID");
_StepID = dr.GetInt32("StepID");
_ItemType = dr.GetInt32("ItemType");
_TextM = dr.GetString("TextM");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
}
catch (Exception ex)
{
Database.LogException("StepTextInfo.Constructor", ex);
throw new DbCslaException("StepTextInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StepTextInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StepTextInfoList : ReadOnlyListBase<StepTextInfoList, StepTextInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static StepTextInfoList Get()
{
return DataPortal.Fetch<StepTextInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static StepTextInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<StepTextInfoList>(new FilteredCriteria(<criteria>));
//}
public static StepTextInfoList GetByStep(int stepID)
{
return DataPortal.Fetch<StepTextInfoList>(new StepCriteria(stepID));
}
private StepTextInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStepTexts";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new StepTextInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("StepTextInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("StepTextInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StepCriteria
{
public StepCriteria(int stepID)
{
_StepID = stepID;
}
private int _StepID;
public int StepID
{
get { return _StepID; }
set { _StepID = value; }
}
}
private void DataPortal_Fetch(StepCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStepTextsByStep";
cm.Parameters.AddWithValue("@StepID", criteria.StepID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new StepTextInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("StepTextInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("StepTextInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,759 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Structure Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Structure : BusinessBase<Structure>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextStructureID = -1;
public static int NextStructureID
{
get { return _nextStructureID--; }
}
private int _StructureID;
[System.ComponentModel.DataObjectField(true, true)]
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
}
private int _FromType;
/// <summary>
/// 0 - Parent, 1 - Previous
/// </summary>
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FromType != value)
{
_FromType = value;
PropertyHasChanged();
}
}
}
private int _FromID;
public int FromID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FromID != value)
{
_FromID = value;
PropertyHasChanged();
}
}
}
private int _ContentType;
/// <summary>
/// 0 - Structure, 1 - Procedure, 2 - Section, 3 - Step, 4 - Branch
/// </summary>
public int ContentType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ContentType != value)
{
_ContentType = value;
PropertyHasChanged();
}
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ContentID != value)
{
_ContentID = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private StructureRoUsages _StructureRoUsages = StructureRoUsages.New();
/// <summary>
/// Related Field
/// </summary>
public StructureRoUsages StructureRoUsages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureRoUsages;
}
}
private StructureTransitions _StructureTransitions = StructureTransitions.New();
/// <summary>
/// Related Field
/// </summary>
public StructureTransitions StructureTransitions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureTransitions;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _StructureRoUsages.IsDirty || _StructureTransitions.IsDirty; }
}
public override bool IsValid
{
get { return base.IsValid && _StructureRoUsages.IsValid && _StructureTransitions.IsValid; }
}
// TODO: Replace base Structure.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Structure</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Structure.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 Structure</returns>
protected override object GetIdValue()
{
return _StructureID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(StructureID, "<Role(s)>");
//AuthorizationRules.AllowRead(FromType, "<Role(s)>");
//AuthorizationRules.AllowRead(FromID, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentType, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FromType, "<Role(s)>");
//AuthorizationRules.AllowWrite(FromID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentType, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Structure()
{/* require use of factory methods */}
public static Structure New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Structure");
return DataPortal.Create<Structure>();
}
public static Structure New(int fromType, int fromID, int contentType, int contentID)
{
Structure tmp = Structure.New();
tmp.FromType = fromType;
tmp.FromID = fromID;
tmp.ContentType = contentType;
tmp.ContentID = contentID;
return tmp;
}
public static Structure MakeStructure(int fromType, int fromID, int contentType, int contentID)
{
Structure tmp = Structure.New(fromType, fromID, contentType, contentID);
tmp.Save();
return tmp;
}
public static Structure MakeStructure(int fromType, int fromID, int contentType, int contentID, DateTime dts, string userID)
{
Structure tmp = Structure.New(fromType, fromID, contentType, contentID);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static Structure Get(int structureID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Structure");
return DataPortal.Fetch<Structure>(new PKCriteria(structureID));
}
public static Structure Get(SafeDataReader dr)
{
if (dr.Read()) return new Structure(dr);
return null;
}
private Structure(SafeDataReader dr)
{
_StructureID = dr.GetInt32("StructureID");
_FromType = dr.GetInt32("FromType");
_FromID = dr.GetInt32("FromID");
_ContentType = dr.GetInt32("ContentType");
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int structureID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Structure");
DataPortal.Delete(new PKCriteria(structureID));
}
public override Structure Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Structure");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Structure");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Structure");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _StructureID;
public int StructureID
{ get { return _StructureID; } }
public PKCriteria(int structureID)
{
_StructureID = structureID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_StructureID = NextStructureID;
// Database Defaults
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStructure";
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_StructureID = dr.GetInt32("StructureID");
_FromType = dr.GetInt32("FromType");
_FromID = dr.GetInt32("FromID");
_ContentType = dr.GetInt32("ContentType");
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
// load child objects
dr.NextResult();
_StructureRoUsages = StructureRoUsages.Get(dr);
// load child objects
dr.NextResult();
_StructureTransitions = StructureTransitions.Get(dr);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Structure.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Structure.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addStructure";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FromType", _FromType);
cm.Parameters.AddWithValue("@FromID", _FromID);
cm.Parameters.AddWithValue("@ContentType", _ContentType);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int);
param_StructureID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_StructureID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_StructureID = (int)cm.Parameters["@newStructureID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
_StructureRoUsages.Update(this, cn);
_StructureTransitions.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Structure.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Structure.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addStructure";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FromType", fromType);
cm.Parameters.AddWithValue("@FromID", fromID);
cm.Parameters.AddWithValue("@ContentType", contentType);
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int);
param_StructureID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_StructureID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
structureID = (int)cm.Parameters["@newStructureID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Structure.Add", ex);
throw new DbCslaException("Structure.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateStructure";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@StructureID", _StructureID);
cm.Parameters.AddWithValue("@FromType", _FromType);
cm.Parameters.AddWithValue("@FromID", _FromID);
cm.Parameters.AddWithValue("@ContentType", _ContentType);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
_StructureRoUsages.Update(this, cn);
_StructureTransitions.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("Structure.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateStructure";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StructureID", structureID);
cm.Parameters.AddWithValue("@FromType", fromType);
cm.Parameters.AddWithValue("@FromID", fromID);
cm.Parameters.AddWithValue("@ContentType", contentType);
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Structure.Update", ex);
throw new DbCslaException("Structure.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_StructureID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteStructure";
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Structure.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Structure.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int structureID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteStructure";
// Input PK Fields
cm.Parameters.AddWithValue("@StructureID", structureID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Structure.Remove", ex);
throw new DbCslaException("Structure.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int structureID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(structureID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _StructureID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int structureID)
{
_StructureID = structureID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsStructure";
cm.Parameters.AddWithValue("@StructureID", _StructureID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Structure.DataPortal_Execute", ex);
throw new DbCslaException("Structure.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create StructureExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Structure
// {
// partial class Extension : 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,231 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StructureInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StructureInfo : ReadOnlyBase<StructureInfo>
{
#region Business Methods
private int _StructureID;
[System.ComponentModel.DataObjectField(true, true)]
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
}
private int _FromType;
/// <summary>
/// 0 - Parent, 1 - Previous
/// </summary>
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromType;
}
}
private int _FromID;
public int FromID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromID;
}
}
private int _ContentType;
/// <summary>
/// 0 - Structure, 1 - Procedure, 2 - Section, 3 - Step, 4 - Branch
/// </summary>
public int ContentType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentType;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentID;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
private int _RoUsagecount = 0;
/// <summary>
/// Count of RoUsage for this Structure
/// </summary>
public int RoUsageCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _RoUsagecount;
}
}
private RoUsageInfoList _RoUsages = null;
public RoUsageInfoList RoUsages
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_RoUsages == null)
_RoUsages = RoUsageInfoList.GetByStructure(_StructureID);
return _RoUsages;
}
}
private int _Transitioncount = 0;
/// <summary>
/// Count of Transition for this Structure
/// </summary>
public int TransitionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Transitioncount;
}
}
private TransitionInfoList _Transitions = null;
public TransitionInfoList Transitions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Transitions == null)
_Transitions = TransitionInfoList.GetByStructure(_StructureID);
return _Transitions;
}
}
private int _ZStructcount = 0;
/// <summary>
/// Count of ZStruct for this Structure
/// </summary>
public int ZStructCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ZStructcount;
}
}
private ZStructInfoList _ZStructs = null;
public ZStructInfoList ZStructs
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_ZStructs == null)
_ZStructs = ZStructInfoList.GetByStructure(_StructureID);
return _ZStructs;
}
}
// TODO: Replace base StructureInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StructureInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check StructureInfo.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 StructureInfo</returns>
protected override object GetIdValue()
{
return _StructureID;
}
#endregion
#region Factory Methods
private StructureInfo()
{ /* require use of factory methods */ }
public Structure Get()
{
return Structure.Get(_StructureID);
}
#endregion
#region Data Access Portal
internal StructureInfo(SafeDataReader dr)
{
try
{
_StructureID = dr.GetInt32("StructureID");
_FromType = dr.GetInt32("FromType");
_FromID = dr.GetInt32("FromID");
_ContentType = dr.GetInt32("ContentType");
_ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_RoUsagecount = dr.GetInt32("RoUsageCount");
_Transitioncount = dr.GetInt32("TransitionCount");
_ZStructcount = dr.GetInt32("ZStructCount");
}
catch (Exception ex)
{
Database.LogException("StructureInfo.Constructor", ex);
throw new DbCslaException("StructureInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StructureInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StructureInfoList : ReadOnlyListBase<StructureInfoList, StructureInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static StructureInfoList Get()
{
return DataPortal.Fetch<StructureInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static StructureInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<StructureInfoList>(new FilteredCriteria(<criteria>));
//}
private StructureInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getStructures";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new StructureInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("StructureInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("StructureInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,342 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StructureRoUsage Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StructureRoUsage : BusinessBase<StructureRoUsage>
{
#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(true);
return _ROUsageId;
}
}
private string _ROID = string.Empty;
public string ROID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ROID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_ROID != value)
{
_ROID = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check StructureRoUsage.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 StructureRoUsage</returns>
protected override object GetIdValue()
{
return _ROUsageId;
}
// TODO: Replace base StructureRoUsage.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StructureRoUsage</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
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.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// TODO: Add other validation rules
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(ROUsageId, "<Role(s)>");
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
//AuthorizationRules.AllowRead(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 StructureRoUsage New(string roid)
{
return new StructureRoUsage(roid);
}
internal static StructureRoUsage Get(SafeDataReader dr)
{
return new StructureRoUsage(dr);
}
public StructureRoUsage()
{
MarkAsChild();
_ROUsageId = RoUsage.NextROUsageId;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
}
private StructureRoUsage(string roid)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
_ROID = roid;
}
private StructureRoUsage(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_ROUsageId = dr.GetInt32("ROUsageId");
_ROID = dr.GetString("ROID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("StructureRoUsage.Fetch", ex);
throw new DbCslaException("StructureRoUsage.Fetch", ex);
}
MarkOld();
}
internal void Insert(Structure structure, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = RoUsage.Add(cn, ref _ROUsageId, structure.StructureID, _ROID, _DTS, _UserID);
MarkOld();
}
internal void Update(Structure structure, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = RoUsage.Update(cn, ref _ROUsageId, structure.StructureID, _ROID, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Structure structure, SqlConnection cn)
{
// 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;
RoUsage.Remove(cn, _ROUsageId);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultStructureID
{
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create StructureRoUsageExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class StructureRoUsage
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultStructureID
// {
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,137 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StructureRoUsages Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StructureRoUsages : BusinessListBase<StructureRoUsages, StructureRoUsage>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// One To Many
public new StructureRoUsage this[int rOUsageId]
{
get
{
foreach (StructureRoUsage roUsage in this)
if (roUsage.ROUsageId == rOUsageId)
return roUsage;
return null;
}
}
public StructureRoUsage GetItem(int rOUsageId)
{
foreach (StructureRoUsage roUsage in this)
if (roUsage.ROUsageId == rOUsageId)
return roUsage;
return null;
}
public StructureRoUsage Add(string roid)
{
StructureRoUsage roUsage = StructureRoUsage.New(roid);
this.Add(roUsage);
return roUsage;
}
public void Remove(int rOUsageId)
{
foreach (StructureRoUsage roUsage in this)
{
if (roUsage.ROUsageId == rOUsageId)
{
Remove(roUsage);
break;
}
}
}
public bool Contains(int rOUsageId)
{
foreach (StructureRoUsage roUsage in this)
if (roUsage.ROUsageId == rOUsageId)
return true;
return false;
}
public bool ContainsDeleted(int rOUsageId)
{
foreach (StructureRoUsage roUsage in DeletedList)
if (roUsage.ROUsageId == rOUsageId)
return true;
return false;
}
#endregion
#region Factory Methods
internal static StructureRoUsages New()
{
return new StructureRoUsages();
}
internal static StructureRoUsages Get(SafeDataReader dr)
{
return new StructureRoUsages(dr);
}
private StructureRoUsages()
{
MarkAsChild();
}
private StructureRoUsages(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(StructureRoUsage.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Structure structure, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (StructureRoUsage obj in DeletedList)
obj.DeleteSelf(structure, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (StructureRoUsage obj in this)
{
if (obj.IsNew)
obj.Insert(structure, cn);
else
obj.Update(structure, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,496 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StructureTransition Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StructureTransition : BusinessBase<StructureTransition>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _TransitionId;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TransitionId;
}
}
private int _ToId;
/// <summary>
/// StructureID
/// </summary>
public int ToId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ToId;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ToId != value)
{
_ToId = value;
PropertyHasChanged();
}
}
}
private int _TranType;
public int TranType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TranType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_TranType != value)
{
_TranType = value;
PropertyHasChanged();
}
}
}
private int _SectID;
public int SectID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SectID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_SectID != value)
{
_SectID = value;
PropertyHasChanged();
}
}
}
private int _ProcID;
public int ProcID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ProcID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ProcID != value)
{
_ProcID = value;
PropertyHasChanged();
}
}
}
private int _SetID;
public int SetID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SetID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_SetID != value)
{
_SetID = value;
PropertyHasChanged();
}
}
}
private int _PlantID;
public int PlantID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PlantID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_PlantID != value)
{
_PlantID = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check StructureTransition.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 StructureTransition</returns>
protected override object GetIdValue()
{
return _TransitionId;
}
// TODO: Replace base StructureTransition.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current StructureTransition</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
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(TransitionId, "<Role(s)>");
//AuthorizationRules.AllowRead(ToId, "<Role(s)>");
//AuthorizationRules.AllowWrite(ToId, "<Role(s)>");
//AuthorizationRules.AllowRead(TranType, "<Role(s)>");
//AuthorizationRules.AllowWrite(TranType, "<Role(s)>");
//AuthorizationRules.AllowRead(SectID, "<Role(s)>");
//AuthorizationRules.AllowWrite(SectID, "<Role(s)>");
//AuthorizationRules.AllowRead(ProcID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ProcID, "<Role(s)>");
//AuthorizationRules.AllowRead(SetID, "<Role(s)>");
//AuthorizationRules.AllowWrite(SetID, "<Role(s)>");
//AuthorizationRules.AllowRead(PlantID, "<Role(s)>");
//AuthorizationRules.AllowWrite(PlantID, "<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 StructureTransition New(int toId)
{
return new StructureTransition(toId);
}
internal static StructureTransition Get(SafeDataReader dr)
{
return new StructureTransition(dr);
}
public StructureTransition()
{
MarkAsChild();
_TransitionId = Transition.NextTransitionId;
_TranType = ext.DefaultTranType;
_SectID = ext.DefaultSectID;
_ProcID = ext.DefaultProcID;
_SetID = ext.DefaultSetID;
_PlantID = ext.DefaultPlantID;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
}
private StructureTransition(int toId)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_TranType = ext.DefaultTranType;
_SectID = ext.DefaultSectID;
_ProcID = ext.DefaultProcID;
_SetID = ext.DefaultSetID;
_PlantID = ext.DefaultPlantID;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
_ToId = toId;
}
private StructureTransition(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_TransitionId = dr.GetInt32("TransitionId");
_ToId = dr.GetInt32("ToId");
_TranType = dr.GetInt32("TranType");
_SectID = dr.GetInt32("SectID");
_ProcID = dr.GetInt32("ProcID");
_SetID = dr.GetInt32("SetID");
_PlantID = dr.GetInt32("PlantID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("StructureTransition.Fetch", ex);
throw new DbCslaException("StructureTransition.Fetch", ex);
}
MarkOld();
}
internal void Insert(Structure structure, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Transition.Add(cn, ref _TransitionId, structure.StructureID, _ToId, _TranType, _SectID, _ProcID, _SetID, _PlantID, _DTS, _UserID);
MarkOld();
}
internal void Update(Structure structure, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Transition.Update(cn, ref _TransitionId, structure.StructureID, _ToId, _TranType, _SectID, _ProcID, _SetID, _PlantID, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(Structure structure, SqlConnection cn)
{
// 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;
Transition.Remove(cn, _TransitionId);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultTranType
{
get { return 0; }
}
public virtual int DefaultSectID
{
get { return 0; }
}
public virtual int DefaultProcID
{
get { return 0; }
}
public virtual int DefaultSetID
{
get { return 0; }
}
public virtual int DefaultPlantID
{
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create StructureTransitionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class StructureTransition
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultTranType
// {
// get { return 0; }
// }
// public virtual int DefaultSectID
// {
// get { return 0; }
// }
// public virtual int DefaultProcID
// {
// get { return 0; }
// }
// public virtual int DefaultSetID
// {
// get { return 0; }
// }
// public virtual int DefaultPlantID
// {
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,137 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// StructureTransitions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class StructureTransitions : BusinessListBase<StructureTransitions, StructureTransition>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// One To Many
public new StructureTransition this[int transitionId]
{
get
{
foreach (StructureTransition transition in this)
if (transition.TransitionId == transitionId)
return transition;
return null;
}
}
public StructureTransition GetItem(int transitionId)
{
foreach (StructureTransition transition in this)
if (transition.TransitionId == transitionId)
return transition;
return null;
}
public StructureTransition Add(int toId)
{
StructureTransition transition = StructureTransition.New(toId);
this.Add(transition);
return transition;
}
public void Remove(int transitionId)
{
foreach (StructureTransition transition in this)
{
if (transition.TransitionId == transitionId)
{
Remove(transition);
break;
}
}
}
public bool Contains(int transitionId)
{
foreach (StructureTransition transition in this)
if (transition.TransitionId == transitionId)
return true;
return false;
}
public bool ContainsDeleted(int transitionId)
{
foreach (StructureTransition transition in DeletedList)
if (transition.TransitionId == transitionId)
return true;
return false;
}
#endregion
#region Factory Methods
internal static StructureTransitions New()
{
return new StructureTransitions();
}
internal static StructureTransitions Get(SafeDataReader dr)
{
return new StructureTransitions(dr);
}
private StructureTransitions()
{
MarkAsChild();
}
private StructureTransitions(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(StructureTransition.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Structure structure, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (StructureTransition obj in DeletedList)
obj.DeleteSelf(structure, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (StructureTransition obj in this)
{
if (obj.IsNew)
obj.Insert(structure, cn);
else
obj.Update(structure, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,654 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// TextM Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class TextM : BusinessBase<TextM>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextTextMID = -1;
public static int NextTextMID
{
get { return _nextTextMID--; }
}
private int _TextMID;
[System.ComponentModel.DataObjectField(true, true)]
public int TextMID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextMID;
}
}
private string _TextMValue = string.Empty;
public string TextMValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextMValue;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_TextMValue != value)
{
_TextMValue = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private TextMSteps _TextMSteps = TextMSteps.New();
/// <summary>
/// Related Field
/// </summary>
public TextMSteps TextMSteps
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextMSteps;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _TextMSteps.IsDirty; }
}
public override bool IsValid
{
get { return base.IsValid && _TextMSteps.IsValid; }
}
// TODO: Replace base TextM.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current TextM</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check TextM.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 TextM</returns>
protected override object GetIdValue()
{
return _TextMID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "TextMValue");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("TextMValue", 1073741823));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(TextMID, "<Role(s)>");
//AuthorizationRules.AllowRead(TextMValue, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(TextMValue, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private TextM()
{/* require use of factory methods */}
public static TextM New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a TextM");
return DataPortal.Create<TextM>();
}
public static TextM New(string textMValue)
{
TextM tmp = TextM.New();
tmp.TextMValue = textMValue;
return tmp;
}
public static TextM MakeTextM(string textMValue)
{
TextM tmp = TextM.New(textMValue);
tmp.Save();
return tmp;
}
public static TextM MakeTextM(string textMValue, DateTime dts, string userID)
{
TextM tmp = TextM.New(textMValue);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static TextM Get(int textMID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a TextM");
return DataPortal.Fetch<TextM>(new PKCriteria(textMID));
}
public static TextM Get(SafeDataReader dr)
{
if (dr.Read()) return new TextM(dr);
return null;
}
private TextM(SafeDataReader dr)
{
_TextMID = dr.GetInt32("TextMID");
_TextMValue = dr.GetString("TextMValue");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int textMID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a TextM");
DataPortal.Delete(new PKCriteria(textMID));
}
public override TextM Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a TextM");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a TextM");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a TextM");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _TextMID;
public int TextMID
{ get { return _TextMID; } }
public PKCriteria(int textMID)
{
_TextMID = textMID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_TextMID = NextTextMID;
// Database Defaults
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getTextM";
cm.Parameters.AddWithValue("@TextMID", criteria.TextMID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_TextMID = dr.GetInt32("TextMID");
_TextMValue = dr.GetString("TextMValue");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
// load child objects
dr.NextResult();
_TextMSteps = TextMSteps.Get(dr);
}
}
}
}
catch (Exception ex)
{
Database.LogException("TextM.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("TextM.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addTextM";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@TextMValue", _TextMValue);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_TextMID = new SqlParameter("@newTextMID", SqlDbType.Int);
param_TextMID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_TextMID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_TextMID = (int)cm.Parameters["@newTextMID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
_TextMSteps.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("TextM.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("TextM.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int textMID, string textMValue, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addTextM";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@TextMValue", textMValue);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_TextMID = new SqlParameter("@newTextMID", SqlDbType.Int);
param_TextMID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_TextMID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
textMID = (int)cm.Parameters["@newTextMID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("TextM.Add", ex);
throw new DbCslaException("TextM.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateTextM";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@TextMID", _TextMID);
cm.Parameters.AddWithValue("@TextMValue", _TextMValue);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
_TextMSteps.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("TextM.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int textMID, string textMValue, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateTextM";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@TextMID", textMID);
cm.Parameters.AddWithValue("@TextMValue", textMValue);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("TextM.Update", ex);
throw new DbCslaException("TextM.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_TextMID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteTextM";
cm.Parameters.AddWithValue("@TextMID", criteria.TextMID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("TextM.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("TextM.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int textMID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteTextM";
// Input PK Fields
cm.Parameters.AddWithValue("@TextMID", textMID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("TextM.Remove", ex);
throw new DbCslaException("TextM.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int textMID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(textMID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _TextMID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int textMID)
{
_TextMID = textMID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsTextM";
cm.Parameters.AddWithValue("@TextMID", _TextMID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("TextM.DataPortal_Execute", ex);
throw new DbCslaException("TextM.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create TextMExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class TextM
// {
// partial class Extension : 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,140 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// TextMInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class TextMInfo : ReadOnlyBase<TextMInfo>
{
#region Business Methods
private int _TextMID;
[System.ComponentModel.DataObjectField(true, true)]
public int TextMID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextMID;
}
}
private string _TextMValue = string.Empty;
public string TextMValue
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TextMValue;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
private int _Stepcount = 0;
/// <summary>
/// Count of Step for this TextM
/// </summary>
public int StepCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Stepcount;
}
}
private StepInfoList _Steps = null;
public StepInfoList Steps
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Steps == null)
_Steps = StepInfoList.GetByTextM(_TextMID);
return _Steps;
}
}
// TODO: Replace base TextMInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current TextMInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check TextMInfo.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 TextMInfo</returns>
protected override object GetIdValue()
{
return _TextMID;
}
#endregion
#region Factory Methods
private TextMInfo()
{ /* require use of factory methods */ }
public TextM Get()
{
return TextM.Get(_TextMID);
}
#endregion
#region Data Access Portal
internal TextMInfo(SafeDataReader dr)
{
try
{
_TextMID = dr.GetInt32("TextMID");
_TextMValue = dr.GetString("TextMValue");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_Stepcount = dr.GetInt32("StepCount");
}
catch (Exception ex)
{
Database.LogException("TextMInfo.Constructor", ex);
throw new DbCslaException("TextMInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// TextMInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class TextMInfoList : ReadOnlyListBase<TextMInfoList, TextMInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static TextMInfoList Get()
{
return DataPortal.Fetch<TextMInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static TextMInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<TextMInfoList>(new FilteredCriteria(<criteria>));
//}
private TextMInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getTextMs";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new TextMInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("TextMInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("TextMInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,351 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// TextMStep Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class TextMStep : BusinessBase<TextMStep>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _StepID;
[System.ComponentModel.DataObjectField(true, true)]
public int StepID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepID;
}
}
private string _StepType = string.Empty;
public string StepType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_StepType != value)
{
_StepType = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Check TextMStep.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 TextMStep</returns>
protected override object GetIdValue()
{
return _StepID;
}
// TODO: Replace base TextMStep.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current TextMStep</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("StepType", 2));
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(StepID, "<Role(s)>");
//AuthorizationRules.AllowRead(StepType, "<Role(s)>");
//AuthorizationRules.AllowWrite(StepType, "<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 TextMStep New()
{
return new TextMStep();
}
internal static TextMStep Get(SafeDataReader dr)
{
return new TextMStep(dr);
}
public TextMStep()
{
MarkAsChild();
_StepID = Step.NextStepID;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
}
private TextMStep(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_StepID = dr.GetInt32("StepID");
_StepType = dr.GetString("StepType");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("TextMStep.Fetch", ex);
throw new DbCslaException("TextMStep.Fetch", ex);
}
MarkOld();
}
internal void Insert(TextM textM, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Step.Add(cn, ref _StepID, _StepType, textM.TextMID, _Config, _DTS, _UserID);
MarkOld();
}
internal void Update(TextM textM, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Step.Update(cn, ref _StepID, _StepType, textM.TextMID, _Config, _DTS, _UserID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(TextM textM, SqlConnection cn)
{
// 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;
Step.Remove(cn, _StepID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create TextMStepExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class TextMStep
// {
// partial class Extension : 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,137 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// TextMSteps Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class TextMSteps : BusinessListBase<TextMSteps, TextMStep>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// One To Many
public new TextMStep this[int stepID]
{
get
{
foreach (TextMStep step in this)
if (step.StepID == stepID)
return step;
return null;
}
}
public TextMStep GetItem(int stepID)
{
foreach (TextMStep step in this)
if (step.StepID == stepID)
return step;
return null;
}
public TextMStep Add()
{
TextMStep step = TextMStep.New();
this.Add(step);
return step;
}
public void Remove(int stepID)
{
foreach (TextMStep step in this)
{
if (step.StepID == stepID)
{
Remove(step);
break;
}
}
}
public bool Contains(int stepID)
{
foreach (TextMStep step in this)
if (step.StepID == stepID)
return true;
return false;
}
public bool ContainsDeleted(int stepID)
{
foreach (TextMStep step in DeletedList)
if (step.StepID == stepID)
return true;
return false;
}
#endregion
#region Factory Methods
internal static TextMSteps New()
{
return new TextMSteps();
}
internal static TextMSteps Get(SafeDataReader dr)
{
return new TextMSteps(dr);
}
private TextMSteps()
{
MarkAsChild();
}
private TextMSteps(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(TextMStep.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(TextM textM, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (TextMStep obj in DeletedList)
obj.DeleteSelf(textM, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (TextMStep obj in this)
{
if (obj.IsNew)
obj.Insert(textM, cn);
else
obj.Update(textM, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,844 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// Transition Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Transition : BusinessBase<Transition>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextTransitionId = -1;
public static int NextTransitionId
{
get { return _nextTransitionId--; }
}
private int _TransitionId;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TransitionId;
}
}
private int _FromId;
public int FromId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromId;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FromId != value)
{
_FromId = value;
PropertyHasChanged();
}
}
}
private int _ToId;
/// <summary>
/// StructureID
/// </summary>
public int ToId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ToId;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ToId != value)
{
_ToId = value;
PropertyHasChanged();
}
}
}
private int _TranType;
public int TranType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TranType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_TranType != value)
{
_TranType = value;
PropertyHasChanged();
}
}
}
private int _SectID;
public int SectID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SectID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_SectID != value)
{
_SectID = value;
PropertyHasChanged();
}
}
}
private int _ProcID;
public int ProcID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ProcID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ProcID != value)
{
_ProcID = value;
PropertyHasChanged();
}
}
}
private int _SetID;
public int SetID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SetID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_SetID != value)
{
_SetID = value;
PropertyHasChanged();
}
}
}
private int _PlantID;
public int PlantID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PlantID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_PlantID != value)
{
_PlantID = value;
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base Transition.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current Transition</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check Transition.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 Transition</returns>
protected override object GetIdValue()
{
return _TransitionId;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(TransitionId, "<Role(s)>");
//AuthorizationRules.AllowRead(FromId, "<Role(s)>");
//AuthorizationRules.AllowRead(ToId, "<Role(s)>");
//AuthorizationRules.AllowRead(TranType, "<Role(s)>");
//AuthorizationRules.AllowRead(SectID, "<Role(s)>");
//AuthorizationRules.AllowRead(ProcID, "<Role(s)>");
//AuthorizationRules.AllowRead(SetID, "<Role(s)>");
//AuthorizationRules.AllowRead(PlantID, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FromId, "<Role(s)>");
//AuthorizationRules.AllowWrite(ToId, "<Role(s)>");
//AuthorizationRules.AllowWrite(TranType, "<Role(s)>");
//AuthorizationRules.AllowWrite(SectID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ProcID, "<Role(s)>");
//AuthorizationRules.AllowWrite(SetID, "<Role(s)>");
//AuthorizationRules.AllowWrite(PlantID, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private Transition()
{/* require use of factory methods */}
public static Transition New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Transition");
return DataPortal.Create<Transition>();
}
public static Transition New(int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID)
{
Transition tmp = Transition.New();
tmp.FromId = fromId;
tmp.ToId = toId;
tmp.TranType = tranType;
tmp.SectID = sectID;
tmp.ProcID = procID;
tmp.SetID = setID;
tmp.PlantID = plantID;
return tmp;
}
public static Transition MakeTransition(int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID)
{
Transition tmp = Transition.New(fromId, toId, tranType, sectID, procID, setID, plantID);
tmp.Save();
return tmp;
}
public static Transition MakeTransition(int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID, DateTime dts, string userID)
{
Transition tmp = Transition.New(fromId, toId, tranType, sectID, procID, setID, plantID);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (userID != null && userID != string.Empty) tmp.UserID = userID;
tmp.Save();
return tmp;
}
public static Transition Get(int transitionId)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Transition");
return DataPortal.Fetch<Transition>(new PKCriteria(transitionId));
}
public static Transition Get(SafeDataReader dr)
{
if (dr.Read()) return new Transition(dr);
return null;
}
private Transition(SafeDataReader dr)
{
_TransitionId = dr.GetInt32("TransitionId");
_FromId = dr.GetInt32("FromId");
_ToId = dr.GetInt32("ToId");
_TranType = dr.GetInt32("TranType");
_SectID = dr.GetInt32("SectID");
_ProcID = dr.GetInt32("ProcID");
_SetID = dr.GetInt32("SetID");
_PlantID = dr.GetInt32("PlantID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int transitionId)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Transition");
DataPortal.Delete(new PKCriteria(transitionId));
}
public override Transition Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Transition");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a Transition");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a Transition");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _TransitionId;
public int TransitionId
{ get { return _TransitionId; } }
public PKCriteria(int transitionId)
{
_TransitionId = transitionId;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_TransitionId = NextTransitionId;
// Database Defaults
_TranType = ext.DefaultTranType;
_SectID = ext.DefaultSectID;
_ProcID = ext.DefaultProcID;
_SetID = ext.DefaultSetID;
_PlantID = ext.DefaultPlantID;
_DTS = ext.DefaultDTS;
_UserID = ext.DefaultUserID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getTransition";
cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_TransitionId = dr.GetInt32("TransitionId");
_FromId = dr.GetInt32("FromId");
_ToId = dr.GetInt32("ToId");
_TranType = dr.GetInt32("TranType");
_SectID = dr.GetInt32("SectID");
_ProcID = dr.GetInt32("ProcID");
_SetID = dr.GetInt32("SetID");
_PlantID = dr.GetInt32("PlantID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("Transition.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Transition.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addTransition";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FromId", _FromId);
cm.Parameters.AddWithValue("@ToId", _ToId);
cm.Parameters.AddWithValue("@TranType", _TranType);
cm.Parameters.AddWithValue("@SectID", _SectID);
cm.Parameters.AddWithValue("@ProcID", _ProcID);
cm.Parameters.AddWithValue("@SetID", _SetID);
cm.Parameters.AddWithValue("@PlantID", _PlantID);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
// Output Calculated Columns
SqlParameter param_TransitionId = new SqlParameter("@newTransitionId", SqlDbType.Int);
param_TransitionId.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_TransitionId);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_TransitionId = (int)cm.Parameters["@newTransitionId"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("Transition.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Transition.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int transitionId, int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID, DateTime dts, string userID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addTransition";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FromId", fromId);
cm.Parameters.AddWithValue("@ToId", toId);
cm.Parameters.AddWithValue("@TranType", tranType);
cm.Parameters.AddWithValue("@SectID", sectID);
cm.Parameters.AddWithValue("@ProcID", procID);
cm.Parameters.AddWithValue("@SetID", setID);
cm.Parameters.AddWithValue("@PlantID", plantID);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
// Output Calculated Columns
SqlParameter param_TransitionId = new SqlParameter("@newTransitionId", SqlDbType.Int);
param_TransitionId.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_TransitionId);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
transitionId = (int)cm.Parameters["@newTransitionId"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Transition.Add", ex);
throw new DbCslaException("Transition.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateTransition";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@TransitionId", _TransitionId);
cm.Parameters.AddWithValue("@FromId", _FromId);
cm.Parameters.AddWithValue("@ToId", _ToId);
cm.Parameters.AddWithValue("@TranType", _TranType);
cm.Parameters.AddWithValue("@SectID", _SectID);
cm.Parameters.AddWithValue("@ProcID", _ProcID);
cm.Parameters.AddWithValue("@SetID", _SetID);
cm.Parameters.AddWithValue("@PlantID", _PlantID);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("Transition.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int transitionId, int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID, DateTime dts, string userID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateTransition";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@TransitionId", transitionId);
cm.Parameters.AddWithValue("@FromId", fromId);
cm.Parameters.AddWithValue("@ToId", toId);
cm.Parameters.AddWithValue("@TranType", tranType);
cm.Parameters.AddWithValue("@SectID", sectID);
cm.Parameters.AddWithValue("@ProcID", procID);
cm.Parameters.AddWithValue("@SetID", setID);
cm.Parameters.AddWithValue("@PlantID", plantID);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("Transition.Update", ex);
throw new DbCslaException("Transition.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_TransitionId));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteTransition";
cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("Transition.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("Transition.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int transitionId)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteTransition";
// Input PK Fields
cm.Parameters.AddWithValue("@TransitionId", transitionId);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("Transition.Remove", ex);
throw new DbCslaException("Transition.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int transitionId)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(transitionId));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _TransitionId;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int transitionId)
{
_TransitionId = transitionId;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsTransition";
cm.Parameters.AddWithValue("@TransitionId", _TransitionId);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("Transition.DataPortal_Execute", ex);
throw new DbCslaException("Transition.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual int DefaultTranType
{
get { return 0; }
}
public virtual int DefaultSectID
{
get { return 0; }
}
public virtual int DefaultProcID
{
get { return 0; }
}
public virtual int DefaultSetID
{
get { return 0; }
}
public virtual int DefaultPlantID
{
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create TransitionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class Transition
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual int DefaultTranType
// {
// get { return 0; }
// }
// public virtual int DefaultSectID
// {
// get { return 0; }
// }
// public virtual int DefaultProcID
// {
// get { return 0; }
// }
// public virtual int DefaultSetID
// {
// get { return 0; }
// }
// public virtual int DefaultPlantID
// {
// 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 AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,209 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// TransitionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class TransitionInfo : ReadOnlyBase<TransitionInfo>
{
#region Business Methods
private int _TransitionId;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TransitionId;
}
}
private int _FromId;
public int FromId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromId;
}
}
private int _ToId;
/// <summary>
/// StructureID
/// </summary>
public int ToId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ToId;
}
}
private int _TranType;
public int TranType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TranType;
}
}
private int _SectID;
public int SectID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SectID;
}
}
private int _ProcID;
public int ProcID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ProcID;
}
}
private int _SetID;
public int SetID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SetID;
}
}
private int _PlantID;
public int PlantID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PlantID;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
private int _ZTransitioncount = 0;
/// <summary>
/// Count of ZTransition for this Transition
/// </summary>
public int ZTransitionCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ZTransitioncount;
}
}
private ZTransitionInfoList _ZTransitions = null;
public ZTransitionInfoList ZTransitions
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_ZTransitions == null)
_ZTransitions = ZTransitionInfoList.GetByTransition(_TransitionId);
return _ZTransitions;
}
}
// TODO: Replace base TransitionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current TransitionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check TransitionInfo.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 TransitionInfo</returns>
protected override object GetIdValue()
{
return _TransitionId;
}
#endregion
#region Factory Methods
private TransitionInfo()
{ /* require use of factory methods */ }
public Transition Get()
{
return Transition.Get(_TransitionId);
}
#endregion
#region Data Access Portal
internal TransitionInfo(SafeDataReader dr)
{
try
{
_TransitionId = dr.GetInt32("TransitionId");
_FromId = dr.GetInt32("FromId");
_ToId = dr.GetInt32("ToId");
_TranType = dr.GetInt32("TranType");
_SectID = dr.GetInt32("SectID");
_ProcID = dr.GetInt32("ProcID");
_SetID = dr.GetInt32("SetID");
_PlantID = dr.GetInt32("PlantID");
_DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID");
_ZTransitioncount = dr.GetInt32("ZTransitionCount");
}
catch (Exception ex)
{
Database.LogException("TransitionInfo.Constructor", ex);
throw new DbCslaException("TransitionInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// TransitionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class TransitionInfoList : ReadOnlyListBase<TransitionInfoList, TransitionInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static TransitionInfoList Get()
{
return DataPortal.Fetch<TransitionInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static TransitionInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<TransitionInfoList>(new FilteredCriteria(<criteria>));
//}
public static TransitionInfoList GetByStructure(int structureID)
{
return DataPortal.Fetch<TransitionInfoList>(new StructureCriteria(structureID));
}
private TransitionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getTransitions";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new TransitionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("TransitionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("TransitionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StructureCriteria
{
public StructureCriteria(int structureID)
{
_StructureID = structureID;
}
private int _StructureID;
public int StructureID
{
get { return _StructureID; }
set { _StructureID = value; }
}
}
private void DataPortal_Fetch(StructureCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getTransitionsByStructure";
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new TransitionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("TransitionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("TransitionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,993 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// User Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class User : BusinessBase<User>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextUID = -1;
public static int NextUID
{
get { return _nextUID--; }
}
private int _UID;
[System.ComponentModel.DataObjectField(true, true)]
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UID;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private string _FirstName = string.Empty;
public string FirstName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FirstName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_FirstName != value)
{
_FirstName = value;
PropertyHasChanged();
}
}
}
private string _MiddleName = string.Empty;
public string MiddleName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _MiddleName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_MiddleName != value)
{
_MiddleName = value;
PropertyHasChanged();
}
}
}
private string _LastName = string.Empty;
public string LastName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _LastName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_LastName != value)
{
_LastName = value;
PropertyHasChanged();
}
}
}
private string _Suffix = string.Empty;
public string Suffix
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Suffix;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Suffix != value)
{
_Suffix = value;
PropertyHasChanged();
}
}
}
private string _CourtesyTitle = string.Empty;
public string CourtesyTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _CourtesyTitle;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_CourtesyTitle != value)
{
_CourtesyTitle = value;
PropertyHasChanged();
}
}
}
private string _PhoneNumber = string.Empty;
public string PhoneNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PhoneNumber;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_PhoneNumber != value)
{
_PhoneNumber = value;
PropertyHasChanged();
}
}
}
private string _CFGName = string.Empty;
public string CFGName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _CFGName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_CFGName != value)
{
_CFGName = value;
PropertyHasChanged();
}
}
}
private string _UserLogin = string.Empty;
public string UserLogin
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserLogin;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserLogin != value)
{
_UserLogin = value;
PropertyHasChanged();
}
}
}
private string _UserName = string.Empty;
public string UserName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserName;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UserName != value)
{
_UserName = value;
PropertyHasChanged();
}
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private UserMemberships _UserMemberships = UserMemberships.New();
/// <summary>
/// Related Field
/// </summary>
public UserMemberships UserMemberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserMemberships;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _UserMemberships.IsDirty; }
}
public override bool IsValid
{
get { return base.IsValid && _UserMemberships.IsValid; }
}
// TODO: Replace base User.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current User</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check User.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 User</returns>
protected override object GetIdValue()
{
return _UID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UserID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("FirstName", 50));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("MiddleName", 50));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("LastName", 50));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Suffix", 10));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("CourtesyTitle", 10));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("PhoneNumber", 30));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("CFGName", 8));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserLogin", 10));
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserName", 32));
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));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(UID, "<Role(s)>");
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
//AuthorizationRules.AllowRead(FirstName, "<Role(s)>");
//AuthorizationRules.AllowRead(MiddleName, "<Role(s)>");
//AuthorizationRules.AllowRead(LastName, "<Role(s)>");
//AuthorizationRules.AllowRead(Suffix, "<Role(s)>");
//AuthorizationRules.AllowRead(CourtesyTitle, "<Role(s)>");
//AuthorizationRules.AllowRead(PhoneNumber, "<Role(s)>");
//AuthorizationRules.AllowRead(CFGName, "<Role(s)>");
//AuthorizationRules.AllowRead(UserLogin, "<Role(s)>");
//AuthorizationRules.AllowRead(UserName, "<Role(s)>");
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
//AuthorizationRules.AllowWrite(FirstName, "<Role(s)>");
//AuthorizationRules.AllowWrite(MiddleName, "<Role(s)>");
//AuthorizationRules.AllowWrite(LastName, "<Role(s)>");
//AuthorizationRules.AllowWrite(Suffix, "<Role(s)>");
//AuthorizationRules.AllowWrite(CourtesyTitle, "<Role(s)>");
//AuthorizationRules.AllowWrite(PhoneNumber, "<Role(s)>");
//AuthorizationRules.AllowWrite(CFGName, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserLogin, "<Role(s)>");
//AuthorizationRules.AllowWrite(UserName, "<Role(s)>");
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private User()
{/* require use of factory methods */}
public static User New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a User");
return DataPortal.Create<User>();
}
public static User New(string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config)
{
User tmp = User.New();
tmp.UserID = userID;
tmp.FirstName = firstName;
tmp.MiddleName = middleName;
tmp.LastName = lastName;
tmp.Suffix = suffix;
tmp.CourtesyTitle = courtesyTitle;
tmp.PhoneNumber = phoneNumber;
tmp.CFGName = cFGName;
tmp.UserLogin = userLogin;
tmp.UserName = userName;
tmp.Config = config;
return tmp;
}
public static User MakeUser(string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config)
{
User tmp = User.New(userID, firstName, middleName, lastName, suffix, courtesyTitle, phoneNumber, cFGName, userLogin, userName, config);
tmp.Save();
return tmp;
}
public static User MakeUser(string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config, DateTime dts, string usrID)
{
User tmp = User.New(userID, firstName, middleName, lastName, suffix, courtesyTitle, phoneNumber, cFGName, userLogin, userName, config);
if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts;
if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID;
tmp.Save();
return tmp;
}
public static User Get(int uid)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a User");
return DataPortal.Fetch<User>(new PKCriteria(uid));
}
public static User Get(SafeDataReader dr)
{
if (dr.Read()) return new User(dr);
return null;
}
private User(SafeDataReader dr)
{
_UID = dr.GetInt32("UID");
_UserID = dr.GetString("UserID");
_FirstName = dr.GetString("FirstName");
_MiddleName = dr.GetString("MiddleName");
_LastName = dr.GetString("LastName");
_Suffix = dr.GetString("Suffix");
_CourtesyTitle = dr.GetString("CourtesyTitle");
_PhoneNumber = dr.GetString("PhoneNumber");
_CFGName = dr.GetString("CFGName");
_UserLogin = dr.GetString("UserLogin");
_UserName = dr.GetString("UserName");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int uid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a User");
DataPortal.Delete(new PKCriteria(uid));
}
public override User Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a User");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a User");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a User");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _UID;
public int UID
{ get { return _UID; } }
public PKCriteria(int uid)
{
_UID = uid;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_UID = NextUID;
// Database Defaults
_UserID = ext.DefaultUserID;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getUser";
cm.Parameters.AddWithValue("@UID", criteria.UID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_UID = dr.GetInt32("UID");
_UserID = dr.GetString("UserID");
_FirstName = dr.GetString("FirstName");
_MiddleName = dr.GetString("MiddleName");
_LastName = dr.GetString("LastName");
_Suffix = dr.GetString("Suffix");
_CourtesyTitle = dr.GetString("CourtesyTitle");
_PhoneNumber = dr.GetString("PhoneNumber");
_CFGName = dr.GetString("CFGName");
_UserLogin = dr.GetString("UserLogin");
_UserName = dr.GetString("UserName");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
// load child objects
dr.NextResult();
_UserMemberships = UserMemberships.Get(dr);
}
}
}
}
catch (Exception ex)
{
Database.LogException("User.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("User.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addUser";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@FirstName", _FirstName);
cm.Parameters.AddWithValue("@MiddleName", _MiddleName);
cm.Parameters.AddWithValue("@LastName", _LastName);
cm.Parameters.AddWithValue("@Suffix", _Suffix);
cm.Parameters.AddWithValue("@CourtesyTitle", _CourtesyTitle);
cm.Parameters.AddWithValue("@PhoneNumber", _PhoneNumber);
cm.Parameters.AddWithValue("@CFGName", _CFGName);
cm.Parameters.AddWithValue("@UserLogin", _UserLogin);
cm.Parameters.AddWithValue("@UserName", _UserName);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
// Output Calculated Columns
SqlParameter param_UID = new SqlParameter("@newUID", SqlDbType.Int);
param_UID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_UID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_UID = (int)cm.Parameters["@newUID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
_UserMemberships.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("User.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("User.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int uid, string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config, DateTime dts, string usrID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addUser";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@FirstName", firstName);
cm.Parameters.AddWithValue("@MiddleName", middleName);
cm.Parameters.AddWithValue("@LastName", lastName);
cm.Parameters.AddWithValue("@Suffix", suffix);
cm.Parameters.AddWithValue("@CourtesyTitle", courtesyTitle);
cm.Parameters.AddWithValue("@PhoneNumber", phoneNumber);
cm.Parameters.AddWithValue("@CFGName", cFGName);
cm.Parameters.AddWithValue("@UserLogin", userLogin);
cm.Parameters.AddWithValue("@UserName", userName);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
// Output Calculated Columns
SqlParameter param_UID = new SqlParameter("@newUID", SqlDbType.Int);
param_UID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_UID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
uid = (int)cm.Parameters["@newUID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("User.Add", ex);
throw new DbCslaException("User.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateUser";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@UID", _UID);
cm.Parameters.AddWithValue("@UserID", _UserID);
cm.Parameters.AddWithValue("@FirstName", _FirstName);
cm.Parameters.AddWithValue("@MiddleName", _MiddleName);
cm.Parameters.AddWithValue("@LastName", _LastName);
cm.Parameters.AddWithValue("@Suffix", _Suffix);
cm.Parameters.AddWithValue("@CourtesyTitle", _CourtesyTitle);
cm.Parameters.AddWithValue("@PhoneNumber", _PhoneNumber);
cm.Parameters.AddWithValue("@CFGName", _CFGName);
cm.Parameters.AddWithValue("@UserLogin", _UserLogin);
cm.Parameters.AddWithValue("@UserName", _UserName);
cm.Parameters.AddWithValue("@Config", _Config);
cm.Parameters.AddWithValue("@DTS", _DTS);
cm.Parameters.AddWithValue("@UsrID", _UsrID);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
_UserMemberships.Update(this, cn);
}
}
catch (Exception ex)
{
Database.LogException("User.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int uid, string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config, DateTime dts, string usrID, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateUser";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@UID", uid);
cm.Parameters.AddWithValue("@UserID", userID);
cm.Parameters.AddWithValue("@FirstName", firstName);
cm.Parameters.AddWithValue("@MiddleName", middleName);
cm.Parameters.AddWithValue("@LastName", lastName);
cm.Parameters.AddWithValue("@Suffix", suffix);
cm.Parameters.AddWithValue("@CourtesyTitle", courtesyTitle);
cm.Parameters.AddWithValue("@PhoneNumber", phoneNumber);
cm.Parameters.AddWithValue("@CFGName", cFGName);
cm.Parameters.AddWithValue("@UserLogin", userLogin);
cm.Parameters.AddWithValue("@UserName", userName);
cm.Parameters.AddWithValue("@Config", config);
cm.Parameters.AddWithValue("@DTS", dts);
cm.Parameters.AddWithValue("@UsrID", usrID);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("User.Update", ex);
throw new DbCslaException("User.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_UID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteUser";
cm.Parameters.AddWithValue("@UID", criteria.UID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("User.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("User.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int uid)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteUser";
// Input PK Fields
cm.Parameters.AddWithValue("@UID", uid);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("User.Remove", ex);
throw new DbCslaException("User.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int uid)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(uid));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _UID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int uid)
{
_UID = uid;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsUser";
cm.Parameters.AddWithValue("@UID", _UID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("User.DataPortal_Execute", ex);
throw new DbCslaException("User.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultUserID
{
get { return Environment.UserName.ToUpper(); }
}
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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create UserExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class User
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual string DefaultUserID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,250 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// UserInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class UserInfo : ReadOnlyBase<UserInfo>
{
#region Business Methods
private int _UID;
[System.ComponentModel.DataObjectField(true, true)]
public int UID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UID;
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserID;
}
}
private string _FirstName = string.Empty;
public string FirstName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FirstName;
}
}
private string _MiddleName = string.Empty;
public string MiddleName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _MiddleName;
}
}
private string _LastName = string.Empty;
public string LastName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _LastName;
}
}
private string _Suffix = string.Empty;
public string Suffix
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Suffix;
}
}
private string _CourtesyTitle = string.Empty;
public string CourtesyTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _CourtesyTitle;
}
}
private string _PhoneNumber = string.Empty;
public string PhoneNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PhoneNumber;
}
}
private string _CFGName = string.Empty;
public string CFGName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _CFGName;
}
}
private string _UserLogin = string.Empty;
public string UserLogin
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserLogin;
}
}
private string _UserName = string.Empty;
public string UserName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UserName;
}
}
private string _Config = string.Empty;
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Config;
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UsrID;
}
}
private int _Membershipcount = 0;
/// <summary>
/// Count of Membership for this User
/// </summary>
public int MembershipCount
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Membershipcount;
}
}
private MembershipInfoList _Memberships = null;
public MembershipInfoList Memberships
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
if (_Memberships == null)
_Memberships = MembershipInfoList.GetByUser(_UID);
return _Memberships;
}
}
// TODO: Replace base UserInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current UserInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check UserInfo.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 UserInfo</returns>
protected override object GetIdValue()
{
return _UID;
}
#endregion
#region Factory Methods
private UserInfo()
{ /* require use of factory methods */ }
public User Get()
{
return User.Get(_UID);
}
#endregion
#region Data Access Portal
internal UserInfo(SafeDataReader dr)
{
try
{
_UID = dr.GetInt32("UID");
_UserID = dr.GetString("UserID");
_FirstName = dr.GetString("FirstName");
_MiddleName = dr.GetString("MiddleName");
_LastName = dr.GetString("LastName");
_Suffix = dr.GetString("Suffix");
_CourtesyTitle = dr.GetString("CourtesyTitle");
_PhoneNumber = dr.GetString("PhoneNumber");
_CFGName = dr.GetString("CFGName");
_UserLogin = dr.GetString("UserLogin");
_UserName = dr.GetString("UserName");
_Config = dr.GetString("Config");
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
_Membershipcount = dr.GetInt32("MembershipCount");
}
catch (Exception ex)
{
Database.LogException("UserInfo.Constructor", ex);
throw new DbCslaException("UserInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,76 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// UserInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class UserInfoList : ReadOnlyListBase<UserInfoList, UserInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static UserInfoList Get()
{
return DataPortal.Fetch<UserInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static UserInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<UserInfoList>(new FilteredCriteria(<criteria>));
//}
private UserInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getUsers";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new UserInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("UserInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("UserInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,494 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// UserMembership Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class UserMembership : BusinessBase<UserMembership>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _UGID;
[System.ComponentModel.DataObjectField(true, true)]
public int UGID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _UGID;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _GID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_GID != value)
{
_GID = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(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(true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
private string _Group_GroupName = string.Empty;
public string Group_GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_GroupName;
}
}
private int _Group_GroupType;
public int Group_GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_GroupType;
}
}
private string _Group_Config = string.Empty;
public string Group_Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_Config;
}
}
private DateTime _Group_DTS = new DateTime();
public DateTime Group_DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_DTS;
}
}
private string _Group_UsrID = string.Empty;
public string Group_UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Group_UsrID;
}
}
// TODO: Check UserMembership.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 UserMembership</returns>
protected override object GetIdValue()
{
return _UGID;
}
// TODO: Replace base UserMembership.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current UserMembership</returns>
//public override string ToString()
//{
// return base.ToString();
//}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "StartDate");
ValidationRules.AddRule(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "UsrID");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100));
// TODO: Add other validation rules
}
private bool StartDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_StartDate);
}
catch
{
e.Description = "Invalid Date";
return false;
}
return true;
}
private bool EndDateValid(object target, Csla.Validation.RuleArgs e)
{
try
{
DateTime tmp = SmartDate.StringToDate(_EndDate);
}
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()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(UGID, "<Role(s)>");
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
internal static UserMembership New(int gid)
{
return new UserMembership(Volian.CSLA.Library.Group.Get(gid));
}
internal static UserMembership Get(SafeDataReader dr)
{
return new UserMembership(dr);
}
public UserMembership()
{
MarkAsChild();
_UGID = Membership.NextUGID;
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
}
private UserMembership(Group group)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_StartDate = ext.DefaultStartDate;
_DTS = ext.DefaultDTS;
_UsrID = ext.DefaultUsrID;
_GID = group.GID;
_Group_GroupName = group.GroupName;
_Group_GroupType = group.GroupType;
_Group_Config = group.Config;
_Group_DTS = group.DTS;
_Group_UsrID = group.UsrID;
}
private UserMembership(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try
{
_UGID = dr.GetInt32("UGID");
_GID = dr.GetInt32("GID");
_StartDate = dr.GetSmartDate("StartDate").Text;
_EndDate = dr.GetSmartDate("EndDate").Text;
_DTS = dr.GetDateTime("DTS");
_UsrID = dr.GetString("UsrID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Group_GroupName = dr.GetString("Group_GroupName");
_Group_GroupType = dr.GetInt32("Group_GroupType");
_Group_Config = dr.GetString("Group_Config");
_Group_DTS = dr.GetDateTime("Group_DTS");
_Group_UsrID = dr.GetString("Group_UsrID");
}
catch (Exception ex) // FKItem Fetch
{
Database.LogException("UserMembership.Fetch", ex);
throw new DbCslaException("UserMembership.Fetch", ex);
}
MarkOld();
}
internal void Insert(User user, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Membership.Add(cn, ref _UGID, user.UID, _GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID);
MarkOld();
}
internal void Update(User user, SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_LastChanged = Membership.Update(cn, ref _UGID, user.UID, _GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged);
MarkOld();
}
internal void DeleteSelf(User user, SqlConnection cn)
{
// 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;
Membership.Remove(cn, _UGID);
MarkNew();
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : extensionBase
{
}
[Serializable()]
class extensionBase
{
// Default Values
public virtual string DefaultStartDate
{
get { return DateTime.Now.ToShortDateString(); }
}
public virtual DateTime DefaultDTS
{
get { return DateTime.Now; }
}
public virtual string DefaultUsrID
{
get { return Environment.UserName.ToUpper(); }
}
// Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{
// Needs to be overriden to add new authorization rules
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create UserMembershipExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class UserMembership
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDTS
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrID
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
// }
//}

View File

@@ -0,0 +1,142 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// UserMemberships Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class UserMemberships : BusinessListBase<UserMemberships, UserMembership>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
// Many To Many
public new UserMembership this[int gid]
{
get
{
foreach (UserMembership membership in this)
if (membership.GID == gid)
return membership;
return null;
}
}
public UserMembership GetItem(int gid)
{
foreach (UserMembership membership in this)
if (membership.GID == gid)
return membership;
return null;
}
public UserMembership Add(int gid)
{
if (!Contains(gid))
{
UserMembership membership = UserMembership.New(gid);
this.Add(membership);
return membership;
}
else
throw new InvalidOperationException("membership already exists");
}
public void Remove(int gid)
{
foreach (UserMembership membership in this)
{
if (membership.GID == gid)
{
Remove(membership);
break;
}
}
}
public bool Contains(int gid)
{
foreach (UserMembership membership in this)
if (membership.GID == gid)
return true;
return false;
}
public bool ContainsDeleted(int gid)
{
foreach (UserMembership membership in DeletedList)
if (membership.GID == gid)
return true;
return false;
}
#endregion
#region Factory Methods
internal static UserMemberships New()
{
return new UserMemberships();
}
internal static UserMemberships Get(SafeDataReader dr)
{
return new UserMemberships(dr);
}
private UserMemberships()
{
MarkAsChild();
}
private UserMemberships(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(UserMembership.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(User user, SqlConnection cn)
{
this.RaiseListChangedEvents = false;
try
{
// update (thus deleting) any deleted child objects
foreach (UserMembership obj in DeletedList)
obj.DeleteSelf(user, cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (UserMembership obj in this)
{
if (obj.IsNew)
obj.Insert(user, cn);
else
obj.Update(user, cn);
}
}
finally
{
this.RaiseListChangedEvents = true;
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,531 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZSection Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZSection : BusinessBase<ZSection>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _SectID;
[System.ComponentModel.DataObjectField(true, true)]
public int SectID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SectID;
}
}
private string _OldStepSequence = string.Empty;
public string OldStepSequence
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _OldStepSequence;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_OldStepSequence != value)
{
_OldStepSequence = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base ZSection.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZSection</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZSection.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 ZSection</returns>
protected override object GetIdValue()
{
return _SectID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "OldStepSequence");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("OldStepSequence", 14));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(SectID, "<Role(s)>");
//AuthorizationRules.AllowRead(OldStepSequence, "<Role(s)>");
//AuthorizationRules.AllowWrite(OldStepSequence, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private ZSection()
{/* require use of factory methods */}
public static ZSection New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ZSection");
return DataPortal.Create<ZSection>();
}
public static ZSection New(int sectID, string oldStepSequence)
{
ZSection tmp = ZSection.New();
tmp._SectID = sectID;
tmp.OldStepSequence = oldStepSequence;
return tmp;
}
public static ZSection MakeZSection(int sectID, string oldStepSequence)
{
ZSection tmp = ZSection.New(sectID, oldStepSequence);
tmp.Save();
return tmp;
}
public static ZSection Get(int sectID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ZSection");
return DataPortal.Fetch<ZSection>(new PKCriteria(sectID));
}
public static ZSection Get(SafeDataReader dr)
{
if (dr.Read()) return new ZSection(dr);
return null;
}
private ZSection(SafeDataReader dr)
{
_SectID = dr.GetInt32("SectID");
_OldStepSequence = dr.GetString("OldStepSequence");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int sectID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ZSection");
DataPortal.Delete(new PKCriteria(sectID));
}
public override ZSection Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ZSection");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ZSection");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a ZSection");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _SectID;
public int SectID
{ get { return _SectID; } }
public PKCriteria(int sectID)
{
_SectID = sectID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// Database Defaults
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZSection";
cm.Parameters.AddWithValue("@SectID", criteria.SectID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_SectID = dr.GetInt32("SectID");
_OldStepSequence = dr.GetString("OldStepSequence");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZSection.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZSection.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addZSection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@SectID", _SectID);
cm.Parameters.AddWithValue("@OldStepSequence", _OldStepSequence);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("ZSection.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZSection.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, int sectID, string oldStepSequence)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addZSection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@SectID", sectID);
cm.Parameters.AddWithValue("@OldStepSequence", oldStepSequence);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("ZSection.Add", ex);
throw new DbCslaException("ZSection.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateZSection";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@SectID", _SectID);
cm.Parameters.AddWithValue("@OldStepSequence", _OldStepSequence);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("ZSection.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, int sectID, string oldStepSequence, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateZSection";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@SectID", sectID);
cm.Parameters.AddWithValue("@OldStepSequence", oldStepSequence);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("ZSection.Update", ex);
throw new DbCslaException("ZSection.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_SectID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteZSection";
cm.Parameters.AddWithValue("@SectID", criteria.SectID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("ZSection.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZSection.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int sectID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteZSection";
// Input PK Fields
cm.Parameters.AddWithValue("@SectID", sectID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("ZSection.Remove", ex);
throw new DbCslaException("ZSection.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int sectID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(sectID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _SectID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int sectID)
{
_SectID = sectID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsZSection";
cm.Parameters.AddWithValue("@SectID", _SectID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("ZSection.DataPortal_Execute", ex);
throw new DbCslaException("ZSection.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create ZSectionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class ZSection
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,92 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZSectionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZSectionInfo : ReadOnlyBase<ZSectionInfo>
{
#region Business Methods
private int _SectID;
[System.ComponentModel.DataObjectField(true, true)]
public int SectID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _SectID;
}
}
private string _OldStepSequence = string.Empty;
public string OldStepSequence
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _OldStepSequence;
}
}
// TODO: Replace base ZSectionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZSectionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZSectionInfo.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 ZSectionInfo</returns>
protected override object GetIdValue()
{
return _SectID;
}
#endregion
#region Factory Methods
private ZSectionInfo()
{ /* require use of factory methods */ }
public ZSection Get()
{
return ZSection.Get(_SectID);
}
#endregion
#region Data Access Portal
internal ZSectionInfo(SafeDataReader dr)
{
try
{
_SectID = dr.GetInt32("SectID");
_OldStepSequence = dr.GetString("OldStepSequence");
}
catch (Exception ex)
{
Database.LogException("ZSectionInfo.Constructor", ex);
throw new DbCslaException("ZSectionInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZSectionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZSectionInfoList : ReadOnlyListBase<ZSectionInfoList, ZSectionInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static ZSectionInfoList Get()
{
return DataPortal.Fetch<ZSectionInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static ZSectionInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<ZSectionInfoList>(new FilteredCriteria(<criteria>));
//}
public static ZSectionInfoList GetBySection(int sectID)
{
return DataPortal.Fetch<ZSectionInfoList>(new SectionCriteria(sectID));
}
private ZSectionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZSections";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ZSectionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZSectionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ZSectionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class SectionCriteria
{
public SectionCriteria(int sectID)
{
_SectID = sectID;
}
private int _SectID;
public int SectID
{
get { return _SectID; }
set { _SectID = value; }
}
}
private void DataPortal_Fetch(SectionCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZSectionsBySection";
cm.Parameters.AddWithValue("@SectID", criteria.SectID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ZSectionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZSectionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ZSectionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,531 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZStep Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZStep : BusinessBase<ZStep>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _StepID;
[System.ComponentModel.DataObjectField(true, true)]
public int StepID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepID;
}
}
private string _OldStepSequence = string.Empty;
public string OldStepSequence
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _OldStepSequence;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_OldStepSequence != value)
{
_OldStepSequence = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base ZStep.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZStep</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZStep.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 ZStep</returns>
protected override object GetIdValue()
{
return _StepID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "OldStepSequence");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("OldStepSequence", 12));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(StepID, "<Role(s)>");
//AuthorizationRules.AllowRead(OldStepSequence, "<Role(s)>");
//AuthorizationRules.AllowWrite(OldStepSequence, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private ZStep()
{/* require use of factory methods */}
public static ZStep New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ZStep");
return DataPortal.Create<ZStep>();
}
public static ZStep New(int stepID, string oldStepSequence)
{
ZStep tmp = ZStep.New();
tmp._StepID = stepID;
tmp.OldStepSequence = oldStepSequence;
return tmp;
}
public static ZStep MakeZStep(int stepID, string oldStepSequence)
{
ZStep tmp = ZStep.New(stepID, oldStepSequence);
tmp.Save();
return tmp;
}
public static ZStep Get(int stepID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ZStep");
return DataPortal.Fetch<ZStep>(new PKCriteria(stepID));
}
public static ZStep Get(SafeDataReader dr)
{
if (dr.Read()) return new ZStep(dr);
return null;
}
private ZStep(SafeDataReader dr)
{
_StepID = dr.GetInt32("StepID");
_OldStepSequence = dr.GetString("OldStepSequence");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int stepID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ZStep");
DataPortal.Delete(new PKCriteria(stepID));
}
public override ZStep Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ZStep");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ZStep");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a ZStep");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _StepID;
public int StepID
{ get { return _StepID; } }
public PKCriteria(int stepID)
{
_StepID = stepID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// Database Defaults
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZStep";
cm.Parameters.AddWithValue("@StepID", criteria.StepID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_StepID = dr.GetInt32("StepID");
_OldStepSequence = dr.GetString("OldStepSequence");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZStep.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZStep.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addZStep";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepID", _StepID);
cm.Parameters.AddWithValue("@OldStepSequence", _OldStepSequence);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("ZStep.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZStep.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, int stepID, string oldStepSequence)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addZStep";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepID", stepID);
cm.Parameters.AddWithValue("@OldStepSequence", oldStepSequence);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("ZStep.Add", ex);
throw new DbCslaException("ZStep.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateZStep";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@StepID", _StepID);
cm.Parameters.AddWithValue("@OldStepSequence", _OldStepSequence);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("ZStep.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, int stepID, string oldStepSequence, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateZStep";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StepID", stepID);
cm.Parameters.AddWithValue("@OldStepSequence", oldStepSequence);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("ZStep.Update", ex);
throw new DbCslaException("ZStep.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_StepID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteZStep";
cm.Parameters.AddWithValue("@StepID", criteria.StepID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("ZStep.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZStep.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int stepID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteZStep";
// Input PK Fields
cm.Parameters.AddWithValue("@StepID", stepID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("ZStep.Remove", ex);
throw new DbCslaException("ZStep.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int stepID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(stepID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _StepID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int stepID)
{
_StepID = stepID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsZStep";
cm.Parameters.AddWithValue("@StepID", _StepID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("ZStep.DataPortal_Execute", ex);
throw new DbCslaException("ZStep.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create ZStepExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class ZStep
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,92 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZStepInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZStepInfo : ReadOnlyBase<ZStepInfo>
{
#region Business Methods
private int _StepID;
[System.ComponentModel.DataObjectField(true, true)]
public int StepID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StepID;
}
}
private string _OldStepSequence = string.Empty;
public string OldStepSequence
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _OldStepSequence;
}
}
// TODO: Replace base ZStepInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZStepInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZStepInfo.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 ZStepInfo</returns>
protected override object GetIdValue()
{
return _StepID;
}
#endregion
#region Factory Methods
private ZStepInfo()
{ /* require use of factory methods */ }
public ZStep Get()
{
return ZStep.Get(_StepID);
}
#endregion
#region Data Access Portal
internal ZStepInfo(SafeDataReader dr)
{
try
{
_StepID = dr.GetInt32("StepID");
_OldStepSequence = dr.GetString("OldStepSequence");
}
catch (Exception ex)
{
Database.LogException("ZStepInfo.Constructor", ex);
throw new DbCslaException("ZStepInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZStepInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZStepInfoList : ReadOnlyListBase<ZStepInfoList, ZStepInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static ZStepInfoList Get()
{
return DataPortal.Fetch<ZStepInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static ZStepInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<ZStepInfoList>(new FilteredCriteria(<criteria>));
//}
public static ZStepInfoList GetByStep(int stepID)
{
return DataPortal.Fetch<ZStepInfoList>(new StepCriteria(stepID));
}
private ZStepInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZSteps";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ZStepInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZStepInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ZStepInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StepCriteria
{
public StepCriteria(int stepID)
{
_StepID = stepID;
}
private int _StepID;
public int StepID
{
get { return _StepID; }
set { _StepID = value; }
}
}
private void DataPortal_Fetch(StepCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZStepsByStep";
cm.Parameters.AddWithValue("@StepID", criteria.StepID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ZStepInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZStepInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ZStepInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,740 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZStruct Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZStruct : BusinessBase<ZStruct>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private static int _nextStructureID = -1;
public static int NextStructureID
{
get { return _nextStructureID--; }
}
private int _StructureID;
[System.ComponentModel.DataObjectField(true, true)]
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
}
private int _FromType;
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FromType != value)
{
_FromType = value;
PropertyHasChanged();
}
}
}
private int _FromID;
public int FromID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_FromID != value)
{
_FromID = value;
PropertyHasChanged();
}
}
}
private int _ContentType;
public int ContentType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentType;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ContentType != value)
{
_ContentType = value;
PropertyHasChanged();
}
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_ContentID != value)
{
_ContentID = value;
PropertyHasChanged();
}
}
}
private int _Level;
public int Level
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Level;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_Level != value)
{
_Level = value;
PropertyHasChanged();
}
}
}
private int _Item;
public int Item
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Item;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (_Item != value)
{
_Item = value;
PropertyHasChanged();
}
}
}
private string _PPath = string.Empty;
public string PPath
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PPath;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_PPath != value)
{
_PPath = value;
PropertyHasChanged();
}
}
}
private string _Path = string.Empty;
public string Path
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Path;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Path != value)
{
_Path = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base ZStruct.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZStruct</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZStruct.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 ZStruct</returns>
protected override object GetIdValue()
{
return _StructureID;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// 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(StructureID, "<Role(s)>");
//AuthorizationRules.AllowRead(FromType, "<Role(s)>");
//AuthorizationRules.AllowRead(FromID, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentType, "<Role(s)>");
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
//AuthorizationRules.AllowRead(Level, "<Role(s)>");
//AuthorizationRules.AllowRead(Item, "<Role(s)>");
//AuthorizationRules.AllowRead(PPath, "<Role(s)>");
//AuthorizationRules.AllowRead(Path, "<Role(s)>");
//AuthorizationRules.AllowWrite(FromType, "<Role(s)>");
//AuthorizationRules.AllowWrite(FromID, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentType, "<Role(s)>");
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
//AuthorizationRules.AllowWrite(Level, "<Role(s)>");
//AuthorizationRules.AllowWrite(Item, "<Role(s)>");
//AuthorizationRules.AllowWrite(PPath, "<Role(s)>");
//AuthorizationRules.AllowWrite(Path, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private ZStruct()
{/* require use of factory methods */}
public static ZStruct New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ZStruct");
return DataPortal.Create<ZStruct>();
}
public static ZStruct New(int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path)
{
ZStruct tmp = ZStruct.New();
tmp.FromType = fromType;
tmp.FromID = fromID;
tmp.ContentType = contentType;
tmp.ContentID = contentID;
tmp.Level = level;
tmp.Item = item;
tmp.PPath = pPath;
tmp.Path = path;
return tmp;
}
public static ZStruct MakeZStruct(int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path)
{
ZStruct tmp = ZStruct.New(fromType, fromID, contentType, contentID, level, item, pPath, path);
tmp.Save();
return tmp;
}
public static ZStruct Get(int structureID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ZStruct");
return DataPortal.Fetch<ZStruct>(new PKCriteria(structureID));
}
public static ZStruct Get(SafeDataReader dr)
{
if (dr.Read()) return new ZStruct(dr);
return null;
}
private ZStruct(SafeDataReader dr)
{
_StructureID = dr.GetInt32("StructureID");
_FromType = dr.GetInt32("FromType");
_FromID = dr.GetInt32("FromID");
_ContentType = dr.GetInt32("ContentType");
_ContentID = dr.GetInt32("ContentID");
_Level = dr.GetInt32("Level");
_Item = dr.GetInt32("Item");
_PPath = dr.GetString("PPath");
_Path = dr.GetString("Path");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int structureID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ZStruct");
DataPortal.Delete(new PKCriteria(structureID));
}
public override ZStruct Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ZStruct");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ZStruct");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a ZStruct");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _StructureID;
public int StructureID
{ get { return _StructureID; } }
public PKCriteria(int structureID)
{
_StructureID = structureID;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
_StructureID = NextStructureID;
// Database Defaults
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZStruct";
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_StructureID = dr.GetInt32("StructureID");
_FromType = dr.GetInt32("FromType");
_FromID = dr.GetInt32("FromID");
_ContentType = dr.GetInt32("ContentType");
_ContentID = dr.GetInt32("ContentID");
_Level = dr.GetInt32("Level");
_Item = dr.GetInt32("Item");
_PPath = dr.GetString("PPath");
_Path = dr.GetString("Path");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZStruct.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZStruct.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addZStruct";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FromType", _FromType);
cm.Parameters.AddWithValue("@FromID", _FromID);
cm.Parameters.AddWithValue("@ContentType", _ContentType);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@Level", _Level);
cm.Parameters.AddWithValue("@Item", _Item);
cm.Parameters.AddWithValue("@PPath", _PPath);
cm.Parameters.AddWithValue("@Path", _Path);
// Output Calculated Columns
SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int);
param_StructureID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_StructureID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_StructureID = (int)cm.Parameters["@newStructureID"].Value;
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("ZStruct.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZStruct.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addZStruct";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@FromType", fromType);
cm.Parameters.AddWithValue("@FromID", fromID);
cm.Parameters.AddWithValue("@ContentType", contentType);
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@Level", level);
cm.Parameters.AddWithValue("@Item", item);
cm.Parameters.AddWithValue("@PPath", pPath);
cm.Parameters.AddWithValue("@Path", path);
// Output Calculated Columns
SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int);
param_StructureID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_StructureID);
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
structureID = (int)cm.Parameters["@newStructureID"].Value;
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("ZStruct.Add", ex);
throw new DbCslaException("ZStruct.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateZStruct";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@StructureID", _StructureID);
cm.Parameters.AddWithValue("@FromType", _FromType);
cm.Parameters.AddWithValue("@FromID", _FromID);
cm.Parameters.AddWithValue("@ContentType", _ContentType);
cm.Parameters.AddWithValue("@ContentID", _ContentID);
cm.Parameters.AddWithValue("@Level", _Level);
cm.Parameters.AddWithValue("@Item", _Item);
cm.Parameters.AddWithValue("@PPath", _PPath);
cm.Parameters.AddWithValue("@Path", _Path);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("ZStruct.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateZStruct";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@StructureID", structureID);
cm.Parameters.AddWithValue("@FromType", fromType);
cm.Parameters.AddWithValue("@FromID", fromID);
cm.Parameters.AddWithValue("@ContentType", contentType);
cm.Parameters.AddWithValue("@ContentID", contentID);
cm.Parameters.AddWithValue("@Level", level);
cm.Parameters.AddWithValue("@Item", item);
cm.Parameters.AddWithValue("@PPath", pPath);
cm.Parameters.AddWithValue("@Path", path);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("ZStruct.Update", ex);
throw new DbCslaException("ZStruct.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_StructureID));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteZStruct";
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("ZStruct.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZStruct.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int structureID)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteZStruct";
// Input PK Fields
cm.Parameters.AddWithValue("@StructureID", structureID);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("ZStruct.Remove", ex);
throw new DbCslaException("ZStruct.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int structureID)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(structureID));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _StructureID;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int structureID)
{
_StructureID = structureID;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsZStruct";
cm.Parameters.AddWithValue("@StructureID", _StructureID);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("ZStruct.DataPortal_Execute", ex);
throw new DbCslaException("ZStruct.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create ZStructExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class ZStruct
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,169 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZStructInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZStructInfo : ReadOnlyBase<ZStructInfo>
{
#region Business Methods
private int _StructureID;
[System.ComponentModel.DataObjectField(true, true)]
public int StructureID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _StructureID;
}
}
private int _FromType;
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromType;
}
}
private int _FromID;
public int FromID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _FromID;
}
}
private int _ContentType;
public int ContentType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentType;
}
}
private int _ContentID;
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _ContentID;
}
}
private int _Level;
public int Level
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Level;
}
}
private int _Item;
public int Item
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Item;
}
}
private string _PPath = string.Empty;
public string PPath
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _PPath;
}
}
private string _Path = string.Empty;
public string Path
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Path;
}
}
// TODO: Replace base ZStructInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZStructInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZStructInfo.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 ZStructInfo</returns>
protected override object GetIdValue()
{
return _StructureID;
}
#endregion
#region Factory Methods
private ZStructInfo()
{ /* require use of factory methods */ }
public ZStruct Get()
{
return ZStruct.Get(_StructureID);
}
#endregion
#region Data Access Portal
internal ZStructInfo(SafeDataReader dr)
{
try
{
_StructureID = dr.GetInt32("StructureID");
_FromType = dr.GetInt32("FromType");
_FromID = dr.GetInt32("FromID");
_ContentType = dr.GetInt32("ContentType");
_ContentID = dr.GetInt32("ContentID");
_Level = dr.GetInt32("Level");
_Item = dr.GetInt32("Item");
_PPath = dr.GetString("PPath");
_Path = dr.GetString("Path");
}
catch (Exception ex)
{
Database.LogException("ZStructInfo.Constructor", ex);
throw new DbCslaException("ZStructInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZStructInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZStructInfoList : ReadOnlyListBase<ZStructInfoList, ZStructInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static ZStructInfoList Get()
{
return DataPortal.Fetch<ZStructInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static ZStructInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<ZStructInfoList>(new FilteredCriteria(<criteria>));
//}
public static ZStructInfoList GetByStructure(int structureID)
{
return DataPortal.Fetch<ZStructInfoList>(new StructureCriteria(structureID));
}
private ZStructInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZStructs";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ZStructInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZStructInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ZStructInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class StructureCriteria
{
public StructureCriteria(int structureID)
{
_StructureID = structureID;
}
private int _StructureID;
public int StructureID
{
get { return _StructureID; }
set { _StructureID = value; }
}
}
private void DataPortal_Fetch(StructureCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZStructsByStructure";
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ZStructInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZStructInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ZStructInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,531 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZTransition Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZTransition : BusinessBase<ZTransition>
{
#region Business Methods
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get { return _errorMessage; }
}
private int _TransitionId;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TransitionId;
}
}
private string _Oldto = string.Empty;
public string Oldto
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Oldto;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty(true);
if (value == null) value = string.Empty;
if (_Oldto != value)
{
_Oldto = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
// TODO: Replace base ZTransition.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZTransition</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZTransition.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 ZTransition</returns>
protected override object GetIdValue()
{
return _TransitionId;
}
#endregion
#region ValidationRules
protected override void AddBusinessRules()
{
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringRequired, "Oldto");
ValidationRules.AddRule(
Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Oldto", 32));
ext.AddValidationRules(ValidationRules);
// TODO: Add other validation rules
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
}
// Sample data comparison validation rule
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//{
// if (_started > _ended)
// {
// e.Description = "Start date can't be after end date";
// return false;
// }
// else
// return true;
//}
#endregion
#region Authorization Rules
protected override void AddAuthorizationRules()
{
//TODO: Who can read/write which fields
//AuthorizationRules.AllowRead(TransitionId, "<Role(s)>");
//AuthorizationRules.AllowRead(Oldto, "<Role(s)>");
//AuthorizationRules.AllowWrite(Oldto, "<Role(s)>");
ext.AddAuthorizationRules(AuthorizationRules);
}
public static bool CanAddObject()
{
// TODO: Can Add Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
public static bool CanGetObject()
{
// TODO: CanGet Authorization
return true;
}
public static bool CanDeleteObject()
{
// TODO: CanDelete Authorization
//bool result = false;
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
//return result;
return true;
}
public static bool CanEditObject()
{
// TODO: CanEdit Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true;
}
#endregion
#region Factory Methods
public int CurrentEditLevel
{ get { return EditLevel; } }
private ZTransition()
{/* require use of factory methods */}
public static ZTransition New()
{
if (!CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ZTransition");
return DataPortal.Create<ZTransition>();
}
public static ZTransition New(int transitionId, string oldto)
{
ZTransition tmp = ZTransition.New();
tmp._TransitionId = transitionId;
tmp.Oldto = oldto;
return tmp;
}
public static ZTransition MakeZTransition(int transitionId, string oldto)
{
ZTransition tmp = ZTransition.New(transitionId, oldto);
tmp.Save();
return tmp;
}
public static ZTransition Get(int transitionId)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ZTransition");
return DataPortal.Fetch<ZTransition>(new PKCriteria(transitionId));
}
public static ZTransition Get(SafeDataReader dr)
{
if (dr.Read()) return new ZTransition(dr);
return null;
}
private ZTransition(SafeDataReader dr)
{
_TransitionId = dr.GetInt32("TransitionId");
_Oldto = dr.GetString("oldto");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
public static void Delete(int transitionId)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ZTransition");
DataPortal.Delete(new PKCriteria(transitionId));
}
public override ZTransition Save()
{
if (IsDeleted && !CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a ZTransition");
else if (IsNew && !CanAddObject())
throw new System.Security.SecurityException("User not authorized to add a ZTransition");
else if (!CanEditObject())
throw new System.Security.SecurityException("User not authorized to update a ZTransition");
return base.Save();
}
#endregion
#region Data Access Portal
[Serializable()]
private class PKCriteria
{
private int _TransitionId;
public int TransitionId
{ get { return _TransitionId; } }
public PKCriteria(int transitionId)
{
_TransitionId = transitionId;
}
}
// TODO: If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// Database Defaults
// TODO: Add any defaults that are necessary
ValidationRules.CheckRules();
}
private void DataPortal_Fetch(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZTransition";
cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
dr.Read();
_TransitionId = dr.GetInt32("TransitionId");
_Oldto = dr.GetString("oldto");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZTransition.DataPortal_Fetch", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZTransition.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Insert()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addZTransition";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@TransitionId", _TransitionId);
cm.Parameters.AddWithValue("@Oldto", _Oldto);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
// update child objects
}
}
catch (Exception ex)
{
Database.LogException("ZTransition.DataPortal_Insert", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZTransition.DataPortal_Fetch", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Add(SqlConnection cn, int transitionId, string oldto)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "addZTransition";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@TransitionId", transitionId);
cm.Parameters.AddWithValue("@Oldto", oldto);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("ZTransition.Add", ex);
throw new DbCslaException("ZTransition.Add", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_Update()
{
if (IsDirty)// If this is dirty - open the connection
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
if (base.IsDirty)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateZTransition";
// All Fields including Calculated Fields
cm.Parameters.AddWithValue("@TransitionId", _TransitionId);
cm.Parameters.AddWithValue("@Oldto", _Oldto);
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
// use the open connection to update child objects
}
}
catch (Exception ex)
{
Database.LogException("ZTransition.DataPortal_Update", ex);
_errorMessage = ex.Message;
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
}
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static byte[] Update(SqlConnection cn, int transitionId, string oldto, ref byte[] lastChanged)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "updateZTransition";
// Input All Fields - Except Calculated Columns
cm.Parameters.AddWithValue("@TransitionId", transitionId);
cm.Parameters.AddWithValue("@Oldto", oldto);
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
// Output Calculated Columns
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
param_LastChanged.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_LastChanged);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
// Save all values being returned from the Procedure
return (byte[])cm.Parameters["@newLastChanged"].Value;
}
}
catch (Exception ex)
{
Database.LogException("ZTransition.Update", ex);
throw new DbCslaException("ZTransition.Update", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
protected override void DataPortal_DeleteSelf()
{
DataPortal_Delete(new PKCriteria(_TransitionId));
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(PKCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteZTransition";
cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId);
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Database.LogException("ZTransition.DataPortal_Delete", ex);
_errorMessage = ex.Message;
throw new DbCslaException("ZTransition.DataPortal_Delete", ex);
}
}
[Transactional(TransactionalTypes.TransactionScope)]
public static void Remove(SqlConnection cn, int transitionId)
{
try
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "deleteZTransition";
// Input PK Fields
cm.Parameters.AddWithValue("@TransitionId", transitionId);
// TODO: Define any additional output parameters
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Database.LogException("ZTransition.Remove", ex);
throw new DbCslaException("ZTransition.Remove", ex);
}
}
#endregion
#region Exists
public static bool Exists(int transitionId)
{
ExistsCommand result;
result = DataPortal.Execute<ExistsCommand>
(new ExistsCommand(transitionId));
return result.Exists;
}
[Serializable()]
private class ExistsCommand : CommandBase
{
private int _TransitionId;
private bool _exists;
public bool Exists
{
get { return _exists; }
}
public ExistsCommand(int transitionId)
{
_TransitionId = transitionId;
}
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "existsZTransition";
cm.Parameters.AddWithValue("@TransitionId", _TransitionId);
int count = (int)cm.ExecuteScalar();
_exists = (count > 0);
}
}
}
catch (Exception ex)
{
Database.LogException("ZTransition.DataPortal_Execute", ex);
throw new DbCslaException("ZTransition.DataPortal_Execute", ex);
}
}
}
#endregion
// Standard Default Code
#region extension
Extension ext = new Extension();
[Serializable()]
partial class Extension : 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
}
// Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{
// Needs to be overriden to add new validation rules
}
}
#endregion
} // Class
} // Namespace
//// The following is a sample Extension File. You can use it to create ZTransitionExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace Volian.CSLA.Library
//{
// public partial class ZTransition
// {
// partial class Extension : extensionBase
// {
// // TODO: Override automatic defaults
// 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));
// }
// }
// }
//}

View File

@@ -0,0 +1,92 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZTransitionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZTransitionInfo : ReadOnlyBase<ZTransitionInfo>
{
#region Business Methods
private int _TransitionId;
[System.ComponentModel.DataObjectField(true, true)]
public int TransitionId
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _TransitionId;
}
}
private string _Oldto = string.Empty;
public string Oldto
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _Oldto;
}
}
// TODO: Replace base ZTransitionInfo.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current ZTransitionInfo</returns>
//public override string ToString()
//{
// return base.ToString();
//}
// TODO: Check ZTransitionInfo.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 ZTransitionInfo</returns>
protected override object GetIdValue()
{
return _TransitionId;
}
#endregion
#region Factory Methods
private ZTransitionInfo()
{ /* require use of factory methods */ }
public ZTransition Get()
{
return ZTransition.Get(_TransitionId);
}
#endregion
#region Data Access Portal
internal ZTransitionInfo(SafeDataReader dr)
{
try
{
_TransitionId = dr.GetInt32("TransitionId");
_Oldto = dr.GetString("oldto");
}
catch (Exception ex)
{
Database.LogException("ZTransitionInfo.Constructor", ex);
throw new DbCslaException("ZTransitionInfo.Constructor", ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,122 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
namespace Volian.CSLA.Library
{
/// <summary>
/// ZTransitionInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ZTransitionInfoList : ReadOnlyListBase<ZTransitionInfoList, ZTransitionInfo>
{
#region Factory Methods
/// <summary>
/// Return a list of all projects.
/// </summary>
public static ZTransitionInfoList Get()
{
return DataPortal.Fetch<ZTransitionInfoList>(new Criteria());
}
// TODO: Add alternative gets -
//public static ZTransitionInfoList Get(<criteria>)
//{
// return DataPortal.Fetch<ZTransitionInfoList>(new FilteredCriteria(<criteria>));
//}
public static ZTransitionInfoList GetByTransition(int transitionId)
{
return DataPortal.Fetch<ZTransitionInfoList>(new TransitionCriteria(transitionId));
}
private ZTransitionInfoList()
{ /* require use of factory methods */ }
#endregion
#region Data Access Portal
[Serializable()]
private class Criteria
{ /* no criteria - retrieve all rows */ }
private void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZTransitions";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ZTransitionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZTransitionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ZTransitionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
[Serializable()]
private class TransitionCriteria
{
public TransitionCriteria(int transitionId)
{
_TransitionId = transitionId;
}
private int _TransitionId;
public int TransitionId
{
get { return _TransitionId; }
set { _TransitionId = value; }
}
}
private void DataPortal_Fetch(TransitionCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getZTransitionsByTransition";
cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new ZTransitionInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ZTransitionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ZTransitionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace