Пример #1
0
        public static List<Model.DTO.Appraisal.Appraisal> CreateAppraisalsForUpdateCycle(List<Model.DTO.Core.Employee> participants, List<Model.DTO.Cycle.Stage> stages, Model.DTO.Core.Security.User user)
        {
            List<Model.DTO.Appraisal.Appraisal> lst_appraisals = null;
            if (!Lib.Utility.Common.IsNullOrEmptyList(participants))
            {
                lst_appraisals = new List<Model.DTO.Appraisal.Appraisal>();
                foreach (Model.DTO.Core.Employee obj_participant in participants)
                {
                    Model.DTO.Appraisal.Appraisal obj_appraisal = new Model.DTO.Appraisal.Appraisal()
                    {
                        Stage = new Model.DTO.Master.Stage() { Id = Model.PMSConstants.STAGE_ID_PRE_CYCLE },
                        Status = new Model.DTO.Master.Status() { Id = Model.PMSConstants.STATUS_ID_NEW },
                        Employee = obj_participant,
                        Department = Model.Mappers.CoreMapper.MapDepartmentDTOToMasterDepartmentDTO(obj_participant.Department),
                        Locked = true
                    };

                    obj_appraisal.AddAppraisalSection(new Model.DTO.Appraisal.Section() { SectionId = Model.PMSConstants.SECTION_ID_KPI });
                    obj_appraisal.AddAppraisalSection(new Model.DTO.Appraisal.Section() { SectionId = Model.PMSConstants.SECTION_ID_CORE_VALUES });

                    int flag = CheckStageDate(stages[1], stages[2], stages[3]);
                    switch (flag)
                    {
                        case 1:
                            foreach (Model.DTO.Cycle.Stage obj_cycle_stage in stages)
                            {

                                Model.DTO.Appraisal.Stage obj_appraisal_stage = new Model.DTO.Appraisal.Stage()
                                {
                                    StageId = obj_cycle_stage.StageId,
                                    StartDate = obj_cycle_stage.StartDate,
                                    EndDate = obj_cycle_stage.EndDate,
                                    SubmissionDeadline = obj_cycle_stage.SubmissionDeadline,
                                    Level1ApprovalDeadline = obj_cycle_stage.Level1ApprovalDeadline,
                                    Level2ApprovalDeadline = obj_cycle_stage.Level2ApprovalDeadline
                                };
                                obj_appraisal.AddAppraisalStage(obj_appraisal_stage);
                            }
                            break;
                        case 2:
                        case 3:
                            foreach (Model.DTO.Cycle.Stage obj_cycle_stage in stages.Where(sec=>sec.StageId>eHR.PMS.Model.PMSConstants.STAGE_ID_PRE_CYCLE))
                            {

                                Model.DTO.Appraisal.Stage obj_appraisal_stage = new Model.DTO.Appraisal.Stage()
                                {
                                    StageId = obj_cycle_stage.StageId,
                                    StartDate = obj_cycle_stage.StartDate,
                                    EndDate = obj_cycle_stage.EndDate,
                                    SubmissionDeadline = obj_cycle_stage.SubmissionDeadline,
                                    Level1ApprovalDeadline = obj_cycle_stage.Level1ApprovalDeadline,
                                    Level2ApprovalDeadline = obj_cycle_stage.Level2ApprovalDeadline
                                };
                                obj_appraisal.AddAppraisalStage(obj_appraisal_stage);
                            }
                            break;
                        case 4:
                        case 5:
                        case 6:
                        case 7:
                            foreach (Model.DTO.Cycle.Stage obj_cycle_stage in stages.Where(sec => (sec.StageId == eHR.PMS.Model.PMSConstants.STAGE_ID_GOAL_SETTING || sec.Id == eHR.PMS.Model.PMSConstants.STAGE_ID_FINAL_YEAR)))
                            {

                                Model.DTO.Appraisal.Stage obj_appraisal_stage = new Model.DTO.Appraisal.Stage()
                                {
                                    StageId = obj_cycle_stage.StageId,
                                    StartDate = obj_cycle_stage.StartDate,
                                    EndDate = obj_cycle_stage.EndDate,
                                    SubmissionDeadline = obj_cycle_stage.SubmissionDeadline,
                                    Level1ApprovalDeadline = obj_cycle_stage.Level1ApprovalDeadline,
                                    Level2ApprovalDeadline = obj_cycle_stage.Level2ApprovalDeadline
                                };
                                obj_appraisal.AddAppraisalStage(obj_appraisal_stage);
                            }
                            break;
                        default:
                            break;
                    }

                    if (obj_participant.Level1Approver != null) { obj_appraisal.AddApprover(Model.Mappers.PMSMapper.MapEmployeeDTOToApproverDTO(obj_participant.Level1Approver, 1)); }
                    if (obj_participant.Level2Approver != null) { obj_appraisal.AddApprover(Model.Mappers.PMSMapper.MapEmployeeDTOToApproverDTO(obj_participant.Level2Approver, 2)); }

                    if (obj_participant.SMPEmploeeId != null && obj_participant.SMPEmploeeId > 0)
                    {
                        Model.DTO.Appraisal.Reviewer obj_reviewer = new Model.DTO.Appraisal.Reviewer()
                        {
                            EmployeeId = obj_participant.SMPEmploeeId,
                            Appraisal = obj_appraisal,
                            SMT = true
                        };
                        obj_appraisal.AddReviewer(obj_reviewer);
                    }

                    Model.DTO.Appraisal.Trail obj_trail = new Model.DTO.Appraisal.Trail()
                    {
                        Appraisal = obj_appraisal,
                        Stage = new Model.DTO.Master.Stage() { Id = PMS.Model.PMSConstants.STAGE_ID_PRE_CYCLE },
                        Action = new Model.DTO.Master.Action() { Id = PMS.Model.PMSConstants.ACTION_ID_APPRAISAL_CREATED },
                        ActionTimestamp = DateTime.Now,
                        Actioner = Model.Mappers.CoreMapper.MapUserDTOToEmployeeDTO(user)
                    };
                    obj_appraisal.AddTrail(obj_trail);

                    lst_appraisals.Add(obj_appraisal);
                }
            }
            return lst_appraisals;
        }
