1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using Microsoft.Azure.Cosmos;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.Models.Cosmos;
- using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
- namespace TEAMModelOS.SDK.Models.Service.BI
- {
- public static class BISchoolService
- {
- /// <summary>
- /// 更新版本信息
- /// </summary>
- /// <param name="cosmosClient"></param>
- /// <param name="server"></param>
- /// <param name="id"></param>
- /// <returns></returns>
- public static async Task UpSchoolEdition(CosmosClient cosmosClient, DingDing _dingDing, List<string> services, string id)
- {
- try
- {
- School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(id, new PartitionKey("Base"));
- school.edition = calSchoolEdition(school, services);
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, id, new PartitionKey("Base"));
- BIRelation biRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<BIRelation>(id, new PartitionKey("BIRel"));
- biRel.edition = school.edition;
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<BIRelation>(biRel, id, new PartitionKey("BIRel"));
- }
- catch (Exception ex)
- {
- _ = _dingDing.SendBotMsg($"BI,{Environment.GetEnvironmentVariable("Option:Location")},UpSchoolEdition() 服务列表:{services},学校id:{id}\n{ex.Message}\n{ex.StackTrace}\n", GroupNames.成都开发測試群組);
- }
- }
- /// <summary>
- /// 計算學校版本公式 ※計算邏輯變更:廢止原size+scale判斷邏輯
- /// </summary>
- public static Edition calSchoolEdition(School school, List<string> services)
- {
- int edition = 1;
- bool adminFlg = (services.Contains("IPDYZYLC")) ? true : false;
- bool analFlg = (services.Contains("YMPCVCIM")) ? true : false;
- bool fiveFlg = (services.Contains("YPXSJ6NJ")) ? true : false;
- if (adminFlg && analFlg && fiveFlg) edition = 3;
- else if (adminFlg && analFlg) edition = 2;
- else edition = 1;
- if (school.edition != null)
- {
- school.edition.current = edition;
- if (school.edition.record < edition)
- {
- school.edition.record = edition;
- }
- }
- else
- {
- Edition tempEdition = new()
- {
- current = edition,
- record = edition
- };
- school.edition = tempEdition;
- }
- return school.edition;
- }
- }
- }
|