Пример #1
0
        public int CreateAppointmentReport(Appointment entity/*,User creator*/)
        {
            int id = 0;
            int secondnumber = 0;
            var reports = AppointmentReportDao.QueryExpression(x => x.Appointment.Id == entity.Id);
            if (reports != null && reports.Any())
            {
                foreach (var el in reports)
                {
                    if (el.SecondNumber > secondnumber) secondnumber = el.SecondNumber;
                }
            }
            secondnumber++;
            AppointmentReport report = new AppointmentReport
                                               {
                                                   Appointment = entity,
                                                   Creator = entity.AcceptStaff!=null?entity.AcceptStaff:UserDao.Load(CurrentUser.Id) ,
                                                   CreateDate = DateTime.Now,
                                                   EditDate = DateTime.Now,
                                                   Email = string.Empty,
                                                   Name = entity.FIO!=null?entity.FIO:"",
                                                   Number = RequestNextNumberDao.GetNextNumberForType((int)RequestTypeEnum.AppointmentReport),
                                                   SecondNumber = secondnumber,
                                                   Phone = string.Empty,
                                                   Type = AppointmentEducationTypeDao.Get(entity.AppointmentEducationTypeId),
                                                   IsColloquyPassed=entity.Recruter==2?true:new bool?(),
                                                                                                };
            if (entity.Recruter == 2) report.StaffDateAccept = DateTime.Now;
                AppointmentReportDao.Save(report);
                id = report.Id;

            return id;
        }
Пример #2
0
 public int CreateNewReport(int otherReportId)
 {
     AppointmentReport entity = AppointmentReportDao.Get(otherReportId);
     if (entity == null)
         throw new ValidationException(string.Format(StrAppointmentReportNotFound, otherReportId));
     if(entity.Appointment.DeleteDate.HasValue)
         throw new ValidationException(string.Format(StrAppointmentWasDeleted));
     /*if(CurrentUser.Id != entity.Appointment.AcceptStaff.Id && !entity.Appointment.Recruters.Any(x=>x.Id==CurrentUser.Id))
         throw new ValidationException(string.Format(CannotCreateReport));*/
     //return CreateAppointmentReport(entity.Appointment/*,entity.Appointment.AcceptStaff*/);
     int secondnumber = 0;
     var reports = AppointmentReportDao.QueryExpression(x => x.Appointment.Id == entity.Appointment.Id);
     if (reports != null && reports.Any())
     {
         foreach (var el in reports)
         {
             if (el.SecondNumber > secondnumber) secondnumber = el.SecondNumber;
         }
     }
     secondnumber++;
     AppointmentReport report = new AppointmentReport
     {
         Appointment = entity.Appointment,
         Creator = entity.Appointment.AcceptStaff,
         CreateDate = DateTime.Now,
         EditDate = DateTime.Now,
         Email = string.Empty,
         Name = string.Empty,
         Number = entity.Number,
         SecondNumber = secondnumber,
         Phone = string.Empty,
         Type = AppointmentEducationTypeDao.Get(1),
     };
     AppointmentReportDao.SaveAndFlush(report);
     return report.Id;
 }
Пример #3
0
 private void CreateCandidate(AppointmentReport entity)
 {
     User newUserEntity = new User();
     newUserEntity.Login = entity.TempLogin;
     newUserEntity.Password = entity.TempPassword;
     newUserEntity.IsFirstTimeLogin = true;
     newUserEntity.IsActive = true;
     newUserEntity.IsNew = true;
     newUserEntity.Name = entity.Name;
     newUserEntity.RoleId = (int)UserRole.Candidate;
     newUserEntity.GivesCredit = false;
     newUserEntity.IsMainManager = false;
     //UserDao.SaveAndFlush(newUserEntity);
     EmploymentCommonDao.SaveAndFlush(new EmploymentCandidate { User = newUserEntity });
 }
