Beispiel #1
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;
            }
        }
Beispiel #2
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;
        }
Beispiel #3
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;
            }
        }
Beispiel #4
0
        public ActionResult GetIntervieCampaignDetailList([DataSourceRequest] DataSourceRequest request, Rec_InterviewCampaignDetailSearchModel model)
        {
            List<Rec_InterviewCampaignDetailModel> resultInterviewCampaignDetail = new List<Rec_InterviewCampaignDetailModel>();

            string status = string.Empty;
            var baseService = new BaseService();
            var actionService = new ActionService(UserLogin);
            List<object> objs = new List<object>();
            List<object> objshis = new List<object>();

            var InterviewServices = new Rec_InterviewCampaignDetailServices();

            ListQueryModel lstModel = new ListQueryModel
            {
                PageSize = int.MaxValue - 1,
                PageIndex = 1,
                Filters = ExtractFilterAttributes(request),
                Sorts = ExtractSortAttributes(request),
                AdvanceFilters = ExtractAdvanceFilterAttributes(model)
            };
            int? level = (model != null && model.LevelInterview != 0) ? model.LevelInterview : null;
            List<object> lstModels = new List<object>();
            lstModels.AddRange(new object[16]);
            lstModels[0] = model.CandidateName;
            lstModels[1] = model.DateFrom;
            lstModels[2] = model.DateTo;
            lstModels[3] = model.CodeCandidate;
            lstModels[4] = model.RankID;
            lstModels[5] = model.OrgStructureID;
            lstModels[6] = model.JobVacancyID;
            lstModels[7] = model.PositionID;
            lstModels[8] = level;
            lstModels[13] = model.WorkPlaceID;
            lstModels[14] = 1;
            lstModels[15] = Int32.MaxValue - 1;

            var result = actionService.GetData<Rec_InterviewCampaignDetailModel>(lstModels, ConstantSql.hrm_rec_sp_get_InterviewCampaignDetail, ref status);
            #region Load Chi tiet ke hoach chua phong van
            if (result != null)
            {
                var InTerCamDetaiServices = new Rec_InterviewCampaignDetailServices();
                var HistoryServices = new Rec_RecruitmentHistoryServices();
                var lstCandidateIDS = result.Select(s => s.CandidateID).Distinct().ToList();

                var lstCandidateHistory = new List<Rec_RecruitmentHistoryEntity>();
                int _total = lstCandidateIDS.Count;
                int _totalPage = _total / 100 + 1;
                int _pageSize = 100;
                for (int _page = 1; _page <= _totalPage; _page++)
                {
                    int _skip = _pageSize * (_page - 1);
                    var _listCurrenPage = lstCandidateIDS.Skip(_skip).Take(_pageSize).ToList();
                    string _strselectedIDs = Common.DotNetToOracle(string.Join(",", _listCurrenPage));

                    var lstRecruitmentHistory = baseService.GetData<Rec_RecruitmentHistoryEntity>(_strselectedIDs, ConstantSql.hrm_rec_sp_get_RecHisByListCandidateID, UserLogin, ref status).ToList();
                    if (lstRecruitmentHistory != null && lstRecruitmentHistory.Count > 0)
                    {
                        lstCandidateHistory.AddRange(lstRecruitmentHistory);
                    }
                }

                foreach (var item in result)
                {
                    bool IsAdd = false;
                    //var IlInterviewcampaugnDetail = result.Where(s => s.CandidateID == item.CandidateID).ToList();
                    var ObjHisCandidate = lstCandidateHistory.Where(s => s.ID == item.RecruitmentHistoryID).FirstOrDefault();
                    if (ObjHisCandidate == null)
                    {
                        continue;
                    }
                    if (item.LevelInterview == null)
                    {
                        IsAdd = true;
                    }

                    Rec_JobVacancyEntity entityJobVacancy = null;
                    if (ObjHisCandidate != null && ObjHisCandidate.JobVacancyID != Guid.Empty && ObjHisCandidate.JobVacancyID != null)
                    {
                        entityJobVacancy = actionService.GetByIdUseStore<Rec_JobVacancyEntity>(ObjHisCandidate.JobVacancyID.Value, ConstantSql.hrm_rec_sp_get_JobVacancyId, ref status);
                    }
                    if (entityJobVacancy != null)
                    {
                        if (item.LevelInterview != null && item.LevelInterview == entityJobVacancy.NoLevelInterview)
                        {
                            continue;
                        }
                    }
                    if (item.LevelInterview == null && (ObjHisCandidate.Status != HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_PASS.ToString()
                     && ObjHisCandidate.Status != HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_FAIL.ToString()
                        ))
                    {
                        if (ObjHisCandidate != null)
                        {
                            if (ObjHisCandidate.LevelInterview == null)
                            {
                                item.LevelInterview = 1;
                            }
                            else
                            {
                                item.LevelInterview = ObjHisCandidate.LevelInterview + 1;
                            }

                            if (IsAdd == true)
                            {
                                resultInterviewCampaignDetail.Add(item);
                            }
                        }
                    }
                }
            }
            resultInterviewCampaignDetail = resultInterviewCampaignDetail.Distinct().ToList();
            #endregion

            var isDataTable = false;
            object obj = new Rec_InterviewCampaignDetailModel();
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = model.DateFrom };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = model.DateTo };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            if (model.IsCreateTemplateForDynamicGrid)
            {
                obj = resultInterviewCampaignDetail;
                isDataTable = false;
            }
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "Rec_InterviewCampaignDetailModel",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                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();


            if (model.ExportId != Guid.Empty)
            {
                foreach (var item in resultInterviewCampaignDetail)
                {
                    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;
                    }
                }
                var fullPath = ExportService.Export(model.ExportId, resultInterviewCampaignDetail, listHeaderInfo, model.ExportType);
                return Json(fullPath);
            }

            // return Json(resultInterviewCampaignDetail.ToDataSourceResult(request));
            return Json(resultInterviewCampaignDetail.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
            //var result = GetListDataAndReturn<Rec_InterviewCampaignDetailModel, Rec_InterviewCampaignDetailEntity, Rec_InterviewCampaignDetailSearchModel>(request, model, ConstantSql.hrm_rec_sp_get_InterviewCampaignDetail);
            //return result;
        }
