Commit for development environment setup

This commit is contained in:
2023-06-19 16:12:33 -04:00
parent be72063a3c
commit bbce2ad0a6
2209 changed files with 1171775 additions and 625 deletions

View File

@@ -0,0 +1,770 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// Assignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Assignment : BusinessBase<Assignment>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
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 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 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;
}
}
// If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// 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",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",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",ex);
return null;
}
}
[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",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",ex);
return null;
}
}
[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",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",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",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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,167 @@
// ========================================================================
// 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;
namespace Volian.Object.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;
[System.ComponentModel.DataObjectField(true, true)]
public int Gid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _gid;
}
}
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 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 string _startdate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _startdate;
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _enddate;
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
public DateTime Dts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _dts;
}
}
private string _usrid=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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 */ }
#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",ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,78 @@
// ========================================================================
// 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;
namespace Volian.Object.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>));
//}
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",ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,771 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// Connection Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Connection : BusinessBase<Connection>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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.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
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 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 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;
}
}
// If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// 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",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",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",ex);
return null;
}
}
[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",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",ex);
return null;
}
}
[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",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",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",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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,444 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// ConnectionFolder Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ConnectionFolder : BusinessBase<ConnectionFolder>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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.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
internal static ConnectionFolder New(string name)
{
return new ConnectionFolder(name);
}
internal static ConnectionFolder Get(SafeDataReader dr)
{
return new ConnectionFolder(dr);
}
private ConnectionFolder()
{
MarkAsChild();
_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)
{
Database.LogException("ConnectionFolder",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);
}
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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,85 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// ConnectionFolders Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class ConnectionFolders : BusinessListBase<ConnectionFolders,ConnectionFolder>
{
// No Columns to retrieve
#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;
// 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);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,170 @@
// ========================================================================
// 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;
namespace Volian.Object.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;
[System.ComponentModel.DataObjectField(true, true)]
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _name;
}
}
private string _title=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _title;
}
}
private string _connectionstring=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
public int ServerType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _servertype;
}
}
private string _config=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _config;
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
public DateTime Dts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _dts;
}
}
private string _usrid=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Usrid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _usrid;
}
}
// 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 */ }
#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");
}
catch(Exception ex)
{
Database.LogException("ConnectionInfo",ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,78 @@
// ========================================================================
// 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;
namespace Volian.Object.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",ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,83 @@
using System;
using System.Configuration;
using Csla;
using System.Data.SqlClient;
using System.IO;
namespace Volian.Object.Library
{
public static class Database
{
#region Log4Net
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#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);
}
}
}
}

View File

