예제 #1
0
 //kiểm tra có phải là người cuối cùng đánh giá ko?
 public bool CheckOrderEnd(Eva_PerformanceEva obj)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repoPE     = new Eva_PerformanceEvaRepository(unitOfWork);
         var objMax     = repoPE.FindBy(x => x.PerformanceID == obj.PerformanceID).Where(x => x.IsDelete == null).Max(x => x.OrderEva);
         if (objMax == obj.OrderEva)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
        // kiểm tra người đánh giá đã đánh giá
        public bool CheckEvaluatorHasUse(List <Guid> list, Guid PerformanceTypeID)
        {
            using (var context = new VnrHrmDataContext())
            {
                var status     = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo       = new Eva_EvaluatorRepository(unitOfWork);
                var repoPE     = new Eva_PerformanceEvaRepository(unitOfWork);

                var ilPerformanceEva = repoPE.FindBy(x => list.Contains(x.Eva_Performance.ProfileID ?? Guid.Empty) && x.IsDelete == null && x.Eva_Performance.Eva_PerformanceTemplate.PerformanceTypeID == PerformanceTypeID).ToList();
                if (ilPerformanceEva != null && ilPerformanceEva.Count != 0)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        // kiểm tra người đánh giá đã đánh giá 
        public bool CheckEvaluatorHasUse(List<Guid> list, Guid PerformanceTypeID)
        {
            using (var context = new VnrHrmDataContext())
            {
                var status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Eva_EvaluatorRepository(unitOfWork);
                var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);

                var ilPerformanceEva = repoPE.FindBy(x => list.Contains(x.Eva_Performance.ProfileID ?? Guid.Empty) && x.IsDelete == null && x.Eva_Performance.Eva_PerformanceTemplate.PerformanceTypeID == PerformanceTypeID).ToList();
                if (ilPerformanceEva != null && ilPerformanceEva.Count != 0)
                    return true;

            }

            return false;
        }
예제 #4
0
        public bool DeletePerformance(Guid performanceId)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoPerformance = new Eva_PerformanceRepository(unitOfWork);
                var repoEvaluator = new Eva_EvaluatorRepository(unitOfWork);
                var repoPerformanceForDetail = new Eva_PerformanceForDetailRepository(unitOfWork);
                var repoPerformanceEva = new Eva_PerformanceEvaRepository(unitOfWork);
                var repoPerformanceEvaDetail = new Eva_PerformanceEvaDetailRepository(unitOfWork);
                //   var evaluatorObjs = repoEvaluator.FindBy(p => evaluators.Contains(p.EvaluatorID ?? Guid.Empty) && p.ProfileID == model.ProfileID && p.PerformanceTypeID == model.PerformanceTypeID).ToList();

                //get performance
                var performanceDelete = repoPerformance.FindBy(p => p.ID == performanceId).FirstOrDefault();
                if (performanceDelete != null)
                {
                    performanceDelete.IsDelete = true;
                    repoPerformance.SaveChanges();

                    #region xoa performanceForDetail
                    var performanceForDetailDelete =
                        repoPerformanceForDetail.FindBy(p => p.PerformanceID == performanceDelete.ID).ToList();
                    foreach (var performanceForDetail in performanceForDetailDelete)
                    {
                        performanceForDetail.IsDelete = true;
                    }
                    if (performanceForDetailDelete.Any())
                    {
                        repoPerformanceForDetail.SaveChanges();
                    }
                    #endregion

                    #region xoa eva_performanceEva

                    var performanceEvaDelete =
                        repoPerformanceEva.FindBy(p => p.PerformanceID == performanceDelete.ID).ToList();

                    foreach (var evaPerformanceEva in performanceEvaDelete)
                    {
                        evaPerformanceEva.IsDelete = true;
                    }
                    if (performanceEvaDelete.Any())
                    {
                        repoPerformanceEva.SaveChanges();
                    }

                    #endregion

                    #region xoa eva_performanceEvaDetail

                    if (performanceEvaDelete.Any())
                    {
                        foreach (var evaPerformanceEva in performanceEvaDelete)
                        {
                            var performanceEvaDetailDelete =
                                repoPerformanceEvaDetail.FindBy(p => p.PerfomanceEvaID == evaPerformanceEva.ID)
                                    .FirstOrDefault();
                            if (performanceEvaDetailDelete != null)
                            {
                                performanceEvaDetailDelete.IsDelete = true;
                            }
                        }
                        repoPerformanceEvaDetail.SaveChanges();
                    }

                    #endregion
                }
            }
            return true;
        }