Beispiel #5
0
        public ActionResult ExportAllInterviewDetailListNew([DataSourceRequest] DataSourceRequest request, Rec_InterviewCampaignDetailSearchModel model)
        {
            string status = string.Empty;
            var baseService = new BaseService();
            ActionService service = new ActionService(UserLogin);
            List<object> objs = new List<object>();
            List<object> objshis = new List<object>();
            List<Rec_InterviewCampaignDetailModel> resultInterviewCampaignDetail = new List<Rec_InterviewCampaignDetailModel>();
            var InterviewServices = new Rec_InterviewCampaignDetailServices();

            ListQueryModel lstModel = new ListQueryModel
            {
                PageSize = int.MaxValue - 1,
                PageIndex = 1,
                Filters = ExtractFilterAttributes(request),
                Sorts = ExtractSortAttributes(request),
                AdvanceFilters = ExtractAdvanceFilterAttributes(model)
            };
            var result = baseService.GetData<Rec_InterviewCampaignDetailModel>(lstModel, ConstantSql.hrm_rec_sp_get_InterviewCampaignDetail, UserLogin, ref status);
            if (result != null)
            {
                var InTerCamDetaiServices = new Rec_InterviewCampaignDetailServices();
                var HistoryServices = new Rec_RecruitmentHistoryServices();
                var lstCandidateIDS = result.Select(s => s.CandidateID).Distinct().ToList();
                //string temp = string.Empty;
                //foreach (Guid item in lstCandidateIDS)
                //{
                //    temp += item;
                //    temp += ",";
                //}
                //if (temp.Length > 0)
                //{
                //    temp = temp.Substring(0, temp.Length - 1);
                //}

               // var lstCandidateHistory = HistoryServices.GetData<Rec_RecruitmentHistoryEntity>(Common.DotNetToOracle(temp), ConstantSql.hrm_rec_sp_get_RecHisByListCandidateID, UserLogin, ref status).ToList();
                var lstCandidateHistory = new List<Rec_RecruitmentHistoryEntity>();
                int _total = lstCandidateIDS.Count;
                int _totalPage = _total / 100 + 1;
                int _pageSize = 100;
                for (int _page = 1; _page <= _totalPage; _page++)
                {
                    int _skip = _pageSize * (_page - 1);
                    var _listCurrenPage = lstCandidateIDS.Skip(_skip).Take(_pageSize).ToList();
                    string _strselectedIDs = Common.DotNetToOracle(string.Join(",", _listCurrenPage));

                    var lstRecruitmentHistory = baseService.GetData<Rec_RecruitmentHistoryEntity>(_strselectedIDs, ConstantSql.hrm_rec_sp_get_RecHisByListCandidateID, UserLogin, ref status).ToList();
                    if (lstRecruitmentHistory != null && lstRecruitmentHistory.Count > 0)
                    {
                        lstCandidateHistory.AddRange(lstRecruitmentHistory);
                    }
                }
                foreach (var item in result)
                {
                    //var IlInterviewcampaugnDetail = result.Where(s => s.CandidateID == item.CandidateID).ToList();
                    var ObjHisCandidate = lstCandidateHistory.Where(s => s.ID == item.RecruitmentHistoryID).FirstOrDefault();
                    if (ObjHisCandidate == null)
                    {
                        continue;
                    }
                    Rec_JobVacancyEntity entityJobVacancy = null;
                    if (ObjHisCandidate != null && ObjHisCandidate.JobVacancyID != Guid.Empty && ObjHisCandidate.JobVacancyID != null)
                    {
                        entityJobVacancy = service.GetByIdUseStore<Rec_JobVacancyEntity>(ObjHisCandidate.JobVacancyID.Value, ConstantSql.hrm_rec_sp_get_JobVacancyId, ref status);
                    }
                    if (entityJobVacancy != null)
                    {
                        if (item.LevelInterview != null && item.LevelInterview == entityJobVacancy.NoLevelInterview)
                        {
                            continue;
                        }
                    }
                    if (item.LevelInterview == null && (ObjHisCandidate.Status != HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_PASS.ToString()
                     && ObjHisCandidate.Status != HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_FAIL.ToString()
                        ))
                    {
                        if (ObjHisCandidate != null)
                        {
                            if (ObjHisCandidate.LevelInterview == null)
                            {
                                item.LevelInterview = 1;
                                resultInterviewCampaignDetail.Add(item);
                            }
                            else
                            {
                                item.LevelInterview = ObjHisCandidate.LevelInterview + 1;
                                resultInterviewCampaignDetail.Add(item);
                            }
                        }
                    }
                }
            }
            resultInterviewCampaignDetail = resultInterviewCampaignDetail.Distinct().ToList();
            if (status == NotificationType.Success.ToString())
            {
                status = ExportService.Export(resultInterviewCampaignDetail, model.GetPropertyValue("ValueFields").TryGetValue<string>().Split(','));
            }
            return Json(status);

        }
