コード例 #1
0
        /// <summary>
        /// 从指定的职位所关联的已通过审核的报名表导入考试候选人。
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="examPlan"></param>
        /// <param name="job"></param>
        /// <returns></returns>
        public static async Task ImportFromJobAsync(this CandidateManager manager, ExaminationPlan examPlan, Job job)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            if (examPlan == null)
            {
                throw new ArgumentNullException(nameof(examPlan));
            }

            if (job == null)
            {
                throw new ArgumentNullException(nameof(job));
            }

            foreach (var form in job.ApplicationForms.Approved())
            {
                var candidate = new Candidate(examPlan, form.Person, form.Job.Name)
                {
                    HeadImageFile = form.HeadImageFile
                };
                await manager.CreateAsync(candidate);
            }
        }
コード例 #2
0
 public Candidate(ExaminationPlan plan, Person person, string applyFor = null)
     : this()
 {
     this.Plan   = plan ?? throw new ArgumentNullException(nameof(plan));
     this.ExamId = plan.Id;
     if (this.Plan.WhenPublished.HasValue)
     {
         throw new InvalidOperationException("已发布的考试不能创建候选人。");
     }
     this.Person   = person ?? throw new ArgumentNullException(nameof(person));
     this.PersonId = person.Id;
     this.ApplyFor = applyFor;
 }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public virtual async Task DeleteAsync(ExaminationPlan plan)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }
            if (plan.WhenPublished.HasValue)
            {
                throw new InvalidOperationException("已发布的计划不能删除。");
            }

            await this.Store.DeleteAsync(plan);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public virtual async Task CreateAsync(ExaminationPlan plan)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }

            if (plan.AttendanceConfirmationExpiresAt.HasValue && plan.AttendanceConfirmationExpiresAt.Value < DateTime.Now)
            {
                throw new ArgumentException("确认参加考试的截止时间早于当前时间。");
            }

            await this.Store.CreateAsync(plan);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public virtual async Task UpdateAsync(ExaminationPlan plan)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }
            if (plan.WhenPublished.HasValue)
            {
                throw new InvalidOperationException("已发布的计划不能删除。");
            }

            plan.WhenChanged = DateTime.Now;

            await this.Store.UpdateAsync(plan);
        }
コード例 #6
0
        /// <summary>
        /// 发布考试。
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public virtual async Task PublishAsync(ExaminationPlan plan)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }

            if (!plan.Subjects.Any())
            {
                throw new InvalidOperationException("该考试计划没有任何考试科目。");
            }

            if (!plan.Candidates.Any())
            {
                throw new InvalidOperationException("没有任何考试候选人。");
            }

            if (plan.AttendanceConfirmationExpiresAt.HasValue)
            {
                if (plan.AttendanceConfirmationExpiresAt < DateTime.Now)
                {
                    throw new ArgumentException("确认参加考试的截止时间早于当前时间。");
                }
            }
            else
            {
                //没有设定确认时间,则默认所有考试候选人都参加考试。
                foreach (var candidate in plan.Candidates)
                {
                    candidate.Attendance = true;
                }
            }

            plan.WhenPublished = DateTime.Now;

            await this.Store.UpdateAsync(plan);

            //调用通知服务。
            //如果没有设定确认截止时间,那么发布时不进行通知。
            if (plan.AttendanceConfirmationExpiresAt.HasValue)
            {
                if (this.NotificationService != null)
                {
                    await this.NotificationService.NotifyPlanPublishedAsync(plan);
                }
            }
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public virtual async Task ReleaseAdmissionTicket(ExaminationPlan plan)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }
            if (plan.Candidates.Any(c => c.Attendance.HasValue && c.Attendance.Value == true && string.IsNullOrEmpty(c.AdmissionNumber)))
            {
                throw new InvalidOperationException("尚未对已确认参加考试的人员编制准考证。");
            }

            plan.WhenAdmissionTicketReleased = DateTime.Now;
            await this.Store.UpdateAsync(plan);

            if (NotificationService != null)
            {
                await this.NotificationService.NotifyAdmissionTicketReleasedAsync(plan);
            }
        }
コード例 #8
0
        /// <summary>
        /// 从指定的招聘计划中,将已通过审核报名表导入为考试候选人。
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="examPlan"></param>
        /// <param name="recruitmentPlan"></param>
        /// <returns></returns>
        public static async Task ImportFromRecruitmentPlanAsync(this CandidateManager manager, ExaminationPlan examPlan, RecruitmentPlan recruitmentPlan)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            if (examPlan == null)
            {
                throw new ArgumentNullException(nameof(examPlan));
            }

            if (recruitmentPlan == null)
            {
                throw new ArgumentNullException(nameof(recruitmentPlan));
            }

            if (!recruitmentPlan.WhenAuditCommited.HasValue)
            {
                throw new InvalidOperationException("审核尚未提交的招聘计划不能执行导入。");
            }

            foreach (var job in recruitmentPlan.Jobs)
            {
                await ImportFromJobAsync(manager, examPlan, job);
            }
        }
コード例 #9
0
        /// <summary>
        /// 从指定的考试计划关联的考试候选人中,依据指定的条件导入考试候选人。
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <param name="predicate"></param>
        /// <returns></returns>
        public static async Task ImportFromExaminationPlan(this CandidateManager manager, ExaminationPlan target, ExaminationPlan source, Func <Candidate, bool> predicate)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (source.Equals(target))
            {
                throw new InvalidOperationException("目标和源不能为同一个考试计划。");
            }

            foreach (var candidate in source.Candidates.Where(predicate))
            {
                var newCandidate = new Candidate(target, candidate.Person, candidate.ApplyFor)
                {
                    HeadImageFile = candidate.HeadImageFile
                };
                await manager.CreateAsync(newCandidate);
            }
        }