예제 #5
0
        /// <summary> Lấy file đính kèm theo cấp bậc đánh giá </summary>
        /// <param name="PerformanceID"></param>
        /// <returns></returns>
        public string GetAttachFileByOrderNo(Guid PerformanceID, int orderNo)
        {
            string attachFile = "";
            //lay thu tu đánh giá của người trước
            orderNo = orderNo - 1;
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoP = new Eva_PerformanceRepository(unitOfWork);
                var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);
                Eva_Performance performance = repoP.GetById(PerformanceID);
                if (performance != null && !string.IsNullOrEmpty(performance.AttachFile) && performance.IsDelete == null)
                {
                    attachFile = performance.AttachFile;
                }
                var ilEva_PerformanceEva = repoPE.FindBy(x => x.PerformanceID == PerformanceID
                    && x.IsDelete == null && x.OrderEva == orderNo).Select(p => p.AttachFile).FirstOrDefault();
                if (ilEva_PerformanceEva != null)
                {
                    attachFile = ilEva_PerformanceEva;
                }
            }

            #region Đọc Xml từ db và chuyển sang string

            if (!string.IsNullOrEmpty(attachFile))
            {
                var performanceService = new Eva_PerformanceServices();
                var doc = performanceService.ReadXml(attachFile, AttachFileEntity.FieldNames.FullName);
                attachFile = string.Join(",", doc.ToArray());
            }
            #endregion

            return attachFile;
        }
예제 #6
0
        public List<Eva_PerformanceEva> GetlistPerformanceEva(Guid PerformanceID, Guid PerformanceEvaID)
        {
            int Rs = 0;
            List<Eva_PerformanceEva> ilEva_PerformanceEva;
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);
                var PerformanceEva = repoPE.GetById(PerformanceEvaID);
                ilEva_PerformanceEva = repoPE.FindBy(x => x.PerformanceID == PerformanceID).Where(x => x.IsDelete == null).ToList();
                if (ilEva_PerformanceEva != null && ilEva_PerformanceEva.Count != 0)
                {
                    ilEva_PerformanceEva = ilEva_PerformanceEva.OrderByDescending(x => x.OrderEva).ToList();
                    ilEva_PerformanceEva = ilEva_PerformanceEva.Where(x => x.OrderEva < PerformanceEva.OrderEva && x.OrderEva > 0).ToList();

                }
            }
            return ilEva_PerformanceEva;


        }
예제 #7
0
        /// <summary> Kiểm tra cấp sau đã đánh giá chưa? </summary>
        /// <param name="PerformanceID"></param>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool CheckSuperiorHasPerformance(Guid PerformanceID, Guid ID)
        {
            /*
            *  Goal(Kiểm tra cấp sau đã đánh giá chưa [Bảng Eva_PerformanceEva])
            *  Input : PerformanceId , ID
            *  OutPut: true(cấp sau đã đánh giá) , false(cấp sau chưa đánh giá) 
            *  Steps :
            *      Step1    :  Nếu là cấp cuối => false(cấp sau chưa đánh giá)
            *      Step2    :  Lấy ds nguoi đánh giá (bảng Eva_PerformanceEva)
            *      Step3    :  Neu ds chỉ có 1 người đánh giá => false (cấp sau chưa đánh giá)
            *      Step4    :  Duyệt người đánh giá 
            *      Step4.1  :  kt từng người đánh giá có trạng thái "chờ" hoặc "Tự đánh giá" => false(cấp sau chưa đánh giá)    
            */
            
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));

                var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);
                var PerformanceEva = repoPE.GetById(ID);
                //nếu là người đánh giá cuối cùng thì cấp sau chưa đánh giá
                if (PerformanceEva.Status == PerformaceEvaStatus.E_APPROVE_END.ToString())
                {
                    //cấp sau chưa đánh giá
                    return false;
                }
                List<Eva_PerformanceEva> ilEva_PerformanceEva = repoPE.FindBy(x => x.PerformanceID == PerformanceID).Where(x => x.IsDelete == null).ToList();
                if (ilEva_PerformanceEva == null || ilEva_PerformanceEva.Count == 0)
                {
                    //true(cấp sau đã đánh giá)
                    return true;
                }
                else
                {
                    ilEva_PerformanceEva = ilEva_PerformanceEva.Where(x => x.OrderEva > 0).OrderBy(x => x.OrderEva).ToList();
                    int Count = ilEva_PerformanceEva.Count();
                    //nếu có 1 người đánh giá thì cấp sau chưa đánh giá
                    if (Count == 1)
                    {
                        //cấp sau chưa đánh giá
                        return false;
                    }
                    else
                    {
                        for (int i = 0; i < Count; i++)
                        {
                            if (i < Count - 1 && ilEva_PerformanceEva[i] == PerformanceEva)
                            {
                                //kiểm tra trạng thái người đánh giá sau là "Chờ" hoặc "Tự Đánh Giá"
                                if (ilEva_PerformanceEva[i + 1].Status == PerformaceEvaStatus.E_WAITING.ToString() 
                                    || ilEva_PerformanceEva[i + 1].Status == PerformaceEvaStatus.E_SEFT.ToString())
                                {
                                    //cấp sau chưa đánh giá
                                    return false;
                                }
                            }

                        }
                    }
                }
            }


            return true;
        }
