예제 #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 đá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);
        }
예제 #4
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);
        }
예제 #5
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());
            }
        }
예제 #6
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;
        }
예제 #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
        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();
            }
        }
예제 #10
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;
        }
예제 #11
0
        public Eva_PerformanceEntity AddPerfomance360(Eva_PerformanceEntity model, bool isSelft)
        {
            /*
            *  Goal(Luu đánh giá nhân viên)
            *  Steps :
            *      Step1  :  Insert Eva_Performance
            *      Step2  :  Tự động insert xuống table Eva_PerformanceForDetail
            *      Step3  :  Tự động insert xuống table Eva_PerformanceEva &Eva_PerformanceEvaDetail 
            *                  - Tự Đánh Giá : orderNo =0 (Ngoai ra orderNo >0)
             
            */


            var evaluationStatus = PerformaceEvaStatus.E_WAITING.ToString();
            var result = new Eva_PerformanceEntity();
            var performanceForDetail = new Eva_PerformanceForDetail();
            var performanceEva = new Eva_PerformanceEva();
            var performanceEvaDetail = new Eva_PerformanceEvaDetail();

            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);

                #region step1 : thêm Eva_Performance
                result = model;
                if (result != null && result.ID == Guid.Empty)
                {
                    result.Status = evaluationStatus;
                }
                Add(result);
                #endregion

                #region Step2  :  Tự động insert xuống table Eva_PerformanceForDetail dựa vào các KPI tương ứng

                //lay ds KPIs (kèm theo Marks và Evaluation) - lay dữ liệu từ edit trên lưới
                var kpis = model.KPIs;//cac tieu chi danh gia
                var kpiByTempalateIds = kpis;

                var lstPerformanceForDetails = new List<Eva_PerformanceForDetail>();
                foreach (var kpiByTempalateId in kpiByTempalateIds)
                {
                    performanceForDetail = new Eva_PerformanceForDetail();
                    performanceForDetail.ID = Guid.NewGuid();
                    if (result != null)
                    {
                        performanceForDetail.PerformanceID = result.ID;
                    }
                    performanceForDetail.KPIID = kpiByTempalateId.ID;
                    performanceForDetail.KPIName = kpiByTempalateId.KPIName;
                    performanceForDetail.OrderKPI = kpiByTempalateId.OrderNumber;
                    performanceForDetail.OrderNumber = kpiByTempalateId.OrderNumber;
                    performanceForDetail.Rate = kpiByTempalateId.Rate;
                    lstPerformanceForDetails.Add(performanceForDetail);
                    repoPerformanceForDetail.Add(performanceForDetail);//add vao repo
                }
                repoPerformanceForDetail.SaveChanges();
                #endregion

                #region Step3  :  Tự động insert xuống table Eva_PerformanceEva &Eva_PerformanceEvaDetail

                #region Luu bảng Eva_PerformanceEva (cho từng người đánh giá)

                var lstPerformanceEvaIDs = new List<Guid>();
                int orderNo = 1;
                var performanceEvaSeftId = Guid.Empty;//ID cua bang Eva_PerformanceEva

                #region Tự đánh giá : tự động add 1 người đánh giá là chính bảng thân người tạo bảng đánh giá
                if (isSelft && result != null && model != null && model.ProfileID != Guid.Empty)
                {
                    //tu tao nguoi danh gia la ban than
                    performanceEva = new Eva_PerformanceEva();
                    performanceEva.ID = Guid.NewGuid();
                    performanceEvaSeftId = performanceEva.ID;
                    lstPerformanceEvaIDs.Add(performanceEva.ID);
                    performanceEva.PerformanceID = result.ID;
                    performanceEva.EvaluatorID = model.ProfileID;
                    performanceEva.Status = PerformaceEvaStatus.E_SEFT.ToString();//evaluationStatus;
                    performanceEva.OrderEva = 0;
                    repoPerformanceEva.Add(performanceEva);

                    //cap nhat lai status cua Eva_Performance
                    var performanceEntity = repoPerformance.GetById(result.ID);
                    if (performanceEntity != null)
                    {
                        performanceEntity.Status = PerformaceEvaStatus.E_SEFT.ToString();
                        repoPerformance.SaveChanges();
                    }
                }

                #endregion

                //Lấy ds người đánh giá theo NV và loại đánh giá
                var evaluatorIds = model.EvaluatorIDs;
                var evaluatorObjs = repoEvaluator.FindBy(p => p.IsDelete == null && evaluatorIds.Contains(p.EvaluatorID ?? Guid.Empty)
                    && p.ProfileID == model.ProfileID
                    && p.PerformanceTypeID == model.PerformanceTypeID).ToList();
                evaluatorObjs = evaluatorObjs.OrderBy(p => p.OrderNo).ToList();

                foreach (var evaluator in evaluatorObjs)
                {
                    performanceEva = new Eva_PerformanceEva();
                    performanceEva.ID = Guid.NewGuid();
                    lstPerformanceEvaIDs.Add(performanceEva.ID);
                    if (result != null)
                    {
                        performanceEva.PerformanceID = result.ID;
                    }
                    performanceEva.EvaluatorID = evaluator.EvaluatorID;
                    performanceEva.Status = evaluationStatus;
                    performanceEva.OrderEva = orderNo++;
                    repoPerformanceEva.Add(performanceEva);
                }
                repoPerformanceEva.SaveChanges();
                #endregion
                              
                #region comment Luu Eva_PerformanceEvaDetail (lưu chi tiết cho bảng đánh giá)

                //var isSeft = false;
                ////khởi tạo chi tiet đánh giá cho từng người đánh giá
                //foreach (var performanceEvaID in lstPerformanceEvaIDs)
                //{
                //    //ds cac tieu chí
                //    foreach (var performanceForDetailItem in lstPerformanceForDetails)
                //    {
                //        performanceEvaDetail = new Eva_PerformanceEvaDetail
                //        {
                //            ID = Guid.NewGuid(),
                //            PerfomanceEvaID = performanceEvaID,
                //            PerfomanceDetailID = performanceForDetailItem.ID,
                //            KPIName = performanceForDetailItem.KPIName
                //        };

                //        #region Dành Cho Tự Đánh Giá

                //        if (performanceEvaSeftId != Guid.Empty && performanceEvaSeftId == performanceEvaID)
                //        {
                //            /*Add Mark va Evaluation cho nguoi danh gia la ban than*/
                //            //lay kpi theo name tu model de set data cho Mark va Evaluation

                //            var kpi = kpiByTempalateIds.FirstOrDefault(p => p.KPIName == performanceEvaDetail.KPIName);
                //            if (kpi != null)
                //            {
                //                performanceEvaDetail.Mark = kpi.Mark;
                //                performanceEvaDetail.Evaluation = kpi.Evaluation;
                //            }
                //            //đặt flag là tự đánh giá
                //            isSeft = true;
                //        }
                //        repoPerformanceEvaDetail.Add(performanceEvaDetail);
                //        #endregion
                //    }

                //    if (isSeft)
                //    {
                //        performanceEvaSeftId = Guid.Empty;
                //    }

                //}
                //repoPerformanceEvaDetail.SaveChanges();

                #endregion

                #endregion

            }
            return result;
        }
