Commit for development environment setup
This commit is contained in:
614
PROMS/VEPROMS_Security/Volian.Object.Library/GroupAssignment.cs
Normal file
614
PROMS/VEPROMS_Security/Volian.Object.Library/GroupAssignment.cs
Normal 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
|
Reference in New Issue
Block a user