예제 #8
0
        public Eva_PerformanceEvaEntity EditPerformanceEva(Eva_PerformanceEvaEntity model)
        {
            var Performance = new Eva_Performance();
            var PerformanceEva = new Eva_PerformanceEva();
            List<Guid> ilID = model.PerformanceEvaDetails.Select(x => x.ID).ToList();



            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoP = new Eva_PerformanceRepository(unitOfWork);
                var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);
                var repoPED = new Eva_PerformanceEvaDetailRepository(unitOfWork);
                PerformanceEva = repoPE.GetById(model.ID);
                //cập nhật đánh giá của người đánh giá Eva_PerformanceEva
                if (PerformanceEva != null)
                {
                    //PerformanceEva.AttachFile = model.AttachFile.Substring(0, model.AttachFile.LastIndexOf("_"));
                    PerformanceEva.AttachFile = model.AttachFile;
                    if (CheckOrderEnd(PerformanceEva) == true)
                        PerformanceEva.Status = PerformaceEvaStatus.E_APPROVE_END.ToString();
                    else
                        PerformanceEva.Status = "E_APPROVE_" + PerformanceEva.OrderEva.ToString();
                    PerformanceEva.Strengths = model.Strengths;
                    PerformanceEva.Weaknesses = model.Weaknesses;
                    PerformanceEva.LevelID = model.LevelID;
                    PerformanceEva.ResultNote = model.ResultNote;
                    PerformanceEva.Proportion = model.Proportion;
                    PerformanceEva.TotalMark = model.TotalMark;
                }
                repoPE.SaveChanges();
                //Cập nhật ngược status và Level, Strengths, Weakness, Resultnote cho Eva_Performance theo status Eva_PerformanceEva
                Performance = repoP.GetById(PerformanceEva.PerformanceID ?? Guid.Empty);
                if (Performance != null)
                {
                    Performance.Status = PerformanceEva.Status;
                    if (PerformanceEva.LevelID.HasValue)
                        Performance.LevelID = PerformanceEva.LevelID;
                    if (!string.IsNullOrEmpty(PerformanceEva.Strengths))
                        Performance.Strengths = PerformanceEva.Strengths;
                    if (!string.IsNullOrEmpty(PerformanceEva.Weaknesses))
                        Performance.Weaknesses = PerformanceEva.Weaknesses;
                    if (!string.IsNullOrEmpty(PerformanceEva.ResultNote))
                        Performance.ResultNote = PerformanceEva.ResultNote;
                    repoP.SaveChanges();

                }
                //cập nhật average cho Eva_Performance khi có người đánh giá

                var ilPerformanceEva = repoPE.FindBy(x => x.IsDelete == null && x.OrderEva <= PerformanceEva.OrderEva && x.OrderEva > 0 && x.TotalMark.HasValue).ToList();
                double? totalmark = ilPerformanceEva.Sum(x => x.TotalMark) / ilPerformanceEva.Count();

                float _totalMark = 0;
                float.TryParse(Math.Round(totalmark ?? 0, 2).ToString(), out _totalMark);
                Performance.TotalMark = _totalMark;  //float.Parse(Math.Round(totalmark??0,2).ToString());
                repoP.SaveChanges();




                //cập nhật chi tiết người đánh giá Eva_PerformanceEvaDetail


                Eva_PerformanceEvaDetail objPerformanceEvaDetail = null;
                List<Eva_PerformanceEvaDetail> ilPerformanceEvaDetail = repoPED.FindBy(x => ilID.Contains(x.ID)).ToList();
                var ilobj = model.PerformanceEvaDetails.ToList();
                foreach (var obj in ilobj)
                {
                    objPerformanceEvaDetail = repoPED.GetById(obj.ID);
                    objPerformanceEvaDetail.KPIName = obj.KPIName;
                    objPerformanceEvaDetail.Evaluation = obj.Evaluation;
                    if (obj.Mark.HasValue)
                        objPerformanceEvaDetail.Mark = obj.Mark;
                }
                repoPED.SaveChanges();





            }

            return model;

        }
