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("menuKey", _menuKey, value); _menuKey = value; } } #endregion #region roleID : ID private ID _roleID; public ID RoleID { get { return _roleID; } set { base.OnPropertyChange("roleID", _roleID, value); _roleID = value; } } #endregion private string _ApprovedComputerName; public string ApprovedComputerName { get { return _ApprovedComputerName; } set { base.OnPropertyChange("ApprovedComputerName", _ApprovedComputerName, value); _ApprovedComputerName = value; } } private string _ComputerName; public string ComputerName { get { return _ComputerName; } set { base.OnPropertyChange("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("AddButton", _addButton, value); _addButton = value; } } #endregion #region Edit : bool private bool _editButton; public bool Edit { get { return _editButton; } set { base.OnPropertyChange("EditButton", _editButton, value); _editButton = value; } } #endregion #region Delete : bool private bool _deleteButton; public bool DeleteButton { get { return _deleteButton; } set { base.OnPropertyChange("DeleteButton", _deleteButton, value); _deleteButton = value; } } #endregion #region Lock : bool private bool _lockButton; public bool Lock { get { return _lockButton; } set { base.OnPropertyChange("LockButton", _lockButton, value); _lockButton = value; } } #endregion #region Process : bool private bool _process; public bool Process { get { return _process; } set { base.OnPropertyChange("Process", _process, value); _process = value; } } #endregion #region Undo : bool private bool _undo; public bool Undo { get { return _undo; } set { base.OnPropertyChange("Undo", _undo, value); _undo = value; } } #endregion #region Authorize : bool private bool _authorizedButton; public bool Authorize { get { return _authorizedButton; } set { base.OnPropertyChange("AuthorizeButton", _authorizedButton, value); _authorizedButton = value; } } #endregion #region Approve : bool private bool _approve; public bool Approve { get { return _approve; } set { base.OnPropertyChange("Approve", _approve, value); _approve = value; } } #endregion #region Active : bool private bool _active; public bool Active { get { return _active; } set { base.OnPropertyChange("Active", _active, value); _active = value; } } #endregion #region Save : bool private bool _save; public bool SaveButton { get { return _save; } set { base.OnPropertyChange("Active", _save, value); _save = value; } } #endregion #region Up : bool private bool _up; public bool Up { get { return _up; } set { base.OnPropertyChange("Up", _up, value); _up = value; } } #endregion #region Down : bool private bool _down; public bool Down { get { return _down; } set { base.OnPropertyChange("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(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 Get() { #region Cache Header ObjectsTemplate rolePermissions = _cache["Get"] as ObjectsTemplate; 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 Get(int roleID) { #region Cache Header ObjectsTemplate rolePermissions = _cache["Get", roleID] as ObjectsTemplate; 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 GetAll(int roleID) { #region Cache Header ObjectsTemplate rolePermissions = _cache["Get", roleID] as ObjectsTemplate; 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 GetAllItem(int roleID) { #region Cache Header ObjectsTemplate rolePermissions = _cache["Get", roleID] as ObjectsTemplate; 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 Get(int roleID, EnumStatus eStatus) { #region Cache Header ObjectsTemplate rolePermissions = _cache["Get", roleID] as ObjectsTemplate; 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 _RolePermissions) { foreach (RolePermission permission in _RolePermissions) { permission.SetAuditTrailProperties(); } RolePermission.Service.Save(_RolePermissions); } public static void Save(List _RolePermissions) { foreach (RolePermission permission in _RolePermissions) { permission.SetAuditTrailProperties(); } RolePermission.Service.Save(_RolePermissions); } public static void Update(List _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 Get(); ObjectsTemplate Get(int roleID); ObjectsTemplate GetAll(int roleID); ObjectsTemplate Get(int roleID, EnumStatus eStatus); ID Save(RolePermission item); void Save(ObjectsTemplate _RolePermissions); void Save(List _RolePermissions); void Update(List _RolePermissions); void Delete(ID id); ObjectsTemplate GetAllItem(int roleID); DataSet GetRolePerAudit(int type, DateTime fromDate, DateTime ToDate); } #endregion }