547 lines
14 KiB
C#
547 lines
14 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using System.Data.Linq.Mapping;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
#region RolePermission
|
|||
|
|
|||
|
[Serializable]
|
|||
|
public class RolePermission : AuditTrailBase
|
|||
|
{
|
|||
|
#region Cache Store
|
|||
|
|
|||
|
private static Cache _cache = new Cache(typeof(RolePermission));
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
public RolePermission()
|
|||
|
{
|
|||
|
_menuKey = string.Empty;
|
|||
|
_roleID = null;
|
|||
|
_role = null;
|
|||
|
_addButton = false;
|
|||
|
_editButton = false;
|
|||
|
_deleteButton = false;
|
|||
|
_authorizedButton = false;
|
|||
|
_lockButton = false;
|
|||
|
_process = false;
|
|||
|
_undo = false;
|
|||
|
_active = false;
|
|||
|
_save = false;
|
|||
|
_up = false;
|
|||
|
_down = false;
|
|||
|
_IsApproved = EnumStatus.Role_Menu_Assigned_And_Waiting_For_Approve;
|
|||
|
_MenuPermissionStatus = EnumMenuPermissionStatus.Added;
|
|||
|
_ComputerName = "";
|
|||
|
_ApprovedComputerName = "";
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Properties
|
|||
|
|
|||
|
#region menuKey : int
|
|||
|
|
|||
|
private string _menuKey;
|
|||
|
public string MenuKey
|
|||
|
{
|
|||
|
get { return _menuKey; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<string>("menuKey", _menuKey, value);
|
|||
|
_menuKey = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region roleID : ID
|
|||
|
|
|||
|
private ID _roleID;
|
|||
|
public ID RoleID
|
|||
|
{
|
|||
|
get { return _roleID; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<ID>("roleID", _roleID, value);
|
|||
|
_roleID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
private string _ApprovedComputerName;
|
|||
|
public string ApprovedComputerName
|
|||
|
{
|
|||
|
get { return _ApprovedComputerName; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<string>("ApprovedComputerName", _ApprovedComputerName, value);
|
|||
|
_ApprovedComputerName = value;
|
|||
|
}
|
|||
|
}
|
|||
|
private string _ComputerName;
|
|||
|
public string ComputerName
|
|||
|
{
|
|||
|
get { return _ComputerName; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<string>("ComputerName", _ComputerName, value);
|
|||
|
_ComputerName = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#region role : Role
|
|||
|
|
|||
|
private Role _role;
|
|||
|
public Role Role
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_roleID.Integer > 0 && _role == null)
|
|||
|
{
|
|||
|
_role = Role.Get(_roleID);
|
|||
|
}
|
|||
|
return this._role;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_role = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Newly Added by ashek 6 June 2012
|
|||
|
|
|||
|
#region Add : bool
|
|||
|
private bool _addButton;
|
|||
|
public bool Add
|
|||
|
{
|
|||
|
get { return _addButton; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("AddButton", _addButton, value);
|
|||
|
_addButton = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Edit : bool
|
|||
|
private bool _editButton;
|
|||
|
public bool Edit
|
|||
|
{
|
|||
|
get { return _editButton; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("EditButton", _editButton, value);
|
|||
|
_editButton = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Delete : bool
|
|||
|
private bool _deleteButton;
|
|||
|
public bool DeleteButton
|
|||
|
{
|
|||
|
get { return _deleteButton; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("DeleteButton", _deleteButton, value);
|
|||
|
_deleteButton = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Lock : bool
|
|||
|
private bool _lockButton;
|
|||
|
public bool Lock
|
|||
|
{
|
|||
|
get { return _lockButton; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("LockButton", _lockButton, value);
|
|||
|
_lockButton = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Process : bool
|
|||
|
private bool _process;
|
|||
|
public bool Process
|
|||
|
{
|
|||
|
get { return _process; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("Process", _process, value);
|
|||
|
_process = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Undo : bool
|
|||
|
private bool _undo;
|
|||
|
public bool Undo
|
|||
|
{
|
|||
|
get { return _undo; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("Undo", _undo, value);
|
|||
|
_undo = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Authorize : bool
|
|||
|
private bool _authorizedButton;
|
|||
|
public bool Authorize
|
|||
|
{
|
|||
|
get { return _authorizedButton; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("AuthorizeButton", _authorizedButton, value);
|
|||
|
_authorizedButton = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Approve : bool
|
|||
|
private bool _approve;
|
|||
|
public bool Approve
|
|||
|
{
|
|||
|
get { return _approve; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("Approve", _approve, value);
|
|||
|
_approve = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Active : bool
|
|||
|
private bool _active;
|
|||
|
public bool Active
|
|||
|
{
|
|||
|
get { return _active; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("Active", _active, value);
|
|||
|
_active = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Save : bool
|
|||
|
private bool _save;
|
|||
|
public bool SaveButton
|
|||
|
{
|
|||
|
get { return _save; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("Active", _save, value);
|
|||
|
_save = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Up : bool
|
|||
|
private bool _up;
|
|||
|
public bool Up
|
|||
|
{
|
|||
|
get { return _up; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("Up", _up, value);
|
|||
|
_up = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region Down : bool
|
|||
|
private bool _down;
|
|||
|
public bool Down
|
|||
|
{
|
|||
|
get { return _down; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("Down", _down, value);
|
|||
|
_down = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region IsApproved : bool
|
|||
|
private EnumStatus _IsApproved;
|
|||
|
public EnumStatus IsApproved
|
|||
|
{
|
|||
|
get { return _IsApproved; }
|
|||
|
set
|
|||
|
{
|
|||
|
_IsApproved = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
private EnumMenuPermissionStatus _MenuPermissionStatus;
|
|||
|
public EnumMenuPermissionStatus MenuPermissionStatus
|
|||
|
{
|
|||
|
get { return _MenuPermissionStatus; }
|
|||
|
set
|
|||
|
{
|
|||
|
_MenuPermissionStatus = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Factory IRolePermissionService : IRolePermissionService
|
|||
|
|
|||
|
internal static IRolePermissionService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<IRolePermissionService>(typeof(IRolePermissionService)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
|
|||
|
public RolePermission Get(ID nID)
|
|||
|
{
|
|||
|
RolePermission oRolePermission = null;
|
|||
|
#region Cache Header
|
|||
|
oRolePermission = (RolePermission)_cache["Get", ID];
|
|||
|
if (oRolePermission != null)
|
|||
|
return oRolePermission;
|
|||
|
#endregion
|
|||
|
oRolePermission = RolePermission.Service.Get(ID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oRolePermission, "Get", ID);
|
|||
|
#endregion
|
|||
|
return oRolePermission;
|
|||
|
}
|
|||
|
public static RolePermission Get(string sKey, ID nRoleID)
|
|||
|
{
|
|||
|
RolePermission oRolePermission = null;
|
|||
|
#region Cache Header
|
|||
|
oRolePermission = (RolePermission)_cache["Get", sKey, nRoleID];
|
|||
|
if (oRolePermission != null)
|
|||
|
return oRolePermission;
|
|||
|
#endregion
|
|||
|
oRolePermission = RolePermission.Service.Get(sKey, nRoleID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oRolePermission, "Get", sKey, nRoleID);
|
|||
|
#endregion
|
|||
|
return oRolePermission;
|
|||
|
}
|
|||
|
public static ObjectsTemplate<RolePermission> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<RolePermission> rolePermissions = _cache["Get"] as ObjectsTemplate<RolePermission>;
|
|||
|
if (rolePermissions != null)
|
|||
|
return rolePermissions;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
rolePermissions = Service.Get();
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(rolePermissions, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return rolePermissions;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<RolePermission> Get(int roleID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<RolePermission> rolePermissions = _cache["Get", roleID] as ObjectsTemplate<RolePermission>;
|
|||
|
if (rolePermissions != null)
|
|||
|
return rolePermissions;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
rolePermissions = Service.Get(roleID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(rolePermissions, "Get", roleID);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return rolePermissions;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<RolePermission> GetAll(int roleID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<RolePermission> rolePermissions = _cache["Get", roleID] as ObjectsTemplate<RolePermission>;
|
|||
|
if (rolePermissions != null)
|
|||
|
return rolePermissions;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
rolePermissions = Service.GetAll(roleID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(rolePermissions, "Get", roleID);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return rolePermissions;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<RolePermission> GetAllItem(int roleID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<RolePermission> rolePermissions = _cache["Get", roleID] as ObjectsTemplate<RolePermission>;
|
|||
|
if (rolePermissions != null)
|
|||
|
return rolePermissions;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
rolePermissions = Service.GetAllItem(roleID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(rolePermissions, "Get", roleID);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return rolePermissions;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<RolePermission> Get(int roleID, EnumStatus eStatus)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<RolePermission> rolePermissions = _cache["Get", roleID] as ObjectsTemplate<RolePermission>;
|
|||
|
if (rolePermissions != null)
|
|||
|
return rolePermissions;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
rolePermissions = Service.Get(roleID, eStatus);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(rolePermissions, "Get", roleID);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return rolePermissions;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
return RolePermission.Service.Save(this);
|
|||
|
}
|
|||
|
public void Delete()
|
|||
|
{
|
|||
|
RolePermission.Service.Delete(ID);
|
|||
|
}
|
|||
|
|
|||
|
public static void Save(ObjectsTemplate<RolePermission> _RolePermissions)
|
|||
|
{
|
|||
|
foreach (RolePermission permission in _RolePermissions)
|
|||
|
{
|
|||
|
permission.SetAuditTrailProperties();
|
|||
|
}
|
|||
|
RolePermission.Service.Save(_RolePermissions);
|
|||
|
}
|
|||
|
public static void Save(List<RolePermission> _RolePermissions)
|
|||
|
{
|
|||
|
foreach (RolePermission permission in _RolePermissions)
|
|||
|
{
|
|||
|
permission.SetAuditTrailProperties();
|
|||
|
}
|
|||
|
RolePermission.Service.Save(_RolePermissions);
|
|||
|
}
|
|||
|
public static void Update(List<RolePermission> _RolePermissions)
|
|||
|
{
|
|||
|
RolePermission.Service.Update(_RolePermissions);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
public static DataSet GetRolePerAudit(int type, DateTime fromDate, DateTime ToDate)
|
|||
|
{
|
|||
|
DataSet ds = null;
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
ds = Service.GetRolePerAudit(type, fromDate, ToDate);
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
return ds;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IRolePermission Service
|
|||
|
|
|||
|
public interface IRolePermissionService
|
|||
|
{
|
|||
|
RolePermission Get(ID id);
|
|||
|
RolePermission Get(string sKey, ID nRoleID);
|
|||
|
ObjectsTemplate<RolePermission> Get();
|
|||
|
ObjectsTemplate<RolePermission> Get(int roleID);
|
|||
|
ObjectsTemplate<RolePermission> GetAll(int roleID);
|
|||
|
ObjectsTemplate<RolePermission> Get(int roleID, EnumStatus eStatus);
|
|||
|
ID Save(RolePermission item);
|
|||
|
void Save(ObjectsTemplate<RolePermission> _RolePermissions);
|
|||
|
void Save(List<RolePermission> _RolePermissions);
|
|||
|
void Update(List<RolePermission> _RolePermissions);
|
|||
|
void Delete(ID id);
|
|||
|
|
|||
|
ObjectsTemplate<RolePermission> GetAllItem(int roleID);
|
|||
|
|
|||
|
DataSet GetRolePerAudit(int type, DateTime fromDate, DateTime ToDate);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|