예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="form"></param>
        /// <param name="fileId"></param>
        /// <returns></returns>
        public async Task RemoveOtherFileAsync(ApplicationForm form, string fileId)
        {
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }
            if (string.IsNullOrEmpty(fileId))
            {
                throw new ArgumentException("fileId is null or empty.");
            }

            var list = form.OtherFileList;

            if (list.Contains(fileId))
            {
                list.Remove(fileId);
                var file = await this.fileStore.FindByIdAsync(fileId);

                if (file != null)
                {
                    await this.fileStore.DeleteAsync(file);
                }
            }
            await this.formStore.UpdateAsync(form);
        }
예제 #2
0
        /// <summary>
        /// Upload head image.
        /// </summary>
        /// <param name="form"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <string> UploadHeadImageAsync(ApplicationForm form, Stream data)
        {
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }
            if (form.WhenCommited.HasValue)
            {
                throw new InvalidOperationException("不能更改已提交的报名表资料。");
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (!string.IsNullOrEmpty(form.HeadImageFile))
            {
                throw new InvalidOperationException("文件已存在。");
            }

            this.EnsureImage(data, new Size(207, 290), true, out string mimeType);

            var file = new File(Guid.NewGuid().ToString(), mimeType);

            data.Position = 0;
            await file.ReadAsync(data);

            await this.fileStore.CreateAsync(file);

            form.HeadImageFile = file.Id;
            await this.formStore.UpdateAsync(form);

            return(file.Id);
        }
예제 #3
0
        /// <summary>
        /// File review.
        /// </summary>
        /// <param name="form"></param>
        /// <param name="accepted"></param>
        /// <param name="fileReviewedBy"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task FileReviewAsync(ApplicationForm form, bool accepted, string fileReviewedBy, string message = null)
        {
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }

            if (!form.WhenCommited.HasValue)
            {
                throw new InvalidOperationException("报名表尚未提交。");
            }

            if (form.WhenFileReviewed.HasValue)
            {
                throw new FileReviewException("报名表已审查。");
            }

            form.FileReviewAccepted = accepted;
            form.WhenFileReviewed   = DateTime.Now;
            form.FileReviewedBy     = fileReviewedBy;
            form.FileReviewMessage  = message;

            await this.formStore.UpdateAsync(form);

            if (this.NotificationService != null)
            {
                await this.NotificationService.NotifyFileReviewStateAsync(form);
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="form"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <string> UploadOtherFileAsync(ApplicationForm form, Stream data)
        {
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (form.WhenCommited.HasValue)
            {
                throw new InvalidOperationException("不能更改已提交的报名表资料。");
            }
            if (form.OtherFileList.Count >= 10)
            {
                throw new InvalidOperationException("只能传送最多10份资料。");
            }

            this.EnsureImage(data, new Size(1240, 1754), false, out string mimeType);

            var file = new File(Guid.NewGuid().ToString(), mimeType);

            data.Position = 0;
            await file.ReadAsync(data);

            await this.fileStore.CreateAsync(file);

            form.OtherFileList.Add(file.Id);

            await this.formStore.UpdateAsync(form);

            return(file.Id);
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="form"></param>
        /// <param name="fileId"></param>
        /// <returns></returns>
        public async Task RemoveAcademicFileAsync(ApplicationForm form, string fileId)
        {
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }
            if (form.WhenCommited.HasValue)
            {
                throw new InvalidOperationException("不能更改已提交的报名表资料。");
            }
            if (string.IsNullOrEmpty(fileId))
            {
                throw new ArgumentException("fileId is null or empty.");
            }

            var list = form.AcademicCertFileList;

            if (list.Contains(fileId))
            {
                list.Remove(fileId);
                var file = await this.fileStore.FindByIdAsync(fileId);

                if (file != null)
                {
                    await this.fileStore.DeleteAsync(file);
                }
            }
            await this.formStore.UpdateAsync(form);
        }
예제 #6
0
        /// <summary>
        /// 提交报名资料。
        /// </summary>
        /// <returns></returns>
        public async Task CommitAsync(ApplicationForm form)
        {
            if (form == null)
            {
                throw new ArgumentNullException();
            }

            if (form.Id == 0)
            {
                await this.EnrollAsync(form);
            }

            if (form.WhenCommited.HasValue)
            {
                return;
            }

            if (form.Job.Plan.WhenAuditCommited.HasValue)
            {
                throw new InvalidOperationException("关联的招聘计划已完成资格审核,不再接受提交任何报名表。");
            }

            //如果没有FileReview标记,则不允许在超过报名时间提交。
            if (!form.FileReviewAccepted.HasValue && form.Job.Plan.EnrollExpirationDate < DateTime.Now)
            {
                throw new InvalidOperationException("报名截止时间已过。");
            }

            //检查传送资料是否齐全并满足规则。
            if (string.IsNullOrEmpty(form.HeadImageFile))
            {
                throw new InvalidOperationException("需要证件照。");
            }

            if (!form.AcademicCertFileList.Any())
            {
                throw new InvalidOperationException("至少需要上传一份学历证明文件。");
            }

            //设置提交时间。
            form.WhenCommited = DateTime.Now;
            form.CommitCount += 1;
            form.Log("提交报名表。");

            //清除资料审查标记,以便将此报名表自再次加入资料审查列表中。
            form.WhenFileReviewed   = null;
            form.FileReviewAccepted = null;
            form.FileReviewedBy     = null;
            form.FileReviewMessage  = null;

            //清除审核标记
            form.AuditFlag         = false;
            form.AuditMessage      = null;
            form.AuditBy           = null;
            form.WhenAudit         = null;
            form.WhenAuditComplete = null;

            await this.formStore.UpdateAsync(form);
        }
예제 #7
0
 /// <summary>
 /// 更新报名表。
 /// </summary>
 /// <param name="form"></param>
 /// <param name="tags"></param>
 /// <returns></returns>
 public async Task SetTagsAsync(ApplicationForm form, string tags)
 {
     if (form == null)
     {
         throw new ArgumentNullException(nameof(form));
     }
     form.Tags = tags;
     await this.formStore.UpdateAsync(form);
 }
예제 #8
0
        /// <summary>
        /// 为指定的用户和招聘计划创建报名表。
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public async Task EnrollAsync(ApplicationForm form)
        {
            //根据要求,一个用户只能参与一个报名。
            var currentPlanId   = form.Job.PlanId;
            var currentPersonId = form.PersonId;

            if (this.formStore.ApplicationForms.Count(a => a.Job.PlanId == currentPlanId && a.PersonId == currentPersonId) < AllowFormsInPlan)
            {
                await this.formStore.CreateAsync(form);

                return;
            }
            throw new InvalidOperationException("在一个招聘计划内只能创建一份报名表。");
        }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public async Task ModifyAsync(ApplicationForm form)
        {
            if (form == null)
            {
                throw new ArgumentNullException();
            }

            if (form.WhenCommited.HasValue)
            {
                throw new InvalidOperationException("已提交的报名表不能修改。");
            }

            form.WhenChanged = DateTime.Now;

            await this.formStore.UpdateAsync(form);
        }
예제 #10
0
        /// <summary>
        /// 将报名表退回给求职者。
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public async Task ReturnBackAsync(ApplicationForm form)
        {
            if (form == null)
            {
                throw new ArgumentNullException();
            }

            if (!form.WhenCommited.HasValue)
            {
                return;
            }

            form.WhenCommited = null;
            form.Log("退回报名表。");

            await this.formStore.UpdateAsync(form);
        }
예제 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="form"></param>
        /// <param name="flag"></param>
        /// <param name="message"></param>
        /// <param name="auditBy"></param>
        /// <returns></returns>
        public async Task AuditAsync(ApplicationForm form, bool flag, string message, string auditBy)
        {
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }

            if (string.IsNullOrEmpty(auditBy))
            {
                throw new ArgumentException("auditBy Required");
            }

            form.AuditFlag    = flag;
            form.AuditMessage = message;
            form.AuditBy      = auditBy;
            form.WhenAudit    = DateTime.Now;

            await this.formStore.UpdateAsync(form);
        }