Beispiel #6
0
 public JsonResult getRecruitmentHistoryId(Guid ID)
 {
     string status = string.Empty;
     var RecruitmentHisService = new Rec_RecruitmentHistoryServices();
     Guid? RecruitmentHistoryId = RecruitmentHisService.GetData<Rec_RecruitmentHistoryEntity>(ID, ConstantSql.hrm_rec_sp_get_RecruitmentHistoryIdByCandidateId, UserLogin, ref status).OrderByDescending(s => s.DateApply).Select(s => s.ID).FirstOrDefault();
     return Json(RecruitmentHistoryId);
 }
Beispiel #7
0
        public string getResultInterview(Guid ID, string str, double? score1, double? score2, double? score3, string candidateID)
        {
            string status = string.Empty;
            string result = HRM.Infrastructure.Utilities.Interview.E_PASS.ToString();
            string[] strCondition = str.Split('|').ToArray();
            if (str != "" && str != null)
            {
                strCondition = str.Substring(0, str.Length - 1).Split('|').ToArray();
            }

            //string status = HRM.Infrastructure.Utilities.Interview.E_PASS.ToString();
            var RecruitmentHisService = new Rec_RecruitmentHistoryServices();
            var RecJobconditionservice = new Rec_JobConditionServices();
            IList<Rec_JobConditionEntity> ilistJobCondition = new List<Rec_JobConditionEntity>();

            var baseService = new BaseService();
            var objs = new List<object>();
            objs.Add(Common.DotNetToOracle(ID.ToString()));
            var GroupCondition = baseService.GetData<Rec_CandidateEntity>(objs, ConstantSql.hrm_rec_sp_get_GroupConditionByID, UserLogin, ref status).FirstOrDefault();
            if (GroupCondition.JobConditionIDs == null)
            {
                return null;
            }
            List<Guid> ilist = GroupCondition.JobConditionIDs.Split(',').Select(s => Guid.Parse(s)).ToList();
            string jobConditionIds = string.Empty;
            foreach (Guid item in ilist)
            {
                jobConditionIds += item;
                jobConditionIds += ",";
            }
            if (jobConditionIds.Length > 0)
            {
                jobConditionIds = jobConditionIds.Substring(0, jobConditionIds.Length - 1);
            }
            var lstJobConditions = baseService.GetData<Rec_JobConditionEntity>(Common.DotNetToOracle(jobConditionIds), ConstantSql.hrm_rec_sp_get_JobConditionByIds, UserLogin, ref status).ToList();
            var candidate = baseService.GetData<Rec_CandidateEntity>(Common.DotNetToOracle(candidateID), ConstantSql.hrm_rec_sp_get_CandidateByIds, UserLogin, ref status).FirstOrDefault();
            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 = baseService.GetData<Cat_NameEntityEntity>(lstparadiseelist, ConstantSql.hrm_cat_sp_get_LevelGeneral, UserLogin, ref status).ToList();

            foreach (Guid item in ilist)
            {

                var ObjJobCondition = lstJobConditions.Where(s => s.ID == item).FirstOrDefault();
                if (ObjJobCondition != null)
                {
                    string strConditionName = ObjJobCondition.Value1.Trim();
                    foreach (char c in strConditionName)
                    {
                        if (!char.IsDigit(c))
                            continue;
                    }
                    int value1 = 0;
                    if (ObjJobCondition.ConditionName != "E_DISEASEIDS" && ObjJobCondition.ConditionName != null)
                    {
                        value1 = int.Parse(ObjJobCondition.Value1.Trim());
                    }

                    if (!string.IsNullOrEmpty(strCondition[0].ToString()))
                    {
                        foreach (var temp in strCondition)
                        {
                            string[] strtemp = temp.Split(',').ToArray();
                            if (strtemp != null && strtemp[1] != null)
                            {
                                int value2 = int.Parse(strtemp[1].ToString().Trim());
                                if (ObjJobCondition.ConditionName.Contains(strtemp[0].ToString()) && strtemp[0].ToString() != "E_SCORE1" && strtemp[0].ToString() != "E_SCORE2"
                                    && strtemp[0].ToString() != "E_SCORE3" && strtemp[0].ToString() != "E_DISEASEIDS")
                                {
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && value1 != value2)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && value1 < value2)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && value1 > value2)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                }
                                if (ObjJobCondition.ConditionName.Contains(strtemp[0].ToString()) && strtemp[0].ToString() == "E_SCORE1")
                                {
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && value1 != score1)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && value1 < score1)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && value1 > score1)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                }

                                if (ObjJobCondition.ConditionName.Contains(strtemp[0].ToString()) && strtemp[0].ToString() == "E_SCORE2")
                                {
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && value1 != score2)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && value1 < score2)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && value1 > score2)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                }
                                if (ObjJobCondition.ConditionName.Contains(strtemp[0].ToString()) && strtemp[0].ToString() == "E_SCORE3")
                                {
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && value1 != score3)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && value1 < score3)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                    if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && value1 > score3)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                        break;
                                    }
                                }
                                if (ObjJobCondition.ConditionName.Contains(strtemp[0].ToString()) && strtemp[0].ToString() == "E_DISEASEIDS")
                                {
                                    var lstDiseaseCondition = ObjJobCondition.Value1.Split(',').Select(x => x).ToList();
                                    var lstsickbycondition = lstsick.Where(s => lstDiseaseCondition.Contains(Common.DotNetToOracle(s.ID.ToString()))).ToList();
                                    var lstDiseseCandidate = candidate.DiseaseListIDs.Split(',').ToList();
                                    if (lstsickbycondition.Where(x => lstDiseseCandidate.Contains(x.Code)).Count() == 0)
                                    {
                                        result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                                    }
                                }
                            }
                            if (strtemp != null && strtemp[1] == null && (score1 != null && score2 != null && score3 != null))
                            {

                            }
                        }
                    }
                    if (ObjJobCondition.ConditionName == ConditionName.E_SCORE1.ToString())
                    {
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && value1 != score1)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && value1 < score1)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && value1 > score1)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                    }
                    if (ObjJobCondition.ConditionName == ConditionName.E_SCORE2.ToString())
                    {
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && value1 != score2)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && value1 < score2)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && value1 > score2)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                    }
                    if (ObjJobCondition.ConditionName == ConditionName.E_SCORE3.ToString())
                    {
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_EQUAL.ToString() && value1 != score3)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_LESS.ToString() && value1 < score3)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                        if (ObjJobCondition.ValueType == HRM.Infrastructure.Utilities.ValueType.E_THAN.ToString() && value1 > score3)
                        {
                            result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            break;
                        }
                    }
                    if (ObjJobCondition.ConditionName == ConditionName.E_DISEASEIDS.ToString())
                    {
                        var lstDiseaseCondition = ObjJobCondition.Value1.Split(',').Select(x => x).ToList();
                        var lstsickbycondition = lstsick.Where(s => lstDiseaseCondition.Contains(Common.DotNetToOracle(s.ID.ToString()))).ToList();
                        if (candidate.DiseaseListIDs != null)
                        {
                            var lstDiseseCandidate = candidate.DiseaseListIDs.Split(',').ToList();
                            if (lstsickbycondition.Where(x => lstDiseseCandidate.Contains(x.Code)).Count() >= 1)
                            {
                                result = HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString();
                            }
                        }

                    }
                }
                if (result == HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString())
                    break;
            }
            return result;
        }
