1818 lines
89 KiB
C#
1818 lines
89 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
[Serializable]
|
|||
|
public class AttendanceProcess
|
|||
|
{
|
|||
|
#region Declaration
|
|||
|
|
|||
|
double _lateHour, _earlyHour, _oTHour;
|
|||
|
//public event System.EventHandler RefreshStatus;
|
|||
|
//ObjectsTemplate<Employee> _employees = null;
|
|||
|
//ObjectsTemplate<MonthlyWorkPlan> _monthlyWorkPlans = null;
|
|||
|
ObjectsTemplate<AttnNationalHoliday> _AttNHolidays = null;
|
|||
|
EnumWorkPlanGroup _empWPtype = EnumWorkPlanGroup.Fixed;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Private functions
|
|||
|
|
|||
|
private double GetOTHourForBuyer(BuyerSetup buyerSetup, double totalOTHour)
|
|||
|
{
|
|||
|
double OTHour = totalOTHour;
|
|||
|
double AssignedOTHour = 0;
|
|||
|
if (buyerSetup.IsHolidayOTAllowed)
|
|||
|
{
|
|||
|
AssignedOTHour = Math.Round((buyerSetup.AcceptHour - (buyerSetup.MaxHolidayOTHour * buyerSetup.MaxHDInMonth)) / 26);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
AssignedOTHour = Math.Round(buyerSetup.AcceptHour / 26);//maximum OT Hour for each day
|
|||
|
}
|
|||
|
if (OTHour > AssignedOTHour)
|
|||
|
{
|
|||
|
//double rand = 0;
|
|||
|
//Random rd = new Random();
|
|||
|
//rand = Convert.ToDouble(rd.Next(0, 15));
|
|||
|
//OTHour = AssignedOTHour - rand / 10;
|
|||
|
|
|||
|
OTHour = AssignedOTHour;
|
|||
|
}
|
|||
|
return OTHour;
|
|||
|
}
|
|||
|
|
|||
|
//private ObjectsTemplate<AttnRawData> GetRawData(ObjectsTemplate<AttnRawData> rawData, ID empID)
|
|||
|
//{
|
|||
|
// ObjectsTemplate<AttnRawData> empRawData = new ObjectsTemplate<AttnRawData>();
|
|||
|
|
|||
|
// foreach (AttnRawData item in rawData)
|
|||
|
// {
|
|||
|
// if (item.EmployeeID == empID)
|
|||
|
// {
|
|||
|
// empRawData.Add(item);
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
|
|||
|
// return empRawData;
|
|||
|
//}
|
|||
|
|
|||
|
private DateTime GetFirstFriday(DateTime Attdate)
|
|||
|
{
|
|||
|
DateTime date = new DateTime();
|
|||
|
date = Convert.ToDateTime(Attdate.ToString("1 MMM yyyy"));
|
|||
|
for (int i = 0; i < 7; i++)
|
|||
|
{
|
|||
|
if (date.DayOfWeek == DayOfWeek.Friday)
|
|||
|
break;
|
|||
|
date = date.AddDays(1);
|
|||
|
}
|
|||
|
return date;
|
|||
|
|
|||
|
// *** For GetFirstTwoFridays
|
|||
|
//DateTime[] dates = new DateTime[2];
|
|||
|
//DateTime dt;
|
|||
|
//dt = Convert.ToDateTime(Attdate.ToString("1 MMM yyyy"));
|
|||
|
//for (int i = 0; i < 7; i++)
|
|||
|
//{
|
|||
|
// if (dt.DayOfWeek == DayOfWeek.Friday)
|
|||
|
// break;
|
|||
|
// dt = dt.AddDays(1);
|
|||
|
//}
|
|||
|
//dates[0] = dt;
|
|||
|
//dates[1] = dt.AddDays(7);
|
|||
|
|
|||
|
//return dates;
|
|||
|
}
|
|||
|
|
|||
|
private List<DateTime> GetLastTenWorkingDays(DateTime Attdate)
|
|||
|
{
|
|||
|
List<DateTime> dates = new List<DateTime>();
|
|||
|
DateTime dt, dtLast;
|
|||
|
dt = Convert.ToDateTime(Attdate.ToString("21 MMM yyyy"));
|
|||
|
dtLast = Convert.ToDateTime(Attdate.ToString("1 MMM yyyy"));
|
|||
|
dtLast = dtLast.AddMonths(1);
|
|||
|
|
|||
|
for (int i = 0; dt < dtLast; i++)
|
|||
|
{
|
|||
|
if (dt.DayOfWeek == DayOfWeek.Friday)
|
|||
|
{
|
|||
|
i--;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
dates.Add(dt);
|
|||
|
}
|
|||
|
|
|||
|
dt = dt.AddDays(1);
|
|||
|
}
|
|||
|
return dates;
|
|||
|
}
|
|||
|
|
|||
|
private EnumAttendanceType GetAttnType(DateTime empInTime, DateTime empOutTime, Shift shift, DateTime attnDate, MonthlyWorkPlan empMonthlyWorkPlan)
|
|||
|
{
|
|||
|
EnumAttendanceType attntype = EnumAttendanceType.Present;
|
|||
|
DateTime shiftInTime = attnDate.Subtract(attnDate.TimeOfDay).Add(shift.InTime.TimeOfDay);
|
|||
|
|
|||
|
DateTime shiftOutTime = DateTime.MinValue;
|
|||
|
DateTime shiftOutTimeWithMinimumOT = DateTime.MinValue;
|
|||
|
|
|||
|
if (shift.InTime <= shift.OutTime)
|
|||
|
{
|
|||
|
shiftOutTime = attnDate.Subtract(attnDate.TimeOfDay).Add(shift.OutTime.TimeOfDay);
|
|||
|
shiftOutTimeWithMinimumOT = attnDate.Subtract(attnDate.TimeOfDay).Add(shift.OutTime.TimeOfDay).AddMinutes(shift.MinimumOTHour);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
shiftOutTime = attnDate.AddDays(1).Subtract(attnDate.TimeOfDay).Add(shift.OutTime.TimeOfDay);
|
|||
|
shiftOutTimeWithMinimumOT = attnDate.AddDays(1).Subtract(attnDate.TimeOfDay).Add(shift.OutTime.TimeOfDay).AddMinutes(shift.MinimumOTHour);
|
|||
|
}
|
|||
|
|
|||
|
// DateTime shiftInTimeWithLatehour = attnDate.Subtract(attnDate.TimeOfDay).Add(shift.InTime.TimeOfDay).AddMinutes(shift.LateCalcualtion);
|
|||
|
|
|||
|
|
|||
|
if (empMonthlyWorkPlan.Type != EnumWorkPlanDayType.WorkingDay)
|
|||
|
{
|
|||
|
TimeSpan OTHour = empOutTime.Subtract(empInTime);
|
|||
|
_oTHour = Convert.ToDouble(OTHour.Hours) + (Convert.ToDouble(OTHour.Minutes) >= Convert.ToDouble(shift.MinimumOTHour) ? 1 : 0);
|
|||
|
//For Launch break
|
|||
|
if (_oTHour > 6)
|
|||
|
{
|
|||
|
_oTHour = _oTHour - 1;
|
|||
|
}
|
|||
|
OTHour = empOutTime.Subtract(empOutTime);
|
|||
|
// for fixed group employee, night 1 am to 2 pm is rest time, so this one hour will be not included in overtime.
|
|||
|
if (_empWPtype == EnumWorkPlanGroup.Fixed && empInTime.Date > empOutTime.Date && empOutTime.Hour >= 1 && empOutTime.Minute >= shift.MinimumOTHour)
|
|||
|
{
|
|||
|
_oTHour = _oTHour - 1;
|
|||
|
}
|
|||
|
if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.NationalHoliday)
|
|||
|
{
|
|||
|
attntype = EnumAttendanceType.Holiday;
|
|||
|
}
|
|||
|
else if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.WeeklyHoliday)
|
|||
|
{
|
|||
|
attntype = EnumAttendanceType.WeeklyHoliday;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (empOutTime > shiftOutTimeWithMinimumOT)
|
|||
|
{
|
|||
|
TimeSpan OTHour = empOutTime.Subtract(shiftOutTime);
|
|||
|
_oTHour = Convert.ToDouble(OTHour.Hours) + (Convert.ToDouble(OTHour.Minutes) >= Convert.ToDouble(shift.MinimumOTHour) ? 1 : 0);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (_oTHour < 0) _oTHour = 0;
|
|||
|
|
|||
|
|
|||
|
return attntype;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void CalcullateWorkdayType(DailyAttnProcess attnProcess, EmployeeWorkPlanSetup oEmpWorkplan, WorkPlanGroup oEmpWPlanGroup)
|
|||
|
{
|
|||
|
//ObjectsTemplate<ShiftRotation> oShiftRotations = null;
|
|||
|
//oShiftRotations = ShiftRotation.Get(oEmpWPlanGroup.Type);
|
|||
|
attnProcess.WorkDayType = EnumWorkPlanDayType.WorkingDay;
|
|||
|
|
|||
|
if (_AttNHolidays == null)
|
|||
|
{
|
|||
|
DateTime oLastDate = GlobalFunctions.LastDateOfMonth(attnProcess.AttnDate);
|
|||
|
DateTime oFirstDate = GlobalFunctions.FirstDateOfMonth(attnProcess.AttnDate);
|
|||
|
_AttNHolidays = AttnNationalHoliday.GetByMonth(oFirstDate, oLastDate);
|
|||
|
}
|
|||
|
|
|||
|
AttnNationalHoliday oAttNHoliday = _AttNHolidays.Where(o => attnProcess.AttnDate.Date >= o.FromDate.Date && attnProcess.AttnDate.Date <= o.ToDate.Date)
|
|||
|
.FirstOrDefault();
|
|||
|
|
|||
|
if (oAttNHoliday.LocationID == null)
|
|||
|
{
|
|||
|
//Holiday;
|
|||
|
}
|
|||
|
|
|||
|
if (oAttNHoliday != null && oAttNHoliday.LocationID == null)
|
|||
|
{
|
|||
|
attnProcess.WorkDayType = EnumWorkPlanDayType.NationalHoliday;
|
|||
|
attnProcess.ReferenceID = oAttNHoliday.ID;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if(oAttNHoliday != null)
|
|||
|
|
|||
|
if (oEmpWPlanGroup.Type == EnumWorkPlanGroup.Fixed)
|
|||
|
{
|
|||
|
if ((oEmpWorkplan.WeekEndOn != null && attnProcess.AttnDate.DayOfWeek == (DayOfWeek)oEmpWorkplan.WeekEndOn)
|
|||
|
|| (oEmpWorkplan.WeekEndOn2 != null && attnProcess.AttnDate.DayOfWeek == (DayOfWeek)oEmpWorkplan.WeekEndOn2))
|
|||
|
{
|
|||
|
attnProcess.WorkDayType = EnumWorkPlanDayType.WeeklyHoliday;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
if (oEmpWorkplan.WeekEndOn != null)
|
|||
|
{
|
|||
|
if (attnProcess.AttnDate.DayOfWeek == (DayOfWeek)oEmpWorkplan.WeekEndOn)
|
|||
|
{
|
|||
|
attnProcess.WorkDayType = EnumWorkPlanDayType.WeeklyHoliday;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (attnProcess.AttnDate >= oEmpWorkplan.StartDate)
|
|||
|
{
|
|||
|
int nShiftInterval = 7;
|
|||
|
TimeSpan st = attnProcess.AttnDate - oEmpWorkplan.StartDate;
|
|||
|
int dayCount = st.Days;
|
|||
|
int nCircleDay = (dayCount % nShiftInterval);
|
|||
|
|
|||
|
if ((nShiftInterval - nCircleDay - 1) == 0)
|
|||
|
{
|
|||
|
attnProcess.WorkDayType = EnumWorkPlanDayType.WeeklyHoliday;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void CalcullateOT(DailyAttnProcess attnProcess, Shift oshift, DateTime Attdate)
|
|||
|
{
|
|||
|
_oTHour = 0;
|
|||
|
|
|||
|
//DateTime shiftInTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.InTime.TimeOfDay);
|
|||
|
|
|||
|
DateTime shiftInTime = Attdate.Subtract(Attdate.TimeOfDay).Add(attnProcess.InTime.TimeOfDay);
|
|||
|
|
|||
|
DateTime shiftOutTime = DateTime.MinValue;
|
|||
|
DateTime shiftOutTimeWithMinimumOT = DateTime.MinValue;
|
|||
|
|
|||
|
TimeSpan shiftTimeDifference = new TimeSpan(0);
|
|||
|
|
|||
|
if (oshift.InTime <= oshift.OutTime)
|
|||
|
{
|
|||
|
shiftTimeDifference = oshift.OutTime.Subtract(oshift.InTime);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
shiftTimeDifference = oshift.OutTime.AddDays(1).Subtract(oshift.InTime);
|
|||
|
}
|
|||
|
|
|||
|
shiftOutTime = shiftInTime.Add(shiftTimeDifference);
|
|||
|
shiftOutTimeWithMinimumOT = shiftOutTime.AddMinutes(oshift.MinimumOTHour);
|
|||
|
|
|||
|
|
|||
|
//if (oshift.InTime <= oshift.OutTime)
|
|||
|
//{
|
|||
|
// shiftOutTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.OutTime.TimeOfDay);
|
|||
|
// shiftOutTimeWithMinimumOT = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.OutTime.TimeOfDay).AddMinutes(oshift.MinimumOTHour);
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// shiftOutTime = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).Add(oshift.OutTime.TimeOfDay);
|
|||
|
// shiftOutTimeWithMinimumOT = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).Add(oshift.OutTime.TimeOfDay).AddMinutes(oshift.MinimumOTHour);
|
|||
|
//}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if (attnProcess.WorkDayType != EnumWorkPlanDayType.WorkingDay)
|
|||
|
{
|
|||
|
TimeSpan OTHour = attnProcess.OutTime.Subtract(attnProcess.InTime);
|
|||
|
|
|||
|
DateTime tempShiftInTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.InTime.TimeOfDay);
|
|||
|
DateTime tempShiftOutTime = oshift.InTime <= oshift.OutTime ? Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.OutTime.TimeOfDay)
|
|||
|
: Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.OutTime.TimeOfDay).AddDays(1);
|
|||
|
// _oTHour = Convert.ToDouble(OTHour.Hours) + (Convert.ToDouble(OTHour.Minutes) >= Convert.ToDouble(oshift.MinimumOTHour) ? 1 : 0);
|
|||
|
|
|||
|
// *** Early by Out time
|
|||
|
// If there is an early exit rule
|
|||
|
if (oshift.EarlyExitBefore != 0)
|
|||
|
{
|
|||
|
// check whether he/she has done early exit
|
|||
|
if (attnProcess.OutTime < tempShiftOutTime)
|
|||
|
{
|
|||
|
// if he or she left between the early exit range
|
|||
|
if (attnProcess.OutTime.AddMinutes(oshift.EarlyExitBefore) >= tempShiftOutTime)
|
|||
|
{
|
|||
|
// then his/her out time will be shift's out time
|
|||
|
OTHour = tempShiftOutTime.Subtract(attnProcess.InTime);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// *** Early by total Hour
|
|||
|
// If there is an early exit rule
|
|||
|
//if (oshift.EarlyExitBefore != 0)
|
|||
|
//{
|
|||
|
|
|||
|
// TimeSpan totalShiftHour = shiftOutTime.Subtract(shiftInTime);
|
|||
|
|
|||
|
// // check whether he/she has done early exit
|
|||
|
// if (_oTHour < totalShiftHour.Hours)
|
|||
|
// {
|
|||
|
// // if his (worktime + early exit time) overtakes his total shift hour
|
|||
|
// // then he/she is given full shift hour OT
|
|||
|
// if ((_oTHour + (oshift.EarlyExitBefore / 60.0)) >= (double)totalShiftHour.Hours)
|
|||
|
// {
|
|||
|
// _oTHour = totalShiftHour.Hours;
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
_oTHour = Convert.ToDouble(OTHour.Hours) + (Convert.ToDouble(OTHour.Minutes) >= Convert.ToDouble(oshift.MinimumOTHour) ? 1 : 0);
|
|||
|
|
|||
|
//For Launch break
|
|||
|
if (_oTHour > 6)
|
|||
|
{
|
|||
|
_oTHour = _oTHour - 1;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
// need to discuss
|
|||
|
// for fixed group employee, night 1 am to 2 pm is rest time, so this one hour will be not included in overtime.
|
|||
|
//if (_empWPtype == EnumWorkPlanGroup.Fixed && attnProcess.InTime.Date > attnProcess.OutTime.Date && attnProcess.OutTime.Hour >= 1 && attnProcess.OutTime.Minute >= oshift.MinimumOTHour)
|
|||
|
//{
|
|||
|
// _oTHour = _oTHour - 1;
|
|||
|
//}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//TimeSpan WorkHour = attnProcess.OutTime.Subtract(attnProcess.InTime);
|
|||
|
|
|||
|
if (attnProcess.OutTime > shiftOutTimeWithMinimumOT)
|
|||
|
{
|
|||
|
TimeSpan OTHour = attnProcess.OutTime.Subtract(shiftOutTime);
|
|||
|
_oTHour = Convert.ToDouble(OTHour.Hours) + (Convert.ToDouble(OTHour.Minutes) >= Convert.ToDouble(oshift.MinimumOTHour) ? 1 : 0);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (_oTHour < 0) _oTHour = 0;
|
|||
|
|
|||
|
attnProcess.OTHour = _oTHour;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Public Functions
|
|||
|
|
|||
|
public void Process(DateTime Attdate,EnumProcessMode prMode)
|
|||
|
{
|
|||
|
|
|||
|
AttnProcessRunSummary oAttnRunSummary = new AttnProcessRunSummary();
|
|||
|
oAttnRunSummary.ProcessMode = prMode;
|
|||
|
|
|||
|
bool isInOutApplicable = false;
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
// #region Load Attendence Raw Data
|
|||
|
|
|||
|
//AttnRawData.CollectRawData(oAttnRunSummary);
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
#region Initialization for Attendence Process
|
|||
|
|
|||
|
isInOutApplicable = ConfigurationManager.GetBoolValue("attendence", "inoutapplicable", EnumConfigurationType.Logic);
|
|||
|
|
|||
|
ObjectsTemplate<DailyAttnProcess> dailyattProcesses = new ObjectsTemplate<DailyAttnProcess>();
|
|||
|
List<EmpFieldTrack> oEmpFieldTracks = new List<EmpFieldTrack>();
|
|||
|
|
|||
|
DateTime startTime = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, 5, 30, 0);
|
|||
|
DateTime ToTime = Attdate.AddDays(1);
|
|||
|
ToTime = new DateTime(ToTime.Year, ToTime.Month, ToTime.Day, 10, 0, 0);
|
|||
|
|
|||
|
ObjectsTemplate<ShiftRotation> CounterClockRotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_1);
|
|||
|
ObjectsTemplate<ShiftRotation> CounterClock2Rotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_2);
|
|||
|
ObjectsTemplate<ShiftRotation> CounterClock3Rotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_3);
|
|||
|
ObjectsTemplate<ShiftRotation> CounterClock4Rotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_4);
|
|||
|
ObjectsTemplate<EmployeeWorkPlanSetup> empWPGroups = EmployeeWorkPlanSetup.Get();
|
|||
|
ObjectsTemplate<Employee> employees = Employee.Get();
|
|||
|
ObjectsTemplate<Shift> shifts = Shift.Get();
|
|||
|
ObjectsTemplate<WorkPlanGroup> workPlanGroups = WorkPlanGroup.Get();
|
|||
|
|
|||
|
ObjectsTemplate<Employee> discontinueEmps = Employee.GetDiscontinueEmp(Attdate, DateTime.Now);
|
|||
|
|
|||
|
ObjectsTemplate<AttnRawData> attRawdata = AttnRawData.Get(startTime, ToTime);// get raw data by a date and order by date, employee, punchTime
|
|||
|
ObjectsTemplate<EmployeeOutsideDuty> outSideDuties = EmployeeOutsideDuty.Get(Attdate); // get transaction by the a rate
|
|||
|
ObjectsTemplate<LeaveEntry> leaves = LeaveEntry.Get(Attdate); // workplans by the date
|
|||
|
oEmpFieldTracks = EmpFieldTrack.Get().Where(obj=> obj.TranDateTime.Date == Attdate.Date).ToList();
|
|||
|
List<LeaveParameter> lvParameters = LeaveParameter.Get(true);
|
|||
|
|
|||
|
if (discontinueEmps != null && discontinueEmps.Count > 0)
|
|||
|
{
|
|||
|
foreach (Employee emp in discontinueEmps)
|
|||
|
{
|
|||
|
if (employees.Contains(emp.ID) == false)
|
|||
|
employees.Add(emp);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
ObjectsTemplate<DailyAttnProcess> prvDayattns = DailyAttnProcess.Get(Attdate.AddDays(-1));
|
|||
|
|
|||
|
|
|||
|
ObjectsTemplate<DailyAttnProcess> manualAttnProcesses = DailyAttnProcess.GetManualProcess(Attdate);
|
|||
|
|
|||
|
foreach (DailyAttnProcess item in manualAttnProcesses)
|
|||
|
{
|
|||
|
dailyattProcesses.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
foreach (Employee emp in employees)
|
|||
|
{
|
|||
|
// For Test
|
|||
|
//if (emp.EmployeeNo.Trim()=="182")
|
|||
|
//{
|
|||
|
|
|||
|
//}
|
|||
|
|
|||
|
#region EmployeeWise Setup
|
|||
|
|
|||
|
// 1. If Joining date is after Attendendence date then no attendence
|
|||
|
if (emp.JoiningDate > Attdate)
|
|||
|
{
|
|||
|
oAttnRunSummary.AddError(EnumErrorType.Others, "Employee Joining Date Greater than Attendence Date.", emp);
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
var manualEntry = manualAttnProcesses
|
|||
|
.Where(obj => obj.EmployeeID == emp.ID)
|
|||
|
.ToList();
|
|||
|
|
|||
|
// 2. If Attendendence is manually enterred then it is already added
|
|||
|
if (manualEntry.Count > 0) continue;
|
|||
|
|
|||
|
DailyAttnProcess attnProcess = new DailyAttnProcess();
|
|||
|
attnProcess.AttnDate = Attdate;
|
|||
|
attnProcess.EmployeeID = emp.ID;
|
|||
|
attnProcess.IsManualEntry = false;
|
|||
|
_lateHour = 0; _earlyHour = 0; _oTHour = 0;
|
|||
|
|
|||
|
MonthlyWorkPlan empMonthlyWorkPlan = null;
|
|||
|
|
|||
|
List<AttnRawData> empAttnData = null;
|
|||
|
|
|||
|
EmployeeOutsideDuty empOutsideDuty = null;
|
|||
|
|
|||
|
LeaveEntry empLeaveEntry = null;
|
|||
|
|
|||
|
|
|||
|
#region Some fine tuning in Employee's attendence RawData
|
|||
|
|
|||
|
if (attRawdata != null && attRawdata.Count > 0)
|
|||
|
{
|
|||
|
empAttnData = attRawdata.Where(erd => erd.EmployeeID.Integer == emp.ID.Integer)
|
|||
|
.OrderBy(erd => erd.PunchTime)
|
|||
|
.ToList();
|
|||
|
// If empAttendence Data exist and
|
|||
|
if (empAttnData.Count > 0)
|
|||
|
{
|
|||
|
// If empAttendence Data's first punchTime is greater than current date's last Time
|
|||
|
if (empAttnData[0].PunchTime > new DateTime(ToTime.Year, ToTime.Month, ToTime.Day, 2, 0, 0))
|
|||
|
{
|
|||
|
// We Clear empAttendence Data
|
|||
|
empAttnData = new ObjectsTemplate<AttnRawData>();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// Gets Employees Previous Days Attendence
|
|||
|
DailyAttnProcess op = prvDayattns.Where(itm => itm.EmployeeID.Integer == emp.ID.Integer)
|
|||
|
.OrderByDescending(itm => itm.OutTime)
|
|||
|
.FirstOrDefault();
|
|||
|
|
|||
|
// if Previous day attendence exists
|
|||
|
if (op != null)
|
|||
|
|
|||
|
{
|
|||
|
// Previous Day's Out time Exists
|
|||
|
if (op.OutTime != DateTime.MinValue)
|
|||
|
{
|
|||
|
|
|||
|
while (empAttnData.Count > 0)
|
|||
|
{
|
|||
|
// Take the Current First Attndence Data
|
|||
|
AttnRawData ordata = empAttnData[0];
|
|||
|
// If PunchTime is less than Previous Date's OutTime OR
|
|||
|
// Difference is less Than 10 minutes
|
|||
|
if (ordata.PunchTime < op.OutTime || Math.Abs((ordata.PunchTime - op.OutTime).TotalMinutes) < 10)
|
|||
|
{
|
|||
|
// discard that attendence entry
|
|||
|
empAttnData.Remove(ordata);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// What to do??
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (isInOutApplicable)
|
|||
|
{
|
|||
|
empAttnData = empAttnData
|
|||
|
.OrderBy(erd => (int)erd.EntryMode)
|
|||
|
.ThenBy(erd => erd.PunchTime)
|
|||
|
.ToList();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
if (outSideDuties != null && outSideDuties.Count > 0)
|
|||
|
{
|
|||
|
empOutsideDuty = outSideDuties.Where(od => od.EmployeeID.Integer == emp.ID.Integer)
|
|||
|
.FirstOrDefault();
|
|||
|
|
|||
|
}
|
|||
|
if (leaves != null && leaves.Count > 0)
|
|||
|
{
|
|||
|
empLeaveEntry = leaves.Where(lv => lv.EmpID == emp.ID.Integer)
|
|||
|
.FirstOrDefault();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
EmployeeWorkPlanSetup oEmpWorkplan = empWPGroups.Where(oGr => oGr.EmployeeID.Integer == emp.ID.Integer)
|
|||
|
.SingleOrDefault();
|
|||
|
|
|||
|
// 3. If There is no EmployeeWorkPlanSetup then no attendence
|
|||
|
if (oEmpWorkplan == null)
|
|||
|
{
|
|||
|
oAttnRunSummary.AddError(EnumErrorType.WorkGroupUndefine, "Employee WorkPlan Not Defined.", emp);
|
|||
|
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
WorkPlanGroup oEmpWPlanGroup = workPlanGroups.Where(o => o.ID.Integer == oEmpWorkplan.WorkPlanGroupID.Integer)
|
|||
|
.Single();
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Calcullate ShiftID and WorkPlan Day Type
|
|||
|
|
|||
|
// not needed now
|
|||
|
// _empWPtype = oEmpWPlanGroup.Type; // Set Workplan Type
|
|||
|
// Get ShiftID from WorkPlan for Fixed workplan
|
|||
|
|
|||
|
if (oEmpWPlanGroup.Type == EnumWorkPlanGroup.Fixed)
|
|||
|
{
|
|||
|
switch (Attdate.DayOfWeek)
|
|||
|
{
|
|||
|
case DayOfWeek.Friday:
|
|||
|
attnProcess.ShiftID = oEmpWorkplan.FridayShiftID.HasValue ? ID.FromInteger(oEmpWorkplan.FridayShiftID.Value) : null;
|
|||
|
break;
|
|||
|
case DayOfWeek.Monday:
|
|||
|
attnProcess.ShiftID = oEmpWorkplan.MondayShiftID.HasValue ? ID.FromInteger(oEmpWorkplan.MondayShiftID.Value) : null;
|
|||
|
break;
|
|||
|
case DayOfWeek.Saturday:
|
|||
|
attnProcess.ShiftID = oEmpWorkplan.SaturdayShiftID.HasValue ? ID.FromInteger(oEmpWorkplan.SaturdayShiftID.Value) : null;
|
|||
|
break;
|
|||
|
case DayOfWeek.Sunday:
|
|||
|
attnProcess.ShiftID = oEmpWorkplan.SundayShiftID.HasValue ? ID.FromInteger(oEmpWorkplan.SundayShiftID.Value) : null;
|
|||
|
break;
|
|||
|
case DayOfWeek.Thursday:
|
|||
|
attnProcess.ShiftID = oEmpWorkplan.ThursdayShiftID.HasValue ? ID.FromInteger(oEmpWorkplan.ThursdayShiftID.Value) : null;
|
|||
|
break;
|
|||
|
case DayOfWeek.Tuesday:
|
|||
|
attnProcess.ShiftID = oEmpWorkplan.TuesdayShiftID.HasValue ? ID.FromInteger(oEmpWorkplan.TuesdayShiftID.Value) : null;
|
|||
|
break;
|
|||
|
case DayOfWeek.Wednesday:
|
|||
|
attnProcess.ShiftID = oEmpWorkplan.WednesdayShiftID.HasValue ? ID.FromInteger(oEmpWorkplan.WednesdayShiftID.Value) : null;
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
// Calcullate ShiftID for Rotation workplan
|
|||
|
else
|
|||
|
{
|
|||
|
if (empAttnData != null && empAttnData.Count > 0)
|
|||
|
{
|
|||
|
DateTime inTime = empAttnData[0].PunchTime;
|
|||
|
double nminutes = 10000;
|
|||
|
ObjectsTemplate<ShiftRotation> osrs;
|
|||
|
if (oEmpWPlanGroup.Type == EnumWorkPlanGroup.Counter_Clock_2)
|
|||
|
{
|
|||
|
osrs = CounterClock2Rotation;
|
|||
|
}
|
|||
|
else if (oEmpWPlanGroup.Type == EnumWorkPlanGroup.Counter_Clock_3)
|
|||
|
{
|
|||
|
osrs = CounterClock3Rotation;
|
|||
|
}
|
|||
|
else if (oEmpWPlanGroup.Type == EnumWorkPlanGroup.Counter_Clock_4)
|
|||
|
{
|
|||
|
osrs = CounterClock4Rotation;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
osrs = CounterClockRotation;
|
|||
|
}
|
|||
|
|
|||
|
foreach (ShiftRotation sr in osrs)
|
|||
|
{
|
|||
|
Shift oshift = shifts.Where(o => o.ID.Integer == sr.ShiftID.Integer)
|
|||
|
.Single();
|
|||
|
|
|||
|
DateTime shiftInTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.InTime.TimeOfDay);
|
|||
|
TimeSpan ospan = (inTime - shiftInTime);
|
|||
|
if (nminutes > Math.Abs(ospan.TotalMinutes))
|
|||
|
{
|
|||
|
nminutes = Math.Abs(ospan.TotalMinutes);
|
|||
|
attnProcess.ShiftID = sr.ShiftID;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
CalcullateWorkdayType(attnProcess, oEmpWorkplan, oEmpWPlanGroup);
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region calculate In/Out time and With Other Things
|
|||
|
|
|||
|
/*
|
|||
|
* if ShiftID found and attendence data exists
|
|||
|
* Calcullate InTime and OutTime
|
|||
|
* If elligable for OT calcullate OT according to DayType(Holiday or Workday)
|
|||
|
*/
|
|||
|
|
|||
|
if (empAttnData != null && empAttnData.Count > 0 && attnProcess.ShiftID.Integer != 0)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Present;
|
|||
|
|
|||
|
Shift oshift = shifts.GetItem(attnProcess.ShiftID);
|
|||
|
|
|||
|
#region Calcullate In Out
|
|||
|
|
|||
|
if (!isInOutApplicable)
|
|||
|
{
|
|||
|
attnProcess.InTime = empAttnData[0].PunchTime;
|
|||
|
|
|||
|
if (empAttnData.Count > 1)
|
|||
|
{
|
|||
|
attnProcess.OutTime = empAttnData[empAttnData.Count - 1].PunchTime;
|
|||
|
|
|||
|
//TimeSpan otime = attnProcess.OutTime - attnProcess.InTime;
|
|||
|
// here we defined that total working hour is 19 hour in a day.
|
|||
|
|
|||
|
for (int i = empAttnData.Count - 1; i >= 1; i--)
|
|||
|
{
|
|||
|
TimeSpan ntime = empAttnData[i].PunchTime - attnProcess.InTime;
|
|||
|
if (oEmpWPlanGroup.Type != EnumWorkPlanGroup.Fixed)
|
|||
|
{
|
|||
|
if (ntime.TotalHours <= 16)
|
|||
|
{
|
|||
|
attnProcess.OutTime = empAttnData[i].PunchTime;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
attnProcess.OutTime = DateTime.MinValue;
|
|||
|
if (empAttnData[i].PunchTime.Date > attnProcess.InTime.Date && empAttnData[i].PunchTime.Hour > 5)
|
|||
|
continue;
|
|||
|
else
|
|||
|
{
|
|||
|
attnProcess.OutTime = empAttnData[i].PunchTime;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (attnProcess.OutTime != DateTime.MinValue)
|
|||
|
{
|
|||
|
if (Math.Abs((attnProcess.InTime - attnProcess.OutTime).TotalMinutes) < 10)
|
|||
|
{
|
|||
|
attnProcess.OutTime = DateTime.MinValue;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
List<AttnRawData> empInRawData = empAttnData.Where(rd => rd.EntryMode == EnumEntryMode.In)
|
|||
|
.OrderBy(rd => rd.PunchTime)
|
|||
|
.ToList();
|
|||
|
List<AttnRawData> empOutRawData = empAttnData.Where(rd => rd.EntryMode == EnumEntryMode.Out)
|
|||
|
.OrderByDescending(rd => rd.PunchTime)
|
|||
|
.ToList();
|
|||
|
|
|||
|
if (empInRawData.Count > 0)
|
|||
|
{
|
|||
|
attnProcess.InTime = empInRawData[0].PunchTime;
|
|||
|
if (empOutRawData.Count > 0)
|
|||
|
{
|
|||
|
attnProcess.OutTime = empOutRawData[0].PunchTime;
|
|||
|
foreach (AttnRawData item in empOutRawData)
|
|||
|
{
|
|||
|
TimeSpan ntime = item.PunchTime - attnProcess.InTime;
|
|||
|
|
|||
|
if (oEmpWPlanGroup.Type != EnumWorkPlanGroup.Fixed)
|
|||
|
{
|
|||
|
if (ntime.TotalHours <= 16)
|
|||
|
{
|
|||
|
attnProcess.OutTime = item.PunchTime;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
attnProcess.OutTime = DateTime.MinValue;
|
|||
|
if (item.PunchTime.Date > attnProcess.InTime.Date && item.PunchTime.Hour > 5)
|
|||
|
continue;
|
|||
|
else
|
|||
|
{
|
|||
|
attnProcess.OutTime = item.PunchTime;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (attnProcess.OutTime != DateTime.MinValue)
|
|||
|
{
|
|||
|
if (Math.Abs((attnProcess.InTime - attnProcess.OutTime).TotalMinutes) < 10)
|
|||
|
{
|
|||
|
attnProcess.OutTime = DateTime.MinValue;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Calcullate Delay & Absent
|
|||
|
|
|||
|
if (oshift.LateCalcualtion != 0 && attnProcess.InTime.TimeOfDay.Subtract(oshift.InTime.TimeOfDay).TotalMinutes > oshift.LateCalcualtion)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Late;
|
|||
|
attnProcess.IsLate = true;
|
|||
|
_lateHour = attnProcess.InTime.TimeOfDay.Subtract(oshift.InTime.TimeOfDay).TotalMinutes/60;
|
|||
|
}
|
|||
|
if(oshift.DelayCalcualtion!=0 && attnProcess.InTime.TimeOfDay.Subtract(oshift.InTime.TimeOfDay).TotalMinutes > oshift.DelayCalcualtion)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Delay;
|
|||
|
attnProcess.IsLate = true;
|
|||
|
_lateHour = attnProcess.InTime.TimeOfDay.Subtract(oshift.InTime.TimeOfDay).TotalMinutes / 60;
|
|||
|
}
|
|||
|
if (oshift.OutTime.TimeOfDay.Subtract(attnProcess.OutTime.TimeOfDay).TotalMinutes > 0)
|
|||
|
{
|
|||
|
|
|||
|
_earlyHour = oshift.OutTime.TimeOfDay.Subtract(attnProcess.OutTime.TimeOfDay).TotalMinutes / 60;
|
|||
|
}
|
|||
|
if (oshift.hasAbsentTime)
|
|||
|
{
|
|||
|
if (oshift.InTime.TimeOfDay <= oshift.OutTime.TimeOfDay)
|
|||
|
{
|
|||
|
if (attnProcess.InTime.TimeOfDay > oshift.AbsentTime.TimeOfDay)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Absent;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (oshift.AbsentTime.TimeOfDay <= oshift.OutTime.TimeOfDay)
|
|||
|
{
|
|||
|
if (attnProcess.InTime.TimeOfDay > oshift.AbsentTime.TimeOfDay && attnProcess.InTime.TimeOfDay <= oshift.OutTime.TimeOfDay)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Absent;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if(!(attnProcess.InTime.TimeOfDay < oshift.AbsentTime.TimeOfDay && attnProcess.InTime.TimeOfDay > oshift.OutTime.TimeOfDay))
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Absent;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region CalcullateOT
|
|||
|
|
|||
|
// If Eligable for OT calcullate OT
|
|||
|
|
|||
|
if(emp.IsEligibleOT && attnProcess.AttenType == EnumAttendanceType.Present)
|
|||
|
{
|
|||
|
CalcullateOT(attnProcess, oshift, Attdate);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
// here _lateHour & _earlyHour is set to '0'
|
|||
|
// May need to calcullate in future
|
|||
|
|
|||
|
attnProcess.LateHour = _lateHour;
|
|||
|
attnProcess.EarlyHour = _earlyHour;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Calcullate MobileAttendence if Not found in rawData
|
|||
|
|
|||
|
if (attnProcess.InTime == DateTime.MinValue && oEmpFieldTracks.Any(obj=>obj.EmployeeID.Integer == attnProcess.EmployeeID.Integer))
|
|||
|
{
|
|||
|
List<EmpFieldTrack> oCurrentEmpFTracks = oEmpFieldTracks.Where(obj => obj.EmployeeID.Integer == attnProcess.EmployeeID.Integer).OrderBy(o=>o.TranDateTime).ToList();
|
|||
|
attnProcess.InTime = oCurrentEmpFTracks[0].TranDateTime;
|
|||
|
if(oCurrentEmpFTracks.Count>1)
|
|||
|
attnProcess.OutTime = oCurrentEmpFTracks[oCurrentEmpFTracks.Count-1].TranDateTime;
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Present;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Calcullate not present status
|
|||
|
|
|||
|
if (attnProcess.InTime == DateTime.MinValue)
|
|||
|
{
|
|||
|
|
|||
|
if (empOutsideDuty != null)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.OutSideDuty;
|
|||
|
attnProcess.ReferenceID = empOutsideDuty.ID;
|
|||
|
}
|
|||
|
else if (empLeaveEntry != null)
|
|||
|
{
|
|||
|
// Check wether Ignore Holidays
|
|||
|
if (lvParameters.Where(x => x.LeaveId == empLeaveEntry.LeaveID.Integer).Any(x => x.IgnoreHoliday))
|
|||
|
{
|
|||
|
if (attnProcess.WorkDayType == EnumWorkPlanDayType.WeeklyHoliday)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.WeeklyHoliday;
|
|||
|
}
|
|||
|
else if (attnProcess.WorkDayType == EnumWorkPlanDayType.NationalHoliday)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Holiday;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Leave;
|
|||
|
attnProcess.ReferenceID = empLeaveEntry.LeaveID;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Leave;
|
|||
|
attnProcess.ReferenceID = empLeaveEntry.LeaveID;
|
|||
|
}
|
|||
|
}
|
|||
|
else if (attnProcess.WorkDayType == EnumWorkPlanDayType.WeeklyHoliday)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.WeeklyHoliday;
|
|||
|
}
|
|||
|
else if (attnProcess.WorkDayType == EnumWorkPlanDayType.NationalHoliday)
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Holiday;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Absent;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
dailyattProcesses.Add(attnProcess); // Add the process to collection
|
|||
|
}
|
|||
|
|
|||
|
//if (dailyattProcesses.Count == 0)
|
|||
|
// throw new ServiceException("After process Raw data, no attandance found for the selected date.");
|
|||
|
//DailyAttnProcess.Save(dailyattProcesses, false);
|
|||
|
|
|||
|
DailyAttnProcess.SaveAuto(dailyattProcesses, oAttnRunSummary);
|
|||
|
}
|
|||
|
catch (ServiceException ex)
|
|||
|
{
|
|||
|
oAttnRunSummary.AddError(EnumErrorType.ServiceException, ex.Message, null);
|
|||
|
oAttnRunSummary.Save();
|
|||
|
throw new ServiceException(ex.Message, ex);
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
oAttnRunSummary.AddError(EnumErrorType.Exception, e.Message, null);
|
|||
|
|
|||
|
oAttnRunSummary.Save();
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//public void ProcessOld(DateTime Attdate)
|
|||
|
//{
|
|||
|
// #region Process
|
|||
|
|
|||
|
// try
|
|||
|
// {
|
|||
|
// DateTime startTime = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, 5, 30, 0);
|
|||
|
// DateTime ToTime = Attdate.AddDays(1);
|
|||
|
// ToTime = new DateTime(ToTime.Year, ToTime.Month, ToTime.Day, 10, 0, 0);
|
|||
|
|
|||
|
// ObjectsTemplate<ShiftRotation> CcRotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock);
|
|||
|
// ObjectsTemplate<ShiftRotation> TwoShiftRotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_2);
|
|||
|
// ObjectsTemplate<EmployeeWorkPlanSetup> empWPGroups = EmployeeWorkPlanSetup.Get();
|
|||
|
// ObjectsTemplate<WorkPlanGroup> oWPGroup = WorkPlanGroup.Get();
|
|||
|
// ObjectsTemplate<Employee> employees = Employee.Get();
|
|||
|
// ObjectsTemplate<AttnRawData> attRawdata = AttnRawData.Get(startTime, ToTime);// get raw data by a date and order by date, employee, punchTime
|
|||
|
// ObjectsTemplate<DailyAttnProcess> dailyattProcesses = new ObjectsTemplate<DailyAttnProcess>();
|
|||
|
// ObjectsTemplate<EmployeeOutsideDuty> outSideDuties = EmployeeOutsideDuty.Get(Attdate); // get transaction by the a rate
|
|||
|
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = MonthlyWorkPlan.Get(Attdate); // get workplans by the date
|
|||
|
// ObjectsTemplate<LeaveEntry> leaves = LeaveEntry.Get(Attdate); // workplans by the date
|
|||
|
// ObjectsTemplate<BuyerSetup> buyers = BuyerSetup.Get();
|
|||
|
// ObjectsTemplate<BuyerDailyAttProcess> bDailyattProcesses = new ObjectsTemplate<BuyerDailyAttProcess>();
|
|||
|
// ObjectsTemplate<Shift> shifts = Shift.Get();
|
|||
|
// ObjectsTemplate<WorkPlanGroup> workPlanGroups = WorkPlanGroup.Get();
|
|||
|
// EmployeeWorkPlanSetup oesetup = null;
|
|||
|
// //for considering employess discontinued after the process date
|
|||
|
// ObjectsTemplate<Employee> discontinueEmps = Employee.GetDiscontinueEmp(Attdate, DateTime.Now);
|
|||
|
// if (discontinueEmps != null && discontinueEmps.Count > 0)
|
|||
|
// {
|
|||
|
// foreach (Employee emp in discontinueEmps)
|
|||
|
// {
|
|||
|
// if (employees.Contains(emp.ID) == false)
|
|||
|
// employees.Add(emp);
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// ObjectsTemplate<DailyAttnProcess> prvDayattns = DailyAttnProcess.Get(Attdate.AddDays(-1));
|
|||
|
|
|||
|
// // manual entry Actual
|
|||
|
// ObjectsTemplate<DailyAttnProcess> manualAttnProcesses = DailyAttnProcess.GetManualProcess(Attdate);
|
|||
|
// foreach (DailyAttnProcess item in manualAttnProcesses)
|
|||
|
// {
|
|||
|
// dailyattProcesses.Add(item);
|
|||
|
// }
|
|||
|
// //manual entry Buyer
|
|||
|
// ObjectsTemplate<BuyerDailyAttProcess> manualAttnEntry = BuyerDailyAttProcess.GetManualEntry(Attdate);
|
|||
|
// foreach (BuyerDailyAttProcess item in manualAttnEntry)
|
|||
|
// {
|
|||
|
// bDailyattProcesses.Add(item);
|
|||
|
// }
|
|||
|
|
|||
|
// if (monthlyWorkPlans == null || monthlyWorkPlans.Count == 0)
|
|||
|
// throw new ServiceException("Current month monthly work plan not yet save.");
|
|||
|
|
|||
|
// int nCount = 0;
|
|||
|
// _empWPtype = EnumWorkPlanGroup.Fixed;
|
|||
|
// foreach (Employee emp in employees)
|
|||
|
// {
|
|||
|
// if (emp.EmployeeNo == "99000254")
|
|||
|
// {
|
|||
|
// emp.EmployeeNo = "99000254";
|
|||
|
// }
|
|||
|
// if (emp.JoiningDate > Attdate) continue;
|
|||
|
// nCount = nCount + 1;
|
|||
|
// #region
|
|||
|
// var manualEntry = from DailyAttnProcess item in manualAttnProcesses
|
|||
|
// where item.EmployeeID == emp.ID
|
|||
|
// select item;
|
|||
|
|
|||
|
// if (manualEntry.ToList().Count > 0) continue;
|
|||
|
// DailyAttnProcess attnProcess = new DailyAttnProcess();
|
|||
|
|
|||
|
// attnProcess.AttnDate = Attdate;
|
|||
|
// attnProcess.EmployeeID = emp.ID;
|
|||
|
// attnProcess.IsManualEntry = false;
|
|||
|
// _lateHour = 0; _earlyHour = 0; _oTHour = 0;
|
|||
|
// MonthlyWorkPlan empMonthlyWorkPlan = null;
|
|||
|
|
|||
|
// List<AttnRawData> empAttnData = null;
|
|||
|
// EmployeeOutsideDuty empOutsideDuty = null;
|
|||
|
// LeaveEntry empLeaveEntry = null;
|
|||
|
|
|||
|
// if (attRawdata != null && attRawdata.Count > 0)
|
|||
|
// {
|
|||
|
// empAttnData = attRawdata.Where(erd => erd.EmployeeID.Integer == emp.ID.Integer)
|
|||
|
// .OrderBy(erd => erd.PunchTime)
|
|||
|
// .ToList();
|
|||
|
// //empAttnData = GetRawData(attRawdata, emp.ID);
|
|||
|
// if (empAttnData.Count > 0 && empAttnData[0].PunchTime > new DateTime(ToTime.Year, ToTime.Month, ToTime.Day, 2, 0, 0))
|
|||
|
// empAttnData = new ObjectsTemplate<AttnRawData>();
|
|||
|
|
|||
|
// DailyAttnProcess op = prvDayattns.Find(delegate(DailyAttnProcess item)
|
|||
|
// { return item.EmployeeID.Integer == emp.ID.Integer; });
|
|||
|
// if (empAttnData.Count > 0 && op != null && op.OutTime != DateTime.MinValue)
|
|||
|
// {
|
|||
|
// while (true)
|
|||
|
// {
|
|||
|
// if (empAttnData.Count == 0) break;
|
|||
|
// AttnRawData ordata = empAttnData[0];
|
|||
|
// if (Math.Abs((ordata.PunchTime - op.OutTime).TotalMinutes) < 10)
|
|||
|
// {
|
|||
|
// empAttnData.Remove(ordata);
|
|||
|
// }
|
|||
|
// else break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// if (outSideDuties != null && outSideDuties.Count > 0)
|
|||
|
// {
|
|||
|
// empOutsideDuty = outSideDuties.Find(delegate(EmployeeOutsideDuty item)
|
|||
|
// { return item.EmployeeID == emp.ID; });
|
|||
|
// }
|
|||
|
// if (leaves != null && leaves.Count > 0)
|
|||
|
// {
|
|||
|
// empLeaveEntry = leaves.Find(delegate(LeaveEntry item)
|
|||
|
// { return item.EmpID == emp.ID.Integer; });
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
// #region find monthly workplan
|
|||
|
// if (monthlyWorkPlans != null && monthlyWorkPlans.Count > 0)
|
|||
|
// {
|
|||
|
// empMonthlyWorkPlan = monthlyWorkPlans.Find(delegate(MonthlyWorkPlan item)
|
|||
|
// { return item.EmployeeID == emp.ID; });
|
|||
|
|
|||
|
// if (empMonthlyWorkPlan != null)
|
|||
|
// {
|
|||
|
// oesetup = empWPGroups.Find(delegate(EmployeeWorkPlanSetup item)
|
|||
|
// { return item.EmployeeID.Integer == emp.ID.Integer; });
|
|||
|
// if (oesetup == null) _empWPtype = EnumWorkPlanGroup.Fixed;
|
|||
|
// else
|
|||
|
// {
|
|||
|
// WorkPlanGroup wpgroup = workPlanGroups.Find(delegate(WorkPlanGroup wpitem)
|
|||
|
// { return wpitem.ID.Integer == oesetup.WorkPlanGroupID.Integer; });
|
|||
|
// _empWPtype = wpgroup.Type;
|
|||
|
// }
|
|||
|
// if (!empMonthlyWorkPlan.ShiftID.IsUnassigned)
|
|||
|
// attnProcess.ShiftID = empMonthlyWorkPlan.ShiftID;
|
|||
|
|
|||
|
// if (_empWPtype != EnumWorkPlanGroup.Fixed && empAttnData != null && empAttnData.Count > 0)
|
|||
|
// {
|
|||
|
// DateTime inTime = empAttnData[0].PunchTime;
|
|||
|
// double nminutes = 10000;
|
|||
|
// ObjectsTemplate<ShiftRotation> osrs = CcRotation;
|
|||
|
// if (_empWPtype == EnumWorkPlanGroup.Counter_Clock_2) osrs = TwoShiftRotation;
|
|||
|
// foreach (ShiftRotation sr in osrs)
|
|||
|
// {
|
|||
|
// Shift oshift = shifts.Find(delegate(Shift item)
|
|||
|
// {
|
|||
|
// return item.ID.Integer == sr.ShiftID.Integer;
|
|||
|
// });
|
|||
|
// DateTime shiftInTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.InTime.TimeOfDay);
|
|||
|
// TimeSpan ospan = (inTime - shiftInTime);
|
|||
|
// if (nminutes > Math.Abs(ospan.TotalMinutes))
|
|||
|
// {
|
|||
|
// nminutes = Math.Abs(ospan.TotalMinutes);
|
|||
|
// attnProcess.ShiftID = sr.ShiftID;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// if (!empMonthlyWorkPlan.HolidayID.IsUnassigned)
|
|||
|
// attnProcess.ReferenceID = empMonthlyWorkPlan.HolidayID;
|
|||
|
// }
|
|||
|
// else continue;
|
|||
|
// }
|
|||
|
// #endregion find monthly workplan
|
|||
|
// #region calculate In/Out time and OT hour
|
|||
|
// if (empAttnData != null && empAttnData.Count > 0 && attnProcess.ShiftID.Integer != 0)
|
|||
|
// {
|
|||
|
// Shift oshift = shifts.GetItem(attnProcess.ShiftID);
|
|||
|
// attnProcess.InTime = empAttnData[0].PunchTime;
|
|||
|
// if (empAttnData.Count > 1)
|
|||
|
// {
|
|||
|
// attnProcess.OutTime = empAttnData[empAttnData.Count - 1].PunchTime;
|
|||
|
// TimeSpan otime = attnProcess.OutTime - attnProcess.InTime;
|
|||
|
// // here we defined that total working hour is 19 hour in a day.
|
|||
|
// for (int i = empAttnData.Count - 1; i >= 1; i--)
|
|||
|
// {
|
|||
|
// TimeSpan ntime = empAttnData[i].PunchTime - attnProcess.InTime;
|
|||
|
// if (_empWPtype != EnumWorkPlanGroup.Fixed)
|
|||
|
// {
|
|||
|
// if (ntime.TotalHours <= 16)
|
|||
|
// {
|
|||
|
// attnProcess.OutTime = empAttnData[i].PunchTime;
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// attnProcess.OutTime = DateTime.MinValue;
|
|||
|
// if (empAttnData[i].PunchTime.Date > attnProcess.InTime.Date && empAttnData[i].PunchTime.Hour > 5)
|
|||
|
// continue;
|
|||
|
// else
|
|||
|
// {
|
|||
|
// attnProcess.OutTime = empAttnData[i].PunchTime;
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// if (attnProcess.OutTime != DateTime.MinValue)
|
|||
|
// {
|
|||
|
// if (Math.Abs((attnProcess.InTime - attnProcess.OutTime).TotalMinutes) < 10)
|
|||
|
// {
|
|||
|
// attnProcess.OutTime = DateTime.MinValue;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// #region Old Code, Do not remove
|
|||
|
// //Shift oshift = shifts.GetItem(attnProcess.ShiftID);
|
|||
|
|
|||
|
// //DateTime shiftIntimeStart = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.InTime.TimeOfDay).Subtract(new TimeSpan(2, 0, 0));
|
|||
|
// //DateTime shiftIntimeEnd = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.InTime.TimeOfDay).Add(new TimeSpan(4, 0, 0));
|
|||
|
|
|||
|
// //DateTime shiftOutTimeEnd = DateTime.MinValue;
|
|||
|
// //if (oshift.InTime > oshift.OutTime)
|
|||
|
// //{
|
|||
|
// // shiftOutTimeEnd = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).Add(oshift.OutTime.TimeOfDay).Add(new TimeSpan(6, 0, 0));
|
|||
|
// //}
|
|||
|
// //else
|
|||
|
// //{
|
|||
|
// // shiftOutTimeEnd = Attdate.Subtract(Attdate.TimeOfDay).Add(oshift.OutTime.TimeOfDay).Add(new TimeSpan(6, 0, 0));
|
|||
|
// //}
|
|||
|
|
|||
|
// //bool inTime = false;
|
|||
|
// //foreach (AttnRawData attndata in empAttnData)
|
|||
|
// //{
|
|||
|
// // if (inTime == false && attndata.PunchTime >= shiftIntimeStart && attndata.PunchTime <= shiftIntimeEnd)
|
|||
|
// // {
|
|||
|
// // attnProcess.InTime = attndata.PunchTime;
|
|||
|
// // inTime = true;
|
|||
|
// // }
|
|||
|
// // if (inTime == true && attndata.PunchTime > shiftIntimeEnd && attndata.PunchTime <= shiftOutTimeEnd)
|
|||
|
// // {
|
|||
|
// // attnProcess.OutTime = attndata.PunchTime;
|
|||
|
// // }
|
|||
|
|
|||
|
// //}
|
|||
|
// #endregion Old Code, Do not remove
|
|||
|
|
|||
|
// attnProcess.AttenType = GetAttnType(attnProcess.InTime, attnProcess.OutTime, oshift, Attdate, empMonthlyWorkPlan);
|
|||
|
// if (emp.IsEligibleOT)
|
|||
|
// {
|
|||
|
// attnProcess.LateHour = _lateHour;
|
|||
|
// attnProcess.EarlyHour = _earlyHour;
|
|||
|
// attnProcess.OTHour = _oTHour;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion calculate In/Out time and OT hour
|
|||
|
// #region present status
|
|||
|
// if (attnProcess.InTime == DateTime.MinValue)
|
|||
|
// {
|
|||
|
// if (empOutsideDuty != null)
|
|||
|
// {
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.OutSideDuty;
|
|||
|
// attnProcess.ReferenceID = empOutsideDuty.ID;
|
|||
|
// }
|
|||
|
// else if (empLeaveEntry != null)
|
|||
|
// {
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.Leave;
|
|||
|
// attnProcess.ReferenceID = empLeaveEntry.LeaveID;
|
|||
|
// }
|
|||
|
// else if (empMonthlyWorkPlan != null && empMonthlyWorkPlan.Type != EnumWorkPlanDayType.WorkingDay)
|
|||
|
// {
|
|||
|
// if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.NationalHoliday)
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.Holiday;
|
|||
|
// else if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.WeeklyHoliday)
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.WeeklyHoliday;
|
|||
|
// }
|
|||
|
// else attnProcess.AttenType = EnumAttendanceType.Absent;
|
|||
|
|
|||
|
// if (_empWPtype == EnumWorkPlanGroup.Counter_Clock && oesetup.WeekEndOn != null
|
|||
|
// && attnProcess.AttnDate.DayOfWeek == (DayOfWeek)oesetup.WeekEndOn
|
|||
|
// && attnProcess.AttenType != EnumAttendanceType.Holiday)
|
|||
|
// {
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.WeeklyHoliday;
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// #endregion present status
|
|||
|
// dailyattProcesses.Add(attnProcess);
|
|||
|
|
|||
|
// #region BuyerWise Process
|
|||
|
|
|||
|
// //int exceesOTDays = 3;
|
|||
|
// foreach (BuyerSetup buyerSetup in buyers)
|
|||
|
// {
|
|||
|
// BuyerDailyAttProcess bDailyAttnProcess = new BuyerDailyAttProcess();
|
|||
|
|
|||
|
// bDailyAttnProcess.BuyerID = buyerSetup.ID;
|
|||
|
// bDailyAttnProcess.AttnDate = attnProcess.AttnDate;
|
|||
|
// bDailyAttnProcess.Comments = attnProcess.Comments;
|
|||
|
// bDailyAttnProcess.EmployeeID = attnProcess.EmployeeID;
|
|||
|
// bDailyAttnProcess.IsManualEntry = attnProcess.IsManualEntry;
|
|||
|
// bDailyAttnProcess.ShiftID = attnProcess.ShiftID;
|
|||
|
// bDailyAttnProcess.AttenType = attnProcess.AttenType;
|
|||
|
// bDailyAttnProcess.ReferenceID = attnProcess.ReferenceID;
|
|||
|
// #region Fixed workpan buyer process
|
|||
|
// if (_empWPtype == EnumWorkPlanGroup.Fixed)
|
|||
|
// {
|
|||
|
// if (empMonthlyWorkPlan != null && empMonthlyWorkPlan.Type != EnumWorkPlanDayType.WorkingDay)
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.ReferenceID = attnProcess.ReferenceID;
|
|||
|
// bDailyAttnProcess.LateHour = 0;
|
|||
|
// bDailyAttnProcess.EarlyHour = 0;
|
|||
|
|
|||
|
// WorkPlanGroup workPlanGroup = workPlanGroups.GetItem(empMonthlyWorkPlan.WorkPlanGroupID);
|
|||
|
|
|||
|
// if (buyerSetup.IsHolidayOTAllowed && workPlanGroup.Type != EnumWorkPlanGroup.Counter_Clock)
|
|||
|
// {
|
|||
|
// //DateTime[] dates = GetFirstTwoFridays(Attdate);
|
|||
|
|
|||
|
// if (Attdate == GetFirstFriday(Attdate))
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.InTime = attnProcess.InTime;
|
|||
|
// if (attnProcess.OTHour > buyerSetup.MaxHolidayOTHour)
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OTHour = buyerSetup.MaxHolidayOTHour;
|
|||
|
// bDailyAttnProcess.OutTime = attnProcess.InTime.AddHours(buyerSetup.MaxHolidayOTHour);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OTHour = attnProcess.OTHour;
|
|||
|
// bDailyAttnProcess.OutTime = attnProcess.InTime.AddHours(bDailyAttnProcess.OTHour);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OTHour = 0;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// // in Counter Clock wise shift there should be no OTHour and in & out time should be shift In & out Time
|
|||
|
// Shift oShift = attnProcess.Shift;
|
|||
|
|
|||
|
// WorkPlanGroup workPlanGroup = workPlanGroups.GetItem(empMonthlyWorkPlan.WorkPlanGroupID);
|
|||
|
|
|||
|
// bDailyAttnProcess.InTime = attnProcess.InTime;
|
|||
|
// bDailyAttnProcess.ReferenceID = attnProcess.ReferenceID;
|
|||
|
// bDailyAttnProcess.LateHour = attnProcess.LateHour;
|
|||
|
// bDailyAttnProcess.EarlyHour = attnProcess.EarlyHour;
|
|||
|
|
|||
|
|
|||
|
// bDailyAttnProcess.OTHour = GetOTHourForBuyer(buyerSetup, attnProcess.OTHour);
|
|||
|
|
|||
|
// if (bDailyAttnProcess.OTHour > 0)
|
|||
|
// {
|
|||
|
// int rand = 0;
|
|||
|
// Random rd = new Random();
|
|||
|
// rand = rd.Next(0, 15);
|
|||
|
|
|||
|
|
|||
|
// //bDailyAttnProcess.OTHour = exceesOTDays != 0 ? bDailyAttnProcess.OTHour + 1 : bDailyAttnProcess.OTHour;
|
|||
|
// //exceesOTDays--;
|
|||
|
// List<DateTime> dates = GetLastTenWorkingDays(Attdate);
|
|||
|
// if (buyerSetup.AcceptHour == 95)
|
|||
|
// {
|
|||
|
// if (dates.Contains(Attdate))
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OTHour = bDailyAttnProcess.OTHour + 1;
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// if (oShift.InTime > oShift.OutTime)
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OutTime = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).Add(oShift.OutTime.TimeOfDay).AddHours(bDailyAttnProcess.OTHour).AddMinutes(Convert.ToDouble(rand));
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OutTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oShift.OutTime.TimeOfDay).AddHours(bDailyAttnProcess.OTHour).AddMinutes(Convert.ToDouble(rand));
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OutTime = attnProcess.OutTime;
|
|||
|
// }
|
|||
|
// // }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion Fixed workpan buyer process
|
|||
|
// #region counter clock buyer process
|
|||
|
// else if (_empWPtype == EnumWorkPlanGroup.Counter_Clock || _empWPtype == EnumWorkPlanGroup.Counter_Clock_2)
|
|||
|
// {
|
|||
|
// EnumAttendanceType ntype = bDailyAttnProcess.AttenType; //EnumAttendanceType.Present;
|
|||
|
// if (empMonthlyWorkPlan != null && empMonthlyWorkPlan.Type != EnumWorkPlanDayType.WorkingDay)
|
|||
|
// {
|
|||
|
// if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.NationalHoliday)
|
|||
|
// ntype = EnumAttendanceType.Holiday;
|
|||
|
// else if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.WeeklyHoliday)
|
|||
|
// ntype = EnumAttendanceType.WeeklyHoliday;
|
|||
|
// }
|
|||
|
// bDailyAttnProcess.AttenType = ntype;
|
|||
|
// if (ntype == EnumAttendanceType.Present)
|
|||
|
// {
|
|||
|
// Shift oShift = shifts.GetItem(empMonthlyWorkPlan.ShiftID);
|
|||
|
// if (oShift == null) continue;
|
|||
|
// int rand = 0;
|
|||
|
// Random rd = new Random();
|
|||
|
// rand = rd.Next(0, 15);
|
|||
|
|
|||
|
// bDailyAttnProcess.InTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oShift.InTime.TimeOfDay).AddMinutes(Convert.ToDouble(rand));
|
|||
|
|
|||
|
// rand = rd.Next(0, 15);
|
|||
|
// if (oShift.InTime > oShift.OutTime)
|
|||
|
// bDailyAttnProcess.OutTime = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).Add(oShift.OutTime.TimeOfDay).AddMinutes(Convert.ToDouble(rand));
|
|||
|
// else
|
|||
|
// bDailyAttnProcess.OutTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oShift.OutTime.TimeOfDay).AddMinutes(Convert.ToDouble(rand));
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.InTime = DateTime.MinValue;
|
|||
|
// bDailyAttnProcess.OutTime = DateTime.MinValue;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion counter clock buyer process
|
|||
|
// bDailyattProcesses.Add(bDailyAttnProcess);
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
|
|||
|
// //if (RefreshStatus != null)
|
|||
|
// //{
|
|||
|
// // object sender = "Total employee:" + employees.Count.ToString() + " left:" + Convert.ToString(employees.Count - nCount);
|
|||
|
// // RefreshStatus(sender, null);
|
|||
|
// //}
|
|||
|
// }
|
|||
|
|
|||
|
// if (dailyattProcesses.Count == 0)
|
|||
|
// throw new ServiceException("After process Raw data, no attandance found for the selected date.");
|
|||
|
|
|||
|
// DailyAttnProcess.Save(dailyattProcesses, false);
|
|||
|
// //BuyerDailyAttProcess.Save(bDailyattProcesses, false);
|
|||
|
|
|||
|
|
|||
|
// }
|
|||
|
// catch (Exception e)
|
|||
|
// {
|
|||
|
// throw new ServiceException(e.Message, e);
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
//}
|
|||
|
|
|||
|
//#region Attendance Process for CounterClockEmployee
|
|||
|
|
|||
|
//#region odd
|
|||
|
////for counterClock Employee
|
|||
|
////public void ProcessCounterClockEmp(DateTime Attdate)
|
|||
|
////{
|
|||
|
//// try
|
|||
|
//// {
|
|||
|
//// ObjectsTemplate<DailyAttnProcess> dAPMorningShift = null;
|
|||
|
//// ObjectsTemplate<DailyAttnProcess> dAPEveningShift = null;
|
|||
|
//// ObjectsTemplate<DailyAttnProcess> dAPNightShift = null;
|
|||
|
|
|||
|
//// //for previous Day Process(AttnDate)
|
|||
|
//// ObjectsTemplate<AttnRawData> rawDataEvening = AttnRawData.Get(Attdate.Subtract(Attdate.TimeOfDay).Add(_counterClockShifts[1].InTime.TimeOfDay).Subtract(new TimeSpan(3, 0, 0)), Attdate.Subtract(Attdate.TimeOfDay).Add(_counterClockShifts[1].InTime.TimeOfDay).Add(new TimeSpan(4, 59, 0)));
|
|||
|
//// ObjectsTemplate<AttnRawData> rawDataNight = AttnRawData.Get(Attdate.Subtract(Attdate.TimeOfDay).Add(_counterClockShifts[2].InTime.TimeOfDay).Subtract(new TimeSpan(3, 0, 0)), Attdate.Subtract(Attdate.TimeOfDay).Add(_counterClockShifts[2].InTime.TimeOfDay).Add(new TimeSpan(4, 59, 0)));
|
|||
|
//// //for current Day Process(AttnDate+1)
|
|||
|
//// ObjectsTemplate<AttnRawData> rawDataMorning = AttnRawData.Get(Attdate.Subtract(Attdate.TimeOfDay).AddDays(1).Add(_counterClockShifts[0].InTime.TimeOfDay).Subtract(new TimeSpan(3, 0, 0)), Attdate.Subtract(Attdate.TimeOfDay).AddDays(1).Add(_counterClockShifts[0].InTime.TimeOfDay).Add(new TimeSpan(4, 59, 0)));
|
|||
|
|
|||
|
//// //process outTime of morning shift and Nightshift(Previous Date) and in time of evening shift
|
|||
|
//// dAPMorningShift = DailyAttnProcess.GetWhrOutTimeIsNull(Attdate, _counterClockShifts[0].ID);
|
|||
|
//// dAPNightShift = DailyAttnProcess.GetWhrOutTimeIsNull(Attdate.AddDays(-1), _counterClockShifts[2].ID);
|
|||
|
//// if (rawDataEvening != null)
|
|||
|
//// {
|
|||
|
//// ProcessOutTime(rawDataEvening, dAPMorningShift, dAPNightShift, Attdate, _counterClockShifts[1], false);
|
|||
|
//// }
|
|||
|
|
|||
|
//// //process outtime of evening shift AND Morning Shift and intime of night shift
|
|||
|
//// dAPEveningShift = DailyAttnProcess.GetWhrOutTimeIsNull(Attdate, _counterClockShifts[1].ID);
|
|||
|
//// dAPMorningShift = DailyAttnProcess.GetWhrOutTimeIsNull(Attdate, _counterClockShifts[0].ID);
|
|||
|
//// if (rawDataNight != null)
|
|||
|
//// {
|
|||
|
//// ProcessOutTime(rawDataNight, dAPEveningShift, dAPMorningShift, Attdate, _counterClockShifts[2], false);
|
|||
|
//// }
|
|||
|
//// //process outtime of nightshift And Evening Shift and intime of morning shift(currentDay)
|
|||
|
//// dAPNightShift = DailyAttnProcess.GetWhrOutTimeIsNull(Attdate, _counterClockShifts[2].ID);
|
|||
|
//// dAPEveningShift = DailyAttnProcess.GetWhrOutTimeIsNull(Attdate, _counterClockShifts[1].ID);
|
|||
|
//// if (rawDataMorning != null)
|
|||
|
//// {
|
|||
|
//// ProcessOutTime(rawDataMorning, dAPNightShift, dAPEveningShift, Attdate, _counterClockShifts[0], true);
|
|||
|
//// }
|
|||
|
//// //process absent employee
|
|||
|
//// ProcessAbsentEmp(Attdate);
|
|||
|
|
|||
|
//// ProcessBuyerWiseCounterClockEmp(Attdate);
|
|||
|
|
|||
|
//// }
|
|||
|
//// catch (Exception e)
|
|||
|
//// {
|
|||
|
//// throw new ServiceException(e.Message, e);
|
|||
|
//// }
|
|||
|
|
|||
|
////}
|
|||
|
|
|||
|
////private void ProcessOutTime(ObjectsTemplate<AttnRawData> rawData, ObjectsTemplate<DailyAttnProcess> dAProcesses1, ObjectsTemplate<DailyAttnProcess> dAProcesses2, DateTime Attdate, Shift shift, bool isNightShift)
|
|||
|
////{
|
|||
|
//// try
|
|||
|
//// {
|
|||
|
//// ObjectsTemplate<DailyAttnProcess> dAProcessesToSave = new ObjectsTemplate<DailyAttnProcess>();
|
|||
|
//// AttnRawData empAttnData = null;
|
|||
|
//// Shift oShift = null;
|
|||
|
//// Employee emp = null;
|
|||
|
//// if (dAProcesses1 != null)
|
|||
|
//// {
|
|||
|
//// foreach (DailyAttnProcess dAP in dAProcesses1)
|
|||
|
//// {
|
|||
|
//// empAttnData = GetRawData(rawData, dAP.EmployeeID, false);
|
|||
|
|
|||
|
//// if (empAttnData != null)
|
|||
|
//// {
|
|||
|
//// emp = _employees.GetItem(dAP.EmployeeID);
|
|||
|
|
|||
|
//// dAP.OutTime = empAttnData.PunchTime;
|
|||
|
//// oShift = _counterClockShifts.GetItem(dAP.ShiftID);
|
|||
|
//// if (emp != null && emp.IsEligibleOT)
|
|||
|
//// {
|
|||
|
//// if (isNightShift)
|
|||
|
//// {
|
|||
|
//// dAP.OTHour = GetOTHour(Attdate.AddDays(1), oShift, dAP.InTime, dAP.OutTime, dAP.AttenType);
|
|||
|
//// }
|
|||
|
//// else
|
|||
|
//// {
|
|||
|
//// dAP.OTHour = GetOTHour(Attdate, oShift, dAP.InTime, dAP.OutTime, dAP.AttenType);
|
|||
|
//// }
|
|||
|
//// }
|
|||
|
//// rawData = RemoveOutTime(rawData, dAP.EmployeeID);
|
|||
|
//// //dailyAttnProcessesToSave.Add(dAP);
|
|||
|
//// }
|
|||
|
//// dAProcessesToSave.Add(dAP);
|
|||
|
//// }
|
|||
|
//// }
|
|||
|
//// if (dAProcesses2 != null)
|
|||
|
//// {
|
|||
|
//// foreach (DailyAttnProcess dAP in dAProcesses2)
|
|||
|
//// {
|
|||
|
//// empAttnData = GetRawData(rawData, dAP.EmployeeID, false);
|
|||
|
|
|||
|
//// if (empAttnData != null)
|
|||
|
//// {
|
|||
|
//// dAP.OutTime = empAttnData.PunchTime;
|
|||
|
//// oShift = _counterClockShifts.GetItem(dAP.ShiftID);
|
|||
|
//// if (isNightShift)
|
|||
|
//// {
|
|||
|
//// dAP.OTHour = GetOTHour(Attdate.AddDays(1), oShift, dAP.InTime, dAP.OutTime, dAP.AttenType);
|
|||
|
//// }
|
|||
|
//// else
|
|||
|
//// {
|
|||
|
//// dAP.OTHour = GetOTHour(Attdate, oShift, dAP.InTime, dAP.OutTime, dAP.AttenType);
|
|||
|
//// }
|
|||
|
//// rawData = RemoveOutTime(rawData, dAP.EmployeeID);
|
|||
|
//// //dailyAttnProcessesToSave.Add(dAP);
|
|||
|
//// }
|
|||
|
//// dAProcessesToSave.Add(dAP);
|
|||
|
//// }
|
|||
|
//// }
|
|||
|
|
|||
|
//// if (dAProcessesToSave.Count > 0)
|
|||
|
//// {
|
|||
|
//// DailyAttnProcess.Save(dAProcessesToSave, true);
|
|||
|
//// }
|
|||
|
|
|||
|
//// if (isNightShift)
|
|||
|
//// {
|
|||
|
//// ProcessInTime(rawData, shift, Attdate.AddDays(1));
|
|||
|
//// }
|
|||
|
//// else
|
|||
|
//// {
|
|||
|
//// ProcessInTime(rawData, shift, Attdate);
|
|||
|
//// }
|
|||
|
//// }
|
|||
|
//// catch (Exception e)
|
|||
|
//// {
|
|||
|
//// throw new ServiceException(e.Message, e);
|
|||
|
//// }
|
|||
|
////}
|
|||
|
|
|||
|
////private void ProcessInTime(ObjectsTemplate<AttnRawData> rawData, Shift shift, DateTime Attdate)
|
|||
|
////{
|
|||
|
//// try
|
|||
|
//// {
|
|||
|
//// ObjectsTemplate<DailyAttnProcess> dAProcess = new ObjectsTemplate<DailyAttnProcess>();
|
|||
|
//// _monthlyWorkPlans = MonthlyWorkPlan.GetByDateAndWPGType(Attdate, EnumWorkPlanGroup.CounterClock);
|
|||
|
|
|||
|
//// DailyAttnProcess dAP = null;
|
|||
|
//// MonthlyWorkPlan empMonthlyWorkPlan = null;
|
|||
|
//// if (_employees != null)
|
|||
|
//// {
|
|||
|
//// AttnRawData empAttnData = null;
|
|||
|
//// foreach (Employee item in _employees)
|
|||
|
//// {
|
|||
|
//// empAttnData = GetRawData(rawData, item.ID, true);
|
|||
|
//// if (empAttnData != null)
|
|||
|
//// {
|
|||
|
//// dAP = new DailyAttnProcess();
|
|||
|
//// dAP.AttnDate = Attdate;
|
|||
|
//// dAP.EmployeeID = item.ID;
|
|||
|
//// dAP.ShiftID = shift.ID;
|
|||
|
//// dAP.InTime = empAttnData.PunchTime;
|
|||
|
//// dAP.IsManualEntry = false;
|
|||
|
//// if (_monthlyWorkPlans != null && _monthlyWorkPlans.Count > 0)
|
|||
|
//// {
|
|||
|
//// empMonthlyWorkPlan = _monthlyWorkPlans.Find(delegate(MonthlyWorkPlan mWP)
|
|||
|
//// { return mWP.EmployeeID == item.ID; });
|
|||
|
//// }
|
|||
|
//// if (empMonthlyWorkPlan != null)
|
|||
|
//// {
|
|||
|
//// dAP.AttenType = GetAttendanceType(empMonthlyWorkPlan);
|
|||
|
//// }
|
|||
|
//// else
|
|||
|
//// {
|
|||
|
//// dAP.AttenType = EnumAttendanceType.Present;
|
|||
|
//// }
|
|||
|
|
|||
|
//// dAProcess.Add(dAP);
|
|||
|
//// }
|
|||
|
//// }
|
|||
|
//// DailyAttnProcess.Save(dAProcess, true);
|
|||
|
//// }
|
|||
|
//// }
|
|||
|
//// catch (Exception e)
|
|||
|
//// {
|
|||
|
//// throw new ServiceException(e.Message, e);
|
|||
|
//// }
|
|||
|
|
|||
|
////}
|
|||
|
|
|||
|
//private EnumAttendanceType GetAttendanceType(MonthlyWorkPlan empMonthlyWorkPlan)
|
|||
|
//{
|
|||
|
// EnumAttendanceType attnType = EnumAttendanceType.Present;
|
|||
|
// if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.NationalHoliday)
|
|||
|
// {
|
|||
|
// attnType = EnumAttendanceType.Holiday;
|
|||
|
// }
|
|||
|
// else if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.WeeklyHoliday)
|
|||
|
// {
|
|||
|
// attnType = EnumAttendanceType.WeeklyHoliday;
|
|||
|
// }
|
|||
|
|
|||
|
// return attnType;
|
|||
|
//}
|
|||
|
|
|||
|
//private double GetOTHour(DateTime AttDate, Shift shift, DateTime inTime, DateTime outTime, EnumAttendanceType attnType)
|
|||
|
//{
|
|||
|
// double OTHour = 0.0;
|
|||
|
// DateTime shiftOutTime = AttDate.Subtract(AttDate.TimeOfDay).Add(shift.OutTime.TimeOfDay);
|
|||
|
// if (attnType == EnumAttendanceType.Present)
|
|||
|
// {
|
|||
|
// if (outTime > shiftOutTime)
|
|||
|
// {
|
|||
|
// TimeSpan OT = outTime.Subtract(shiftOutTime);
|
|||
|
// OTHour = Convert.ToDouble(OT.Hours) + (Convert.ToDouble(OT.Minutes) >= Convert.ToDouble(shift.MinimumOTHour) ? 1 : 0);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// OTHour = 0.0;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// //for any Kind of holiday total workHour will be treated as OT
|
|||
|
// else
|
|||
|
// {
|
|||
|
// TimeSpan OT = outTime.Subtract(inTime);
|
|||
|
// OTHour = Convert.ToDouble(OT.Hours) + (Convert.ToDouble(OT.Minutes) >= Convert.ToDouble(shift.MinimumOTHour) ? 1 : 0);
|
|||
|
// }
|
|||
|
|
|||
|
// return OTHour;
|
|||
|
//}
|
|||
|
|
|||
|
//private void ProcessAbsentEmp(DateTime attnDate)
|
|||
|
//{
|
|||
|
// try
|
|||
|
// {
|
|||
|
// ObjectsTemplate<DailyAttnProcess> dailtAttnProcess = new ObjectsTemplate<DailyAttnProcess>();
|
|||
|
// ObjectsTemplate<Employee> employees = Employee.GetAbsentEmp(attnDate, EnumWorkPlanGroup.CounterClock);
|
|||
|
// if (employees != null && employees.Count > 0)
|
|||
|
// {
|
|||
|
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = MonthlyWorkPlan.GetByDateAndWPGType(attnDate, EnumWorkPlanGroup.CounterClock);
|
|||
|
// ObjectsTemplate<LeaveEntry> leaves = LeaveEntry.Get(attnDate);
|
|||
|
// ObjectsTemplate<EmployeeOutsideDuty> outSideDuties = EmployeeOutsideDuty.Get(attnDate);
|
|||
|
|
|||
|
// MonthlyWorkPlan empMonthlyWorkPlan = null;
|
|||
|
// DailyAttnProcess attnProcess = null;
|
|||
|
// EmployeeOutsideDuty empOutsideDuty = null;
|
|||
|
// LeaveEntry empLeaveEntry = null;
|
|||
|
|
|||
|
// foreach (Employee emp in employees)
|
|||
|
// {
|
|||
|
// attnProcess = new DailyAttnProcess();
|
|||
|
// attnProcess.EmployeeID = emp.ID;
|
|||
|
// attnProcess.AttnDate = attnDate;
|
|||
|
|
|||
|
// if (monthlyWorkPlans != null && monthlyWorkPlans.Count > 0)
|
|||
|
// {
|
|||
|
// empMonthlyWorkPlan = monthlyWorkPlans.Find(delegate(MonthlyWorkPlan item)
|
|||
|
// { return item.EmployeeID == emp.ID; });
|
|||
|
// if (empMonthlyWorkPlan != null)
|
|||
|
// {
|
|||
|
|
|||
|
// if (!empMonthlyWorkPlan.ShiftID.IsUnassigned)
|
|||
|
// {
|
|||
|
// attnProcess.ShiftID = empMonthlyWorkPlan.ShiftID;
|
|||
|
// }
|
|||
|
// if (!empMonthlyWorkPlan.HolidayID.IsUnassigned)
|
|||
|
// {
|
|||
|
// attnProcess.ReferenceID = empMonthlyWorkPlan.HolidayID;
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// if (outSideDuties != null && outSideDuties.Count > 0)
|
|||
|
// {
|
|||
|
// empOutsideDuty = outSideDuties.Find(delegate(EmployeeOutsideDuty item)
|
|||
|
// { return item.EmployeeID == emp.ID; });
|
|||
|
// }
|
|||
|
// if (leaves != null && leaves.Count > 0)
|
|||
|
// {
|
|||
|
// empLeaveEntry = leaves.Find(delegate(LeaveEntry item)
|
|||
|
// { return item.EmpID == emp.ID.Integer; });
|
|||
|
// }
|
|||
|
// if (empOutsideDuty != null)
|
|||
|
// {
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.OutSideDuty;
|
|||
|
// attnProcess.ReferenceID = empOutsideDuty.ID;
|
|||
|
// }
|
|||
|
|
|||
|
// else if (empLeaveEntry != null)
|
|||
|
// {
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.Leave;
|
|||
|
// attnProcess.ReferenceID = empLeaveEntry.LeaveID;
|
|||
|
// }
|
|||
|
|
|||
|
// else if (empMonthlyWorkPlan != null && empMonthlyWorkPlan.Type != EnumWorkPlanDayType.WorkingDay)
|
|||
|
// {
|
|||
|
// if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.NationalHoliday)
|
|||
|
// {
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.Holiday;
|
|||
|
// }
|
|||
|
// else if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.WeeklyHoliday)
|
|||
|
// {
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.WeeklyHoliday;
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// attnProcess.AttenType = EnumAttendanceType.Absent;
|
|||
|
// }
|
|||
|
|
|||
|
// dailtAttnProcess.Add(attnProcess);
|
|||
|
// }
|
|||
|
// if (dailtAttnProcess.Count > 0)
|
|||
|
// {
|
|||
|
// DailyAttnProcess.Save(dailtAttnProcess, true);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// catch (Exception e)
|
|||
|
// {
|
|||
|
// throw new ServiceException(e.Message, e);
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//private AttnRawData GetRawData(ObjectsTemplate<AttnRawData> rawData, ID employeeID, bool isInTime)
|
|||
|
//{
|
|||
|
// AttnRawData empRawData = null;
|
|||
|
// foreach (AttnRawData item in rawData)
|
|||
|
// {
|
|||
|
// if (item.EmployeeID == employeeID)
|
|||
|
// {
|
|||
|
// empRawData = item;
|
|||
|
// if (isInTime)
|
|||
|
// {
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// return empRawData;
|
|||
|
//}
|
|||
|
|
|||
|
//private ObjectsTemplate<AttnRawData> RemoveOutTime(ObjectsTemplate<AttnRawData> rawData, ID employeeID)
|
|||
|
//{
|
|||
|
// ObjectsTemplate<AttnRawData> empRawData = new ObjectsTemplate<AttnRawData>();
|
|||
|
// foreach (AttnRawData item in rawData)
|
|||
|
// {
|
|||
|
// if (item.EmployeeID != employeeID)
|
|||
|
// {
|
|||
|
// empRawData.Add(item);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// return empRawData;
|
|||
|
//}
|
|||
|
|
|||
|
//#endregion
|
|||
|
|
|||
|
|
|||
|
//#endregion
|
|||
|
//private void ProcessBuyerWiseCounterClockEmp(DateTime Attdate)
|
|||
|
//{
|
|||
|
// try
|
|||
|
// {
|
|||
|
// ObjectsTemplate<BuyerDailyAttProcess> dBuyerDAProcess = new ObjectsTemplate<BuyerDailyAttProcess>();
|
|||
|
// BuyerDailyAttProcess bDailyAttnProcess = null;
|
|||
|
// ObjectsTemplate<BuyerSetup> buyers = BuyerSetup.Get();
|
|||
|
// ObjectsTemplate<DailyAttnProcess> dAProcesses = DailyAttnProcess.GetProcessByWPG(EnumWorkPlanGroup.CounterClock, Attdate);
|
|||
|
// if (_monthlyWorkPlans == null)
|
|||
|
// {
|
|||
|
// _monthlyWorkPlans = MonthlyWorkPlan.GetByDateAndWPGType(Attdate, EnumWorkPlanGroup.CounterClock);
|
|||
|
// }
|
|||
|
// if (buyers != null && _monthlyWorkPlans != null && dAProcesses != null)
|
|||
|
// {
|
|||
|
// foreach (BuyerSetup buyer in buyers)
|
|||
|
// {
|
|||
|
// Shift oShift = null;
|
|||
|
// MonthlyWorkPlan empMonthlyWorkPlan = null;
|
|||
|
// foreach (DailyAttnProcess attnProcess in dAProcesses)
|
|||
|
// {
|
|||
|
// bDailyAttnProcess = new BuyerDailyAttProcess();
|
|||
|
|
|||
|
// bDailyAttnProcess.BuyerID = buyer.ID;
|
|||
|
// bDailyAttnProcess.AttnDate = attnProcess.AttnDate;
|
|||
|
// bDailyAttnProcess.Comments = attnProcess.Comments;
|
|||
|
// bDailyAttnProcess.EmployeeID = attnProcess.EmployeeID;
|
|||
|
// bDailyAttnProcess.IsManualEntry = attnProcess.IsManualEntry;
|
|||
|
// bDailyAttnProcess.ShiftID = attnProcess.ShiftID;
|
|||
|
// bDailyAttnProcess.AttenType = attnProcess.AttenType;
|
|||
|
// bDailyAttnProcess.ReferenceID = attnProcess.ReferenceID;
|
|||
|
// bDailyAttnProcess.EarlyHour = 0;
|
|||
|
// bDailyAttnProcess.LateHour = 0;
|
|||
|
// bDailyAttnProcess.OTHour = 0;
|
|||
|
|
|||
|
// if (bDailyAttnProcess.AttenType == EnumAttendanceType.Present)
|
|||
|
// {
|
|||
|
// if (_monthlyWorkPlans != null && _monthlyWorkPlans.Count > 0)
|
|||
|
// {
|
|||
|
// empMonthlyWorkPlan = _monthlyWorkPlans.Find(delegate(MonthlyWorkPlan mWP)
|
|||
|
// { return mWP.EmployeeID == attnProcess.EmployeeID; });
|
|||
|
// }
|
|||
|
// if (empMonthlyWorkPlan == null)
|
|||
|
// {
|
|||
|
// continue;
|
|||
|
// }
|
|||
|
|
|||
|
// oShift = _counterClockShifts.GetItem(empMonthlyWorkPlan.ShiftID);
|
|||
|
// if (oShift == null)
|
|||
|
// {
|
|||
|
// continue;
|
|||
|
// }
|
|||
|
|
|||
|
// int rand = 0;
|
|||
|
// Random rd = new Random();
|
|||
|
// rand = rd.Next(0, 15);
|
|||
|
|
|||
|
// bDailyAttnProcess.InTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oShift.InTime.TimeOfDay).AddMinutes(Convert.ToDouble(rand));
|
|||
|
|
|||
|
// rand = rd.Next(0, 15);
|
|||
|
// if (oShift.InTime > oShift.OutTime)
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OutTime = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).Add(oShift.OutTime.TimeOfDay).AddMinutes(Convert.ToDouble(rand));
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.OutTime = Attdate.Subtract(Attdate.TimeOfDay).Add(oShift.OutTime.TimeOfDay).AddMinutes(Convert.ToDouble(rand));
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// bDailyAttnProcess.InTime = DateTime.MinValue;
|
|||
|
// bDailyAttnProcess.OutTime = DateTime.MinValue;
|
|||
|
// }
|
|||
|
|
|||
|
// dBuyerDAProcess.Add(bDailyAttnProcess);
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// if (dBuyerDAProcess.Count > 0)
|
|||
|
// {
|
|||
|
// BuyerDailyAttProcess.Save(dBuyerDAProcess, true);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// catch (Exception e)
|
|||
|
// {
|
|||
|
// throw new ServiceException(e.Message, e);
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|