BISchoolService.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Azure.Cosmos;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using TEAMModelOS.SDK.DI;
  8. using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
  9. namespace TEAMModelOS.SDK.Models.Service.BI
  10. {
  11. public static class BISchoolService
  12. {
  13. /// <summary>
  14. /// 更新版本信息
  15. /// </summary>
  16. /// <param name="cosmosClient"></param>
  17. /// <param name="server"></param>
  18. /// <param name="id"></param>
  19. /// <returns></returns>
  20. public static async Task UpSchoolEdition(CosmosClient cosmosClient, DingDing _dingDing, List<string> server, string id)
  21. {
  22. try
  23. {
  24. School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(id, new PartitionKey("Base"));
  25. int edition = 0;
  26. if (school.size <= 100 && school.scale == 0)
  27. edition = 1;
  28. else if (school.size >= 300 && school.scale >= 500 && server.Contains("YMPCVCIM"))
  29. edition = 2;
  30. else if (school.size >= 300 && school.scale >= 1000 && server.Contains("YMPCVCIM") && server.Count > 2)
  31. edition = 3;
  32. if (school.edition != null)
  33. {
  34. school.edition.current = edition;
  35. if (school.edition.record < edition)
  36. school.edition.record = edition;
  37. }
  38. else
  39. {
  40. school.edition.current = edition;
  41. school.edition.record = edition;
  42. }
  43. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, id, new PartitionKey("Base"));
  44. BIRelation biRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<BIRelation>(id, new PartitionKey("BIRel"));
  45. biRel.edition = school.edition;
  46. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<BIRelation>(biRel, id, new PartitionKey("BIRel"));
  47. }
  48. catch (Exception ex)
  49. {
  50. _ = _dingDing.SendBotMsg($"BI, UpSchoolEdition() \n{ex.Message}\n{ex.StackTrace}\n", GroupNames.成都开发測試群組);
  51. }
  52. }
  53. }
  54. }