425 lines
10 KiB
C#
425 lines
10 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 UserRole
|
|
|
|
[Serializable]
|
|
public class UserRole : BasicBaseObject
|
|
{
|
|
#region Cache Store
|
|
|
|
private static Cache _cache = new Cache(typeof(UserRole));
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public UserRole()
|
|
{
|
|
_rolePermission = null;
|
|
_UserAccessType = null;
|
|
_roleID = 0;
|
|
_userID = null;
|
|
_role = null;
|
|
_user = null;
|
|
_eventDate = DateTime.Today;
|
|
_createdBy = null;
|
|
_authorizedBy = null;
|
|
_authorizedDate = DateTime.MinValue;
|
|
_status = EnumStatus.Inactive;
|
|
_ComputerName = "";
|
|
_ApprovedComputerName = "";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#region roleID : int
|
|
|
|
private int _roleID;
|
|
public int RoleID
|
|
{
|
|
get { return _roleID; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<int>("roleID", _roleID, value);
|
|
_roleID = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region userID : ID
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
private ID _userID;
|
|
public ID UserID
|
|
{
|
|
get { return _userID; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<ID>("userID", _userID, value);
|
|
_userID = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CreatedBy : ID
|
|
|
|
private ID _createdBy;
|
|
public ID CreatedBy
|
|
{
|
|
get { return _createdBy; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<ID>("CreatedBy", _createdBy, value);
|
|
_createdBy = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
#region AuthorizedBy : ID
|
|
|
|
private ID _authorizedBy;
|
|
public ID AuthorizedBy
|
|
{
|
|
get { return _authorizedBy; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<ID>("AuthorizedBy", _authorizedBy, value);
|
|
_authorizedBy = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region role : Role
|
|
|
|
private Role _role;
|
|
public Role Role
|
|
{
|
|
get
|
|
{
|
|
if (_roleID > 0 && _role == null)
|
|
{
|
|
_role = Role.Get(ID.FromInteger(_roleID));
|
|
}
|
|
return this._role;
|
|
}
|
|
set
|
|
{
|
|
_role = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region user : User
|
|
|
|
private User _user;
|
|
public User User
|
|
{
|
|
get
|
|
{
|
|
if (_userID.Integer > 0 && _user == null)
|
|
{
|
|
_user = User.Get(_userID);
|
|
}
|
|
return this._user;
|
|
}
|
|
set
|
|
{
|
|
_user = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region RolePermission
|
|
ObjectsTemplate<RolePermission> _rolePermission;
|
|
public ObjectsTemplate<RolePermission> RolePermision
|
|
{
|
|
get
|
|
{
|
|
if (_rolePermission == null && _roleID > 0)
|
|
{
|
|
_rolePermission = RolePermission.Get(_roleID);
|
|
}
|
|
return _rolePermission;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region RoleAccessType
|
|
ObjectsTemplate<UserAccessType> _UserAccessType;
|
|
public ObjectsTemplate<UserAccessType> UserAccessTypeObj
|
|
{
|
|
get
|
|
{
|
|
if (_UserAccessType == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
|
|
{
|
|
_UserAccessType = UserAccessType.Get(this.ID.Integer);
|
|
}
|
|
return _UserAccessType;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region AuthorizedDate : Datetime
|
|
|
|
private DateTime? _authorizedDate;
|
|
public DateTime? AuthorizedDate
|
|
{
|
|
get { return _authorizedDate; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<DateTime>("AuthorizedDate", _authorizedDate, value);
|
|
_authorizedDate = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region EventDate : Datetime
|
|
|
|
private DateTime _eventDate;
|
|
public DateTime EventDate
|
|
{
|
|
get { return _eventDate; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<DateTime>("EventDate", _eventDate, value);
|
|
_eventDate = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Status : EnumStatus
|
|
|
|
private EnumStatus _status;
|
|
public EnumStatus Status
|
|
{
|
|
get { return _status; }
|
|
set
|
|
{
|
|
_status = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Service Factory IUserRoleService : IUserRoleService
|
|
|
|
internal static IUserRoleService Service
|
|
{
|
|
get { return Services.Factory.CreateService<IUserRoleService>(typeof(IUserRoleService)); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Functions
|
|
|
|
public static UserRole Get(ID nID)
|
|
{
|
|
UserRole oUserRole = null;
|
|
#region Cache Header
|
|
oUserRole = (UserRole)_cache["Get", nID];
|
|
if (oUserRole != null)
|
|
return oUserRole;
|
|
#endregion
|
|
oUserRole = UserRole.Service.Get(nID);
|
|
#region Cache Footer
|
|
_cache.Add(oUserRole, "Get", nID);
|
|
#endregion
|
|
return oUserRole;
|
|
}
|
|
|
|
public static ObjectsTemplate<UserRole> Get()
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<UserRole> userRoles = _cache["Get"] as ObjectsTemplate<UserRole>;
|
|
if (userRoles != null)
|
|
return userRoles;
|
|
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
userRoles = Service.Get();
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(userRoles, "Get");
|
|
|
|
#endregion
|
|
|
|
return userRoles;
|
|
}
|
|
|
|
public static ObjectsTemplate<UserRole> GetByUserID(ID UserID)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<UserRole> userRoles = _cache["Get", UserID] as ObjectsTemplate<UserRole>;
|
|
if (userRoles != null)
|
|
return userRoles;
|
|
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
userRoles = Service.GetByUserID(UserID);
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
_cache.Add(userRoles, "Get", UserID);
|
|
|
|
#endregion
|
|
|
|
return userRoles;
|
|
}
|
|
public ID Save()
|
|
{
|
|
return UserRole.Service.Save(this);
|
|
}
|
|
public static void Save(ObjectsTemplate<UserRole> userRoles)
|
|
{
|
|
foreach (UserRole userRole in userRoles)
|
|
{
|
|
userRole.SetAuditTrailProperties();
|
|
}
|
|
UserRole.Service.Save(userRoles);
|
|
}
|
|
public static void Save(List<UserRole> userRoles)
|
|
{
|
|
foreach (UserRole userRole in userRoles)
|
|
{
|
|
userRole.SetAuditTrailProperties();
|
|
}
|
|
UserRole.Service.Save(userRoles);
|
|
}
|
|
public static void Update(List<UserRole> userRoles)
|
|
{
|
|
UserRole.Service.Update(userRoles);
|
|
}
|
|
public static void SaveSingleUserRole(UserRole item)
|
|
{
|
|
UserRole.Service.SaveSingleUserRole(item);
|
|
}
|
|
|
|
public void Update(ID nID)
|
|
{
|
|
if (this.Status == EnumStatus.Active)
|
|
{
|
|
UserRole.Service.Update(nID, EnumStatus.Inactive);
|
|
}
|
|
else
|
|
{
|
|
UserRole.Service.Update(nID, EnumStatus.Active);
|
|
}
|
|
}
|
|
|
|
|
|
public void Delete()
|
|
{
|
|
UserRole.Service.Delete(ID);
|
|
}
|
|
|
|
public void DeleteByUserID()
|
|
{
|
|
UserRole.Service.DeleteByUserID(ID);
|
|
}
|
|
public void DeleteByUserID(int nUserID)
|
|
{
|
|
UserRole.Service.DeleteByUserID(nUserID);
|
|
}
|
|
|
|
public static void DeleteByUserID2(ID nUserID)
|
|
{
|
|
UserRole.Service.DeleteByUserID2(nUserID);
|
|
}
|
|
#endregion
|
|
|
|
|
|
public static DataSet GetRoleAudit(int type, DateTime fromDate, DateTime ToDate)
|
|
{
|
|
DataSet ds = null;
|
|
|
|
try
|
|
{
|
|
ds = Service.GetRoleAudit(type, fromDate, ToDate);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
|
|
return ds;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region IUserRole Service
|
|
|
|
public interface IUserRoleService
|
|
{
|
|
UserRole Get(ID id);
|
|
ObjectsTemplate<UserRole> Get();
|
|
ObjectsTemplate<UserRole> GetByUserID(ID UserID);
|
|
ID Save(UserRole item);
|
|
void Update(ID nID, EnumStatus status);
|
|
void Save(ObjectsTemplate<UserRole> userRoles);
|
|
void Save(List<UserRole> userRoles);
|
|
void Update(List<UserRole> userRoles);
|
|
void SaveSingleUserRole(UserRole item);
|
|
void Delete(ID id);
|
|
void DeleteByUserID(ID id);
|
|
void DeleteByUserID(int id);
|
|
void DeleteByUserID2(ID nID);
|
|
DataSet GetRoleAudit(int type, DateTime fromDate, DateTime ToDate);
|
|
}
|
|
|
|
#endregion
|
|
}
|