|
@@ -1,4 +1,5 @@
|
|
|
using Azure.Cosmos;
|
|
|
+using DocumentFormat.OpenXml.Drawing;
|
|
|
using DocumentFormat.OpenXml.ExtendedProperties;
|
|
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
@@ -27,7 +28,7 @@ namespace TEAMModelOS.SDK.Services
|
|
|
/// <param name="pid"></param>
|
|
|
/// <param name="newNodes"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async static Task<(List<List<IdCode>> idCodes, HashSet<Syllabus> syllabus)> ImportSyllabus(List<List<string>> nodes,string volumeId,string scope ,string code,string creatorId ,string creatorName, AzureCosmosFactory azureCosmos, bool ignoreCharacter = true) {
|
|
|
+ public async static Task<(List<List<IdCode>> idCodes, List<SyllabusTreeNode> tree)> ImportSyllabus(List<List<string>> nodes,string volumeId,string scope ,string code,string creatorId ,string creatorName, AzureCosmosFactory azureCosmos, bool ignoreCharacter = true) {
|
|
|
HashSet<Syllabus> syllabuses= new HashSet<Syllabus>();
|
|
|
string tbname = scope.Equals("school", StringComparison.OrdinalIgnoreCase) ? Constant.School : Constant.Teacher;
|
|
|
await foreach (var item in azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIterator<Syllabus>(queryText: $"select value(c) from c where c.volumeId='{volumeId}'",
|
|
@@ -134,6 +135,7 @@ namespace TEAMModelOS.SDK.Services
|
|
|
}
|
|
|
}
|
|
|
bool volumeChange=false;
|
|
|
+ List<SyllabusTreeNode> treeNodes = new List<SyllabusTreeNode>();
|
|
|
foreach (var chapter in chapters)
|
|
|
{
|
|
|
if (!volume.syllabusIds.Contains(chapter.id)) {
|
|
@@ -141,11 +143,37 @@ namespace TEAMModelOS.SDK.Services
|
|
|
volumeChange = true;
|
|
|
}
|
|
|
await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).UpsertItemAsync(chapter);
|
|
|
+ List<SyllabusTree> trees = SyllabusService.ListToTree(chapter.children);
|
|
|
+ SyllabusTreeNode tree = new SyllabusTreeNode() { id = chapter.id, scope = chapter.scope, trees = trees, volumeId = chapter.volumeId, auth = chapter.auth, codeval = volume.school };
|
|
|
+ treeNodes.Add(tree);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (volumeChange)
|
|
|
+ {
|
|
|
+ await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync(volume, volume.id, new PartitionKey(volume.code));
|
|
|
+ }
|
|
|
+ List<SyllabusTreeNode> redt = new List<SyllabusTreeNode>();
|
|
|
+ //对课纲树形结构排序
|
|
|
+ if (volume.syllabusIds.IsNotEmpty())
|
|
|
+ {
|
|
|
+
|
|
|
+ volume.syllabusIds.ForEach(x =>
|
|
|
+ {
|
|
|
+ for (int index = 0; index < treeNodes.Count; index++)
|
|
|
+ {
|
|
|
+ if (treeNodes[index].id == x)
|
|
|
+ {
|
|
|
+ redt.Add(treeNodes[index]);
|
|
|
+ treeNodes.RemoveAt(index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ redt.AddRange(treeNodes);
|
|
|
+ return (resNodes, redt);
|
|
|
}
|
|
|
- if (volumeChange) {
|
|
|
- await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync(volume,volume.id,new PartitionKey(volume.code));
|
|
|
+ else {
|
|
|
+ return (resNodes, treeNodes);
|
|
|
}
|
|
|
- return (resNodes,chapters);
|
|
|
}
|
|
|
|
|
|
|