FixDataService.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. using Azure;
  2. using Azure.Cosmos;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Text.Json;
  9. using System.Threading.Tasks;
  10. using TEAMModelOS.SDK.DI;
  11. using TEAMModelOS.SDK.Extension;
  12. using TEAMModelOS.SDK;
  13. using HTEXLib.COMM.Helpers;
  14. using TEAMModelOS.SDK.Models.Cosmos.Common;
  15. using System.Dynamic;
  16. using Newtonsoft.Json;
  17. namespace TEAMModelOS.SDK.Models.Service
  18. {
  19. public static class FixDataService
  20. {
  21. /// <summary>
  22. /// 修复学生数据
  23. /// </summary>
  24. /// <param name="client"></param>
  25. /// <param name="_dingDing"></param>
  26. /// <param name="_azureStorage"></param>
  27. /// <param name="data"></param>
  28. /// <returns></returns>
  29. public static async Task<List<Student>> FixStudentInfo(CosmosClient client, DingDing _dingDing, AzureStorageFactory _azureStorage, JsonElement data)
  30. {
  31. var code = data.GetProperty("code").GetString();
  32. var ids = data.GetProperty("ids").ToObject<List<string>>();
  33. var dict = data.GetProperty("dict").ToObject<Dictionary<string, object>>();
  34. string queryText = $"SELECT VALUE c FROM c WHERE c.id IN ({string.Join(",", ids.Select(o => $"'{o}'"))})";
  35. List<Student> students = new List<Student>();
  36. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student")
  37. .GetItemQueryIterator<Student>(
  38. queryText: queryText,
  39. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{code}") }))
  40. {
  41. foreach (var key in dict.Keys)
  42. {
  43. switch (key)
  44. {
  45. case "classId":
  46. item.classId = $"{ dict[key]}";
  47. break;
  48. case "periodId":
  49. item.periodId = $"{ dict[key]}";
  50. break;
  51. case "schoolId":
  52. item.schoolId = $"{ dict[key]}";
  53. break;
  54. case "year":
  55. int year = DateTime.Now.Year;
  56. int.TryParse($"dict[key]", out year);
  57. item.year = year;
  58. break;
  59. default:
  60. break;
  61. }
  62. await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<Student>(item, item.id, new PartitionKey(item.code));
  63. students.Add(item);
  64. }
  65. }
  66. return students;
  67. }
  68. /// <summary>
  69. /// 修复内容模块数据
  70. /// </summary>
  71. /// <param name="client"></param>
  72. /// <param name="_dingDing"></param>
  73. /// <param name="_azureStorage"></param>
  74. /// <param name="data"></param>
  75. /// <returns></returns>
  76. public static async Task FixBlobContent(CosmosClient client, DingDing _dingDing, AzureStorageFactory _azureStorage, JsonElement data)
  77. {
  78. if (data.TryGetProperty("doPrivate", out JsonElement _doPrivate) && $"{_doPrivate}".Equals("yes", StringComparison.OrdinalIgnoreCase))
  79. {
  80. foreach (var cnt in _azureStorage.GetBlobServiceClient().GetBlobContainers())
  81. {
  82. if (cnt.Name.Length == 10 && int.TryParse(cnt.Name, out _))
  83. {
  84. await doFixBlob(client, _azureStorage, cnt.Name, "private");
  85. }
  86. }
  87. }
  88. List<School> schools = new List<School>();
  89. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
  90. {
  91. schools.Add(item);
  92. }
  93. foreach (var school in schools)
  94. {
  95. await doFixBlob(client, _azureStorage, school.id, "school");
  96. }
  97. }
  98. private static async Task doFixBlob(CosmosClient client, AzureStorageFactory _azureStorage, string name, string scope)
  99. {
  100. List<string> prefixs = new List<string>() { "audio", "doc", "image", "other", "res", "video" };
  101. var ContainerClient = _azureStorage.GetBlobContainerClient($"{name}");
  102. var tb = "Teacher";
  103. if (scope != "private")
  104. {
  105. tb = "School";
  106. }
  107. List<string> ids = new List<string>();
  108. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, tb).GetItemQueryIterator<Bloblog>(queryDefinition: new QueryDefinition("select c.id from c "), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Bloblog-{name}") }))
  109. {
  110. ids.Add(item.id);
  111. }
  112. await client.GetContainer(Constant.TEAMModelOS, tb).DeleteItemsStreamAsync(ids, $"Bloblog-{name}");
  113. long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
  114. foreach (var prefix in prefixs)
  115. {
  116. if (prefix.Equals("res"))
  117. {
  118. List<string> itemres = await ContainerClient.List(prefix);
  119. if (itemres.IsNotEmpty())
  120. {
  121. HashSet<string> set = new HashSet<string>();
  122. itemres.ForEach(x =>
  123. {
  124. var uri = x.Split("/");
  125. set.Add($"res/{uri[1]}");
  126. });
  127. foreach (var item in set)
  128. {
  129. var urlsSize = await ContainerClient.GetBlobsSize(item);
  130. var url = item;
  131. if (!item.EndsWith(".hte", StringComparison.OrdinalIgnoreCase) && !item.EndsWith(".HTEX", StringComparison.OrdinalIgnoreCase))
  132. {
  133. url += ".HTEX";
  134. }
  135. Bloblog bloblog = new Bloblog { id = Guid.NewGuid().ToString(), code = $"Bloblog-{name}", pk = "Bloblog", time = now, url = url, size = urlsSize != null && urlsSize.HasValue ? urlsSize.Value : 0, type = prefix };
  136. await client.GetContainer(Constant.TEAMModelOS, tb).UpsertItemAsync(bloblog, new Azure.Cosmos.PartitionKey(bloblog.code));
  137. }
  138. }
  139. }
  140. else
  141. {
  142. List<string> items = await ContainerClient.List(prefix);
  143. if (items.IsNotEmpty())
  144. {
  145. foreach (var item in items)
  146. {
  147. var urlsSize = await ContainerClient.GetBlobsSize(item);
  148. Bloblog bloblog = new Bloblog { id = Guid.NewGuid().ToString(), code = $"Bloblog-{name}", pk = "Bloblog", time = now, url = item, size = urlsSize != null && urlsSize.HasValue ? urlsSize.Value : 0, type = prefix };
  149. await client.GetContainer(Constant.TEAMModelOS, tb).UpsertItemAsync(bloblog, new Azure.Cosmos.PartitionKey(bloblog.code));
  150. }
  151. }
  152. }
  153. }
  154. }
  155. /// <summary>
  156. /// 修復學校基本資料
  157. /// </summary>
  158. /// <param name="client"></param>
  159. /// <param name="schoolCode"></param>
  160. /// <returns></returns>
  161. public static async Task<List<string>> FixSchoolPeriodId(CosmosClient client, string schoolCode)
  162. {
  163. List<string> periodIdList = new List<string>();
  164. await foreach (School schinfo in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: $"SELECT value(c) FROM c WHERE c.id = '{schoolCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  165. {
  166. int periodIndex = 0;
  167. foreach (Period periodNow in schinfo.period)
  168. {
  169. if (periodNow.id.Equals("上學期") || periodNow.id.Equals("上学期") || periodNow.id.Equals("First semester"))
  170. {
  171. string periodId = Guid.NewGuid().ToString();
  172. schinfo.period[periodIndex].id = periodId;
  173. periodIdList.Add(periodId);
  174. }
  175. periodIndex++;
  176. }
  177. await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(schinfo, schinfo.id, new PartitionKey("Base"));
  178. }
  179. return periodIdList;
  180. }
  181. /// <summary>
  182. /// 修復學校班級資料
  183. /// </summary>
  184. /// <param name="client"></param>
  185. /// <param name="schoolCode"></param>
  186. /// <param name="dataDic"></param>
  187. /// <returns></returns>
  188. public static async Task<List<string>> FixClassInfo(CosmosClient client, string schoolCode, Dictionary<string,string> dataDic)
  189. {
  190. List<string> classIdList = new List<string>();
  191. await foreach (Class classinfo in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Class>(queryText: $"SELECT value(c) FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolCode}") }))
  192. {
  193. foreach (KeyValuePair<string, string> item in dataDic)
  194. {
  195. switch (item.Key)
  196. {
  197. case "periodId":
  198. classinfo.periodId = item.Value;
  199. break;
  200. }
  201. }
  202. await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Class>(classinfo, classinfo.id, new PartitionKey($"Class-{schoolCode}"));
  203. classIdList.Add(classinfo.id);
  204. }
  205. return classIdList;
  206. }
  207. /// <summary>
  208. /// 修復學校課程資料
  209. /// </summary>
  210. /// <param name="client"></param>
  211. /// <param name="schoolCode"></param>
  212. /// <param name="dataDic"></param>
  213. /// <returns></returns>
  214. public static async Task<List<string>> FixCourseInfo(CosmosClient client, string schoolCode, Dictionary<string, string> dataDic)
  215. {
  216. List<string> courseIdList = new List<string>();
  217. await foreach (Course courseinfo in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: $"SELECT value(c) FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolCode}") }))
  218. {
  219. foreach (KeyValuePair<string, string> item in dataDic)
  220. {
  221. switch (item.Key)
  222. {
  223. case "periodId":
  224. courseinfo.period.id = item.Value;
  225. break;
  226. }
  227. }
  228. await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Course>(courseinfo, courseinfo.id, new PartitionKey($"Course-{schoolCode}"));
  229. courseIdList.Add(courseinfo.id);
  230. }
  231. return courseIdList;
  232. }
  233. /// <summary>
  234. /// 修復學校知識點資料
  235. /// </summary>
  236. /// <param name="client"></param>
  237. /// <param name="schoolCode"></param>
  238. /// <param name="dataDic"></param>
  239. /// <returns></returns>
  240. public static async Task<List<string>> FixKnowledgeInfo(CosmosClient client, string schoolCode, Dictionary<string, string> dataDic)
  241. {
  242. List<string> knowledgeIdList = new List<string>();
  243. await foreach (Knowledge knowledgeinfo in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Knowledge>(queryText: $"SELECT value(c) FROM c WHERE c.pk = 'Knowledge' AND c.owner = '{schoolCode}'", requestOptions: new QueryRequestOptions() {}))
  244. {
  245. foreach (KeyValuePair<string, string> item in dataDic)
  246. {
  247. switch (item.Key)
  248. {
  249. case "periodId":
  250. knowledgeinfo.periodId = item.Value;
  251. break;
  252. }
  253. }
  254. await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Knowledge>(knowledgeinfo, knowledgeinfo.id, new PartitionKey($"{knowledgeinfo.code}"));
  255. knowledgeIdList.Add(knowledgeinfo.id);
  256. }
  257. return knowledgeIdList;
  258. }
  259. /// <summary>
  260. /// 修復學校試卷資料
  261. /// </summary>
  262. /// <param name="client"></param>
  263. /// <param name="schoolCode"></param>
  264. /// <param name="dataDic"></param>
  265. /// <returns></returns>
  266. public static async Task<List<string>> FixPaperInfo(CosmosClient client, string schoolCode, Dictionary<string, string> dataDic)
  267. {
  268. List<string> paperIdList = new List<string>();
  269. await foreach (Paper paperinfo in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Paper>(queryText: $"SELECT value(c) FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{schoolCode}") }))
  270. {
  271. foreach (KeyValuePair<string, string> item in dataDic)
  272. {
  273. switch (item.Key)
  274. {
  275. case "periodId":
  276. paperinfo.periodId = item.Value;
  277. break;
  278. }
  279. }
  280. await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Paper>(paperinfo, paperinfo.id, new PartitionKey($"Paper-{schoolCode}"));
  281. paperIdList.Add(paperinfo.id);
  282. }
  283. return paperIdList;
  284. }
  285. /// <summary>
  286. /// 修復學校課綱資料
  287. /// </summary>
  288. /// <param name="client"></param>
  289. /// <param name="schoolCode"></param>
  290. /// <param name="dataDic"></param>
  291. /// <returns></returns>
  292. public static async Task<List<string>> FixVolumeInfo(CosmosClient client, string schoolCode, Dictionary<string, string> dataDic)
  293. {
  294. List<string> volumeIdList = new List<string>();
  295. await foreach (Volume volumeinfo in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Volume>(queryText: $"SELECT value(c) FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Volume-{schoolCode}") }))
  296. {
  297. foreach (KeyValuePair<string, string> item in dataDic)
  298. {
  299. switch (item.Key)
  300. {
  301. case "periodId":
  302. volumeinfo.periodId = item.Value;
  303. break;
  304. }
  305. }
  306. await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Volume>(volumeinfo, volumeinfo.id, new PartitionKey($"Volume-{schoolCode}"));
  307. volumeIdList.Add(volumeinfo.id);
  308. }
  309. return volumeIdList;
  310. }
  311. /// <summary>
  312. /// 修復學校試題資料
  313. /// </summary>
  314. /// <param name="client"></param>
  315. /// <param name="schoolCode"></param>
  316. /// <param name="dataDic"></param>
  317. /// <returns></returns>
  318. public static async Task<List<string>> FixItemInfo(CosmosClient client, string schoolCode, Dictionary<string, string> dataDic)
  319. {
  320. List<string> itemIdList = new List<string>();
  321. await foreach (ItemInfo iteminfo in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemInfo>(queryText: $"SELECT value(c) FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{schoolCode}") }))
  322. {
  323. foreach (KeyValuePair<string, string> item in dataDic)
  324. {
  325. switch (item.Key)
  326. {
  327. case "periodId":
  328. iteminfo.periodId = item.Value;
  329. break;
  330. }
  331. }
  332. await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<ItemInfo>(iteminfo, iteminfo.id, new PartitionKey($"Item-{schoolCode}"));
  333. itemIdList.Add(iteminfo.id);
  334. }
  335. return itemIdList;
  336. }
  337. /// <summary>
  338. /// 修復學校評測資料
  339. /// </summary>
  340. /// <param name="client"></param>
  341. /// <param name="schoolCode"></param>
  342. /// <param name="dataDic"></param>
  343. /// <returns></returns>
  344. public static async Task<List<string>> FixExamInfo(CosmosClient client, string schoolCode, Dictionary<string, string> dataDic)
  345. {
  346. List<string> examIdList = new List<string>();
  347. await foreach (ExamInfo examinfo in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: $"SELECT value(c) FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{schoolCode}") }))
  348. {
  349. foreach (KeyValuePair<string, string> item in dataDic)
  350. {
  351. switch (item.Key)
  352. {
  353. case "periodId":
  354. examinfo.period.id = item.Value;
  355. break;
  356. }
  357. }
  358. await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(examinfo, examinfo.id, new PartitionKey($"Exam-{schoolCode}"));
  359. examIdList.Add(examinfo.id);
  360. }
  361. return examIdList;
  362. }
  363. /// <summary>
  364. /// 修復學生資料
  365. /// </summary>
  366. /// <param name="client"></param>
  367. /// <param name="schoolCode"></param>
  368. /// <param name="dataDic"></param>
  369. /// <returns></returns>
  370. public static async Task<List<string>> FixStudentInfo(CosmosClient client, string schoolCode, Dictionary<string, string> dataDic)
  371. {
  372. List<string> studentIdList = new List<string>();
  373. await foreach (Student studentinfo in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"SELECT value(c) FROM c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolCode}") }))
  374. {
  375. foreach (KeyValuePair<string, string> item in dataDic)
  376. {
  377. switch (item.Key)
  378. {
  379. case "periodId":
  380. studentinfo.periodId = item.Value;
  381. break;
  382. }
  383. }
  384. await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<Student>(studentinfo, studentinfo.id, new PartitionKey($"Base-{schoolCode}"));
  385. studentIdList.Add(studentinfo.id);
  386. }
  387. return studentIdList;
  388. }
  389. /// <summary>
  390. /// 修復评测内容
  391. /// </summary>
  392. /// <param name="client"></param>
  393. /// <param name="data"></param>
  394. /// <returns></returns>
  395. public static async Task<List<string>> FixExamPublish(CosmosClient client, JsonElement data)
  396. {
  397. List<string> infos = new List<string>();
  398. var dict = data.GetProperty("publish").GetInt32();
  399. //List<(string id, string code)> ps = new List<(string id, string code)>();
  400. List<object> exams = new List<object>();
  401. List<Task<ItemResponse<ExamInfo>>> tasks = new List<Task<ItemResponse<ExamInfo>>>();
  402. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"SELECT value(c) FROM c where c.pk = 'Exam'"))
  403. {
  404. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  405. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  406. {
  407. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  408. {
  409. if (obj.TryGetProperty("publish", out JsonElement publish)) {
  410. try {
  411. if (!string.IsNullOrEmpty(publish.GetString()) && publish.GetString().Equals("0"))
  412. {
  413. ExamInfo examInfo = new ExamInfo
  414. {
  415. id = obj.GetProperty("id").GetString(),
  416. owner = obj.TryGetProperty("owner", out JsonElement owner) ? owner.GetString() : "",
  417. //examInfo.owner = obj.GetProperty("owner").GetString();
  418. name = obj.GetProperty("name").GetString(),
  419. school = obj.GetProperty("school").GetString(),
  420. creatorId = obj.GetProperty("creatorId").GetString(),
  421. stuCount = obj.TryGetProperty("stuCount", out JsonElement stuCount) ? stuCount.GetInt32() : 0,
  422. createTime = obj.GetProperty("createTime").GetInt64(),
  423. updateTime = obj.TryGetProperty("updateTime", out JsonElement updateTime) ? updateTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  424. startTime = obj.GetProperty("startTime").GetInt64(),
  425. endTime = obj.GetProperty("endTime").GetInt64(),
  426. year = obj.TryGetProperty("year", out JsonElement year) ? year.GetInt32() : 0,
  427. source = obj.TryGetProperty("source", out JsonElement source) ? source.GetString() : "0",
  428. classes = obj.TryGetProperty("classes", out JsonElement classes) ? classes.ToObject<List<string>>() : new List<string>(),
  429. stuLists = obj.TryGetProperty("stuLists", out JsonElement stuLists) ? stuLists.ToObject<List<string>>() : new List<string>(),
  430. //examInfo.stuLists = obj.GetProperty("stuLists").ToObject<List<string>>();
  431. papers = obj.TryGetProperty("papers", out JsonElement papers) ? papers.ToObject<List<PaperSimple>>() : new List<PaperSimple>(),
  432. type = obj.TryGetProperty("type", out JsonElement type)? type.GetString(): "",
  433. period = obj.TryGetProperty("period", out JsonElement period)? period.ToObject<PeriodSimple>() : new PeriodSimple(),
  434. grades = obj.TryGetProperty("grades", out JsonElement grades)? grades.ToObject<List<Grade>>(): new List<Grade>(),
  435. subjects = obj.GetProperty("subjects").ToObject<List<ExamSubject>>(),
  436. progress = obj.TryGetProperty("progress", out JsonElement progress) ? progress.GetString() : "finish",
  437. scope = obj.TryGetProperty("scope", out JsonElement scope) ? scope.GetString() : "school",
  438. examType = obj.TryGetProperty("examType", out JsonElement examType) ? examType.ToObject<Custom>() : new Custom(),
  439. status = obj.TryGetProperty("status", out JsonElement status) ? status.GetInt32() : 0,
  440. average = obj.TryGetProperty("average", out JsonElement average) ? average.GetDouble() : 0,
  441. sRate = obj.TryGetProperty("sRate", out JsonElement sRate) ? sRate.GetDouble() : 0,
  442. lostStu = obj.TryGetProperty("lostStu", out JsonElement lostStu) ? lostStu.ToObject<List<string>>() : new List<string>(),
  443. standard = obj.TryGetProperty("standard", out JsonElement standard) ? standard.GetDouble() : 0,
  444. size = obj.TryGetProperty("size", out JsonElement size) ? standard.GetInt64() : 0,
  445. income = obj.TryGetProperty("income", out JsonElement income) ? income.GetInt32() : 0,
  446. touch = obj.TryGetProperty("touch", out JsonElement touch) ? touch.GetInt32() : 0,
  447. publish = 0,
  448. groupLists = obj.TryGetProperty("groupLists", out JsonElement groupLists) ? groupLists.ToObject<List<Dictionary<string, List<string>>>>() : new List<Dictionary<string, List<string>>>(),
  449. targets = obj.TryGetProperty("targets", out JsonElement targets) ? targets.ToObject<List<JsonElement>>() : new List<JsonElement>()
  450. };
  451. tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new PartitionKey(examInfo.code)));
  452. infos.Add(examInfo.id);
  453. };
  454. } catch (Exception e) {
  455. var aa = obj.GetProperty("id").GetString() ;
  456. }
  457. }
  458. }
  459. }
  460. await Task.WhenAll(tasks);
  461. /* info.publish = dict;
  462. await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
  463. infos.Add(info.id);*/
  464. }
  465. /*foreach (var item in exams) {
  466. dynamic dyn = JsonConvert.DeserializeObject(Convert.ToString(item)) ;
  467. foreach (var obj in dyn)
  468. {
  469. if (obj.Name == "publish")
  470. {
  471. obj.Value = 0;
  472. break;
  473. }
  474. }
  475. ExamInfo info = new ExamInfo();
  476. try {
  477. string dy = JsonConvert.SerializeObject(dyn);
  478. info = JsonConvert.DeserializeObject<ExamInfo>(dy);
  479. } catch (Exception e ) {
  480. //string dy = JsonConvert.SerializeObject(dyn);
  481. }
  482. //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(dyn, dyn.id, new PartitionKey(dyn.code));
  483. infos.Add(info.id);
  484. }*/
  485. return infos;
  486. }
  487. }
  488. }