197 lines
6.5 KiB
C#
197 lines
6.5 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Payroll.BO;
|
|||
|
using Payroll.Service.Attendence.DA;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
|
|||
|
|
|||
|
namespace Payroll.Service.Attendence
|
|||
|
{
|
|||
|
#region DailyOTProcess Service
|
|||
|
[Serializable]
|
|||
|
public class DailyOTProcessService : ServiceTemplate, IDailyOTProcessService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(DailyOTProcess));
|
|||
|
|
|||
|
#endregion
|
|||
|
public DailyOTProcessService() { }
|
|||
|
|
|||
|
private void MapObject(DailyOTProcess oDailyOTProcess, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oDailyOTProcess, oReader.GetID("ProcessID"));
|
|||
|
oDailyOTProcess.TermID = oReader.GetID("termID");
|
|||
|
oDailyOTProcess.Value = oReader.GetInt32("value").Value;
|
|||
|
oDailyOTProcess.EmployeeID = oReader.GetID("employeeID");
|
|||
|
oDailyOTProcess.WorkingDate = oReader.GetDateTime("workingdate").Value;
|
|||
|
this.SetObjectState(oDailyOTProcess, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
DailyOTProcess oDailyOTProcess = new DailyOTProcess();
|
|||
|
MapObject(oDailyOTProcess, oReader);
|
|||
|
return oDailyOTProcess as T;
|
|||
|
}
|
|||
|
protected DailyOTProcess CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
DailyOTProcess oDailyOTProcess = new DailyOTProcess();
|
|||
|
MapObject(oDailyOTProcess, oReader);
|
|||
|
return oDailyOTProcess;
|
|||
|
}
|
|||
|
#region Service implementation
|
|||
|
public DailyOTProcess Get(ID id)
|
|||
|
{
|
|||
|
DailyOTProcess oDailyOTProcess = new DailyOTProcess();
|
|||
|
#region Cache Header
|
|||
|
oDailyOTProcess = _cache["Get", id] as DailyOTProcess;
|
|||
|
if (oDailyOTProcess != null)
|
|||
|
return oDailyOTProcess;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(DailyOTProcessDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oDailyOTProcess = this.CreateObject<DailyOTProcess>(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(oDailyOTProcess, "Get", id);
|
|||
|
#endregion
|
|||
|
return oDailyOTProcess;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyOTProcess> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyOTProcess> dailyOTProcesses = _cache["Get"] as ObjectsTemplate<DailyOTProcess>;
|
|||
|
if (dailyOTProcesses != null)
|
|||
|
return dailyOTProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyOTProcessDA.Get(tc));
|
|||
|
dailyOTProcesses = this.CreateObjects<DailyOTProcess>(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(dailyOTProcesses, "Get");
|
|||
|
#endregion
|
|||
|
return dailyOTProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save(DailyOTProcess oDailyOTProcess)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oDailyOTProcess.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("DailyOTProcess", "ProcessID");
|
|||
|
base.SetObjectID(oDailyOTProcess, ID.FromInteger(id));
|
|||
|
DailyOTProcessDA.Insert(tc, oDailyOTProcess);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
DailyOTProcessDA.Update(tc, oDailyOTProcess);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
return oDailyOTProcess.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Save(ObjectsTemplate<DailyOTProcess> oDailyOTProcesses)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
foreach (DailyOTProcess oDailyOTProcess in oDailyOTProcesses)
|
|||
|
{
|
|||
|
if (oDailyOTProcess.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("DailyOTProcess", "ProcessID");
|
|||
|
base.SetObjectID(oDailyOTProcess, ID.FromInteger(id));
|
|||
|
DailyOTProcessDA.Insert(tc, oDailyOTProcess);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
DailyOTProcessDA.Update(tc, oDailyOTProcess);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
DailyOTProcessDA.Delete(tc, id);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|