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


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

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

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

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

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

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

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

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

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

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

                message = InterviewCampaignDetailServices.Edit(ObjInterviewCampaignDetail);
                message = RecruitmentHistoryServices.Edit(ObjRecruitmentHistory);
                message = CandidateServices.Edit(ObjCandidate);
            }
            #endregion
            return(result);
        }
Exemplo n.º 2
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);
            }
        }