|
|
@ -40,6 +40,18 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course |
|
|
|
x.RelativePath = x.RelativePath.Replace("/Advanced", null); |
|
|
|
x.RelativePath = x.RelativePath.Replace("/Advanced", null); |
|
|
|
}); |
|
|
|
}); |
|
|
|
await _ghre_CourseWareAttachmentServices.Add(entity.Attachments); |
|
|
|
await _ghre_CourseWareAttachmentServices.Add(entity.Attachments); |
|
|
|
|
|
|
|
if (entity.Links != null && entity.Links.Any()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var attachments = entity.Links.Select(x => new InsertGhre_CourseWareAttachmentInput() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CourseWareId = result, |
|
|
|
|
|
|
|
AttachmentName = x.LinkName, |
|
|
|
|
|
|
|
RelativePath = x.LinkAddress, |
|
|
|
|
|
|
|
AttachFileExtension = "http" |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
await _ghre_CourseWareAttachmentServices.Add(attachments); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -69,7 +81,17 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course |
|
|
|
}); |
|
|
|
}); |
|
|
|
await _ghre_CourseWareAttachmentServices.Add(editModel.Attachments); |
|
|
|
await _ghre_CourseWareAttachmentServices.Add(editModel.Attachments); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (editModel.Links != null && editModel.Links.Any()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var attachments = editModel.Links.Select(x => new InsertGhre_CourseWareAttachmentInput() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CourseWareId = Id, |
|
|
|
|
|
|
|
AttachmentName = x.LinkName, |
|
|
|
|
|
|
|
RelativePath = x.LinkAddress, |
|
|
|
|
|
|
|
AttachFileExtension = "http" |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
await _ghre_CourseWareAttachmentServices.Add(attachments); |
|
|
|
|
|
|
|
} |
|
|
|
return await base.Update(Id, editModel); |
|
|
|
return await base.Update(Id, editModel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -77,22 +99,23 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course |
|
|
|
{ |
|
|
|
{ |
|
|
|
var result = await base.QueryForm(body); |
|
|
|
var result = await base.QueryForm(body); |
|
|
|
string courseIds = result.result.DT_TableDataT1[0].CourseIds; |
|
|
|
string courseIds = result.result.DT_TableDataT1[0].CourseIds; |
|
|
|
if (!string.IsNullOrWhiteSpace(courseIds)) |
|
|
|
if (courseIds.IsNotEmptyOrNull()) |
|
|
|
{ |
|
|
|
|
|
|
|
result.result.DT_TableDataT1[0].CourseIds2 = JsonConvert.DeserializeObject<List<long>>(courseIds); |
|
|
|
result.result.DT_TableDataT1[0].CourseIds2 = JsonConvert.DeserializeObject<List<long>>(courseIds); |
|
|
|
if (result.result.DT_TableDataT1[0].CourseIds2.Any()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else result.result.DT_TableDataT1[0].CourseIds2 = new List<long>(); |
|
|
|
else result.result.DT_TableDataT1[0].CourseIds2 = new List<long>(); |
|
|
|
|
|
|
|
|
|
|
|
result.result.DT_TableDataT1[0].Attachments = await _ghre_CourseWareAttachmentServices.Query(x => x.CourseWareId == body.id); |
|
|
|
var attachments = await _ghre_CourseWareAttachmentServices.Query(x => x.CourseWareId == body.id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.result.DT_TableDataT1[0].Attachments = attachments.Where(x => x.AttachFileExtension != "http").ToList(); |
|
|
|
if (result.result.DT_TableDataT1[0].Attachments.Any()) |
|
|
|
if (result.result.DT_TableDataT1[0].Attachments.Any()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
result.result.DT_TableDataT1[0].Attachments.ForEach(x => x.RelativePath = "/Advanced" + x.RelativePath); |
|
|
|
result.result.DT_TableDataT1[0].Attachments.ForEach(x => x.RelativePath = "/Advanced" + x.RelativePath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
result.result.DT_TableDataT1[0].Links = attachments.Where(x => x.AttachFileExtension == "http").Select(x => new Ghre_CourseWareLink() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LinkName = x.AttachmentName, |
|
|
|
|
|
|
|
LinkAddress = x.RelativePath, |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var IDS = result.result.DT_TableDataT1[0].CourseIds2; |
|
|
|
var IDS = result.result.DT_TableDataT1[0].CourseIds2; |
|
|
|
result.result.DT_TableDataT1[0].Courses = await _ghre_CourseServices.Query(x => IDS.Contains(x.Id)); |
|
|
|
result.result.DT_TableDataT1[0].Courses = await _ghre_CourseServices.Query(x => IDS.Contains(x.Id)); |
|
|
|
|
|
|
|
|
|
|
@ -101,48 +124,6 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course |
|
|
|
result.result.DT_TableDataT1[0].CourseWareNo = null; |
|
|
|
result.result.DT_TableDataT1[0].CourseWareNo = null; |
|
|
|
result.result.DT_TableDataT1[0].CourseWareName = null; |
|
|
|
result.result.DT_TableDataT1[0].CourseWareName = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// string sql = "SELECT Id,QuestionId from Ghre_QuestionAnswer where AnswerContent='单选题'"; |
|
|
|
|
|
|
|
// var questionAnswers = await Db.Ado.SqlQueryAsync<Ghre_QuestionAnswer>(sql); |
|
|
|
|
|
|
|
// for (int i = 0; i < questionAnswers.Count; i++) |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// await Db.Deleteable(new Ghre_QuestionAnswer() { Id = questionAnswers[i].Id }).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
// sql = $@"UPDATE A |
|
|
|
|
|
|
|
//SET A.TaxisNo = B.NUM |
|
|
|
|
|
|
|
//FROM Ghre_QuestionAnswer A |
|
|
|
|
|
|
|
// JOIN |
|
|
|
|
|
|
|
// (SELECT ID, NUM * 100 NUM |
|
|
|
|
|
|
|
// FROM (SELECT *, ROW_NUMBER () OVER (ORDER BY TaxisNo) NUM |
|
|
|
|
|
|
|
// FROM (SELECT * |
|
|
|
|
|
|
|
// FROM (SELECT * |
|
|
|
|
|
|
|
// FROM Ghre_QuestionAnswer |
|
|
|
|
|
|
|
// WHERE QuestionId = '{questionAnswers[i].QuestionId}') A) B) C) B |
|
|
|
|
|
|
|
// ON A.ID = b.ID; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//UPDATE Ghre_QuestionAnswer |
|
|
|
|
|
|
|
//SET QuestionNo = |
|
|
|
|
|
|
|
// CASE TaxisNo |
|
|
|
|
|
|
|
// WHEN 100 THEN 'A' |
|
|
|
|
|
|
|
// WHEN 200 THEN 'B' |
|
|
|
|
|
|
|
// WHEN 300 THEN 'C' |
|
|
|
|
|
|
|
// WHEN 400 THEN 'D' |
|
|
|
|
|
|
|
// WHEN 500 THEN 'E' |
|
|
|
|
|
|
|
// WHEN 600 THEN 'F' |
|
|
|
|
|
|
|
// WHEN 700 THEN 'G' |
|
|
|
|
|
|
|
// WHEN 800 THEN 'H' |
|
|
|
|
|
|
|
// WHEN 900 THEN 'I' |
|
|
|
|
|
|
|
// WHEN 1000 THEN 'J' |
|
|
|
|
|
|
|
// WHEN 1100 THEN 'K' |
|
|
|
|
|
|
|
// WHEN 1200 THEN 'L' |
|
|
|
|
|
|
|
// END |
|
|
|
|
|
|
|
//WHERE QuestionId = '{questionAnswers[i].QuestionId}'"; |
|
|
|
|
|
|
|
// await Db.Ado.SqlQueryAsync<Ghre_QuestionAnswer>(sql); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -177,7 +158,7 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course |
|
|
|
string sql = @$"SELECT DISTINCT B.Id
|
|
|
|
string sql = @$"SELECT DISTINCT B.Id
|
|
|
|
FROM Ghre_CourseWareAttachment A |
|
|
|
FROM Ghre_CourseWareAttachment A |
|
|
|
JOIN Ghre_CourseWare B ON A.CourseWareId = B.Id AND B.IsEnable = 1 |
|
|
|
JOIN Ghre_CourseWare B ON A.CourseWareId = B.Id AND B.IsEnable = 1 |
|
|
|
WHERE A.IsEnable = 1 AND A.IsAllowDownload = '{IsAllowDownload}'";
|
|
|
|
WHERE A.IsEnable = 1 AND A.AttachFileExtension != 'http' AND A.IsAllowDownload = '{IsAllowDownload}'";
|
|
|
|
var entitys = await Db.Ado.SqlQueryAsync<long>(sql); |
|
|
|
var entitys = await Db.Ado.SqlQueryAsync<long>(sql); |
|
|
|
if (entitys.Any()) |
|
|
|
if (entitys.Any()) |
|
|
|
condition = "Id IN (" + string.Join(",", entitys.Select(x => x)) + ")"; |
|
|
|
condition = "Id IN (" + string.Join(",", entitys.Select(x => x)) + ")"; |
|
|
@ -198,29 +179,35 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course |
|
|
|
|
|
|
|
|
|
|
|
x.StudyDuration = $"{x.Hours}小时{x.Minutes}分钟"; |
|
|
|
x.StudyDuration = $"{x.Hours}小时{x.Minutes}分钟"; |
|
|
|
x.SourceLabel = await GetParaLabel("CourseWareSource", x.Source); |
|
|
|
x.SourceLabel = await GetParaLabel("CourseWareSource", x.Source); |
|
|
|
x.Attachments = attachments.Where(a => a.CourseWareId == x.Id).ToList(); |
|
|
|
x.Attachments = attachments.Where(a => a.CourseWareId == x.Id && a.AttachFileExtension != "http").ToList(); |
|
|
|
|
|
|
|
x.Links = attachments.Where(x => x.AttachFileExtension == "http") |
|
|
|
|
|
|
|
.Select(x => new Ghre_CourseWareLink() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LinkName = x.AttachmentName, |
|
|
|
|
|
|
|
LinkAddress = x.RelativePath, |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
courseIds = courseIds.Distinct().ToList(); |
|
|
|
courseIds = courseIds.Distinct().ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var courses = await _ghre_CourseServices.Query(x => courseIds.Contains(x.Id)); |
|
|
|
var courses = await _ghre_CourseServices.Query(x => courseIds.Contains(x.Id)); |
|
|
|
|
|
|
|
|
|
|
|
data.ForEach(x => |
|
|
|
data.ForEach(x => |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!string.IsNullOrWhiteSpace(x.CourseIds)) |
|
|
|
if (!string.IsNullOrWhiteSpace(x.CourseIds)) |
|
|
|
x.CourseNames = string.Join("、", courses.Where(o => x.CourseIds2.Contains(o.Id)).Select(o => o.CourseNo + " " + o.CourseName)); |
|
|
|
x.CourseNames = string.Join("、", courses.Where(o => x.CourseIds2.Contains(o.Id)).Select(o => o.CourseNo + " " + o.CourseName)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
result.result.DT_TableDataT1 = data; |
|
|
|
result.result.DT_TableDataT1 = data; |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 打包下载 |
|
|
|
public async Task<ServiceResult<string>> DownZip(long id) |
|
|
|
public async Task<ServiceResult<string>> DownZip(long id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var result = await base.QueryById(id); |
|
|
|
var result = await base.QueryById(id); |
|
|
|
if (result is null) |
|
|
|
if (result is null) |
|
|
|
return ServiceResult<string>.OprateFailed("无效的课件ID!"); |
|
|
|
return ServiceResult<string>.OprateFailed("无效的课件ID!"); |
|
|
|
var attachments = await _ghre_CourseWareAttachmentServices.Query(x => x.CourseWareId == id); |
|
|
|
var attachments = await _ghre_CourseWareAttachmentServices.Query(x => x.CourseWareId == id && x.AttachFileExtension != "http"); |
|
|
|
var webRootPath = _hostingEnvironment.WebRootPath; |
|
|
|
var webRootPath = _hostingEnvironment.WebRootPath; |
|
|
|
var outPath = $"/files/upload/{result.CourseWareName}_{result.VersionNo}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip"; |
|
|
|
var outPath = $"/files/upload/{result.CourseWareName}_{result.VersionNo}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip"; |
|
|
|
if (attachments.Any()) |
|
|
|
if (attachments.Any()) |
|
|
@ -268,6 +255,7 @@ public class Ghre_CourseWareServices : BaseServices<Ghre_CourseWare, Ghre_Course |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region 删除 |
|
|
|
#region 删除 |
|
|
|
// <summary> |
|
|
|
// <summary> |
|
|
|