示例#1
0
        public Rec_InterviewModel Post([Bind]Rec_InterviewModel model)
        {
            #region Validate
            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Rec_InterviewModel>(model, "Rec_Interview", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
            #endregion

           
            ActionService service = new ActionService(UserLogin);
            var result = service.UpdateOrCreate<Rec_InterviewEntity, Rec_InterviewModel>(model);

            var RecruitmentHisService = new Rec_RecruitmentHistoryServices();
            var candService = new Rec_CandidateServices();
            var InTerCamDetaiServices = new Rec_InterviewCampaignDetailServices();

            Rec_RecruitmentHistoryEntity ObjRecruitmentHistory = null;
            Rec_RecruitmentHistoryServices RecruitmentHistoryServices = new Rec_RecruitmentHistoryServices();

            Rec_CandidateEntity ObjCandidate = null;
            Rec_CandidateServices CandidateServices = new Rec_CandidateServices();

            Rec_InterviewCampaignDetailEntity ObjInterviewCampaignDetail = null;
            Rec_InterviewCampaignDetailServices InterviewCampaignDetailServices = new Rec_InterviewCampaignDetailServices();

            string status = string.Empty;
            #region xử lý cap nhat lich su ung vien, cap nhat ung vien
            if (result != null)
            {
                ObjRecruitmentHistory = new Rec_RecruitmentHistoryEntity();
                ObjCandidate = new Rec_CandidateEntity();
                ObjInterviewCampaignDetail = new Rec_InterviewCampaignDetailEntity();

                var IlRecruitmentHistory = RecruitmentHisService.GetData<Rec_RecruitmentHistoryEntity>(result.CandidateID, ConstantSql.hrm_rec_sp_get_RecruitmentHistoryIdByCandidateId,UserLogin, ref status).OrderByDescending(s => s.DateApply).FirstOrDefault();
                var IlCandate = candService.GetData<Rec_CandidateEntity>(result.CandidateID, ConstantSql.hrm_rec_sp_get_CandidateById, UserLogin, ref status).FirstOrDefault();
                var IlInterviewcampaugnDetail = InTerCamDetaiServices.GetData<Rec_InterviewCampaignDetailEntity>(result.CandidateID, ConstantSql.hrm_rec_sp_get_InterviewCampaignDetailByCddId, UserLogin ,ref status).ToList();

                ObjCandidate = IlCandate;
                ObjRecruitmentHistory = IlRecruitmentHistory;
                if (IlCandate != null)
                {
                    string[] strCondition = model.ConditionTemp.Split('|').ToArray();
                    foreach (var Objitem in strCondition)
                    {
                        string[] item = Objitem.Split(',').ToArray();
                        if(item[0].ToString() == EnumDropDown.JobCondition.E_HEIGHT.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.Height = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_WEIGHT.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.Weight = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_LEVELEYES.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.LevelEye = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_LEVERIGHTLEYES.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.LevelEyeRight = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_MUSCULOSKELETAL.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.Musculoskeletal = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_BLOODPRESSURE.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.BloodPressure = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_HEARTBEAT.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.HeartBeat = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_GENARALHEALTH.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.GenaralHealth = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_DISEASELISTIDS.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.DiseaseListIDs = item[1].ToString();
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_WRITETEST.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.WriteTest = double.Parse(item[1].ToString());
                            }
                        }
                        else if (item[0].ToString() == EnumDropDown.JobCondition.E_INTERVIEW.ToString())
                        {
                            if (item[1] != null && item[1] != "")
                            {
                                ObjCandidate.Interview = double.Parse(item[1].ToString());
                            }
                        }
                    }
                    ObjCandidate.LevelInterview = result.LevelInterview;
                    if (result.ResultInterview.Equals(HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString()))
                    {
                        ObjCandidate.Status = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                        ObjCandidate.DateUpdate = DateTime.Now;
                    }
                    // Nếu có nhập điểm thì gán ngày đánh giá = ngày phỏng vấn
                    if (model != null && (model.Score1 != null || model.Score2 != null))
                    {
                        ObjCandidate.DateExam = model.DateInterview;
                        ObjCandidate.DateUpdate = DateTime.Now;
                    }
                    if(ObjCandidate.JobVacancyID != null)
                    {
                        var entityJobVacancy = service.GetData<Rec_JobVacancyEntity>(Common.DotNetToOracle(ObjCandidate.JobVacancyID.ToString()), ConstantSql.hrm_rec_sp_get_JobVacancyId, ref status).FirstOrDefault();
                        if (entityJobVacancy.NoLevelInterview == result.LevelInterview && result.ResultInterview.Equals(HRM.Infrastructure.Utilities.Interview.E_PASS.ToString()))
                        {
                            if (IlCandate != null)
                            {
                                ObjCandidate.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_PASS.ToString();
                                ObjCandidate.DateUpdate = DateTime.Now;
                            }
                            if (IlRecruitmentHistory != null)
                            {
                                ObjRecruitmentHistory.Status = HRM.Infrastructure.Utilities.Interview.E_PASS.ToString();
                                ObjRecruitmentHistory.DateUpdate = DateTime.Now;
                            }
                        }
                    }
                }

                if (IlRecruitmentHistory != null)
                {
                    // Nếu có nhập điểm thì gán ngày đánh giá = ngày phỏng vấn
                    if (model != null && (model.Score1 != null || model.Score2 != null))
                    {
                        IlRecruitmentHistory.DateExam = model.DateInterview;
                    }
                    ObjRecruitmentHistory = IlRecruitmentHistory;
                    ObjRecruitmentHistory.LevelInterview = result.LevelInterview;
                    if (result.ResultInterview.Equals(HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString()))
                    {
                        //cap nhat status cho lich su ung vien
                        ObjRecruitmentHistory.Status = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                    }
                }

                //Cập nhật level cho intercampaigndetail
                if (IlInterviewcampaugnDetail != null)
                {
                    var ObjTemp = IlInterviewcampaugnDetail.Where(s => s.CandidateID == result.CandidateID && s.LevelInterview == null).FirstOrDefault();
                    if (ObjTemp != null)
                    {
                        ObjInterviewCampaignDetail = ObjTemp;
                        ObjInterviewCampaignDetail.LevelInterview = result.LevelInterview;
                    }
                }

                message = InterviewCampaignDetailServices.Edit(ObjInterviewCampaignDetail);
                message = RecruitmentHistoryServices.Edit(ObjRecruitmentHistory);
                message = CandidateServices.Edit(ObjCandidate);
            }
            #endregion
            return result;
        }