Пример #4
0
        protected void SetManagerInfoModel(User user, ManagerInfoModel model,Appointment appointment,
            AppointmentReport appointmentReport)
        {
            if(appointmentReport != null)
                model.StaffName = appointmentReport.Creator.FullName;
            else if(appointment != null)
            {
                AppointmentReport rep = AppointmentReportDao.LoadForAppointmentId(appointment.Id).FirstOrDefault();
                if(rep != null)
                    model.StaffName = rep.Creator.FullName;
            }

            #region Заполнение списка вышестоящих руководителей

            IList<User> chiefs = GetChiefsForManager(user.Id)
                //.Where<User>(chief => chief.Level >= 4)
                .OrderByDescending<User, int?>(chief => chief.Level)
                .ToList<User>();

            // + руководители по ручным привязкам
            IList<User> manualRoleManagers = ManualRoleRecordDao.GetManualRoleHoldersForUser(user.Id, UserManualRole.ApprovesEmployment);
            foreach (var manualRoleManager in manualRoleManagers)
            {
                if (!chiefs.Contains(manualRoleManager))
                {
                    chiefs.Add(manualRoleManager);
                }
            }

            StringBuilder chiefsBuilder = new StringBuilder();
            foreach (var chief in chiefs)
            {
                chiefsBuilder.AppendFormat("{0} ({1}), ", chief.Name, chief.Position == null ? "<не указана>" : chief.Position.Name);
            }
            // Cut off trailing ", "
            if (chiefsBuilder.Length >= 2)
            {
                chiefsBuilder.Remove(chiefsBuilder.Length - 2, 2);
            }

            model.Chiefs = chiefsBuilder.ToString();

            #endregion
            if(appointment!=null)
            model.DocumentNumber = appointment.Number.ToString();
            model.Department = user.Department == null ? string.Empty : user.Department.Name;
            model.Organization = user.Organization != null ? user.Organization.Name : string.Empty;
            model.Position = user.Position != null ? user.Position.Name : string.Empty;
            model.UserName = user.FullName;
            model.ManagerId = user.Id;
        }
Пример #5
0
 protected void SetHiddenFields(AppointmentReportEditModel model, AppointmentReport entity)
 {
     if (entity != null)
     {
         model.DepartmentName = entity.Appointment.Department.Name;
         model.DepartmentId = entity.Appointment.Department.Id;
         model.ManagerId = entity.Appointment.Creator.Id;
         model.City = entity.Appointment.City;
         model.CandidatePosition = entity.Appointment.PositionName;
         model.VacationCount = entity.Appointment.BankAccountantAcceptCount.ToString();
         model.Reason = entity.Appointment.Reason.Name;
         model.AppointmentNumber = entity.Appointment.Number.ToString();
     }
     model.TypeIdHidden = model.TypeId;
     model.IsEducationExistsHidden = model.IsEducationExists;
     model.IsColloquyPassedHidden = model.IsColloquyPassed;
     model.IsManagerApprovedHidden = model.IsManagerApproved;
     model.IsStaffApprovedHidden = model.IsStaffApproved;
     //model.DateCreatedHidden = model.DateCreated;
 }
