550 lines
28 KiB
C#
550 lines
28 KiB
C#
|
using Ease.Core.Model;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Linq;
|
|||
|
using HRM.BO;
|
|||
|
using HRM.DA;
|
|||
|
using NPOI.SS.Formula.Functions;
|
|||
|
using System.Text;
|
|||
|
using System.IO;
|
|||
|
using System.Diagnostics;
|
|||
|
|
|||
|
namespace HRM.UI.MODELS
|
|||
|
{
|
|||
|
public class DailyAttendanceProcess : AuditTrailBase
|
|||
|
{
|
|||
|
public readonly IDailyAttnProcessService _dailyAttnProcess;
|
|||
|
Shift oShift = null;
|
|||
|
List<Shift> _shifts = null;
|
|||
|
MonthlyWorkPlan mplan = null;
|
|||
|
|
|||
|
public DailyAttnProcess ProcessAttendanceForSingleEmployeeToday(DailyAttnProcessTModel oDailyAttnProcessTmodel, int PayrollTypeID)
|
|||
|
{
|
|||
|
// Employee oEmp = Employee.Get(Ease.Core.Model.ID.FromInteger(oDailyAttnProcessTmodel.EmployeeID));
|
|||
|
|
|||
|
DailyAttnProcess attnProcess = new DailyAttnProcess();
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
attnProcess.AttnDate = oDailyAttnProcessTmodel.AttnDate;
|
|||
|
attnProcess.EmployeeID = oDailyAttnProcessTmodel.EmployeeID;
|
|||
|
attnProcess.IsManualEntry = true;
|
|||
|
attnProcess.AttenType = EnumAttendanceType.Present;
|
|||
|
//attnProcess.IsFromMobile = true;
|
|||
|
attnProcess.IsFromMobile = oDailyAttnProcessTmodel.IsFromMobile;
|
|||
|
attnProcess.WFStatus = EnumWFAttnStatus.None;
|
|||
|
attnProcess.InTime = DateTime.Now;
|
|||
|
attnProcess.OutTime = null;
|
|||
|
attnProcess.InTimeLatitude = oDailyAttnProcessTmodel.Location.InTimeLatitude;
|
|||
|
attnProcess.InTimeLongitude = oDailyAttnProcessTmodel.Location.InTimeLongitude;
|
|||
|
attnProcess.InTimeNearestAddress = oDailyAttnProcessTmodel.InTimeNearestAddress;
|
|||
|
|
|||
|
//SearchEmployee oemp = new SearchEmployeeService().get(oDailyAttnProcessTmodel.EmployeeID);
|
|||
|
//User ouser = new UserService().Get(oemp.EmployeeNo);
|
|||
|
attnProcess.CreatedBy = 1; //ouser.ID;
|
|||
|
attnProcess.CreatedDate = DateTime.Today;
|
|||
|
|
|||
|
//List<EmployeeWorkPlanSetup> empWPGroups = new EmployeeWorkPlanSetupService().Get();
|
|||
|
//List<MonthlyWorkPlan> monthlyWorkPlans = new MonthlyWorkPlanService().GetByDate(attnProcess.AttnDate, ouser.LogInPayrollTypeID);
|
|||
|
|
|||
|
//mplan = AttendanceProcess.GetPlanwithEmployee(attnProcess.AttnDate, attnProcess.EmployeeID, empWPGroups, monthlyWorkPlans, null);
|
|||
|
|
|||
|
DataSet dsShidtIDWorkDatType = new DailyAttnProcessService().GetAttnShiftAndWorkDatTypeMobileWithNoLock(attnProcess.EmployeeID, attnProcess.AttnDate);
|
|||
|
|
|||
|
if (dsShidtIDWorkDatType != null && dsShidtIDWorkDatType.Tables[0].Rows.Count > 0)
|
|||
|
{
|
|||
|
if (dsShidtIDWorkDatType.Tables[0].Rows[0][0] != DBNull.Value)
|
|||
|
attnProcess.ShiftID = Convert.ToInt16(dsShidtIDWorkDatType.Tables[0].Rows[0][0].ToString());
|
|||
|
else if (dsShidtIDWorkDatType.Tables[0].Rows[0]["defaultShiftID"] != DBNull.Value)
|
|||
|
{
|
|||
|
attnProcess.ShiftID = Convert.ToInt16(dsShidtIDWorkDatType.Tables[0].Rows[0]["defaultShiftID"].ToString());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
throw new Exception("Failed to get roster, contact to system administrator");
|
|||
|
}
|
|||
|
|
|||
|
double FlexibleHour = Convert.ToDouble(dsShidtIDWorkDatType.Tables[0].Rows[0]["FlexibleHour"]);
|
|||
|
double LunchHour = Convert.ToDouble((Decimal)dsShidtIDWorkDatType.Tables[0].Rows[0]["LunchHour"]);
|
|||
|
|
|||
|
double LateCalcualtion = Convert.ToDouble(dsShidtIDWorkDatType.Tables[0].Rows[0]["LateCalcualtion"]);
|
|||
|
double totalLateMinute = 0;
|
|||
|
DateTime ShiftInTime = ((DateTime)dsShidtIDWorkDatType.Tables[0].Rows[0]["ShiftInTime"]).AddMinutes(FlexibleHour);
|
|||
|
DateTime ShiftOutTime = ((DateTime)dsShidtIDWorkDatType.Tables[0].Rows[0]["ShiftOutTime"]);
|
|||
|
|
|||
|
#region Old LateHour Calculation
|
|||
|
//if (((DateTime)attnProcess.InTime).TimeOfDay > temptime.TimeOfDay)
|
|||
|
//{
|
|||
|
// totalLateMinute = ((DateTime)attnProcess.InTime).TimeOfDay.Subtract(temptime.TimeOfDay).TotalMinutes;
|
|||
|
// if (totalLateMinute > LateCalcualtion)
|
|||
|
// {
|
|||
|
// attnProcess.IsLate = true;
|
|||
|
// attnProcess.LateHour = totalLateMinute;
|
|||
|
// }
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
|
|||
|
Shift oshift = new Shift();
|
|||
|
oshift.ID = (int)attnProcess.ShiftID;
|
|||
|
oshift.InTime = ShiftInTime;
|
|||
|
oshift.OutTime = ShiftOutTime;
|
|||
|
oshift.FlexibleHour = FlexibleHour;
|
|||
|
oshift.LunchHour = LunchHour;
|
|||
|
|
|||
|
DailyAttnProcess daProcess = new DailyAttnProcess();
|
|||
|
daProcess = new AttendanceProcess().CalulateLateAndDelayForMobileAttendance(attnProcess, oshift);
|
|||
|
|
|||
|
attnProcess.LateHour = daProcess.LateHour;
|
|||
|
//attnProcess.EarlyHour = daProcess.EarlyHour;
|
|||
|
attnProcess.WorkHour = daProcess.WorkHour;
|
|||
|
attnProcess.WorkDayType = (EnumWorkPlanDayType)Convert.ToInt16(dsShidtIDWorkDatType.Tables[0].Rows[0][1].ToString());
|
|||
|
|
|||
|
// new AttendanceProcess().CalculateLateAndDelay(attnProcess, oshift);
|
|||
|
}
|
|||
|
|
|||
|
List<DailyAttnProcess> _dailyAttnProcesses = new List<DailyAttnProcess>();
|
|||
|
_dailyAttnProcesses.Add(attnProcess);
|
|||
|
new DailyAttnProcessService().Save(_dailyAttnProcesses, null);
|
|||
|
|
|||
|
//Save RawData
|
|||
|
AttnMobileRawData orawData = new AttnMobileRawData();
|
|||
|
orawData.AttnDate = attnProcess.AttnDate;
|
|||
|
orawData.PunchTime = (DateTime)attnProcess.InTime;
|
|||
|
orawData.EmpID = attnProcess.EmployeeID;
|
|||
|
orawData.PunchType = EnumMobilePunchType.In;
|
|||
|
orawData.IsSynced = true;
|
|||
|
|
|||
|
new AttnMobileRawDataService().Save(orawData);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
string _filePath = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory);
|
|||
|
_filePath += @"\ChckInOutLog.txt";
|
|||
|
|
|||
|
//StreamWriter r = new StreamWriter(_filePath, true);
|
|||
|
//string sms = "";
|
|||
|
//if (ex.Message != null) sms = ex.Message;
|
|||
|
//r.WriteLine((sms.Length > 50) ? sms.Substring(0, 50) : sms + " [" + attnProcess.EmployeeID + "] "
|
|||
|
//+ attnProcess.AttnDate.ToString("dd MMM yyyy") + ", " + ((DateTime)attnProcess.OutTime).ToString("dd MMM yyyy hh:mm"));
|
|||
|
//r.Close();
|
|||
|
|
|||
|
using (StreamWriter r = new StreamWriter(_filePath, true))
|
|||
|
{
|
|||
|
string sms = "";
|
|||
|
if (ex.Message != null) sms = ex.Message;
|
|||
|
r.WriteLine((sms.Length > 50) ? sms.Substring(0, 50) : sms + " [" + attnProcess.EmployeeID + "] "
|
|||
|
+ attnProcess.AttnDate.ToString("dd MMM yyyy") + ", " + ((DateTime)attnProcess.OutTime).ToString("dd MMM yyyy hh:mm"));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return attnProcess;
|
|||
|
}
|
|||
|
public void CheckOutFixedPosition(int empid, DateTime attnDate, string comment, decimal OutTimeLatitude, decimal OutTimeLongitude,
|
|||
|
int locationID, EnumIsFromMobile IsFromMobile, string OutTimeNearestAddress)
|
|||
|
{
|
|||
|
DailyAttnProcess daProcess = null;
|
|||
|
List<DailyAttnProcess> _dailyAttnProcesses = new List<DailyAttnProcess>();
|
|||
|
try
|
|||
|
{
|
|||
|
daProcess = new DailyAttnProcessService().GetforMobileWithNoLock(empid, attnDate);
|
|||
|
|
|||
|
if (daProcess == null)
|
|||
|
throw new CustomException(EnumExceptionType.Error, "Check-In data not found for this Day.");
|
|||
|
|
|||
|
|
|||
|
daProcess.IsManualEntry = true;
|
|||
|
daProcess.IsFromMobile = IsFromMobile;
|
|||
|
daProcess.LocationID = daProcess.LocationID == 0 ? locationID : daProcess.LocationID;
|
|||
|
daProcess.OutTime = DateTime.Now;
|
|||
|
daProcess.LocationID = locationID;
|
|||
|
|
|||
|
daProcess.OutTimeLatitude = OutTimeLatitude;
|
|||
|
daProcess.OutTimeLongitude = OutTimeLongitude;
|
|||
|
daProcess.OutTimeNearestAddress = OutTimeNearestAddress;
|
|||
|
//daProcess.ActualInTime = daProcess.InTime;
|
|||
|
//daProcess.ActualOutTime = daProcess.OutTime;
|
|||
|
//daProcess.WFStatus = EnumWFAttnStatus.EmpSubmitted;
|
|||
|
|
|||
|
if (daProcess.ShiftID != null)
|
|||
|
{
|
|||
|
Shift oshift = new ShiftService().Get((int)daProcess.ShiftID);
|
|||
|
|
|||
|
// DateTime temptime = oshift.OutTime.AddMinutes(-oshift.FlexibleHour);
|
|||
|
//if ((daProcess.InTime != null && ((DateTime)daProcess.OutTime).Subtract((DateTime)daProcess.InTime).TotalHours < oshift.WorkHour))
|
|||
|
//{
|
|||
|
// daProcess.EarlyHour = oshift.WorkHour - ((DateTime)daProcess.OutTime).Subtract((DateTime)daProcess.InTime).TotalHours;
|
|||
|
//}
|
|||
|
|
|||
|
//Shift tempShift = new Shift();
|
|||
|
//tempShift.ID = (int)daProcess.ShiftID;
|
|||
|
//tempShift.InTime = (DateTime)daProcess.InTime;
|
|||
|
//tempShift.OutTime = (DateTime)daProcess.OutTime;
|
|||
|
//tempShift.FlexibleHour = oshift.FlexibleHour;
|
|||
|
//tempShift.LunchHour = oshift.LunchHour;
|
|||
|
|
|||
|
DailyAttnProcess odaProcess = new DailyAttnProcess();
|
|||
|
odaProcess = new AttendanceProcess().CalulateLateAndDelayForMobileAttendance(daProcess, oshift);
|
|||
|
|
|||
|
new AttendanceProcess().CalulateOverTimeForMobileAttendance(daProcess, oshift);
|
|||
|
//daProcess.LateHour = odaProcess.LateHour;
|
|||
|
daProcess.EarlyHour = daProcess.EarlyHour;
|
|||
|
daProcess.WorkHour = odaProcess.WorkHour;
|
|||
|
|
|||
|
// new AttendanceProcess().CalculateLateAndDelay(daProcess, oshift);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
_dailyAttnProcesses.Add(daProcess);
|
|||
|
|
|||
|
new DailyAttnProcessService().Save(_dailyAttnProcesses, null);
|
|||
|
AttnMobileRawData orawData = new AttnMobileRawData();
|
|||
|
orawData.AttnDate = daProcess.AttnDate;
|
|||
|
orawData.PunchTime = (DateTime)daProcess.OutTime;
|
|||
|
orawData.EmpID = daProcess.EmployeeID;
|
|||
|
orawData.PunchType = EnumMobilePunchType.Out;
|
|||
|
orawData.IsSynced = true;
|
|||
|
|
|||
|
new AttnMobileRawDataService().Save(orawData);
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
string _filePath = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory);
|
|||
|
_filePath += @"\ChckInOutLog.txt";
|
|||
|
|
|||
|
//StreamWriter r = new StreamWriter(_filePath,true);
|
|||
|
//string sms = "";
|
|||
|
//if(ex.Message !=null) sms = ex.Message;
|
|||
|
//r.WriteLine((sms.Length > 50) ? sms.Substring(0, 50) : sms + " [" + daProcess.EmployeeID + "] "
|
|||
|
// + daProcess.AttnDate.ToString("dd MMM yyyy") + ", " + ((DateTime)daProcess.OutTime).ToString("dd MMM yyyy hh:mm"));
|
|||
|
//r.Close();
|
|||
|
|
|||
|
using (StreamWriter r = new StreamWriter(_filePath, true))
|
|||
|
{
|
|||
|
string sms = "";
|
|||
|
if (ex.Message != null) sms = ex.Message;
|
|||
|
r.WriteLine((sms.Length > 50) ? sms.Substring(0, 50) : sms + " [" + daProcess.EmployeeID + "] "
|
|||
|
+ daProcess.AttnDate.ToString("dd MMM yyyy") + ", " + ((DateTime)daProcess.OutTime).ToString("dd MMM yyyy hh:mm"));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//private void CalculateLateAttendanceType(DailyAttnProcess attnProcess, DateTime Attdate)
|
|||
|
//{
|
|||
|
// if (attnProcess.WorkDayType == EnumWorkPlanDayType.WorkingDay && attnProcess.AttenType == EnumAttendanceType.Present)
|
|||
|
// {
|
|||
|
|
|||
|
// CalcullateLateAttendanceType(attnProcess, oShift, Attdate);
|
|||
|
// if (attnProcess.LateAttendanceType != EnumLateAttendanceType.NotApplicable)
|
|||
|
// {
|
|||
|
// attnProcess.IsLate = true;
|
|||
|
// double _lateHour = 0;
|
|||
|
// _lateHour = (attnProcess.InTime.TimeOfDay.Subtract(oShift.InTime.TimeOfDay).TotalMinutes) / 60;
|
|||
|
// attnProcess.LateHour = _lateHour;
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//private void CalcullateLateAttendanceType(DailyAttnProcess attnProcess, Shift oshift, DateTime Attdate)
|
|||
|
//{
|
|||
|
// int extraMinutes = 0;
|
|||
|
// if (attnProcess.InTime == DateTime.MinValue || attnProcess.OutTime == DateTime.MinValue)
|
|||
|
// {
|
|||
|
// return;
|
|||
|
// }
|
|||
|
|
|||
|
// DateTime tInTime = attnProcess.InTime ?? DateTime.MinValue;
|
|||
|
// DateTime tOutTime = DateTime.MinValue;
|
|||
|
|
|||
|
// DateTime dt_0_hour_00_minutes = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oshift.InTime.Hour, oshift.InTime.Minute, oshift.InTime.Second);
|
|||
|
// DateTime dt0_hour_14_minutes = dt_0_hour_00_minutes.AddMinutes(14).AddSeconds(59);
|
|||
|
|
|||
|
// if (attnProcess.InTime >= dt_0_hour_00_minutes && attnProcess.InTime <= dt0_hour_14_minutes)
|
|||
|
// {
|
|||
|
// extraMinutes = 15;
|
|||
|
// tOutTime = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oshift.OutTime.Hour, oshift.OutTime.Minute, 0);
|
|||
|
// tOutTime = tOutTime.AddMinutes(extraMinutes);
|
|||
|
// if (attnProcess.OutTime < tOutTime)
|
|||
|
// {
|
|||
|
// attnProcess.LateAttendanceType = EnumLateAttendanceType.Nine_0am_to_Nine_14am;
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// DateTime dt0_hours_15_minutes = dt_0_hour_00_minutes.AddMinutes(15);
|
|||
|
// DateTime dt0_hours_29_minutes = dt_0_hour_00_minutes.AddMinutes(29).AddSeconds(59);
|
|||
|
|
|||
|
// if (attnProcess.InTime >= dt0_hours_15_minutes && attnProcess.InTime <= dt0_hours_29_minutes)
|
|||
|
// {
|
|||
|
// extraMinutes = 30;
|
|||
|
// tOutTime = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oshift.OutTime.Hour, oshift.OutTime.Minute, 0);
|
|||
|
// tOutTime = tOutTime.AddMinutes(extraMinutes);
|
|||
|
// if (attnProcess.OutTime < tOutTime)
|
|||
|
// {
|
|||
|
// attnProcess.LateAttendanceType = EnumLateAttendanceType.Nine_15am_to_Nine_29am;
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
|
|||
|
// DateTime dt_0_hour_30_minutes = dt_0_hour_00_minutes.AddMinutes(30);
|
|||
|
// DateTime dt_1_hour_59_minutes = dt_0_hour_00_minutes.AddHours(1).AddMinutes(59).AddSeconds(59);
|
|||
|
|
|||
|
// if (attnProcess.InTime >= dt_0_hour_30_minutes && attnProcess.InTime <= dt_1_hour_59_minutes)
|
|||
|
// {
|
|||
|
// attnProcess.LateAttendanceType = EnumLateAttendanceType.Nine_30am_to_Ten_59am;
|
|||
|
// }
|
|||
|
|
|||
|
// DateTime dt_2hour_00_minutes = dt_0_hour_00_minutes.AddHours(2);
|
|||
|
// DateTime dt_4_hour_30_minutes = dt_0_hour_00_minutes.AddHours(4).AddMinutes(30);
|
|||
|
// if (attnProcess.InTime >= dt_2hour_00_minutes && attnProcess.InTime <= dt_4_hour_30_minutes)
|
|||
|
// {
|
|||
|
// attnProcess.LateAttendanceType = EnumLateAttendanceType.Eleven_0am_to_One_30pm;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//private void CalculateShift(WorkPlanGroup oEmpWPlanGroup, DailyAttnProcess attnProcess, DateTime Attdate, Employee emp, EmployeeWorkPlanSetup oEmpWorkplanSetup)
|
|||
|
//{
|
|||
|
// #region Calculate Particular Shift Based On WorkPlan Group Type
|
|||
|
|
|||
|
// List<MonthlyWorkPlan> monthlyWorkPlans = MonthlyWorkPlan.GetByDate(Attdate);
|
|||
|
// List<ActingResponsibilitySetup> _tempraryShifts = new List<ActingResponsibilitySetup>();
|
|||
|
// MonthlyWorkPlan mplan = null;
|
|||
|
// ActingResponsibilitySetup tempShiftEmployee = null; //_tempraryShifts.Where(o => o.EmployeeID == attnProcess.EmployeeID).FirstOrDefault();
|
|||
|
// List<Shift> shifts = Shift.Get();
|
|||
|
// List<ShiftRotation> CounterClockRotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_1);
|
|||
|
// List<ShiftRotation> CounterClock2Rotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_2);
|
|||
|
// List<ShiftRotation> CounterClock3Rotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_3);
|
|||
|
// List<ShiftRotation> CounterClock4Rotation = ShiftRotation.Get(EnumWorkPlanGroup.Counter_Clock_4);
|
|||
|
|
|||
|
// if (oEmpWPlanGroup.Type == EnumWorkPlanGroup.Fixed)
|
|||
|
// {
|
|||
|
|
|||
|
// if (oEmpWPlanGroup.WorkPlanGroupType == EnumWorkPlanGroupType.Exception && attnProcess.MonthlyWorkPlan != null)
|
|||
|
// {
|
|||
|
// attnProcess.ShiftID = mplan.ShiftID;
|
|||
|
// attnProcess.TempShiftID = null;
|
|||
|
// if (tempShiftEmployee != null)
|
|||
|
// {
|
|||
|
// mplan = GetPlanwithEmployee(Attdate, emp.ID, oEmpWorkplanSetup, monthlyWorkPlans, _tempraryShifts);
|
|||
|
// attnProcess.MonthlyWorkPlan = mplan;
|
|||
|
// attnProcess.TempShiftID = mplan.ShiftID;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// switch (Attdate.DayOfWeek)
|
|||
|
// {
|
|||
|
// case DayOfWeek.Friday:
|
|||
|
// attnProcess.ShiftID = oEmpWPlanGroup.FridayShiftID.HasValue ? ID.FromInteger(oEmpWPlanGroup.FridayShiftID.Value) : ID.FromInteger(0);
|
|||
|
// break;
|
|||
|
// case DayOfWeek.Monday:
|
|||
|
// attnProcess.ShiftID = oEmpWPlanGroup.MondayShiftID.HasValue ? ID.FromInteger(oEmpWPlanGroup.MondayShiftID.Value) : ID.FromInteger(0);
|
|||
|
// break;
|
|||
|
// case DayOfWeek.Saturday:
|
|||
|
// attnProcess.ShiftID = oEmpWPlanGroup.SaturdayShiftID.HasValue ? ID.FromInteger(oEmpWPlanGroup.SaturdayShiftID.Value) : ID.FromInteger(0);
|
|||
|
// break;
|
|||
|
// case DayOfWeek.Sunday:
|
|||
|
// attnProcess.ShiftID = oEmpWPlanGroup.SundayShiftID.HasValue ? ID.FromInteger(oEmpWPlanGroup.SundayShiftID.Value) : ID.FromInteger(0);
|
|||
|
// break;
|
|||
|
// case DayOfWeek.Thursday:
|
|||
|
// attnProcess.ShiftID = oEmpWPlanGroup.ThursdayShiftID.HasValue ? ID.FromInteger(oEmpWPlanGroup.ThursdayShiftID.Value) : ID.FromInteger(0);
|
|||
|
// break;
|
|||
|
// case DayOfWeek.Tuesday:
|
|||
|
// attnProcess.ShiftID = oEmpWPlanGroup.TuesdayShiftID.HasValue ? ID.FromInteger(oEmpWPlanGroup.TuesdayShiftID.Value) : ID.FromInteger(0);
|
|||
|
// break;
|
|||
|
// case DayOfWeek.Wednesday:
|
|||
|
// attnProcess.ShiftID = oEmpWPlanGroup.WednesdayShiftID.HasValue ? ID.FromInteger(oEmpWPlanGroup.WednesdayShiftID.Value) : ID.FromInteger(0);
|
|||
|
// break;
|
|||
|
// default:
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
|
|||
|
// if (attnProcess.MonthlyWorkPlan != null)
|
|||
|
// {
|
|||
|
// attnProcess.ShiftID = mplan.ShiftID;
|
|||
|
// attnProcess.TempShiftID = null;
|
|||
|
// if (tempShiftEmployee != null)
|
|||
|
// {
|
|||
|
|
|||
|
// mplan = GetPlanwithEmployee(Attdate, emp.ID, oEmpWorkplanSetup, monthlyWorkPlans, _tempraryShifts);
|
|||
|
// attnProcess.MonthlyWorkPlan = mplan;
|
|||
|
// attnProcess.TempShiftID = mplan.ShiftID;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// List<ShiftRotation> osrs;
|
|||
|
// if (oEmpWPlanGroup.Type == EnumWorkPlanGroup.Counter_Clock_1)
|
|||
|
// osrs = CounterClockRotation;
|
|||
|
// else 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);
|
|||
|
// attnProcess.ShiftID = sr.ShiftID;
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// if (attnProcess.TempShiftID == null)
|
|||
|
// {
|
|||
|
// oShift = shifts.GetItem(attnProcess.ShiftID);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// oShift = shifts.GetItem(attnProcess.TempShiftID);
|
|||
|
// }
|
|||
|
|
|||
|
// #endregion
|
|||
|
//}
|
|||
|
|
|||
|
//private MonthlyWorkPlan GetPlanwithEmployee(DateTime EffectDate, int employeeid, EmployeeWorkPlanSetup plans, List<MonthlyWorkPlan> MworkPlans, List<ActingResponsibilitySetup> temporaryShiftEmps)
|
|||
|
//{
|
|||
|
|
|||
|
// MonthlyWorkPlan dPlan = null;
|
|||
|
// if (temporaryShiftEmps == null)
|
|||
|
// {
|
|||
|
// EmployeeWorkPlanSetup workGroup = plans;
|
|||
|
// if (workGroup != null)
|
|||
|
// {
|
|||
|
// dPlan = MworkPlans.FirstOrDefault(x => x.WorkPlanGroupID == workGroup.WorkPlanGroupID && x.WorkDate == EffectDate);
|
|||
|
// dPlan.EmployeeID = employeeid;
|
|||
|
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// ActingResponsibilitySetup tempShift = temporaryShiftEmps.FirstOrDefault(x => x.EmployeeID == employeeid && x.GradeID == null);
|
|||
|
// if (tempShift != null)
|
|||
|
// {
|
|||
|
// dPlan = MworkPlans.FirstOrDefault(x => x.WorkPlanGroupID == tempShift.WorkPlanGroupID && x.WorkDate == EffectDate);
|
|||
|
// dPlan.EmployeeID = employeeid;
|
|||
|
|
|||
|
// }
|
|||
|
// }
|
|||
|
// return dPlan;
|
|||
|
//}
|
|||
|
|
|||
|
//private void CalcullateWorkdayType(DailyAttnProcess attnProcess, EmployeeWorkPlanSetup oEmpWorkplan, WorkPlanGroup oEmpWPlanGroup, Employee emp, DateTime Attdate)
|
|||
|
//{
|
|||
|
// List<Shift> _shifts = Shift.Get();
|
|||
|
// attnProcess.WorkDayType = EnumWorkPlanDayType.WorkingDay;
|
|||
|
// AttnShiftWiseNationalHoliday attnShiftWiseHoliday = null;
|
|||
|
|
|||
|
// if (attnProcess.MonthlyWorkPlan != null)
|
|||
|
// {
|
|||
|
// attnProcess.WorkDayType = attnProcess.MonthlyWorkPlan.Type;
|
|||
|
// // if (attnProcess.WorkDayType == EnumWorkPlanDayType.NationalHoliday) attnProcess.WorkDayType = EnumWorkPlanDayType.WorkingDay; // National holiday calaculated in bottom of function
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// if (oEmpWPlanGroup.WorkPlanGroupType != EnumWorkPlanGroupType.Triple_Shift_Auto)
|
|||
|
// {
|
|||
|
|
|||
|
// if ((oEmpWPlanGroup.WeekEndOn != null && attnProcess.AttnDate.DayOfWeek == (DayOfWeek)oEmpWPlanGroup.WeekEndOn)
|
|||
|
// || (oEmpWPlanGroup.WeekEndOn2 != null && attnProcess.AttnDate.DayOfWeek == (DayOfWeek)oEmpWPlanGroup.WeekEndOn2))
|
|||
|
// {
|
|||
|
// attnProcess.WorkDayType = EnumWorkPlanDayType.WeeklyHoliday;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// #region Counter clock
|
|||
|
// 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 || (nShiftInterval - nCircleDay - 2) == 0)
|
|||
|
// attnProcess.WorkDayType = EnumWorkPlanDayType.WeeklyHoliday;
|
|||
|
|
|||
|
// #region Do not Delete / 6 Day of Week
|
|||
|
// //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;
|
|||
|
// //}
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// Employee employee = new Employee();
|
|||
|
// employee = emp;
|
|||
|
// ID workPlanGroupID = null;
|
|||
|
// workPlanGroupID = oEmpWorkplan.WorkPlanGroupID;
|
|||
|
|
|||
|
// DateTime oLastDate = GlobalFunctions.LastDateOfMonth(Attdate);
|
|||
|
// DateTime oFirstDate = GlobalFunctions.FirstDateOfMonth(Attdate);
|
|||
|
// List<AttnNationalHoliday> _AttNHolidays = AttnNationalHoliday.GetByMonth(oFirstDate, oLastDate);
|
|||
|
|
|||
|
// AttnNationalHoliday holiday = AttnNationalHoliday.GetHoliday(_AttNHolidays, Attdate, employee.LocationID, workPlanGroupID);
|
|||
|
// if (attnProcess.WorkDayType == EnumWorkPlanDayType.NationalHoliday && holiday == null)
|
|||
|
// throw new Exception("Attandance date is defined Holiday in Monthly Calender, but not found in Holiday calender");
|
|||
|
|
|||
|
// if (holiday != null)
|
|||
|
// {
|
|||
|
// attnProcess.WorkDayType = EnumWorkPlanDayType.NationalHoliday;
|
|||
|
// attnProcess.ReferenceID = holiday.ID;
|
|||
|
// attnProcess.Holiday = holiday;
|
|||
|
// attnProcess.Reason = holiday.ID.ToString();
|
|||
|
// }
|
|||
|
|
|||
|
// if (attnProcess.WorkDayType == EnumWorkPlanDayType.WorkingDay && holiday != null && (holiday.HolidayType == HolidayType.Hartal || holiday.HolidayType == HolidayType.Other))
|
|||
|
// {
|
|||
|
// // attnProcess.WorkDayType = EnumWorkPlanDayType.HartalDay;
|
|||
|
// if (holiday.AttnShiftWiseNationalHolidays.Count == 0)
|
|||
|
// {
|
|||
|
// attnProcess.ReferenceID = holiday.ID;
|
|||
|
// attnProcess.Holiday = holiday;
|
|||
|
// attnProcess.Reason = holiday.ID.ToString();
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// attnShiftWiseHoliday = holiday.AttnShiftWiseNationalHolidays.Where(o => o.WorkPlanGroupID == attnProcess.MonthlyWorkPlan.WorkPlanGroupID).FirstOrDefault();
|
|||
|
// if (attnShiftWiseHoliday != null)
|
|||
|
// {
|
|||
|
// attnProcess.ReferenceID = holiday.ID;
|
|||
|
// attnProcess.Holiday = holiday;
|
|||
|
// attnProcess.Reason = holiday.ID.ToString();
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
|
|||
|
//}
|
|||
|
}
|
|||
|
}
|