@@ -0,0 +1,775 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// Folder Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Folder : BusinessBase<Folder>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
public FolderAssignments FolderAssignments
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _folderassignments;
}
}
public override bool IsDirty
{
get { return base.IsDirty || _folderassignments.IsDirty ; }
}
public override bool IsValid
{
get { return base.IsValid && _folderassignments.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.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
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 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 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;
}
}
// If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// 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);
}
}
}
}
catch(Exception ex)
{
Database.LogException("Folder",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);
}
}
catch(Exception ex)
{
Database.LogException("Folder",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",ex);
return null;
}
}
[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);
}
}
catch(Exception ex)
{
Database.LogException("Folder",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",ex);
return null;
}
}
[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",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",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",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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,588 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// FolderAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class FolderAssignment : BusinessBase<FolderAssignment>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
public string Group_GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _group_groupname;
}
}
private int _group_grouptype;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
internal static FolderAssignment New(int gid, int rid)
{
return new FolderAssignment(Volian.Object.Library.Group.Get(gid), Volian.Object.Library.Role.Get(rid));
}
internal static FolderAssignment Get(SafeDataReader dr)
{
return new FolderAssignment(dr);
}
private FolderAssignment()
{
MarkAsChild();
_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("Groups_GroupName");
_group_grouptype = dr.GetInt32("Groups_GroupType");
_group_config = dr.GetString("Groups_Config");
_group_dts = dr.GetDateTime("Groups_DTS");
_group_usrid = dr.GetString("Groups_UsrID");
_role_name = dr.GetString("Roles_Name");
_role_title = dr.GetString("Roles_Title");
_role_dts = dr.GetDateTime("Roles_DTS");
_role_usrid = dr.GetString("Roles_UsrID");
}
catch(Exception ex)
{
Database.LogException("FolderAssignment",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);
}
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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,145 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// FolderAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class FolderAssignments : BusinessListBase<FolderAssignments,FolderAssignment>
{
#region Business Methods
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 void Add(int gid, int rid)
{
if (!Contains(gid, rid))
{
FolderAssignment assignment =
FolderAssignment.New(gid, rid);
this.Add(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;
// 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);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,167 @@
// ========================================================================
// 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;
namespace Volian.Object.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;
[System.ComponentModel.DataObjectField(true, true)]
public int Parentid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _parentid;
}
}
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;
[System.ComponentModel.DataObjectField(true, true)]
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _name;
}
}
private string _title=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _title;
}
}
private string _config=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _config;
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
public DateTime Dts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _dts;
}
}
private string _usrid=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Usrid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _usrid;
}
}
// 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 */ }
#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");
}
catch(Exception ex)
{
Database.LogException("FolderInfo",ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,78 @@
// ========================================================================
// 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;
namespace Volian.Object.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>));
//}
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",ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,719 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// Group Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Group : BusinessBase<Group>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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.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
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 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 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;
}
}
// If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// 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",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",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",ex);
return null;
}
}
[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",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",ex);
return null;
}
}
[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",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",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",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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,614 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// GroupAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupAssignment : BusinessBase<GroupAssignment>
{
#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 _rid;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
public int Folder_Parentid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _folder_parentid;
}
}
private int _folder_dbid;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
internal static GroupAssignment New(int rid, int folderid)
{
return new GroupAssignment(Volian.Object.Library.Role.Get(rid), Volian.Object.Library.Folder.Get(folderid));
}
internal static GroupAssignment Get(SafeDataReader dr)
{
return new GroupAssignment(dr);
}
private GroupAssignment()
{
MarkAsChild();
_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("Folders_ParentID");
_folder_dbid = dr.GetInt32("Folders_DBID");
_folder_name = dr.GetString("Folders_Name");
_folder_title = dr.GetString("Folders_Title");
_folder_config = dr.GetString("Folders_Config");
_folder_dts = dr.GetDateTime("Folders_DTS");
_folder_usrid = dr.GetString("Folders_UsrID");
_role_name = dr.GetString("Roles_Name");
_role_title = dr.GetString("Roles_Title");
_role_dts = dr.GetDateTime("Roles_DTS");
_role_usrid = dr.GetString("Roles_UsrID");
}
catch(Exception ex)
{
Database.LogException("GroupAssignment",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);
}
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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,145 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// GroupAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupAssignments : BusinessListBase<GroupAssignments,GroupAssignment>
{
#region Business Methods
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 void Add(int rid, int folderid)
{
if (!Contains(folderid, rid))
{
GroupAssignment assignment =
GroupAssignment.New(rid, folderid);
this.Add(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;
// 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);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,143 @@
// ========================================================================
// 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;
namespace Volian.Object.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;
[System.ComponentModel.DataObjectField(true, true)]
public string GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _groupname;
}
}
private int _grouptype;
[System.ComponentModel.DataObjectField(true, true)]
public int GroupType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _grouptype;
}
}
private string _config=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _config;
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
public DateTime Dts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _dts;
}
}
private string _usrid=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Usrid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _usrid;
}
}
// 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 */ }
#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");
}
catch(Exception ex)
{
Database.LogException("GroupInfo",ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,78 @@
// ========================================================================
// 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;
namespace Volian.Object.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",ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,615 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// GroupMembership Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupMembership : BusinessBase<GroupMembership>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
internal static GroupMembership New(int uid)
{
return new GroupMembership(Volian.Object.Library.User.Get(uid));
}
internal static GroupMembership Get(SafeDataReader dr)
{
return new GroupMembership(dr);
}
private GroupMembership()
{
MarkAsChild();
_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("Users_UserID");
_user_firstname = dr.GetString("Users_FirstName");
_user_middlename = dr.GetString("Users_MiddleName");
_user_lastname = dr.GetString("Users_LastName");
_user_suffix = dr.GetString("Users_Suffix");
_user_courtesytitle = dr.GetString("Users_CourtesyTitle");
_user_phonenumber = dr.GetString("Users_PhoneNumber");
_user_cfgname = dr.GetString("Users_CFGName");
_user_userlogin = dr.GetString("Users_UserLogin");
_user_username = dr.GetString("Users_UserName");
_user_config = dr.GetString("Users_Config");
_user_dts = dr.GetDateTime("Users_DTS");
_user_usrid = dr.GetString("Users_UsrID");
}
catch(Exception ex)
{
Database.LogException("GroupMembership",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);
}
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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace Volian.Object.Library
{
public partial class GroupMembership : BusinessBase<GroupMembership>
{
public string User_FullName
{
get { return User_LastName + ", " + User_FirstName; }
}
}
}

View File

@@ -0,0 +1,145 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// GroupMemberships Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class GroupMemberships : BusinessListBase<GroupMemberships,GroupMembership>
{
#region Business Methods
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 void Add(int uid)
{
if (!Contains(uid))
{
GroupMembership membership =
GroupMembership.New(uid);
this.Add(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;
// 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);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,742 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// Membership Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Membership : BusinessBase<Membership>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
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 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 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;
}
}
// If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// 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",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",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",ex);
return null;
}
}
[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",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",ex);
return null;
}
}
[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",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",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",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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,155 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
namespace Volian.Object.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;
[System.ComponentModel.DataObjectField(true, true)]
public int Uid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _uid;
}
}
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 _startdate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _startdate;
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _enddate;
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
public DateTime Dts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _dts;
}
}
private string _usrid=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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 */ }
#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",ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,78 @@
// ========================================================================
// 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;
namespace Volian.Object.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>));
//}
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",ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,847 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// Permission Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Permission : BusinessBase<Permission>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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 - Security, 1 - System, 2 - RO, 3 - Procdures, 4 - Sections, 5 - Steps, 6 - Comments
/// </summary>
[System.ComponentModel.DataObjectField(true, true)]
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 - Working Draft, 1 - Temporary Change, 2 Approved
/// </summary>
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
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 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 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;
}
}
// If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// 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",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",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",ex);
return null;
}
}
[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",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",ex);
return null;
}
}
[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",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",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",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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace Volian.Object.Library
{
public partial class Permission
{
private static List<vlnValueKey> _permADLookup;
private static List<vlnValueKey> _permLevelLookup;
private static void setupLookup()
{
if (_permADLookup == null)
{
_permADLookup = new List<vlnValueKey>();
_permADLookup.Add(new vlnValueKey(0,"Allow"));
_permADLookup.Add(new vlnValueKey(1, "Deny"));
}
if (_permLevelLookup == null)
{
_permLevelLookup = new List<vlnValueKey>();
_permLevelLookup.Add(new vlnValueKey(0, "Security"));
_permLevelLookup.Add(new vlnValueKey(1, "System"));
_permLevelLookup.Add(new vlnValueKey(2, "RO"));
_permLevelLookup.Add(new vlnValueKey(3, "Procedure"));
_permLevelLookup.Add(new vlnValueKey(4, "Sections"));
_permLevelLookup.Add(new vlnValueKey(5, "Steps"));
_permLevelLookup.Add(new vlnValueKey(6, "Comments"));
}
}
public static List<vlnValueKey> PermADLookup
{
get { setupLookup(); return _permADLookup; }
}
public static List<vlnValueKey> PermLevelLookup
{
get { setupLookup(); return _permLevelLookup; }
}
public bool ReadAccess
{
get { return ((PermValue & 1) == 1); }
set { PermValue = (value?PermValue|1:PermValue^(PermValue&1));}
}
public bool WriteAccess
{
get { return ((PermValue & 2) == 2); }
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
}
public bool CreateAccess
{
get { return ((PermValue & 4) == 4); }
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
}
public bool DeleteAccess
{
get { return ((PermValue & 8) == 8); }
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
}
// partial class Extension : extensionBase
// {
// TODO: Override automatic defaults
// public virtual int DefaultPermad
// {
// get { return 0; }
// }
// public virtual SmartDate DefaultStartDate
// {
// get { return DateTime.Now.ToShortDateString(); }
// }
// public virtual DateTime DefaultDts
// {
// get { return DateTime.Now; }
// }
// public virtual string DefaultUsrid
// {
// get { return Environment.UserName.ToUpper(); }
// }
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
// {
// //rules.AllowRead(Dbid, "<Role(s)>");
// }
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
// {
// rules.AddRule(
// Csla.Validation.CommonRules.StringMaxLength,
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
// }
// }
}
}

View File

@@ -0,0 +1,203 @@
// ========================================================================
// 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;
namespace Volian.Object.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;
[System.ComponentModel.DataObjectField(true, true)]
public int Rid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _rid;
}
}
private int _permlevel;
/// <summary>
/// 0 - Security, 1 - System, 2 - RO, 3 - Procdures, 4 - Sections, 5 - Steps, 6 - Comments
/// </summary>
[System.ComponentModel.DataObjectField(true, true)]
public int PermLevel
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _permlevel;
}
}
private int _versiontype;
/// <summary>
/// 0 - Working Draft, 1 - Temporary Change, 2 Approved
/// </summary>
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
public int Permad
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _permad;
}
}
private string _startdate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _startdate;
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _enddate;
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
public DateTime Dts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _dts;
}
}
private string _usrid=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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 */ }
#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",ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,78 @@
// ========================================================================
// 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;
namespace Volian.Object.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>));
//}
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",ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,377 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// PermissionRole Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class PermissionRole : BusinessBase<PermissionRole>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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 PermissionRole.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 PermissionRole</returns>
protected override object GetIdValue()
{
return _rid;
}
// TODO: Replace base PermissionRole.ToString function as necessary
/// <summary>
/// Overrides Base ToString
/// </summary>
/// <returns>A string representation of current PermissionRole</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", 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.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(Rid, "<Role(s)>");
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
//AuthorizationRules.AllowWrite(Title, "<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
internal static PermissionRole New(string name, string title)
{
return new PermissionRole(name, title);
}
internal static PermissionRole Get(SafeDataReader dr)
{
return new PermissionRole(dr);
}
private PermissionRole()
{
MarkAsChild();
_dts = ext.DefaultDts;
_usrid = ext.DefaultUsrid;
}
private PermissionRole(string name, string title)
{
MarkAsChild();
// TODO: Add any initialization & defaults
_dts = ext.DefaultDts;
_usrid = ext.DefaultUsrid;
_name = name;
_title = title;
}
private PermissionRole(SafeDataReader dr)
{
MarkAsChild();
Fetch(dr);
}
#endregion
#region Data Access Portal
private void Fetch(SafeDataReader dr)
{
try{
_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);
}
catch(Exception ex)
{
Database.LogException("PermissionRole",ex);
}
MarkOld();
}
internal void Insert(Permission permission,SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_lastchanged=Role.Add(cn, ref _rid, _name, _title, _dts, _usrid);
MarkOld();
}
internal void Update(Permission permission,SqlConnection cn)
{
// if we're not dirty then don't update the database
if (!this.IsDirty) return;
_lastchanged=Role.Update(cn, ref _rid, _name, _title, _dts, _usrid, ref _lastchanged);
}
internal void DeleteSelf(Permission permission,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;
Role.Remove(cn,_rid);
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 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
// The follwing is a sample Extension File. You can use it to create PermissionRoleExt.cs
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Csla;
//namespace PatrialClass
//{
// public partial class PermissionRole
// {
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,85 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// PermissionRoles Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class PermissionRoles : BusinessListBase<PermissionRoles,PermissionRole>
{
// No Columns to retrieve
#region Factory Methods
internal static PermissionRoles New()
{
return new PermissionRoles();
}
internal static PermissionRoles Get(SafeDataReader dr)
{
return new PermissionRoles(dr);
}
private PermissionRoles()
{
MarkAsChild();
}
private PermissionRoles(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(PermissionRole.Get(dr));
this.RaiseListChangedEvents = true;
}
internal void Update(Permission permission,SqlConnection cn)
{
this.RaiseListChangedEvents = false;
// update (thus deleting) any deleted child objects
foreach (PermissionRole obj in DeletedList)
obj.DeleteSelf(permission,cn);
// now that they are deleted, remove them from memory too
DeletedList.Clear();
// add/update any current child objects
foreach (PermissionRole obj in this)
{
if (obj.IsNew)
obj.Insert(permission,cn);
else
obj.Update(permission,cn);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Volian.Object.Library")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Volian Enterprises, Inc.")]
[assembly: AssemblyProduct("Volian.Object.Library")]
[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d6450c32-46ad-4f6f-9609-ad3a96730bfe")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,693 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// Role Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class Role : BusinessBase<Role>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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.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
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 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 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;
}
}
// If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// 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",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",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",ex);
return null;
}
}
[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",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",ex);
return null;
}
}
[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",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",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",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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,627 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// RoleAssignment Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoleAssignment : BusinessBase<RoleAssignment>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
public int Folder_Parentid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _folder_parentid;
}
}
private int _folder_dbid;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
public string Group_GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _group_groupname;
}
}
private int _group_grouptype;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
internal static RoleAssignment New(int gid, int folderid)
{
return new RoleAssignment(Volian.Object.Library.Group.Get(gid), Volian.Object.Library.Folder.Get(folderid));
}
internal static RoleAssignment Get(SafeDataReader dr)
{
return new RoleAssignment(dr);
}
private RoleAssignment()
{
MarkAsChild();
_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("Folders_ParentID");
_folder_dbid = dr.GetInt32("Folders_DBID");
_folder_name = dr.GetString("Folders_Name");
_folder_title = dr.GetString("Folders_Title");
_folder_config = dr.GetString("Folders_Config");
_folder_dts = dr.GetDateTime("Folders_DTS");
_folder_usrid = dr.GetString("Folders_UsrID");
_group_groupname = dr.GetString("Groups_GroupName");
_group_grouptype = dr.GetInt32("Groups_GroupType");
_group_config = dr.GetString("Groups_Config");
_group_dts = dr.GetDateTime("Groups_DTS");
_group_usrid = dr.GetString("Groups_UsrID");
}
catch(Exception ex)
{
Database.LogException("RoleAssignment",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);
}
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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,145 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// RoleAssignments Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RoleAssignments : BusinessListBase<RoleAssignments,RoleAssignment>
{
#region Business Methods
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 void Add(int gid, int folderid)
{
if (!Contains(folderid, gid))
{
RoleAssignment assignment =
RoleAssignment.New(gid, folderid);
this.Add(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;
// 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);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,131 @@
// ========================================================================
// 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;
namespace Volian.Object.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;
[System.ComponentModel.DataObjectField(true, true)]
public string Name
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _name;
}
}
private string _title=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Title
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _title;
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
public DateTime Dts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _dts;
}
}
private string _usrid=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Usrid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _usrid;
}
}
// 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 */ }
#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");
}
catch(Exception ex)
{
Database.LogException("RoleInfo",ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,78 @@
// ========================================================================
// 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;
namespace Volian.Object.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",ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace Volian.Object.Library
{
public partial class RolePermission : BusinessBase<RolePermission>
{
public bool ReadAccess
{
get { return ((PermValue & 1) == 1); }
set { PermValue = (value ? PermValue | 1 : PermValue ^ (PermValue & 1)); }
}
public bool WriteAccess
{
get { return ((PermValue & 2) == 2); }
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
}
public bool CreateAccess
{
get { return ((PermValue & 4) == 4); }
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
}
public bool DeleteAccess
{
get { return ((PermValue & 8) == 8); }
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
}
public List<vlnValueKey> PermADLookup
{
get { return Permission.PermADLookup; }
}
public List<vlnValueKey> PermLevelLookup
{
get { return Permission.PermLevelLookup; }
}
}
}

View File

@@ -0,0 +1,541 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// RolePermission Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RolePermission : BusinessBase<RolePermission>
{
#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 _permlevel;
/// <summary>
/// 0 - Security, 1 - System, 2 - RO, 3 - Procdures, 4 - Sections, 5 - Steps, 6 - Comments
/// </summary>
[System.ComponentModel.DataObjectField(true, true)]
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 - Working Draft, 1 - Temporary Change, 2 Approved
/// </summary>
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
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);
}
private RolePermission()
{
MarkAsChild();
_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)
{
Database.LogException("RolePermission",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);
}
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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace Volian.Object.Library
{
public partial class RolePermission : BusinessBase<RolePermission>
{
public static RolePermission New()
{
return new RolePermission(1, 1, 1);
}
public bool ReadAccess
{
get { return ((PermValue & 1) == 1); }
set { PermValue = (value ? PermValue | 1 : PermValue ^ (PermValue & 1)); }
}
public bool WriteAccess
{
get { return ((PermValue & 2) == 2); }
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
}
public bool CreateAccess
{
get { return ((PermValue & 4) == 4); }
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
}
public bool DeleteAccess
{
get { return ((PermValue & 8) == 8); }
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
}
public List<vlnValueKey> PermADLookup
{
get { return Permission.PermADLookup; }
}
public List<vlnValueKey> PermLevelLookup
{
get { return Permission.PermLevelLookup; }
}
}
public class PermLookup
{
public List<vlnValueKey> PermADLookup
{
get { return Permission.PermADLookup; }
}
public List<vlnValueKey> PermLevelLookup
{
get { return Permission.PermLevelLookup; }
}
}
}

View File

@@ -0,0 +1,85 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// RolePermissions Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class RolePermissions : BusinessListBase<RolePermissions,RolePermission>
{
// No Columns to retrieve
#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;
// 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);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,963 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// User Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class User : BusinessBase<User>
{
#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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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>
[System.ComponentModel.DataObjectField(true, true)]
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.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.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
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 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 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;
}
}
// If Create needs to access DB - It should not be marked RunLocal
[RunLocal()]
private new void DataPortal_Create(object criteria)
{
// 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",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",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",ex);
return null;
}
}
[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",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",ex);
return null;
}
}
[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",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",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",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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace Volian.Object.Library
{
public partial class User : BusinessBase<User>
{
public string FullName
{
get { return LastName + ", " + FirstName; }
}
}
}

View File

@@ -0,0 +1,239 @@
// ========================================================================
// 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;
namespace Volian.Object.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;
[System.ComponentModel.DataObjectField(true, true)]
public string Userid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _userid;
}
}
private string _firstname=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string FirstName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _firstname;
}
}
private string _middlename=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string MiddleName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _middlename;
}
}
private string _lastname=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string LastName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _lastname;
}
}
private string _suffix=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Suffix
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _suffix;
}
}
private string _courtesytitle=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string CourtesyTitle
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _courtesytitle;
}
}
private string _phonenumber=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string PhoneNumber
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _phonenumber;
}
}
private string _cfgname=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string CfgName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _cfgname;
}
}
private string _userlogin=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string UserLogin
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _userlogin;
}
}
private string _username=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string UserName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _username;
}
}
private string _config=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Config
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _config;
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
public DateTime Dts
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _dts;
}
}
private string _usrid=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
public string Usrid
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _usrid;
}
}
// 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 */ }
#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");
}
catch(Exception ex)
{
Database.LogException("UserInfo",ex);
}
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,78 @@
// ========================================================================
// 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;
namespace Volian.Object.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",ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
namespace Volian.Object.Library
{
/// <summary>
/// Extensions
/// </summary>
public partial class UserInfo : ReadOnlyBase<UserInfo>
{
public string FullName
{
get { return LastName + ", " + FirstName; }
}
}
}