Пример #6
0
        protected void SetFlagsState(int id, User current, UserRole currRole, AppointmentReport entity, AppointmentReportEditModel model)
        {
            SetFlagsState(model, false);
            model.AppId = entity.Appointment.Id;
            if (entity.CandidateRejectDate.HasValue)
            {
                model.CandidateRejectDate = entity.CandidateRejectDate;
                model.CandidateRejectedBy = entity.CandidateRejectedBy != null ? entity.CandidateRejectedBy.Name : "";
            }
            model.IsManagerApproved = entity.ManagerDateAccept.HasValue;
            model.IsBankAccountantAccept = entity.Appointment.BankAccountantAccept.HasValue && entity.Appointment.BankAccountantAccept.HasValue && entity.Appointment.BankAccountantAcceptCount > 0;
            model.IsStaffApproved = entity.StaffDateAccept.HasValue;
            model.IsDeleted = entity.DeleteDate.HasValue;
            if (entity.AcceptManager != null && entity.ManagerDateAccept.HasValue)
                model.ManagerFio = entity.AcceptManager.FullName;
            if (entity.AcceptStaff != null && entity.StaffDateAccept.HasValue)
                model.StaffFio = entity.AcceptStaff.FullName;
            if (entity.DeleteDate.HasValue)
                model.DeleteUser = entity.DeleteUser.FullName;
            model.ShowStaff = entity.Appointment.Recruter == 1;
            switch (currRole)
            {
                case UserRole.Manager:
                    if (current.Id == entity.Appointment.Creator.Id && !entity.DeleteDate.HasValue)
                    {
                        if (!entity.StaffDateAccept.HasValue)
                        {
                            model.IsStaffApproveAvailable = true;
                        }
                        model.IsEditable = true;
                        if (entity.AcceptManager != null && !string.IsNullOrEmpty(entity.TempLogin))
                                model.IsPrintLoginAvailable = true;

                        if (!entity.DateAccept.HasValue)
                        {
                            if (entity.StaffDateAccept.HasValue)
                            {
                                model.IsManagerRejectAvailable = true;
                                if (!entity.ManagerDateAccept.HasValue)
                                {
                                    model.IsManagerApproveAvailable = true;
                                    model.IsColloquyDateEditable = true;
                                }
                                else
                                {
                                    model.IsManagerEditable = true;
                                    if (!string.IsNullOrEmpty(entity.TempLogin))
                                        model.IsPrintLoginAvailable = true;
                                }
                            }
                        }
                    }
                    break;
                case UserRole.StaffManager:
                    if (!entity.DeleteDate.HasValue /*&& (current.Id == entity.Appointment.AcceptStaff.Id || (entity.Appointment.Recruters!=null?entity.Appointment.Recruters.Any(x=>x.Id==current.Id):false))*/)
                    {
                        if (entity.AcceptManager != null && entity.AcceptManager.Id == current.Id &&
                                !string.IsNullOrEmpty(entity.TempLogin))
                            model.IsPrintLoginAvailable = true;

                        if (!entity.DateAccept.HasValue)
                        {
                            if (!entity.StaffDateAccept.HasValue)
                            {
                                model.IsStaffApproveAvailable = true;
                                model.IsEditable = true;
                                if (model.AttachmentId > 0)
                                {

                                    model.IsDeleteScanAvailable = true;
                                    model.IsManagerApproveAvailable = true;
                                    model.IsColloquyDateEditable = true;
                                    model.IsManagerEditable = false;
                                }
                            }
                            else if (!entity.ManagerDateAccept.HasValue)
                            {
                                model.IsManagerRejectAvailable = true;
                                model.IsManagerApproveAvailable = true;
                                model.IsColloquyDateEditable = true;
                                model.IsManagerEditable = false;
                            }
                            else if (entity.AcceptManager.Id == current.Id)
                            {
                                model.IsManagerRejectAvailable = true;
                                model.IsManagerEditable = false;
                            }
                            /*if (!entity.StaffDateAccept.HasValue)
                            {
                                model.IsEditable = true;
                                if (model.AttachmentId > 0)
                                {
                                    model.IsStaffApproveAvailable = true;
                                    model.IsDeleteScanAvailable = true;
                                    model.IsManagerApproveAvailable = true;
                                    model.IsColloquyDateEditable = true;
                                }
                            }
                            else
                            {
                                model.IsManagerRejectAvailable = true;
                                if (!entity.ManagerDateAccept.HasValue)
                                {
                                    model.IsManagerApproveAvailable = true;
                                    model.IsColloquyDateEditable = true;
                                }
                                else
                                {
                                    model.IsManagerEditable = true;
                                    if (!string.IsNullOrEmpty(entity.TempLogin))
                                        model.IsPrintLoginAvailable = true;
                                }
                            }*/
                            if (entity.ManagerDateAccept.HasValue && model.IsColloquyPassed == 1)
                                model.IsStaffSetDateAcceptAvailable = true;
                            model.IsAddAvailable = true;
                            /*if (model.AttachmentId > 0)
                                model.ApproveForAllAvailable = true;*/
                        }
                    }
                    break;
                case UserRole.Trainer:
                    model.IsTrainerCanSave = model.IsColloquyPassed == 1;
                    break;
                case UserRole.ConsultantPersonnel:
                case UserRole.PersonnelManager:
                case UserRole.Estimator:
                case UserRole.OutsourcingManager:
                case UserRole.Security:
                    break;
                default:
                    throw new ArgumentException(string.Format("Недопустимая роль {0}", currRole));
            }
            model.IsSaveAvailable = model.IsEditable || model.IsManagerEditable || model.IsManagerApproveAvailable
                                    || model.IsStaffApproveAvailable || model.IsStaffSetDateAcceptAvailable | model.IsTrainerCanSave;
        }
