Exemple #1
0
        public static List <Att_Grade> getAllGrade2(List <Guid> listProfileId, DateTime monthYear)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork    = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_Grade = new CustomBaseRepository <Att_Grade>(unitOfWork);

                List <Att_Grade> lst        = new List <Att_Grade>();
                string[]         strInclude = new string[] { "Cat_GradeAttendance" };

                lst = repoAtt_Grade.FindBy(gd => listProfileId.Contains(gd.ProfileID.Value) &&
                                           gd.MonthStart <= monthYear).OrderByDescending(prop => prop.MonthStart).ToList();

                List <Att_Grade> lstGrade = new List <Att_Grade>();
                foreach (Att_Grade grade in lst)
                {
                    Att_Grade grade1 = lstGrade.FirstOrDefault(prop => prop.ProfileID == grade.ProfileID);
                    if (grade1 == null)
                    {
                        lstGrade.Add(grade);
                    }
                }
                return(lstGrade);
            }
        }
Exemple #2
0
 public void AddDataForGrade(string ProfileIDs, Guid GradeAttendanceID, DateTime DateHire)
 {
     using (var context = new VnrHrmDataContext())
     {
         var              unitOfWork    = (IUnitOfWork)(new UnitOfWork(context));
         var              repoAtt_Grade = new CustomBaseRepository <Att_Grade>(unitOfWork);
         List <Guid>      lstProfileIDs = ProfileIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
         List <Att_Grade> lstGrade      = new List <Att_Grade>();
         foreach (var item in lstProfileIDs)
         {
             Att_Grade Grade = new Att_Grade();
             Grade.ProfileID         = item;
             Grade.GradeAttendanceID = GradeAttendanceID;
             Grade.MonthStart        = DateHire;
             lstGrade.Add(Grade);
         }
         repoAtt_Grade.Add(lstGrade);
         repoAtt_Grade.SaveChanges();
     }
 }
        public Cat_OvertimeType getOTType(DateTime dateWorkDate, bool isNightShift, Hre_Profile profile, List <Cat_DayOff> list_dayOff, List <Att_RosterGroup> lstRosterGroup, List <Att_Roster> lstRosterTypeGroup)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork           = (IUnitOfWork)(new UnitOfWork(context));
                var repoAtt_LeaveDay     = new CustomBaseRepository <Att_LeaveDay>(unitOfWork);
                var repoCat_OvertimeType = new CustomBaseRepository <Cat_OvertimeType>(unitOfWork);

                Cat_OvertimeType otType = null;
                try
                {
                    dateWorkDate = dateWorkDate.Date;

                    //LamLe : Them chuc nang neu tang ca vao ngay nghi thi chon loai tang ca phu thuoc vao cau hinh Tang ca trong ngay nghi.
                    List <Att_LeaveDay> lstLeave = repoAtt_LeaveDay
                                                   .FindBy(lv => lv.IsDelete == null && lv.DateStart <= dateWorkDate && lv.DateEnd >= dateWorkDate && lv.ProfileID == profile.ID)
                                                   .ToList();
                    if (lstLeave.Count > 0)
                    {
                        Att_LeaveDay leave = lstLeave[0];
                        if (leave != null && leave.Cat_LeaveDayType != null && leave.Cat_LeaveDayType.Cat_OvertimeType != null)
                        {
                            otType = leave.Cat_LeaveDayType.Cat_OvertimeType;
                            return(otType);
                        }
                    }

                    Att_Grade grade = Att_GradeServices.GetGrade(profile, dateWorkDate);
                    if (grade == null)
                    {
                        string status = OverTimeType.E_WORKDAY.ToString();
                        otType = repoCat_OvertimeType.FindBy(dayoff => dayoff.IsDelete == null && dayoff.Code == status).FirstOrDefault();
                        return(otType);
                    }
                    list_dayOff = list_dayOff.Where(df => df.DateOff.Date == dateWorkDate.Date).ToList();
                    Cat_GradeCfg gradecfg = grade.Cat_GradeCfg;

                    //Check overtime holiday
                    //List<Cat_DayOff> list_dayOff = EntityService.Instance.GetEntityList<Cat_DayOff>(GuidContext, _userId, dayoff => dayoff.DateOff == dateWorkDate);

                    if (list_dayOff.Count > 0)
                    {
                        //Cat_GradeCfg.FieldNames.Cat_OvertimeType1
                        bool isDayOffHollyDay = false;
                        foreach (var item in list_dayOff)
                        {
                            if (item.DateOff.Date == dateWorkDate.Date && item.Type == HolidayType.E_HOLIDAY_HLD.ToString())
                            {
                                isDayOffHollyDay = true;
                            }
                        }
                        //Ca dem ngay le
                        if (isDayOffHollyDay && isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType5;
                        }
                        //Ca dem ngay nghi cuoi tuan
                        else if (!isDayOffHollyDay && isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType4;
                        }
                        ////Ca ngay ngay le
                        else if (isDayOffHollyDay && !isNightShift)
                        {
                            otType = gradecfg.Cat_OvertimeType2;
                        }
                        ////Ca ngay ngay nghi cuoi tuan
                        else
                        {
                            otType = gradecfg.Cat_OvertimeType1;
                        }
                    }
                    else
                    {
                        Hashtable hsRoster = Att_RosterServices.GetRosterTable(false, profile, dateWorkDate, dateWorkDate, lstRosterGroup, lstRosterTypeGroup);

                        bool isWorkday = Att_AttendanceServices.IsWorkDay(grade.Cat_GradeAttendance, hsRoster, list_dayOff, dateWorkDate);
                        if (isWorkday)
                        {
                            if (isNightShift)
                            {
                                otType = gradecfg.Cat_OvertimeType3;
                            }
                            else
                            {
                                otType = gradecfg.Cat_OvertimeType;
                            }
                            //if (gradecfg.Cat_OvertimeType == null)
                            //{

                            //    string workday = OverTimeType.E_WORKDAY.ToString();
                            //    otType = EntityService.Instance.GetEntity<Cat_OvertimeType>(GuidContext, _userId, dayoff => dayoff.Code == workday);
                            //}
                            //else
                            //    otType = gradecfg.Cat_OvertimeType;
                        }
                        else
                        {
                            if (isNightShift)
                            {
                                otType = gradecfg.Cat_OvertimeType4;
                            }
                            else
                            {
                                otType = gradecfg.Cat_OvertimeType1;
                            }
                            //if (gradecfg.Cat_OvertimeType1 == null)
                            //{
                            //    string workday = OverTimeType.E_WORKDAY.ToString();
                            //    otType = EntityService.Instance.GetEntity<Cat_OvertimeType>(GuidContext, _userId, dayoff => dayoff.Code == workday);
                            //}
                            //else
                            //    otType = gradecfg.Cat_OvertimeType1;
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                return(otType);
            }
        }
        /// <summary>
        /// Edit comment Trung.le 20120529
        /// Them thuoc tinh Khong cat Overtime qua ngày E_STANDARD_WORKDAY - Value37 Trung.le 20120529
        /// </summary>
        /// <param name="overtime"></param>
        /// <param name="lstDayOff"></param>
        /// <param name="_LstPregnancy"></param>
        /// <param name="GuidContext"></param>
        /// <param name="_userId"></param>
        /// <param name="isByShift">Lấy theo ca làm việc của từng người</param>
        /// <returns></returns>
        public List <Att_OvertimeEntity> AnalysisOvertime(Att_OvertimeEntity overtime, List <Cat_DayOff> lstDayOff,
                                                          List <Att_Pregnancy> _LstPregnancy, bool isByShift, bool isAllowCutBreakHour, string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork    = (IUnitOfWork)(new UnitOfWork(context));
                var repoCat_Shift = new CustomBaseRepository <Cat_Shift>(unitOfWork);

                Cat_Shift ShiftOfOT = repoCat_Shift.FindBy(s => s.ID == overtime.ShiftID).FirstOrDefault();


                string status = string.Empty;

                Att_OvertimeEntity baseOT = null;
                if (overtime != null)
                {
                    //overtime.SerialCode = overtime.Workdate.ToString("ddMMyyyy");
                }

                List <Att_OvertimeEntity> listOvertimeInsert = new List <Att_OvertimeEntity>();
                Hre_Profile profile = new Hre_Profile();
                profile.ID = overtime.ProfileID;
                DateTime _workDate    = overtime.WorkDate;
                DateTime dateWorkDate = _workDate;

                string        key      = "HRM_ATT_OT";
                List <object> lstSysOT = new List <object>();
                lstSysOT.Add(key);
                lstSysOT.Add(null);
                lstSysOT.Add(null);
                var config = GetData <Sys_AllSettingEntity>(lstSysOT, ConstantSql.hrm_sys_sp_get_AllSetting, UserLogin, ref status);
                if (config == null)
                {
                    return(listOvertimeInsert);
                }
                var  NoCutOvertimePassDay   = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_NOCUTOVERTIMEPASSDAY.ToString()).FirstOrDefault();
                var  ByPeriodOfTime         = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_BYPERIODOFTIME.ToString()).FirstOrDefault();
                var  nightShiftFrom         = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_NIGHTSHIFTFROM.ToString()).FirstOrDefault();
                var  nightShiftTo           = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_NIGHTSHIFTTO.ToString()).FirstOrDefault();
                bool isNocutOvertimePassDay = Convert.ToBoolean(NoCutOvertimePassDay.Value1);//Không cắt Overtime qua ngày


                List <Hre_Profile> lstProfile = new List <Hre_Profile>()
                {
                    profile
                };
                List <Guid>            lstProfileIDs      = lstProfile.Select(m => m.ID).ToList();
                List <Att_Roster>      lstRosterTypeGroup = new List <Att_Roster>();
                List <Att_RosterGroup> lstRosterGroup     = new List <Att_RosterGroup>();
                Att_RosterServices.GetRosterGroup(lstProfileIDs, _workDate.Date, _workDate.Date, out lstRosterTypeGroup, out lstRosterGroup);

                string registryCode  = "OT_" + overtime.CodeEmp + "_" + overtime.WorkDate.ToString("ddMMyyyyHHmmss");
                double basicHours    = overtime.RegisterHours;
                double durationHours = overtime.RegisterHours;
                //overtime.BasicHours = basicHours;
                //overtime.RegisterCode = registryCode;
                bool                isWorkDay       = true;
                DateTime            dateWorkDateEnd = dateWorkDate.AddHours(durationHours);
                Att_Grade           grade           = Att_GradeServices.GetGrade(profile, _workDate.Date);
                Cat_GradeAttendance gradeCfg        = grade == null ? null : grade.Cat_GradeAttendance;
                if (gradeCfg == null)
                {
                    return(listOvertimeInsert);
                }
                Hashtable htable = null;
                htable    = Att_RosterServices.GetRosterTable(false, profile, _workDate.Date, _workDate.Date, lstRosterGroup, lstRosterTypeGroup);
                isWorkDay = Att_AttendanceServices.IsWorkDay(gradeCfg, htable, lstDayOff, _workDate.Date);
                if (isByShift)//Lấy theo ca làm việc của từng người
                {
                    #region Lấy theo ca làm việc của từng người

                    Cat_Shift ship = Att_AttendanceServices.GetShift(gradeCfg, htable, _workDate.Date);
                    if (ship != null)
                    {
                        if (isWorkDay)
                        {
                            if (overtime.DurationType == EnumDropDown.OvertimeDurationType.E_OT_LATE.ToString() && ship != null)
                            {
                                DateTime timeOut = ship.InTime.AddHours(ship.CoOut);
                                dateWorkDate    = _workDate.Date.AddHours(timeOut.Hour).AddMinutes(timeOut.Minute);
                                dateWorkDateEnd = dateWorkDate.AddHours(durationHours);
                            }
                            else if (overtime.DurationType == EnumDropDown.OvertimeDurationType.E_OT_EARLY.ToString() && ship != null)
                            {
                                DateTime timeIn = ship.InTime;
                                dateWorkDate    = _workDate.Date.AddHours(timeIn.Hour).AddMinutes(timeIn.Minute);
                                dateWorkDateEnd = dateWorkDate;
                                dateWorkDate    = dateWorkDate.AddHours(-durationHours);
                            }
                        }
                        else
                        {
                            DateTime timeIn = ship.InTime;
                            dateWorkDate = _workDate.Date.AddHours(timeIn.Hour).AddMinutes(timeIn.Minute);
                        }
                    }
                    else
                    {
                        dateWorkDate    = dateWorkDate.Date;
                        dateWorkDateEnd = dateWorkDate.AddHours(durationHours);
                    }
                    ShiftOfOT = ship;


                    htable    = Att_RosterServices.GetRosterTable(false, profile, dateWorkDate, dateWorkDate.AddHours(durationHours), lstRosterGroup, lstRosterTypeGroup);
                    isWorkDay = Att_AttendanceServices.IsWorkDay(gradeCfg, htable, lstDayOff, dateWorkDate.AddHours(durationHours));

                    #endregion
                }

                //Kiem tra xem co trong thoi gian nghi thai san khong?
                if (isWorkDay && overtime.DurationType == EnumDropDown.OvertimeDurationType.E_OT_LATE.ToString() &&
                    _LstPregnancy != null && _LstPregnancy.Exists(pc => pc.ProfileID == profile.ID && pc.DateEnd >= dateWorkDate && pc.DateStart <= dateWorkDateEnd))
                {
                    dateWorkDate    = dateWorkDate.AddHours(-1);
                    dateWorkDateEnd = dateWorkDate.AddHours(durationHours);
                }
                overtime.WorkDate = dateWorkDate;



                string strHoursNightFrom = string.Empty;
                string strHoursNightTo   = string.Empty;


                if (!Att_AttendanceServices.IsNightShiftByConfig(ByPeriodOfTime) && ShiftOfOT != null &&
                    ShiftOfOT.NightTimeStart != null &&
                    ShiftOfOT.NightTimeEnd != null)
                {
                    strHoursNightFrom = ShiftOfOT.NightTimeStart.Value.ToString("HH:mm:ss");
                    strHoursNightTo   = ShiftOfOT.NightTimeEnd.Value.ToString("HH:mm:ss");
                }
                else
                {
                    strHoursNightFrom = string.IsNullOrEmpty(nightShiftFrom.Value1) == true ? "21:00:00" : nightShiftFrom.Value1 + ":00";
                    strHoursNightTo   = string.IsNullOrEmpty(nightShiftTo.Value1) == true ? "05:00:00" : nightShiftTo.Value1 + ":00";
                }

                DateTime dateNightFrom = Common.ConvertStringToDateTime(dateWorkDate.Date.ToString("MM/dd/yyyy") + " " + strHoursNightFrom, CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern);
                DateTime dateNightTo   = Common.ConvertStringToDateTime(dateWorkDate.Date.AddDays(1).ToString("MM/dd/yyyy") + " " + strHoursNightTo, CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern);


                OvertimeInfo overtimeInfo = new OvertimeInfo(true);
                overtimeInfo.DateFrom   = dateWorkDate;
                overtimeInfo.TotalHours = overtime.RegisterHours;

                overtimeInfo.DayShiftPoints = new DateTime[] { dateNightTo };

                if (isNocutOvertimePassDay)
                {
                    overtimeInfo.NightShiftPoints = new DateTime[] { dateNightFrom };
                }
                else
                {
                    //truong hop cat khi qua ngay hom sau
                    overtimeInfo.NightShiftPoints = new DateTime[] { dateNightFrom, dateNightFrom.Date };
                }

                if (ShiftOfOT != null && isAllowCutBreakHour)
                {
                    Cat_Shift shift      = ShiftOfOT;
                    DateTime  coBreakOut = shift.InTime.AddHours(shift.CoBreakIn);

                    if (shift.CoBreakOut - shift.CoBreakIn > 0)
                    {
                        overtimeInfo.BreaktPoints.Add(coBreakOut, shift.CoBreakOut - shift.CoBreakIn);
                    }
                }
                Hre_Profile temp = new Hre_Profile();
                temp.ID = overtime.ProfileID;

                overtimeInfo.Hre_Profile = temp;
                overtimeInfo.ListDayOff  = lstDayOff;

                listOvertimeInsert = AnalysisOvertime(overtime, overtimeInfo);



                return(listOvertimeInsert);
            }
        }
        public List <Att_RptExceptionDataEntity> GetAtt_RptExceptionData(DateTime DateStart, DateTime DateEnd, String OrgStructureIDs, bool NoScan, bool DifferenceMoreRoster, double Difference, double LessHours, bool MissInOut, out string message, string userExport, string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork) new UnitOfWork(context);
                message = "";
                var repoHre_Profile          = new CustomBaseRepository <Hre_Profile>(unitOfWork);
                var repoCat_OrgStructure     = new CustomBaseRepository <Cat_OrgStructure>(unitOfWork);
                var repoCat_DayOff           = new CustomBaseRepository <Cat_DayOff>(unitOfWork);
                var repoAtt_Roster           = new CustomBaseRepository <Att_Roster>(unitOfWork);
                var repoAtt_InOut            = new CustomBaseRepository <Att_InOut>(unitOfWork);
                var repoAtt_LeaveDay         = new CustomBaseRepository <Att_LeaveDay>(unitOfWork);
                var repoAtt_Grade            = new CustomBaseRepository <Att_Grade>(unitOfWork);
                var repoHre_WorkHistory      = new CustomBaseRepository <Hre_WorkHistory>(unitOfWork);
                var repoCat_OrgStructureType = new Cat_OrgStructureTypeRepository(unitOfWork);
                var repoCat_Position         = new Cat_PositionRepository(unitOfWork);


                List <Hre_ProfileEntity> lstProfile = new List <Hre_ProfileEntity>();
                List <object>            lstOrgIDs  = new List <object>();
                lstOrgIDs.AddRange(new object[3]);
                lstOrgIDs[0] = OrgStructureIDs;
                lstOrgIDs[1] = null;
                lstOrgIDs[2] = null;
                lstProfile   = GetData <Hre_ProfileEntity>(lstOrgIDs, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, userLogin, ref message);

                List <Att_RptExceptionDataEntity> Result = new List <Att_RptExceptionDataEntity>();
                string waitStatus = ProfileStatusSyn.E_WAITING.ToString();
                lstProfile = lstProfile.Where(d => d.StatusSyn != waitStatus && (d.DateQuit == null || d.DateQuit.Value > DateEnd)).ToList();
                List <Guid>      lstProfileID = lstProfile.Select(d => d.ID).ToList();
                List <Att_InOut> lstInOutAll  = repoAtt_InOut.FindBy(wd => wd.WorkDate >= DateStart &&
                                                                     wd.WorkDate <= DateEnd).OrderBy(wd => wd.Hre_Profile.ProfileName).ToList();
                var positions = repoCat_Position.FindBy(s => s.IsDelete == null && s.Code != null).Select(s => new { s.ID, s.Code, s.PositionName }).ToList();
                var orgTypes  = repoCat_OrgStructureType.FindBy(s => s.IsDelete == null).ToList();
                List <Cat_OrgStructure> lstOrg = new List <Cat_OrgStructure>();
                if (!string.IsNullOrEmpty(OrgStructureIDs)) // Chỉ lấy phòng ban theo sự lựa chọn
                {
                    List <int> lstOrderNumber = OrgStructureIDs.Split(',').Distinct().Select(s => int.Parse(s)).ToList();
                    lstOrg = repoCat_OrgStructure.FindBy(m => m.IsDelete == null && lstOrderNumber.Contains(m.OrderNumber)).ToList();
                }
                else //Lấy hêt phòng ban
                {
                    lstOrg = repoCat_OrgStructure.FindBy(m => m.IsDelete == null).ToList();
                }
                if (NoScan)
                {
                    List <Cat_DayOff> lstHoliday       = repoCat_DayOff.FindBy(d => d.IsDelete == null).ToList();
                    String            RosterTypeAbsent = RosterType.E_TIME_OFF.ToString();
                    List <Att_Roster> lstRoster        = repoAtt_Roster.FindBy(prop => prop.DateStart <= DateEnd && prop.DateEnd >= DateStart &&
                                                                               prop.Type != RosterTypeAbsent).ToList();

                    List <Att_LeaveDay> lstLeaveDayAll = repoAtt_LeaveDay.FindBy(prop => prop.DateStart <= DateEnd && prop.DateEnd >= DateStart).ToList();
                    List <Att_Grade>    lstAtt_Grade   = repoAtt_Grade.FindBy(d => d.MonthStart <= DateEnd && d.MonthEnd >= DateStart && d.ProfileID.HasValue && lstProfileID.Contains(d.ProfileID.Value)).ToList();
                    //List<Sal_Grade> lstGradeAll = GradeDAO.getAllGrade(EntityService.GuidMainContext
                    //                                                , lstProfileID
                    //                                                , DateEnd
                    //                                                , LoginUserID);
                    List <Hre_WorkHistory> lstWHistory        = repoHre_WorkHistory.FindBy(d => d.IsDelete == null).ToList();
                    List <Att_Roster>      lstRosterTypeGroup = new List <Att_Roster>();
                    List <Att_RosterGroup> lstRosterGroup     = new List <Att_RosterGroup>();
                    Att_RosterServices.GetRosterGroup(lstProfileID, DateStart, DateEnd, out lstRosterTypeGroup, out lstRosterGroup);
                    //RosterDAO.GetRosterGroup(GuidContext, lstProfileIDs, DateStart, DateEnd, out lstRosterTypeGroup, out lstRosterGroup);


                    foreach (Hre_ProfileEntity profile in lstProfile)
                    {
                        List <Att_LeaveDay> lstProfileLeaveDay = lstLeaveDayAll.Where(ld => ld.ProfileID == profile.ID).ToList();
                        List <Att_InOut>    lstProfileInOut    = lstInOutAll.Where(ld => ld.ProfileID == profile.ID).ToList();
                        //Sal_Grade grade = lstGradeAll.Where(grad => grad.ProfileID == profile.ID).SingleOrDefault();
                        Att_Grade              grade            = lstAtt_Grade.Where(d => d.ProfileID == profile.ID).FirstOrDefault();
                        List <Att_Roster>      lstProfileRoster = lstRoster.Where(rt => rt.ProfileID == profile.ID).ToList();
                        List <Hre_WorkHistory> lstWHistoryPro   = lstWHistory.Where(wh => wh.ProfileID == profile.ID).ToList();
                        Cat_GradeAttendance    gradeCfg         = grade == null ? null : grade.Cat_GradeAttendance;
                        //Hashtable htRoster = RosterDAO.GetRosterTable(profile, lstProfileRoster, lstWHistoryPro, gradeCfg, DateStart, DateEnd, lstRosterGroup, lstRosterTypeGroup);
                        Hre_Profile objProfile = profile.CopyData <Hre_Profile>();
                        Hashtable   htRoster   = Att_RosterServices.GetRosterTable(objProfile, lstProfileRoster, lstWHistoryPro, gradeCfg, DateStart, DateEnd, lstRosterGroup, lstRosterTypeGroup);
                        //string[] strDepartment = GradeCfgDAO.getLinkDepartment(ListCacheOrgStructure, profile.Cat_OrgStructure);
                        //profile.udLinkDepartmentName = strDepartment[0];
                        if (grade == null)
                        {
                            continue;
                        }
                        if (grade.Cat_GradeAttendance.AttendanceMethod != AttendanceMethod.E_TAM.ToString())
                        {
                            continue;
                        }

                        for (DateTime idx = DateStart; idx <= DateEnd
                             ; idx = idx.AddDays(1))
                        {
                            // kiểm tra nếu nghỉ việc trong tháng, các ngày sau không hiển thị lên
                            if (profile.DateQuit != null && idx > profile.DateQuit.Value)
                            {
                                continue;
                            }

                            //In-Out
                            if (lstHoliday.Where(hol => hol.DateOff == idx).Count() > 0)
                            {
                                continue;
                            }

                            if (!Att_AttendanceServices.IsWorkDay(grade.Cat_GradeAttendance, htRoster, lstHoliday, idx) ||
                                idx < profile.DateHire ||
                                idx >= profile.DateQuit)
                            {
                                continue;
                            }

                            Att_RptExceptionDataEntity exceptionData       = null;
                            List <Att_InOut>           lstDateProfileInOut = lstProfileInOut.Where(inout => inout.WorkDate == idx).ToList();
                            //ko di lam, ko quet the
                            if (lstDateProfileInOut.Count <= 0)
                            {
                                //ko thong bao nghi
                                if (lstProfileLeaveDay.Where(ld => ld.ProfileID == profile.ID &&
                                                             ld.DateStart.Date <= idx && ld.DateEnd.Date >= idx).Count() <= 0)
                                {
                                    exceptionData = SetExceptionData(null, objProfile, null, idx, userExport);
                                    var OrgC = lstOrg.Where(m => m.ID == profile.OrgStructureID).FirstOrDefault();
                                    exceptionData.Department = OrgC != null ? OrgC.OrgStructureName : string.Empty;
                                    var orgSection = LibraryService.GetNearestParent(profile.OrgStructureID, OrgUnit.E_SECTION, lstOrg, orgTypes);
                                    exceptionData.Section = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                                    var positon = positions.FirstOrDefault(s => s.ID == profile.PositionID);
                                    exceptionData.Position = positon != null ? positon.Code : string.Empty;
                                    //exceptionData.DataType = LanguageManager.GetString(ClassNames.Att_InOut);
                                    //exceptionData.Exception = LanguageManager.GetString(Messages.MissingInOut);
                                    exceptionData.DataType    = ("Att_InOut").TranslateString();
                                    exceptionData.Exception   = ConstantMessages.MissingInOut.TranslateString();
                                    exceptionData.Description = "? - ?";
                                    Result.Add(exceptionData);
                                }
                            }
                        }
                    }
                }
                if (DifferenceMoreRoster)
                {
                    foreach (Att_InOut InOut in lstInOutAll)
                    {
                        if (InOut.InTime != null && InOut.OutTime != null)
                        {
                            if (Difference < Att_AttendanceServices.GetShiftRosterShiftInOutHour(InOut, InOut.Cat_Shift))
                            {
                                Att_RptExceptionDataEntity exceptionData = SetExceptionData(InOut, InOut.Hre_Profile
                                                                                            , InOut.Cat_Shift, InOut.WorkDate, userExport);
                                var OrgC = lstOrg.Where(m => m.ID == InOut.Hre_Profile.OrgStructureID).FirstOrDefault();
                                exceptionData.Department = OrgC != null ? OrgC.OrgStructureName : string.Empty;
                                var orgSection = LibraryService.GetNearestParent(InOut.Hre_Profile.OrgStructureID, OrgUnit.E_SECTION, lstOrg, orgTypes);
                                exceptionData.Section = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                                var positon = positions.FirstOrDefault(s => s.ID == InOut.Hre_Profile.PositionID);
                                exceptionData.Position = positon != null ? positon.Code : string.Empty;
                                //exceptionData.DataType = LanguageManager.GetString(ClassNames.Att_InOut);
                                //exceptionData.Exception = LanguageManager.GetString(Messages.DifferenceShiftRosterAndInOut) + " " + Difference + " " + LanguageManager.GetString(Messages.Hour);
                                exceptionData.DataType  = ("Att_InOut").TranslateString();
                                exceptionData.Exception = ConstantMessages.DifferenceShiftRosterAndInOut.TranslateString() + " " + Difference + " " + ConstantMessages.Hour.TranslateString();
                                String desc = "InOut: ";
                                desc += InOut.InTime.Value.ToString(ConstantFormat.HRM_Format_HourMinSecond);
                                desc += " - ";
                                desc += InOut.OutTime.Value.ToString(ConstantFormat.HRM_Format_HourMinSecond);
                                desc += " / Shift: ";
                                desc += InOut.Cat_Shift.ShiftName;

                                exceptionData.Description = desc;
                                Result.Add(exceptionData);
                            }
                        }
                    }
                }
                if (LessHours > 0)
                {
                    Double minHrs = 0;
                    //Get Hours
                    try
                    {
                        minHrs = LessHours;
                    }
                    catch (System.Exception ex)
                    {
                    }


                    List <Att_InOut> lstInOutAllLessHours = lstInOutAll.Where(d => d.InTime.HasValue && d.OutTime.HasValue).ToList();

                    foreach (Att_InOut InOut in lstInOutAllLessHours)
                    {
                        Double workHours = Att_AttendanceServices.GetInOutWorkingHour(InOut, InOut.Cat_Shift);
                        if (minHrs > workHours)
                        {
                            Att_RptExceptionDataEntity exceptionData = SetExceptionData(InOut, InOut.Hre_Profile
                                                                                        , InOut.Cat_Shift, InOut.WorkDate, userExport);
                            var OrgC = lstOrg.Where(m => m.ID == InOut.Hre_Profile.OrgStructureID).FirstOrDefault();
                            exceptionData.Department = OrgC != null ? OrgC.OrgStructureName : string.Empty;
                            var orgSection = LibraryService.GetNearestParent(InOut.Hre_Profile.OrgStructureID, OrgUnit.E_SECTION, lstOrg, orgTypes);
                            exceptionData.Section = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                            var positon = positions.FirstOrDefault(s => s.ID == InOut.Hre_Profile.PositionID);
                            exceptionData.Position = positon != null ? positon.Code : string.Empty;
                            //exceptionData.DataType = LanguageManager.GetString(ClassNames.Att_InOut);
                            //exceptionData.Exception = LanguageManager.GetString(Messages.WorkingHoursLess) + " " + Difference + " " + LanguageManager.GetString(Messages.Hour);
                            exceptionData.DataType  = ("Att_InOut").TranslateString();
                            exceptionData.Exception = ConstantMessages.WorkingHoursLess.TranslateString() + " " + Difference + " " + ConstantMessages.Hour.TranslateString();
                            String desc = "";
                            desc  = InOut.InTime.Value.ToString(ConstantFormat.HRM_Format_HourMinSecond);
                            desc += " - ";
                            desc += InOut.OutTime.Value.ToString(ConstantFormat.HRM_Format_HourMinSecond);

                            exceptionData.Description = desc;
                            Result.Add(exceptionData);
                        }
                    }
                }
                if (MissInOut)
                {
                    List <Att_InOut> lstInOutAllMissInOut = lstInOutAll.Where(wd => (wd.InTime.HasValue &&
                                                                                     !wd.OutTime.HasValue)
                                                                              ||
                                                                              (!wd.InTime.HasValue &&
                                                                               wd.OutTime.HasValue)).ToList();
                    foreach (Att_InOut InOut in lstInOutAll)
                    {
                        if (InOut.InTime == null || InOut.OutTime == null)
                        {
                            Att_RptExceptionDataEntity exceptionData = SetExceptionData(InOut, InOut.Hre_Profile, InOut.Cat_Shift, InOut.WorkDate, userExport);
                            var OrgC = lstOrg.Where(m => m.ID == InOut.Hre_Profile.OrgStructureID).FirstOrDefault();
                            exceptionData.Department = OrgC != null ? OrgC.OrgStructureName : string.Empty;
                            var orgSection = LibraryService.GetNearestParent(InOut.Hre_Profile.OrgStructureID, OrgUnit.E_SECTION, lstOrg, orgTypes);
                            exceptionData.Section = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                            var positon = positions.FirstOrDefault(s => s.ID == InOut.Hre_Profile.PositionID);
                            exceptionData.Position = positon != null ? positon.Code : string.Empty;
                            //exceptionData.DataType = LanguageManager.GetString(ClassNames.Att_InOut);
                            //exceptionData.Exception = LanguageManager.GetString(Messages.MissingInOut);
                            exceptionData.DataType  = ("Att_InOut").TranslateString();
                            exceptionData.Exception = ConstantMessages.MissingInOut.TranslateString();
                            String desc = "";
                            if (InOut.InTime != null)
                            {
                                desc = InOut.InTime.Value.ToString(ConstantFormat.HRM_Format_HourMinSecond);
                            }
                            else
                            {
                                desc = "?";
                            }
                            desc += " - ";
                            if (InOut.OutTime != null)
                            {
                                desc += InOut.OutTime.Value.ToString(ConstantFormat.HRM_Format_HourMinSecond);
                            }
                            else
                            {
                                desc += "?";
                            }
                            exceptionData.Description = desc;
                            Result.Add(exceptionData);
                        }
                    }
                }
                return(Result);
            }
        }