Esempio n. 1
0
        private static void ManageCycleInPreCycleStage(Model.DTO.Cycle.Cycle cycle, DateTime runDate)
        {
            Model.DTO.Cycle.Stage obj_cycle_stage = cycle.CycleStages.Where(rec => rec.StageId == Model.PMSConstants.STAGE_ID_GOAL_SETTING).SingleOrDefault();

            if (obj_cycle_stage != null && Convert.ToDateTime(obj_cycle_stage.StartDate).Date == runDate)
            {
                Business.AppraisalManager.PreCycleStageManagement(cycle, runDate.Date, new Model.DTO.Core.Employee());
            }
        }
Esempio n. 2
0
 private static void ManageCycleInProgressReviewStage(Model.DTO.Cycle.Cycle cycle, DateTime runDate)
 {
 }
Esempio n. 3
0
        private static void ManageCycleInGoalSettingStage(Model.DTO.Cycle.Cycle cycle, DateTime runDate)
        {
            List <System.Net.Mail.MailMessage>   lst_email_messages       = new List <System.Net.Mail.MailMessage>();
            List <Model.DTO.Core.Task.Task>      lst_all_tasks            = new List <Model.DTO.Core.Task.Task>();
            List <Model.DTO.Core.Task.Task>      lst_tasks_to_delete      = new List <Model.DTO.Core.Task.Task>();
            List <Model.DTO.Appraisal.Appraisal> lst_appraisals_to_update = new List <Model.DTO.Appraisal.Appraisal>();
            List <Model.DTO.Cycle.Cycle>         lst_cycles = new List <Model.DTO.Cycle.Cycle>();

            Model.DTO.Cycle.Stage obj_current_cycle_stage = cycle.CycleStages.Where(rec => rec.StageId == Model.PMSConstants.STAGE_ID_GOAL_SETTING).SingleOrDefault();
            Model.DTO.Cycle.Stage obj_next_cycle_stage    = cycle.CycleStages.Where(rec => rec.StageId == Model.PMSConstants.STAGE_ID_PROGRESS_REVIEW).SingleOrDefault();

            // stage closing
            if (obj_current_cycle_stage != null && Convert.ToDateTime(obj_current_cycle_stage.EndDate).Date == runDate)
            {
                if (!Lib.Utility.Common.IsNullOrEmptyList(cycle.Appriasals))
                {
                    IEnumerable <Model.DTO.Appraisal.Appraisal> lst_appraisals = cycle.Appriasals.Where(rec => rec.Stage.Id == obj_current_cycle_stage.StageId && rec.Status.Id != Model.PMSConstants.STATUS_ID_APPROVED);

                    if (!Lib.Utility.Common.IsNullOrEmptyList(lst_appraisals))
                    {
                        foreach (Model.DTO.Appraisal.Appraisal obj_appraisal in lst_appraisals)
                        {
                            // force close for those that are not approved.
                            obj_appraisal.Locked = false;
                            //obj_appraisal.AddTrail(Business.AppraisalManager.CreateAppraisalTrail(obj_appraisal, new Model.DTO.Core.Employee(), new Model.DTO.Master.Action() { Id = Model.PMSConstants.ACTION_ID_APPRAISAL_HR_ADMINISTERED }));
                            obj_appraisal.Status = new Model.DTO.Master.Status()
                            {
                                Id = Model.PMSConstants.STATUS_ID_HR_ADMINISTERED
                            };
                            obj_appraisal.Stage = cycle.Stage;

                            // remove open task belong to appraisal
                            lst_tasks_to_delete = Business.AppraisalManager.GetTasksByAppraisal(obj_appraisal.Id, Model.PMSConstants.STATUS_CORE_ID_OPEN);
                            lst_appraisals_to_update.Add(obj_appraisal);
                        }
                    }
                }
            }

            // stage opening
            if (obj_next_cycle_stage != null && Convert.ToDateTime(obj_next_cycle_stage.StartDate).Date == runDate)
            {
                cycle.Stage = Business.AppraisalManager.GetCycleNextStage(cycle, runDate);
                lst_cycles.Add(cycle);
                if (!Lib.Utility.Common.IsNullOrEmptyList(cycle.Appriasals))
                {
                    IEnumerable <Model.DTO.Appraisal.Appraisal> lst_appraisals_to_convert_stage = cycle.Appriasals.Where(rec => rec.Stage.Id == Model.PMSConstants.STAGE_ID_GOAL_SETTING && rec.Status.Id == Model.PMSConstants.STATUS_ID_APPROVED);
                    IEnumerable <Model.DTO.Appraisal.Appraisal> lst_new_appraisals = cycle.Appriasals.Where(rec => rec.Stage.Id == Model.PMSConstants.STAGE_ID_PRE_CYCLE);

                    if (!Lib.Utility.Common.IsNullOrEmptyList(lst_appraisals_to_convert_stage))
                    {
                        foreach (Model.DTO.Appraisal.Appraisal obj_appraisal in lst_appraisals_to_convert_stage)
                        {
                            obj_appraisal.Locked = false;
                            //obj_appraisal.AddTrail(Business.AppraisalManager.CreateAppraisalTrail(obj_appraisal, new Model.DTO.Core.Employee(), new Model.DTO.Master.Action() { Id = Model.PMSConstants.ACTION_ID_APPRAISAL_OPENED }));
                            obj_appraisal.Status = new Model.DTO.Master.Status()
                            {
                                Id = Model.PMSConstants.STATUS_ID_NEW
                            };
                            obj_appraisal.Stage = Model.Mappers.PMSMapper.MapAppraisalStageDTOToStageDTO(obj_appraisal.AppraisalStages.Where(rec => rec.StageId == Model.PMSConstants.STAGE_ID_PROGRESS_REVIEW).SingleOrDefault());

                            if (!string.IsNullOrEmpty(obj_appraisal.Employee.OfficeEmailAddress) && Lib.Utility.Common.IsValidEmail(obj_appraisal.Employee.OfficeEmailAddress))
                            {
                                lst_email_messages.Add(Business.AppraisalManager.GenerateEmailMessageForCycleStageStart(obj_appraisal));
                            }
                            lst_appraisals_to_update.Add(obj_appraisal);
                            lst_all_tasks.Add(Business.AppraisalManager.CreateTasksForCycleStageChange(obj_appraisal));
                        }
                    }

                    if (!Lib.Utility.Common.IsNullOrEmptyList(lst_new_appraisals))
                    {
                        foreach (Model.DTO.Appraisal.Appraisal obj_appraisal in lst_new_appraisals)
                        {
                            // these are appraisals that are created after the goal setting stage of cycle
                            obj_appraisal.Locked = false;
                            //obj_appraisal.AddTrail(Business.AppraisalManager.CreateAppraisalTrail(obj_appraisal, new Model.DTO.Core.Employee(), new Model.DTO.Master.Action() { Id = Model.PMSConstants.ACTION_ID_APPRAISAL_OPENED }));
                            obj_appraisal.Status = new Model.DTO.Master.Status()
                            {
                                Id = Model.PMSConstants.STATUS_ID_NEW
                            };
                            obj_appraisal.Stage = new Model.DTO.Master.Stage()
                            {
                                Id = Model.PMSConstants.STAGE_ID_GOAL_SETTING
                            };

                            if (!string.IsNullOrEmpty(obj_appraisal.Employee.OfficeEmailAddress) && Lib.Utility.Common.IsValidEmail(obj_appraisal.Employee.OfficeEmailAddress))
                            {
                                lst_email_messages.Add(Business.AppraisalManager.GenerateEmailMessageForCycleStageStart(obj_appraisal));
                            }
                            lst_appraisals_to_update.Add(obj_appraisal);
                            lst_all_tasks.Add(Business.AppraisalManager.CreateTasksForCycleStageChange(obj_appraisal));
                        }
                    }
                }
            }

            if (Model.PMSModel.AppraisalStageManager(lst_cycles, lst_appraisals_to_update, lst_all_tasks, lst_tasks_to_delete))
            {
                Business.AppraisalManager.SendEmailNotification(lst_email_messages);
            }
        }