|
|
@ -253,7 +253,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> UpdateStatus(long[] ids, string status) |
|
|
|
public async Task<ServiceResult> UpdateStatus(long[] ids, string status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (status != Consts.DIC_COURSE_STATUS.RELEASED && status != Consts.DIC_COURSE_STATUS.DISABLED && status != Consts.DIC_COURSE_STATUS.DRAFT) |
|
|
|
if (status != DIC_COURSE_STATUS.RELEASED && status != DIC_COURSE_STATUS.DISABLED && status != DIC_COURSE_STATUS.DRAFT) |
|
|
|
throw new Exception("无效的状态"); |
|
|
|
throw new Exception("无效的状态"); |
|
|
|
|
|
|
|
|
|
|
|
HttpRequest request = UserContext.Context.Request; |
|
|
|
HttpRequest request = UserContext.Context.Request; |
|
|
@ -269,7 +269,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
var entity = await BaseDal.QueryById(id); |
|
|
|
var entity = await BaseDal.QueryById(id); |
|
|
|
|
|
|
|
|
|
|
|
#region 关联数据有效性验证 |
|
|
|
#region 关联数据有效性验证 |
|
|
|
if (entity.Status == Consts.DIC_COURSE_STATUS.DRAFT && status == Consts.DIC_COURSE_STATUS.RELEASED) |
|
|
|
if (entity.Status == DIC_COURSE_STATUS.DRAFT && status == DIC_COURSE_STATUS.RELEASED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!entity.CourseClassId.IsNull()) |
|
|
|
if (!entity.CourseClassId.IsNull()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -301,8 +301,6 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 课程ID 同步至课件 |
|
|
|
#region 课程ID 同步至课件 |
|
|
|
if (!entity.CourseWareId.IsNull()) |
|
|
|
if (!entity.CourseWareId.IsNull()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -338,7 +336,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
|
|
|
|
|
|
|
|
entity.PublishTime = DateTime.Now; |
|
|
|
entity.PublishTime = DateTime.Now; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (status == Consts.DIC_COURSE_STATUS.DRAFT && entity.Status == Consts.DIC_COURSE_STATUS.RELEASED) |
|
|
|
else if (status == DIC_COURSE_STATUS.DRAFT && entity.Status == DIC_COURSE_STATUS.RELEASED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#region 课程ID 同步至课件 |
|
|
|
#region 课程ID 同步至课件 |
|
|
|
if (!entity.CourseWareId.IsNull()) |
|
|
|
if (!entity.CourseWareId.IsNull()) |
|
|
@ -354,33 +352,39 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
wares[j].CourseIds = JsonConvert.SerializeObject(courseIds2); |
|
|
|
wares[j].CourseIds = JsonConvert.SerializeObject(courseIds2); |
|
|
|
} |
|
|
|
} |
|
|
|
await Db.Updateable(wares).UpdateColumns(it => new { it.CourseIds }).ExecuteCommandAsync(); |
|
|
|
await Db.Updateable(wares).UpdateColumns(it => new { it.CourseIds }).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
if (entity.Status == Consts.DIC_COURSE_STATUS.RELEASED) |
|
|
|
if (entity.Status == DIC_COURSE_STATUS.RELEASED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var examPaper = await Db.Queryable<Ghre_ExamPaper>().FirstAsync(x => x.LinkId == id && x.LinkType == "CourseId" && x.Status != Consts.DIC_COURSE_STATUS.DISABLED); |
|
|
|
var examPaper = await Db.Queryable<Ghre_ExamPaper>().FirstAsync(x => x.LinkId == id && x.LinkType == "CourseId" && x.Status != DIC_COURSE_STATUS.DISABLED); |
|
|
|
|
|
|
|
if (examPaper is null && entity.CourseSceneId != null) |
|
|
|
|
|
|
|
examPaper = await Db.Queryable<Ghre_ExamPaper>().FirstAsync(x => x.LinkId == entity.CourseSceneId && x.LinkType == "CourseSceneId" && x.Status != DIC_COURSE_STATUS.DISABLED); |
|
|
|
if (examPaper != null) |
|
|
|
if (examPaper != null) |
|
|
|
return ServiceResult.OprateFailed($"课程【{entity.CourseName}({entity.CourseNo})】已与试卷【{examPaper.PaperName}({examPaper.PaperName})】关联,暂不可{(status == Consts.DIC_COURSE_STATUS.DRAFT ? "取消发布" : "停用")}"); |
|
|
|
return ServiceResult.OprateFailed($"课程【{entity.CourseName}({entity.CourseNo})】已与试卷【{examPaper.PaperName}({examPaper.PaperName})】关联,暂不可{(status == DIC_COURSE_STATUS.DRAFT ? "取消发布" : "停用")}"); |
|
|
|
|
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.CourseId == id && x.StudyStatus != Consts.DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH && x.CourseEndTime != null && x.CourseEndTime.Value.Date >= DateTime.Now.Date)) |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed($"课程【{entity.CourseName}({entity.CourseNo})】有学员正在学习中,暂不可{(status == Consts.DIC_COURSE_STATUS.DRAFT ? "取消发布" : "停用")}"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.CourseId == id && x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH && x.CourseEndTime != null && x.CourseEndTime.Value.Date >= DateTime.Now.Date) || await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.CourseId == id && x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH && x.CourseEndTime != null && x.CourseEndTime.Value.Date >= DateTime.Now.Date)) |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed($"课程【{entity.CourseName}({entity.CourseNo})】有学员正在学习中,暂不可{(status == DIC_COURSE_STATUS.DRAFT ? "取消发布" : "停用")}"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (entity.CourseWareId.IsNotEmptyOrNull()) |
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.CourseSceneId == entity.CourseWareId && x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH && x.CourseEndTime != null && x.CourseEndTime.Value.Date >= DateTime.Now.Date) || await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.CourseId == id && x.StudyStatus != DIC_STUDY_RECORD_STUDY_STATUS.HAS_FINISH && x.CourseEndTime != null && x.CourseEndTime.Value.Date >= DateTime.Now.Date)) |
|
|
|
|
|
|
|
return ServiceResult.OprateFailed($"课程【{entity.CourseName}({entity.CourseNo})】有学员正在学习中,暂不可{(status == DIC_COURSE_STATUS.DRAFT ? "取消发布" : "停用")}"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
entity.UpdateIP = ip; |
|
|
|
entity.UpdateIP = ip; |
|
|
|
entity.UpdateProg = api; |
|
|
|
entity.UpdateProg = api; |
|
|
|
if (status == Consts.DIC_COURSE_STATUS.RELEASED || status == Consts.DIC_COURSE_STATUS.DISABLED || status == Consts.DIC_COURSE_STATUS.DRAFT) |
|
|
|
if (status == DIC_COURSE_STATUS.RELEASED || status == DIC_COURSE_STATUS.DISABLED || status == DIC_COURSE_STATUS.DRAFT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
entity.Status = status; |
|
|
|
entity.Status = status; |
|
|
|
entities.Add(entity); |
|
|
|
entities.Add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 生成课程快照 |
|
|
|
#region 生成课程快照 |
|
|
|
if (status == Consts.DIC_COURSE_STATUS.RELEASED) |
|
|
|
if (status == DIC_COURSE_STATUS.RELEASED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CheckCodeExist("Ghre_Course", "CourseNo", entity.CourseNo, ModifyType.Add, "【已发布】中课程编号", id, $"Status='{DIC_COURSE_STATUS.RELEASED}'"); |
|
|
|
CheckCodeExist("Ghre_Course", "CourseNo", entity.CourseNo, ModifyType.Add, "【已发布】中课程编号", id, $"Status='{DIC_COURSE_STATUS.RELEASED}'"); |
|
|
|
var sql = $"UPDATE Ghre_CourseSnap SET IsEnable = 0 WHERE CourseId = '{id}' AND IsEnable = 1"; |
|
|
|
var sql = $"UPDATE Ghre_CourseSnap SET IsEnable = 0 WHERE CourseId = '{id}' AND IsEnable = 1"; |
|
|
@ -393,7 +397,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
entity1.CourseClass1 = string.Join("、", classs.Select(o => o.ClassName + "(" + o.ClassNo + ")")); |
|
|
|
entity1.CourseClass1 = string.Join("、", classs.Select(o => o.ClassName + "(" + o.ClassNo + ")")); |
|
|
|
entity1.CourseId = id; |
|
|
|
entity1.CourseId = id; |
|
|
|
|
|
|
|
|
|
|
|
var examPaper = await Db.Queryable<Ghre_ExamPaper>().FirstAsync(x => x.LinkId == id && x.LinkType == "CourseId" && x.Status != Consts.DIC_COURSE_STATUS.DISABLED); |
|
|
|
var examPaper = await Db.Queryable<Ghre_ExamPaper>().FirstAsync(x => x.LinkId == id && x.LinkType == "CourseId" && x.Status != DIC_COURSE_STATUS.DISABLED); |
|
|
|
await _ghre_CourseSnapServices.Add(entity1); |
|
|
|
await _ghre_CourseSnapServices.Add(entity1); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
@ -405,8 +409,8 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
if (courseScene != null) |
|
|
|
if (courseScene != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var courses = await Db.Queryable<Ghre_Course>() |
|
|
|
var courses = await Db.Queryable<Ghre_Course>() |
|
|
|
.WhereIF(status == Consts.DIC_COURSE_STATUS.RELEASED, x => x.Id == id || (x.CourseSceneId == entity.CourseSceneId && x.Status == Consts.DIC_COURSE_STATUS.RELEASED)) |
|
|
|
.WhereIF(status == DIC_COURSE_STATUS.RELEASED, x => x.Id == id || (x.CourseSceneId == entity.CourseSceneId && x.Status == DIC_COURSE_STATUS.RELEASED)) |
|
|
|
.WhereIF(status != Consts.DIC_COURSE_STATUS.RELEASED, x => x.Id != id || (x.CourseSceneId == entity.CourseSceneId && x.Status == Consts.DIC_COURSE_STATUS.RELEASED)) |
|
|
|
.WhereIF(status != DIC_COURSE_STATUS.RELEASED, x => x.Id != id || (x.CourseSceneId == entity.CourseSceneId && x.Status == DIC_COURSE_STATUS.RELEASED)) |
|
|
|
.ToListAsync(); |
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
courseScene.StandardHour = courses.Sum(x => x.StandardHour); |
|
|
|
courseScene.StandardHour = courses.Sum(x => x.StandardHour); |
|
|
|