123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using 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.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, List<object> server, string id)
- {
- School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(id, new PartitionKey("Base"));
- int edition = 0;
- if (school.size <= 100 && school.scale == 0)
- edition = 1;
- else if (school.size >= 300 && school.scale >= 500 && server.Contains("YMPCVCIM"))
- edition = 2;
- else if (school.size >= 300 && school.scale >= 1000 && server.Contains("YMPCVCIM") && server.Count > 2)
- edition = 3;
- if (school.edition != null)
- {
- school.edition.current = edition;
- if (school.edition.record < edition)
- school.edition.record = edition;
- }
- else
- {
- school.edition.current = edition;
- school.edition.record = edition;
- }
- 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"));
- }
- }
- }
|