CEL_Payroll/Payroll.BO/Attendence/AttnProcessRunSummary.cs

339 lines
10 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35.Caching;
using Ease.CoreV35.Model;
using System.Data;
namespace Payroll.BO
{
#region AttnProcessRunSummary
[Serializable]
public class AttnProcessRunSummary : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(AttnProcessRunSummary));
#endregion
#region Constructor
public AttnProcessRunSummary()
{
_processDate = DateTime.Now;
_processMode = EnumProcessMode.Manual;
_processBy = null;
_processStatus = EnumAttnProcessStatus.SuccessWithoutError;
_payrollTypeID = SystemInformation.CurrentSysInfo.PayrollTypeID;
}
#endregion
#region Properties
#region ProcessDate : DateTime
private DateTime _processDate;
public DateTime ProcessDate
{
get { return _processDate; }
set {_processDate = value; }
}
#endregion
#region ProcessMode : EnumProcessMode
private EnumProcessMode _processMode;
public EnumProcessMode ProcessMode
{
get { return _processMode; }
set
{
_processMode = value;
if (_processMode == EnumProcessMode.Manual)
{
_processBy = User.CurrentUser.ID;
}
}
}
#endregion
#region ProcessBy : ID
private ID _processBy;
public ID ProcessBy
{
get { return _processBy; }
set { _processBy = value; }
}
#endregion
#region ProcessStatus : EnumProcessStatus
private EnumAttnProcessStatus _processStatus;
public EnumAttnProcessStatus ProcessStatus
{
get { return _processStatus; }
set { _processStatus = value; }
}
#endregion
#region payrollTypeID : ID
private ID _payrollTypeID;
public ID PayrollTypeID
{
get { return _payrollTypeID; }
set
{
base.OnPropertyChange<ID>("payrollTypeID", _payrollTypeID, value);
_payrollTypeID = value;
}
}
#endregion
#region Property AttnProcessRunDetails : AttnProcessRunDetail
private ObjectsTemplate<AttnProcessRunDetail> _attnProcessRunDetail;
public ObjectsTemplate<AttnProcessRunDetail> AttnProcessRunDetails
{
get
{
if (_attnProcessRunDetail == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_attnProcessRunDetail = Service.GetAttnProcessRunDetails(this.ID);
}
return _attnProcessRunDetail;
}
set
{
_attnProcessRunDetail = value;
}
}
#endregion
#endregion
#region Function
#region Get
public static AttnProcessRunSummary Get(ID nID)
{
AttnProcessRunSummary oAttnProcessRunSummary = null;
#region Cache Header
oAttnProcessRunSummary = (AttnProcessRunSummary)_cache["Get", nID];
if (oAttnProcessRunSummary != null)
return oAttnProcessRunSummary;
#endregion
oAttnProcessRunSummary = AttnProcessRunSummary.Service.Get(nID);
#region Cache Footer
_cache.Add(oAttnProcessRunSummary, "Get", nID);
#endregion
return oAttnProcessRunSummary;
}
public static ObjectsTemplate<AttnProcessRunSummary> Get()
{
#region Cache Header
ObjectsTemplate<AttnProcessRunSummary> oAttnProcessRunSummary = _cache["Get"] as ObjectsTemplate<AttnProcessRunSummary>;
if (oAttnProcessRunSummary != null)
return oAttnProcessRunSummary;
#endregion
try
{
oAttnProcessRunSummary = Service.GetByID(SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oAttnProcessRunSummary, "Get");
#endregion
return oAttnProcessRunSummary;
}
public static ObjectsTemplate<AttnProcessRunSummary> GetByStatus(EnumProcessStatus ProcessStatus)
{
#region Cache Header
ObjectsTemplate<AttnProcessRunSummary> oAttnProcessRunSummary = _cache["GetByStatus"] as ObjectsTemplate<AttnProcessRunSummary>;
if (oAttnProcessRunSummary != null)
return oAttnProcessRunSummary;
#endregion
try
{
oAttnProcessRunSummary = Service.GetByStatus(ProcessStatus, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oAttnProcessRunSummary, "GetByStatus");
#endregion
return oAttnProcessRunSummary;
}
public static ObjectsTemplate<AttnProcessRunSummary> GetByMode(EnumProcessMode ProcessMode)
{
#region Cache Header
ObjectsTemplate<AttnProcessRunSummary> oAttnProcessRunSummary = _cache["GetByMode"] as ObjectsTemplate<AttnProcessRunSummary>;
if (oAttnProcessRunSummary != null)
return oAttnProcessRunSummary;
#endregion
try
{
oAttnProcessRunSummary = Service.GetByMode(ProcessMode, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oAttnProcessRunSummary, "GetByMode");
#endregion
return oAttnProcessRunSummary;
}
#endregion
public void AddError(EnumErrorType enumErrorType, string errorDescription, Employee emp)
{
if (_attnProcessRunDetail == null)
_attnProcessRunDetail = new ObjectsTemplate<AttnProcessRunDetail>();
_attnProcessRunDetail.Add(new AttnProcessRunDetail()
{
EnumErrorType = enumErrorType,
Description = errorDescription,
EmployeeNo = emp == null ? string.Empty : emp.EmployeeNo,
EmployeeName = emp == null ? string.Empty : emp.Name
});
if (enumErrorType == EnumErrorType.ServiceException || enumErrorType == EnumErrorType.Exception)
{
ProcessStatus = EnumAttnProcessStatus.Error;
}
else
{
ProcessStatus = EnumAttnProcessStatus.SuccessWithError;
}
}
public ID Save()
{
//this.SetAuditTrailProperties();
return Service.Save(this);
}
#endregion
#region Service Factory IAttnProcessRunSummaryService : IAttnProcessRunSummaryService
internal static IAttnProcessRunSummaryService Service
{
get { return Services.Factory.CreateService<IAttnProcessRunSummaryService>(typeof(IAttnProcessRunSummaryService)); }
}
#endregion
}
#endregion
#region Child Class
#region AttnProcessRunDetail
[Serializable]
public class AttnProcessRunDetail : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(AttnProcessRunDetail));
#endregion
#region Constructor
public AttnProcessRunDetail()
{
_employeeName = string.Empty;
_employeeNo = string.Empty;
_enumErrorType = EnumErrorType.Others;
_locationID = null;
}
#endregion
#region Properties
#region ProcessSummaryID : ID
private ID _processSummaryID;
public ID ProcessSummaryID
{
get { return _processSummaryID; }
set { _processSummaryID = value; }
}
#endregion
#region ErrorType : EnumErrorType
private EnumErrorType _enumErrorType;
public EnumErrorType EnumErrorType
{
get { return _enumErrorType; }
set { _enumErrorType = value; }
}
#endregion
#region EmployeeNo : string
private string _employeeNo;
public string EmployeeNo
{
get { return _employeeNo; }
set { _employeeNo = value; }
}
#endregion
#region EmployeeName : string
private string _employeeName;
public string EmployeeName
{
get { return _employeeName; }
set { _employeeName = value; }
}
#endregion
#region LocationID : ID
private ID _locationID;
public ID LocationID
{
get { return _locationID; }
set { _locationID = value; }
}
#endregion
#region Description : string
private string _description;
public string Description
{
get { return _description; }
set { _description = value; }
}
#endregion
#endregion
}
#endregion
#endregion
#region IAttnProcessRunSummary Service
public interface IAttnProcessRunSummaryService
{
ID Save(AttnProcessRunSummary item);
AttnProcessRunSummary Get(ID id);
ObjectsTemplate<AttnProcessRunSummary> GetByID( ID PayrolltypeID);
ObjectsTemplate<AttnProcessRunSummary> GetByStatus(EnumProcessStatus ProcessStatus, ID PayrolltypeID);
ObjectsTemplate<AttnProcessRunSummary> GetByMode(EnumProcessMode ProcessMode, ID PayrolltypeID);
ObjectsTemplate<AttnProcessRunDetail> GetAttnProcessRunDetails(ID id);
}
#endregion
}