|
@@ -1,8 +1,13 @@
|
|
|
+using Azure.Cosmos;
|
|
|
+using DocumentFormat.OpenXml.Bibliography;
|
|
|
+using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
using TEAMModelOS.SDK.Models;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
@@ -11,6 +16,45 @@ namespace TEAMModelOS.SDK.Services
|
|
|
{
|
|
|
public static class SyllabusService
|
|
|
{
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 根据id查询列表串联id pid的新的关系列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="nodes"></param>
|
|
|
+ /// <param name="pid"></param>
|
|
|
+ /// <param name="newNodes"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async static Task<HashSet<Tnode>> ImportSyllabus(List<List<string>> nodes,string volumeId,string scope ,string code , AzureCosmosFactory azureCosmos) {
|
|
|
+ List<Syllabus> syllabuses= new List<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}'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Syllabus-{code}") })) {
|
|
|
+ syllabuses.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var points in nodes) {
|
|
|
+ int level = 0;
|
|
|
+ Syllabus chapter = null;
|
|
|
+ foreach (var point in points) {
|
|
|
+ string pt = Regex.Replace(point, "[ \\[ \\] \\^ \\-|()【】/' {}_*×――(^)$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", " ");
|
|
|
+ if (level == 0)
|
|
|
+ {
|
|
|
+ var sylbs = syllabuses.SelectMany(z => z.children).Where(c => c.pid.Equals(volumeId) && c.title.Equals(Regex.Replace(point, "[ \\[ \\] \\^ \\-|()【】/' {}_*×――(^)$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", " ")));
|
|
|
+ if (sylbs.Any())
|
|
|
+ {
|
|
|
+ chapter = syllabuses.Find(z=>z.id.Equals(sylbs.First().id));
|
|
|
+ if (chapter == null) { }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 根据id查询列表串联id pid的新的关系列表
|
|
|
/// </summary>
|