예제 #12
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;
        }
예제 #13
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;
 }
예제 #14
0
        public string ApproveKPIforPerformance(Guid PerformanceID, List<Eva_KPIEntity> list)
        {
            string rs = null;
            using (var context = new VnrHrmDataContext())
            {
                var status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoPerformance = new Eva_PerformanceRepository(unitOfWork);
                var repoPerformanceForDetail = new Eva_PerformanceForDetailRepository(unitOfWork);
                var repoPerformanceEvaDetail = new Eva_PerformanceEvaDetailRepository(unitOfWork);
                var repoPerformanceEva = new Eva_PerformanceEvaRepository(unitOfWork);
                var repoEvaluator = new Eva_EvaluatorRepository(unitOfWork);
                var lstPerformanceForDetail = repoPerformanceForDetail.FindBy(x => x.PerformanceID == PerformanceID).ToList();
                var Performance = repoPerformance.GetById(PerformanceID);
                if (lstPerformanceForDetail == null && lstPerformanceForDetail.Count == 0)
                    return null;
                foreach (var item in lstPerformanceForDetail)
                {
                    var obj = list.FirstOrDefault(x => x.PerformanceForDetailID.HasValue && x.PerformanceForDetailID == item.ID);
                    if (obj != null)
                    {
                        item.DescriptionKP = obj.DescriptionKP;
                    }
                }
                repoPerformanceForDetail.SaveChanges();
                Performance.Status = "Approve";
                repoPerformance.SaveChanges();
                rs = Performance.Status;

            }
            return rs;
        }
예제 #15
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;
        }
예제 #16
0
        /// <summary>
        /// truoc khi vào màn hình chờ đánh giá , sẽ thêm vào bảng eva_performanceEvaDetail nếu bảng này chưa có data ứng với performanceID
        /// </summary>
        /// <param name="performanceEvaID"></param>
        /// <returns></returns>
        public bool AddPerformanceEvaDetail360(Guid performanceEvaID) {
            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 performanceEvaDetail = new Eva_PerformanceEvaDetail();

                #region Lay DS EvaPerformanceEvaDetail
                //neu co du lieu => khong tao moi 
                var lstPerformanceEvaDetail = unitOfWork.CreateQueryable<Eva_PerformanceEvaDetail>(Guid.Empty, m => m.PerfomanceEvaID == performanceEvaID).ToList();
                if (lstPerformanceEvaDetail.Any())
                {
                    return false;
                }
                #endregion
                   
                //lay performanceID
                var performanceEva = unitOfWork.CreateQueryable<Eva_PerformanceEva>(Guid.Empty, m => m.ID == performanceEvaID).FirstOrDefault();
                var performanceID = Guid.Empty;
                if (performanceEva != null && performanceEva.PerformanceID.HasValue)
                {
                    performanceID = performanceEva.PerformanceID.Value;
                }
                else
                {
                    return false;
                }

                #region lay ds eva_performancefordetail theo performanceID
                var lstPerformanceForDetails = unitOfWork.CreateQueryable<Eva_PerformanceForDetail>(Guid.Empty, m => m.PerformanceID == performanceID).ToList();
                #endregion
                                
                #region comment Luu Eva_PerformanceEvaDetail (lưu chi tiết cho bảng đánh giá)

                //khởi tạo chi tiet đánh giá cho người đánh giá
                if (performanceEvaID != Guid.Empty)
                {
                    //ds cac tieu chí
                    foreach (var performanceForDetailItem in lstPerformanceForDetails)
                    {
                        performanceEvaDetail = new Eva_PerformanceEvaDetail
                        {
                            ID = Guid.NewGuid(),
                            PerfomanceEvaID = performanceEvaID,
                            PerfomanceDetailID = performanceForDetailItem.ID,
                            KPIName = performanceForDetailItem.KPIName
                        };
                        repoPerformanceEvaDetail.Add(performanceEvaDetail);                       
                    }
                }
                repoPerformanceEvaDetail.SaveChanges();
                #endregion
            }
            return false;
        }
예제 #17
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;


        }
예제 #18
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;
        }
예제 #19
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;

        }