示例#2
0
 public ActionResult SendMailCandidatePass([DataSourceRequest] DataSourceRequest request, List<Guid> candidateIds)
 {
     var service = new Rec_CandidateServices();
     bool result = false;
     if (candidateIds != null && candidateIds.Any())
     {
         result = service.SendMailCandidateFail(candidateIds, true);
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
示例#3
0
 // Click nút gọi điện ds ứng viên trúng tuyển
 public ActionResult SubmitCall(string selectedIds)
 {
     List<Guid> ids = new List<Guid>();
     if (selectedIds != null)
     {
         ids = selectedIds
            .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(x => Guid.Parse(x))
            .ToList();
     }
     var lstMealRecordMissing = new List<Rec_CandidateEntity>();
     var services = new Rec_CandidateServices();
     services.SubmitCall(ids);
     return Json("");
 }
示例#4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        //public Rec_InterviewModel DeleteOrRemove(string id)
        //{
        //    ActionService service = new ActionService(UserLogin);
        //    var result = service.DeleteOrRemove<Rec_InterviewEntity, Rec_InterviewModel>(id);
        //    return result;
        //}

        public void Delete(Guid ID)
        {
            var service = new Rec_CandidateServices();
            var result = service.Remove<Rec_InterviewEntity>(ID);
        }
示例#5
0
 public ActionResult UpdateStatusHireCandidate(string selectedIds, string userID)
 {
     var service = new Rec_CandidateServices();
     service.UpdateStatusHireCandidate(selectedIds, userID, UserLogin);
     return Json("true", JsonRequestBehavior.AllowGet);
 }
示例#6
0
        public ActionResult GetFilterCandidateList([DataSourceRequest] DataSourceRequest request, Rec_FilterCandidateModel model)
        {
            var services = new Rec_CandidateServices();
            var dateFrom = DateTime.Now.Date;
            var dateTo = DateTime.Now.Date;
            var lstModel = new List<Rec_CandidateModel>();

            if (model.DateFrom != null)
            {
                dateFrom = model.DateFrom.Value;
            }

            if (model.DateTo != null)
            {
                dateTo = model.DateTo.Value;
            }
            var result = services.FilterCandidate(dateFrom, dateTo, model.JobVacancyIDs, UserLogin, model.GetListFail, model.IsIncludeEvaCandidate).ToList();
            if (result.Count > 0)
            {
                lstModel = result.Translate<Rec_CandidateModel>();
            }
            return Json(lstModel.ToDataSourceResult(request));
            //return GetListDataAndReturn<Rec_CandidateModel, Rec_CandidateEntity, Rec_CandidateGeneralMultiSearchModel>(request, candidateModel, ConstantSql.hrm_hr_sp_get_Candidate_GeneralGrid);
        }
示例#7
0
 public ActionResult AddToBlackListCandidate([Bind]Rec_CandidateModel model)
 {
     var service = new Rec_CandidateServices();
     var message = service.ActionBlackListCandidate(model.lstprofileid, model.ReasonBlackListID);
     return Json(message);
 }
示例#8
0
 public ActionResult GetHistoryApprove(string HistoryApproves)
 {
     var service = new Rec_CandidateServices();
     //var rs = service.GetHistoryApprove(HistoryApprove);
     string strResult = HistoryApproves ?? string.Empty;
     List<HistoryApprove> listHistoryApprove = new List<HistoryApprove>();
     HistoryApprove historyApp = null;
     string[] arrHistory = strResult.Split(new char[] { ';' });
     foreach (string history in arrHistory)
     {
         int index__ = history.IndexOf("#");
         if (index__ > 0)
         {
             historyApp = new HistoryApprove();
             string[] arr = history.Split(new char[] { '#' });
             if (arr.Length < 5)
                 continue;
             historyApp.DateApprove = arr[0];
             historyApp.UserApprove = arr[1];
             historyApp.Status = EnumDropDown.GetEnumDescription(arr[2]);
             //Dich Change
             string[] _change = arr[3].Split(new char[] { '$' });
             if (_change.Length == 2)
                 historyApp.Changes = EnumDropDown.GetEnumDescription(_change[0]) + " ==> " + EnumDropDown.GetEnumDescription(_change[1]);
             historyApp.WaitUserApprove = arr[4];
             listHistoryApprove.Add(historyApp);
         }
     }
     return Json(listHistoryApprove, JsonRequestBehavior.AllowGet);
 }
示例#9
0
 public ActionResult BackToInterview(string selectedIds)
 {
     var service = new Rec_CandidateServices();
     var message = service.BackToInterview(selectedIds);
     return Json(message);
 }
示例#10
0
 public ActionResult ComeBackToCandidate(string selectedIds)
 {
     var service = new Rec_CandidateServices();
     var message = service.CombackToCandidate(selectedIds);
     return Json(message);
 }
示例#11
0
 public ActionResult OutOfBlackList(string selectedIds)
 {
     var service = new Rec_CandidateServices();
     var message = service.OutOfBlackList(selectedIds);
     return Json(message);
 }
示例#12
0
 public ActionResult CancelCandidate(string selectedIds)
 {
     var service = new Rec_CandidateServices();
     var message = service.ActionCancelCandidate(selectedIds);
     return Json(message);
 }
示例#13
0
 public ActionResult UpdateReasonDenny([Bind]Rec_CandidateModel model)
 {
     IList<Rec_CandidateEntity> list = new List<Rec_CandidateEntity>();
     if (!string.IsNullOrEmpty(model.listId))
     {
         List<Guid> lisIDs = model.listId.Split(',').Select(x => Guid.Parse(x)).ToList();
         Rec_CandidateEntity ObjProfile = null;
         Rec_CandidateServices CandidateService = new Rec_CandidateServices();
         foreach (Guid item in lisIDs)
         {
             string status = string.Empty;
             ObjProfile = new Rec_CandidateEntity();
             var ResultProfile = CandidateService.GetData<Rec_CandidateEntity>(item, ConstantSql.hrm_rec_sp_get_CandidateById, UserLogin, ref status).FirstOrDefault();
             ObjProfile = ResultProfile;
             ObjProfile.StatusHire = HRM.Infrastructure.Utilities.ProfileStatusSyn.E_UNHIRE.ToString();
             ObjProfile.ReasonDeny = model.ReasonDeny;
             //ObjProfile.StatusSyn = HRM.Infrastructure.Utilities.ProfileStatusSyn.E_UNHIRE.ToString();
             CandidateService.Edit(ObjProfile);
             list.Add(ObjProfile);
         }
     }
     return Json(list);
 }
示例#14
0
        public List<Rec_CandidateEntity> FilterCandidate(DateTime dateFrom, DateTime dateTo, string jobVacancyIDs, string UserLogin, bool GetListFail = false, bool IsIncludeEvaCandidate = false)
        {
            List<Rec_CandidateEntity> lstCandidateResultPass = new List<Rec_CandidateEntity>();
            List<Rec_CandidateEntity> lstCandidateResultFail = new List<Rec_CandidateEntity>();
            using (var context = new VnrHrmDataContext())
            {
                BaseService service = new BaseService();
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoJobVacancy = new Rec_JobVacancyRepository(unitOfWork);
                var repoProfile = new Hre_ProfileRepository(unitOfWork);
                var repoJobCondition = new Rec_JobConditionRepository(unitOfWork);
                var repoCadidate = new Rec_CandidateRepository(unitOfWork);
                var repoRecruimentHistory = new Rec_RecruitmentHistoryRepository(unitOfWork);
                string status = string.Empty;
                #region Lấy tất cả nv
                var profileRepository = new Hre_ProfileRepository(unitOfWork);
                var lstProfile = new List<Hre_Profile>().Select(s => new
                {
                    s.ID,
                    s.IDNo,
                    s.ProfileName,
                    s.DateOfBirth
                }).ToList();

                lstProfile.AddRange(profileRepository.FindBy(s => s.IsDelete == null).Select(s => new
                {
                    s.ID,
                    s.IDNo,
                    s.ProfileName,
                    s.DateOfBirth
                }).ToList());
                #endregion

                var lstJobCondition = repoJobCondition.FindBy(s => s.IsDelete == null).ToList();
                List<object> lstpara = new List<object>();
                lstpara.Add(dateFrom);
                lstpara.Add(dateTo);
                lstpara.Add(Common.DotNetToOracle(jobVacancyIDs));

                var lstCandidate = service.GetData<Rec_CandidateEntity>(lstpara, ConstantSql.hrm_rec_sp_getdata_FilterCandidate, UserLogin, ref status);
                if (lstCandidate == null || lstCandidate.Count == 0)
                {
                    return new List<Rec_CandidateEntity>();
                }

                if (IsIncludeEvaCandidate == false)
                {
                    lstCandidate = lstCandidate.Where(x => x.Status == null || x.Status == HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_NEW.ToString()).ToList();
                }

                if (lstCandidate == null || lstCandidate.Count == 0)
                {
                    return new List<Rec_CandidateEntity>();
                }

                var lstCandidateIds = lstCandidate.Select(s => s.ID).Distinct().ToList();


                #region Lấy ds pv
                var interviewRepository = new Rec_InterviewRepository(unitOfWork);
                var lstInterview = new List<Rec_Interview>().Select(s => new
                {
                    s.CandidateID,
                    s.LevelInterview,
                    s.Score1,
                    s.Score2,
                    s.Score3,
                    s.DateUpdate
                }).ToList();

                lstInterview.AddRange(interviewRepository.FindBy(s => s.IsDelete == null && lstCandidateIds.Contains(s.CandidateID.Value)).Select(s => new 
                {   s.CandidateID,
                    s.LevelInterview,
                    s.Score1,
                    s.Score2,
                    s.Score3,
                    s.DateUpdate
                }).ToList());

                #endregion
                var RecruitmentHistoryRepository = new Rec_RecruitmentHistoryRepository(unitOfWork);
                var lstrecruitmentHistory = RecruitmentHistoryRepository.FindBy(s => s.IsDelete == null && lstCandidateIds.Contains(s.CandidateID)).ToList();

                List<object> lstparaEdu = new List<object>();
                lstparaEdu.Add(null);
                lstparaEdu.Add(1);
                lstparaEdu.Add(int.MaxValue - 1);
                var lstEducationLevel = service.GetData<Cat_NameEntityEntity>(lstparaEdu, ConstantSql.hrm_cat_sp_get_EducationLevel, UserLogin,ref status).ToList();

                List<object> lstparadiseelist = new List<object>();
                lstparadiseelist.Add(null);
                lstparadiseelist.Add(EnumDropDown.EntityType.E_SICK_REC.ToString());
                lstparadiseelist.Add(1);
                lstparadiseelist.Add(int.MaxValue - 1);
                var lstsick = service.GetData<Cat_NameEntityEntity>(lstparadiseelist, ConstantSql.hrm_cat_sp_get_LevelGeneral, UserLogin,ref status).ToList();

                List<object> lstparaProvince = new List<object>();
                lstparaProvince.Add(null);
                lstparaProvince.Add(null);
                lstparaProvince.Add(null);
                lstparaProvince.Add(null);
                lstparaProvince.Add(1);
                lstparaProvince.Add(int.MaxValue - 1);
                var lstProvince = service.GetData<Cat_ProvinceEntity>(lstparaProvince, ConstantSql.hrm_cat_sp_get_Province, UserLogin, ref status).ToList();

                foreach (var item in lstCandidate)
                {
                    string ReasonFailFilter = string.Empty;
                    // nếu ko có điều kiện thì add vào ds fail
                    if (string.IsNullOrEmpty(item.JobConditionIDs))
                    {
                        lstCandidateResultPass.Add(item);
                        continue;
                    }

                    if (item.IsFilterCV == null || item.IsFilterCV == false)
                    {
                        lstCandidateResultPass.Add(item);
                        continue;
                    }

                    // nếu có thì bắt đầu lọc
                    else
                    {
                        List<Guid> ids = new List<Guid>();
                        ids = item.JobConditionIDs
                               .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                               .Select(x => Guid.Parse(x))
                               .ToList();
                        var lstCondition = lstJobCondition.Where(x => ids.Contains(x.ID)).ToList();
                        int countCondition = lstCondition.Count;
                        int countAgree = 0;
                        foreach (var Condition in lstCondition)
                        {
                            #region Kiểm tra Tổng Điểm Phỏng Vấn
                            if (Condition.ConditionName == ConditionName.E_INTERVIEW.ToString())
                            {
                                double valueInterview1 = 0;
                                try
                                {
                                    valueInterview1 = double.Parse(Condition.Value1);
                                }
                                catch
                                {

                                }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.Interview == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueInterview1 != 0 && item.Interview.HasValue)
                                {

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueInterview1 <= item.Interview)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueInterview1 >= item.Interview)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueInterview1 == item.Interview)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueInterview1 != 0 && item.Interview.HasValue)
                                {


                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueInterview1 <= item.Interview)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueInterview1 >= item.Interview)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueInterview1 != item.Interview)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                            }
                            #endregion
                            #region Kiểm tra Điểm Thi Viết
                            if (Condition.ConditionName == ConditionName.E_WRITETEST.ToString())
                            {
                                double valueWriteTest1 = 0;
                                try
                                {
                                    valueWriteTest1 = double.Parse(Condition.Value1);
                                }
                                catch
                                { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.WriteTest == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueWriteTest1 != 0 && item.WriteTest.HasValue)
                                {

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueWriteTest1 <= item.WriteTest)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueWriteTest1 >= item.WriteTest)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueWriteTest1 == item.WriteTest)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueWriteTest1 != 0 && item.WriteTest.HasValue)
                                {


                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueWriteTest1 <= item.WriteTest)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueWriteTest1 >= item.WriteTest)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueWriteTest1 != item.WriteTest)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                            }
                            #endregion
                            #region Kiểm tra Tổng Sức Khỏe
                            if (Condition.ConditionName == ConditionName.E_GENERALHEALTH.ToString())
                            {
                                double valueHealth1 = 0;
                                try
                                {
                                    valueHealth1 = double.Parse(Condition.Value1);
                                }
                                catch
                                { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.GenaralHealth == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueHealth1 != 0 && item.GenaralHealth.HasValue)
                                {


                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueHealth1 <= item.GenaralHealth)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueHealth1 >= item.GenaralHealth)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueHealth1 == item.GenaralHealth)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && item.GenaralHealth.HasValue && valueHealth1 != 0)
                                {


                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueHealth1 <= item.GenaralHealth)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueHealth1 >= item.GenaralHealth)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueHealth1 != item.GenaralHealth)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm tra cao
                            if (Condition.ConditionName == ConditionName.E_HEIGHT.ToString())
                            {
                                double valueHeight1 = 0;
                                try
                                {
                                    valueHeight1 = double.Parse(Condition.Value1);
                                }
                                catch
                                { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.Height == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueHeight1 != 0 && item.Height.HasValue)
                                {


                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueHeight1 <= item.Height)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueHeight1 >= item.Height)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueHeight1 == item.Height)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && item.Height.HasValue && valueHeight1 != 0)
                                {


                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.Height <= valueHeight1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.Height >= valueHeight1)
                                    {

                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueHeight1 != item.Height)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm tra Cân Nặng
                            if (Condition.ConditionName == ConditionName.E_WEIGHT.ToString())
                            {

                                double valueWeight1 = 0;
                                try
                                {
                                    valueWeight1 = double.Parse(Condition.Value1);
                                }
                                catch { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.Weight == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueWeight1 != 0 && item.Weight.HasValue)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.Weight == valueWeight1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.Weight >= valueWeight1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.Height <= valueWeight1)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueWeight1 != 0 && item.Weight.HasValue)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.Weight != valueWeight1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.Weight <= valueWeight1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.Height >= valueWeight1)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm Tra Mắt
                            #region Mắt Trái
                            if (Condition.ConditionName == ConditionName.E_LEVELEYES.ToString())
                            {

                                double valueEyes1 = 0;
                                // double Eyes = 0;
                                try
                                {
                                    valueEyes1 = double.Parse(Condition.Value1);
                                    //  Eyes = double.Parse(item.LevelEye);
                                }
                                catch { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (!item.LevelEye.HasValue)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueEyes1 != 0)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.LevelEye.Value == valueEyes1)
                                    {
                                        countAgree++;
                                        continue;

                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.LevelEye.Value >= valueEyes1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.LevelEye.Value <= valueEyes1)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueEyes1 != 0)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.LevelEye.Value != valueEyes1)
                                    {
                                        countAgree++;
                                        continue;

                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.LevelEye.Value <= valueEyes1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.LevelEye.Value >= valueEyes1)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Mắt Phải
                            if (Condition.ConditionName == ConditionName.E_LEVERIGHTLEYES.ToString())
                            {

                                double valueEyes1 = 0;
                                // double Eyes = 0;
                                try
                                {
                                    valueEyes1 = double.Parse(Condition.Value1);
                                    //  Eyes = double.Parse(item.LevelEye);
                                }
                                catch { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (!item.LevelEye.HasValue)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueEyes1 != 0)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.LevelEyeRight.Value == valueEyes1)
                                    {
                                        countAgree++;
                                        continue;

                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.LevelEyeRight.Value >= valueEyes1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.LevelEyeRight.Value <= valueEyes1)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueEyes1 != 0)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.LevelEyeRight.Value != valueEyes1)
                                    {
                                        countAgree++;
                                        continue;

                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.LevelEyeRight.Value <= valueEyes1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.LevelEyeRight.Value >= valueEyes1)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #endregion
                            #region Kiểm tra Thời Gian Trượt Kỳ Trước
                            if (Condition.ConditionName == ConditionName.E_DURATIONFAILPREVIOUS.ToString())
                            {
                                if (lstrecruitmentHistory == null || lstrecruitmentHistory.Count == 0)
                                {
                                    countAgree++;
                                    continue;
                                }
                                int valueDuration1 = int.Parse(Condition.Value1);
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                {

                                    var listCandidateHis = lstrecruitmentHistory.Where(x => x.CandidateID == item.ID && x.Status == HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_FAIL.ToString())
                                        .OrderByDescending(x => x.DateApply).ToList();
                                    if (listCandidateHis == null || listCandidateHis.Count == 0)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (listCandidateHis != null && listCandidateHis.Count != 0)
                                    {
                                        var CandidateHistory = listCandidateHis.FirstOrDefault();
                                        double month = 0;
                                        if (CandidateHistory.DateApply != null && item.DateApply != null)
                                        {

                                            month = (new DateTime(item.DateApply.Value.Subtract(CandidateHistory.DateApply.Value).Ticks).Year - 1) > 0 ? (new DateTime(item.DateApply.Value.Subtract(CandidateHistory.DateApply.Value).Ticks).Year - 1) : (item.DateApply.Value.Subtract(CandidateHistory.DateApply.Value).TotalDays / (365.25 / 12));

                                        }

                                        if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && month == valueDuration1)
                                        {
                                            countAgree++;
                                            continue;
                                        }

                                        if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && month > valueDuration1)
                                        {
                                            countAgree++;
                                            continue;
                                        }

                                        if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && month < valueDuration1)
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                        else
                                        {
                                            ReasonFailFilter += Condition.ConditionName + ",";
                                        }
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                {

                                    var listCandidateHis = lstrecruitmentHistory.Where(x => x.CandidateID == item.ID && x.Status == HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_FAIL.ToString())
                                        .OrderByDescending(x => x.DateApply).ToList();
                                    if (listCandidateHis == null || listCandidateHis.Count == 0)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (listCandidateHis != null && listCandidateHis.Count != 0)
                                    {

                                        var CandidateHistory = listCandidateHis.FirstOrDefault();
                                        double month = 0;
                                        if (CandidateHistory.DateApply != null && item.DateApply != null)
                                        {
                                            month = (new DateTime(item.DateApply.Value.Subtract(CandidateHistory.DateApply.Value).Ticks).Year - 1) > 0 ? (new DateTime(item.DateApply.Value.Subtract(CandidateHistory.DateApply.Value).Ticks).Year - 1) : (item.DateApply.Value.Subtract(CandidateHistory.DateApply.Value).TotalDays / (365.25 / 12));
                                        }

                                        if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && month != valueDuration1)
                                        {
                                            countAgree++;
                                            continue;

                                        }

                                        if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && month < valueDuration1)
                                        {
                                            countAgree++;
                                            continue;
                                        }

                                        if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && month > valueDuration1)
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                        else
                                        {
                                            ReasonFailFilter += Condition.ConditionName + ",";
                                        }
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm tra Từ Tuổi
                            if (Condition.ConditionName == ConditionName.E_AGE.ToString())
                            {
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.DateOfBirth == null)
                                {
                                    countAgree++;
                                    continue;
                                }

                                //double AgeCadidate = DateTime.Now.Subtract(item.DateOfBirth).TotalDays / 365.242199;

                                //AgeCadidate = Math.Round(AgeCadidate, 2);

                                double? AgeCadidate = (new DateTime(DateTime.Now.Subtract(item.DateOfBirth).Ticks).Year - 1) > 0 ? (new DateTime(DateTime.Now.Subtract(item.DateOfBirth).Ticks).Year - 1) : (DateTime.Now.Subtract(item.DateOfBirth).TotalDays / 365.242199);

                                double? valueAge = 0;
                                try
                                {
                                    valueAge = int.Parse(Condition.Value1);
                                }
                                catch
                                {
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && AgeCadidate > 0)
                                {

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && AgeCadidate >= valueAge)
                                    {
                                        countAgree++;
                                        continue;

                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && AgeCadidate <= valueAge)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && AgeCadidate == valueAge)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && AgeCadidate > 0)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && AgeCadidate <= valueAge)
                                    {
                                        countAgree++;
                                        continue;

                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && AgeCadidate >= valueAge)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && AgeCadidate != valueAge)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                            }
                            #endregion
                            #region Kiểm tra Giới Tính
                            if (Condition.ConditionName == ConditionName.E_GENDER.ToString())
                            {
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (string.IsNullOrEmpty(item.Gender))
                                {
                                    countAgree++;
                                    continue;
                                }
                                string valueGender = Condition.Value1;

                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                {

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.Gender.Equals(valueGender))
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && !item.Gender.Equals(valueGender))
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                            }
                            #endregion
                            #region Kiểm Tra Đã làm ở cty chưa
                            if (Condition.ConditionName == ConditionName.E_ISTERMINATEINCOMPANY.ToString() && Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString())
                            {
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                {

                                    if (lstProfile != null && lstProfile.Count != 0)
                                    {
                                        // nếu có CMND thì ưu tiên kiểm tra trước
                                        if (!string.IsNullOrEmpty(item.IdentifyNumber))
                                        {
                                            var Profile = lstProfile.FirstOrDefault(x => !string.IsNullOrEmpty(x.IDNo) && x.IDNo == item.IdentifyNumber);
                                            if (Profile == null)
                                            {
                                                countAgree++;
                                                continue;
                                            }
                                        }
                                        // nếu ko có CMND thì kiểm tra tên và ngày sinh 
                                        else if (!string.IsNullOrEmpty(item.CandidateName) && item.DateOfBirth != null)
                                        {
                                            var Profile = lstProfile.FirstOrDefault(x => !string.IsNullOrEmpty(x.ProfileName) && x.DateOfBirth.HasValue && x.ProfileName == item.CandidateName && item.DateOfBirth == x.DateOfBirth.Value);
                                            if (Profile == null)
                                            {
                                                countAgree++;
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            ReasonFailFilter += Condition.ConditionName + ",";
                                        }
                                    }
                                }
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                {
                                    if (lstProfile != null && lstProfile.Count != 0)
                                    {
                                        // nếu có CMND thì ưu tiên kiểm tra trước
                                        if (!string.IsNullOrEmpty(item.IdentifyNumber))
                                        {
                                            var Profile = lstProfile.FirstOrDefault(x => !string.IsNullOrEmpty(x.IDNo) && x.IDNo == item.IdentifyNumber);
                                            if (Profile == null)
                                            {
                                                countAgree++;
                                                continue;
                                            }
                                            else
                                            {
                                                ReasonFailFilter += Condition.ConditionName + ",";
                                            }
                                        }
                                        // nếu ko có CMND thì kiểm tra tên và ngày sinh 
                                        else if (!string.IsNullOrEmpty(item.CandidateName) && item.DateOfBirth != null)
                                        {
                                            var Profile = lstProfile.FirstOrDefault(x => !string.IsNullOrEmpty(x.ProfileName) && x.DateOfBirth.HasValue && x.ProfileName == item.CandidateName && item.DateOfBirth.Date == x.DateOfBirth.Value.Date);
                                            if (Profile == null)
                                            {
                                                countAgree++;
                                                continue;
                                            }
                                            else
                                            {
                                                ReasonFailFilter += Condition.ConditionName + ",";
                                            }
                                        }
                                        else
                                        {
                                            ReasonFailFilter += Condition.ConditionName + ",";
                                        }
                                    }
                                }
                            }
                            #endregion
                            #region Kiểm Tra Bệnh Loại Trừ
                            if (Condition.ConditionName == ConditionName.E_DISEASEIDS.ToString())
                            {
                                // nếu ko có bệnh thì qua
                                if (string.IsNullOrEmpty(item.DiseaseListIDs))
                                {
                                    countAgree++;
                                    continue;

                                }
                                // nếu có chứa bệnh nào thì ko qua
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                {
                                    if (!string.IsNullOrEmpty(Condition.Value1))
                                    {
                                        //lấy ds bệnh của đk tuyển
                                        var lstDiseaseCondition = Condition.Value1.Split(',').Select(x => x).ToList();

                                        var lstsickbycondition = lstsick.Where(s => lstDiseaseCondition.Contains(Common.DotNetToOracle(s.ID.ToString()))).ToList();
                                        // lấy ds mã bệnh của candidate - vì candidate lưu mã
                                        var lstDiseseCandidate = item.DiseaseListIDs.Split(',').ToList();
                                        if (lstsickbycondition.Where(x => lstDiseseCandidate.Contains(x.Code)).Count() == 0)
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                        else
                                        {
                                            ReasonFailFilter += Condition.ConditionName + ",";
                                        }
                                    }
                                }
                                else if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                {
                                    if (!string.IsNullOrEmpty(Condition.Value1))
                                    {
                                        //lấy ds bệnh của đk tuyển
                                        var lstDiseaseCondition = Condition.Value1.Split(',').Select(x => x).ToList();

                                        var lstsickbycondition = lstsick.Where(s => lstDiseaseCondition.Contains(Common.DotNetToOracle(s.ID.ToString()))).ToList();
                                        // lấy ds mã bệnh của candidate - vì candidate lưu mã
                                        var lstDiseseCandidate = item.DiseaseListIDs.Split(',').ToList();
                                        if (lstsickbycondition.Where(x => lstDiseseCandidate.Contains(x.Code)).Count() != 0)
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                        else
                                        {
                                            ReasonFailFilter += Condition.ConditionName + ",";
                                        }
                                    }
                                }
                            }
                            #endregion
                            #region Kiểm tra điểm thi
                            #region Điểm 1
                            if (Condition.ConditionName == ConditionName.E_SCORE1.ToString())
                            {
                                if (lstInterview == null)
                                {
                                    ReasonFailFilter += Condition.ConditionName + ",";
                                    continue;
                                }
                                var lstinterviewbyCandidate = lstInterview.Where(s => s.CandidateID == item.ID).ToList();
                                if (lstinterviewbyCandidate == null || (lstinterviewbyCandidate != null && lstinterviewbyCandidate.Count == 0))
                                {
                                    countAgree++;
                                    continue;
                                }

                                var interviewbyCan = lstinterviewbyCandidate.Where(s => s.LevelInterview == item.LevelInterview).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                                if (interviewbyCan == null)
                                    continue;
                                double? valueScore1Condition = double.Parse(Condition.Value1);
                                double? valueScore1 = interviewbyCan.Score1;
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore1 == valueScore1Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore1 > valueScore1Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore1 < valueScore1Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore1 != valueScore1Condition)
                                    {
                                        countAgree++;
                                        continue;

                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore1 < valueScore1Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore1 > valueScore1Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                            }
                            #endregion
                            #region Điểm 2
                            if (Condition.ConditionName == ConditionName.E_SCORE2.ToString())
                            {
                                if (lstInterview == null)
                                {
                                    ReasonFailFilter += Condition.ConditionName + ",";
                                    continue;
                                }
                                var lstinterviewbyCandidate = lstInterview.Where(s => s.CandidateID == item.ID).ToList();
                                if (lstinterviewbyCandidate == null || (lstinterviewbyCandidate != null && lstinterviewbyCandidate.Count == 0))
                                {
                                    countAgree++;
                                    continue;
                                }

                                var interviewbyCan = lstinterviewbyCandidate.Where(s => s.LevelInterview == item.LevelInterview).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                                if (interviewbyCan == null)
                                    continue;
                                double? valueScore2Condition = double.Parse(Condition.Value1);
                                double? valueScore2 = interviewbyCan.Score2;
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore2 == valueScore2Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore2 > valueScore2Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore2 < valueScore2Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore2 != valueScore2Condition)
                                    {
                                        countAgree++;
                                        continue;

                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore2 < valueScore2Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore2 > valueScore2Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                            }
                            #endregion
                            #region Điểm 3
                            if (Condition.ConditionName == ConditionName.E_SCORE3.ToString())
                            {
                                if (lstInterview == null || lstInterview.Count == 0)
                                {
                                    ReasonFailFilter += Condition.ConditionName + ",";
                                    continue;
                                }
                                var lstinterviewbyCandidate = lstInterview.Where(s => s.CandidateID == item.ID).ToList();
                                if (lstinterviewbyCandidate == null || (lstinterviewbyCandidate != null && lstinterviewbyCandidate.Count == 0))
                                {
                                    countAgree++;
                                    continue;
                                }

                                var interviewbyCan = lstinterviewbyCandidate.Where(s => s.LevelInterview == item.LevelInterview).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                                if (interviewbyCan == null)
                                    continue;
                                double? valueScore3Condition = double.Parse(Condition.Value1);
                                double? valueScore3 = interviewbyCan.Score3;
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore3 == valueScore3Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore3 > valueScore3Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore3 < valueScore3Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore3 != valueScore3Condition)
                                    {
                                        countAgree++;
                                        continue;

                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore3 < valueScore3Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore3 > valueScore3Condition)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                            }
                            #endregion
                            #endregion
                            #region Kiểm tra Hệ Vận Động
                            if (Condition.ConditionName == ConditionName.E_MUSCULOSKELETAL.ToString())
                            {

                                double valuemusculoskeletal = 0;
                                try
                                {
                                    valuemusculoskeletal = double.Parse(Condition.Value1);
                                }
                                catch { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.Musculoskeletal == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valuemusculoskeletal != 0 && item.Musculoskeletal.HasValue)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.Musculoskeletal == valuemusculoskeletal)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.Musculoskeletal >= valuemusculoskeletal)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.Musculoskeletal <= valuemusculoskeletal)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valuemusculoskeletal != 0 && item.Musculoskeletal.HasValue)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.Musculoskeletal != valuemusculoskeletal)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.Musculoskeletal < valuemusculoskeletal)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.Musculoskeletal > valuemusculoskeletal)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm tra Huyết Áp
                            if (Condition.ConditionName == ConditionName.E_BLOODPRESSURE.ToString())
                            {

                                double bloodpressure = 0;
                                try
                                {
                                    bloodpressure = double.Parse(Condition.Value1);
                                }
                                catch { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.BloodPressure == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && bloodpressure != 0 && item.BloodPressure.HasValue)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.BloodPressure == bloodpressure)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.BloodPressure >= bloodpressure)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.BloodPressure <= bloodpressure)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && bloodpressure != 0 && item.BloodPressure.HasValue)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.BloodPressure != bloodpressure)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.BloodPressure < bloodpressure)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.BloodPressure > bloodpressure)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm tra Nhịp Tim
                            if (Condition.ConditionName == ConditionName.E_HEARTBEAT.ToString())
                            {
                                double heartbeat = 0;
                                try
                                {
                                    heartbeat = double.Parse(Condition.Value1);
                                }
                                catch { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.HeartBeat == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && heartbeat != 0 && item.HeartBeat.HasValue)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.HeartBeat == heartbeat)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.HeartBeat >= heartbeat)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.HeartBeat <= heartbeat)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && heartbeat != 0 && item.HeartBeat.HasValue)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && item.HeartBeat != heartbeat)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.HeartBeat < heartbeat)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.HeartBeat > heartbeat)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm tra Trình độ học vấn
                            if (Condition.ConditionName == ConditionName.E_EDUCATIONLEVEL.ToString())
                            {
                                if (item.EducationLevelID == null)
                                {
                                    countAgree++;
                                    continue;

                                }
                                else
                                {
                                    if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                    {
                                        if (!string.IsNullOrEmpty(Condition.Value1))
                                        {
                                            // Lấy list string mã trình độ học vấn
                                            var lstCodeEducationLevelOfCondition = Condition.Value1.Split(',').Select(x => x).ToList();
                                            // lấy mã trình độ học vấn của Candidate
                                            var CodeEduOfCandidate = lstEducationLevel.Where(s => s.ID == item.EducationLevelID).Select(s => s.Code).FirstOrDefault();

                                            if (lstCodeEducationLevelOfCondition.Contains(CodeEduOfCandidate))
                                            {
                                                countAgree++;
                                                continue;
                                            }
                                            else
                                            {
                                                ReasonFailFilter += Condition.ConditionName + ",";
                                            }
                                        }
                                    }
                                    if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                    {
                                        var lstEduCondition = Condition.Value1.Split(',').Select(x => x).ToList();
                                        var CodeEduOfCandidate = lstEducationLevel.Where(s => s.ID == item.EducationLevelID).Select(s => s.Code).FirstOrDefault();
                                        if (!lstEduCondition.Contains(CodeEduOfCandidate))
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                        else
                                        {
                                            ReasonFailFilter += Condition.ConditionName + ",";
                                        }
                                    }
                                }
                            }
                            #endregion
                            #region Kiểm tra số năm kinh nghiệm
                            if (Condition.ConditionName == ConditionName.E_YEAROFEXPERIENCE.ToString())
                            {
                                double yearofexperienceFilter = 0;
                                try
                                {
                                    yearofexperienceFilter = double.Parse(Condition.Value1);
                                }
                                catch
                                { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.YearOfExperience == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && yearofexperienceFilter != 0 && item.YearOfExperience.HasValue)
                                {


                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && yearofexperienceFilter <= item.YearOfExperience)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && yearofexperienceFilter >= item.YearOfExperience)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && yearofexperienceFilter == item.YearOfExperience)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && item.YearOfExperience.HasValue && yearofexperienceFilter != 0)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && item.YearOfExperience <= yearofexperienceFilter)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && item.YearOfExperience >= yearofexperienceFilter)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && yearofexperienceFilter != item.YearOfExperience)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm tra tỉnh thường trú
                            if (Condition.ConditionName == ConditionName.E_CANDIDATEP_PPROVINCE.ToString())
                            {
                                if (item.PProvinceID == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                else
                                {
                                    if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                    {
                                        if (!string.IsNullOrEmpty(Condition.Value1))
                                        {
                                            // Lấy list string mã trình độ học vấn
                                            var lstCodeProvinceFilter = Condition.Value1.Split(',').Select(x => x).ToList();
                                            // lấy mã trình độ học vấn của Candidate
                                            var codeProvinceCandidate = lstProvince.Where(s => s.ID == item.PProvinceID).Select(s => s.Code).FirstOrDefault();

                                            if (lstCodeProvinceFilter.Contains(codeProvinceCandidate))
                                            {
                                                countAgree++;
                                                continue;
                                            }
                                            else
                                            {
                                                ReasonFailFilter += Condition.ConditionName + ",";
                                            }
                                        }
                                    }
                                    if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                    {
                                        var lstCodeProvinceFilter = Condition.Value1.Split(',').Select(x => x).ToList();
                                        var codeProvinceCandidate = lstProvince.Where(s => s.ID == item.PProvinceID).Select(s => s.Code).FirstOrDefault();
                                        if (!lstCodeProvinceFilter.Contains(codeProvinceCandidate))
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                        else
                                        {
                                            ReasonFailFilter += Condition.ConditionName + ",";
                                        }
                                    }
                                }
                            }
                            #endregion
                            #region Kiểm tra chuyên ngành
                            if (Condition.ConditionName == ConditionName.E_SPECIALISATION.ToString())
                            {
                                string specialisationFilter = null;
                                try
                                {
                                    specialisationFilter = Condition.Value1;
                                }
                                catch
                                { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.Specialisation == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && specialisationFilter != null && item.Specialisation != null)
                                {

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && specialisationFilter.ToLower() == item.Specialisation.ToLower())
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && specialisationFilter != null && item.Specialisation != null)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && specialisationFilter.ToLower() != item.Specialisation.ToLower())
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                            #region Kiểm tra trường tốt nghiệp
                            if (Condition.ConditionName == ConditionName.E_GRADUATESCHOOL.ToString())
                            {
                                string schoolGraduateFilter = null;
                                try
                                {
                                    schoolGraduateFilter = Condition.Value1;
                                }
                                catch
                                { }
                                // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                                if (item.GraduateSchool == null)
                                {
                                    countAgree++;
                                    continue;
                                }
                                // Điều kiện thỏa
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && schoolGraduateFilter != null && item.GraduateSchool != null)
                                {

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && schoolGraduateFilter.ToLower() == item.GraduateSchool.ToLower())
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }
                                //không thỏa
                                else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && schoolGraduateFilter != null && item.GraduateSchool != null)
                                {
                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && schoolGraduateFilter.ToLower() != item.GraduateSchool.ToLower())
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                    else
                                    {
                                        ReasonFailFilter += Condition.ConditionName + ",";
                                    }
                                }

                            }
                            #endregion
                        }
                        if (ReasonFailFilter != string.Empty)
                        {
                            ReasonFailFilter = ReasonFailFilter.Substring(0, ReasonFailFilter.Length - 1);
                            item.ReasonFailFilter = ReasonFailFilter;
                        }
                        if (countAgree == countCondition)
                            lstCandidateResultPass.Add(item);
                        else
                            lstCandidateResultFail.Add(item);
                    }
                }
                // cap  nhat status và history cho cadidate pass
                if (lstCandidateResultPass != null && lstCandidateResultPass.Count != 0)
                {
                    var candidateservices = new Rec_CandidateServices();
                    var recruimenthistoryservices = new Rec_RecruitmentHistoryServices();
                    var ListIDsCadidate = lstCandidateResultPass.Select(x => x.ID).ToList();
                    var listCadidate = repoCadidate.FindBy(x => ListIDsCadidate.Contains(x.ID)).ToList();
                    //cập nhật status cho cadidate
                    foreach (var item1 in listCadidate)
                    {
                        item1.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_WAITINTERVIEW.ToString();
                        item1.PassFilterResume = true;
                        if (lstrecruitmentHistory != null)
                        {
                            var listCandidateHis = lstrecruitmentHistory.Where(x => x.CandidateID == item1.ID).ToList();
                            if (listCandidateHis != null && listCandidateHis.Count != 0)
                            {
                                listCandidateHis = listCandidateHis.OrderByDescending(x => x.DateApply).ToList();
                                var objcandidatehis = listCandidateHis.FirstOrDefault();
                                objcandidatehis.PassFilterResume = true;
                                objcandidatehis.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_WAITINTERVIEW.ToString();
                                recruimenthistoryservices.Edit(objcandidatehis);
                            }
                        }
                        candidateservices.Edit(item1);
                    }
                    repoRecruimentHistory.SaveChanges();
                    repoCadidate.SaveChanges();
                }

                // cap  nhat status và history cho cadidate fail
                if (lstCandidateResultFail != null && lstCandidateResultFail.Count != 0)
                {
                    var candidateservices = new Rec_CandidateServices();
                    var recruimenthistoryservices = new Rec_RecruitmentHistoryServices();
                    var ListIDsCadidate = lstCandidateResultFail.Select(x => x.ID).ToList();
                    var listCadidate = repoCadidate.FindBy(x => ListIDsCadidate.Contains(x.ID)).ToList();
                    //cập nhật status cho cadidate
                    foreach (var item1 in listCadidate)
                    {
                        //if()
                        //item1.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_FAIL.ToString();
                        var reasonbyCandidate = lstCandidateResultFail.Where(s => s.ID == item1.ID).FirstOrDefault();
                        item1.PassFilterResume = false;
                        item1.Status = EnumDropDown.CandidateStatus.E_FAILFILTERRESUME.ToString();
                        item1.ReasonFailFilter = reasonbyCandidate != null ? reasonbyCandidate.ReasonFailFilter : null;
                        if (lstrecruitmentHistory != null)
                        {
                            var listCandidateHis = lstrecruitmentHistory.Where(x => x.CandidateID == item1.ID).ToList();
                            if (listCandidateHis != null && listCandidateHis.Count != 0)
                            {
                                listCandidateHis = listCandidateHis.OrderByDescending(x => x.DateApply).ToList();
                                var objcandidatehis = listCandidateHis.FirstOrDefault();
                                objcandidatehis.PassFilterResume = false;
                                objcandidatehis.Status = EnumDropDown.CandidateStatus.E_FAILFILTERRESUME.ToString();
                                recruimenthistoryservices.Edit(objcandidatehis);
                            }
                        }
                        candidateservices.Edit(item1);
                    }
                    repoRecruimentHistory.SaveChanges();
                    repoCadidate.SaveChanges();
                }

            }
            if (GetListFail)
            {
                return lstCandidateResultFail;
            }
            else
            {
                return lstCandidateResultPass;
            }
        }