View File

@@ -0,0 +1,512 @@
// ========================================================================
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
namespace Volian.Object.Library
{
/// <summary>
/// UserMembership Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class UserMembership : BusinessBase<UserMembership>
{
#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 _gid;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_startdate != tmp.ToShortDateString())
{
_startdate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _enddate=string.Empty;
[System.ComponentModel.DataObjectField(true, true)]
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
{
DateTime tmp = SmartDate.StringToDate(value);
if (_enddate != tmp.ToShortDateString())
{
_enddate = tmp.ToShortDateString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _dts=new DateTime();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
public string Group_GroupName
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty(true);
return _group_groupname;
}
}
private int _group_grouptype;
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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();
[System.ComponentModel.DataObjectField(true, true)]
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;
[System.ComponentModel.DataObjectField(true, true)]
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(StartDateValid, "StartDate");
ValidationRules.AddRule(EndDateValid, "EndDate");
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
internal static UserMembership New(int gid)
{
return new UserMembership(Volian.Object.Library.Group.Get(gid));
}
internal static UserMembership Get(SafeDataReader dr)
{
return new UserMembership(dr);
}
private UserMembership()
{
MarkAsChild();
_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("Groups_GroupName");
_group_grouptype = dr.GetInt32("Groups_GroupType");
_group_config = dr.GetString("Groups_Config");
_group_dts = dr.GetDateTime("Groups_DTS");
_group_usrid = dr.GetString("Groups_UsrID");
}
catch(Exception ex)
{
Database.LogException("UserMembership",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);
MarkClean();
}
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
// The follwing 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 PatrialClass
//{
// 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));
// }
// }
// }
//}
} // Class
} // Namespace

View File

@@ -0,0 +1,145 @@
// ========================================================================
// 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;
namespace Volian.Object.Library
{
/// <summary>
/// UserMemberships Generated by MyGeneration using the CSLA Object Mapping template
/// </summary>
[Serializable()]
public partial class UserMemberships : BusinessListBase<UserMemberships,UserMembership>
{
#region Business Methods
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 void Add(int gid)
{
if (!Contains(gid))
{
UserMembership membership =
UserMembership.New(gid);
this.Add(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;
// 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);
}
this.RaiseListChangedEvents = true;
}
#endregion
} // Class
} // Namespace

View File

@@ -0,0 +1,102 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{592B86E9-D488-452B-B89B-2BB037793FE3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Volian.Object.Library</RootNamespace>
<AssemblyName>Volian.Object.Library</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Csla, Version=2.0.3.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\csla20cs\csla20cs\Csla\bin\Debug\Csla.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Log4Net\log4net-1.2.10\bin\net\2.0\release\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Assignment.cs" />
<Compile Include="AssignmentInfo.cs" />
<Compile Include="AssignmentInfoList.cs" />
<Compile Include="Connection.cs" />
<Compile Include="ConnectionFolder.cs" />
<Compile Include="ConnectionFolders.cs" />
<Compile Include="ConnectionInfo.cs" />
<Compile Include="ConnectionInfoList.cs" />
<Compile Include="Database.cs" />
<Compile Include="Folder.cs" />
<Compile Include="FolderAssignment.cs" />
<Compile Include="FolderAssignments.cs" />
<Compile Include="FolderInfo.cs" />
<Compile Include="FolderInfoList.cs" />
<Compile Include="Group.cs" />
<Compile Include="GroupAssignment.cs" />
<Compile Include="GroupAssignments.cs" />
<Compile Include="GroupInfo.cs" />
<Compile Include="GroupInfoList.cs" />
<Compile Include="GroupMembership.cs" />
<Compile Include="GroupMembershipExt.cs" />
<Compile Include="GroupMemberships.cs" />
<Compile Include="Membership.cs" />
<Compile Include="MembershipInfo.cs" />
<Compile Include="MembershipInfoList.cs" />
<Compile Include="Permission.cs" />
<Compile Include="PermissionExt.cs" />
<Compile Include="PermissionInfo.cs" />
<Compile Include="PermissionInfoList.cs" />
<Compile Include="PermissionRole.cs" />
<Compile Include="PermissionRoles.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Role.cs" />
<Compile Include="RoleAssignment.cs" />
<Compile Include="RoleAssignments.cs" />
<Compile Include="RoleInfo.cs" />
<Compile Include="RoleInfoList.cs" />
<Compile Include="RolePermissionExt.cs" />
<Compile Include="RolePermission.cs" />
<Compile Include="RolePermissions.cs" />
<Compile Include="User.cs" />
<Compile Include="UserExt.cs" />
<Compile Include="UserInfo.cs" />
<Compile Include="UserInfoList.cs" />
<Compile Include="UserInfoListExt.cs" />
<Compile Include="UserMembership.cs" />
<Compile Include="UserMemberships.cs" />
<Compile Include="vlnValueKey.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Volian.Object.Library
{
public class vlnValueKey
{
public vlnValueKey() { ;}
public vlnValueKey(int key, string value)
{
_key = key;
_value = value;
}
private int _key;
public int Key
{
get { return _key; }
}
private string _value;
public string Value
{
get { return _value; }
}
public override string ToString()
{
return _value;
}
}
}