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