示例#15
0
        public ActionResult GetReportListCandidate([DataSourceRequest] DataSourceRequest request, Rec_ReportListCandidateModel model)
        {
            #region Validate
            string message = string.Empty;
            var checkValidate = ValidatorService.OnValidateData<Rec_ReportListCandidateModel>(model, "Rec_ReportListCandidateModel", ref message);
            if (!checkValidate)
            {
                return Json(message);
            }
            #endregion
            var baseService = new BaseService();
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateExamFrom", Value = model.DateExamFrom == null ? DateTime.Now : model.DateExamFrom };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateExamTo", Value = model.DateExamTo == null ? DateTime.Now : model.DateExamTo };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            var JobVacancyServices = new Rec_CandidateServices();
            List<object> listObj = new List<object>();
            listObj.Add(model.CodeCandidate);
            listObj.Add(model.CandidateName);
            listObj.Add(model.Gender);
            listObj.Add(model.PositionID);
            listObj.Add(model.RankID);
            listObj.Add(model.SourceAdsID);
            listObj.Add(model.Type);
            listObj.Add(model.DateExamFrom);
            listObj.Add(model.DateExamTo);
            listObj.Add(1);
            listObj.Add(int.MaxValue - 1);
            string status = string.Empty;
            var result = JobVacancyServices.GetData<Rec_ReportListCandidateEntity>(listObj, ConstantSql.hrm_rec_sp_get_ReportListCandidate, UserLogin, ref status).ToList().Translate<Rec_ReportListCandidateModel>();

            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Rec_ReportListCandidateModel(),
                    FileName = "Rec_ReportListCandidate",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = false
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            var objInterview = new List<object>();
            objInterview.AddRange(new object[2]);
            objInterview[0] = 1;
            objInterview[1] = int.MaxValue - 1;
            var lstInterView = baseService.GetData<Rec_InterviewModel>(objInterview, ConstantSql.hrm_rec_sp_get_InterviewDataReport, UserLogin, ref status).ToList();

            foreach (var item in result)
            {
                if (lstInterView.Count > 0)
                {
                    var dataLevel1 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 1).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    var dataLevel2 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 2).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    var dataLevel3 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 3).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    var dataLevel4 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 4).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    var dataLevel5 = lstInterView.Where(s => s.CandidateID == item.ID && s.LevelInterview == 5).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    if (dataLevel1 != null)
                    {
                        item.Score1_1 = dataLevel1.Score1;
                        item.Score1_2 = dataLevel1.Score2;
                        item.Score1_3 = dataLevel1.Score3;
                        item.KQ1 = dataLevel1.ResultInterviewView;
                        item.LanguageCode1 = dataLevel1.LanguageCode;
                        item.DateInterview1 = dataLevel1.DateInterview;
                    }
                    if (dataLevel2 != null)
                    {
                        item.Score2_1 = dataLevel2.Score1;
                        item.Score2_2 = dataLevel2.Score2;
                        item.Score2_3 = dataLevel2.Score3;
                        item.KQ2 = dataLevel2.ResultInterviewView;
                        item.LanguageCode2 = dataLevel2.LanguageCode;
                        item.DateInterview2 = dataLevel2.DateInterview;
                    }
                    if (dataLevel3 != null)
                    {
                        item.Score3_1 = dataLevel3.Score1;
                        item.Score3_2 = dataLevel3.Score2;
                        item.Score3_3 = dataLevel3.Score3;
                        item.KQ3 = dataLevel3.ResultInterviewView;
                        item.LanguageCode3 = dataLevel3.LanguageCode;
                        item.DateInterview3 = dataLevel3.DateInterview;
                    }
                    if (dataLevel4 != null)
                    {
                        item.Score4_1 = dataLevel4.Score1;
                        item.Score4_2 = dataLevel4.Score2;
                        item.Score4_3 = dataLevel4.Score3;
                        item.KQ4 = dataLevel4.ResultInterviewView;
                        item.LanguageCode4 = dataLevel4.LanguageCode;
                        item.DateInterview4 = dataLevel4.DateInterview;
                    }
                    if (dataLevel5 != null)
                    {
                        item.Score5_1 = dataLevel5.Score1;
                        item.Score5_2 = dataLevel5.Score2;
                        item.Score5_3 = dataLevel5.Score3;
                        item.KQ5 = dataLevel5.ResultInterviewView;
                        item.LanguageCode5 = dataLevel5.LanguageCode;
                        item.DateInterview5 = dataLevel5.DateInterview;
                    }
                }
            }

            if (model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportID, result, listHeaderInfo, model.ExportType);
                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request));
        }
