using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.Core; using System.Data; using Ease.CoreV35.DataAccess; using HRM.BO.Configuration; namespace HRM.BO { #region DailyAttnProcess public class DailyAttnProcess : AuditTrailBase, IworkflowInterface { #region Constructor public DailyAttnProcess() { _shiftID = null; _inTime = null; _outTime = null; _workDayType = EnumWorkPlanDayType.WorkingDay; _attenType = 0; _comments = string.Empty; _isManualEntry = false; _isLate = false; _referenceID = null; _employee = null; _lateHour = 0; _earlyHour = 0; _oTHour = 0; _reason = string.Empty; _otRemarks = string.Empty; _lMRemarks = string.Empty; _approvedOTHour = 0; _wfStatus = EnumWFAttnStatus.None; _actualShiftID = 0; _lMApproveDate = null; EmpApplyDate = null; _actualInTime = null; _actualOutTime = null; _actualShiftID = null; _lineManagerID = null; _onbehalfEmpID = null; _inTimeNearestAddress = ""; } #endregion #region Properties #region LMApproveDate : DateTime private DateTime? _lMApproveDate; public DateTime? LMApproveDate { get { return _lMApproveDate; } set { _lMApproveDate = value; } } #endregion #region LineManagerID : ID private int? _lineManagerID; public int? LineManagerID { get { return _lineManagerID; } set { _lineManagerID = value; } } #endregion #region OnbehalfEmpID : ID private int? _onbehalfEmpID; public int? OnbehalfEmpID { get { return _onbehalfEmpID; } set { _onbehalfEmpID = value; } } #endregion #region EmpRemarks : string private string _empRemarks; public string EmpRemarks { get { return _empRemarks; } set { _empRemarks = value; } } #endregion #region AttendanceWFHistory private List _attendanceWFHistory; public List AttnWFHistory { get { return _attendanceWFHistory; } set { _attendanceWFHistory = value; } } #endregion #region decimal : InTimeLatitude private decimal _inTimeLatitude; public decimal InTimeLatitude { get { return _inTimeLatitude; } set { _inTimeLatitude = value; } } #endregion #region decimal : OutTimeLatitude private decimal _outTimeLatitude; public decimal OutTimeLatitude { get { return _outTimeLatitude; } set { _outTimeLatitude = value; } } #endregion #region decimal : InTimeLongitue private decimal _inTimeLongitude; public decimal InTimeLongitude { get { return _inTimeLongitude; } set { _inTimeLongitude = value; } } #endregion #region decimal : OutTimeLongitude private decimal _outTimeLongitude; public decimal OutTimeLongitude { get { return _outTimeLongitude; } set { _outTimeLongitude = value; } } #endregion #region string : InTimeNearestAddress private string _inTimeNearestAddress; public string InTimeNearestAddress { get { return _inTimeNearestAddress; } set { _inTimeNearestAddress = value; } } #endregion #region string : OutTimeNearestAddress private string _outTimeNearestAddress; public string OutTimeNearestAddress { get { return _outTimeNearestAddress; } set { _outTimeNearestAddress = value; } } #endregion #region employeeID : ID private int _employeeID; public int EmployeeID { get { return _employeeID; } set { //base.OnPropertyChange("employeeID", _employeeID, value); _employeeID = value; } } #endregion #region attnDate : DateTime private DateTime _attnDate; public DateTime AttnDate { get { return _attnDate; } set { //base.OnPropertyChange("attnDate", _attnDate, value); _attnDate = value; } } #endregion #region shiftID : ID private int? _shiftID; public int? ShiftID { get { return _shiftID; } set { //base.OnPropertyChange("shiftID", _shiftID, value); _shiftID = value; } } #endregion public string ActualInOutTime { get; set; } #region inTime : DateTime private DateTime? _inTime; public DateTime? InTime { get { return _inTime; } set { //base.OnPropertyChange("inTime", _inTime, value); _inTime = value; } } #endregion #region EmpAttenType : EnumAttendanceType private EnumAttendanceType _empAttenType; public EnumAttendanceType EmpAttenType { get { return _empAttenType; } set { _empAttenType = value; } } #endregion #region outTime : DateTime private DateTime? _outTime; public DateTime? OutTime { get { return _outTime; } set { //base.OnPropertyChange("outTime", _outTime, value); _outTime = value; } } #endregion #region actualInTime : DateTime private DateTime? _actualInTime; public DateTime? ActualInTime { get { return _actualInTime; } set { //base.OnPropertyChange("ActualInTime", _actualInTime, value); _actualInTime = value; } } #endregion #region ActualOutTime : DateTime private DateTime? _actualOutTime; public DateTime? ActualOutTime { get { return _actualOutTime; } set { //base.OnPropertyChange("ActualOutTime", _actualOutTime, value); _actualOutTime = value; } } #endregion private int? _actualShiftID; public int? ActualShiftID { get { return _actualShiftID; } set { _actualShiftID = value; } } public MonthlyWorkPlan MonthlyWorkPlan { get; set; } #region WorkDayType : EnumWorkPlanDayType private EnumWorkPlanDayType _workDayType; public EnumWorkPlanDayType WorkDayType { get { return _workDayType; } set { //base.OnPropertyChange("workDayType", (short)_workDayType, (short)value); _workDayType = value; } } #endregion #region attenType : EnumAttendanceType private EnumAttendanceType _attenType; public EnumAttendanceType AttenType { get { return _attenType; } set { //base.OnPropertyChange("attenType", (short)_attenType, (short)value); _attenType = value; } } #endregion #region comments : string private string _comments; public string Comments { get { return _comments; } set { //base.OnPropertyChange("comments", _comments, value); _comments = value; } } #endregion #region Reason : string private string _reason; public string Reason { get { return _reason; } set { _reason = value; } } #endregion #region OtRemarks : string private string _otRemarks; public string OtRemarks { get { return _otRemarks; } set { _otRemarks = value; } } #endregion #region LMRemarks : string private string _lMRemarks; public string LMRemarks { get { return _lMRemarks; } set { _lMRemarks = value; } } #endregion #region isManualEntry : bool private bool _isManualEntry; public bool IsManualEntry { get { return _isManualEntry; } set { //base.OnPropertyChange("isManualEntry", _isManualEntry, value); _isManualEntry = value; } } public bool OnlyManualInTime { get { return (this.IsManualEntry == true && this.ActualInTime != null) ? true : false;} } public bool OnlyManualOutTime { get { return (this.IsManualEntry == true && this.ActualOutTime != null) ? true : false; } } #endregion #region IsLate : bool private bool _isLate; public bool IsLate { get { return _isLate; } set { //base.OnPropertyChange("isLate", _isLate, value); _isLate = value; } } #endregion #region LateHour : double private double _lateHour; public double LateHour { get { return _lateHour; } set { //base.OnPropertyChange("LateHour", _lateHour, value); _lateHour = value; } } #endregion #region EarlyHour : double private double _earlyHour; public double EarlyHour { get { return _earlyHour; } set { //base.OnPropertyChange("EarlyHour", _earlyHour, value); _earlyHour = value; } } #endregion #region OTHour : double private double _oTHour; public double OTHour { get { return _oTHour; } set { //base.OnPropertyChange("OTHour", _oTHour, value); _oTHour = value; } } #endregion #region ApprovedOTHour : double private double _approvedOTHour; public double ApprovedOTHour { get { return _approvedOTHour; } set { //base.OnPropertyChange("ApprovedOTHour", _approvedOTHour, value); _approvedOTHour = value; } } #endregion #region referenceID : ID private int? _referenceID; public int? ReferenceID { get { return _referenceID; } set { //base.OnPropertyChange("referenceID", _referenceID, value); _referenceID = value; } } #endregion #region employee : Employee private Employee _employee; public Employee Employee { get { //if (_employeeID.Integer > 0 && _employee == null) //{ // _employee = new Employee(); // _employee = Employee.Get(_employeeID); //} return this._employee; } set { _employee = value; } } public SearchEmployee SearchEmployee { get; set; } #endregion #region Shift : Shift private Shift _shift; public Shift Shift { get { //if (_shiftID.Integer > 0 && _shift == null) //{ // _shift = new Shift(); // _shift = Shift.Get(_shiftID); //} return this._shift; } set { _shift = value; } } #endregion #region WFStatus : EnumAttendanceStatus private EnumWFAttnStatus _wfStatus; public EnumWFAttnStatus WFStatus { get { return _wfStatus; } set { _wfStatus = value; } } #endregion #region WorkHour : Double private double _workHour; public double WorkHour { get { return _workHour; } set { _workHour = value; } } #endregion //public bool IsFromMobile { get; set; } public EnumIsFromMobile IsFromMobile { get; set; } public DateTime? EmpApplyDate { get; set; } #region Commented Code //private List _attendanceWFHistory; //public List AttnWFHistory //{ // get // { // //if (this.ID != null && !this.ID.IsUnassigned && _attendanceWFHistory == null) // //{ // // _attendanceWFHistory = AttendanceWFHistory.GetByEmpID(this.ID); // //} // return _attendanceWFHistory; // } // set { _attendanceWFHistory = value; } //} //#region Service Factory IDailyAttnProcessService : IDailyAttnProcessService //internal static IDailyAttnProcessService Service //{ // get { return Services.Factory.CreateService(typeof(IDailyAttnProcessService)); } //} //#endregion #endregion public List Benifits { get; set; } //#region Functions ////public void Validate() ////{ //// if (string.IsNullOrEmpty(Comments)) //// { //// throw new CustomException(EnumExceptionType.Validation, "Remarks Cannot Be Empty"); //// } //// if (AttenType == EnumAttendanceType.Leave) //// { //// LeaveEntry oLeaveEntry = LeaveEntry.Get(AttnDate, EmployeeID); //// if (oLeaveEntry.ID.IsUnassigned) //// { //// throw new CustomException(EnumExceptionType.Validation, "Please apply for leave."); //// } //// } //// if (AttenType == EnumAttendanceType.Absent) //// { //// throw new CustomException(EnumExceptionType.Validation, "Please select a correct status."); //// } //// if (AttenType == EnumAttendanceType.WeeklyHoliday) //// { //// if (WorkDayType != EnumWorkPlanDayType.WeeklyHoliday) //// { //// throw new CustomException(EnumExceptionType.Validation, "Please select a correct status."); //// } //// } //// if (AttenType == EnumAttendanceType.Holiday) //// { //// if (WorkDayType != EnumWorkPlanDayType.NationalHoliday) //// { //// throw new CustomException(EnumExceptionType.Validation, "Please select a correct status."); //// } //// } //// if (InTime == DateTime.MinValue) //// throw new CustomException(EnumExceptionType.Validation, "You must fill in time"); //// if (OutTime == DateTime.MinValue) //// throw new CustomException(EnumExceptionType.Validation, "You must fill out time"); ////} //public static DailyAttnProcess GetAttnDataByWFStatus(int DailyAttnProcessID, EnumWFAttnStatus status) //{ // DailyAttnProcess dailyAttnProcesses = null; // try // { // dailyAttnProcesses = Service.GetAttnDataByWFStatus(DailyAttnProcessID, status); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyAttnProcesses; //} //public static ObjectsTemplate RefreshObject(Employee emp, ID id, string ddlSelectedValue, string comment, DateTime InTime, DateTime OutTime) //{ // DateTime tempDateTime = DateTime.MinValue; // DailyAttnProcess daProcess = null; // AttendanceWFHistory attnHistory = null; // ObjectsTemplate _dailyAttnProcesses = new ObjectsTemplate(); // bool isChanged = false; // EnumAttendanceType previousStatus; // DateTime previousInTime = DateTime.MinValue; // DateTime previousOutTime = DateTime.MinValue; // isChanged = false; // attnHistory = new AttendanceWFHistory(); // //previous code // //ObjectsTemplate oNotYetSubmittedAttnDatas = DailyAttnProcess.GetAttnDataByWFStatus(emp.ID.ToString(), EnumWFAttnStatus.None); // //daProcess = oNotYetSubmittedAttnDatas.Where(o => o.ID == id).FirstOrDefault(); // //for optimization // daProcess = DailyAttnProcess.GetAttnDataByWFStatus(id.Integer, EnumWFAttnStatus.None); // if (daProcess == null) // throw new CustomException(EnumExceptionType.Error, "Attendance Data Not Found"); // previousInTime = daProcess.InTime; // previousOutTime = daProcess.OutTime; // if (daProcess.ActualInTime == DateTime.MinValue) // daProcess.ActualInTime = daProcess.InTime; // if (daProcess.ActualOutTime == DateTime.MinValue) // daProcess.ActualOutTime = daProcess.OutTime; // previousStatus = daProcess.AttenType; // attnHistory.EmployeeID = daProcess.EmployeeID; // attnHistory.DailyAttnProcessID = daProcess.ID; // daProcess.IsManualEntry = true; // EnumAttendanceType value; // if (ddlSelectedValue != string.Empty) // { // value = (EnumAttendanceType)Convert.ToInt32(ddlSelectedValue); // daProcess.EmpAttenType = value; // attnHistory.AttandanceStatus = value; // if (previousStatus != value) // isChanged = true; // } // //RadNumericTextBox txtBoxApprovedOT = (RadNumericTextBox)gridItem.FindControl("numActualOT"); // //if (txtBoxApprovedOT.Text != string.Empty) // //{ // // daProcess.ApprovedOTHour = Convert.ToDouble(txtBoxApprovedOT.Text); // // daProcess.OtRemarks = daProcess.ApprovedOTHour.ToString(); // // attnHistory.OTHour = daProcess.ApprovedOTHour; // // isChanged = true; // //} // if (comment != string.Empty) // { // daProcess.Comments = comment; // attnHistory.Remarks = daProcess.Comments; // isChanged = true; // } // if (InTime != null) // { // if (InTime != DateTime.MinValue) // { // tempDateTime = InTime; // daProcess.EmpInTime = new DateTime(daProcess.AttnDate.Year, daProcess.AttnDate.Month, daProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second); // } // } // if (OutTime != null) // { // if (OutTime != DateTime.MinValue) // { // tempDateTime = OutTime; // daProcess.EmpOutTime = new DateTime(daProcess.AttnDate.Year, daProcess.AttnDate.Month, daProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second); ; // } // } // if (previousInTime != daProcess.InTime) // isChanged = true; // if (previousOutTime != daProcess.OutTime) // isChanged = true; // if (isChanged == true) // { // attnHistory.WFStatus = EnumWFAttnStatus.EmpSubmitted; // } // else // { // attnHistory.WFStatus = EnumWFAttnStatus.NotApplicable; // daProcess.WFStatus = EnumWFAttnStatus.NotApplicable; // } // daProcess.WFStatus = EnumWFAttnStatus.EmpSubmitted; // daProcess.AttnWFHistory.Add(attnHistory); // _dailyAttnProcesses.Add(daProcess); // return _dailyAttnProcesses; //} //private static EnumLateAttendanceType SetLateAttendanceType(DailyAttnProcess oDailyAttnProcess) //{ // EnumLateAttendanceType lateAttntype = EnumLateAttendanceType.NotApplicable; // DateTime Attdate = oDailyAttnProcess.AttnDate; // DateTime tInTime = oDailyAttnProcess.InTime; // DateTime tOutTime = DateTime.MinValue; // ObjectsTemplate _shifts = Shift.Get(); // Shift oShift = _shifts.Where(o => o.ID == oDailyAttnProcess.ShiftID).FirstOrDefault(); // if (oShift == null) // throw new CustomException(EnumExceptionType.Validation, "An Error Occurred From SetLateAttendanceType. oShift is empty"); // DateTime dt0_00 = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oShift.InTime.Hour, oShift.InTime.Minute, oShift.InTime.Second); // DateTime dt0_14 = dt0_00.AddMinutes(14); // dt0_14 = dt0_14.AddSeconds(59); // if (oDailyAttnProcess.InTime >= dt0_00 && oDailyAttnProcess.InTime <= dt0_14) // { // tOutTime = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oShift.OutTime.Hour, oShift.OutTime.Minute, 0); // tOutTime = tOutTime.AddMinutes(15); // if (oDailyAttnProcess.OutTime < tOutTime) // lateAttntype = EnumLateAttendanceType.Nine_0am_to_Nine_14am; // } // DateTime dt0_15 = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oShift.InTime.Hour, oShift.InTime.Minute, 0); // dt0_15 = dt0_15.AddMinutes(15); // DateTime dt0_29 = dt0_15.AddMinutes(14); // dt0_29 = dt0_29.AddSeconds(59); // if (oDailyAttnProcess.InTime >= dt0_15 && oDailyAttnProcess.InTime <= dt0_29) // { // tOutTime = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oShift.OutTime.Hour, oShift.OutTime.Minute, 0); // tOutTime = tOutTime.AddMinutes(30); // if (oDailyAttnProcess.OutTime < tOutTime) // lateAttntype = EnumLateAttendanceType.Nine_15am_to_Nine_29am; // } // DateTime dt0_30 = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oShift.InTime.Hour, oShift.InTime.Minute, oShift.InTime.Second); // dt0_30 = dt0_30.AddMinutes(30); // DateTime dt01_59 = dt0_30.AddHours(1); // dt01_59 = dt01_59.AddMinutes(29); // dt01_59 = dt01_59.AddSeconds(59); // if (oDailyAttnProcess.InTime >= dt0_30 && oDailyAttnProcess.InTime <= dt01_59) // { // lateAttntype = EnumLateAttendanceType.Nine_30am_to_Ten_59am; // } // DateTime dt02_00 = new DateTime(Attdate.Year, Attdate.Month, Attdate.Day, oShift.InTime.Hour, oShift.InTime.Minute, oShift.InTime.Second); // dt02_00 = dt02_00.AddHours(2); // DateTime dt04_30 = dt02_00.AddHours(2); // dt04_30 = dt04_30.AddMinutes(30); // if (oDailyAttnProcess.InTime >= dt02_00 && oDailyAttnProcess.InTime <= dt04_30) // { // lateAttntype = EnumLateAttendanceType.Eleven_0am_to_One_30pm; // } // return lateAttntype; //} //public static ObjectsTemplate LMRefreshObject(ID DailyAttnProcessID, EnumWFAttnStatus WFStatus) //{ // ObjectsTemplate _shifts = Shift.Get(); // DailyAttnProcess dailyAttnProcess = DailyAttnProcess.Get(DailyAttnProcessID); // if (dailyAttnProcess == null) // throw new CustomException(EnumExceptionType.Validation, "An Error Occurred From SubmitData dailyAttnProcess is empty"); // ObjectsTemplate _daPocessForSave = new ObjectsTemplate(); // dailyAttnProcess.WFStatus = WFStatus; // if (WFStatus == EnumWFAttnStatus.LMApproved) // { // dailyAttnProcess.AttenType = dailyAttnProcess.EmpAttenType; // dailyAttnProcess.InTime = dailyAttnProcess.EmpInTime; // dailyAttnProcess.OutTime = dailyAttnProcess.EmpOutTime; // dailyAttnProcess.LateAttendanceType = SetLateAttendanceType(dailyAttnProcess); // } // AttendanceWFHistory attnWFHistory = new AttendanceWFHistory(); // attnWFHistory.EmployeeID = dailyAttnProcess.EmployeeID; // attnWFHistory.DailyAttnProcessID = dailyAttnProcess.ID; // attnWFHistory.WFStatus = WFStatus; // dailyAttnProcess.SalaryMonth = SystemInformation.CurrentSysInfo.NextPayProcessDate; //SystemInformation.GetSystemMonth(SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // dailyAttnProcess.AttnWFHistory.Add(attnWFHistory); // _daPocessForSave.Add(dailyAttnProcess); // return _daPocessForSave; //} //public static ObjectsTemplate RefreshObjectDailyAttnMobile(Employee emp, ID id, EnumAttendanceType attenType, string comment, DateTime InTime, DateTime OutTime, EnumWFAttnStatus attStatus, // string ZipcodeInTime = null, string ZipcodeOutTime = null, decimal InTimeLatitude = 0, decimal OutTimeLatitude = 0, decimal InTimeLongitude = 0, decimal OutTimeLongitude = 0, string InTimeNearestAddress = null, string OutTimeNearestAddress = null) //{ // DateTime tempDateTime = DateTime.MinValue; // DailyAttnProcess daProcess = null; // AttendanceWFHistory attnHistory = null; // ObjectsTemplate _dailyAttnProcesses = new ObjectsTemplate(); // bool isChanged = false; // EnumAttendanceType previousStatus; // DateTime previousInTime = DateTime.MinValue; // DateTime previousOutTime = DateTime.MinValue; // isChanged = false; // attnHistory = new AttendanceWFHistory(); // //previous code // //ObjectsTemplate oNotYetSubmittedAttnDatas = DailyAttnProcess.GetAttnDataByWFStatus(emp.ID.ToString(), EnumWFAttnStatus.None); // //daProcess = oNotYetSubmittedAttnDatas.Where(o => o.ID == id).FirstOrDefault(); // //for optimization // daProcess = DailyAttnProcess.Get(id); // if (daProcess == null) // throw new CustomException(EnumExceptionType.Error, "Attendance Data Not Found"); // previousInTime = daProcess.InTime; // previousOutTime = daProcess.OutTime; // if (daProcess.ActualInTime == DateTime.MinValue) // daProcess.ActualInTime = daProcess.InTime; // if (daProcess.ActualOutTime == DateTime.MinValue) // daProcess.ActualOutTime = daProcess.OutTime; // previousStatus = daProcess.AttenType; // attnHistory.EmployeeID = daProcess.EmployeeID; // attnHistory.DailyAttnProcessID = daProcess.ID; // daProcess.IsManualEntry = true; // if ((int)attenType != 0) // { // daProcess.EmpAttenType = attenType; // attnHistory.AttandanceStatus = attenType; // if (previousStatus != attenType) // isChanged = true; // } // //RadNumericTextBox txtBoxApprovedOT = (RadNumericTextBox)gridItem.FindControl("numActualOT"); // //if (txtBoxApprovedOT.Text != string.Empty) // //{ // // daProcess.ApprovedOTHour = Convert.ToDouble(txtBoxApprovedOT.Text); // // daProcess.OtRemarks = daProcess.ApprovedOTHour.ToString(); // // attnHistory.OTHour = daProcess.ApprovedOTHour; // // isChanged = true; // //} // if (comment != string.Empty) // { // daProcess.Comments = comment; // attnHistory.Remarks = daProcess.Comments; // isChanged = true; // } // if (InTime != null) // { // if (InTime != DateTime.MinValue) // { // tempDateTime = InTime; // daProcess.EmpInTime = new DateTime(daProcess.AttnDate.Year, daProcess.AttnDate.Month, daProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second); // } // } // if (OutTime != null) // { // if (OutTime != DateTime.MinValue) // { // tempDateTime = OutTime; // daProcess.EmpOutTime = new DateTime(daProcess.AttnDate.Year, daProcess.AttnDate.Month, daProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second); ; // } // } // if (previousInTime != daProcess.InTime) // isChanged = true; // if (previousOutTime != daProcess.OutTime) // isChanged = true; // if (isChanged == true) // { // attnHistory.WFStatus = attStatus; // } // else // { // attnHistory.WFStatus = EnumWFAttnStatus.NotApplicable; // daProcess.WFStatus = EnumWFAttnStatus.NotApplicable; // } // daProcess.ZipcodeInTime = ZipcodeInTime == null ? string.Empty : ZipcodeInTime; // daProcess.ZipcodeOutTime = ZipcodeOutTime == null ? string.Empty : ZipcodeOutTime; // daProcess.InTimeLatitude = InTimeLatitude; // daProcess.OutTimeLatitude = OutTimeLatitude; // daProcess.InTimeLongitude = InTimeLongitude; // daProcess.OutTimeLongitude = OutTimeLongitude; // daProcess.InTimeNearestAddress = InTimeNearestAddress == null ? string.Empty : InTimeNearestAddress; // daProcess.OutTimeNearestAddress = OutTimeNearestAddress == null ? string.Empty : OutTimeNearestAddress; // daProcess.WFStatus = attStatus; // daProcess.AttnWFHistory.Add(attnHistory); // _dailyAttnProcesses.Add(daProcess); // return _dailyAttnProcesses; //} //public static void SaveAutoForLmApproved(ObjectsTemplate dailyattProcesses, ObjectsTemplate oAtnMonthlyBenifits, AttnProcessRunSummary oAttnRunSummary, TransactionContext tc) //{ // foreach (DailyAttnProcess dAttnProcess in dailyattProcesses) // { // dAttnProcess.SetAuditTrailProperties(); // } // DailyAttnProcess.Service.SaveAutoForLmApproved(dailyattProcesses, oAtnMonthlyBenifits, oAttnRunSummary, tc); //} //public static ObjectsTemplate GetManualProcess(DateTime attnDate, int payrollType) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["GetManualProcess", attnDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.GetManualProcess(attnDate, payrollType); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "GetManualProcess", attnDate); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate Get(DateTime attnDate, int payrollType) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", attnDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(attnDate, payrollType); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", attnDate); // #endregion // return dailyAttnProcesses; //} //public static DateTime GetLastProcessDate(int payrollType) //{ // DateTime lastProcessDate = DateTime.MinValue; // try // { // lastProcessDate = DailyAttnProcess.Service.GetLastProcessDate(payrollType); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return lastProcessDate; //} //public void ValidateObject() //{ // if (EmpRequestAttenType == EnumAttendanceType.None) // throw new CustomException(EnumExceptionType.Error, "Please select a status other than None."); // if (EmpRequestAttenType == EnumAttendanceType.Absent) // throw new CustomException(EnumExceptionType.Error, "Please select a status other than Absent."); // if (EmpRemarks == string.Empty) // throw new CustomException(EnumExceptionType.Error, "Please write a remarks."); // if (EmpRequestInTime == DateTime.MinValue) // throw new CustomException(EnumExceptionType.Error, "InTime can not be empty."); // if (EmpRequestOutTime == DateTime.MinValue) // throw new CustomException(EnumExceptionType.Error, "OutTime can not be empty."); // //if (GlobalFunctions.ApplyValidation(AttnDate)) // // throw new CustomException(EnumExceptionType.Error, "You can not apply for the previous month at this time while salary process is not completed yet"); //} //public static DailyAttnProcess RefreshObject(DailyAttnProcess dAttProcess, string txtComments, ObjectsTemplate empWPGroups, DateTime inTime, DateTime outTime, int ddlStatus, int ddlShift) //{ // DateTime tempDateTime = DateTime.MinValue; // ObjectsTemplate _shifts = Shift.Get(); // DateTime previousInTime = dAttProcess.InTime; // DateTime previousOutTime = dAttProcess.OutTime; // dAttProcess.EmpRemarks = txtComments; // dAttProcess.ClaimWFStatus = EnumClaimWFStatus.EmpSubmitted; // dAttProcess.EmpSubmitDate = DateTime.Now; // ObjectsTemplate _tempraryShifts = ActingResponsibilitySetup.GetTemporaryShiftEmployee(dAttProcess.AttnDate); // ActingResponsibilitySetup tempShiftEmployee = _tempraryShifts.Where(o => o.EmployeeID == dAttProcess.EmployeeID).FirstOrDefault(); // ObjectsTemplate _monthlyWorkPlans = MonthlyWorkPlan.GetByDate(dAttProcess.AttnDate); // MonthlyWorkPlan oMWPlan = null; // if (tempShiftEmployee != null) // oMWPlan = MonthlyWorkPlan.GetPlanwithEmployee(dAttProcess.AttnDate, dAttProcess.EmployeeID, empWPGroups, _monthlyWorkPlans, _tempraryShifts); // else // oMWPlan = MonthlyWorkPlan.GetPlanwithEmployee(dAttProcess.AttnDate, dAttProcess.EmployeeID, empWPGroups, _monthlyWorkPlans, null); // if (inTime != DateTime.MinValue) // { // if (inTime != null) // { // tempDateTime = inTime; // dAttProcess.EmpRequestInTime = new DateTime(dAttProcess.AttnDate.Year, dAttProcess.AttnDate.Month, dAttProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second); // } // } // if (outTime != DateTime.MinValue) // { // if (outTime != null) // { // tempDateTime = outTime; // dAttProcess.EmpRequestOutTime = new DateTime(dAttProcess.AttnDate.Year, dAttProcess.AttnDate.Month, dAttProcess.AttnDate.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second); ; // } // } // if (inTime != DateTime.MinValue) // { // dAttProcess.InTime = inTime; // } // if (outTime != DateTime.MinValue) // { // dAttProcess.OutTime = outTime; // } // EnumAttendanceType value; // Shift sft = new Shift(); // if (ddlShift != -1) // { // sft = _shifts.Where(o => o.ID.Integer == Convert.ToInt32(ddlShift)).FirstOrDefault(); // dAttProcess.EmpRequestShiftID = sft == null ? Ease.CoreV35.Model.ID.FromInteger(0) : sft.ID; // } // if (dAttProcess.EmpRequestInTime != DateTime.MinValue && dAttProcess.EmpRequestOutTime != DateTime.MinValue && (previousInTime != dAttProcess.EmpRequestInTime) || (previousOutTime != dAttProcess.EmpRequestOutTime)) // { // if (sft != null && sft.IsOverlapingDay) // { // if (dAttProcess.EmpRequestInTime > dAttProcess.EmpRequestOutTime) // dAttProcess.EmpRequestOutTime = dAttProcess.EmpRequestOutTime.AddDays(1); // } // } // if (oMWPlan != null && oMWPlan.Type == EnumWorkPlanDayType.WeeklyHoliday) // dAttProcess.EmpRequestAttenType = EnumAttendanceType.WeeklyHoliday; // else if (oMWPlan != null && oMWPlan.Type == EnumWorkPlanDayType.NationalHoliday) // dAttProcess.EmpRequestAttenType = EnumAttendanceType.Holiday; // else // { // if (ddlStatus != -1) // { // value = (EnumAttendanceType)Convert.ToInt32(ddlStatus); // dAttProcess.EmpRequestAttenType = value; // } // } // return dAttProcess; //} //public static ObjectsTemplate GetByStatus(ID empID, DateTime fromDate, DateTime toDate, string status) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["GetByStatus", empID, fromDate, toDate, status] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.GetByStatus(empID, fromDate, toDate, status); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "GetByStatus", empID, fromDate, toDate, status); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate Get(string empID, DateTime fromDate, DateTime toDate, EnumClaimWFStatus status) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", empID, fromDate, toDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(empID, fromDate, toDate, status); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", empID, fromDate, toDate); // #endregion // return dailyAttnProcesses; //} //public static DataTable GetAttnData(ID employeeID, DateTime fromdate, DateTime toDate) //{ // DataTable attnDataDT = null; // try // { // attnDataDT = Service.GetAttnData(employeeID, fromdate, toDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return attnDataDT; //} //public static DataTable GetAttnData(ID employeeID, DateTime fromdate, DateTime toDate, string status) //{ // DataTable attnDataDT = null; // try // { // attnDataDT = Service.GetAttnData(employeeID, fromdate, toDate, status); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return attnDataDT; //} //public static DataTable GetTeamMembersAttnData(string sEmpID, DateTime fromdate, DateTime toDate, EnumClaimWFStatus empSubmitStatus) //{ // DataTable attnDataDT = null; // try // { // attnDataDT = Service.GetTeamMembersAttnData(sEmpID, fromdate, toDate, empSubmitStatus); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return attnDataDT; //} //public static DataTable GetTeamMembersAttnData(ID employeeID, DateTime fromdate, DateTime toDate, EnumClaimWFStatus empSubmitStatus) //{ // DataTable attnDataDT = null; // try // { // attnDataDT = Service.GetTeamMembersAttnData(employeeID, fromdate, toDate, empSubmitStatus); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return attnDataDT; //} //public static ObjectsTemplate GetBySalaryMonth(DateTime salaryMonth) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", salaryMonth] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.GetBySalaryMonth(salaryMonth, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", salaryMonth); // #endregion // return dailyAttnProcesses; //} //public static void UpdateLateAttnBenefitStatus(ObjectsTemplate dailyattProcesses) //{ // DailyAttnProcess.Service.UpdateLateAttnBenefitStatus(dailyattProcesses); //} //public static DailyAttnProcess ProcessAttendanceForSingleEmployeeToday(Employee employee, GeoCoordinate coordinate, EnumAttendanceType attnType) //{ // DailyAttnProcess attnProcess = new DailyAttnProcess(); // attnProcess.AttnDate = DateTime.Today; // attnProcess.EmployeeID = employee.ID; // attnProcess.IsManualEntry = true; // attnProcess.EmpAttenType = attnType; // attnProcess.AttenType = attnType; // //attnProcess. = oDailyAttnProcessTmodel.AttenType; // attnProcess.EmployeeID = employee.ID; // attnProcess.WFStatus = EnumWFAttnStatus.EmpInTimeSubmitted; // attnProcess.EmpInTime = DateTime.Now; // //if (!coordinate.IsUnknown) // //{ // // attnProcess.InTimeLatitude = (decimal)coordinate.Latitude; // // attnProcess.InTimeLongitude = (decimal)coordinate.Longitude; // //} // //else // //{ // // throw new CustomException(EnumExceptionType.Error, "Location has not been set"); // //} // //attnProcess.InTimeLatitude = (decimal)23.7487; // //attnProcess.InTimeLongitude = (decimal)90.3683; // EmployeeWorkPlanSetup oEmpWorkplanSetup = EmployeeWorkPlanSetup.GetByEmpID(employee.ID); // if (oEmpWorkplanSetup == null) // { // throw new CustomException(EnumExceptionType.Error, "Employee Not Assigned in work plan setup"); // } // ObjectsTemplate workPlanGroups = WorkPlanGroup.Get(); // WorkPlanGroup oEmpWPlanGroup = workPlanGroups.Where(o => o.ID.Integer == oEmpWorkplanSetup.WorkPlanGroupID.Integer) // .Single(); // CalcullateWorkdayType(attnProcess, oEmpWorkplanSetup, oEmpWPlanGroup, employee, attnProcess.AttnDate); // Shift oShift = CalculateShift(oEmpWPlanGroup, attnProcess, attnProcess.AttnDate, employee, oEmpWorkplanSetup); // CalculateLateAttendance(attnProcess, oShift, attnProcess.AttnDate); // return attnProcess; //} //private static void CalcullateWorkdayType(DailyAttnProcess attnProcess, EmployeeWorkPlanSetup oEmpWorkplan, WorkPlanGroup oEmpWPlanGroup, Employee emp, DateTime Attdate) //{ // ObjectsTemplate _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; // //ID shiftID = null; // //if (attnProcess.TempShiftID == null) // // shiftID = attnProcess.ShiftID; // //else // // shiftID = attnProcess.TempShiftID; // DateTime oLastDate = GlobalFunctions.LastDateOfMonth(Attdate); // DateTime oFirstDate = GlobalFunctions.FirstDateOfMonth(Attdate); // ObjectsTemplate _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.NationalHoliday && 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(); // } // } // //Hortal Time Range Business Logic Start Here //Need to Debug // //DateTime hortalFromTime = holiday.FromTime; // //DateTime hortalToTime = holiday.ToTime; // //DateTime shiftInTime = new DateTime(attnProcess.AttnDate.Year, attnProcess.AttnDate.Month, attnProcess.AttnDate.Day, attnProcess.Shift.InTime.Hour, attnProcess.Shift.InTime.Minute, attnProcess.Shift.InTime.Second); // //DateTime shiftOutTime = DateTime.MinValue; // //if (attnProcess.Shift.InTime.Hour > 16) // // shiftOutTime = shiftInTime.AddDays(1); // //else // // shiftOutTime = shiftInTime; // //shiftOutTime = new DateTime(shiftOutTime.Year, shiftOutTime.Month, shiftOutTime.Day, attnProcess.Shift.OutTime.Hour, attnProcess.Shift.OutTime.Minute, attnProcess.Shift.OutTime.Second); // //if ((shiftInTime >= hortalFromTime && shiftInTime < hortalToTime) || (shiftOutTime > hortalFromTime && shiftOutTime <= hortalToTime)) // //{ // // // "Hortal"; // //} // //else // //{ // // // "No Hortal"; // //} // //Hortal Time Range Business Logic End Here // } // //if (attnProcess.WorkDayType != EnumWorkPlanDayType.WeeklyHoliday) // //{ // // if (_AttNHolidays.Count > 0) // // oAttNHoliday = _AttNHolidays.Where(o => attnProcess.AttnDate.Date >= o.FromDate.Date && attnProcess.AttnDate.Date <= o.ToDate.Date).FirstOrDefault(); // // if (oAttNHoliday != null && oAttNHoliday.AttnNationalHolidayLocations.Count==0) // // { // // attnProcess.WorkDayType = EnumWorkPlanDayType.NationalHoliday; // // attnProcess.ReferenceID = oAttNHoliday.ID; // // attnProcess.Holiday = oAttNHoliday; // // return; // // } // // if (oAttNHoliday != null && oAttNHoliday.AttnNationalHolidayLocations.Count > 0) // // { // // employee = new Employee(); // // employee = employees.Where(o => o.ID == attnProcess.EmployeeID).FirstOrDefault(); // // foreach (AttnNationalHolidayLocation anHoliday in oAttNHoliday.AttnNationalHolidayLocations) // // { // // if (anHoliday.LocationID == employee.LocationID) // // { // // attnProcess.WorkDayType = EnumWorkPlanDayType.NationalHoliday; // // attnProcess.ReferenceID = oAttNHoliday.ID; // // attnProcess.Holiday = oAttNHoliday; // // } // // else // // { // // attnProcess.WorkDayType = EnumWorkPlanDayType.WorkingDay; // // } // // } // // } // //} //} //private static void CalculateLateAttendance(DailyAttnProcess attnProcess, Shift oShift, 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; // if (oShift != null) // _lateHour = (attnProcess.InTime.TimeOfDay.Subtract(oShift.InTime.TimeOfDay).TotalMinutes) / 60; // attnProcess.LateHour = _lateHour; // } // } //} //private static 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 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 static Shift CalculateShift(WorkPlanGroup oEmpWPlanGroup, DailyAttnProcess attnProcess, DateTime Attdate, Employee emp, EmployeeWorkPlanSetup oEmpWorkplanSetup) //{ // #region Calculate Particular Shift Based On WorkPlan Group Type // Shift oShift = null; // ObjectsTemplate monthlyWorkPlans = MonthlyWorkPlan.GetByDate(Attdate); // ObjectsTemplate _tempraryShifts = new ObjectsTemplate(); // MonthlyWorkPlan mplan = null; // ActingResponsibilitySetup tempShiftEmployee = null; //_tempraryShifts.Where(o => o.EmployeeID == attnProcess.EmployeeID).FirstOrDefault(); // ObjectsTemplate shifts = Shift.Get(); // ObjectsTemplate CounterClockRotation = ShiftRotation.Get(EnumWorkPlanGroupType.Fixed); // ObjectsTemplate CounterClock2Rotation = ShiftRotation.Get(EnumWorkPlanGroupType.Double_Shift_Fixed); // ObjectsTemplate CounterClock3Rotation = ShiftRotation.Get(EnumWorkPlanGroupType.Triple_Shift_Fixed); // ObjectsTemplate CounterClock4Rotation = ShiftRotation.Get(EnumWorkPlanGroupType.Triple_Shift_Auto); // if (oEmpWPlanGroup.WorkPlanGroupType == EnumWorkPlanGroupType.Fixed || oEmpWPlanGroup.WorkPlanGroupType == EnumWorkPlanGroupType.Exception) // { // 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 // { // ObjectsTemplate osrs; // if (oEmpWPlanGroup.WorkPlanGroupType == EnumWorkPlanGroupType.Double_Shift_Fixed) // osrs = CounterClock2Rotation; // else if (oEmpWPlanGroup.WorkPlanGroupType == EnumWorkPlanGroupType.Triple_Shift_Fixed) // osrs = CounterClock3Rotation; // else if (oEmpWPlanGroup.WorkPlanGroupType == EnumWorkPlanGroupType.Triple_Shift_Auto) // 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 // return oShift; //} //private static MonthlyWorkPlan GetPlanwithEmployee(DateTime EffectDate, ID employeeid, EmployeeWorkPlanSetup plans, ObjectsTemplate MworkPlans, ObjectsTemplate temporaryShiftEmps) //{ // MonthlyWorkPlan dPlan = null; // if (temporaryShiftEmps == null) // { // EmployeeWorkPlanSetup workGroup = plans; // if (workGroup != null) // { // dPlan = MworkPlans.FirstOrDefault(x => x.WorkPlanGroupID.Integer == workGroup.WorkPlanGroupID.Integer && x.WorkDate == EffectDate); // dPlan.EmployeeID = employeeid.Integer; // } // } // else // { // ActingResponsibilitySetup tempShift = temporaryShiftEmps.FirstOrDefault(x => x.EmployeeID.Integer == employeeid.Integer && x.GradeID == null); // if (tempShift != null) // { // dPlan = MworkPlans.FirstOrDefault(x => x.WorkPlanGroupID.Integer == tempShift.WorkPlanGroupID.Integer && x.WorkDate == EffectDate); // dPlan.EmployeeID = employeeid.Integer; // } // } // return dPlan; //} //public static DailyAttnProcess Get(ID nID) //{ // DailyAttnProcess oDailyAttnProcess = null; // #region Cache Header // oDailyAttnProcess = (DailyAttnProcess)_cache["Get", nID]; // if (oDailyAttnProcess != null) // return oDailyAttnProcess; // #endregion // oDailyAttnProcess = DailyAttnProcess.Service.Get(nID); // #region Cache Footer // _cache.Add(oDailyAttnProcess, "Get", nID); // #endregion // return oDailyAttnProcess; //} //public static DailyAttnProcess Get(int empId, DateTime attnDate) //{ // DailyAttnProcess oDailyAttnProcess = null; // #region Cache Header // oDailyAttnProcess = (DailyAttnProcess)_cache["Get", empId]; // if (oDailyAttnProcess != null) // return oDailyAttnProcess; // #endregion // oDailyAttnProcess = DailyAttnProcess.Service.Get(empId, attnDate); // #region Cache Footer // _cache.Add(oDailyAttnProcess, "Get", empId); // #endregion // return oDailyAttnProcess; //} //public static ObjectsTemplate Get() //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get"] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get"); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate GetByEmployeeID(ID employeeID) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get"] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.GetByEmployeeID(employeeID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get"); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate GetEmpMonthlySchedule(DateTime fromDate, DateTime toDate, EnumWorkPlanGroup _workGroup) //{ // ObjectsTemplate empWorkPlanSetups = EmployeeWorkPlanSetup.Get(_workGroup); // ObjectsTemplate dailyattProcesses = new ObjectsTemplate(); // ObjectsTemplate shiftRotations = ShiftRotation.Get(_workGroup); // DailyAttnProcess daProcess = new DailyAttnProcess(); // foreach (EmployeeWorkPlanSetup esetup in empWorkPlanSetups) // { // TimeSpan timeInterval = esetup.StartDate - toDate; // int ti = timeInterval.Days; // DateTime empStartDate = esetup.StartDate; // for (DateTime startdate = empStartDate; startdate <= toDate; startdate = startdate.AddDays(1)) // { // TimeSpan timespan = startdate - empStartDate; // int tSpan = timespan.Days; // daProcess = new DailyAttnProcess(); // daProcess.EmployeeID = esetup.EmployeeID; // daProcess.AttnDate = startdate; // if (tSpan >= 0 && tSpan < 8) // { // daProcess.ShiftID = esetup.ShiftID; // } // if (tSpan >= 8 && tSpan < 16) // { // shiftRotations[1].ShiftID = esetup.ShiftID; // } // if (tSpan >= 16 && tSpan < 24) // { // shiftRotations[2].ShiftID = esetup.ShiftID; // if (tSpan == 23) // { // empStartDate.AddDays(24); // } // } // int nShiftInterval = 8; // TimeSpan st = startdate - empStartDate; // int dayCount = st.Days; // int nCircleDay = (dayCount % nShiftInterval); // if ((nShiftInterval - nCircleDay - 1) == 0 || (nShiftInterval - nCircleDay - 2) == 0) // { // daProcess.WorkDayType = EnumWorkPlanDayType.WeeklyHoliday; // } // dailyattProcesses.Add(daProcess); // } // } // return dailyattProcesses; //} //public static ObjectsTemplate GetProcessByWPG(EnumWorkPlanGroup wpg, DateTime attnDate) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["GetProcessByWPG", wpg, attnDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.GetProcessByWPG(wpg, attnDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "GetProcessByWPG", wpg, attnDate); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate Get(DateTime attnDate) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", attnDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(attnDate, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", attnDate); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate Get(DateTime attnDate, string empids) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", attnDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(attnDate, empids, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", attnDate); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate GetManualProcess(DateTime attnDate) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["GetManualProcess", attnDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.GetManualProcess(attnDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "GetManualProcess", attnDate); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate Get(ID empID, DateTime fromDate, DateTime toDate) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", empID, fromDate, toDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(empID, fromDate, toDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", empID, fromDate, toDate); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate Get(string empID, DateTime fromDate, DateTime toDate) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", empID, fromDate, toDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(empID, fromDate, toDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", empID, fromDate, toDate); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate Get(DateTime fromDate, DateTime toDate) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", fromDate, toDate] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(fromDate, toDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", fromDate, toDate); // #endregion // return dailyAttnProcesses; //} //public static ObjectsTemplate Get(DateTime attnDate, ID shiftID, EnumAttendanceType attnType) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["Get", attnDate, shiftID, attnType] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.Get(attnDate, shiftID, attnType); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "Get", attnDate, shiftID, attnType); // #endregion // return dailyAttnProcesses; //} //public static int GetAttnDataByWFStatusCount(DateTime fromdate, DateTime toDate, EnumWFAttnStatus status) //{ // try // { // return Service.GetAttnDataByWFStatusCount(fromdate, toDate, status); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } //} //public ID Save() //{ // this.SetAuditTrailProperties(); // return DailyAttnProcess.Service.Save(this); //} //public static void Save(ObjectsTemplate dAttnProcessess) //{ // foreach (DailyAttnProcess dAttnProcess in dAttnProcessess) // { // dAttnProcess.SetAuditTrailProperties(); // } // DailyAttnProcess.Service.Save(dAttnProcessess); //} //public static void Save(ObjectsTemplate dAttnProcessess, bool IscounterClock) //{ // foreach (DailyAttnProcess dAttnProcess in dAttnProcessess) // { // dAttnProcess.SetAuditTrailProperties(); // } // DailyAttnProcess.Service.Save(dAttnProcessess, IscounterClock); //} //public static void Save(ObjectsTemplate dAttnProcessess, ObjectsTemplate attnMonthlyBenefits, bool IscounterClock) //{ // foreach (DailyAttnProcess dAttnProcess in dAttnProcessess) // { // dAttnProcess.SetAuditTrailProperties(); // } // DailyAttnProcess.Service.Save(dAttnProcessess, attnMonthlyBenefits, IscounterClock); //} //public static void SaveAuto(ObjectsTemplate dailyattProcesses, ObjectsTemplate oAtnMonthlyBenifits, AttnProcessRunSummary oAttnRunSummary) //{ // foreach (DailyAttnProcess dAttnProcess in dailyattProcesses) // { // dAttnProcess.SetAuditTrailProperties(); // } // DailyAttnProcess.Service.SaveAuto(dailyattProcesses, oAtnMonthlyBenifits, oAttnRunSummary); //} //public static void SaveForBridgeHoliday(ObjectsTemplate dailyattProcesses, ObjectsTemplate oLeaveEntrys) //{ // foreach (DailyAttnProcess dAttnProcess in dailyattProcesses) // { // dAttnProcess.SetAuditTrailProperties(); // } // DailyAttnProcess.Service.SaveForBridgeHoliday(dailyattProcesses, oLeaveEntrys); //} ////new //public static ObjectsTemplate GetWhrOutTimeIsNull(DateTime attnDate, ID shiftID) //{ // #region Cache Header // ObjectsTemplate dailyAttnProcesses = _cache["GetWhrOutTimeIsNull", attnDate, shiftID] as ObjectsTemplate; // if (dailyAttnProcesses != null) // return dailyAttnProcesses; // #endregion // try // { // dailyAttnProcesses = Service.GetWhrOutTimeIsNull(attnDate, shiftID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(dailyAttnProcesses, "GetWhrOutTimeIsNull", attnDate, shiftID); // #endregion // return dailyAttnProcesses; //} //// //#region Process ///* //public void Process(DateTime Attdate) //{ // //making date time // try // { // DateTime fromDate = Attdate.Subtract(Attdate.TimeOfDay).Subtract(new TimeSpan(2, 0, 0)); // DateTime toDate = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).Add(new TimeSpan(12, 0, 0)); // ////for test // //Employee E = Employee.Get(ID.FromInteger(4364)); // //ObjectsTemplate employees = new ObjectsTemplate(); // //employees.Add(E); // //ObjectsTemplate employees = Employee.GetByEmpIDs("4364"); // ////// // ObjectsTemplate employees = Employee.Get(); // ObjectsTemplate attRawdatas = AttnRawData.Get(fromDate, toDate);// get raw data by a date and order by date, employee, punchTime // ObjectsTemplate dailyattProcesses = new ObjectsTemplate(); // ObjectsTemplate outSideDuties = EmployeeOutsideDuty.Get(Attdate); // get transaction by the a rate // ObjectsTemplate monthlyWorkPlans = MonthlyWorkPlan.Get(Attdate); // get workplans by the date // ObjectsTemplate leaves = LeaveEntry.Get(Attdate); // workplans by the date // ObjectsTemplate buyers = BuyerSetup.Get(); // ObjectsTemplate bDailyattProcesses = new ObjectsTemplate(); // ObjectsTemplate shifts = Shift.Get(); // ObjectsTemplate workPlanGroups = WorkPlanGroup.Get(); // #region Process // foreach (Employee emp in employees) // { // if (monthlyWorkPlans == null || monthlyWorkPlans.Count == 0) // { // //MessageBox.Show("Please Set up Monthly work plan", "Monthly work plan", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; // } // DailyAttnProcess attnProcess = new DailyAttnProcess(); // attnProcess.AttnDate = Attdate; // attnProcess.EmployeeID = emp.ID; // attnProcess.IsManualEntry = false; // _lateHour = 0; // _earlyHour = 0; // _oTHour = 0; // MonthlyWorkPlan empMonthlyWorkPlan = null; // List empAttnDatas = null; // EmployeeOutsideDuty empOutsideDuty = null; // LeaveEntry empLeaveEntry = null; // if (attRawdatas != null && attRawdatas.Count > 0) // { // var attnDatas = from AttnRawData item in attRawdatas // where item.EmployeeID == emp.ID // select item; // if (attnDatas.ToList().Count > 0) // { // empAttnDatas = attnDatas.ToList(); // } // } // if (outSideDuties != null && outSideDuties.Count > 0) // { // var outSideDuty = from EmployeeOutsideDuty item in outSideDuties // where item.EmployeeID == emp.ID // select item; // if (outSideDuty.ToList().Count > 0) // { // empOutsideDuty = outSideDuty.FirstOrDefault(); // } // } // if (leaves != null && leaves.Count > 0) // { // var leave = from LeaveEntry item in leaves // where item.EmpID == emp.ID.Integer // select item; // if (leave.ToList().Count > 0) // { // empLeaveEntry = leave.FirstOrDefault(); // } // } // if (monthlyWorkPlans != null && monthlyWorkPlans.Count > 0) // { // empMonthlyWorkPlan = monthlyWorkPlans.Find(delegate(MonthlyWorkPlan item) // { return item.EmployeeID == emp.ID && item.WorkDate.ToString("dd MMM yyyy") == Attdate.ToString("dd MMM yyyy"); }); // if (empMonthlyWorkPlan != null) // { // if (!empMonthlyWorkPlan.ShiftID.IsUnassigned) // { // attnProcess.ShiftID = empMonthlyWorkPlan.ShiftID; // } // if (!empMonthlyWorkPlan.HolidayID.IsUnassigned) // { // attnProcess.ReferenceID = empMonthlyWorkPlan.HolidayID; // } // } // else // { // continue; // } // } // if (empAttnDatas != null && attnProcess.ShiftID.Integer != 0) // { // Shift oshift = shifts.GetItem(attnProcess.ShiftID); // DateTime shiftIntimeStart = Attdate.Subtract(Attdate.TimeOfDay).AddHours(oshift.InTime.Hour).AddMinutes(oshift.InTime.Minute).Subtract(new TimeSpan(2, 0, 0)); // DateTime shiftIntimeEnd = Attdate.Subtract(Attdate.TimeOfDay).AddHours(oshift.InTime.Hour).AddMinutes(oshift.InTime.Minute).Add(new TimeSpan(4, 0, 0)); // DateTime shiftOutTimeEnd = DateTime.MinValue; // if (oshift.InTime > oshift.OutTime) // { // shiftOutTimeEnd = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).AddHours(oshift.OutTime.Hour).AddMinutes(oshift.OutTime.Minute).Add(new TimeSpan(6, 0, 0)); // } // else // { // shiftOutTimeEnd = Attdate.Subtract(Attdate.TimeOfDay).AddHours(oshift.OutTime.Hour).AddMinutes(oshift.OutTime.Minute).Add(new TimeSpan(6, 0, 0)); // } // bool inTime = false; // foreach (AttnRawData attndata in empAttnDatas) // { // 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; // } // //if (inTime == true && attnProcess.OutTime == DateTime.MinValue) // //{ // // if (oshift.InTime > oshift.OutTime) // // { // // attnProcess.OutTime = Attdate.AddDays(1).Subtract(Attdate.TimeOfDay).AddHours(oshift.OutTime.Hour).AddMinutes(oshift.OutTime.Minute); // // } // // else // // { // // attnProcess.OutTime = Attdate.Subtract(Attdate.TimeOfDay).AddHours(oshift.OutTime.Hour).AddMinutes(oshift.OutTime.Minute); // // } // //} // } // //attnProcess.InTime = empAttnDatas[0].PunchTime; // //attnProcess.OutTime = empAttnDatas[empAttnDatas.Count - 1].PunchTime; // if (attnProcess.InTime != DateTime.MinValue && !attnProcess.ShiftID.IsUnassigned && attnProcess.ShiftID.Integer != 0) // { // attnProcess.AttenType = GetAttnType(attnProcess.InTime, attnProcess.OutTime, oshift, Attdate, empMonthlyWorkPlan); // if (emp.IsEligibleOT) // { // attnProcess.LateHour = _lateHour; // attnProcess.EarlyHour = _earlyHour; // attnProcess.OTHour = _oTHour; // } // } // else if (!attnProcess.ReferenceID.IsUnassigned && attnProcess.ReferenceID.Integer != 0) // { // attnProcess.AttenType = EnumAttendanceType.Holiday; // } // } // 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.ID; // } // 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; // } // } // dailyattProcesses.Add(attnProcess); // #region BuyerWise Process // 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; // 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.CounterClock) // { // 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); // //there are some fixed type employee whose OT should not be Calculated // if (attnProcess.InTime != DateTime.MinValue && (workPlanGroup.Type == EnumWorkPlanGroup.CounterClock || empMonthlyWorkPlan.WorkPlanGroupID.Integer == 4)) // { // int rand = 0; // Random rd = new Random(); // rand = rd.Next(0, 15); // bDailyAttnProcess.InTime = Attdate.Subtract(Attdate.TimeOfDay).Add(attnProcess.Shift.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(attnProcess.Shift.OutTime.TimeOfDay).AddMinutes(Convert.ToDouble(rand)); // } // else // { // bDailyAttnProcess.OutTime = Attdate.Subtract(Attdate.TimeOfDay).Add(attnProcess.Shift.OutTime.TimeOfDay).AddMinutes(Convert.ToDouble(rand)); // } // bDailyAttnProcess.ReferenceID = attnProcess.ReferenceID; // bDailyAttnProcess.EarlyHour = 0; // bDailyAttnProcess.LateHour = 0; // bDailyAttnProcess.OTHour = 0; // bDailyAttnProcess.AttenType = EnumAttendanceType.Present; // } // else // { // 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); // 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; // } // } // } // //if (bDailyAttnProcess.AttenType == EnumAttendanceType.Present || bDailyAttnProcess.AttenType == EnumAttendanceType.Delay || bDailyAttnProcess.AttenType == EnumAttendanceType.Late) // //{ // // if (attnProcess.Shift == null) // // { // // attnProcess.ShiftID = defaultShift.ID; // // } // // bDailyAttnProcess.OutTime = attnProcess.Shift.OutTime.Add(TimeSpan.FromHours(bDailyAttnProcess.OTHour)); // //} // //else // //{ // // bDailyAttnProcess.OutTime = attnProcess.OutTime; // //} // bDailyattProcesses.Add(bDailyAttnProcess); // } // } // if (dailyattProcesses.Count == 0) // { // return; // } // #endregion // DailyAttnProcess.Save(dailyattProcesses); // BuyerDailyAttProcess.Save(bDailyattProcesses); // #endregion // } // catch (Exception e) // { // throw new ServiceException(e.Message, e); // } //} //public 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; // } // if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.NationalHoliday) // { // attntype = EnumAttendanceType.Holiday; // } // else if (empMonthlyWorkPlan.Type == EnumWorkPlanDayType.WeeklyHoliday) // { // attntype = EnumAttendanceType.WeeklyHoliday; // } // } // else // { // //if (empInTime >= shiftInTimeWithLatehour) // //{ // // TimeSpan lateHour = empInTime.Subtract(shiftInTime); // // _lateHour = Convert.ToDouble(lateHour.Hours + "." + lateHour.Minutes.ToString("d2")); // // attntype = EnumAttendanceType.Late; // //} // if (empOutTime > shiftOutTimeWithMinimumOT) // { // TimeSpan OTHour = empOutTime.Subtract(shiftOutTime); // _oTHour = Convert.ToDouble(OTHour.Hours) + (Convert.ToDouble(OTHour.Minutes) >= Convert.ToDouble(shift.MinimumOTHour) ? 1 : 0); // } // } // return attntype; //} //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; //} // */ //#endregion //public void Delete() //{ // DailyAttnProcess.Service.Delete(ID); //} //public static string GetShortAttnWFStatus(EnumWFAttnStatus attnWFStatus) //{ // string wFStatus = string.Empty; // switch (attnWFStatus) // { // case EnumWFAttnStatus.None: // wFStatus = "Not Yet Submitted"; // break; // case EnumWFAttnStatus.EmpSubmitted: // wFStatus = "Employee Submitted"; // break; // case EnumWFAttnStatus.LMApproved: // wFStatus = "LM Approved"; // break; // case EnumWFAttnStatus.DHApproved: // wFStatus = "DH Approved"; // break; // case EnumWFAttnStatus.HRApproved: // wFStatus = "HR Approved"; // break; // case EnumWFAttnStatus.NotApplicable: // wFStatus = "Not Applicable"; // break; // case EnumWFAttnStatus.Rejected: // wFStatus = "Rejected"; // break; // } // return wFStatus; //} //public static DateTime GetLastProcessDate() //{ // DateTime lastProcessDate = DateTime.MinValue; // try // { // lastProcessDate = DailyAttnProcess.Service.GetLastProcessDate(); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return lastProcessDate; //} //public static DateTime GetLastProcessDate(ID employeeID) //{ // DateTime lastProcessDate = DateTime.MinValue; // try // { // lastProcessDate = DailyAttnProcess.Service.GetLastProcessDate(employeeID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return lastProcessDate; //} //public void UpdateLeave(ID employeeID, ID leaveID, DateTime leavaDate, int n) //{ // DailyAttnProcess.Service.UpdateLeave(employeeID, leaveID, leavaDate, n); //} //public static DataSet GetMonthlyAttn(DateTime dFromDate, DateTime dToDate, string sEmpID) //{ // DataSet monthlyAttn = null; // try // { // monthlyAttn = Service.GetMonthlyAttn(dFromDate, dToDate, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return monthlyAttn; //} //public static DataSet GetMonthlyOverTime(DateTime dFromDate, DateTime dToDate, EnumWorkPlanDayType wpType) //{ // DataSet monthlyAttn = null; // try // { // monthlyAttn = Service.GetMonthlyOverTime(dFromDate, dToDate, wpType); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return monthlyAttn; //} //public static ObjectsTemplate GetAttnDataByWFStatus(DateTime fromDate, DateTime toDate, string sEmpID, EnumWFAttnStatus status) //{ // ObjectsTemplate dailyAttnProcesses = null; // try // { // dailyAttnProcesses = Service.GetAttnDataByWFStatus(fromDate, toDate, sEmpID, status); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyAttnProcesses; //} //public static ObjectsTemplate GetAttnDataByWFStatus(string sEmpID, EnumWFAttnStatus status) //{ // ObjectsTemplate dailyAttnProcesses = null; // try // { // dailyAttnProcesses = Service.GetAttnDataByWFStatus(sEmpID, status); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyAttnProcesses; //} //public static int GetAttnDataByWFStatusCount(string sEmpID, EnumWFAttnStatus status) //{ // try // { // return Service.GetAttnDataByWFStatusCount(sEmpID, status); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } //} //public static ObjectsTemplate GetAttnSubmittedData(string sEmpID, bool isCurrentMonth) //{ // ObjectsTemplate dailyAttnProcesses = null; // try // { // dailyAttnProcesses = Service.GetAttnSubmittedData(sEmpID, isCurrentMonth); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyAttnProcesses; //} //public static DataSet GetAttnSubmittedData(string sEmpIDs, EnumWFAttnStatus status, bool isCurrentMonth) //{ // DataSet oDataSet = null; // try // { // oDataSet = Service.GetAttnSubmittedData(sEmpIDs, status, isCurrentMonth); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return oDataSet; //} //public static DataSet GetAttnSubmittedData(string sEmpIDs, EnumWFAttnStatus status, DateTime fromDate, DateTime toDate) //{ // DataSet oDataSet = null; // try // { // oDataSet = Service.GetAttnSubmittedData(sEmpIDs, status, fromDate, toDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return oDataSet; //} //public static ObjectsTemplate GetAttnSubmittedData(string sEmpID, DateTime FromDate, DateTime toDate) //{ // ObjectsTemplate dailyAttnProcesses = null; // try // { // dailyAttnProcesses = Service.GetAttnSubmittedData(sEmpID, FromDate, toDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyAttnProcesses; //} //public static DataSet GetAttnApprovedData(string sEmpID, EnumWFAttnStatus status, DateTime FromDate, DateTime toDate) //{ // DataSet oDataSet = null; // try // { // oDataSet = Service.GetAttnApprovedData(sEmpID, status, FromDate, toDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return oDataSet; //} //public static DataSet GetDailyInOut(DateTime attndate, string sEmpID) //{ // DataSet dailyInOut = null; // try // { // dailyInOut = Service.GetDailyInOut(attndate, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyInOut; //} //public static DataSet GetLMDailyAttnReport(DateTime attndate, string sEmpID) //{ // DataSet lmAttnReport = null; // try // { // lmAttnReport = Service.GetLMDailyAttnReport(attndate, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return lmAttnReport; //} //public static DataSet GetTimeSheetAttnReport(DateTime fromDate, DateTime toDate, int sEmpID) //{ // DataSet timeSheetAttnReport = null; // try // { // timeSheetAttnReport = Service.GetTimeSheetAttnReport(fromDate, toDate, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return timeSheetAttnReport; //} //public static DataSet GetPersonalInfoForDailyAttnReport(int sEmpID) //{ // DataSet lmAttnReport = null; // try // { // lmAttnReport = Service.GetPersonalInfoForDailyAttnReport(sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return lmAttnReport; //} //public static DataSet GetPersonalInfoForTimeSheet(int sEmpID) //{ // DataSet prsnlInfo = null; // try // { // prsnlInfo = Service.GetPersonalInfoForTimeSheet(sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return prsnlInfo; //} //public static DataSet GetDailyInOut(DateTime fromDate, DateTime toDate, string sEmpID) //{ // DataSet dailyInOut = null; // try // { // dailyInOut = Service.GetDailyInOut(fromDate, toDate, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyInOut; //} //public static DataSet GetDailyAbsent(DateTime fromDate, DateTime toDate, string sEmpID, EnumAttendanceType status) //{ // DataSet dailyAbsent = null; // try // { // dailyAbsent = Service.GetDailyAbsent(fromDate, toDate, sEmpID, status, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyAbsent; //} //public static DataSet GetDailyDataByStatus(DateTime attnDate, string sEmpID, params EnumAttendanceType[] eStatus) //{ // DataSet dailyInOut = null; // string sStatus = string.Empty; // sStatus = eStatus.Aggregate(new StringBuilder(), // (sb, el) => sb.Append(((int)el).ToString() + ","), // sb => sb.ToString().Trim(',')); // try // { // dailyInOut = Service.GetDailyDataByStatus(attnDate, sStatus, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyInOut; //} //public static DataSet GetDailyDataByStatus(DateTime fromDate, DateTime toDate, string sEmpID, params EnumAttendanceType[] eStatus) //{ // DataSet dailyInOut = null; // string sStatus = string.Empty; // sStatus = eStatus.Aggregate(new StringBuilder(), // (sb, el) => sb.Append(((int)el).ToString() + ","), // sb => sb.ToString().Trim(',')); // try // { // dailyInOut = Service.GetDailyDataByStatus(fromDate, toDate, sStatus, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyInOut; //} //public static DataSet GetDailyAbsent(DateTime attndate, string sEmpID) //{ // DataSet dailyAbsent = null; // try // { // dailyAbsent = Service.GetDailyAbsent(attndate, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyAbsent; //} //public static DataSet GetDailyInOutAndAbsent(DateTime attnDate, string sEmpID) //{ // DataSet dailyInOutAndAbsent = null; // try // { // dailyInOutAndAbsent = Service.GetDailyInOutAndAbsent(attnDate, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return dailyInOutAndAbsent; //} //public static DataSet GetMonthlyDetail(DateTime dFromDate, DateTime dToDate, string sEmpID) //{ // DataSet monthlyDetail = null; // try // { // monthlyDetail = Service.GetMonthlyDetail(dFromDate, dToDate, sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return monthlyDetail; //} //public static DataSet GetMonthlyLongAbsent(DateTime dFromDate, DateTime dToDate, int totalAbsentDays) //{ // DataSet monthlyDetail = null; // try // { // monthlyDetail = Service.GetMonthlyLongAbsent(dFromDate, dToDate, totalAbsentDays); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return monthlyDetail; //} //public static DataSet GetEmpAttenInfo(string sEmpID) //{ // DataSet empAttenInfo = null; // try // { // empAttenInfo = Service.GetEmpAttenInfo(sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return empAttenInfo; //} ////for creating AccessCard //public static DataSet GetEmpCardInfo(string sEmpID) //{ // DataSet empAttenInfo = null; // try // { // empAttenInfo = Service.GetEmpCardInfo(sEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return empAttenInfo; //} ////return no. of holidays by month range //public static DataSet GetHolidays(DateTime attndate, ID empID) //{ // DataSet holidays = null; // try // { // holidays = Service.GetHolidays(attndate, empID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return holidays; //} //public static DataSet GetPresentDays(DateTime attndate, ID empID) //{ // DataSet presentDays = null; // try // { // presentDays = Service.GetPresentDays(attndate, empID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return presentDays; //} //public static DataSet GetAllNecessaryDataForDailyAttnProcess(DateTime attnDate, DateTime fromTime, DateTime toTime, EnumWorkPlanGroupType wpGroupType) //{ // DataSet requiredAttnDatas = null; // try // { // requiredAttnDatas = Service.GetAllNecessaryDataForDailyAttnProcess(attnDate, fromTime, toTime, wpGroupType, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return requiredAttnDatas; //} //public static ObjectsTemplate GetEmployeesFirstAttendances(string employeeIDs) //{ // ObjectsTemplate oFirstAttendances = null; // try // { // oFirstAttendances = Service.GetEmployeesFirstAttendances(employeeIDs); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return oFirstAttendances; //} //public static DailyAttnProcess GetDailyEmployeeAbsent(ID nID, DateTime dateTime) //{ // DailyAttnProcess oEmployeeAbsent = null; // try // { // oEmployeeAbsent = Service.GetDailyEmployeeAbsent(nID, dateTime); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return oEmployeeAbsent; //} ////public static DailyAttnProcess RefreshObjectDailyAttnMobile(Employee emp, ID id, EnumAttendanceType attenType, string comment, DateTime InTime, DateTime OutTime, EnumWFAttnStatus attStatus, //// string ZipcodeInTime = null, string ZipcodeOutTime = null, decimal InTimeLatitude = 0, decimal OutTimeLatitude = 0, decimal InTimeLongitude = 0, decimal OutTimeLongitude = 0, string InTimeNearestAddress = null, string OutTimeNearestAddress = null) ////{ //// DateTime tempDateTime = DateTime.MinValue; //// DailyAttnProcess daProcess = null; //// AttendanceWFHistory attnHistory = null; //// bool isChanged = false; //// EnumAttendanceType previousStatus; //// DateTime previousInTime = DateTime.MinValue; //// DateTime previousOutTime = DateTime.MinValue; //// isChanged = false; //// attnHistory = new AttendanceWFHistory(); //// //previous code //// //ObjectsTemplate oNotYetSubmittedAttnDatas = DailyAttnProcess.GetAttnDataByWFStatus(emp.ID.ToString(), EnumWFAttnStatus.None); //// //daProcess = oNotYetSubmittedAttnDatas.Where(o => o.ID == id).FirstOrDefault(); //// //for optimization //// //daProcess = DailyAttnProcess.Get(id); //// daProcess = DailyAttnProcess.Get(emp.ID.Integer, DateTime.Today); //// if (daProcess == null) //// throw new CustomException(EnumExceptionType.Error, "Attendance Data Not Found"); //// previousInTime = daProcess.InTime; //// previousOutTime = daProcess.OutTime; //// if (daProcess.ActualInTime == DateTime.MinValue) //// daProcess.ActualInTime = daProcess.InTime; //// if (daProcess.ActualOutTime == DateTime.MinValue) //// daProcess.ActualOutTime = daProcess.OutTime; //// previousStatus = daProcess.AttenType; //// attnHistory.EmployeeID = daProcess.EmployeeID; //// attnHistory.DailyAttnProcessID = daProcess.ID; //// daProcess.IsManualEntry = true; //// if ((int)attenType != 0) //// { //// daProcess.EmpAttenType = attenType; //// attnHistory.AttandanceStatus = attenType; //// if (previousStatus != attenType) //// isChanged = true; //// } //// //RadNumericTextBox txtBoxApprovedOT = (RadNumericTextBox)gridItem.FindControl("numActualOT"); //// //if (txtBoxApprovedOT.Text != string.Empty) //// //{ //// // daProcess.ApprovedOTHour = Convert.ToDouble(txtBoxApprovedOT.Text); //// // daProcess.OtRemarks = daProcess.ApprovedOTHour.ToString(); //// // attnHistory.OTHour = daProcess.ApprovedOTHour; //// // isChanged = true; //// //} //// if (comment != string.Empty) //// { //// daProcess.Comments = comment; //// attnHistory.Remarks = daProcess.Comments; //// isChanged = true; //// } //// if (InTime != null && InTime != DateTime.MinValue) //// { //// daProcess.InTime = InTime; //// } //// if (OutTime != null && OutTime != DateTime.MinValue) //// { //// daProcess.OutTime = OutTime; //// } //// if (previousInTime != daProcess.InTime) //// isChanged = true; //// if (previousOutTime != daProcess.OutTime) //// isChanged = true; //// if (isChanged == true) //// { //// attnHistory.WFStatus = attStatus; //// } //// else //// { //// attnHistory.WFStatus = EnumWFAttnStatus.NotApplicable; //// daProcess.WFStatus = EnumWFAttnStatus.NotApplicable; //// } //// daProcess.ZipcodeInTime = ZipcodeInTime == null ? string.Empty : ZipcodeInTime; //// daProcess.ZipcodeOutTime = ZipcodeOutTime == null ? string.Empty : ZipcodeOutTime; //// daProcess.InTimeLatitude = InTimeLatitude; //// daProcess.OutTimeLatitude = OutTimeLatitude; //// daProcess.InTimeLongitude = InTimeLongitude; //// daProcess.OutTimeLongitude = OutTimeLongitude; //// daProcess.InTimeNearestAddress = InTimeNearestAddress == null ? string.Empty : InTimeNearestAddress; //// daProcess.OutTimeNearestAddress = OutTimeNearestAddress == null ? string.Empty : OutTimeNearestAddress; //// daProcess.WFStatus = attStatus; //// daProcess.AttnWFHistory.Add(attnHistory); //// return daProcess; ////} //public static ObjectsTemplate Get(ID empID, ID shiftID, DateTime fromdate, DateTime todate, EnumAttendanceType enumAttendanceType) //{ // ObjectsTemplate odAttnProcesses = null; // try // { // odAttnProcesses = Service.Get(empID, shiftID, fromdate, todate, enumAttendanceType); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return odAttnProcesses; //} //public static DataSet GetDailyAttndanceBenefitDataFromVB(DateTime AttnDate) //{ // return DailyAttnProcess.Service.GetDailyAttndanceBenefitDataFromVB(AttnDate); //} //public static DataSet GetMonthlyAttndanceBenefitDataFromVB(int Year, int Month) //{ // return DailyAttnProcess.Service.GetMonthlyAttndanceBenefitDataFromVB(Year, Month); //} //#endregion #endregion public string ObjectDescription { get { string str = ""; str = this.EmployeeID + " has checked in and checked out at " + this.AttnDate.ToString("DD MM YYYY"); return str; } } public int SetupID { get; set; } public int ObjectID { get; set; } public string ZipcodeInTime { get; set; } public string ZipcodeOutTime { get; set; } public int LocationID { get; set; } public DateTime SalaryMonth { get; set; } public static string getWFstatusDescription(EnumWFAttnStatus type) { string str = ""; if (type == EnumWFAttnStatus.EmpSubmitted) { str = "Submitted"; } else if (type == EnumWFAttnStatus.LMApproved) { str = "Approved"; } else if (type == EnumWFAttnStatus.Reject) { str = "Rejected"; } else str = ""; return str; } } #endregion #region IDailyAttnProcess Service public class attnProcessRequest { public DateTime fromDate { get; set; } public DateTime ToDate { get; set; } public int? employeeID { get; set; } } public interface IDailyAttnProcessService { List GetByEmployeeID(int employeeID); DataSet GetEarnedLeaveOpening(int employeeID, int leaveid, DateTime fromDate, DateTime toDate); JobCardReport GetMonthJobCardByEmployeeId(int employeeID, DateTime fromDate, DateTime toDate, int payrollTypeId); public List GetDailyDataByStatusReport(DateTime attnDate, string sStatus, string sEmpID); public List GetDataByStatusReport(DateTime fromDate, DateTime todate, string sStatus, string sEmpID); public List GetDateRangeWiseDataByStatusReport(DateTime fromDate, DateTime toDate, string sStatus, string sEmpID); public List GetDailyOddDataByStatusReport(DateTime attnDate, string sEmpID); public List GetDateWiseAttnRecords(DateTime attnDate, string sEmpID); List GetAttnDataByWFStatus(DateTime fromDate, DateTime toDate, string sEmpID, EnumWFAttnStatus status); List getMyNotSubmittedAbsentList(int employeeid); DateTime GetLastProcessDateByEmpId(int employeeID); List GetAttnSubmittedData(string sEmpID, DateTime FromDate, DateTime toDate); DataSet GetAttnSubmittedData(string sEmpIDs, DateTime nextPayProcessDate, EnumWFAttnStatus status, bool isCurrentMonth); List GetAttnSubmittedData(string sEmpID, bool isCurrentMonth); List GetAttnDataByWFStatus(string sEmpID, EnumWFAttnStatus status); int GetAttnDataByWFStatusCount(string empID, EnumWFAttnStatus status); DailyAttnProcess Get(int id); DailyAttnProcess Get(int empId, DateTime attnDate); List AttendanceDataForMailSchedular(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid); List GetProcessByWPG(EnumWorkPlanGroup wpg, DateTime attnDate); List Get(DateTime attnDate, int payrollTypeID); List GetManualProcess(DateTime attnDate); List Get(int empID, DateTime fromDate, DateTime toDate); List Get(string empID, DateTime fromDate, DateTime toDate); List Get(DateTime fromDate, DateTime toDate); List Get(DateTime attnDate, int shiftID, EnumAttendanceType attnType); //new DailyAttnProcess GetDailyEmployeeAbsent(int nID, DateTime dateTime); List GetWhrOutTimeIsNull(DateTime attnDate, int shiftID); List GetEmployeesFirstAttendances(string employeeIDs); DateTime GetLastProcessDate(); // List Get(int empID, int shiftID, DateTime fromdate, DateTime todate, EnumAttendanceType enumAttendanceType); List Get(DateTime attnDate, string empids, int payrollTypeID); int GetAttnDataByWFStatusCount(DateTime fromdate, DateTime toDate, EnumWFAttnStatus status); DataSet GetMonthlyKPIDetail(DateTime dFromDate, DateTime dToDate, string sEmpID, EnumAttendanceType eAttnType); List GetBySalaryMonth(DateTime salaryMonth, int payrollTypeID); List GetByStatus(int empID, DateTime fromDate, DateTime toDate, string status); List Get(string empID, DateTime fromDate, DateTime toDate, EnumClaimWFStatus status); DateTime GetLastProcessDate(int payrollType); List GetManualProcess(DateTime attnDate, int payrollType); DailyAttnProcess GetAttnDataByWFStatus(int dailyAttnProcessID, EnumWFAttnStatus status); //int Save(DailyAttnProcess item); //void Save(List _dAttnProcessess, bool IscounterClock); //void Save(List dAttnProcessess); void Save(List dAttnProcessess, List attnMonthlyBenefits); void ManualEditSave(List oDAttnProcessess, int payrolltypeid, int userid, List attnMonthlyBenefit); void SendRegularizationApplicationMail(DailyAttnProcess dAttnProcessess, EmailSettings emailSettings); void SendRegularizationApprovalMail(DailyAttnProcess dAttnProcessess, EmailSettings emailSettings); void Delete(int id); // void UpdateLeave(int employeeID, int leaveID, DateTime leavaDate, int n); //void SaveForBridgeHoliday(List dailyattProcesses, List oLeaveEntrys); //void SaveAutoForLmApproved(List dailyattProcesses, // List oAtnMonthlyBenifits, AttnProcessRunSummary oAttnRunSummary); //void SaveAuto(List dailyattProcesses, List oAtnMonthlyBenifits, // AttnProcessRunSummary oAttnRunSummary); int GetAttnDataByWFStatusCountForMobile(int sEmpID, EnumWFAttnStatus status); void RejectAttnStatusByLM(int EmpID, DateTime attnDate, int linemanagerID, string remarks, string reason); void ApproveAttnByLM(DailyAttnProcess item); //List CheckOutFixedPosition(int attnID, string comment, // decimal OutTimeLatitude, decimal OutTimeLongitude, int locationID, EnumIsFromMobile IsFromMobile, string OutTimeNearestAddress); DailyAttnProcess GetAttnDataForMobile(int empId, DateTime attnDate); DailyAttnProcess GetAttnDataForMobileWithNoLock(int empId, DateTime attnDate); List GetRegularizableAttn(int EmpID, DateTime fromDate, DateTime toDate); List GetAttnForStatement(int EmpID, DateTime fromDate, DateTime toDate); List GetAttnForStatementWithNoLock(int EmpID, DateTime fromDate, DateTime toDate); List GetByLMID(int LMID, DateTime AttnDate); List GetByLMIDMobileWithNoLock(int LMID, DateTime AttnDate); List RefreshObject(Employee emp, int id, string ddlSelectedValue, string comment, DateTime InTime, DateTime OutTime); //List RefreshObjectDailyAttnMobile(int EmployeeID, int id, EnumAttendanceType attenType, string comment, DateTime InTime, DateTime OutTime, EnumWFAttnStatus attStatus, // string ZipcodeInTime = null, string ZipcodeOutTime = null, decimal InTimeLatitude = 0, decimal OutTimeLatitude = 0, decimal InTimeLongitude = 0, decimal OutTimeLongitude = 0, string InTimeNearestAddress = null, string OutTimeNearestAddress = null, // int locationID = 0, EnumIsFromMobile IsFromMobile = EnumIsFromMobile.None); DataSet GetAttnShiftAndWorkDatType(int EmployeeID, DateTime AttnDate); DataSet GetAttnShiftAndWorkDatTypeMobileWithNoLock(int EmployeeID, DateTime AttnDate); DataTable GetTypeWiseAttnCount(string empID, DateTime fromDate, DateTime toDate, params EnumAttendanceType[] attnType); DataTable getMyTeamNotApprovedList(int lineManagerID); DataTable getMyTeamAbsentAndLeaveList(int lineManagerID, DateTime fromDate, DateTime toDate); DataTable GetAttendanceDashboard(Employee employee); DataTable getTopEmpAbsentData(Employee oEmp, EnumAttendanceType type); DataTable getcorehrAbsentData(Employee oEmp, EnumAttendanceType type); DataSet AttnDaysSummaryForSalaryProcess(DateTime FromDate, DateTime ToDate); } #endregion #region DTO public class JobCardReport { public string EmployeeNo { get; set; } public string EmpName { get; set; } public string Designation { get; set; } public string Department { get; set; } public string JoiningDate { get; set; } public string FromDate { get; set; } public string ToDate { get; set; } public string PresentDays { get; set; } public string AbsentDays { get; set; } public string LateDays { get; set; } public string LeaveDays { get; set; } public string WeeklyHolidays { get; set; } public string OSDDays { get; set; } public string FestivalHolidays { get; set; } public string WorkingDays { get; set; } public string PresentInholidays { get; set; } public string TotalLateHour { get; set; } public string TotalOTHour { get; set; } public List JobCardReportDetails { get; set; } public JobCardReport() { JobCardReportDetails = new List(); } } public class JobCardReportDetails { public string Date { get; set; } public string Day { get; set; } public string InTime { get; set; } public string OutTime { get; set; } public string LateBy { get; set; } public string WorkingHour { get; set; } public string OTHour { get; set; } public string Status { get; set; } public string Shift { get; set; } public string Remarks { get; set; } public string Reason { get; set; } } public class DailyAttnByStatusReport { public string AttendanceDate { get; set; } public string EmployeeNo { get; set; } public string EmpName { get; set; } public string Designation { get; set; } public string Department { get; set; } public string Shift { get; set; } public string InTime { get; set; } public string OutTime { get; set; } public string Time { get; set; } public string Status { get; set; } public string StatusFull { get; set; } public string OTHour { get; set; } } public class AttendanceRegularizationDTO { public int DailyAttnProcessID { get; set; } public string AttendanceDate { get; set; } public string Shift { get; set; } public DateTime? InTime { get; set; } public DateTime? OutTime { get; set; } public double lateHour { get; set; } public double otHour { get; set; } public double earlyHour { get; set; } public double workHour { get; set; } public bool IsLate { get; set; } public DateTime? ActualInTime { get; set; } public DateTime? ActualOutTime { get; set; } public EnumWFAttnStatus WFStatus { get; set; } public string WFStatusDescription { get; set; } public EnumAttendanceType Status { get; set; } public string StatusDescription { get; set; } public string Comments { get; set; } public string LMRemarks { get; set; } public string empRemarks { get; set; } public int ReferenceId { get; set; } public string Reference { get; set; } } public class DailyAttnMailSenderReport : AuditTrailBase { public int DailyAttnProcessID { get; set; } public int EmployeeId { get; set; } public string EmployeeNo { get; set; } public string Name { get; set; } public string Designation { get; set; } public string Department { get; set; } public DateTime AttnDate { get; set; } public string Day { get; set; } public DateTime InTime { get; set; } public DateTime OutTime { get; set; } public string AttnType { get; set; } public string NotPresentType { get; set; } public string LineManagerNo { get; set; } public string LineManagerName { get; set; } public string TotalWorkingHour { get; set; } public string LateCount { get; set; } } #endregion }