Пример #7
0
        protected void ChangeEntityProperties(IUser current, AppointmentReport entity, AppointmentReportEditModel model,
           User user, out string error)
        {
            error = string.Empty;
            User currUser = UserDao.Get(current.Id);
            bool dateAcceptSet = false;
            if (model.CandidateRejectDate.HasValue)
            {
                entity.CandidateRejectDate = DateTime.Now;
                entity.CandidateRejectedBy = UserDao.Load(CurrentUser.Id);
            }
            if (!model.IsDelete)
            {
                if (model.IsEditable)
                {
                    //model.IsEducationExists = !entity.IsEducationExists.HasValue ? 0 : (entity.IsEducationExists.Value ? 1 : 0);
                    //model.UserId = entity.Creator.Id;
                    //entity.Type = AppointmentEducationTypeDao.Get(model.TypeId);
                    entity.Name = model.Name;
                    entity.Phone = model.Phone;
                    entity.Email = model.Email;
                    //entity.ColloquyDate = DateTime.Parse(model.ColloquyDate);
                    entity.EducationTime =  model.EducationTime ;
                    //entity.RejectReason = model.RejectReason;
                }
                if (!String.IsNullOrWhiteSpace(model.LessonDate))
                {
                    DateTime res;
                    if (DateTime.TryParse(model.LessonDate, out res)) { entity.LessonDate = res; };
                }
                if(model.IsColloquyDateEditable)
                {
                    entity.ColloquyDate = string.IsNullOrEmpty(model.ColloquyDate)
                        ? new DateTime?()
                        : DateTime.Parse(model.ColloquyDate);
                }
                if (model.IsManagerEditable)
                {

                    entity.ResumeComment = model.ResumeComment;

                    if (model.IsColloquyPassed >= 0)
                        entity.IsColloquyPassed = model.IsColloquyPassed == 1 ? true : false;
                    else
                        entity.IsColloquyPassed = new bool?();
                    if (!string.IsNullOrEmpty(model.DateAccept))
                    {
                        entity.DateAccept = DateTime.Parse(model.DateAccept);
                        dateAcceptSet = true;
                    }
                }
                if (model.IsStaffSetDateAcceptAvailable)
                {
                    /*if (model.IsEducationExists >= 0)
                        entity.IsEducationExists = model.IsEducationExists == 1 ? true : false;
                    else
                        entity.IsEducationExists = new bool?();*/
                    if (!string.IsNullOrEmpty(model.DateAccept) && entity.IsEducationExists.HasValue)
                    {
                        entity.DateAccept = DateTime.Parse(model.DateAccept);
                        dateAcceptSet = true;
                    }
                }
            }
            switch (current.UserRole)
            {
                case UserRole.StaffManager:
                {
                    if (!entity.DeleteDate.HasValue /*&& (entity.Appointment.AcceptStaff.Id == current.Id || entity.Appointment.Recruters.Any(x=>x.Id==current.Id))*/)
                    {
                        entity.TestingResult = model.TestingResult;
                        entity.ResumeCommentByOPINP = model.ResumeCommentByOPINP;
                            if (!entity.StaffDateAccept.HasValue && model.IsStaffApproved && model.AttachmentId > 0)
                            {
                                entity.StaffDateAccept = DateTime.Now;
                                entity.AcceptStaff = currUser;
                            }
                            if (entity.StaffDateAccept.HasValue && !entity.ManagerDateAccept.HasValue && model.IsManagerApproved)
                            {
                                entity.ManagerDateAccept = DateTime.Now;
                                entity.AcceptManager = currUser;
                                entity.TempLogin = entity.Id.ToString();
                                entity.TempPassword = CreatePassword(PasswordLength);
                            }
                            /*if (entity.Appointment.Creator.Id == current.Id && dateAcceptSet)
                            {
                                RejectReportsExceptId(entity.Appointment.Id, entity.Id, entity.Appointment.Creator,
                                                      string.Format("Другой кандидат принят на работу (отчет № {0})",
                                                                    entity.Number));
                            }*/
                            if (entity.AcceptStaff != null && dateAcceptSet)
                            {
                                RejectReportsExceptId(entity.Appointment.Id, entity.Id, entity.Creator,
                                                      string.Format("Другой кандидат принят на работу (отчет № {0})",
                                                                    entity.Number));
                            }
                        //}
                    }
                }
                break;
                case UserRole.Manager:
                {
                    if (!entity.StaffDateAccept.HasValue && model.IsStaffApproved && model.AttachmentId > 0)
                    {
                        entity.StaffDateAccept = DateTime.Now;
                        entity.AcceptStaff = currUser;
                    }
                    if(!entity.DeleteDate.HasValue && entity.StaffDateAccept.HasValue
                        && !entity.ManagerDateAccept.HasValue
                        && entity.Appointment.Creator.Id == current.Id
                        && model.IsManagerApproved)
                    {
                        entity.ManagerDateAccept = DateTime.Now;
                        entity.AcceptManager = currUser;
                        entity.TempLogin = entity.Id.ToString();
                        entity.TempPassword = CreatePassword(PasswordLength);
                        entity.ResumeComment = model.ResumeComment;
                        CreateCandidate(entity);
                    }
                    if (!entity.DeleteDate.HasValue && entity.Appointment.Creator.Id == current.Id && dateAcceptSet)
                    {
                        RejectReportsExceptId(entity.Appointment.Id, entity.Id, entity.Appointment.Creator,
                                              string.Format("Другой кандидат принят на работу (отчет № {0})",
                                                            entity.Number));
                    }
                }
                break;
                case UserRole.Trainer:
                if (model.IsEducationExists >= 0)
                    entity.IsEducationExists = model.IsEducationExists == 1 ? true : false;
                else
                    entity.IsEducationExists = new bool?();
                break;
                case UserRole.Estimator:
                case UserRole.OutsourcingManager:
                break;
                default:
                    throw new ArgumentException(string.Format("Недопустимая роль {0}", current.UserRole));
            }
        }