예제 #9
0
        // kiểm tra đánh giá vượt cấp
        public bool CheckOrder(Guid PerformanceID, Guid ID)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));

                var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);
                var PerformanceEva = repoPE.GetById(ID);


                List<Eva_PerformanceEva> ilEva_PerformanceEva = repoPE.FindBy(x => x.PerformanceID == PerformanceID).Where(x => x.IsDelete == null).ToList();
                if (ilEva_PerformanceEva == null || ilEva_PerformanceEva.Count == 0)
                {
                    return false;
                }
                else
                {
                    ilEva_PerformanceEva = ilEva_PerformanceEva.Where(x => x.OrderEva > 0).OrderBy(x => x.OrderEva).ToList();
                    int Count = ilEva_PerformanceEva.Count();
                    //nếu đánh giá hiện tại là đầu tiên thì thỏa
                    if (PerformanceEva == ilEva_PerformanceEva[0])
                    {
                        return true;
                    }
                    else
                        // chạy từ 1 vì bỏ qua người đầu vì đã được kt ở trước
                        for (int i = 1; i < Count; i++)
                        {

                            if (ilEva_PerformanceEva[i] == PerformanceEva && PerformanceEva.OrderEva != 0)
                            {

                                if (ilEva_PerformanceEva[i - 1].Status != PerformaceEvaStatus.E_WAITING.ToString() || ilEva_PerformanceEva[i - 1].Status == PerformaceEvaStatus.E_SEFT.ToString())
                                    return true;
                            }
                        }
                }
            }


            return false;
        }
예제 #10
0
        public string GetAttachFile(Guid PerformanceID)
        {
            string str = "";
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoP = new Eva_PerformanceRepository(unitOfWork);
                var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);
                Eva_Performance Performance = repoP.GetById(PerformanceID);
                if (Performance != null && !string.IsNullOrEmpty(Performance.AttachFile) && Performance.IsDelete == null)
                {
                    str = Performance.AttachFile;
                }

                List<Eva_PerformanceEva> ilEva_PerformanceEva = repoPE.FindBy(x => x.PerformanceID == PerformanceID && x.IsDelete == null).ToList();
                List<string> lstAttachFiles = ilEva_PerformanceEva.OrderByDescending(p => p.AttachFile).Select(p => p.AttachFile).ToList();
                lstAttachFiles.Add(str);
                lstAttachFiles = lstAttachFiles.OrderByDescending(p => p).ToList();
                return lstAttachFiles.FirstOrDefault();
            }
        }
예제 #11
0
 //kiểm tra có phải là người cuối cùng đánh giá ko?
 public bool CheckOrderEnd(Eva_PerformanceEva obj)
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repoPE = new Eva_PerformanceEvaRepository(unitOfWork);
         var objMax = repoPE.FindBy(x => x.PerformanceID == obj.PerformanceID).Where(x => x.IsDelete == null).Max(x => x.OrderEva);
         if (objMax == obj.OrderEva)
             return true;
     }
     return false;
 }