diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs index 87ac36eb..6ff3902c 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs @@ -34,9 +34,12 @@ public class Ghre_CourseSceneServices : BaseServices(); }); - var coures = await Db.Queryable().Where(x => x.CourseSceneIds != null && (x.CourseSceneIds.Contains(body.id.ObjToString()) || x.CourseSceneId == body.id) && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).ToListAsync(); - if (DT_TableDataT1.Any()) - DT_TableDataT1[0].Courses = coures; + if (body.id.IsNotEmptyOrNull()) + { + var coures = await Db.Queryable().Where(x => x.CourseSceneIds != null && (x.CourseSceneIds.Contains(body.id.ObjToString()) || x.CourseSceneId == body.id) && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).ToListAsync(); + if (DT_TableDataT1.Any()) + DT_TableDataT1[0].Courses = coures; + } result.result.DT_TableDataT1 = DT_TableDataT1; return result; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs index 49256d89..d609195b 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs @@ -1,5 +1,4 @@ using MongoDB.Driver.Linq; -using NPOI.SS.Formula.Functions; using System.Net; using System.Text.RegularExpressions; @@ -608,7 +607,7 @@ public class Ghre_ExamPaperServices : BaseServices x.Id == examRecordId || x.StudyRecordId == examRecordId); examRecordId = record.Id; - var details = await Db.Queryable().Where(x => x.ExamRecordId == record.Id).ToListAsync(); - var detailIds = details.Select(x => x.Id).ToList(); - var recordAnswers = await Db.Queryable() + using var _context = ContextFactory.CreateContext(); + + var src = _context.Ghre_ExamRecordDetail.Where(x => x.ExamRecordId == record.Id); + var src1 = _context.Ghre_ExamRecordAnswer .OrderBy(x => x.TaxisNo) - .Where(x => x.ExamRecordDetailId != null && detailIds.Contains(x.ExamRecordDetailId.Value)) + .Where(x => x.ExamRecordDetailId != null && x.ExamRecordId == record.Id); + + if (groupId != null) + src = src.Where(x => x.GroupId == groupId); + else + src = src.Where(x => x.IsEnable == 1); + + var details = await src + .ToListAsync(); + var detailIds = details.Select(x => x.Id).ToList(); + + src1 = src1.Where(x => detailIds.Contains(x.ExamRecordDetailId.Value)); + + var recordAnswers = await src1 .ToListAsync(); if (record.ScoreStatus == Consts.DIC_EXAM_RECORD_SCORE_STATUS.NO_SCORE) await ExamHelper.SystemMarkAsync(Db, record, details, recordAnswers); @@ -636,7 +651,7 @@ public class Ghre_ExamRecordServices : BaseServices new { it.ExamId }).ExecuteCommandAsync(); #endregion - if (entity.DateType == DicExamDateType.EXAM_DATE) - { - courseEndTime = entity.EndTime.Value.Date.AddDays(1); - courseTime = courseEndTime.AddDays(-(snap?.ValidityPeriod ?? 1) * 30); - } + //if (entity.DateType == DicExamDateType.EXAM_DATE) + //{ + // courseEndTime = entity.EndTime.Value.Date.AddDays(1); + // courseTime = courseEndTime.AddDays(-(snap?.ValidityPeriod ?? 1) * 30); + //} for (int i = 0; i < staffs.Count; i++) { @@ -1466,7 +1466,7 @@ public class Ghre_ExamServices : BaseServices