Beispiel #8
0
        public ActionResult ExportIntervieCampaignDetaiByTemplate([DataSourceRequest] DataSourceRequest request, Rec_InterviewCampaignDetailSearchModel model)
        {
            string status = string.Empty;
            var baseService = new BaseService();
            ActionService service = new ActionService(UserLogin);
            List<object> objs = new List<object>();
            List<object> objshis = new List<object>();
            List<Rec_InterviewCampaignDetailModel> resultInterviewCampaignDetail = new List<Rec_InterviewCampaignDetailModel>();
            var InterviewServices = new Rec_InterviewCampaignDetailServices();

            ListQueryModel lstModel = new ListQueryModel
            {
                PageSize = int.MaxValue - 1,
                PageIndex = 1,
                Filters = ExtractFilterAttributes(request),
                Sorts = ExtractSortAttributes(request),
                AdvanceFilters = ExtractAdvanceFilterAttributes(model)
            };
            var result = baseService.GetData<Rec_InterviewCampaignDetailModel>(lstModel, ConstantSql.hrm_rec_sp_get_InterviewCampaignDetail, UserLogin, ref status);
            #region Load Chi tiet ke hoach chua phong van
            if (result != null)
            {
                var InTerCamDetaiServices = new Rec_InterviewCampaignDetailServices();
                var HistoryServices = new Rec_RecruitmentHistoryServices();
                var lstCandidateIDS = result.Select(s => s.CandidateID).Distinct().ToList();
                string temp = string.Empty;
                foreach (Guid item in lstCandidateIDS)
                {
                    temp += item;
                    temp += ",";
                }
                if (temp.Length > 0)
                {
                    temp = temp.Substring(0, temp.Length - 1);
                }
                var lstCandidateHistory = HistoryServices.GetData<Rec_RecruitmentHistoryEntity>(Common.DotNetToOracle(temp), ConstantSql.hrm_rec_sp_get_RecHisByListCandidateID, UserLogin, ref status).ToList();
                foreach (var item in result)
                {
                    //var IlInterviewcampaugnDetail = result.Where(s => s.CandidateID == item.CandidateID).ToList();
                    var ObjHisCandidate = lstCandidateHistory.Where(s => s.ID == item.RecruitmentHistoryID).FirstOrDefault();
                    if (ObjHisCandidate == null)
                    {
                        continue;
                    }
                    Rec_JobVacancyEntity entityJobVacancy = null;
                    if (ObjHisCandidate != null && ObjHisCandidate.JobVacancyID != Guid.Empty && ObjHisCandidate.JobVacancyID != null)
                    {
                        entityJobVacancy = service.GetByIdUseStore<Rec_JobVacancyEntity>(ObjHisCandidate.JobVacancyID.Value, ConstantSql.hrm_rec_sp_get_JobVacancyId, ref status);
                    }
                    if (entityJobVacancy != null)
                    {
                        if (item.LevelInterview != null && item.LevelInterview == entityJobVacancy.NoLevelInterview)
                        {
                            continue;
                        }
                    }
                    if (item.LevelInterview == null && (ObjHisCandidate.Status != HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_PASS.ToString()
                     && ObjHisCandidate.Status != HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_FAIL.ToString()
                        ))
                    {
                        if (ObjHisCandidate != null)
                        {
                            if (ObjHisCandidate.LevelInterview == null)
                            {
                                item.LevelInterview = 1;
                                resultInterviewCampaignDetail.Add(item);
                            }
                            else
                            {
                                item.LevelInterview = ObjHisCandidate.LevelInterview + 1;
                                resultInterviewCampaignDetail.Add(item);
                            }
                        }
                    }
                }
            }
            resultInterviewCampaignDetail = resultInterviewCampaignDetail.Distinct().ToList();
            #endregion

            var isDataTable = false;
            object obj = new Rec_InterviewCampaignDetailModel();
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = model.DateFrom };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = model.DateTo };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            if (model.IsCreateTemplateForDynamicGrid)
            {
                obj = resultInterviewCampaignDetail;
                isDataTable = false;
            }
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "Rec_InterviewCampaignDetailModel",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (model.ExportId != Guid.Empty)
            {

                var fullPath = ExportService.Export(model.ExportId, resultInterviewCampaignDetail, listHeaderInfo, model.ExportType);
                return Json(fullPath);
            }

            return Json(resultInterviewCampaignDetail.ToDataSourceResult(request));
        }
        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;
            }
        }
