518 lines
19 KiB
C#
518 lines
19 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 Payroll.Service.Attendence.DA;
|
|
using System.Data;
|
|
|
|
namespace Payroll.Service.Attendence.Service
|
|
{
|
|
#region BuyerDailyAttProcess Service
|
|
[Serializable]
|
|
public class BuyerDailyAttProcessService : ServiceTemplate, IBuyerDailyAttProcessService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(BuyerDailyAttProcessService));
|
|
|
|
#endregion
|
|
public BuyerDailyAttProcessService() { }
|
|
|
|
private void MapObject(BuyerDailyAttProcess oBuyerDailyAttProcess, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oBuyerDailyAttProcess, oReader.GetID("BuyerDailyAttProcessID"));
|
|
oBuyerDailyAttProcess.BuyerID = oReader.GetID("BuyerID");
|
|
oBuyerDailyAttProcess.EmployeeID = oReader.GetID("EmployeeID");
|
|
oBuyerDailyAttProcess.AttnDate = oReader.GetDateTime("AttnDate").Value;
|
|
oBuyerDailyAttProcess.ShiftID = oReader.GetID("ShiftID").IsUnassigned ? ID.FromInteger(0) : oReader.GetID("ShiftID");
|
|
oBuyerDailyAttProcess.InTime = oReader.GetDateTime("InTime").HasValue ? oReader.GetDateTime("InTime").Value : DateTime.MinValue;
|
|
oBuyerDailyAttProcess.OutTime = oReader.GetDateTime("OutTime").HasValue ? oReader.GetDateTime("OutTime").Value : DateTime.MinValue;
|
|
oBuyerDailyAttProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttnType").Value;
|
|
oBuyerDailyAttProcess.Comments = oReader.GetString("Comments");
|
|
oBuyerDailyAttProcess.IsManualEntry = oReader.GetBoolean("IsManualEntry").Value;
|
|
oBuyerDailyAttProcess.LateHour = oReader.GetDouble("LateHour").HasValue ? oReader.GetDouble("LateHour").Value : 0;
|
|
oBuyerDailyAttProcess.EarlyHour = oReader.GetDouble("EarlyHour").HasValue ? oReader.GetDouble("EarlyHour").Value : 0;
|
|
oBuyerDailyAttProcess.OTHour = oReader.GetDouble("OTHour").HasValue ? oReader.GetDouble("OTHour").Value : 0;
|
|
oBuyerDailyAttProcess.ReferenceID = oReader.GetID("ReferenceID").IsUnassigned ? ID.FromInteger(0) : oReader.GetID("ReferenceID");
|
|
oBuyerDailyAttProcess.CreatedBy = oReader.GetID("CreatedBy");
|
|
oBuyerDailyAttProcess.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
|
|
oBuyerDailyAttProcess.ModifiedBy = oReader.GetID("ModifiedBy");
|
|
oBuyerDailyAttProcess.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
this.SetObjectState(oBuyerDailyAttProcess, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
BuyerDailyAttProcess oBuyerDailyAttProcess = new BuyerDailyAttProcess();
|
|
MapObject(oBuyerDailyAttProcess, oReader);
|
|
return oBuyerDailyAttProcess as T;
|
|
}
|
|
protected BuyerDailyAttProcess CreateObject(DataReader oReader)
|
|
{
|
|
BuyerDailyAttProcess oBuyerDailyAttProcess = new BuyerDailyAttProcess();
|
|
MapObject(oBuyerDailyAttProcess, oReader);
|
|
return oBuyerDailyAttProcess;
|
|
}
|
|
#region Service implementation
|
|
|
|
public BuyerDailyAttProcess Get(ID id)
|
|
{
|
|
BuyerDailyAttProcess oBuyerDailyAttProcess = new BuyerDailyAttProcess();
|
|
#region Cache Header
|
|
oBuyerDailyAttProcess = _cache["Get", id] as BuyerDailyAttProcess;
|
|
if (oBuyerDailyAttProcess != null)
|
|
return oBuyerDailyAttProcess;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(BuyerDailyAttProcessDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oBuyerDailyAttProcess = this.CreateObject<BuyerDailyAttProcess>(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(oBuyerDailyAttProcess, "Get", id);
|
|
#endregion
|
|
return oBuyerDailyAttProcess;
|
|
}
|
|
|
|
public ObjectsTemplate<BuyerDailyAttProcess> Get()
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<BuyerDailyAttProcess> buyerDailyAttnProcesses = _cache["Get"] as ObjectsTemplate<BuyerDailyAttProcess>;
|
|
if (buyerDailyAttnProcesses != null)
|
|
return buyerDailyAttnProcesses;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BuyerDailyAttProcessDA.Get(tc));
|
|
buyerDailyAttnProcesses = this.CreateObjects<BuyerDailyAttProcess>(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(buyerDailyAttnProcesses, "Get");
|
|
#endregion
|
|
return buyerDailyAttnProcesses;
|
|
}
|
|
|
|
public ObjectsTemplate<BuyerDailyAttProcess> Get(DateTime attnDate)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<BuyerDailyAttProcess> buyerDailyAttnProcesses = _cache["Get", attnDate] as ObjectsTemplate<BuyerDailyAttProcess>;
|
|
if (buyerDailyAttnProcesses != null)
|
|
return buyerDailyAttnProcesses;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BuyerDailyAttProcessDA.Get(tc, attnDate));
|
|
buyerDailyAttnProcesses = this.CreateObjects<BuyerDailyAttProcess>(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(buyerDailyAttnProcesses, "Get", attnDate);
|
|
#endregion
|
|
return buyerDailyAttnProcesses;
|
|
}
|
|
|
|
public ObjectsTemplate<BuyerDailyAttProcess> GetManualEntry(DateTime attnDate)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<BuyerDailyAttProcess> buyerDailyAttnProcesses = _cache["GetManualEntry", attnDate] as ObjectsTemplate<BuyerDailyAttProcess>;
|
|
if (buyerDailyAttnProcesses != null)
|
|
return buyerDailyAttnProcesses;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BuyerDailyAttProcessDA.GetManualEntry(tc, attnDate));
|
|
buyerDailyAttnProcesses = this.CreateObjects<BuyerDailyAttProcess>(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(buyerDailyAttnProcesses, "GetManualEntry", attnDate);
|
|
#endregion
|
|
return buyerDailyAttnProcesses;
|
|
}
|
|
|
|
public ObjectsTemplate<BuyerDailyAttProcess> Get(ID empID, DateTime fromDate, DateTime toDate, ID buyerID)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<BuyerDailyAttProcess> buyerDailyAttnProcesses = _cache["Get", empID, fromDate, toDate, buyerID] as ObjectsTemplate<BuyerDailyAttProcess>;
|
|
if (buyerDailyAttnProcesses != null)
|
|
return buyerDailyAttnProcesses;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BuyerDailyAttProcessDA.Get(tc, empID, fromDate, toDate, buyerID));
|
|
buyerDailyAttnProcesses = this.CreateObjects<BuyerDailyAttProcess>(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(buyerDailyAttnProcesses, "Get", empID, fromDate, toDate, buyerID);
|
|
#endregion
|
|
return buyerDailyAttnProcesses;
|
|
}
|
|
|
|
public ObjectsTemplate<BuyerDailyAttProcess> Get(DateTime attnDate, ID shiftID, EnumAttendanceType attnType)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<BuyerDailyAttProcess> buyerDailyAttnProcesses = _cache["Get", attnDate, shiftID, attnType] as ObjectsTemplate<BuyerDailyAttProcess>;
|
|
if (buyerDailyAttnProcesses != null)
|
|
return buyerDailyAttnProcesses;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BuyerDailyAttProcessDA.Get(tc, attnDate, shiftID, attnType));
|
|
buyerDailyAttnProcesses = this.CreateObjects<BuyerDailyAttProcess>(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(buyerDailyAttnProcesses, "Get", attnDate, shiftID, attnType);
|
|
#endregion
|
|
return buyerDailyAttnProcesses;
|
|
}
|
|
|
|
public ID Save(BuyerDailyAttProcess oBuyerDailyAttProcess)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oBuyerDailyAttProcess.IsNew)
|
|
{
|
|
int id = tc.GenerateID("BuyerDailyAttProcess", "BuyerDailyAttProcessID");
|
|
base.SetObjectID(oBuyerDailyAttProcess, ID.FromInteger(id));
|
|
BuyerDailyAttProcessDA.Insert(tc, oBuyerDailyAttProcess);
|
|
}
|
|
else
|
|
{
|
|
BuyerDailyAttProcessDA.Update(tc, oBuyerDailyAttProcess);
|
|
}
|
|
tc.End();
|
|
return oBuyerDailyAttProcess.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<BuyerDailyAttProcess> oDAttnProcessess, bool IsCounterClock)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
|
|
tc = TransactionContext.Begin(true);
|
|
int id = tc.GenerateID("BuyerDailyAttProcess", "BuyerDailyAttProcessID");
|
|
if (!IsCounterClock && oDAttnProcessess[0].IsManualEntry == false)
|
|
{
|
|
BuyerDailyAttProcessDA.DeletewithoutManualEdit(tc, oDAttnProcessess[0].AttnDate);
|
|
foreach (BuyerDailyAttProcess dAttnProcess in oDAttnProcessess)
|
|
{
|
|
id = id + 1;
|
|
//if (BuyerDailyAttProcessDA.IsExist(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate, dAttnProcess.BuyerID))
|
|
//{
|
|
// BuyerDailyAttProcessDA.Delete(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate);
|
|
//}
|
|
|
|
|
|
base.SetObjectID(dAttnProcess, ID.FromInteger(id));
|
|
BuyerDailyAttProcessDA.Insert(tc, dAttnProcess);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (BuyerDailyAttProcess dAttnProcess in oDAttnProcessess)
|
|
{
|
|
id = id + 1;
|
|
if (BuyerDailyAttProcessDA.IsExist(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate, dAttnProcess.BuyerID))
|
|
{
|
|
BuyerDailyAttProcessDA.Delete(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate);
|
|
}
|
|
|
|
|
|
base.SetObjectID(dAttnProcess, ID.FromInteger(id));
|
|
BuyerDailyAttProcessDA.Insert(tc, dAttnProcess);
|
|
}
|
|
}
|
|
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);
|
|
BuyerDailyAttProcessDA.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
|
|
}
|
|
}
|
|
|
|
|
|
public DataSet GetMonthlyAttn(DateTime dFromDate, DateTime dToDate, ID buyerID, string sEmpID)
|
|
{
|
|
DataSet monthlyAttn = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
monthlyAttn = BuyerDailyAttProcessDA.GetMonthlyAttn(tc, dFromDate, dToDate, buyerID, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return monthlyAttn;
|
|
}
|
|
|
|
public DataSet GetDailyInOut(DateTime attnDate, ID buyerID, string sEmpID)
|
|
{
|
|
DataSet dailyInOut = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
dailyInOut = BuyerDailyAttProcessDA.GetDailyInOut(tc, attnDate, buyerID, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
|
|
}
|
|
return dailyInOut;
|
|
}
|
|
|
|
public DataSet GetMonthlyDetail(DateTime dFromDate, DateTime dToDate, ID buyerID, string sEmpID)
|
|
{
|
|
DataSet monthlyDetail = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
monthlyDetail = BuyerDailyAttProcessDA.GetMonthlyDetail(tc, dFromDate, dToDate, buyerID, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return monthlyDetail;
|
|
}
|
|
|
|
public DataSet GetDailyAbsent(DateTime attnDate, ID buyerID, string sEmpID)
|
|
{
|
|
DataSet dailyAbsent = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
dailyAbsent = BuyerDailyAttProcessDA.GetDailyAbsent(tc, attnDate, buyerID, sEmpID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
|
|
}
|
|
return dailyAbsent;
|
|
}
|
|
|
|
public DataSet GetMonthlyAttnData(DateTime attnMonth, ID empID)
|
|
{
|
|
DataSet monthlyOTDataBW = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
monthlyOTDataBW = BuyerDailyAttProcessDA.GetMonthlyAttnData(tc, attnMonth, empID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
|
|
}
|
|
return monthlyOTDataBW;
|
|
}
|
|
|
|
public BuyerDailyAttProcess GetDailyEmployeeAbsent(ID empID, DateTime dateTime, ID buyerID)
|
|
{
|
|
#region Cache Header
|
|
BuyerDailyAttProcess buyerDailyAttnProcess = _cache["GetDailyEmployeeAbsent", dateTime, empID, dateTime, buyerID] as BuyerDailyAttProcess;
|
|
if (buyerDailyAttnProcess != null)
|
|
return buyerDailyAttnProcess;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BuyerDailyAttProcessDA.GetDailyEmployeeAbsent(tc, empID, dateTime, buyerID));
|
|
if (dr.Read())
|
|
buyerDailyAttnProcess = this.CreateObject<BuyerDailyAttProcess>(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(buyerDailyAttnProcess, "GetDailyEmployeeAbsent", dateTime, empID, dateTime, buyerID);
|
|
#endregion
|
|
return buyerDailyAttnProcess;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|