示例#16
0
        // Click nút gọi điện ds ứng viên trúng tuyển
        public string ComputeResultInterview(string selectedIds, string UserLogin)
        {
            List<Rec_Interview> lstInterviewResultPass = new List<Rec_Interview>();
            List<Rec_Interview> lstInterviewResultFail = new List<Rec_Interview>();
            List<Rec_Candidate> lstCandidate = new List<Rec_Candidate>();
            List<Rec_RecruitmentHistory> lstRecruitmentHistory = new List<Rec_RecruitmentHistory>();
            using (var context = new VnrHrmDataContext())
            {
                int? levelinterview = 0;
                string status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Rec_InterviewRepository(unitOfWork);
                var services = new Rec_InterviewServices();
                var Candidateservices = new Rec_CandidateServices();
                var Historyservices = new Rec_RecruitmentHistoryServices();
                BaseService service = new BaseService();
                List<Guid> lstIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
                var lstinterviews = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList();

                #region Lấy ứng viên theo phỏng vấn
                var lstcandidateIDs = lstinterviews.Select(s => s.CandidateID).ToList();
                string strCandidateIDs = string.Empty;
                foreach (var candidatebyinterview in lstcandidateIDs)
                {
                    strCandidateIDs += Common.DotNetToOracle(candidatebyinterview.ToString()) + ",";
                }
                if (strCandidateIDs.IndexOf(",") > 0)
                    strCandidateIDs = strCandidateIDs.Substring(0, strCandidateIDs.Length - 1);

                var lstcandidate = service.GetData<Rec_Candidate>(strCandidateIDs, ConstantSql.hrm_rec_sp_get_CandidateByIds, UserLogin, ref status).ToList();
                var lstrecruitmentHistory = service.GetData<Rec_RecruitmentHistory>(strCandidateIDs, ConstantSql.hrm_hr_sp_get_RecHisByCandidateIds, UserLogin, ref status).ToList();
                #endregion

                #region Lấy nhóm đk tuyển theo phỏng vấn
                var lstgroupconditionIDs = lstinterviews.Where(s => s.CandidateID != null).Select(s => s.GroupConditionID).ToList();
                string strgroupIDs = string.Empty;
                foreach (var candidatebyinterview in lstgroupconditionIDs)
                {
                    strgroupIDs += Common.DotNetToOracle(candidatebyinterview.ToString()) + ",";
                }
                if (strgroupIDs.IndexOf(",") > 0)
                    strgroupIDs = strgroupIDs.Substring(0, strgroupIDs.Length - 1);

                var lstgroupconditions = service.GetData<Rec_GroupConditionEntity>(strgroupIDs, ConstantSql.hrm_rec_sp_get_GroupConditionByIds, UserLogin, ref status).ToList();
                if (lstgroupconditions == null)
                {
                    return null;
                }
                #endregion

                #region Lấy yêu cầu tuyển theo ứng viên
                var lstJobVaCancyIDs = lstcandidate.Select(s => s.JobVacancyID).ToList();
                string strJobVacancyIds = string.Empty;
                foreach (Guid candidatebyinterview in lstJobVaCancyIDs)
                {
                    strJobVacancyIds += candidatebyinterview;
                    strJobVacancyIds += ",";
                }
                if (strJobVacancyIds.Length > 0)
                {
                    strJobVacancyIds = strJobVacancyIds.Substring(0, strJobVacancyIds.Length - 1);
                }
                var lstJobVacancy = service.GetData<Rec_JobVacancyEntity>(Common.DotNetToOracle(strJobVacancyIds), ConstantSql.hrm_rec_sp_get_JobVacancyByIds, UserLogin, ref status).ToList();
                var repoJobCondition = new Rec_JobConditionRepository(unitOfWork);
                var lstJobCondition = repoJobCondition.FindBy(s => s.IsDelete == null).ToList();
                #endregion

                #region Lấy ds nv nghỉ việc
                var ProfileServices = new Hre_ProfileServices();
                List<object> lstparasearchpro = new List<object>();
                lstparasearchpro = new List<object>();
                lstparasearchpro.AddRange(new object[19]);
                lstparasearchpro[17] = 1;
                lstparasearchpro[18] = Int32.MaxValue - 1;
                var lstProfile = service.GetData<Hre_ProfileEntity>(lstparasearchpro, ConstantSql.hrm_hr_sp_get_ProfileQuit, UserLogin, ref status).ToList();
                #endregion

                #region Lấy ds bệnh
                List<object> lstparadiseelist = new List<object>();
                lstparadiseelist.Add(null);
                lstparadiseelist.Add(EnumDropDown.EntityType.E_SICK_REC.ToString());
                lstparadiseelist.Add(1);
                lstparadiseelist.Add(int.MaxValue - 1);
                var lstsick = service.GetData<Cat_NameEntityEntity>(lstparadiseelist, ConstantSql.hrm_cat_sp_get_LevelGeneral, UserLogin, ref status).ToList();

                #endregion

                #region Lấy ds trình độ học vấn
                List<object> lstparaEdu = new List<object>();
                lstparaEdu.Add(null);
                lstparaEdu.Add(1);
                lstparaEdu.Add(int.MaxValue - 1);
                var lstEducationLevel = service.GetData<Cat_NameEntityEntity>(lstparaEdu, ConstantSql.hrm_cat_sp_get_EducationLevel, UserLogin, ref status).ToList();
                #endregion

                string message = NotificationType.Success.ToString();
                foreach (var interview in lstinterviews)
                {
                    var candidatebyinterview = lstcandidate.Where(s => s.ID == interview.CandidateID.Value && s.JobVacancyID != null).FirstOrDefault();
                    if(candidatebyinterview.JobVacancyID == null)
                    {
                        message = ConstantMessages.Fail;
                        continue;
                    }
                    var jobvacancybyCandidate = lstJobVacancy.Where(s => candidatebyinterview.JobVacancyID != null && s.ID == candidatebyinterview.JobVacancyID.Value).FirstOrDefault();
                    var lstconditionidsbygroupcondition = lstgroupconditions.Where(s => s.ID == interview.GroupConditionID).FirstOrDefault();
                    if (lstconditionidsbygroupcondition == null)
                    {
                        continue;
                    }

                    if (interview.LevelInterview > jobvacancybyCandidate.NoLevelInterview || candidatebyinterview.Status == EnumDropDown.CandidateStatus.E_PASS.ToString()
                    || candidatebyinterview.Status == EnumDropDown.CandidateStatus.E_FAIL.ToString() || candidatebyinterview.Status == EnumDropDown.CandidateStatus.E_HIRE.ToString())
                    {
                        message = ConstantDisplay.HRM_Rec_EmpHaveResult;
                        continue;
                    }
                    List<Guid> ids = new List<Guid>();
                    ids = lstconditionidsbygroupcondition.JobConditionIDs
                           .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                           .Select(x => Guid.Parse(x))
                           .ToList();
                    var lstconditionbyGroup = lstJobCondition.Where(s => ids.Contains(s.ID)).ToList();
                    int countCondition = lstconditionbyGroup.Count;
                    int countAgree = 0;
                    #region MyRegion
                    foreach (var Condition in lstconditionbyGroup)
                    {
                        #region Kiểm tra Tổng Điểm Phỏng Vấn
                        if (Condition.ConditionName == ConditionName.E_INTERVIEW.ToString())
                        {
                            double valueInterview1 = 0;
                            try
                            {
                                valueInterview1 = double.Parse(Condition.Value1);
                            }
                            catch
                            {

                            }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.Interview == null)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueInterview1 != 0 && candidatebyinterview.Interview.HasValue)
                            {

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueInterview1 <= candidatebyinterview.Interview)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueInterview1 >= candidatebyinterview.Interview)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueInterview1 == candidatebyinterview.Interview)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueInterview1 != 0 && candidatebyinterview.Interview.HasValue)
                            {


                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueInterview1 <= candidatebyinterview.Interview)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueInterview1 >= candidatebyinterview.Interview)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueInterview1 == candidatebyinterview.Interview)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                        }
                        #endregion
                        #region Kiểm tra Điểm Thi Viết
                        if (Condition.ConditionName == ConditionName.E_WRITETEST.ToString())
                        {
                            double valueWriteTest1 = 0;
                            try
                            {
                                valueWriteTest1 = double.Parse(Condition.Value1);
                            }
                            catch
                            { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.WriteTest == null)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueWriteTest1 != 0 && candidatebyinterview.WriteTest.HasValue)
                            {

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueWriteTest1 <= candidatebyinterview.WriteTest)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueWriteTest1 >= candidatebyinterview.WriteTest)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueWriteTest1 == candidatebyinterview.WriteTest)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueWriteTest1 != 0 && candidatebyinterview.WriteTest.HasValue)
                            {


                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueWriteTest1 <= candidatebyinterview.WriteTest)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueWriteTest1 >= candidatebyinterview.WriteTest)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueWriteTest1 == candidatebyinterview.WriteTest)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                        }
                        #endregion
                        #region Kiểm tra Tổng Sức Khỏe
                        if (Condition.ConditionName == ConditionName.E_GENERALHEALTH.ToString())
                        {
                            double valueHealth1 = 0;
                            try
                            {
                                valueHealth1 = double.Parse(Condition.Value1);
                            }
                            catch
                            { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.GenaralHealth == null)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueHealth1 != 0 && candidatebyinterview.GenaralHealth.HasValue)
                            {


                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueHealth1 <= candidatebyinterview.GenaralHealth)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueHealth1 >= candidatebyinterview.GenaralHealth)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueHealth1 == candidatebyinterview.GenaralHealth)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && candidatebyinterview.GenaralHealth.HasValue && valueHealth1 != 0)
                            {


                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueHealth1 <= candidatebyinterview.GenaralHealth)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueHealth1 >= candidatebyinterview.GenaralHealth)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueHealth1 == candidatebyinterview.GenaralHealth)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }

                        }
                        #endregion
                        #region Kiểm tra cao
                        if (Condition.ConditionName == ConditionName.E_HEIGHT.ToString())
                        {
                            double valueHeight1 = 0;
                            try
                            {
                                valueHeight1 = double.Parse(Condition.Value1);
                            }
                            catch
                            { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.Height == null)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueHeight1 != 0 && candidatebyinterview.Height.HasValue)
                            {


                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueHeight1 <= candidatebyinterview.Height)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueHeight1 >= candidatebyinterview.Height)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueHeight1 == candidatebyinterview.Height)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && candidatebyinterview.Height.HasValue && valueHeight1 != 0)
                            {


                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.Height <= valueHeight1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.Height >= valueHeight1)
                                {

                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueHeight1 == candidatebyinterview.Height)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }

                        }
                        #endregion
                        #region Kiểm tra Cân Nặng
                        if (Condition.ConditionName == ConditionName.E_WEIGHT.ToString())
                        {

                            double valueWeight1 = 0;
                            try
                            {
                                valueWeight1 = double.Parse(Condition.Value1);
                            }
                            catch { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.Weight == null)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueWeight1 != 0 && candidatebyinterview.Weight.HasValue)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.Weight == valueWeight1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.Weight >= valueWeight1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.Height <= valueWeight1)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueWeight1 != 0 && candidatebyinterview.Weight.HasValue)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.Weight == valueWeight1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.Weight <= valueWeight1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.Height >= valueWeight1)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }

                        }
                        #endregion
                        #region Kiểm Tra Mắt
                        #region Mắt Trái
                        if (Condition.ConditionName == ConditionName.E_LEVELEYES.ToString())
                        {

                            double valueEyes1 = 0;
                            // double Eyes = 0;
                            try
                            {
                                valueEyes1 = double.Parse(Condition.Value1);
                                //  Eyes = double.Parse(candidatebyinterview.LevelEye);
                            }
                            catch { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (!candidatebyinterview.LevelEye.HasValue)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueEyes1 != 0)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.LevelEye.Value == valueEyes1)
                                {
                                    countAgree++;
                                    continue;

                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.LevelEye.Value >= valueEyes1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.LevelEye.Value <= valueEyes1)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueEyes1 != 0)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.LevelEye.Value == valueEyes1)
                                {
                                    countAgree++;
                                    continue;

                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.LevelEye.Value <= valueEyes1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.LevelEye.Value >= valueEyes1)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }

                        }
                        #endregion
                        #region Mắt Phải
                        if (Condition.ConditionName == ConditionName.E_LEVERIGHTLEYES.ToString())
                        {

                            double valueEyes1 = 0;
                            // double Eyes = 0;
                            try
                            {
                                valueEyes1 = double.Parse(Condition.Value1);
                                //  Eyes = double.Parse(candidatebyinterview.LevelEye);
                            }
                            catch { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (!candidatebyinterview.LevelEye.HasValue)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valueEyes1 != 0)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.LevelEyeRight.Value == valueEyes1)
                                {
                                    countAgree++;
                                    continue;

                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.LevelEyeRight.Value >= valueEyes1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.LevelEyeRight.Value <= valueEyes1)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valueEyes1 != 0)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.LevelEyeRight.Value == valueEyes1)
                                {
                                    countAgree++;
                                    continue;

                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.LevelEyeRight.Value <= valueEyes1)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.LevelEyeRight.Value >= valueEyes1)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }

                        }
                        #endregion
                        #endregion
                        #region Kiểm tra Thời Gian Trượt Kỳ Trước
                        if (Condition.ConditionName == ConditionName.E_DURATIONFAILPREVIOUS.ToString())
                        {
                            int valueDuration1 = int.Parse(Condition.Value1);
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                            {

                                var listCandidateHis = lstrecruitmentHistory.Where(x => x.CandidateID == candidatebyinterview.ID && x.Status == HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_FAIL.ToString())
                                    .OrderByDescending(x => x.DateApply).ToList();
                                if (listCandidateHis == null || listCandidateHis.Count == 0)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (listCandidateHis != null && listCandidateHis.Count != 0)
                                {
                                    var CandidateHistory = listCandidateHis.FirstOrDefault();
                                    int Monthhistory = CandidateHistory.DateApply.Value.Month;
                                    int monthcheck = candidatebyinterview.DateApply.Value.Month;

                                    int month = Math.Abs(monthcheck - Monthhistory);

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && month == valueDuration1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && month > valueDuration1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && month < valueDuration1)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                            {

                                var listCandidateHis = lstrecruitmentHistory.Where(x => x.CandidateID == candidatebyinterview.ID && x.Status == HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_FAIL.ToString())
                                    .OrderByDescending(x => x.DateApply).ToList();
                                if (listCandidateHis == null || listCandidateHis.Count == 0)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (listCandidateHis != null && listCandidateHis.Count != 0)
                                {

                                    var CandidateHistory = listCandidateHis.FirstOrDefault();
                                    int Monthhistory = CandidateHistory.DateApply.Value.Month;

                                    int monthcheck = candidatebyinterview.DateApply.Value.Month;

                                    int month = Math.Abs(monthcheck - Monthhistory);

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && month != valueDuration1)
                                    {
                                        countAgree++;
                                        continue;

                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && month < valueDuration1)
                                    {
                                        countAgree++;
                                        continue;
                                    }

                                    if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && month > valueDuration1)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                }
                            }

                        }
                        #endregion
                        #region Kiểm tra Từ Tuổi
                        if (Condition.ConditionName == ConditionName.E_AGE.ToString())
                        {
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.DateOfBirth == null)
                            {
                                countAgree++;
                                continue;
                            }
                            double? AgeCadidate = (new DateTime(DateTime.Now.Subtract(candidatebyinterview.DateOfBirth).Ticks).Year - 1) > 0 ? (new DateTime(DateTime.Now.Subtract(candidatebyinterview.DateOfBirth).Ticks).Year - 1) : (DateTime.Now.Subtract(candidatebyinterview.DateOfBirth).TotalDays / 365.242199);
                            double? valueAge = 0;
                            try
                            {
                                valueAge = int.Parse(Condition.Value1);
                            }
                            catch
                            {
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && AgeCadidate > 0)
                            {

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && AgeCadidate >= valueAge)
                                {
                                    countAgree++;
                                    continue;

                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && AgeCadidate <= valueAge)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && AgeCadidate == valueAge)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && AgeCadidate > 0)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && AgeCadidate >= valueAge)
                                {
                                    countAgree++;
                                    continue;

                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && AgeCadidate <= valueAge)
                                {
                                    countAgree++;
                                    continue;
                                }
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && AgeCadidate == valueAge)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                        }
                        #endregion
                        #region Kiểm tra Giới Tính
                        if (Condition.ConditionName == ConditionName.E_GENDER.ToString())
                        {
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (string.IsNullOrEmpty(candidatebyinterview.Gender))
                            {
                                countAgree++;
                                continue;
                            }
                            string valueGender = Condition.Value1;

                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                            {

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.Gender.Equals(valueGender))
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && !candidatebyinterview.Gender.Equals(valueGender))
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                        }
                        #endregion
                        #region Kiểm Tra Đã làm ở cty chưa
                        if (Condition.ConditionName == ConditionName.E_ISTERMINATEINCOMPANY.ToString() && Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString())
                        {
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                            {

                                if (lstProfile != null && lstProfile.Count != 0)
                                {
                                    // nếu có CMND thì ưu tiên kiểm tra trước
                                    if (!string.IsNullOrEmpty(candidatebyinterview.IdentifyNumber))
                                    {
                                        var Profile = lstProfile.FirstOrDefault(x => !string.IsNullOrEmpty(x.IDNo) && x.IDNo == candidatebyinterview.IdentifyNumber);
                                        if (Profile == null)
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                    }
                                    // nếu ko có CMND thì kiểm tra tên và ngày sinh 
                                    else if (!string.IsNullOrEmpty(candidatebyinterview.CandidateName) && candidatebyinterview.DateOfBirth != null)
                                    {
                                        var Profile = lstProfile.FirstOrDefault(x => !string.IsNullOrEmpty(x.ProfileName) && x.DateOfBirth.HasValue && x.ProfileName == candidatebyinterview.CandidateName && candidatebyinterview.DateOfBirth == x.DateOfBirth.Value);
                                        if (Profile == null)
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                    }

                                }
                            }
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                            {
                                if (lstProfile != null && lstProfile.Count != 0)
                                {
                                    // nếu có CMND thì ưu tiên kiểm tra trước
                                    if (!string.IsNullOrEmpty(candidatebyinterview.IdentifyNumber))
                                    {
                                        var Profile = lstProfile.FirstOrDefault(x => !string.IsNullOrEmpty(x.IDNo) && x.IDNo == candidatebyinterview.IdentifyNumber);
                                        if (Profile == null)
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                    }
                                    // nếu ko có CMND thì kiểm tra tên và ngày sinh 
                                    else if (!string.IsNullOrEmpty(candidatebyinterview.CandidateName) && candidatebyinterview.DateOfBirth != null)
                                    {
                                        var Profile = lstProfile.FirstOrDefault(x => !string.IsNullOrEmpty(x.ProfileName) && x.DateOfBirth.HasValue && x.ProfileName == candidatebyinterview.CandidateName && candidatebyinterview.DateOfBirth.Date == x.DateOfBirth.Value.Date);
                                        if (Profile == null)
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                    }

                                }


                            }
                        }
                        #endregion
                        #region Kiểm Tra Bệnh Loại Trừ
                        if (Condition.ConditionName == ConditionName.E_DISEASEIDS.ToString())
                        {
                            // nếu ko có bệnh thì qua
                            if (string.IsNullOrEmpty(candidatebyinterview.DiseaseListIDs))
                            {
                                countAgree++;
                                continue;

                            }
                            // nếu có chứa bệnh nào thì ko qua
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                            {
                                if (!string.IsNullOrEmpty(Condition.Value1))
                                {
                                    //lấy ds bệnh của đk tuyển
                                    var lstDiseaseCondition = Condition.Value1.Split(',').Select(x => x).ToList();

                                    var lstsickbycondition = lstsick.Where(s => lstDiseaseCondition.Contains(Common.DotNetToOracle(s.ID.ToString()))).ToList();
                                    // lấy ds mã bệnh của candidate - vì candidate lưu mã
                                    var lstDiseseCandidate = candidatebyinterview.DiseaseListIDs.Split(',').ToList();
                                    if (lstsickbycondition.Where(x => lstDiseseCandidate.Contains(x.Code)).Count() == 0)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                }
                            }
                            else if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                            {
                                if (!string.IsNullOrEmpty(Condition.Value1))
                                {
                                    //lấy ds bệnh của đk tuyển
                                    var lstDiseaseCondition = Condition.Value1.Split(',').Select(x => x).ToList();

                                    var lstsickbycondition = lstsick.Where(s => lstDiseaseCondition.Contains(Common.DotNetToOracle(s.ID.ToString()))).ToList();
                                    // lấy ds mã bệnh của candidate - vì candidate lưu mã
                                    var lstDiseseCandidate = candidatebyinterview.DiseaseListIDs.Split(',').ToList();
                                    if (lstsickbycondition.Where(x => lstDiseseCandidate.Contains(x.Code)).Count() != 0)
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                }
                            }
                        }
                        #endregion
                        #region Kiểm tra điểm thi
                        #region Điểm 1
                        if (Condition.ConditionName == ConditionName.E_SCORE1.ToString())
                        {

                            double? valueScore1Condition = double.Parse(Condition.Value1);
                            double? valueScore1 = interview.Score1;
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore1 == valueScore1Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore1 > valueScore1Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore1 < valueScore1Condition)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore1 != valueScore1Condition)
                                {
                                    countAgree++;
                                    continue;

                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore1 < valueScore1Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore1 > valueScore1Condition)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                        }
                        #endregion
                        #region Điểm 2
                        if (Condition.ConditionName == ConditionName.E_SCORE2.ToString())
                        {
                            double? valueScore2Condition = double.Parse(Condition.Value1);
                            double? valueScore2 = interview.Score2;
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore2 == valueScore2Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore2 > valueScore2Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore2 < valueScore2Condition)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore2 != valueScore2Condition)
                                {
                                    countAgree++;
                                    continue;

                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore2 < valueScore2Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore2 > valueScore2Condition)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                        }
                        #endregion
                        #region Điểm 3
                        if (Condition.ConditionName == ConditionName.E_SCORE3.ToString())
                        {
                            double? valueScore3Condition = double.Parse(Condition.Value1);
                            double? valueScore3 = interview.Score3;
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore3 == valueScore3Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore3 > valueScore3Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore3 < valueScore3Condition)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && valueScore3 != valueScore3Condition)
                                {
                                    countAgree++;
                                    continue;

                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && valueScore3 < valueScore3Condition)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && valueScore3 > valueScore3Condition)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                        }
                        #endregion
                        #endregion
                        #region Kiểm tra Hệ Vận Động
                        if (Condition.ConditionName == ConditionName.E_MUSCULOSKELETAL.ToString())
                        {

                            double valuemusculoskeletal = 0;
                            try
                            {
                                valuemusculoskeletal = double.Parse(Condition.Value1);
                            }
                            catch { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.Musculoskeletal == null)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && valuemusculoskeletal != 0 && candidatebyinterview.Musculoskeletal.HasValue)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.Musculoskeletal == valuemusculoskeletal)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.Musculoskeletal >= valuemusculoskeletal)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.Musculoskeletal <= valuemusculoskeletal)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && valuemusculoskeletal != 0 && candidatebyinterview.Musculoskeletal.HasValue)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.Musculoskeletal != valuemusculoskeletal)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.Musculoskeletal < valuemusculoskeletal)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.Musculoskeletal > valuemusculoskeletal)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }

                        }
                        #endregion
                        #region Kiểm tra Huyết Áp
                        if (Condition.ConditionName == ConditionName.E_BLOODPRESSURE.ToString())
                        {

                            double bloodpressure = 0;
                            try
                            {
                                bloodpressure = double.Parse(Condition.Value1);
                            }
                            catch { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.BloodPressure == null)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && bloodpressure != 0 && candidatebyinterview.BloodPressure.HasValue)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.BloodPressure == bloodpressure)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.BloodPressure >= bloodpressure)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.BloodPressure <= bloodpressure)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && bloodpressure != 0 && candidatebyinterview.BloodPressure.HasValue)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.BloodPressure != bloodpressure)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.BloodPressure < bloodpressure)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.BloodPressure > bloodpressure)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }

                        }
                        #endregion
                        #region Kiểm tra Nhịp Tim
                        if (Condition.ConditionName == ConditionName.E_HEARTBEAT.ToString())
                        {

                            double heartbeat = 0;
                            try
                            {
                                heartbeat = double.Parse(Condition.Value1);
                            }
                            catch { }
                            // nếu giá trị của ứng viên là null thì ko kiểm tra =>thỏa
                            if (candidatebyinterview.HeartBeat == null)
                            {
                                countAgree++;
                                continue;
                            }
                            // Điều kiện thỏa
                            if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString() && heartbeat != 0 && candidatebyinterview.HeartBeat.HasValue)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.HeartBeat == heartbeat)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.HeartBeat >= heartbeat)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.HeartBeat <= heartbeat)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }
                            //không thỏa
                            else if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString() && heartbeat != 0 && candidatebyinterview.HeartBeat.HasValue)
                            {
                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && candidatebyinterview.HeartBeat != heartbeat)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && candidatebyinterview.HeartBeat < heartbeat)
                                {
                                    countAgree++;
                                    continue;
                                }

                                if (Condition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && candidatebyinterview.HeartBeat > heartbeat)
                                {
                                    countAgree++;
                                    continue;
                                }
                            }

                        }
                        #endregion
                        #region Kiểm tra Trình độ học vấn
                        if (Condition.ConditionName == ConditionName.E_EDUCATIONLEVEL.ToString())
                        {
                            if (candidatebyinterview.EducationLevelID == null)
                            {
                                countAgree++;
                                continue;

                            }
                            else
                            {
                                if (Condition.ConditionBrand == ConditionBrand.E_AGREEMENT.ToString())
                                {
                                    if (!string.IsNullOrEmpty(Condition.Value1))
                                    {
                                        // Lấy list string mã trình độ học vấn
                                        var lstCodeEducationLevelOfCondition = Condition.Value1.Split(',').Select(x => x).ToList();
                                        // lấy mã trình độ học vấn của Candidate
                                        var CodeEduOfCandidate = lstEducationLevel.Where(s => s.ID == candidatebyinterview.EducationLevelID).Select(s => s.Code).FirstOrDefault();

                                        if (lstCodeEducationLevelOfCondition.Contains(CodeEduOfCandidate))
                                        {
                                            countAgree++;
                                            continue;
                                        }
                                    }
                                }
                                if (Condition.ConditionBrand == ConditionBrand.E_NOTAGREEMENT.ToString())
                                {
                                    var lstEduCondition = Condition.Value1.Split(',').Select(x => x).ToList();
                                    var CodeEduOfCandidate = lstEducationLevel.Where(s => s.ID == candidatebyinterview.EducationLevelID).Select(s => s.Code).FirstOrDefault();
                                    if (!lstEduCondition.Contains(CodeEduOfCandidate))
                                    {
                                        countAgree++;
                                        continue;
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                    #endregion
                    // Son.Vo làm theo task 0045675 Nếu ko có vòng pv thì vòng pv = 0.
                    if (interview.LevelInterview == null) 
                    {
                        message = ConstantDisplay.HRM_Common_NotHaveLevelInterview.ToString();
                        continue;
                    }
                    else
                    {
                        levelinterview = interview.LevelInterview;
                    }

                    // Cập nhật lại trạng Ứng viên + lịch sử.
                    candidatebyinterview.LevelInterview = levelinterview;
                    var rechisbycandidate = lstrecruitmentHistory.Where(s => s.CandidateID == candidatebyinterview.ID).OrderByDescending(s => s.DateApply).FirstOrDefault();
                    interview.LevelInterview = levelinterview;
                    rechisbycandidate.LevelInterview = levelinterview;
                    if (countAgree == countCondition)
                    {
                        interview.Status = "E_PASS";
                        interview.ResultInterview = "E_PASS";
                        lstInterviewResultPass.Add(interview);
                        // Nếu là vòng pv cuối và kq là đậu thì cập nhật ứng viên + lịch sử
                        if (jobvacancybyCandidate != null && jobvacancybyCandidate.NoLevelInterview == levelinterview)
                        {
                            candidatebyinterview.Status = "E_PASS";
                            rechisbycandidate.Status = "E_PASS";
                        }
                    }
                    else
                    {
                        interview.Status = "E_FAIL";
                        interview.ResultInterview = "E_FAIL";
                        // Nếu là là rớt thì cập nhật ứng viên + lịch sử
                        candidatebyinterview.Status = "E_FAIL";
                        rechisbycandidate.Status = "E_FAIL";
                        lstInterviewResultFail.Add(interview);
                    }
                    lstCandidate.Add(candidatebyinterview);
                    lstRecruitmentHistory.Add(rechisbycandidate);
                }
                if (lstInterviewResultPass.Count > 0)
                {
                    services.Edit(lstInterviewResultPass);
                }
                if (lstInterviewResultFail.Count > 0)
                {

                    services.Edit(lstInterviewResultFail);
                }
                Candidateservices.Edit(lstCandidate);
                Historyservices.Edit(lstRecruitmentHistory);
                repo.SaveChanges();
                return message;
            }
        }
        public string ActionPassing(string selectedIds, string userLogin)
        {

            using (var context = new VnrHrmDataContext())
            {
                BaseService service = new BaseService();
                Rec_InterviewServices services = new Rec_InterviewServices();
                Rec_InterviewCampaignDetailServices InterviewCampaignDetailServices = new Rec_InterviewCampaignDetailServices();
                Rec_RecruitmentHistoryServices RecruitmentHistoryServices = new Rec_RecruitmentHistoryServices();
                Rec_CandidateServices CandidateServices = new Rec_CandidateServices();
                string status = string.Empty;
                string message = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Rec_InterviewCampaignDetailRepository(unitOfWork);
                var InterviewRepository = new Rec_InterviewRepository(unitOfWork);
                var InterviewCampaignDetailRepository = new Rec_InterviewCampaignDetailRepository(unitOfWork);
                List<Guid> lstIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
                var lstInterviewCampaignDetail = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList();
                var lstcandidateid = lstInterviewCampaignDetail.Select(s => s.CandidateID).ToList();
                var objs = new List<object>();
                string strIDs = string.Empty;
                foreach (var item in lstcandidateid)
                {
                    strIDs += Common.DotNetToOracle(item.ToString()) + ",";
                }
                if (strIDs.IndexOf(",") > 0)
                    strIDs = strIDs.Substring(0, strIDs.Length - 1);
                objs.Add(strIDs);

                var lstcandidate = service.GetData<Rec_CandidateEntity>(strIDs, ConstantSql.hrm_rec_sp_get_CandidateByIds, userLogin, ref status).ToList();
                var lstrecruimenthistory = service.GetData<Rec_RecruitmentHistoryEntity>(strIDs, ConstantSql.hrm_hr_sp_get_RecHisByCandidateIds, userLogin, ref status).ToList();
                var lstinterviewbycandidateids = service.GetData<Rec_InterviewEntity>(strIDs, ConstantSql.hrm_hr_sp_get_InterViewByCandidateIds, userLogin, ref status).ToList();


                List<Rec_InterviewEntity> lstinterview = new List<Rec_InterviewEntity>();
                List<Rec_InterviewCampaignDetail> lstAllInterviewCampaignDetail = new List<Rec_InterviewCampaignDetail>();
                var lstJobVaCancyIDs = lstcandidate.Select(s => s.JobVacancyID).ToList();
                

                string strJobVacancyIds = string.Empty;
                foreach (Guid item in lstJobVaCancyIDs)
                {
                    strJobVacancyIds += item;
                    strJobVacancyIds += ",";
                }

                if (strJobVacancyIds.Length > 0)
                {
                    strJobVacancyIds = strJobVacancyIds.Substring(0, strJobVacancyIds.Length - 1);
                }

                var lstJobVacancy = service.GetData<Rec_JobVacancyEntity>(Common.DotNetToOracle(strJobVacancyIds), ConstantSql.hrm_rec_sp_get_JobVacancyByIds, userLogin, ref status).ToList();

                Rec_InterviewCampaignDetail ObjRecInterviewDt = null;


                foreach (var candidate in lstcandidate)
                {
                    ObjRecInterviewDt = new Rec_InterviewCampaignDetail();
                    Rec_InterviewEntity Interview = new Rec_InterviewEntity();
                    var hisbycandidate = lstrecruimenthistory.Where(s => s.CandidateID == candidate.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    Interview.CandidateID = candidate.ID;
                    Interview.RecruitmentHistoryID = hisbycandidate.ID;

                    var interviewbycan = lstinterviewbycandidateids.Where(s => s.RecruitmentHistoryID == hisbycandidate.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                    int? level = 0;
                    if (interviewbycan != null && interviewbycan.LevelInterview != null)
                    {
                        level = interviewbycan.LevelInterview + 1;
                    }
                    else
                    {
                        level = 1;
                    }

                    var InterviewCampaignDetail = lstInterviewCampaignDetail.Where(s => s.RecruitmentHistoryID == hisbycandidate.ID && s.LevelInterview == null).FirstOrDefault();
                    if (InterviewCampaignDetail == null)
                    {
                        continue;
                    }
                    ObjRecInterviewDt = InterviewCampaignDetail;
                    ObjRecInterviewDt.LevelInterview = level;

                    var jobVacancybyCandidate = lstJobVacancy.Where(s => s.ID == candidate.JobVacancyID).FirstOrDefault();
                    var rechisbycandidate = lstrecruimenthistory.Where(s => s.CandidateID == candidate.ID).OrderByDescending(s => s.DateApply).FirstOrDefault();

                    // nếu là vòng phỏng vấn cuối cùng thì cập nhật lại trạng thái.
                    if (jobVacancybyCandidate != null && jobVacancybyCandidate.NoLevelInterview == level)
                    {
                        rechisbycandidate.Status = "E_PASS";
                        candidate.Status = "E_PASS";
                    }
                    candidate.LevelInterview = level;
                    rechisbycandidate.LevelInterview = level;
                    rechisbycandidate.CandidateID = candidate.ID;
                    Interview.Status = "E_PASS";
                    Interview.ResultInterview = "E_PASS";
                    Interview.LevelInterview = level;
                    lstinterview.Add(Interview);
                    lstAllInterviewCampaignDetail.Add(ObjRecInterviewDt);
                    RecruitmentHistoryServices.Edit(rechisbycandidate);
                    CandidateServices.Edit(candidate);
                }
                services.Add(lstinterview);
                InterviewCampaignDetailServices.Edit(lstAllInterviewCampaignDetail);
                InterviewRepository.SaveChanges();
                InterviewCampaignDetailRepository.SaveChanges();
                message = NotificationType.Success.ToString();
                return message;
            }
        }