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