예제 #12
0
        /// <summary>
        /// Remove HeadImage.
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public async Task RemoveHeadImageAsync(ApplicationForm form)
        {
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }
            if (form.WhenCommited.HasValue)
            {
                throw new InvalidOperationException("不能更改已提交的报名表资料。");
            }
            if (string.IsNullOrEmpty(form.HeadImageFile))
            {
                return;
            }

            var file = await this.fileStore.FindByIdAsync(form.HeadImageFile);

            await this.fileStore.DeleteAsync(file);

            form.HeadImageFile = null;
            await this.formStore.UpdateAsync(form);
        }
예제 #13
-5
        /// <summary>
        /// 删除报名表。
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public async Task DeleteAsync(ApplicationForm form)
        {
            //如果该报名表已经提交,则不能删除。
            if (form.WhenCommited.HasValue)
            {
                throw new InvalidOperationException("已提交的报名表不能删除。");
            }

            //与此报名表关联的文件。
            var fileList = new List <string>();

            fileList.Union(form.AcademicCertFileList);
            fileList.Union(form.DegreeCertFileList);
            fileList.Union(form.OtherFileList);
            if (!string.IsNullOrEmpty(form.HeadImageFile))
            {
                fileList.Add(form.HeadImageFile);
            }

            foreach (var fileId in fileList)
            {
                var file = await this.fileStore.FindByIdAsync(fileId);

                if (file != null)
                {
                    await this.fileStore.DeleteAsync(file);
                }
            }
            await this.formStore.DeleteAsync(form);
        }