Пример #2
0
        public static List<Model.DTO.Appraisal.Appraisal> CreateAppraisalsForNewCycle(List<Model.DTO.Core.Employee> participants, List<Model.DTO.Cycle.Stage> stages, Model.DTO.Core.Security.User user)
        {
            List<Model.DTO.Appraisal.Appraisal> lst_appraisals = null;
            if (!Lib.Utility.Common.IsNullOrEmptyList(participants))
            {
                lst_appraisals = new List<Model.DTO.Appraisal.Appraisal>();
                foreach (Model.DTO.Core.Employee obj_participant in participants)
                {
                    Model.DTO.Appraisal.Appraisal obj_appraisal = new Model.DTO.Appraisal.Appraisal()
                    {
                        Stage = new Model.DTO.Master.Stage() { Id = Model.PMSConstants.STAGE_ID_PRE_CYCLE },
                        Status = new Model.DTO.Master.Status() { Id = Model.PMSConstants.STATUS_ID_NEW },
                        Employee = obj_participant,
                        Department = Model.Mappers.CoreMapper.MapDepartmentDTOToMasterDepartmentDTO(obj_participant.Department),
                        Locked = true
                    };

                    obj_appraisal.AddAppraisalSection(new Model.DTO.Appraisal.Section() { SectionId = Model.PMSConstants.SECTION_ID_KPI });
                    obj_appraisal.AddAppraisalSection(new Model.DTO.Appraisal.Section() { SectionId = Model.PMSConstants.SECTION_ID_CORE_VALUES });

                    foreach (Model.DTO.Cycle.Stage obj_cycle_stage in stages)
                    {
                        Model.DTO.Appraisal.Stage obj_appraisal_stage = new Model.DTO.Appraisal.Stage()
                        {
                            StageId = obj_cycle_stage.StageId,
                            StartDate = obj_cycle_stage.StartDate,
                            EndDate = obj_cycle_stage.EndDate,
                            SubmissionDeadline = obj_cycle_stage.SubmissionDeadline,
                            Level1ApprovalDeadline = obj_cycle_stage.Level1ApprovalDeadline,
                            Level2ApprovalDeadline = obj_cycle_stage.Level2ApprovalDeadline
                        };
                        obj_appraisal.AddAppraisalStage(obj_appraisal_stage);
                    }

                    if (obj_participant.Level1Approver != null) { obj_appraisal.AddApprover(Model.Mappers.PMSMapper.MapEmployeeDTOToApproverDTO(obj_participant.Level1Approver, 1)); }
                    if (obj_participant.Level2Approver != null) { obj_appraisal.AddApprover(Model.Mappers.PMSMapper.MapEmployeeDTOToApproverDTO(obj_participant.Level2Approver, 2)); }

                    Model.DTO.Appraisal.Trail obj_trail = new Model.DTO.Appraisal.Trail()
                    {
                        Appraisal = obj_appraisal,
                        Stage = new Model.DTO.Master.Stage() { Id = PMS.Model.PMSConstants.STAGE_ID_PRE_CYCLE },
                        Action = new Model.DTO.Master.Action() { Id = PMS.Model.PMSConstants.ACTION_ID_APPRAISAL_CREATED },
                        ActionTimestamp = DateTime.Now,
                        Actioner = Model.Mappers.CoreMapper.MapUserDTOToEmployeeDTO(user)
                    };
                    obj_appraisal.AddTrail(obj_trail);

                    if (obj_participant.SMPEmploeeId != null && obj_participant.SMPEmploeeId > 0)
                    {
                        Model.DTO.Appraisal.Reviewer obj_reviewer = new Model.DTO.Appraisal.Reviewer()
                        {
                            EmployeeId = obj_participant.SMPEmploeeId,
                            Appraisal = obj_appraisal,
                            SMT = true
                        };
                        obj_appraisal.AddReviewer(obj_reviewer);
                    }

                    lst_appraisals.Add(obj_appraisal);
                }
            }
            return lst_appraisals;
        }