diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index 61f764d3..1eee64a7 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -18,6 +18,7 @@ using Tiobon.Core.Common.DB.Dapper; using Tiobon.Core.Common.Helper; using System.Data; using static Tiobon.Core.Model.Consts; +using Org.BouncyCastle.Crypto; namespace Tiobon.Core.Services; @@ -1186,10 +1187,10 @@ public class Ghre_ExamServices : BaseServices x.ExamId == id && x.Status == DIC_EXAM_RECORD_STATUS.EXAMING)) + if (entity.Status == DIC_EXAM_STATUS.RELEASED && status == DIC_EXAM_STATUS.DRAFT && await _ghre_ExamRecordServices.AnyAsync(x => x.ExamId == id && x.Status == DIC_EXAM_RECORD_STATUS.EXAMING)) return ServiceResult.OprateFailed("已有学员参与考试,不可取消发布!"); - if (entity.Status == Consts.DIC_EXAM_STATUS.DISABLED && status == Consts.DIC_EXAM_STATUS.RELEASED) + if (entity.Status == DIC_EXAM_STATUS.DISABLED && status == DIC_EXAM_STATUS.RELEASED) { if (entity.LinkType == "CourseId") { @@ -1207,21 +1208,23 @@ public class Ghre_ExamServices : BaseServices id != x).ToList(); + if (entity.LinkType == DIC_EXAM_LINK_TYPE_COURSE) { #region 校验同一个课程下 考试时间不允许重叠 - var exams = await base.Query(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED && x.CourseId == entity.CourseId && x.Id != id); + var exams = await base.Query(x => (x.Status == DIC_EXAM_STATUS.RELEASED && x.CourseId == entity.CourseId && x.Id != id) || ids1.Contains(x.Id)); if (exams.Any()) for (int i = 0; i < exams.Count; i++) { var exam = exams[i]; var course = await _ghre_CourseServices.QuerySingle(entity.CourseId); - if (exam.DateType != entity.DateType || exam.DateType == Consts.DicExamDateType.AFTER_HOW_LONG) + if (exam.DateType != entity.DateType || exam.DateType == DicExamDateType.AFTER_HOW_LONG) return ServiceResult.OprateFailed($"课程【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】!"); - else if (exam.DateType == Consts.DicExamDateType.EXAM_DATE) + else if (exam.DateType == DicExamDateType.EXAM_DATE) { if ((entity.BeginTime >= exam.BeginTime && entity.BeginTime <= exam.EndTime) || (entity.EndTime >= exam.BeginTime && entity.EndTime <= exam.EndTime) @@ -1235,16 +1238,16 @@ public class Ghre_ExamServices : BaseServices x.Status == Consts.DIC_EXAM_STATUS.RELEASED && x.CourseSceneId == entity.CourseSceneId && x.Id != id); + var exams = await base.Query(x => (x.Status == DIC_EXAM_STATUS.RELEASED && x.CourseSceneId == entity.CourseSceneId && x.Id != id) || ids1.Contains(x.Id)); if (exams.Any()) for (int i = 0; i < exams.Count; i++) { var exam = exams[i]; var course = await _ghre_CourseSceneServices.QuerySingle(entity.CourseSceneId); - if (exam.DateType != entity.DateType || exam.DateType == Consts.DicExamDateType.AFTER_HOW_LONG) + if (exam.DateType != entity.DateType || exam.DateType == DicExamDateType.AFTER_HOW_LONG) return ServiceResult.OprateFailed($"课程场景【{course.CourseName}】已存在有效的考试管理数据【{exam.ExamName}({exam.ExamNo})】!"); - else if (exam.DateType == Consts.DicExamDateType.EXAM_DATE) + else if (exam.DateType == DicExamDateType.EXAM_DATE) { if ((entity.BeginTime >= exam.BeginTime && entity.BeginTime <= exam.EndTime) || (entity.EndTime >= exam.BeginTime && entity.EndTime <= exam.EndTime)