338 lines
13 KiB
C#
338 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35.Model;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Caching;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Data;
|
|
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
class AttnProcessRunSummaryService : ServiceTemplate, IAttnProcessRunSummaryService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(DailyAttnProcess));
|
|
|
|
#endregion
|
|
#region Map Object
|
|
private void MapObject(AttnProcessRunSummary oAttnProcessRunSummary, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oAttnProcessRunSummary, oReader.GetID("AttnProcessRunSummeryID"));
|
|
oAttnProcessRunSummary.ProcessDate = oReader.GetDateTime("ProcessDate").Value;
|
|
oAttnProcessRunSummary.ProcessMode = (EnumProcessMode)oReader.GetInt32("ProcessMode").Value;
|
|
oAttnProcessRunSummary.ProcessBy = oReader.GetID("ProcessBy");
|
|
oAttnProcessRunSummary.ProcessStatus = (EnumAttnProcessStatus)oReader.GetInt32("ProcessStatus").Value;
|
|
oAttnProcessRunSummary.PayrollTypeID = oReader.GetID("PayrollTypeID");
|
|
this.SetObjectState(oAttnProcessRunSummary, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
AttnProcessRunSummary oAttnProcessRunSummary = new AttnProcessRunSummary();
|
|
MapObject(oAttnProcessRunSummary, oReader);
|
|
return oAttnProcessRunSummary as T;
|
|
}
|
|
protected AttnProcessRunSummary CreateObject(DataReader oReader)
|
|
{
|
|
AttnProcessRunSummary oAttnProcessRunSummary = new AttnProcessRunSummary();
|
|
MapObject(oAttnProcessRunSummary, oReader);
|
|
return oAttnProcessRunSummary;
|
|
}
|
|
#endregion
|
|
#region Child Object Mapping
|
|
|
|
private ObjectsTemplate<AttnProcessRunDetail> CreateAttnProcessRunDetails(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<AttnProcessRunDetail> oAttnProcessRunDetails = new ObjectsTemplate<AttnProcessRunDetail>();
|
|
while (oReader.Read())
|
|
{
|
|
AttnProcessRunDetail oAttnProcessRunDetail = new AttnProcessRunDetail();
|
|
MapAttnProcessRunDetailObject(oAttnProcessRunDetail, oReader);
|
|
oAttnProcessRunDetails.Add(oAttnProcessRunDetail);
|
|
}
|
|
return oAttnProcessRunDetails;
|
|
}
|
|
|
|
private void MapAttnProcessRunDetailObject(AttnProcessRunDetail oAttnProcessRunDetail, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oAttnProcessRunDetail, oReader.GetID("AttnProcessRunDetailID"));
|
|
oAttnProcessRunDetail.ProcessSummaryID = oReader.GetID("AttnProcessSummaryID");
|
|
oAttnProcessRunDetail.EnumErrorType = (EnumErrorType)oReader.GetInt32("ErrorType").Value;
|
|
oAttnProcessRunDetail.EmployeeNo = oReader.GetString("EmployeeNo");
|
|
oAttnProcessRunDetail.EmployeeName = oReader.GetString("EmployeeName");
|
|
oAttnProcessRunDetail.Description = oReader.GetString("Description");
|
|
oAttnProcessRunDetail.LocationID = oReader.GetID("LocationID");
|
|
this.SetObjectState(oAttnProcessRunDetail, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
|
|
#endregion
|
|
#region IAttnProcessRunSummaryService Members
|
|
#region Save
|
|
public ID Save(AttnProcessRunSummary oAttnProcessRunSummary)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
if (oAttnProcessRunSummary.IsNew)
|
|
{
|
|
int id = tc.GenerateID("AttnProcessRunSummary", "AttnProcessRunSummeryID");
|
|
base.SetObjectID(oAttnProcessRunSummary, ID.FromInteger(id));
|
|
AttnProcessRunSummaryDA.Insert(tc, oAttnProcessRunSummary);
|
|
}
|
|
else
|
|
{
|
|
AttnProcessRunSummaryDA.Update(tc, oAttnProcessRunSummary);
|
|
|
|
#region Delete Childs
|
|
AttnProcessRunSummaryDA.DeleteAttnProcessRunDetails(tc, oAttnProcessRunSummary.ID);
|
|
#endregion
|
|
}
|
|
|
|
#region Insert Childs
|
|
foreach (AttnProcessRunDetail item in oAttnProcessRunSummary.AttnProcessRunDetails)
|
|
{
|
|
item.ProcessSummaryID = oAttnProcessRunSummary.ID;
|
|
base.SetObjectID(item, ID.FromInteger(tc.GenerateID("AttnProcessRunDetail", "AttnProcessRunDetailID")));
|
|
AttnProcessRunSummaryDA.InsertAttnProcessRunDetail(tc, item);
|
|
}
|
|
#endregion
|
|
|
|
tc.End();
|
|
return oAttnProcessRunSummary.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public ID Save(AttnProcessRunSummary oAttnProcessRunSummary, TransactionContext tc)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (oAttnProcessRunSummary.IsNew)
|
|
{
|
|
int id = tc.GenerateID("AttnProcessRunSummary", "AttnProcessRunSummeryID");
|
|
base.SetObjectID(oAttnProcessRunSummary, ID.FromInteger(id));
|
|
AttnProcessRunSummaryDA.Insert(tc, oAttnProcessRunSummary);
|
|
}
|
|
else
|
|
{
|
|
AttnProcessRunSummaryDA.Update(tc, oAttnProcessRunSummary);
|
|
|
|
#region Delete Childs
|
|
AttnProcessRunSummaryDA.DeleteAttnProcessRunDetails(tc, oAttnProcessRunSummary.ID);
|
|
#endregion
|
|
}
|
|
|
|
#region Insert Childs
|
|
|
|
foreach (AttnProcessRunDetail item in oAttnProcessRunSummary.AttnProcessRunDetails)
|
|
{
|
|
item.ProcessSummaryID = oAttnProcessRunSummary.ID;
|
|
base.SetObjectID(item, ID.FromInteger(tc.GenerateID("AttnProcessRunDetail", "AttnProcessRunDetailID")));
|
|
AttnProcessRunSummaryDA.InsertAttnProcessRunDetail(tc, item);
|
|
}
|
|
|
|
#endregion
|
|
|
|
return oAttnProcessRunSummary.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#region Child Class Functions
|
|
|
|
public ObjectsTemplate<AttnProcessRunDetail> GetAttnProcessRunDetails(ID id)
|
|
{
|
|
ObjectsTemplate<AttnProcessRunDetail> oAttnProcessRunDetails = new ObjectsTemplate<AttnProcessRunDetail>();
|
|
|
|
#region Cache Header
|
|
oAttnProcessRunDetails = _cache["Get", id] as ObjectsTemplate<AttnProcessRunDetail>;
|
|
if (oAttnProcessRunDetails != null)
|
|
return oAttnProcessRunDetails;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(AttnProcessRunSummaryDA.GetAttnProcessRunDetails(tc, id));
|
|
|
|
oAttnProcessRunDetails = this.CreateAttnProcessRunDetails(oreader);
|
|
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oAttnProcessRunDetails, "Get", id);
|
|
#endregion
|
|
|
|
return oAttnProcessRunDetails;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
#region Get By ID
|
|
public AttnProcessRunSummary Get(ID id)
|
|
{
|
|
AttnProcessRunSummary oAttnProcessRunSummary = new AttnProcessRunSummary();
|
|
#region Cache Header
|
|
oAttnProcessRunSummary = _cache["Get", id] as AttnProcessRunSummary;
|
|
if (oAttnProcessRunSummary != null)
|
|
return oAttnProcessRunSummary;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(AttnProcessRunSummaryDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oAttnProcessRunSummary = this.CreateObject<AttnProcessRunSummary>(oreader);
|
|
}
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oAttnProcessRunSummary, "Get", id);
|
|
#endregion
|
|
return oAttnProcessRunSummary;
|
|
}
|
|
#endregion
|
|
#region Get All
|
|
public ObjectsTemplate<AttnProcessRunSummary> GetByID(ID PayrolltypeID)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<AttnProcessRunSummary> oAttnProcessRunSummary = _cache["Get"] as ObjectsTemplate<AttnProcessRunSummary>;
|
|
if (oAttnProcessRunSummary != null)
|
|
return oAttnProcessRunSummary;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnProcessRunSummaryDA.Get(tc, PayrolltypeID));
|
|
oAttnProcessRunSummary = this.CreateObjects<AttnProcessRunSummary>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oAttnProcessRunSummary, "Get");
|
|
#endregion
|
|
return oAttnProcessRunSummary;
|
|
}
|
|
#endregion
|
|
#region Get By Status
|
|
public ObjectsTemplate<AttnProcessRunSummary> GetByStatus(EnumProcessStatus ProcessStatus, ID PayrolltypeID)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<AttnProcessRunSummary> oAttnProcessRunSummarys = _cache["GetByStatus", ProcessStatus] as ObjectsTemplate<AttnProcessRunSummary>;
|
|
if (oAttnProcessRunSummarys != null)
|
|
return oAttnProcessRunSummarys;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnProcessRunSummaryDA.GetByStatus(tc, ProcessStatus, PayrolltypeID));
|
|
oAttnProcessRunSummarys = this.CreateObjects<AttnProcessRunSummary>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oAttnProcessRunSummarys, "GetByStatus", ProcessStatus);
|
|
#endregion
|
|
return oAttnProcessRunSummarys;
|
|
}
|
|
#endregion
|
|
#region Get By Mode
|
|
public ObjectsTemplate<AttnProcessRunSummary> GetByMode(EnumProcessMode ProcessMode, ID PayrolltypeID)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<AttnProcessRunSummary> oAttnProcessRunSummarys = _cache["GetByMode", ProcessMode] as ObjectsTemplate<AttnProcessRunSummary>;
|
|
if (oAttnProcessRunSummarys != null)
|
|
return oAttnProcessRunSummarys;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(AttnProcessRunSummaryDA.GetByMode(tc, ProcessMode, PayrolltypeID));
|
|
oAttnProcessRunSummarys = this.CreateObjects<AttnProcessRunSummary>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oAttnProcessRunSummarys, "GetByMode", ProcessMode);
|
|
#endregion
|
|
return oAttnProcessRunSummarys;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|