Beispiel #10
0
        public Rec_CandidateModel Post([Bind]Rec_CandidateModel model)
        {
            #region Validate
            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Rec_CandidateModel>(model, "Rec_Candidate", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
           
            if(model != null && model.DateExpiresPassport !=null && model.DateIssuePassport != null)
            {
                checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Rec_CandidateModel>(model, "Rec_CandidateCheckDate", ref message);
                if (!checkValidate)
                {
                    model.ActionStatus = message;
                    return model;
                }
            }
            #endregion
            ActionService service = new ActionService(UserLogin);
            Rec_RecruitmentHistoryServices recruimentHistoryService = new Rec_RecruitmentHistoryServices();
            #region Check trùng và xử lý lưu or edit lại dòng cũ
            BaseService baseservice = new BaseService();
            string status = string.Empty;
            List<object> lstObj = new List<object>();
            lstObj.Add(model.ID);
            lstObj.Add(model.IdentifyNumber);
            lstObj.Add(model.CandidateName);
            lstObj.Add(model.DateOfBirth);
            var candidate = baseservice.GetData<Rec_CandidateModel>(lstObj, ConstantSql.hrm_rec_sp_checkduplidatecandidate, UserLogin,ref status).FirstOrDefault();
            if (candidate != null)
            {
                model.PassFilterResume = null;
                model.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_NEW.ToString();
                model.ID = candidate.ID;
            }

            // Làm theo task 0048666 - edit mà thay đổi ngày nộp thì update trạng thái = null - task 0049801 sửa lại thành E_NEW
            if (model.ID != Guid.Empty)
            {
                var candidateEntity = baseservice.GetData<Rec_CandidateEntity>(Common.DotNetToOracle(model.ID.ToString()), ConstantSql.hrm_rec_sp_get_CandidateById, UserLogin, ref status).FirstOrDefault();
                
                if (candidateEntity != null && candidateEntity.DateApply != model.DateApply && candidateEntity.Status != model.Status)
                {
                    model.Status = model.Status;
                }
                if (candidateEntity != null && candidateEntity.DateApply == model.DateApply && candidateEntity.Status != model.Status)
                {
                    model.Status = model.Status;
                }
                if (candidateEntity != null && candidateEntity.DateApply != model.DateApply && model.Status == candidateEntity.Status)
                {
                    model.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_NEW.ToString();
                }
            }

            // theo task 0049799 - tạo mới trạng thái e_new
            if(model.ID == Guid.Empty)
            {
                model.Status = HRM.Infrastructure.Utilities.EnumDropDown.CandidateStatus.E_NEW.ToString();
            }

            var userCreateID = Guid.Empty;
            Guid.TryParse(model.UserCreateID, out userCreateID);

            var candidateModel = service.UpdateOrCreate<Rec_CandidateEntity, Rec_CandidateModel>(model, userCreateID);
            #region Xử lý lưu lịch sử ứng viên
            DoActionAfterImport doActionImport = new DoActionAfterImport();
            List<Guid> lstID = new List<Guid>();
            lstID.Add(model.ID);
            doActionImport.ImportRecruitmentHistory(lstID,UserLogin); 
            #endregion
            #endregion
            return model;
        }
 public Rec_InterviewCampaignModel Post([Bind]Rec_InterviewCampaignModel model)
 {
     #region Validate
     string message = string.Empty;
     var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Rec_InterviewCampaignModel>(model, "Rec_InterviewCampaign", ref message);
     if (!checkValidate)
     {
         model.ActionStatus = message;
         return model;
     }
     #endregion
     ActionService service = new ActionService(UserLogin);
     var result = service.UpdateOrCreate<Rec_InterviewCampaignEntity, Rec_InterviewCampaignModel>(model);
     if (model.listCandidateGuidIds != null)
     {
         List<Guid> listId = model.listCandidateGuidIds;
         Rec_InterviewCampaignDetailEntity OjbInterviewDetail = null;
         Rec_InterviewCampaignDetailServices InterviewCampaignDetailService = new Rec_InterviewCampaignDetailServices();
         string status = string.Empty;
         foreach (Guid item in listId)
         {
             var RecruitmentHisService = new Rec_RecruitmentHistoryServices(); 
             var ilistRecruitmentHistory = RecruitmentHisService.GetData<Rec_RecruitmentHistoryEntity>(item, ConstantSql.hrm_rec_sp_get_RecruitmentHistoryIdByCandidateId, UserLogin,ref status).ToList();
             Guid? RecruitmentHistoryId = ilistRecruitmentHistory.Where(s => s.Status != HRM.Infrastructure.Utilities.Interview.E_FAIL.ToString() 
                                                                        && s.Status != HRM.Infrastructure.Utilities.Interview.E_PASS.ToString() && s.Status != null).Select(s => s.ID).FirstOrDefault();
             OjbInterviewDetail = new Rec_InterviewCampaignDetailEntity();
             OjbInterviewDetail.InterviewCampaignID = result.ID;
             OjbInterviewDetail.CandidateID = item;
             OjbInterviewDetail.DateInterview = model.DateInterviewFrom;
             OjbInterviewDetail.RecruitmentHistoryID = RecruitmentHistoryId;
             OjbInterviewDetail.LevelInterview = model.LevelInterview;
             InterviewCampaignDetailService.Add(OjbInterviewDetail);
         }
     }
     return result;
 }
Beispiel #12
0
        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);
            }
        }