EchoTex_Payroll/HRM.DA/Service/Attendance/DailyAttnProcessService.cs
2024-10-14 10:01:49 +06:00

4815 lines
184 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Payroll.Service;
using HRM.BO;
using Ease.Core.Model;
using Ease.Core.DataAccess;
using Ease.Core.Utility;
using Ease.Core.DataAccess.SQL;
using Microsoft.Data.SqlClient;
using HRM.BO.Configuration;
using NPOI.Util;
using System.DirectoryServices.Protocols;
using System.Threading;
using iTextSharp.text.pdf.parser.clipper;
namespace HRM.DA
{
#region DailyAttnProcess Service
[Serializable]
public class DailyAttnProcessService : ServiceTemplate, IDailyAttnProcessService
{
public DailyAttnProcessService()
{
}
private void MapObject(DailyAttnProcess oDailyAttnProcess, DataReader oReader)
{
base.SetObjectID(oDailyAttnProcess, (oReader.GetInt32("DailyAttnProcessID").Value));
oDailyAttnProcess.EmployeeID = oReader.GetInt32("EmployeeID").Value;
oDailyAttnProcess.AttnDate = oReader.GetDateTime("AttnDate").Value;
oDailyAttnProcess.ShiftID = oReader.GetInt32("ShiftID");
oDailyAttnProcess.InTime = oReader.GetDateTime("InTime");
oDailyAttnProcess.OutTime = oReader.GetDateTime("OutTime");
oDailyAttnProcess.ActualInTime = oReader.GetDateTime("ActualInTime");
oDailyAttnProcess.ActualOutTime = oReader.GetDateTime("ActualOutTime");
oDailyAttnProcess.ActualShiftID = oReader.GetInt32("ActualShiftID");
oDailyAttnProcess.WorkDayType = (EnumWorkPlanDayType)oReader.GetInt32("WorkDayType").Value;
//oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttenType", true, 0);
//if(oDailyAttnProcess.AttenType == EnumAttendanceType.None)
//oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttnType", true, 0);
//oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttnType").Value;
oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttenType").Value;
oDailyAttnProcess.Comments = oReader.GetString("Comments") == null ? "" : oReader.GetString("Comments");
oDailyAttnProcess.Reason = oReader.GetString("Reason") == null ? "" : oReader.GetString("Reason");
oDailyAttnProcess.IsManualEntry = oReader.GetBoolean("IsManualEntry").Value;
oDailyAttnProcess.IsFromMobile = (EnumIsFromMobile)oReader.GetInt32("IsFromMobile").Value;
oDailyAttnProcess.InTimeLatitude = oReader.GetString("InTimeLatitude") == null ? 0.0m : Convert.ToDecimal(oReader.GetString("InTimeLatitude"));
oDailyAttnProcess.OutTimeLatitude = oReader.GetString("OutTimeLatitude") == null ? 0.0m : Convert.ToDecimal(oReader.GetString("OutTimeLatitude"));
oDailyAttnProcess.InTimeLongitude = oReader.GetString("InTimeLongitude") == null ? 0.0m : Convert.ToDecimal(oReader.GetString("InTimeLongitude"));
oDailyAttnProcess.OutTimeLongitude = oReader.GetString("OutTimeLongitude") == null ? 0.0m : Convert.ToDecimal(oReader.GetString("OutTimeLongitude"));
oDailyAttnProcess.InTimeNearestAddress = oReader.GetString("InTimeNearestAddress") == null ? "" : oReader.GetString("InTimeNearestAddress");
oDailyAttnProcess.OutTimeNearestAddress = oReader.GetString("OutTimeNearestAddress") == null ? "" : oReader.GetString("OutTimeNearestAddress");
oDailyAttnProcess.EmpApplyDate = oReader.GetDateTime("EmpApplyDate");
oDailyAttnProcess.EmpRemarks = oReader.GetString("EmpRemarks") == null ? "" : oReader.GetString("EmpRemarks");
oDailyAttnProcess.LMApproveDate = oReader.GetDateTime("LMApproveDate");
oDailyAttnProcess.LineManagerID = oReader.GetInt32("LineManagerID");
oDailyAttnProcess.OnbehalfEmpID = oReader.GetInt32("OnbehalfEmpID");
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.WorkHour = oReader.GetDouble("WorkHour").HasValue ? oReader.GetDouble("WorkHour").Value : 0;
oDailyAttnProcess.OTHour = oReader.GetDouble("OTHour").HasValue ? oReader.GetDouble("OTHour").Value : 0;
oDailyAttnProcess.ApprovedOTHour = oReader.GetDouble("APPROVEDOTHOUR", 0);
oDailyAttnProcess.ReferenceID = oReader.GetInt32("ReferenceID");
oDailyAttnProcess.CreatedBy = oReader.GetInt32("CreatedBy").Value;
oDailyAttnProcess.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
oDailyAttnProcess.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
oDailyAttnProcess.OtRemarks = oReader.GetString("OtRemarks") == null ? "" : oReader.GetString("OtRemarks");
oDailyAttnProcess.LMRemarks = oReader.GetString("LMRemarks") == null ? "" : oReader.GetString("LMRemarks");
oDailyAttnProcess.ModifiedDate = oReader.GetDateTime("ModifiedDate");
oDailyAttnProcess.WFStatus = (EnumWFAttnStatus)oReader.GetInt32("WFStatus", 0);
this.SetObjectState(oDailyAttnProcess, Ease.Core.ObjectState.Saved);
}
private void MapObject(DailyAttnMailSenderReport oDailyAttnMailSenderReport, DataReader oReader)
{
base.SetObjectID(oDailyAttnMailSenderReport, (oReader.GetInt32("DAILYATTNPROCESSID").Value));
oDailyAttnMailSenderReport.DailyAttnProcessID = oReader.GetInt32("DAILYATTNPROCESSID").Value;
oDailyAttnMailSenderReport.EmployeeId = oReader.GetInt32("EMPLOYEEID", 0);
oDailyAttnMailSenderReport.EmployeeNo = oReader.GetString("EMPLOYEENO", string.Empty);
oDailyAttnMailSenderReport.Name = oReader.GetString("NAME", string.Empty);
oDailyAttnMailSenderReport.Designation = oReader.GetString("DESIGNATION", string.Empty);
oDailyAttnMailSenderReport.Department = oReader.GetString("DEPARTMENT", string.Empty);
oDailyAttnMailSenderReport.AttnDate = oReader.GetDateTime("AttnDate", DateTime.MinValue);
oDailyAttnMailSenderReport.Day = oReader.GetString("day", string.Empty);
oDailyAttnMailSenderReport.InTime = oReader.GetDateTime("InTime", DateTime.MinValue);
oDailyAttnMailSenderReport.OutTime = oReader.GetDateTime("OutTime", DateTime.MinValue);
//oDailyAttnMailSenderReport.AttnType = Enum.GetName(typeof(EnumAttendanceType), oReader.GetInt32("AttenType", 0));
oDailyAttnMailSenderReport.AttnType = Enum.GetName(typeof(EnumAttendanceType), oReader.GetInt32("AttnType", 0));
oDailyAttnMailSenderReport.NotPresentType = oReader.GetString("NotPresentType", string.Empty);
oDailyAttnMailSenderReport.LineManagerNo = oReader.GetString("LINEMANAGERNO", string.Empty);
oDailyAttnMailSenderReport.LineManagerName = oReader.GetString("LINEMANAGERNAME", string.Empty);
TimeSpan tempTimeSpan = (oDailyAttnMailSenderReport.OutTime != DateTime.MinValue && oDailyAttnMailSenderReport.InTime != DateTime.MinValue) ? oDailyAttnMailSenderReport.OutTime.Subtract(oDailyAttnMailSenderReport.InTime) : TimeSpan.MinValue;
oDailyAttnMailSenderReport.TotalWorkingHour = tempTimeSpan != TimeSpan.MinValue ? tempTimeSpan.Hours + ":" + tempTimeSpan.Minutes : "0:0";
//oDailyAttnMailSenderReport.LateCount = ((EnumAttendanceType)oReader.GetInt32("AttenType", 0)) == EnumAttendanceType.Late ? "1" : "0";
oDailyAttnMailSenderReport.LateCount = ((EnumAttendanceType)oReader.GetInt32("AttnType", 0)) == EnumAttendanceType.Late ? "1" : "0";
this.SetObjectState(oDailyAttnMailSenderReport, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
MapObject(oDailyAttnProcess, oReader);
return oDailyAttnProcess as T;
}
protected DailyAttnMailSenderReport CreateObject(DataReader oReader)
{
DailyAttnMailSenderReport oDailyAttnMailSenderReport = new DailyAttnMailSenderReport();
MapObject(oDailyAttnMailSenderReport, oReader);
return oDailyAttnMailSenderReport;
}
#region Service implementation
public DataSet GetMonthlyKPIDetail(DateTime dFromDate, DateTime dToDate, string sEmpID, EnumAttendanceType eAttnType)
{
DataSet monthlyDetail = null;
TransactionContext tc = null;
try
{
List<Leave> oLeaves = new LeaveService().GetAll();
tc = TransactionContext.Begin();
monthlyDetail = DailyAttnProcessDA.GetMonthlyKPIDetail(tc, dFromDate, dToDate, sEmpID, oLeaves, eAttnType);
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 List<DailyAttnProcess> GetNew(int empID, DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetNew(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
}
return dailyAttnProcesses;
}
public DataSet GetMonthlyAttendanceReportData(DateTime dFromDate, DateTime dToDate, string sEmpID)
{
DataSet monthlyDetail = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
monthlyDetail = DailyAttnProcessDA.GetMonthlyAttendanceData(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 int GetAttnDataByWFStatusCount(DateTime fromDate, DateTime toDate, EnumWFAttnStatus status)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
return DailyAttnProcessDA.GetAttnDataByWFStatusCount(tc, fromDate, toDate, status);
}
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();
}
}
}
public DailyAttnProcess Get(int id)
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
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
}
return oDailyAttnProcess;
}
public DailyAttnProcess Get(int empid, DateTime attnDate)
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(DailyAttnProcessDA.Get(tc, empid, attnDate));
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
}
return oDailyAttnProcess;
}
public DailyAttnProcess GetforMobileWithNoLock(int empid, DateTime attnDate)
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(DailyAttnProcessDA.GetforMobileWithNoLock(tc, empid, attnDate));
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
}
return oDailyAttnProcess;
}
public DailyAttnProcess Get(TransactionContext tc, int empid, DateTime attnDate)
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
try
{
DataReader oreader = new DataReader(DailyAttnProcessDA.Get(tc, empid, attnDate));
if (oreader.Read())
{
oDailyAttnProcess = this.CreateObject<DailyAttnProcess>(oreader);
}
oreader.Close();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oDailyAttnProcess;
}
public List<DailyAttnProcess> Get(TransactionContext tc, int empid, DateTime attnFromDate, DateTime attnToDate)
{
List<DailyAttnProcess> oDailyAttnProcesses = new List<DailyAttnProcess>();
try
{
DataReader oreader = new DataReader(DailyAttnProcessDA.Get(tc, empid, attnFromDate, attnToDate));
oDailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(oreader);
oreader.Close();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oDailyAttnProcesses;
}
public List<DailyAttnProcess> GetByEmployeeID(int employeeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetByEmployeeID(tc, employeeID));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public JobCardReport GetMonthJobCardByEmployeeId(int EmpID, DateTime dFromDate, DateTime dToDate, int payrollTypeId)
{
JobCardReport jobCardReport = new JobCardReport();
JobCardReportDetails jobCardReportDetails = null;
//Employee employee = new EmployeeService().Get(EmpID);
HREmployee employee = new HREmployeeService().Get(EmpID);
if (employee == null)
{
return new JobCardReport();
}
List<EmployeeUnAuthorizeLeave> _unAuthorizedLeaves = new EmployeeUnAuthorizeLeaveService().GetByEmployeeID(EmpID);
_unAuthorizedLeaves = _unAuthorizedLeaves.Where(o => o.IsLateAttendanceRelated == false).ToList();
EmployeeUnAuthorizeLeave unAuthorizedLeave = null;
EmployeeUnAuthorizeLeave unAuthorizedLeaveHalfDay = null;
string workingHour = string.Empty;
List<Leave> oLeaves = new LeaveService().Get(EnumStatus.Active, payrollTypeId);
//List<AttnMonthlyBenefit> amBenefits = null;
DateTime fromSalaryMonth = DateTime.MinValue;
DateTime toSalaryMonth = DateTime.MinValue;
fromSalaryMonth = new AttnMonthlyBenefitService().GetAttandaceSalaryMonth(dFromDate);
toSalaryMonth = new AttnMonthlyBenefitService().GetAttandaceSalaryMonth(dToDate);
//if (fromSalaryMonth == toSalaryMonth)
//{
// amBenefits = new AttnMonthlyBenefitService().Get(EmpID, fromSalaryMonth);
//}
//else
//{
// amBenefits = new AttnMonthlyBenefitService().Get(EmpID, fromSalaryMonth, toSalaryMonth);
//}
List<DailyAttnProcess> dAttnProcessess = new List<DailyAttnProcess>();
dAttnProcessess = Get(EmpID, dFromDate, dToDate);
List<Shift> oShifts = new ShiftService().Get(string.Empty, string.Empty, EnumStatus.Active, payrollTypeId);
jobCardReport.EmployeeNo = employee.EmployeeNo;
jobCardReport.EmpName = employee.Name;
jobCardReport.Designation = employee.DesignationName;
jobCardReport.Department = employee.DepartmentName;
jobCardReport.JoiningDate = employee.JoiningDate.ToString("dd MMM yyyy");
jobCardReport.FromDate = dFromDate.ToString("dd MMM yyyy");
jobCardReport.ToDate = dToDate.ToString("dd MMM yyyy");
List<String> oTHours = new List<String>();
List<String> latehours = new List<String>();
int presentDays = 0, absentDays = 0, lateDays = 0, leaveDays = 0,
weeklyHolidays = 0, osdDays = 0, festivalHolidays = 0, workingdays = 0, presentInholidays = 0;
if (!(dAttnProcessess == null || dAttnProcessess.Count <= 0))
{
foreach (DailyAttnProcess dAttnProcess in dAttnProcessess)
{
jobCardReportDetails = new JobCardReportDetails();
jobCardReportDetails.Date = dAttnProcess.AttnDate.ToString("dd MMM yyyy");
jobCardReportDetails.Day = dAttnProcess.AttnDate.ToString("dddd");
jobCardReportDetails.Reason = dAttnProcess.Reason;
// jobCardReportDetails.Remarks = dAttnProcess.EmpRemarks;
if ((dAttnProcess.InTime == DateTime.MinValue) || (dAttnProcess.InTime == null))
{
jobCardReportDetails.InTime = "00:00";
}
else
{
jobCardReportDetails.InTime = ((DateTime)dAttnProcess.InTime).ToString("hh:mm tt");
}
if ((dAttnProcess.OutTime == DateTime.MinValue) || (dAttnProcess.OutTime == null))
{
jobCardReportDetails.OutTime = "00:00";
}
else
{
jobCardReportDetails.OutTime = ((DateTime)dAttnProcess.OutTime).ToString("hh:mm tt");
}
if (dAttnProcess.WorkDayType == EnumWorkPlanDayType.WorkingDay) workingdays = workingdays + 1;
//workingHour = ((DateTime)dAttnProcess.OutTime).Subtract(((DateTime)dAttnProcess.InTime)).ToString("hh\\:mm");
//jobCardReportDetails.WorkingHour = dAttnProcess.WorkHour.ToString();
//TimeSpan timeDifferenceWorkingHour = (dAttnProcess.OutTime - dAttnProcess.InTime).HasValue ? (dAttnProcess.OutTime - dAttnProcess.InTime).Value : TimeSpan.Zero;
//jobCardReportDetails.WorkingHour = $"{timeDifferenceWorkingHour.Hours:D2}:{timeDifferenceWorkingHour.Minutes:D2}";
jobCardReportDetails.WorkingHour = dAttnProcess.WorkHour.ToString("0.00");
//jobCardReportDetails.WorkingHour = GlobalFunctions.ConvertDoubleHourToHourMinute(dAttnProcess.WorkHour).ToString();
string LateBy = dAttnProcess.LateHour.ToString("f");
decimal lHour = LateBy == string.Empty ? 0 : Convert.ToDecimal(LateBy);
TimeSpan ts = TimeSpan.FromHours((double)lHour);
int H = ts.Hours + (ts.Days * 24);
int M = ts.Minutes;
//string latehour = H.ToString() + ":" + M.ToString();
jobCardReportDetails.LateBy = dAttnProcess.LateHour.ToString("0.00");
//TimeSpan timeDifferenceLateBy = dAttnProcess.LateHour;
//string OTHr = dAttnProcess.OTHour.ToString("f");
//jobCardReportDetails.OTHour = GlobalFunctions.GetHourMinutes(dAttnProcess.OTHour);
//jobCardReportDetails.OTHour = dAttnProcess.OTHour.ToString();
jobCardReportDetails.OTHour = dAttnProcess.OTHour.ToString("0.00");
oTHours.Add(dAttnProcess.OTHour.ToString("0.00"));
latehours.Add(dAttnProcess.LateHour.ToString("0.00"));
if (dAttnProcess.AttenType == EnumAttendanceType.Leave)
{
jobCardReportDetails.Status = GlobalFunctions.GetLeaveType(dAttnProcess.ReferenceID == null ? 0 : dAttnProcess.ReferenceID.Value, oLeaves);
leaveDays++;
}
else
{
jobCardReportDetails.Status = GlobalFunctions.GetShortAttnType(dAttnProcess.AttenType,
ref presentDays, ref absentDays, ref lateDays, ref leaveDays,
ref weeklyHolidays, ref osdDays, ref festivalHolidays);
if (dAttnProcess.WorkDayType == EnumWorkPlanDayType.WorkingDay &&
dAttnProcess.AttenType == EnumAttendanceType.Present && dAttnProcess.LateHour > 0)
{
jobCardReportDetails.Status = "L-PR";
lateDays = lateDays + 1;
}
else if (dAttnProcess.WorkDayType == EnumWorkPlanDayType.WeeklyHoliday &&
dAttnProcess.AttenType == EnumAttendanceType.Present && dAttnProcess.LateHour > 0)
{
jobCardReportDetails.Status = "WD-L-PR";
weeklyHolidays = weeklyHolidays + 1;
presentInholidays = presentInholidays + 1;
lateDays = lateDays + 1;
}
else if (dAttnProcess.WorkDayType == EnumWorkPlanDayType.WeeklyHoliday &&
dAttnProcess.AttenType == EnumAttendanceType.Present && dAttnProcess.LateHour <= 0)
{
jobCardReportDetails.Status = "WD-PR";
weeklyHolidays = weeklyHolidays + 1;
presentInholidays = presentInholidays + 1;
}
else if (dAttnProcess.WorkDayType == EnumWorkPlanDayType.NationalHoliday &&
dAttnProcess.AttenType == EnumAttendanceType.Present && dAttnProcess.LateHour > 0)
{
jobCardReportDetails.Status = "H-L-PR";
lateDays = lateDays + 1;
festivalHolidays = festivalHolidays + 1;
presentInholidays = presentInholidays + 1;
}
else if (dAttnProcess.WorkDayType == EnumWorkPlanDayType.NationalHoliday &&
dAttnProcess.AttenType == EnumAttendanceType.Present && dAttnProcess.LateHour <= 0)
{
jobCardReportDetails.Status = "H-PR";
festivalHolidays = festivalHolidays + 1;
presentInholidays = presentInholidays + 1;
}
//else
//{
// jobCardReportDetails.Status = GlobalFunctions.GetShortAttnType(dAttnProcess.AttenType,
// ref presentDays, ref absentDays, ref lateDays, ref leaveDays,
// ref weeklyHolidays, ref osdDays, ref festivalHolidays);
//}
}
unAuthorizedLeaveHalfDay = _unAuthorizedLeaves.Where(o => o.LeaveDays == 0.5 && o.FromDate.Date == dAttnProcess.AttnDate && o.ToDate.Date == dAttnProcess.AttnDate).FirstOrDefault();
unAuthorizedLeave = _unAuthorizedLeaves.Where(o => dAttnProcess.AttnDate >= o.FromDate && dAttnProcess.AttnDate <= o.ToDate).FirstOrDefault();
//oAttNHoliday = attNHolidays.Where(o => dDate.Date >= o.FromDate.Date && dDate.Date <= o.ToDate.Date).FirstOrDefault();
// jobCardReportDetails.Remarks = unAuthorizedLeaveHalfDay == null ? dAttnProcess.Comments : "1/2 day";
if (unAuthorizedLeave != null)
jobCardReportDetails.Status = "LWP";
if (dAttnProcess.ShiftID != null)
{
Shift oSft = oShifts.Where(o => o.ID == dAttnProcess.ShiftID).FirstOrDefault();
if (oSft != null)
{
jobCardReportDetails.Shift = oSft.ShortName;
}
else
{
jobCardReportDetails.Shift = string.Empty;
}
}
jobCardReportDetails.Reason = dAttnProcess.Reason;
jobCardReport.JobCardReportDetails.Add(jobCardReportDetails);
}
}
jobCardReport.TotalOTHour = GlobalFunctions.GetHourMinutes(oTHours);
jobCardReport.TotalLateHour = GlobalFunctions.GetHourMinutes(latehours);
jobCardReport.PresentDays = (presentDays - presentInholidays).ToString();
jobCardReport.AbsentDays = absentDays.ToString();
jobCardReport.LateDays = lateDays.ToString();
jobCardReport.LeaveDays = leaveDays.ToString();
jobCardReport.WeeklyHolidays = weeklyHolidays.ToString();
jobCardReport.OSDDays = osdDays.ToString();
jobCardReport.FestivalHolidays = festivalHolidays.ToString();
jobCardReport.WorkingDays = dAttnProcessess.Count.ToString();
jobCardReport.PresentInholidays = presentInholidays.ToString();
return jobCardReport;
}
public List<DailyAttnProcess> GetProcessByWPG(EnumWorkPlanGroup wpg, DateTime attnDate)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetProcessByWPG(tc, wpg, attnDate));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public DailyAttnProcess GetAttnDataByWFStatus(int DailyAttnProcessID, EnumWFAttnStatus status)
{
TransactionContext tc = null;
try
{
var dailyAttnProcess = new DailyAttnProcess();
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(DailyAttnProcessDA.GetAttnDataByWFStatus(tc, DailyAttnProcessID, status));
if (dr.Read())
{
dailyAttnProcess = this.CreateObject<DailyAttnProcess>(dr);
}
dr.Close();
tc.End();
return dailyAttnProcess;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> GetManualProcess(DateTime attnDate, int payrollType)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetManualProcess(tc, attnDate, payrollType));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> Get(DateTime attnDate, int payrollTypeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, attnDate, payrollTypeID));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> GetDateRange(DateTime attnFromDate, DateTime attnToDate, int payrollTypeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, attnFromDate, attnToDate, payrollTypeID));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> GetAll()
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> Get(DateTime attnDate, string empids, int payrollTypeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, attnDate, empids, payrollTypeID));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> GetManualProcess(int payrollTypeID, DateTime attnDate)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetManualProcess(tc, payrollTypeID, attnDate));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
//new
public DailyAttnProcess GetDailyEmployeeAbsent(int nID, DateTime dateTime)
{
TransactionContext tc = null;
try
{
var dailyAttnProcess = new DailyAttnProcess();
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetDailyEmployeeAbsent(tc, dateTime, nID));
if (dr.Read())
dailyAttnProcess = this.CreateObject<DailyAttnProcess>(dr);
dr.Close();
return dailyAttnProcess;
}
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();
}
}
public List<DailyAttnProcess> GetWhrOutTimeIsNull(DateTime attnDate, int shiftID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetWhrOutTimeIsNull(tc, attnDate, shiftID));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> GetEmployeesFirstAttendances(string employeeIDs)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetEmployeesFirstAttendances(tc, employeeIDs));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
return dailyAttnProcesses;
}
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();
}
}
public List<DailyAttnProcess> Get(int empID, int shiftID, DateTime fromdate, DateTime todate,
EnumAttendanceType enumAttendanceType)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(DailyAttnProcessDA.Get(tc, empID, shiftID, fromdate, todate, enumAttendanceType));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
return dailyAttnProcesses;
}
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();
}
}
//
public List<DailyAttnProcess> Get(int empID, DateTime fromDate, DateTime toDate)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, empID, fromDate, toDate));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> Get(string empID, DateTime fromDate, DateTime toDate)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, empID, fromDate, toDate));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> Get(TransactionContext tc, string empID, DateTime fromDate, DateTime toDate)
{
try
{
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, empID, fromDate, toDate));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> Get(DateTime fromDate, DateTime toDate, int payrollType)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, fromDate, toDate, payrollType));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> Get(DateTime attnDate, int shiftID, EnumAttendanceType attnType)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, attnDate, shiftID, attnType));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void Save(List<DailyAttnProcess> oDAttnProcessess, List<AttnMonthlyBenefit> attnMonthlyBenefit)
{
TransactionContext tc = null;
try
{
List<DailyAttendanceAllowance> benifits = new List<DailyAttendanceAllowance>();
foreach (DailyAttnProcess item in oDAttnProcessess)
{
if (item.Benifits != null)
{
benifits.AddRange(item.Benifits);
}
//else
//{
// if (item.AttenType != EnumAttendanceType.Absent && item.InTime != null && item.OutTime != null)
// item.Benifits = new AttendanceProcess().CalculateDailyAttendanceAllowance(item);
// if(item.Benifits.Count >0)
// benifits.AddRange(item.Benifits);
//}
}
tc = TransactionContext.Begin(true);
this.Save(tc, oDAttnProcessess, attnMonthlyBenefit);
if (benifits.Count > 0)
new DailyAttendanceAllowanceService().Save(tc, benifits);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
private void Save(TransactionContext tc, List<DailyAttnProcess> oDAttnProcessess, List<AttnMonthlyBenefit> attnMonthlyBenefit)
{
try
{
if (oDAttnProcessess.Count == 1)
{
foreach (DailyAttnProcess item in oDAttnProcessess)
{
if (item.IsNew)
{
int id = tc.GenerateID("DailyAttnProcess", "DAILYATTNPROCESSID");
base.SetObjectID(item, id);
}
SaveWithSP(tc, item);
}
}
else
{
SaveBulk(tc, oDAttnProcessess);
}
// (new AttnMonthlyBenefitService()).Insert(attnMonthlyBenefit, tc);
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void ManualEditSave(List<DailyAttnProcess> oDAttnProcessess,
int payrolltypeid, int userid, List<DailyAttendanceAllowance> attnMonthlyBenefit)
{
TransactionContext tc = null;
try
{
//if(attnMonthlyBenefit == null)
//{
// AttendanceProcess attnPrc = new AttendanceProcess();
// attnMonthlyBenefit = new List<DailyAttendanceAllowance>();
// List<Shift> oshift = new ShiftService().GetAllShift();
// foreach (DailyAttnProcess item in oDAttnProcessess)
// {
// if (item.ShiftID == null) continue;
// item.Shift = oshift.FirstOrDefault(x => x.ID == item.ShiftID);
// List<DailyAttendanceAllowance> allowItems = attnPrc.CalculateDailyAttendanceAllowance(item, payrolltypeid, userid);
// if(allowItems.Count >0) attnMonthlyBenefit.AddRange(allowItems);
// }
//}
tc = TransactionContext.Begin(true);
foreach (DailyAttnProcess item in oDAttnProcessess)
{
DailyAttnProcessDA.ManualEditUpdate(tc, item);
}
//if (attnMonthlyBenefit.Count > 0)
// new DailyAttendanceAllowanceService().Save(tc, attnMonthlyBenefit);
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(List<DailyAttnProcess> oDAttnProcessess, List<AttnMonthlyBenefit> oAtnMonthlyBenifits,
// AttnProcessRunSummary oAttnRunSummary, int payrollTypeID)
//{
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin(true);
// int id = tc.GenerateID("DailyAttnProcess", "DailyAttnProcessID");
// 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));
// dAttnProcess.CreatedBy = 1;
// dAttnProcess.CreatedDate = DateTime.Now;
// DailyAttnProcessDA.Insert(tc, dAttnProcess);
// }
// (new AttnProcessRunSummaryService()).Insert(oAttnRunSummary, payrollTypeID, tc);
// (new AttnMonthlyBenefitService()).Insert(oAtnMonthlyBenifits, 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 SaveForBridgeHoliday(List<DailyAttnProcess> oDAttnProcessess, List<LeaveEntry> oLeaveEntrys)
//{
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin(true);
// int id = tc.GenerateID("DailyAttnProcess", "DailyAttnProcessID");
// foreach (DailyAttnProcess dAttnProcess in oDAttnProcessess)
// {
// if (dAttnProcess.IsNew)
// {
// base.SetObjectID(dAttnProcess, (id));
// DailyAttnProcessDA.Insert(tc, dAttnProcess);
// id++;
// }
// else
// {
// DailyAttnProcessDA.Update(tc, dAttnProcess);
// }
// }
// //(new LeaveEntryService()).SaveLeaveEntry(oLeaveEntrys, 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(int 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(int employeeID, int 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, int employeeID, int leaveID, int userid, DateTime fromDate,
DateTime toDate)
{
try
{
// if(fromDate < DateTime.Today)
DailyAttnProcessDA.UpdateLeave(tc, employeeID, leaveID, userid, fromDate, toDate);
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void UpdateLeaveAndReason(TransactionContext tc, int employeeID, int leaveID, int userid, DateTime fromDate,
DateTime toDate)
{
try
{
// if(fromDate < DateTime.Today)
DailyAttnProcessDA.UpdateLeaveClearReason(tc, employeeID, leaveID, userid, fromDate, toDate);
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void UndoLeave(TransactionContext tc, int employeeID, int userid, DateTime fromDate,
DateTime toDate)
{
try
{
if (fromDate < DateTime.Today)
DailyAttnProcessDA.UndoLeave(tc, employeeID, userid, fromDate, toDate);
}
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, int employeeID, int leaveID, DateTime leavaDate,
EnumAttendanceType attntype)
{
try
{
DailyAttnProcessDA.UpdateLeave(tc, employeeID, leaveID, leavaDate, attntype);
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void UndoAttendanceStatus(TransactionContext tc, int employeeID, DateTime attnDate,
EnumAttendanceType attntype)
{
try
{
DailyAttnProcessDA.UndoAttendanceStatus(tc, employeeID, attnDate, attntype);
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
internal void UpdateAttProcessedShift(TransactionContext tc, EmpLifeCycle oEmpLifeCycle, int currentPayrollTypeID)
{
try
{
DateTime dtAtt = GlobalFunctions.FirstDateOfMonth(oEmpLifeCycle.EffectDate.AddMonths(-2));
DailyAttnProcessDA.UpdateShiftID(tc, dtAtt, oEmpLifeCycle.EmployeeID, oEmpLifeCycle.PayrollTypeID, currentPayrollTypeID);
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
public void RejectAttnStatusByLM(int EmpID, DateTime attnDate, int linemanagerID, string remarks, string reason)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DailyAttnProcessDA.RejectAttnStatusByLM(tc, EmpID, attnDate, linemanagerID, remarks, reason);
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 ApproveAttnByLM(DailyAttnProcess item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DailyAttnProcessDA.ApproveAttnByLM(tc, item);
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 RegularizationRequestbyEmp(DailyAttnProcess item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DailyAttnProcessDA.RegularizationRequestbyEmp(tc, item);
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, string sEmpID)
{
DataSet monthlyAttn = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
monthlyAttn = DailyAttnProcessDA.GetMonthlyAttnSummary(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 GetDailyAttndanceBenefitDataFromVB(DateTime AttnDate)
{
DataSet oDailyBenefitDatas = new DataSet();
TransactionContext tc = null;
try
{
ConnectionContext connContext = new ConnectionContext("serviceHandler1");
tc = TransactionContext.Begin(true, connContext);
oDailyBenefitDatas = DailyAttnProcessDA.GetDailyAttndanceBenefitDataFromVB(tc, AttnDate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oDailyBenefitDatas;
}
public DataSet GetMonthlyAttndanceBenefitDataFromVB(int year, int month)
{
DataSet oDailyBenefitDatas = new DataSet();
TransactionContext tc = null;
try
{
ConnectionContext connContext = new ConnectionContext("serviceHandler1");
tc = TransactionContext.Begin(true, connContext);
oDailyBenefitDatas = DailyAttnProcessDA.GetMonthlyAttndanceBenefitDataFromVB(tc, year, month);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return oDailyBenefitDatas;
}
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 GetLMDailyAttnReport(DateTime attnDate, string sEmpID)
{
DataSet lmAttnReport = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
lmAttnReport = DailyAttnProcessDA.GetLMDailyAttnReport(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 lmAttnReport;
}
public DataSet GetTimeSheetAttnReport(DateTime fromDate, DateTime toDate, int sEmpID)
{
DataSet timeSheetAttnReport = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
timeSheetAttnReport = DailyAttnProcessDA.GetTimeSheetAttnReport(tc, fromDate, toDate, 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 timeSheetAttnReport;
}
public DataSet GetPersonalInfoForDailyAttnReport(int sEmpID)
{
DataSet lmAttnReport = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
lmAttnReport = DailyAttnProcessDA.GetPersonalInfoForDailyAttnReport(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 lmAttnReport;
}
public DataSet GetPersonalInfoForTimeSheet(int sEmpID)
{
DataSet prsnlData = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
prsnlData = DailyAttnProcessDA.GetPersonalInfoForTimeSheet(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 prsnlData;
}
public DataSet GetDailyInOut(DateTime fromDate, DateTime toDate, string sEmpID)
{
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetDailyInOut(tc, fromDate, toDate, 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 sEmpID, params EnumAttendanceType[] eStatus)
{
DataSet dailyInOut = null;
string sStatus = string.Empty;
sStatus = eStatus.Aggregate(new StringBuilder(),
(sb, el) => sb.Append(((int)el).ToString() + ","),
sb => sb.ToString().Trim(','));
try
{
dailyInOut = this.GetDailyDataByStatus(attnDate, sStatus, sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
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 List<DailyAttnByStatusReport> GetDailyDataByStatusReport(DateTime attnDate, string sStatus, string sEmpID)
{
List<DailyAttnByStatusReport> dailyAttnReports = new List<DailyAttnByStatusReport>();
DailyAttnByStatusReport dailyAttnByStatusReport = null;
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetDailyDataByStatus(tc, attnDate, sStatus, sEmpID);
tc.End();
if (dailyInOut.Tables[0].Rows.Count > 0)
{
foreach (DataRow Dr in dailyInOut.Tables[0].Rows)
{
dailyAttnByStatusReport = new DailyAttnByStatusReport();
dailyAttnByStatusReport.AttendanceDate = Convert.ToDateTime(Dr["attndate"]).ToString("dd MMM yyyy");
dailyAttnByStatusReport.EmployeeNo = Dr["EMPLOYEENO"].ToString();
dailyAttnByStatusReport.EmpName = Dr["Name"].ToString();
dailyAttnByStatusReport.Designation = Dr["Designation"].ToString();
dailyAttnByStatusReport.InTime = Dr["InTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm");
dailyAttnByStatusReport.OutTime = Dr["OutTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm");
dailyAttnByStatusReport.Status = GlobalFunctions.GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); //((EnumAttendanceType)Convert.ToInt32(Dr["Status"])).GetShortAttnType();
dailyAttnByStatusReport.StatusFull = GlobalFunctions.GetFullAttnType(((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))));
dailyAttnByStatusReport.OTHour = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
dailyAttnByStatusReport.Department = Dr["DeptName"].ToString();
dailyAttnByStatusReport.Shift = Dr["Shift"].ToString();
dailyAttnReports.Add(dailyAttnByStatusReport);
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnReports;
}
public DataSet GetDailyDataByStatusDateset(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 List<DailyAttnByStatusReport> GetDataByStatusReport(DateTime fromDate, DateTime toDate, string sStatus, string sEmpID)
{
List<DailyAttnByStatusReport> dailyAttnReports = new List<DailyAttnByStatusReport>();
DailyAttnByStatusReport dailyAttnByStatusReport = null;
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetDataByStatus(tc, fromDate, toDate, sStatus, sEmpID);
tc.End();
if (dailyInOut.Tables[0].Rows.Count > 0)
{
foreach (DataRow Dr in dailyInOut.Tables[0].Rows)
{
dailyAttnByStatusReport = new DailyAttnByStatusReport();
dailyAttnByStatusReport.AttendanceDate = Convert.ToDateTime(Dr["attndate"]).ToString("dd MMM yyyy");
dailyAttnByStatusReport.EmployeeNo = Dr["EMPLOYEENO"].ToString();
dailyAttnByStatusReport.EmpName = Dr["Name"].ToString();
dailyAttnByStatusReport.Designation = Dr["Designation"].ToString();
dailyAttnByStatusReport.InTime = Dr["InTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm");
dailyAttnByStatusReport.OutTime = Dr["OutTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm");
dailyAttnByStatusReport.Status = GlobalFunctions.GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); //((EnumAttendanceType)Convert.ToInt32(Dr["Status"])).GetShortAttnType();
dailyAttnByStatusReport.StatusFull = GlobalFunctions.GetFullAttnType(((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))));
dailyAttnByStatusReport.OTHour = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
dailyAttnByStatusReport.Department = Dr["DeptName"].ToString();
dailyAttnByStatusReport.Shift = Dr["Shift"].ToString();
dailyAttnReports.Add(dailyAttnByStatusReport);
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnReports;
}
public List<DailyAttnByStatusReport> GetDateRangeWiseDataByStatusReport(DateTime fromDate, DateTime toDate, string sStatus, string sEmpID)
{
List<DailyAttnByStatusReport> dailyAttnReports = new List<DailyAttnByStatusReport>();
DailyAttnByStatusReport dailyAttnByStatusReport = null;
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetDateRangeWiseDataByStatusReport(tc, fromDate, toDate, sStatus, sEmpID);
tc.End();
if (dailyInOut.Tables[0].Rows.Count > 0)
{
foreach (DataRow Dr in dailyInOut.Tables[0].Rows)
{
dailyAttnByStatusReport = new DailyAttnByStatusReport();
dailyAttnByStatusReport.AttendanceDate = Convert.ToDateTime(Dr["attndate"]).ToString("dd MMM yyyy");
dailyAttnByStatusReport.EmployeeNo = Dr["EMPLOYEENO"].ToString();
dailyAttnByStatusReport.EmpName = Dr["Name"].ToString();
dailyAttnByStatusReport.Designation = Dr["Designation"].ToString();
dailyAttnByStatusReport.InTime = Dr["InTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm");
dailyAttnByStatusReport.OutTime = Dr["OutTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm");
dailyAttnByStatusReport.Status = GlobalFunctions.GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); //((EnumAttendanceType)Convert.ToInt32(Dr["Status"])).GetShortAttnType();
dailyAttnByStatusReport.StatusFull = GlobalFunctions.GetFullAttnType(((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))));
dailyAttnByStatusReport.OTHour = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
dailyAttnByStatusReport.Department = Dr["DeptName"].ToString();
dailyAttnByStatusReport.Shift = Dr["Shift"].ToString();
dailyAttnReports.Add(dailyAttnByStatusReport);
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnReports;
}
public List<DailyAttnByStatusReport> GetDailyOddDataByStatusReport(DateTime attnDate, string sEmpID)
{
List<DailyAttnByStatusReport> dailyAttnReports = new List<DailyAttnByStatusReport>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataSet dailyInOut = DailyAttnProcessDA.GetDailyOddDataByStatusReport(tc, attnDate, sEmpID);
tc.End();
if (dailyInOut.Tables[0].Rows.Count > 0)
{
foreach (DataRow Dr in dailyInOut.Tables[0].Rows)
{
DailyAttnByStatusReport dailyAttnByStatusReport = new DailyAttnByStatusReport();
dailyAttnByStatusReport.AttendanceDate = Convert.ToDateTime(Dr["attndate"]).ToString("dd MMM yyyy");
dailyAttnByStatusReport.EmployeeNo = Dr["EMPLOYEENO"].ToString();
dailyAttnByStatusReport.EmpName = Dr["Name"].ToString();
dailyAttnByStatusReport.Designation = Dr["Designation"].ToString();
//dailyAttnByStatusReport.InTime = Dr["InTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm");
//dailyAttnByStatusReport.OutTime = Dr["OutTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm");
dailyAttnByStatusReport.InTime = Dr["InTime"] is DBNull ? "" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm");
dailyAttnByStatusReport.OutTime = Dr["OutTime"] is DBNull ? "" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm");
dailyAttnByStatusReport.Status = GlobalFunctions.GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); //((EnumAttendanceType)Convert.ToInt32(Dr["Status"])).GetShortAttnType();
dailyAttnByStatusReport.StatusFull = GlobalFunctions.GetFullAttnType(((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))));
dailyAttnByStatusReport.OTHour = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
dailyAttnByStatusReport.Department = Dr["DeptName"].ToString();
dailyAttnByStatusReport.Shift = Dr["Shift"].ToString();
dailyAttnReports.Add(dailyAttnByStatusReport);
}
}
//dailyAttnReports = dailyAttnReports.Where(o => (o.InTime != "00:00" || o.OutTime != "00:00")).ToList();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnReports;
}
public DataSet GetDailyOddDataByStatusReportDataset(DateTime attnDate, string sEmpID)
{
DataSet dailyInOut = null;
List<DailyAttnByStatusReport> dailyAttnReports = new List<DailyAttnByStatusReport>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetDailyOddDataByStatusReport(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 List<DailyAttnByStatusReport> GetDateWiseAttnRecords(DateTime attnDate, string sEmpID)
{
List<DailyAttnByStatusReport> dailyAttnReports = new List<DailyAttnByStatusReport>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataSet dailyInOut = DailyAttnProcessDA.GetDateWiseAttnRecords(tc, attnDate, sEmpID);
tc.End();
if (dailyInOut.Tables[0].Rows.Count > 0)
{
foreach (DataRow Dr in dailyInOut.Tables[0].Rows)
{
DailyAttnByStatusReport dailyAttnByStatusReport = new DailyAttnByStatusReport();
dailyAttnByStatusReport.AttendanceDate = Convert.ToDateTime(Dr["attndate"]).ToString("dd MMM yyyy");
dailyAttnByStatusReport.EmployeeNo = Dr["EMPLOYEENO"].ToString();
dailyAttnByStatusReport.EmpName = Dr["Name"].ToString();
dailyAttnByStatusReport.Designation = Dr["Designation"].ToString();
dailyAttnByStatusReport.InTime = Dr["InTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm");
dailyAttnByStatusReport.OutTime = Dr["OutTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm");
dailyAttnByStatusReport.Time = dailyAttnByStatusReport.InTime + " " + dailyAttnByStatusReport.OutTime;
dailyAttnByStatusReport.Status = GlobalFunctions.GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); //((EnumAttendanceType)Convert.ToInt32(Dr["Status"])).GetShortAttnType();
dailyAttnByStatusReport.StatusFull = GlobalFunctions.GetFullAttnType(((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))));
dailyAttnByStatusReport.OTHour = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
dailyAttnByStatusReport.Department = Dr["DeptName"].ToString();
dailyAttnByStatusReport.Shift = Dr["Shift"].ToString();
dailyAttnReports.Add(dailyAttnByStatusReport);
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnReports;
}
public DataSet GetZandDocLeaveDays(DateTime fromDate, DateTime toDate, int payrollTypeID)
{
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetZandDocLeave(tc, fromDate, toDate, payrollTypeID);
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 GetUnauthorizeCount(DateTime fromDate, DateTime toDate, int payrollTypeId)
{
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetUnauthorizeCount(tc, fromDate, toDate, payrollTypeId);
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 GetZandDocLeaveDays(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeId, int? refID)
{
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetZandDocLeave(tc, fromDate, toDate, attnType, payrollTypeId, refID);
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 double GetStatusCount(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeId, int empid, int? refID)
{
double dailyInOut = 0;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetStatusCount(tc, fromDate, toDate, attnType, payrollTypeId, empid, refID);
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 fromDate, DateTime toDate, string sStatus, string sEmpID)
{
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetDailyDataByStatus(tc, fromDate, toDate, 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 fromDate, DateTime toDate, string sEmpID, EnumAttendanceType status,
int payrollTypeID)
{
DataSet dailyAbsent = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyAbsent = DailyAttnProcessDA.GetDailyAbsent(tc, fromDate, toDate, sEmpID, status, payrollTypeID);
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 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 AttnDaysSummaryForSalaryProcess(DateTime FromDate, DateTime ToDate)
{
DataSet attnDaysSummary = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
attnDaysSummary = DailyAttnProcessDA.AttnDaysSummaryForSalaryProcess(tc, FromDate, ToDate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return attnDaysSummary;
}
public DataSet GetHolidays(DateTime attnDate, int 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 int GetAttnDataByWFStatusCount(string empID, EnumWFAttnStatus status)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
return DailyAttnProcessDA.GetAttnDataByWFStatusCount(tc, empID, status);
}
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();
}
}
}
public List<DailyAttnProcess> GetAttnDataByWFStatus(string empID, EnumWFAttnStatus status)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetAttnDataByWFStatus(tc, empID, status));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> getMyNotSubmittedAbsentList(int employeeid)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(DailyAttnProcessDA.getMyNotSubmittedAbsentList(tc, employeeid));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> GetAttnDataByWFStatus(DateTime fromDate, DateTime toDate, string empID,
EnumWFAttnStatus status)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(DailyAttnProcessDA.GetAttnDataByWFStatus(tc, fromDate, toDate, empID, status));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> GetAttnSubmittedData(string sEmpID, DateTime fromDate, DateTime toDate)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetAttnSubmittedData(tc, sEmpID, fromDate, toDate));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> GetAttnSubmittedData(string sEmpID, bool isCurrentMonth,
DateTime NextPayProcessDate)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr =
new DataReader(
DailyAttnProcessDA.GetAttnSubmittedData(tc, sEmpID, isCurrentMonth, NextPayProcessDate));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public DataSet GetAttnApprovedData(string sEmpIDs, EnumWFAttnStatus status, DateTime fromDate, DateTime toDate)
{
DataSet dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.GetAttnApprovedData(tc, sEmpIDs, status, fromDate, toDate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataSet GetMonthlyOverTime(DateTime fromDate, DateTime toDate, EnumWorkPlanDayType wdType)
{
DataSet dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.GetMonthlyOverTime(tc, fromDate, toDate, wdType);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataSet GetAttnSubmittedData(string sEmpIDs, EnumWFAttnStatus status, bool isCurrentMonth,
DateTime NextPayProcessDate)
{
DataSet dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.GetAttnSubmittedData(tc, sEmpIDs, status, isCurrentMonth, NextPayProcessDate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataTable GetPendingJobDetail(int ID)
{
DataSet oSet;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oSet = DailyAttnProcessDA.GetPendingJobDetail(tc, ID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to Get Detail" + e.Message, e);
#endregion
}
return oSet.Tables[0];
}
public DataSet GetAttnSubmittedData(string sEmpIDs, EnumWFAttnStatus status, DateTime fromDate, DateTime toDate)
{
DataSet dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.GetAttnSubmittedData(tc, sEmpIDs, status, fromDate, toDate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataSet GetPresentDays(DateTime attnDate, int 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 void UpdateLateAttnBenefitStatus(List<DailyAttnProcess> daProcess)
//{
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin();
// foreach (DailyAttnProcess item in daProcess)
// {
// DailyAttnProcessDA.UpdateLateAttnBenefitStatus(tc, item);
// }
// tc.End();
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException(e.Message, e);
// #endregion
// }
//}
public List<DailyAttnProcess> GetByStatus(int empID, DateTime fromDate, DateTime toDate, string status)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetByStatus(tc, empID, fromDate, toDate, status));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<DailyAttnProcess> Get(string empID, DateTime fromDate, DateTime toDate, EnumClaimWFStatus status)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.Get(tc, empID, fromDate, toDate, status));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public DataTable GetAttnData(int employeeID, DateTime fromdate, DateTime toDate)
{
DataTable attnDataDT = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
attnDataDT = DailyAttnProcessDA.GetAttnData(tc, employeeID, fromdate, toDate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return attnDataDT;
}
public DataTable GetAttnData(int employeeID, DateTime fromdate, DateTime toDate, string status)
{
DataTable attnDataDT = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
attnDataDT = DailyAttnProcessDA.GetAttnData(tc, employeeID, fromdate, toDate, status);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return attnDataDT;
}
public DataTable GetTeamMembersAttnData(string sEmpID, DateTime fromdate, DateTime toDate,
EnumClaimWFStatus status)
{
DataTable attnDataDT = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
attnDataDT = DailyAttnProcessDA.GetTeamMembersAttnData(tc, sEmpID, fromdate, toDate, status);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return attnDataDT;
}
public DataTable GetTeamMembersAttnData(int employeeID, DateTime fromdate, DateTime toDate,
EnumClaimWFStatus status)
{
DataTable attnDataDT = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
attnDataDT = DailyAttnProcessDA.GetTeamMembersAttnData(tc, employeeID, fromdate, toDate, status);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return attnDataDT;
}
public List<DailyAttnProcess> GetBySalaryMonth(DateTime salaryMonth, int payrollTypeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetBySalaryMonth(tc, salaryMonth, payrollTypeID));
var dailyAttnProcesses = this.CreateObjects<DailyAttnProcess>(dr);
dr.Close();
tc.End();
return dailyAttnProcesses;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public DateTime GetLastProcessDateUsingPayrollType(int PayrolltypeID)
{
DateTime lastProcessDate = DateTime.MinValue;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(DailyAttnProcessDA.GetLastProcessDate(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;
}
public DateTime GetLastProcessDate(int employeeID)
{
DateTime lastProcessDate = DateTime.MinValue;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(DailyAttnProcessDA.GetLastProcessDate(tc, employeeID));
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 List<DailyAttnProcess> GetAttnSubmittedData(string sEmpID, bool isCurrentMonth)
{
throw new NotImplementedException();
}
public List<DailyAttnProcess> GetManualProcess(DateTime attnDate)
{
throw new NotImplementedException();
}
public List<DailyAttnProcess> Get(DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
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
}
return dailyAttnProcesses;
//return new List<DailyAttnProcess>();
}
/// <summary>
///
/// </summary>
/// <param name="fromDate"></param>
/// <param name="toDate"></param>
/// <returns></returns>
public List<DailyAttnProcess> GetshotList(DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oReader = new DataReader(DailyAttnProcessDA.GetshotList(tc, fromDate, toDate));
while (oReader.Read())
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
base.SetObjectID(oDailyAttnProcess, (oReader.GetInt32("DailyAttnProcessID").Value));
oDailyAttnProcess.EmployeeID = oReader.GetInt32("EmployeeID").Value;
oDailyAttnProcess.AttnDate = oReader.GetDateTime("AttnDate").Value;
oDailyAttnProcess.ShiftID = oReader.GetInt32("ShiftID");
oDailyAttnProcess.InTime = oReader.GetDateTime("InTime");
oDailyAttnProcess.OutTime = oReader.GetDateTime("OutTime");
oDailyAttnProcess.WorkDayType = (EnumWorkPlanDayType)oReader.GetInt32("WorkDayType").Value;
oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttenType").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.WorkHour = oReader.GetDouble("WorkHour").HasValue ? oReader.GetDouble("WorkHour").Value : 0;
oDailyAttnProcess.OTHour = oReader.GetDouble("OTHour").HasValue ? oReader.GetDouble("OTHour").Value : 0;
this.SetObjectState(oDailyAttnProcess, Ease.Core.ObjectState.Saved);
dailyAttnProcesses.Add(oDailyAttnProcess);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnProcesses;
//return new List<DailyAttnProcess>();
}
public List<DailyAttnProcess> GetshotList(DateTime fromDate, DateTime toDate, int empid)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oReader = new DataReader(DailyAttnProcessDA.GetshotList(tc, fromDate, toDate, empid));
while (oReader.Read())
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
base.SetObjectID(oDailyAttnProcess, (oReader.GetInt32("DailyAttnProcessID").Value));
oDailyAttnProcess.EmployeeID = oReader.GetInt32("EmployeeID").Value;
oDailyAttnProcess.AttnDate = oReader.GetDateTime("AttnDate").Value;
oDailyAttnProcess.ShiftID = oReader.GetInt32("ShiftID");
oDailyAttnProcess.InTime = oReader.GetDateTime("InTime");
oDailyAttnProcess.OutTime = oReader.GetDateTime("OutTime");
oDailyAttnProcess.WorkDayType = (EnumWorkPlanDayType)oReader.GetInt32("WorkDayType").Value;
oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttenType").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.WorkHour = oReader.GetDouble("WorkHour").HasValue ? oReader.GetDouble("WorkHour").Value : 0;
oDailyAttnProcess.OTHour = oReader.GetDouble("OTHour").HasValue ? oReader.GetDouble("OTHour").Value : 0;
this.SetObjectState(oDailyAttnProcess, Ease.Core.ObjectState.Saved);
dailyAttnProcesses.Add(oDailyAttnProcess);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnProcesses;
//return new List<DailyAttnProcess>();
}
public List<DailyAttnProcess> GetshotList(DateTime attnDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oReader = new DataReader(DailyAttnProcessDA.GetshotList(tc, attnDate));
while (oReader.Read())
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
base.SetObjectID(oDailyAttnProcess, (oReader.GetInt32("DailyAttnProcessID").Value));
oDailyAttnProcess.EmployeeID = oReader.GetInt32("EmployeeID").Value;
oDailyAttnProcess.AttnDate = oReader.GetDateTime("AttnDate").Value;
oDailyAttnProcess.ShiftID = oReader.GetInt32("ShiftID");
oDailyAttnProcess.InTime = oReader.GetDateTime("InTime");
oDailyAttnProcess.OutTime = oReader.GetDateTime("OutTime");
oDailyAttnProcess.WorkDayType = (EnumWorkPlanDayType)oReader.GetInt32("WorkDayType").Value;
oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttenType").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.WorkHour = oReader.GetDouble("WorkHour").HasValue ? oReader.GetDouble("WorkHour").Value : 0;
oDailyAttnProcess.OTHour = oReader.GetDouble("OTHour").HasValue ? oReader.GetDouble("OTHour").Value : 0;
this.SetObjectState(oDailyAttnProcess, Ease.Core.ObjectState.Saved);
dailyAttnProcesses.Add(oDailyAttnProcess);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnProcesses;
//return new List<DailyAttnProcess>();
}
public List<DailyAttnProcess> GetshotListForProdBonus(string prodbonussetupids, DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oReader = new DataReader(DailyAttnProcessDA.GetshotListForProdBonus(tc, prodbonussetupids, fromDate, toDate));
while (oReader.Read())
{
DailyAttnProcess oDailyAttnProcess = new DailyAttnProcess();
base.SetObjectID(oDailyAttnProcess, (oReader.GetInt32("DailyAttnProcessID").Value));
oDailyAttnProcess.EmployeeID = oReader.GetInt32("EmployeeID").Value;
oDailyAttnProcess.AttnDate = oReader.GetDateTime("AttnDate").Value;
oDailyAttnProcess.ShiftID = oReader.GetInt32("ShiftID");
oDailyAttnProcess.InTime = oReader.GetDateTime("InTime");
oDailyAttnProcess.OutTime = oReader.GetDateTime("OutTime");
oDailyAttnProcess.WorkDayType = (EnumWorkPlanDayType)oReader.GetInt32("WorkDayType").Value;
oDailyAttnProcess.AttenType = (EnumAttendanceType)oReader.GetInt32("AttenType").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.WorkHour = oReader.GetDouble("WorkHour").HasValue ? oReader.GetDouble("WorkHour").Value : 0;
//oDailyAttnProcess.OTHour = oReader.GetDouble("OTHour").HasValue ? oReader.GetDouble("OTHour").Value : 0;
this.SetObjectState(oDailyAttnProcess, Ease.Core.ObjectState.Saved);
dailyAttnProcesses.Add(oDailyAttnProcess);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dailyAttnProcesses;
//return new List<DailyAttnProcess>();
}
public List<DailyAttnProcess> GetByEmployeeID(int employeeID, DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetByEmployeeID(tc, employeeID, 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
}
return dailyAttnProcesses;
//return new List<DailyAttnProcess>();
}
public List<DailyAttnProcess> GetAttnByEmployeeID(int employeeID, DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetAttnByEmployeeID(tc, employeeID, 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
}
return dailyAttnProcesses;
//return new List<DailyAttnProcess>();
}
public DateTime GetLastProcessDate()
{
throw new NotImplementedException();
}
public void SaveAuto(List<DailyAttnProcess> dailyattProcesses, List<AttnMonthlyBenefit> oAtnMonthlyBenifits,
AttnProcessRunSummary oAttnRunSummary)
{
throw new NotImplementedException();
}
public void SaveAutoForLmApproved(List<DailyAttnProcess> dailyattProcesses,
List<AttnMonthlyBenefit> oAtnMonthlyBenifits, AttnProcessRunSummary oAttnRunSummary)
{
throw new NotImplementedException();
}
public DateTime GetLastProcessDateByEmpId(int employeeID)
{
throw new NotImplementedException();
}
public int GetAttnDataByWFStatusCountForMobile(int empID, EnumWFAttnStatus status)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
return DailyAttnProcessDA.GetAttnDataByWFStatusCountForMobile(tc, empID, status);
}
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();
}
}
}
private static void SaveWithSP(TransactionContext tc, DailyAttnProcess item)
{
List<SqlParameter> p = new List<SqlParameter>
{
SqlHelperExtension.CreateInParam("@DAILYATTNPROCESSID", SqlDbType.Int, item.ID),
SqlHelperExtension.CreateInParam("@EmployeeID", SqlDbType.Int, item.EmployeeID),
SqlHelperExtension.CreateInParam("@AttnDate", SqlDbType.DateTime, item.AttnDate),
SqlHelperExtension.CreateInParam("@ShiftID", SqlDbType.Int, item.ShiftID),
SqlHelperExtension.CreateInParam("@WorkDayType", SqlDbType.Int, (int)item.WorkDayType),
SqlHelperExtension.CreateInParam("@AttenType", SqlDbType.Int, (int)item.AttenType),
SqlHelperExtension.CreateInParam("@Comments", SqlDbType.Text, item.Comments),
SqlHelperExtension.CreateInParam("@Reason", SqlDbType.Text, item.Reason),
SqlHelperExtension.CreateInParam("@IsManualEntry", SqlDbType.Bit, item.IsManualEntry),
SqlHelperExtension.CreateInParam("@IsLate", SqlDbType.Bit, item.IsLate),
SqlHelperExtension.CreateInParam("@LateHour", SqlDbType.Decimal, item.LateHour),
SqlHelperExtension.CreateInParam("@EarlyHour", SqlDbType.Decimal, item.EarlyHour),
SqlHelperExtension.CreateInParam("@OTHour", SqlDbType.Decimal, item.OTHour),
SqlHelperExtension.CreateInParam("@CREATEDBY", SqlDbType.Int, item.CreatedBy),
SqlHelperExtension.CreateInParam("@CREATEDDATE", SqlDbType.DateTime, item.CreatedDate),
SqlHelperExtension.CreateInParam("@OtRemarks", SqlDbType.Text, item.OtRemarks),
SqlHelperExtension.CreateInParam("@WFStatus", SqlDbType.Int, (int)item.WFStatus),
SqlHelperExtension.CreateInParam("@ApprovedOTHOUR", SqlDbType.Money, item.ApprovedOTHour),
SqlHelperExtension.CreateInParam("@LMRemarks", SqlDbType.Text, item.LMRemarks),
SqlHelperExtension.CreateInParam("@IsFromMobile", SqlDbType.Int, (int)item.IsFromMobile),
//SqlHelperExtension.CreateInParam("@IsFromMobile", SqlDbType.Int, item.MobileCheckInOutStatus),
SqlHelperExtension.CreateInParam("@ReferenceID", SqlDbType.Int, item.ReferenceID),
SqlHelperExtension.CreateInParam("@actualShiftID", SqlDbType.Int, item.ActualShiftID ),
SqlHelperExtension.CreateInParam("@Empremarks", SqlDbType.Text, item.EmpRemarks ),
SqlHelperExtension.CreateInParam("@LineManagerID", SqlDbType.Int, item.LineManagerID),
SqlHelperExtension.CreateInParam("@OnbehalfEmpID", SqlDbType.Int, item.OnbehalfEmpID),
SqlHelperExtension.CreateInParam("@WorkHour", SqlDbType.Decimal, item.WorkHour ),
SqlHelperExtension.CreateInParam("@InTimeNearestAddress", SqlDbType.Text, item.InTimeNearestAddress ),
SqlHelperExtension.CreateInParam("@OutTimeNearestAddress", SqlDbType.Text, item.OutTimeNearestAddress ),
SqlHelperExtension.CreateInParam("@InTimeLatitude", SqlDbType.Text, item.InTimeLatitude.ToString()),
SqlHelperExtension.CreateInParam("@OutTimeLatitude", SqlDbType.Text, item.OutTimeLatitude.ToString() ),
SqlHelperExtension.CreateInParam("@InTimeLongitude", SqlDbType.Text, item.InTimeLongitude.ToString() ),
SqlHelperExtension.CreateInParam("@outTimeLongitude", SqlDbType.Text, item.OutTimeLongitude.ToString() )
};
if (item.LMApproveDate != null)
{
p.Add(SqlHelperExtension.CreateInParam("@LMApproveDate", SqlDbType.DateTime, item.LMApproveDate));
}
else
{
p.Add(SqlHelperExtension.CreateInParam("@LMApproveDate", SqlDbType.DateTime, DBNull.Value));
}
if (item.EmpApplyDate != null)
{
p.Add(SqlHelperExtension.CreateInParam("@EmpApplyDate", SqlDbType.DateTime, item.EmpApplyDate));
}
else
{
p.Add(SqlHelperExtension.CreateInParam("@EmpApplyDate", SqlDbType.DateTime, DBNull.Value));
}
if (item.InTime != null && item.InTime != DateTime.MinValue)
{
p.Add(SqlHelperExtension.CreateInParam("@InTime", SqlDbType.DateTime, item.InTime));
}
else
{
p.Add(SqlHelperExtension.CreateInParam("@InTime", SqlDbType.DateTime, DBNull.Value));
}
if (item.OutTime != null && item.OutTime != DateTime.MinValue)
{
p.Add(SqlHelperExtension.CreateInParam("@OutTime", SqlDbType.DateTime, item.OutTime));
}
else
{
p.Add(SqlHelperExtension.CreateInParam("@OutTime", SqlDbType.DateTime, DBNull.Value));
}
if (item.ActualInTime != null && item.ActualInTime != DateTime.MinValue)
{
p.Add(SqlHelperExtension.CreateInParam("@ActualInTime", SqlDbType.DateTime, item.ActualInTime));
}
else
{
p.Add(SqlHelperExtension.CreateInParam("@ActualInTime", SqlDbType.DateTime, DBNull.Value));
}
if (item.ActualOutTime != null && item.ActualOutTime != DateTime.MinValue)
{
p.Add(SqlHelperExtension.CreateInParam("@ActualOutTime", SqlDbType.DateTime, item.ActualOutTime));
}
else
{
p.Add(SqlHelperExtension.CreateInParam("@ActualOutTime", SqlDbType.DateTime, DBNull.Value));
}
if (item.ModifiedBy != null)
{
p.Add(SqlHelperExtension.CreateInParam("@ModifiedBy", SqlDbType.Int, item.ModifiedBy));
}
else
{
p.Add(SqlHelperExtension.CreateInParam("@ModifiedBy", SqlDbType.Int, DBNull.Value));
}
if (item.ModifiedDate != null)
{
p.Add(SqlHelperExtension.CreateInParam("@ModifiedDate", SqlDbType.DateTime, item.ModifiedDate));
}
else
{
p.Add(SqlHelperExtension.CreateInParam("@ModifiedDate", SqlDbType.DateTime, DBNull.Value));
}
tc.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Insert_DailyAttnProcess", p.ToArray());
}
public void SaveBulk(TransactionContext tc, List<DailyAttnProcess> oDAttnProcessess)
{
try
{
if (oDAttnProcessess.Count > 0)
{
string commaSeparatedEmployeeIDs = oDAttnProcessess.Aggregate(new StringBuilder(), (acc, x) => acc.Append(x.EmployeeID + ","),
acc => acc.ToString().Trim(','));
DailyAttnProcessDA.Delete(tc, commaSeparatedEmployeeIDs, oDAttnProcessess[0].AttnDate);
int id = tc.GenerateID("DailyAttnProcess", "DailyAttnProcessID");
DataTable attnProcessEntryTable = new DataTable("DailyAttnProcess");
attnProcessEntryTable.Columns.Add(new DataColumn("DAILYATTNPROCESSID", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("EMPLOYEEID", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("ATTNDATE", typeof(DateTime)));
attnProcessEntryTable.Columns.Add(new DataColumn("SHIFTID", typeof(int))); // NULL
attnProcessEntryTable.Columns.Add(new DataColumn("INTIME", typeof(DateTime))); // NULL
attnProcessEntryTable.Columns.Add(new DataColumn("OUTTIME", typeof(DateTime))); // NULL
attnProcessEntryTable.Columns.Add(new DataColumn("ATTENTYPE", typeof(int)));
//attnProcessEntryTable.Columns.Add(new DataColumn("AttnType", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("COMMENTS", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("ISMANUALENTRY", typeof(bool)));
attnProcessEntryTable.Columns.Add(new DataColumn("ISFROMMOBILE", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("LATEHOUR", typeof(double))); // NULL
attnProcessEntryTable.Columns.Add(new DataColumn("EARLYHOUR", typeof(double))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("OTHOUR", typeof(double))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("REFERENCEID", typeof(int))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("WORKDAYTYPE", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("REASON", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("ISLATE", typeof(bool)));
attnProcessEntryTable.Columns.Add(new DataColumn("OTREMARKS", typeof(string))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("WFSTATUS", typeof(int))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("APPROVEDOTHOUR", typeof(double))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("LMREMARKS", typeof(string))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("ACTUALINTIME", typeof(DateTime))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("ACTUALOUTTIME", typeof(DateTime))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("ACTUALSHIFTID", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("EMPREMARKS", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("EMPAPPLYDATE", typeof(DateTime)));
attnProcessEntryTable.Columns.Add(new DataColumn("LMAPPROVEDATE", typeof(DateTime)));
attnProcessEntryTable.Columns.Add(new DataColumn("LINEMANAGERID", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("ONBEHALFEMPID", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("WORKHOUR", typeof(double)));
attnProcessEntryTable.Columns.Add(new DataColumn("INTIMENEARESTADDRESS", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("OUTTIMENEARESTADDRESS", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("INTIMELATITUDE", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("OUTTIMELATITUDE", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("INTIMELONGITUDE", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("OUTTIMELONGITUDE", typeof(string)));
attnProcessEntryTable.Columns.Add(new DataColumn("CREATEDBY", typeof(int)));
attnProcessEntryTable.Columns.Add(new DataColumn("CREATEDDATE", typeof(DateTime)));
attnProcessEntryTable.Columns.Add(new DataColumn("MODIFIEDBY", typeof(int))); // NULL,
attnProcessEntryTable.Columns.Add(new DataColumn("MODIFIEDDATE", typeof(DateTime))); // NULL,
foreach (DailyAttnProcess dAttnProcess in oDAttnProcessess)
{
attnProcessEntryTable.Rows.Add(
id++,
dAttnProcess.EmployeeID,
dAttnProcess.AttnDate,
dAttnProcess.ShiftID,
dAttnProcess.InTime,
dAttnProcess.OutTime,
dAttnProcess.AttenType,
dAttnProcess.Comments,
dAttnProcess.IsManualEntry,
dAttnProcess.IsFromMobile,
dAttnProcess.LateHour,
dAttnProcess.EarlyHour,
dAttnProcess.OTHour,
dAttnProcess.ReferenceID,
dAttnProcess.WorkDayType,
dAttnProcess.Reason,
dAttnProcess.IsLate,
dAttnProcess.OtRemarks == string.Empty ? null : dAttnProcess.OtRemarks,
dAttnProcess.WFStatus,
dAttnProcess.ApprovedOTHour,
dAttnProcess.LMRemarks == string.Empty ? null : dAttnProcess.LMRemarks,
dAttnProcess.ActualInTime,
dAttnProcess.ActualOutTime,
dAttnProcess.ActualShiftID,
dAttnProcess.EmpRemarks == string.Empty ? null : dAttnProcess.EmpRemarks,
dAttnProcess.EmpApplyDate,
dAttnProcess.LMApproveDate,
dAttnProcess.LineManagerID,
dAttnProcess.OnbehalfEmpID,
dAttnProcess.WorkHour,
dAttnProcess.InTimeNearestAddress == string.Empty ? null : dAttnProcess.InTimeNearestAddress,
dAttnProcess.OutTimeNearestAddress == string.Empty ? null : dAttnProcess.OutTimeNearestAddress,
dAttnProcess.InTimeLatitude.ToString(),
dAttnProcess.OutTimeLatitude.ToString(),
dAttnProcess.InTimeLongitude.ToString(),
dAttnProcess.OutTimeLongitude.ToString(),
dAttnProcess.CreatedBy,
dAttnProcess.CreatedDate,
dAttnProcess.ModifiedBy,
dAttnProcess.ModifiedDate
);
}
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)tc.Transaction))
{
bulkCopy.BulkCopyTimeout = 6000; // in seconds
bulkCopy.ColumnMappings.Add("DAILYATTNPROCESSID", "DAILYATTNPROCESSID");
bulkCopy.ColumnMappings.Add("EMPLOYEEID", "EMPLOYEEID");
bulkCopy.ColumnMappings.Add("ATTNDATE", "ATTNDATE");
bulkCopy.ColumnMappings.Add("SHIFTID", "SHIFTID"); // NULL
bulkCopy.ColumnMappings.Add("INTIME", "INTIME"); // NULL
bulkCopy.ColumnMappings.Add("OUTTIME", "OUTTIME"); // NULL
bulkCopy.ColumnMappings.Add("ATTENTYPE", "ATTENTYPE");
//bulkCopy.ColumnMappings.Add("AttnType", typeof(int)));
bulkCopy.ColumnMappings.Add("COMMENTS", "COMMENTS");
bulkCopy.ColumnMappings.Add("ISMANUALENTRY", "ISMANUALENTRY");
bulkCopy.ColumnMappings.Add("ISFROMMOBILE", "ISFROMMOBILE");
bulkCopy.ColumnMappings.Add("LATEHOUR", "LATEHOUR"); // NULL
bulkCopy.ColumnMappings.Add("EARLYHOUR", "EARLYHOUR"); // NULL,
bulkCopy.ColumnMappings.Add("OTHOUR", "OTHOUR"); // NULL
bulkCopy.ColumnMappings.Add("REFERENCEID", "REFERENCEID"); // NULL,
bulkCopy.ColumnMappings.Add("WORKDAYTYPE", "WORKDAYTYPE");
bulkCopy.ColumnMappings.Add("REASON", "REASON");
bulkCopy.ColumnMappings.Add("ISLATE", "ISLATE");
bulkCopy.ColumnMappings.Add("OTREMARKS", "OTREMARKS"); // NULL,
bulkCopy.ColumnMappings.Add("WFSTATUS", "WFSTATUS"); // NULL,
bulkCopy.ColumnMappings.Add("APPROVEDOTHOUR", "APPROVEDOTHOUR"); // NULL,
bulkCopy.ColumnMappings.Add("LMREMARKS", "LMREMARKS"); // NULL,
bulkCopy.ColumnMappings.Add("ACTUALINTIME", "ACTUALINTIME"); // NULL,
bulkCopy.ColumnMappings.Add("ACTUALOUTTIME", "ACTUALOUTTIME"); // NULL,
bulkCopy.ColumnMappings.Add("ACTUALSHIFTID", "ACTUALSHIFTID");
bulkCopy.ColumnMappings.Add("EMPREMARKS", "EMPREMARKS");
bulkCopy.ColumnMappings.Add("EMPAPPLYDATE", "EMPAPPLYDATE");
bulkCopy.ColumnMappings.Add("LMAPPROVEDATE", "LMAPPROVEDATE");
bulkCopy.ColumnMappings.Add("LINEMANAGERID", "LINEMANAGERID");
bulkCopy.ColumnMappings.Add("ONBEHALFEMPID", "ONBEHALFEMPID");
bulkCopy.ColumnMappings.Add("WORKHOUR", "WORKHOUR");
bulkCopy.ColumnMappings.Add("INTIMENEARESTADDRESS", "INTIMENEARESTADDRESS");
bulkCopy.ColumnMappings.Add("OUTTIMENEARESTADDRESS", "OUTTIMENEARESTADDRESS");
bulkCopy.ColumnMappings.Add("INTIMELATITUDE", "INTIMELATITUDE");
bulkCopy.ColumnMappings.Add("OUTTIMELATITUDE", "OUTTIMELATITUDE");
bulkCopy.ColumnMappings.Add("INTIMELONGITUDE", "INTIMELONGITUDE");
bulkCopy.ColumnMappings.Add("OUTTIMELONGITUDE", "OUTTIMELONGITUDE");
bulkCopy.ColumnMappings.Add("CREATEDBY", "CREATEDBY");
bulkCopy.ColumnMappings.Add("CREATEDDATE", "CREATEDDATE");
bulkCopy.ColumnMappings.Add("MODIFIEDBY", "MODIFIEDBY"); // NULL,
bulkCopy.ColumnMappings.Add("MODIFIEDDATE", "MODIFIEDDATE"); // NULL,
bulkCopy.DestinationTableName = "DailyAttnProcess";
bulkCopy.WriteToServer(attnProcessEntryTable);
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public DailyAttnProcess GetAttnDataForMobile(int empId, DateTime attnDate)
{
DailyAttnProcess oDailyAttnProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(DailyAttnProcessDA.GetAttnDataForMobile(tc, empId, attnDate));
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
}
return oDailyAttnProcess;
}
public DailyAttnProcess GetAttnDataForMobileWithNoLock(int empId, DateTime attnDate)
{
DailyAttnProcess oDailyAttnProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(DailyAttnProcessDA.GetAttnDataForMobileWithNoLock(tc, empId, attnDate));
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
}
return oDailyAttnProcess;
}
public List<DailyAttnProcess> GetRegularizableAttn(int EmpID, DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetRegularizableAttn(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
}
return dailyAttnProcesses;
}
public List<DailyAttnProcess> GetAttnForStatement(int EmpID, DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetAttnForStatement(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
}
return dailyAttnProcesses;
}
public List<DailyAttnProcess> GetAttnForStatementWithNoLock(int EmpID, DateTime fromDate, DateTime toDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetAttnForStatementWithNoLock(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
}
return dailyAttnProcesses;
}
public List<DailyAttnProcess> GetByLMID(int LMID, DateTime AttnDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetByLMID(tc, LMID, 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
}
return dailyAttnProcesses;
}
public List<DailyAttnProcess> GetByLMIDMobileWithNoLock(int LMID, DateTime AttnDate)
{
List<DailyAttnProcess> dailyAttnProcesses = new List<DailyAttnProcess>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetByLMIDMobileWithNoLock(tc, LMID, 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
}
return dailyAttnProcesses;
}
public DataSet GetAttnSubmittedData(string sEmpIDs, DateTime nextPayProcessDate, EnumWFAttnStatus status, bool isCurrentMonth)
{
DataSet dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.GetAttnSubmittedData(tc, sEmpIDs, nextPayProcessDate, status, isCurrentMonth);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public List<DailyAttnProcess> RefreshObject(Employee emp, int id, string ddlSelectedValue, string comment, DateTime InTime, DateTime OutTime)
{
DateTime tempDateTime = DateTime.MinValue;
DailyAttnProcess daProcess = null;
AttendanceWFHistory attnHistory = null;
List<DailyAttnProcess> _dailyAttnProcesses = new List<DailyAttnProcess>();
bool isChanged = false;
EnumAttendanceType previousStatus;
DateTime previousInTime = DateTime.MinValue;
DateTime previousOutTime = DateTime.MinValue;
isChanged = false;
attnHistory = new AttendanceWFHistory();
daProcess = this.GetAttnDataByWFStatus(id, EnumWFAttnStatus.None);
if (daProcess == null)
throw new CustomException(EnumExceptionType.Error, "Attendance Data Not Found");
daProcess.AttnWFHistory = new List<AttendanceWFHistory>();
previousInTime = daProcess.InTime ?? DateTime.MinValue;
previousOutTime = daProcess.OutTime ?? DateTime.MinValue;
if (daProcess.ActualInTime == DateTime.MinValue)
daProcess.ActualInTime = daProcess.InTime;
if (daProcess.ActualOutTime == DateTime.MinValue)
daProcess.ActualOutTime = daProcess.OutTime;
previousStatus = daProcess.AttenType;
attnHistory.EmployeeID = daProcess.EmployeeID;
attnHistory.DailyAttnProcessID = daProcess.ID;
daProcess.IsManualEntry = true;
EnumAttendanceType value;
if (ddlSelectedValue != string.Empty)
{
value = (EnumAttendanceType)Convert.ToInt32(ddlSelectedValue);
daProcess.AttenType = value;
attnHistory.AttandanceStatus = value;
if (previousStatus != value)
isChanged = true;
}
//RadNumericTextBox txtBoxApprovedOT = (RadNumericTextBox)gridItem.FindControl("numActualOT");
//if (txtBoxApprovedOT.Text != string.Empty)
//{
// daProcess.ApprovedOTHour = Convert.ToDouble(txtBoxApprovedOT.Text);
// daProcess.OtRemarks = daProcess.ApprovedOTHour.ToString();
// attnHistory.OTHour = daProcess.ApprovedOTHour;
// isChanged = true;
//}
if (comment != string.Empty)
{
daProcess.Comments = comment;
attnHistory.Remarks = daProcess.Comments;
isChanged = true;
}
if (InTime != DateTime.MinValue)
{
tempDateTime = InTime;
daProcess.InTime = new DateTime(daProcess.AttnDate.Year, daProcess.AttnDate.Month, daProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second);
}
if (OutTime != DateTime.MinValue)
{
tempDateTime = OutTime;
daProcess.OutTime = new DateTime(daProcess.AttnDate.Year, daProcess.AttnDate.Month, daProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second); ;
}
if (previousInTime != daProcess.InTime)
isChanged = true;
if (previousOutTime != daProcess.OutTime)
isChanged = true;
if (isChanged == true)
{
attnHistory.WFStatus = EnumWFAttnStatus.EmpSubmitted;
}
else
{
attnHistory.WFStatus = EnumWFAttnStatus.NotApplicable;
daProcess.WFStatus = EnumWFAttnStatus.NotApplicable;
}
daProcess.WFStatus = EnumWFAttnStatus.EmpSubmitted;
daProcess.AttnWFHistory.Add(attnHistory);
if (comment == string.Empty)
daProcess.Comments = "Regularized By Supervisor";
_dailyAttnProcesses.Add(daProcess);
return _dailyAttnProcesses;
}
// DataTable getMyTeamNotApprovedList(int lineManagerID);
public DataTable getMyTeamAbsentAndLeaveList(int linemanagerid, DateTime fromdate, DateTime todate)
{
DataTable dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.getMyTeamAbsentAndLeave(tc, linemanagerid, fromdate, todate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataTable getMyTeamNotApprovedList(int linemanagerid)
{
DataTable dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.getMyTeamNotApprovedList(tc, linemanagerid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataTable getMyTeamNotApprovedListMobile(int linemanagerid)
{
DataTable dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.getMyTeamNotApprovedListMobile(tc, linemanagerid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataTable getMyTeamNotApprovedListMobileWithNoLock(int linemanagerid)
{
DataTable dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.getMyTeamNotApprovedListMobileWithNoLock(tc, linemanagerid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataTable GetTypeWiseAttnCount(string empID, DateTime fromDate, DateTime toDate, params EnumAttendanceType[] attnType)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataSet dSet = DailyAttnProcessDA.GetTypeWiseAttnCount(tc, empID, fromDate, toDate, attnType);
return dSet.Tables[0];
}
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();
}
}
public DataSet GetAttnShiftAndWorkDatType(int EmployeeID, DateTime AttnDate)
{
DataSet dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.GetAttnShiftAndWorkDatType(tc, EmployeeID, AttnDate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public DataSet GetAttnShiftAndWorkDatTypeMobileWithNoLock(int EmployeeID, DateTime AttnDate)
{
DataSet dSet = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dSet = DailyAttnProcessDA.GetAttnShiftAndWorkDatTypeMobileWithNoLock(tc, EmployeeID, AttnDate);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dSet;
}
public List<DailyAttnProcess> RefreshObjectDailyAttnMobile(int EmployeeID, int id, EnumAttendanceType attenType, string comment, DateTime InTime, DateTime OutTime, EnumWFAttnStatus attStatus,
string ZipcodeInTime = null, string ZipcodeOutTime = null, decimal InTimeLatitude = 0, decimal OutTimeLatitude = 0, decimal InTimeLongitude = 0, decimal OutTimeLongitude = 0, string InTimeNearestAddress = null, string OutTimeNearestAddress = null,
int locationID = 0, EnumIsFromMobile IsFromMobile = EnumIsFromMobile.None)
{
DateTime tempDateTime = DateTime.MinValue;
DailyAttnProcess daProcess = null;
AttendanceWFHistory attnHistory = null;
List<DailyAttnProcess> _dailyAttnProcesses = new List<DailyAttnProcess>();
bool isChanged = false;
EnumAttendanceType previousStatus;
DateTime previousInTime = DateTime.MinValue;
DateTime previousOutTime = DateTime.MinValue;
isChanged = false;
attnHistory = new AttendanceWFHistory();
try
{
daProcess = this.Get(id);
if (daProcess == null)
throw new CustomException(EnumExceptionType.Error, "Attendance Data Not Found");
previousInTime = daProcess.InTime ?? DateTime.MinValue;
previousOutTime = daProcess.OutTime ?? DateTime.MinValue;
if (daProcess.ActualInTime == DateTime.MinValue)
daProcess.ActualInTime = daProcess.InTime;
if (daProcess.ActualOutTime == DateTime.MinValue)
daProcess.ActualOutTime = daProcess.OutTime;
previousStatus = daProcess.AttenType;
attnHistory.EmployeeID = daProcess.EmployeeID;
attnHistory.DailyAttnProcessID = daProcess.ID;
daProcess.IsManualEntry = true;
daProcess.IsFromMobile = daProcess.IsFromMobile;
daProcess.LocationID = daProcess.LocationID == 0 ? locationID : daProcess.LocationID;
if ((int)attenType != 0)
{
daProcess.EmpAttenType = attenType;
attnHistory.AttandanceStatus = attenType;
if (previousStatus != attenType)
isChanged = true;
}
if (comment != string.Empty)
{
daProcess.Comments = comment;
attnHistory.Remarks = daProcess.Comments;
isChanged = true;
}
if (InTime != DateTime.MinValue)
{
tempDateTime = InTime;
daProcess.InTime = new DateTime(daProcess.AttnDate.Year, daProcess.AttnDate.Month, daProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second);
}
if (OutTime != DateTime.MinValue)
{
tempDateTime = OutTime;
daProcess.OutTime = new DateTime(daProcess.AttnDate.Year, daProcess.AttnDate.Month, daProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second);
}
if (InTime != DateTime.MinValue &&
OutTime != DateTime.MinValue &&
InTime > OutTime)
{
OutTime = DateTime.MinValue;
}
if (previousInTime != daProcess.InTime)
isChanged = true;
if (previousOutTime != daProcess.OutTime)
isChanged = true;
if (isChanged == true)
{
attnHistory.WFStatus = attStatus;
}
else
{
attnHistory.WFStatus = EnumWFAttnStatus.NotApplicable;
daProcess.WFStatus = EnumWFAttnStatus.NotApplicable;
}
daProcess.ZipcodeInTime = ZipcodeInTime == null ? string.Empty : ZipcodeInTime;
daProcess.ZipcodeOutTime = ZipcodeOutTime == null ? string.Empty : ZipcodeOutTime;
daProcess.InTimeLatitude = InTimeLatitude;
daProcess.OutTimeLatitude = OutTimeLatitude;
daProcess.InTimeLongitude = InTimeLongitude;
daProcess.OutTimeLongitude = OutTimeLongitude;
daProcess.InTimeNearestAddress = InTimeNearestAddress == null ? string.Empty : InTimeNearestAddress;
daProcess.OutTimeNearestAddress = OutTimeNearestAddress == null ? string.Empty : OutTimeNearestAddress;
daProcess.IsFromMobile = IsFromMobile;
daProcess.WFStatus = attStatus;
if (daProcess.AttnWFHistory == null)
{
daProcess.AttnWFHistory = new AttendanceWFHistoryService().GetByEmpID(daProcess.ID);
}
daProcess.AttnWFHistory.Add(attnHistory);
_dailyAttnProcesses.Add(daProcess);
new DailyAttnProcessService().Save(_dailyAttnProcesses, null);
}
catch (Exception ex)
{
StringBuilder sb = new StringBuilder();
//sb.Append(ex.Message);
Exception innerException = ex.InnerException;
while (innerException != null)
{
sb.Append(innerException.Message.Substring(0, 50) + " ," + daProcess.EmployeeID + ", " + daProcess.AttnDate + ", " + daProcess.InTime);
innerException = innerException.InnerException;
}
throw new Exception(string.Format("Error Saving Attendance. message: {0}", sb.ToString()));
}
return _dailyAttnProcesses;
}
public List<DailyAttnProcess> GetAttnDataByWFStatusForLM(DateTime fromDate, DateTime toDate, string empID, EnumWFAttnStatus status)
{
List<DailyAttnProcess> dailyAttnProcesses = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.GetAttnDataByWFStatusForLM(tc, fromDate, toDate, empID, status));
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
}
return dailyAttnProcesses;
}
public DataSet GetWorkingDayLateCount(DateTime fromDate, DateTime toDate, int payrollTypeId)
{
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dailyInOut = DailyAttnProcessDA.GetWorkingDayLateCount(tc, fromDate, toDate, payrollTypeId);
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 int AbsentCount(DateTime fromDate, DateTime toDate, int empid, int payrollTypeId)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
return DailyAttnProcessDA.GetAbsentCount(tc, fromDate, toDate, empid, payrollTypeId);
}
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();
}
}
}
public int GetLateCount(DateTime fromDate, DateTime toDate, int empid, int payrollTypeId)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
return DailyAttnProcessDA.GetLateCount(tc, fromDate, toDate, empid, payrollTypeId);
}
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();
}
}
}
public List<DailyAttnMailSenderReport> AttendanceDataForMailSchedular(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid)
{
List<DailyAttnMailSenderReport> oDailyAttnMailSenderReport = new List<DailyAttnMailSenderReport>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(DailyAttnProcessDA.AttendanceDataForMailSchedular(tc, fromDate, toDate, attnType, payrollTypeid));
while (dr.Read())
{
DailyAttnMailSenderReport ot = CreateObject(dr);
oDailyAttnMailSenderReport.Add(ot);
}
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
}
return oDailyAttnMailSenderReport;
}
public void SendRegularizationApplicationMail(DailyAttnProcess dAttnProcessess, EmailSettings emailSettings)
{
DataTable empDt = new EmployeeService().GetRegularizableEmail(dAttnProcessess.EmployeeID.ToString());
if (empDt != null && empDt.Rows.Count > 0)
{
foreach (DataRow item in empDt.Rows)
{
MailSender mailSender = new MailSender();
mailSender.AddTo(item["LMEMAILADDRESS"].ToString());
mailSender.Subject = "Employee Attendance Regularization Application";
mailSender.Body =
"Dear " + item["LMNAME"].ToString() + "," +
"<br><br>" +
item["EMPEMPLOYEENO"].ToString() + "-" + item["EMPNAME"].ToString() +
", has applied to regularize the attendance of " + dAttnProcessess.AttnDate.ToString("dd-MMM-yyyy") + ". " +
"<br>" +
"Your Approval is required. To Approve/Reject, please click " +
"<a href='" + emailSettings.WebAddress + "'>HERE</a>";
mailSender.SendMail(emailSettings);
}
}
}
public void SendRegularizationApplicationMailinThread(DailyAttnProcess dAttnProcessess, EmailSettings emailSettings)
{
Thread myNewThread = new Thread(() => SendRegularizationApplicationMail(dAttnProcessess, emailSettings));
myNewThread.Start();
}
public void SendRegularizationApprovalMail(DailyAttnProcess dAttnProcessess, EmailSettings emailSettings)
{
Thread myNewThread = new Thread(() => sendApproveMail(dAttnProcessess, emailSettings));
myNewThread.Start();
}
public void sendApproveMail(DailyAttnProcess dAttnProcessess, EmailSettings emailSettings)
{
DataTable emp = new EmployeeService().getNameAndEmail(dAttnProcessess.EmployeeID);
if (emp.Rows.Count == 0) return;
if (emp.Rows[0]["linemanagerid"] == DBNull.Value) return;
DataTable lineManager = new EmployeeService().getNameAndEmail(Convert.ToInt32(emp.Rows[0]["linemanagerid"]));
if (lineManager.Rows.Count == 0) return;
if (emp.Rows[0]["linemanagerid"] != DBNull.Value)
{
MailSender mailSender = new MailSender();
mailSender.AddTo(lineManager.Rows[0]["emailaddress"].ToString());
mailSender.Subject = "Employee Attendance Regularization Approval";
mailSender.Body =
"Dear " + emp.Rows[0]["name"] + "," +
"<br><br>" +
lineManager.Rows[0]["employeeno"] + "-" + lineManager.Rows[0]["name"] +
", has " +
(dAttnProcessess.WFStatus == EnumWFAttnStatus.LMApproved ? "approved" : "rejected") +
" your Request of attendance regularization of " + dAttnProcessess.AttnDate.ToString("dd-MMM-yyyy") + ". ";
mailSender.SendMail(emailSettings);
}
}
public DataTable GetAttendanceDashboard(Employee oEmp)
{
DataTable dt = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
dt = DailyAttnProcessDA.GetAttendanceDashboard(tc, oEmp);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dt;
}
public DataTable getTopEmpAbsentData(Employee oEmp, EnumAttendanceType type)
{
DataTable dt = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
dt = DailyAttnProcessDA.getTopEmpAbsentData(tc, oEmp, type);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dt;
}
public DataTable getcorehrAbsentData(Employee oEmp, EnumAttendanceType type)
{
DataTable dt = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
dt = DailyAttnProcessDA.getcorehrAbsentData(tc, oEmp, type);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dt;
}
//public DataSet AttnDaysSummaryForSalaryProcess(DateTime FromDate, DateTime ToDate)
//{
// DataSet attnDaysSummary = null;
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin();
// attnDaysSummary = DailyAttnProcessDA.AttnDaysSummaryForSalaryProcess(tc, FromDate, ToDate);
// tc.End();
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException(e.Message, e);
// #endregion
// }
// return attnDaysSummary;
//}
public DataSet MonthlyAttendanceSummaryForMailSchedularCordinator(int id, DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid)
{
DataSet dataTable = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dataTable = DailyAttnProcessDA.MonthlyAttendanceSummaryForMailSchedularCordinator(tc, id, fromDate, toDate, attnType, payrollTypeid);
tc.End();
}
catch (Exception e)
{
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
}
return dataTable;
}
public DataSet MonthlyAttendanceSummaryForMailSchedular(int id, DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid)
{
DataSet dataTable = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dataTable = DailyAttnProcessDA.MonthlyAttendanceSummaryForMailSchedular(tc, id, fromDate, toDate, attnType, payrollTypeid);
tc.End();
}
catch (Exception e)
{
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
}
return dataTable;
}
#endregion
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 GetEarnedLeaveOpening(int employeeId, int leaveid, DateTime fromDate, DateTime toDate)
{
DataSet dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
tc.CommandTimeOut = 60000;
dailyInOut = DailyAttnProcessDA.GetEarnedLeaveOpening(tc, employeeId, leaveid, fromDate, toDate);
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 DataTable GetEarnedLeaveOpeningByEmployees(string employeeIds, string leaveids, DateTime fromDate, DateTime toDate)
{
DataTable dailyInOut = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
tc.CommandTimeOut = 60000;
dailyInOut = DailyAttnProcessDA.GetEarnedLeaveOpeningByEmployees(tc, employeeIds, leaveids, fromDate, toDate);
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 GetEmpCardInfoPerPageBangla(string sEmpID)
{
DataSet empAttenInfo = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
empAttenInfo = DailyAttnProcessDA.GetEmpCardInfoPerPageBangla(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 DataTable GetAttandanceDashboardData(DateTime fromDate, DateTime toDate, int shiftId, string departmentIds, string employeeIds, bool appliedForRegularize,
int status, string otHourType, int otHour, int CurrentUserId, bool isCalledFromEss, string lineManager, string statusText, int payrollTypeId)
{
DataTable dt = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
tc.CommandTimeOut = 60000;
dt = DailyAttnProcessDA.GetAttandanceDashboardData(tc, fromDate, toDate, shiftId, departmentIds, employeeIds, appliedForRegularize,
status, otHourType, otHour, CurrentUserId, isCalledFromEss, lineManager, statusText, payrollTypeId);
tc.End();
dt.Columns.Add("inTimeString", typeof(string));
dt.Columns.Add("outTimeString", typeof(string));
dt.Columns.Add("attenDateString", typeof(string));
dt.Columns.Add("statusString", typeof(string));
dt.Columns.Add("workhourString", typeof(string));
dt.Columns.Add("lateHourString", typeof(string));
dt.Columns.Add("empRemarksString", typeof(string));
dt.Columns.Add("othourString", typeof(string));
foreach (DataRow dr in dt.Rows)
{
string sActualInTime = dr["InTime"].ToString();
string sActualOutTime = dr["OutTime"].ToString();
string sATTNDATE = dr["ATTNDATE"].ToString();
string sAttenType = dr["AttenType"].ToString();
string sWorkHour = dr["WORKHOUR"].ToString();
string sEmpRemarks = dr["EmpRemarks"].ToString();
string sWfStatus = dr["wfstatus"].ToString();
string sReason = dr["Reason"].ToString();
string othour = dr["OThour"].ToString();
if (sActualInTime != string.Empty)
{
dr["inTimeString"] = Convert.ToDateTime(dr["InTime"]).ToString("hh:mm tt");
}
if (sActualOutTime != string.Empty)
{
dr["outTimeString"] = Convert.ToDateTime(dr["OutTime"]).ToString("hh:mm tt");
}
if (sATTNDATE != string.Empty)
{
dr["attenDateString"] = Convert.ToDateTime(dr["ATTNDATE"]).ToString("dd MMM yy");
}
if (Convert.ToInt64(sWfStatus) == 1)
{
string x1 = "";
string x2 = sReason == string.Empty ? "" : sReason;
dr["empRemarksString"] = x1 + x2;
}
else
{
string x1 = sEmpRemarks == string.Empty ? "" : sEmpRemarks;
string x2 = sReason == string.Empty ? "" : sReason;
dr["empRemarksString"] = x1 + " " + x2;
}
dr["lateHourString"] = "";
if (sAttenType != string.Empty)
{
if ((EnumAttendanceType)Convert.ToInt32(sAttenType) == EnumAttendanceType.Leave)
{
dr["statusString"] = "Leave (" + dr["LeaveType"] + ")";
}
else
{
double totalLateMinute = Convert.ToDouble(dr["LateHour"]);
if (totalLateMinute > 0)
dr["lateHourString"] = Convert.ToDouble(dr["LateHour"]).ToString("0.00") + " hr";
EnumWorkPlanDayType dtype = (EnumWorkPlanDayType)Convert.ToDouble(dr["WORKDAYTYPE"]);
dr["statusString"] =
GlobalFunctions.GetShortAttnType((EnumAttendanceType)Convert.ToInt32(sAttenType),
dtype, totalLateMinute);
}
}
//if (Convert.ToDouble(sWorkHour) == 0 && sActualInTime != string.Empty && sActualOutTime != string.Empty)
//{
// DateTime outTime = Convert.ToDateTime(dr["OutTime"]);
// DateTime inTime = Convert.ToDateTime(dr["InTime"]);
// TimeSpan timeDifference = outTime - inTime;
// double totalMinutes = (double)timeDifference.TotalMinutes;
// double hours = totalMinutes / 60;
// double minutes = totalMinutes % 60;
// dr["workhourString"] = (hours + minutes).ToString("0.00") + " hr";
//}
//else
//{
// dr["workhourString"] = Convert.ToDouble(sWorkHour) == 0 ? string.Empty : Convert.ToDouble( dr["WorkHour"]).ToString("0.00") + " hr";
//}
if (sWorkHour != string.Empty)
{
var totalLateMinute = Convert.ToDouble(dr["WORKHOUR"]);
if (totalLateMinute > 0)
{
dr["workhourString"] = Convert.ToDouble(dr["WORKHOUR"]).ToString("0.00") + " hr";
}
else dr["workhourString"] = "";
}
if (othour != string.Empty)
{
var totalLateMinute = Convert.ToDouble(dr["OTHOUR"]);
if (totalLateMinute > 0)
{
dr["othourString"] = Convert.ToDouble(dr["OTHOUR"]).ToString("0.00") + " hr";
}
else dr["othourString"] = "";
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dt;
}
}
#endregion
}