1063 lines
37 KiB
C#
1063 lines
37 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 Ease.CoreV35.DataAccess;
|
|||
|
using Payroll.Service.Attendence.DA;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
#region DailyAttnProcess Service
|
|||
|
[Serializable]
|
|||
|
public class DailyAttnProcessService : ServiceTemplate, IDailyAttnProcessService
|
|||
|
{
|
|||
|
Cache _cache = new Cache(typeof(DailyAttnProcess));
|
|||
|
|
|||
|
public DailyAttnProcessService() { }
|
|||
|
|
|||
|
private void MapObject(DailyAttnProcess oDailyAttnProcess, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oDailyAttnProcess, oReader.GetID("DailyAttnProcessID"));
|
|||
|
oDailyAttnProcess.EmployeeID = oReader.GetID("EmployeeID");
|
|||
|
oDailyAttnProcess.AttnDate = oReader.GetDateTime("AttnDate").Value;
|
|||
|
oDailyAttnProcess.ShiftID = oReader.GetID("ShiftID").IsUnassigned ? ID.FromInteger(0) : oReader.GetID("ShiftID"); ;
|
|||
|
oDailyAttnProcess.InTime = oReader.GetDateTime("InTime").HasValue ? oReader.GetDateTime("InTime").Value : DateTime.MinValue;
|
|||
|
oDailyAttnProcess.OutTime = oReader.GetDateTime("OutTime").HasValue ? oReader.GetDateTime("OutTime").Value : DateTime.MinValue;
|
|||
|
oDailyAttnProcess.WorkDayType = (EnumWorkPlanDayType)oReader.GetInt32("WorkDayType").Value;
|
|||
|
oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttnType").Value;
|
|||
|
oDailyAttnProcess.Comments = oReader.GetString("Comments");
|
|||
|
// oDailyAttnProcess.Reason = oReader.GetString("Reason");
|
|||
|
oDailyAttnProcess.IsManualEntry = oReader.GetBoolean("IsManualEntry").Value;
|
|||
|
//oDailyAttnProcess.IsLate = oReader.GetBoolean("IsLate").Value;
|
|||
|
oDailyAttnProcess.LateHour = oReader.GetDouble("LateHour").HasValue ? oReader.GetDouble("LateHour").Value : 0;
|
|||
|
oDailyAttnProcess.EarlyHour = oReader.GetDouble("EarlyHour").HasValue ? oReader.GetDouble("EarlyHour").Value : 0;
|
|||
|
oDailyAttnProcess.OTHour = oReader.GetDouble("OTHour").HasValue ? oReader.GetDouble("OTHour").Value : 0;
|
|||
|
oDailyAttnProcess.ReferenceID = oReader.GetID("ReferenceID").IsUnassigned ? ID.FromInteger(0) : oReader.GetID("ReferenceID");
|
|||
|
oDailyAttnProcess.CreatedBy = oReader.GetID("CreatedBy");
|
|||
|
oDailyAttnProcess.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
|
|||
|
oDailyAttnProcess.ModifiedBy = oReader.GetID("ModifiedBy");
|
|||
|
oDailyAttnProcess.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
this.SetObjectState(oDailyAttnProcess, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
|
|||
|
MapObject(oDailyAttnProcess, oReader);
|
|||
|
return oDailyAttnProcess as T;
|
|||
|
}
|
|||
|
protected DailyAttnProcess CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
|
|||
|
MapObject(oDailyAttnProcess, oReader);
|
|||
|
return oDailyAttnProcess;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
public DailyAttnProcess Get(ID id)
|
|||
|
{
|
|||
|
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
|
|||
|
#region Cache Header
|
|||
|
oDailyAttnProcess = _cache["Get", id] as DailyAttnProcess;
|
|||
|
if (oDailyAttnProcess != null)
|
|||
|
return oDailyAttnProcess;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(DailyAttnProcessDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oDailyAttnProcess = this.CreateObject<DailyAttnProcess>(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(oDailyAttnProcess, "Get", id);
|
|||
|
#endregion
|
|||
|
return oDailyAttnProcess;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get"] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "Get");
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> GetProcessByWPG(EnumWorkPlanGroup wpg, DateTime attnDate)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["GetProcessByWPG", wpg, attnDate] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.GetProcessByWPG(tc, wpg, attnDate));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "GetProcessByWPG", wpg, attnDate);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> Get(DateTime attnDate)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", attnDate] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, attnDate));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "Get", attnDate);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> GetManualProcess(DateTime attnDate)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["GetManualProcess", attnDate] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.GetManualProcess(tc, attnDate));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "GetManualProcess", attnDate);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
//new
|
|||
|
public DailyAttnProcess GetDailyEmployeeAbsent(ID nID, DateTime dateTime)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
DailyAttnProcess dailyAttnProcess = _cache["GetDailyEmployeeAbsent", dateTime, nID] as DailyAttnProcess;
|
|||
|
if (dailyAttnProcess != null)
|
|||
|
return dailyAttnProcess;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.GetDailyEmployeeAbsent(tc, dateTime, nID));
|
|||
|
if (dr.Read())
|
|||
|
dailyAttnProcess = this.CreateObject<DailyAttnProcess>(dr);
|
|||
|
dr.Close();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
if (tc != null)
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(dailyAttnProcess, "GetDailyEmployeeAbsent", dateTime, nID);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcess;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> GetWhrOutTimeIsNull(DateTime attnDate, ID shiftID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["GetWhrOutTimeIsNull", attnDate, shiftID] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.GetWhrOutTimeIsNull(tc, attnDate, shiftID));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "GetWhrOutTimeIsNull", attnDate, shiftID);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> GetEmployeesFirstAttendances(string employeeIDs)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["GetEmployeesFirstAttendances", employeeIDs] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.GetEmployeesFirstAttendances(tc, employeeIDs));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
|
|||
|
dr.Close();
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
if (tc != null)
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(dailyAttnProcesses, "GetEmployeesFirstAttendances", employeeIDs);
|
|||
|
#endregion
|
|||
|
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> Get(ID empID, ID shiftID, DateTime fromdate, DateTime todate, EnumAttendanceType enumAttendanceType)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", empID, shiftID, fromdate, todate, enumAttendanceType] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, empID, shiftID, fromdate, todate, enumAttendanceType));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
|
|||
|
dr.Close();
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
if (tc != null)
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(dailyAttnProcesses, "Get", empID, shiftID, fromdate, todate, enumAttendanceType);
|
|||
|
#endregion
|
|||
|
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
//
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> Get(ID empID, DateTime fromDate, DateTime toDate)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", empID, fromDate, toDate] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, empID, fromDate, toDate));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "Get", empID, fromDate, toDate);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> Get(string empID, DateTime fromDate, DateTime toDate)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", empID, fromDate, toDate] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
if (string.IsNullOrEmpty(empID))
|
|||
|
dailyAttnProcesses = new ObjectsTemplate<DailyAttnProcess>();
|
|||
|
else
|
|||
|
{
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, empID, fromDate, toDate));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "Get", empID, fromDate, toDate);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<DailyAttnProcess> Get(DateTime fromDate, DateTime toDate)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", fromDate, toDate] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, fromDate, toDate));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "Get", fromDate, toDate);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
public ObjectsTemplate<DailyAttnProcess> Get(DateTime attnDate, ID shiftID, EnumAttendanceType attnType)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", attnDate, shiftID, attnType] as ObjectsTemplate<DailyAttnProcess>;
|
|||
|
if (dailyAttnProcesses != null)
|
|||
|
return dailyAttnProcesses;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, attnDate, shiftID, attnType));
|
|||
|
dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(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(dailyAttnProcesses, "Get", attnDate, shiftID, attnType);
|
|||
|
#endregion
|
|||
|
return dailyAttnProcesses;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save(DailyAttnProcess oDailyAttnProcess)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oDailyAttnProcess.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("DailyAttnProcess", "DailyAttnProcessID");
|
|||
|
base.SetObjectID(oDailyAttnProcess, ID.FromInteger(id));
|
|||
|
DailyAttnProcessDA.Insert(tc, oDailyAttnProcess);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
DailyAttnProcessDA.Update(tc, oDailyAttnProcess);
|
|||
|
}
|
|||
|
tc.End();
|
|||
|
return oDailyAttnProcess.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<DailyAttnProcess> oDAttnProcessess, bool IscounterClock)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
int id = tc.GenerateID("DailyAttnProcess", "DailyAttnProcessID");
|
|||
|
if (!IscounterClock && oDAttnProcessess[0].IsManualEntry == false)
|
|||
|
{
|
|||
|
DailyAttnProcessDA.Deletewithoutmanulentry(tc, oDAttnProcessess[0].AttnDate);
|
|||
|
foreach (DailyAttnProcess dAttnProcess in oDAttnProcessess)
|
|||
|
{
|
|||
|
id = id + 1;
|
|||
|
//if (DailyAttnProcessDA.IsExist(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate))
|
|||
|
//{
|
|||
|
// DailyAttnProcessDA.Delete(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate);
|
|||
|
//}
|
|||
|
|
|||
|
base.SetObjectID(dAttnProcess, ID.FromInteger(id));
|
|||
|
DailyAttnProcessDA.Insert(tc, dAttnProcess);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
foreach (DailyAttnProcess dAttnProcess in oDAttnProcessess)
|
|||
|
{
|
|||
|
id = id + 1;
|
|||
|
if (DailyAttnProcessDA.IsExist(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate))
|
|||
|
{
|
|||
|
DailyAttnProcessDA.Delete(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate);
|
|||
|
}
|
|||
|
|
|||
|
base.SetObjectID(dAttnProcess, ID.FromInteger(id));
|
|||
|
DailyAttnProcessDA.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 SaveAuto(ObjectsTemplate<DailyAttnProcess> oDAttnProcessess, AttnProcessRunSummary oAttnRunSummary)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
int id = tc.GenerateID("DailyAttnProcess", "DailyAttnProcessID");
|
|||
|
|
|||
|
//DailyAttnProcessDA.Deletewithoutmanulentry(tc, oDAttnProcessess[0].AttnDate);
|
|||
|
foreach (DailyAttnProcess dAttnProcess in oDAttnProcessess)
|
|||
|
{
|
|||
|
id = id + 1;
|
|||
|
|
|||
|
if (DailyAttnProcessDA.IsExist(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate))
|
|||
|
{
|
|||
|
DailyAttnProcessDA.Delete(tc, dAttnProcess.EmployeeID, dAttnProcess.AttnDate);
|
|||
|
}
|
|||
|
|
|||
|
base.SetObjectID(dAttnProcess, ID.FromInteger(id));
|
|||
|
DailyAttnProcessDA.Insert(tc, dAttnProcess);
|
|||
|
}
|
|||
|
|
|||
|
(new AttnProcessRunSummaryService()).Save(oAttnRunSummary, tc);
|
|||
|
|
|||
|
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);
|
|||
|
DailyAttnProcessDA.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 void UpdateLeave(ID employeeID, ID leaveID, DateTime leavaDate, int n)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
DailyAttnProcessDA.UpdateLeave(tc, employeeID, leaveID, leavaDate, n);
|
|||
|
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 UpdateLeave(TransactionContext tc, ID employeeID, ID leaveID, DateTime leavaDate, int n)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
DailyAttnProcessDA.UpdateLeave(tc, employeeID, leaveID, leavaDate, n);
|
|||
|
}
|
|||
|
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, string sEmpID)
|
|||
|
{
|
|||
|
DataSet monthlyAttn = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
monthlyAttn = DailyAttnProcessDA.GetMonthlyAttn(tc, dFromDate, dToDate, 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, string sEmpID)
|
|||
|
{
|
|||
|
DataSet dailyInOut = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
dailyInOut = DailyAttnProcessDA.GetDailyInOut(tc, attnDate, 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 GetDailyDataByStatus(DateTime attnDate, string sStatus, string sEmpID)
|
|||
|
{
|
|||
|
DataSet dailyInOut = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
dailyInOut = DailyAttnProcessDA.GetDailyDataByStatus(tc, attnDate, sStatus, 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 GetDateRangeDataByStatus(DateTime attnFromDate,DateTime attnToDate, string sStatus, string sEmpID)
|
|||
|
{
|
|||
|
DataSet dailyInOut = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
dailyInOut = DailyAttnProcessDA.GetDateRangeDataByStatus(tc, attnFromDate, attnToDate, sStatus, 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 GetDailyAbsent(DateTime attnDate, string sEmpID)
|
|||
|
{
|
|||
|
DataSet dailyAbsent = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
dailyAbsent = DailyAttnProcessDA.GetDailyAbsent(tc, attnDate, 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 GetDailyInOutAndAbsent(DateTime attnDate, string sEmpID)
|
|||
|
{
|
|||
|
DataSet dailyInOutAndAbsent = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
dailyInOutAndAbsent = DailyAttnProcessDA.GetDailyInOutAndAbsent(tc, attnDate, 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 dailyInOutAndAbsent;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetMonthlyDetail(DateTime dFromDate, DateTime dToDate, string sEmpID)
|
|||
|
{
|
|||
|
DataSet monthlyDetail = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
monthlyDetail = DailyAttnProcessDA.GetMonthlyDetail(tc, dFromDate, dToDate, 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 GetMonthlyLongAbsent(DateTime dFromDate, DateTime dToDate, int totalAbsentDays)
|
|||
|
{
|
|||
|
DataSet monthlyDetail = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
monthlyDetail = DailyAttnProcessDA.GetMonthlyLongAbsent(tc, dFromDate, dToDate, totalAbsentDays);
|
|||
|
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 GetEmpAttenInfo(string sEmpID)
|
|||
|
{
|
|||
|
DataSet empAttenInfo = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
empAttenInfo = DailyAttnProcessDA.GetEmpAttenInfo(tc, 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 empAttenInfo;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpCardInfo(string sEmpID)
|
|||
|
{
|
|||
|
DataSet empAttenInfo = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
empAttenInfo = DailyAttnProcessDA.GetEmpCardInfo(tc, 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 empAttenInfo;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpCardInfoPerPage(string sEmpID)
|
|||
|
{
|
|||
|
DataSet empAttenInfo = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
empAttenInfo = DailyAttnProcessDA.GetEmpCardInfoPerPage(tc, 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 empAttenInfo;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetHolidays(DateTime attnDate, ID empID)
|
|||
|
{
|
|||
|
DataSet holidays = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
holidays = DailyAttnProcessDA.GetHolidays(tc, attnDate, 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 holidays;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetPresentDays(DateTime attnDate, ID empID)
|
|||
|
{
|
|||
|
DataSet presentDays = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
presentDays = DailyAttnProcessDA.GetPresentDays(tc, attnDate, 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 presentDays;
|
|||
|
}
|
|||
|
|
|||
|
public DateTime GetLastProcessDate()
|
|||
|
{
|
|||
|
DateTime lastProcessDate = DateTime.MinValue;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
DataReader oreader = new DataReader(DailyAttnProcessDA.GetLastProcessDate(tc));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
lastProcessDate = oreader.GetDateTime("LastProcessDate").HasValue ? oreader.GetDateTime("LastProcessDate").Value : DateTime.MinValue;
|
|||
|
}
|
|||
|
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
|
|||
|
}
|
|||
|
return lastProcessDate;
|
|||
|
}
|
|||
|
|
|||
|
public DateTime GetLastProcessDateByPayrollType(ID PayrolltypeID)
|
|||
|
{
|
|||
|
DateTime lastProcessDate = DateTime.MinValue;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
DataReader oreader = new DataReader(DailyAttnProcessDA.GetLastProcessDateByPayrollType(tc, PayrolltypeID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
lastProcessDate = oreader.GetDateTime("LastProcessDate").HasValue ? oreader.GetDateTime("LastProcessDate").Value : DateTime.MinValue;
|
|||
|
}
|
|||
|
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
|
|||
|
}
|
|||
|
return lastProcessDate;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|