|
@@ -1,5 +1,4 @@
|
|
|
-using Azure.Cosmos;
|
|
|
-using HTEXLib.COMM.Helpers;
|
|
|
+using Microsoft.Azure.Cosmos;
|
|
|
using MathNet.Numerics.LinearAlgebra.Double;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
@@ -107,9 +106,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
sqltxt.Append($" WHERE c.pk='School' and (c.areaId = '' or c.areaId = null or IS_DEFINED(c.areaId) = false)");
|
|
|
|
|
|
List<NotAreaSchool> tempNotAreaSchools = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -137,7 +136,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
if (iscontinuation)
|
|
|
{
|
|
|
- continuationToken = item.GetContinuationToken();
|
|
|
+ continuationToken = item.ContinuationToken;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -187,9 +186,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
List<NotAreaSchool> notAreaSchools = new();
|
|
|
foreach (string pk in partitionKeys)
|
|
|
{
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -276,9 +275,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
//}
|
|
|
|
|
|
var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_areaId}", new PartitionKey("AreaSetting"));
|
|
|
- if (responseSet.Status == 200)
|
|
|
+ if (responseSet.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
|
|
|
+ using var fileJson = await JsonDocument.ParseAsync(responseSet.Content);
|
|
|
AreaSetting delSet = fileJson.ToObject<AreaSetting>();
|
|
|
if (!string.IsNullOrEmpty(delSet.accessConfig))
|
|
|
return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
|
|
@@ -309,7 +308,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
msg.Append($"{school.name}【{school.id}】学校移除多区域的名单:");
|
|
|
List<Teacher> teachers = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{school.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(queryText: $"SELECT value(c) FROM c join s in c.schools where s.schoolId ='{school.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
teachers.Add(item);
|
|
|
}
|
|
@@ -369,7 +368,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
AssistSchool schoolAssists = new(); //返回学校列表集合
|
|
|
string sqlTxt = $"select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard,c.period,c.campuses from c where c.id='{schoolId}'";
|
|
|
- await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
schoolAssists = itemSchool;
|
|
|
}
|
|
@@ -377,9 +376,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (schoolAssists.id != null)
|
|
|
{
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolAssists.id, new PartitionKey("ProductSum"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
|
|
|
{
|
|
|
schoolAssists.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
@@ -402,7 +401,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
//無實體學校 => 取得虛擬學校
|
|
|
else
|
|
|
{
|
|
|
- await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
|
|
|
+ await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<AssistSchool>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("VirtualBase") }))
|
|
|
{
|
|
|
schoolAssists = itemSchool;
|
|
|
}
|
|
@@ -443,11 +442,11 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
string _auth = HttpContext.GetXAuth("AuthToken");
|
|
|
var (tmdId, tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(_auth, _option);
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey($"Base"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{school.id}'";
|
|
|
List<Teacher> teachers = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
teachers.Add(item);
|
|
|
}
|
|
@@ -500,16 +499,16 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
|
School school = new();
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(sid, new PartitionKey("Base"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
school = json.ToObject<School>();
|
|
|
}
|
|
|
|
|
|
long teach = 0;
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{sid}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{sid}") }))
|
|
|
{
|
|
|
- var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
{
|
|
|
if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
|
|
@@ -720,7 +719,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
// cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
|
|
|
List<BaseInfo> scManages = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<BaseInfo>(queryText: $"select c.id,c.name,c.picture from c where ARRAY_CONTAINS(c.roles,'admin',true) and c.code='Teacher-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<BaseInfo>(queryText: $"select c.id,c.name,c.picture from c where ARRAY_CONTAINS(c.roles,'admin',true) and c.code='Teacher-{scId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
|
|
|
{
|
|
|
scManages.Add(item);
|
|
|
}
|
|
@@ -768,9 +767,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
|
var resScInfo = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
|
|
|
|
|
|
- if (resScInfo.Status == 200)
|
|
|
+ if (resScInfo.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var tchJson = await JsonDocument.ParseAsync(resScInfo.ContentStream);
|
|
|
+ using var tchJson = await JsonDocument.ParseAsync(resScInfo.Content);
|
|
|
School scInfo = tchJson.ToObject<School>();
|
|
|
areaId = scInfo.areaId;
|
|
|
}
|
|
@@ -781,9 +780,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
Teacher teacher = new();
|
|
|
SchoolTeacher schoolTeacher = new();
|
|
|
var resTeacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
|
|
|
- if (resTeacher.Status == 200)
|
|
|
+ if (resTeacher.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var tchJson = await JsonDocument.ParseAsync(resTeacher.ContentStream);
|
|
|
+ using var tchJson = await JsonDocument.ParseAsync(resTeacher.Content);
|
|
|
teacher = tchJson.ToObject<Teacher>();
|
|
|
|
|
|
var existArea = teacher.schools.Find(f => f.schoolId.Equals($"{schoolId}"));
|
|
@@ -812,9 +811,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (teacher != null)
|
|
|
{
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{schoolId}"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
schoolTeacher = json.ToObject<SchoolTeacher>();
|
|
|
if (!schoolTeacher.roles.Contains("admin"))
|
|
|
{
|
|
@@ -822,6 +821,12 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
schoolTeacher.roles.Add("admin");
|
|
|
schoolTeacher.status = "join";
|
|
|
schoolTeacher = await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{schoolId}"));
|
|
|
+
|
|
|
+ #region 同時更新teacher的school.status
|
|
|
+ var school = teacher.schools.Find(f => f.schoolId.Equals($"{schoolId}"));
|
|
|
+ school.status = "join";
|
|
|
+ await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
|
+ #endregion
|
|
|
strMsg.Append($"并设置管理员,学校信息{schoolName}【{schoolId}】");
|
|
|
}
|
|
|
else
|
|
@@ -888,9 +893,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (rmvFromSc) //從老師的學校列表移除該學校
|
|
|
{
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey("Base"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
Teacher teacher = json.ToObject<Teacher>();
|
|
|
teacher.schools.RemoveAll(s => scIds.Contains(s.schoolId));
|
|
|
await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
@@ -901,7 +906,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
foreach (var scId in scIds)
|
|
|
{
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
if (rmvFromSc) //將該老師從學校的老師名單中移除
|
|
|
{
|
|
@@ -911,7 +916,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
scTeacher = json.ToObject<SchoolTeacher>();
|
|
|
if (scTeacher.roles.Contains("admin"))
|
|
|
{
|
|
@@ -963,9 +968,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (schools.Count > 0)
|
|
|
{
|
|
|
var resTeacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
|
|
|
- if (resTeacher.Status == 200)
|
|
|
+ if (resTeacher.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var tchJson = await JsonDocument.ParseAsync(resTeacher.ContentStream);
|
|
|
+ using var tchJson = await JsonDocument.ParseAsync(resTeacher.Content);
|
|
|
teacher = tchJson.ToObject<Teacher>();
|
|
|
}
|
|
|
else
|
|
@@ -992,9 +997,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
existSchool.name = school.name;
|
|
|
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{school.id}"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
schoolTeacher = json.ToObject<SchoolTeacher>();
|
|
|
if (!schoolTeacher.roles.Contains("admin"))
|
|
|
{
|
|
@@ -1025,7 +1030,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
msg.Append($"{school.name}[{school.id}]");
|
|
|
}
|
|
|
|
|
|
- if (resTeacher.Status == 200)
|
|
|
+ if (resTeacher.StatusCode == HttpStatusCode.OK)
|
|
|
teacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
|
else
|
|
|
teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
|
|
@@ -1092,44 +1097,44 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
List<string> scTchIds = new();
|
|
|
List<string> scStuIds = new();
|
|
|
string scTecSql = $"select value(c.id) from c where ARRAY_LENGTH(c.roles) > 0 and c.status = 'join'";
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempId}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempId}") }))
|
|
|
{
|
|
|
scTchIds.Add(item);
|
|
|
}
|
|
|
|
|
|
string scStuSql = $"select value(c.id) from c";
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{tempId}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryIteratorSql<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{tempId}") }))
|
|
|
{
|
|
|
scStuIds.Add(item);
|
|
|
}
|
|
|
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"Base"));
|
|
|
- if (response.Status == 204)
|
|
|
- msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.Status},删除ID:{tempId}");
|
|
|
+ if (response.StatusCode == HttpStatusCode.NoContent)
|
|
|
+ msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.StatusCode},删除ID:{tempId}");
|
|
|
else
|
|
|
- delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = response.Status });
|
|
|
+ delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = (int)HttpStatusCode.NoContent });
|
|
|
|
|
|
//删除学校信息中间
|
|
|
var resBiRel = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"BIRel"));
|
|
|
- if (resBiRel.Status == 204)
|
|
|
- msg.AppendLine($"{tmdName}【{tmdId}】删除学校信息中间件,删除状态:{resBiRel.Status},删除ID:{tempId}");
|
|
|
+ if (resBiRel.StatusCode == HttpStatusCode.NoContent)
|
|
|
+ msg.AppendLine($"{tmdName}【{tmdId}】删除学校信息中间件,删除状态:{resBiRel.StatusCode},删除ID:{tempId}");
|
|
|
else
|
|
|
- delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = response.Status });
|
|
|
+ delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "Base", type = 1, status = (int)response.StatusCode });
|
|
|
|
|
|
foreach (var item in scTchIds)
|
|
|
{
|
|
|
//学校教师信息
|
|
|
var tchRespnse = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{item}", new PartitionKey($"Teacher-{tempId}"));
|
|
|
- if (tchRespnse.Status == 204)
|
|
|
- msg.AppendLine($"删除教师,删除状态:{tchRespnse.Status},删除ID:{item}");
|
|
|
+ if (tchRespnse.StatusCode == HttpStatusCode.NoContent)
|
|
|
+ msg.AppendLine($"删除教师,删除状态:{tchRespnse.StatusCode},删除ID:{item}");
|
|
|
else
|
|
|
- delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Teacher-{tempId}", type = 2, status = response.Status });
|
|
|
+ delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Teacher-{tempId}", type = 2, status = (int)response.StatusCode });
|
|
|
|
|
|
//教师基础信息
|
|
|
var tchBaseResponse = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{item}", new PartitionKey("Base"));
|
|
|
- if (tchBaseResponse.Status == 200)
|
|
|
+ if (tchBaseResponse.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(tchBaseResponse.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(tchBaseResponse.Content);
|
|
|
Teacher teacher = json.ToObject<Teacher>();
|
|
|
var tempSc = teacher.schools.Find(f => f.schoolId.Equals($"{tempId}"));
|
|
|
if (tempSc != null)
|
|
@@ -1139,38 +1144,38 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
- delSchoolRels.Add(new DelSchoolRel { id = $"{item}", code = "Base", type = 2, status = response.Status });
|
|
|
+ delSchoolRels.Add(new DelSchoolRel { id = $"{item}", code = "Base", type = 2, status = (int)response.StatusCode });
|
|
|
}
|
|
|
//删除学校学生
|
|
|
foreach (var item in scStuIds)
|
|
|
{
|
|
|
var stuRespnse = await cosmosClient.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync($"{item}", new PartitionKey($"Base-{tempId}"));
|
|
|
- if (stuRespnse.Status == 204)
|
|
|
- msg.AppendLine($"删除学生,删除状态:{stuRespnse.Status},删除ID:{item}");
|
|
|
+ if (stuRespnse.StatusCode == HttpStatusCode.NoContent)
|
|
|
+ msg.AppendLine($"删除学生,删除状态:{stuRespnse.StatusCode},删除ID:{item}");
|
|
|
else
|
|
|
- delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Base-{tempId}", type = 3, status = response.Status });
|
|
|
+ delSchoolRels.Add(new DelSchoolRel() { id = $"{item}", code = $"Base-{tempId}", type = 3, status = (int)response.StatusCode });
|
|
|
}
|
|
|
}
|
|
|
//虛擬學校刪除
|
|
|
else
|
|
|
{
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"VirtualBase"));
|
|
|
- if (response.Status == 204)
|
|
|
- msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.Status},删除ID:{tempId}");
|
|
|
+ if (response.StatusCode == HttpStatusCode.NoContent)
|
|
|
+ msg.AppendLine($"{tmdName}【{tmdId}】删除学校,删除状态:{response.StatusCode},删除ID:{tempId}");
|
|
|
else
|
|
|
- delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "VirtualBase", type = 1, status = response.Status });
|
|
|
+ delSchoolRels.Add(new DelSchoolRel() { id = $"{tempId}", code = "VirtualBase", type = 1, status = (int)response.StatusCode });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//string scTecSql = $"select value(c.id) from c where ARRAY_LENGTH(c.roles) > 0 and c.status = 'join'";
|
|
|
- //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{schoolId}") }))
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scTecSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{schoolId}") }))
|
|
|
//{
|
|
|
// scTchIds.Add(item);
|
|
|
//}
|
|
|
|
|
|
//string scStuSql = $"select value(c.id) from c";
|
|
|
- //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: scStuSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
|
|
|
//{
|
|
|
// scStuIds.Add(item);
|
|
|
//}
|
|
@@ -1262,9 +1267,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (schoolInfo != null)
|
|
|
{
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolInfo.id, new PartitionKey("ProductSum"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
|
|
|
schoolInfo.serial = serial.ToObject<List<ProductSumInfos>>();
|
|
|
|
|
@@ -1339,9 +1344,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
RecSchool recSchool = new();
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
recSchool = json.ToObject<RecSchool>();
|
|
|
}
|
|
|
else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
|
|
@@ -1452,7 +1457,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
//获取当前学期所有的课程记录
|
|
|
List<LessAnalyse> records = new List<LessAnalyse>();
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessAnalyse>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<LessAnalyse>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{schoolId}") }))
|
|
|
{
|
|
|
records.Add(item);
|
|
|
}
|
|
@@ -1465,7 +1470,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
List<LessonCount> scount = new();
|
|
|
List<LessonCount> tcount = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{year}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessonCount>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{schoolId}-{year}") }))
|
|
|
{
|
|
|
scount.Add(item);
|
|
|
}
|
|
@@ -1474,7 +1479,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
foreach (var tId in teacIds)
|
|
|
{
|
|
|
var sqlTxtt = $"select value(c) from c where c.id='{tId}'";
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIteratorSql<LessonCount>(queryText: sqlTxtt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{year}") }))
|
|
|
{
|
|
|
tcount.Add(item);
|
|
|
}
|
|
@@ -1859,15 +1864,15 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
AnSchool school = new(); //学校基础基础信息
|
|
|
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
school = json.ToObject<AnSchool>();
|
|
|
}
|
|
|
else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
|
|
|
List<LessAnalyse> lessAnalyses = new();
|
|
|
|
|
|
- await foreach (var lessItem in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<LessAnalyse>(queryText: "select c.id,c.code,c.periodId,c.subjectId,c.grade from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school.id}") }))
|
|
|
+ await foreach (var lessItem in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<LessAnalyse>(queryText: "select c.id,c.code,c.periodId,c.subjectId,c.grade from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonRecord-{school.id}") }))
|
|
|
{
|
|
|
lessAnalyses.Add(lessItem);
|
|
|
}
|
|
@@ -1878,9 +1883,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
var subCnt = subs.Select(x => new { name = x.key, value = x.count });
|
|
|
|
|
|
var responseProduct = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
|
|
|
- if (responseProduct.Status == 200)
|
|
|
+ if (responseProduct.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(responseProduct.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(responseProduct.Content);
|
|
|
if (json.RootElement.TryGetProperty("serial", out JsonElement _serial) && !_serial.ValueKind.Equals(JsonValueKind.Null))
|
|
|
{
|
|
|
school.serial = _serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
@@ -1915,7 +1920,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
if (!string.IsNullOrEmpty($"{areaId}"))
|
|
|
sql.Append($" where c.areaId = '{areaId}'");
|
|
|
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIterator<ScBriefInfo>(queryText: sql.ToString(), requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIteratorSql<ScBriefInfo>(queryText: sql.ToString(), requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("Base")}))
|
|
|
{
|
|
|
scBriefs.Add(item);
|
|
|
}
|
|
@@ -1981,9 +1986,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
allCnt += await CommonFind.GetSqlValueCount(cosmosClient, "School", serialAllSql, $"Product-{scProd.id}");
|
|
|
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
|
|
|
{
|
|
|
List<string> serials = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
@@ -2010,7 +2015,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
// var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
|
|
|
// if (response.Status == 200)
|
|
|
// {
|
|
|
- // using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ // using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
// if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
|
|
|
// {
|
|
|
// scProd.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
@@ -2056,9 +2061,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
List<School> schools = new();
|
|
|
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -2102,9 +2107,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
foreach (var school in schools)
|
|
|
{
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIteratorSql(queryText: $"SELECT sum(c.size) as size FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
|
|
|
{
|
|
|
- var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
{
|
|
|
if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
|
|
@@ -2297,7 +2302,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
List<string> scIds = new();
|
|
|
|
|
|
string mScSql = $"SELECT value(REPLACE(c.code, 'Teacher-', '')) FROM c where array_contains(c.roles,'admin',true) and c.pk='Teacher' and c.id='{tmdId}'";
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: mScSql, requestOptions: new QueryRequestOptions() { }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<string>(queryText: mScSql, requestOptions: new QueryRequestOptions() { }))
|
|
|
{
|
|
|
scIds.Add(item);
|
|
|
}
|
|
@@ -2345,7 +2350,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
List<ScSimple> scSimple = new();
|
|
|
|
|
|
- await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ScSimple>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIteratorSql<ScSimple>(queryText: scSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
scSimple.Add(itemSchool);
|
|
|
}
|
|
@@ -2412,9 +2417,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
////取得各產品目前可得數量
|
|
|
var response = await db.ReadItemStreamAsync(school_code.ToString(), new PartitionKey($"ProductSum"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
|
productSum = json.ToObject<SchoolProductSum>();
|
|
|
prodinfo = productSum.prodinfo;
|
|
|
serviceSum = productSum.service;
|
|
@@ -2424,9 +2429,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
List<string> serialPermitList = getSerialPermitProdcodeList();
|
|
|
string serialPermitJsonStr = JsonConvert.SerializeObject(serialPermitList);
|
|
|
string serialQueryText = $"SELECT * FROM c WHERE c.dataType = 'serial' AND ARRAY_CONTAINS({serialPermitJsonStr}, c.prodCode)";
|
|
|
- await foreach (var itemsr in db.GetItemQueryStreamIterator(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
|
|
|
+ await foreach (var itemsr in db.GetItemQueryStreamIteratorSql(queryText: serialQueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(itemsr.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(itemsr.Content);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
deviceForCoreService uuidForCore;
|
|
@@ -2440,9 +2445,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
//服務
|
|
|
List<SchoolProductSumDataService> service = new List<SchoolProductSumDataService>();
|
|
|
SchoolProductSum schoolProductSum;
|
|
|
- await foreach (var items in db.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.id = '{school_code}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
|
|
|
+ await foreach (var items in db.GetItemQueryStreamIteratorSql(queryText: $"SELECT * FROM c WHERE c.id = '{school_code}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ProductSum") }))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(items.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(items.Content);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -2459,7 +2464,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
|
spOrderRow = new SchoolProductOrder();
|
|
|
spOrderRow.prodCode = serviceRow.prodCode;
|
|
|
- spOrderRow.avaliable = serviceRow.avaliable;
|
|
|
+ spOrderRow.avaliable = UTCNow>serviceRow.endDate ? 0 : serviceRow.avaliable;
|
|
|
spOrderRow.avaliableStartDate = serviceRow.startDate;
|
|
|
spOrderRow.avaliableEndDate = serviceRow.endDate;
|
|
|
serviceOrder.Add(spOrderRow);
|
|
@@ -2467,9 +2472,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
}
|
|
|
|
|
|
//硬體
|
|
|
- await foreach (var itemhd in db.GetItemQueryStreamIterator(queryText: $"SELECT * FROM c WHERE c.dataType = 'hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
|
|
|
+ await foreach (var itemhd in db.GetItemQueryStreamIteratorSql(queryText: $"SELECT * FROM c WHERE c.dataType = 'hard'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Product-{school_code}") }))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(itemhd.ContentStream);
|
|
|
+ using var json = await JsonDocument.ParseAsync(itemhd.Content);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -2483,9 +2488,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
////取得教師分配空間
|
|
|
long teach = 0;
|
|
|
var querysp = $"SELECT SUM(c.size) as size FROM c";
|
|
|
- await foreach (var item in db.GetItemQueryStreamIterator(queryText: querysp, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
|
|
|
+ await foreach (var item in db.GetItemQueryStreamIteratorSql(queryText: querysp, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school_code}") }))
|
|
|
{
|
|
|
- var jsonts = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ var jsonts = await JsonDocument.ParseAsync(item.Content);
|
|
|
foreach (var obj in jsonts.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
{
|
|
|
teach = obj.GetProperty("size").GetInt64() * 1073741824; //G換算
|
|
@@ -2600,6 +2605,100 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region 統購平台用
|
|
|
+ /// <summary>
|
|
|
+ /// 取得CoreBB學校訂單履歷資訊 暂时这样处理
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-bbpurchase")]
|
|
|
+ public async Task<IActionResult> GetBBpurchase(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ List<object> result = new List<object>();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var client = _azureCosmos.GetCosmosClient(name:"CoreServiceV2");
|
|
|
+ string sqlPurchase = $"SELECT * FROM c ";
|
|
|
+ List<PurchaseSeats> purchaseSeatsList = new List<PurchaseSeats>();
|
|
|
+ await foreach (PurchaseSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<PurchaseSeats>(queryText: sqlPurchase, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchase") }))
|
|
|
+ {
|
|
|
+ purchaseSeatsList.Add(item);
|
|
|
+ }
|
|
|
+ Dictionary<string, List<PurchaseSchoolSeats>> purchaseSchoolSeatsDic = new Dictionary<string, List<PurchaseSchoolSeats>>();
|
|
|
+ string sqlSchool = $"SELECT * FROM c ";
|
|
|
+ await foreach (PurchaseSchoolSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<PurchaseSchoolSeats>(queryText: sqlSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchaseSchool") }))
|
|
|
+ {
|
|
|
+ if(!purchaseSchoolSeatsDic.ContainsKey(item.purchaseId))
|
|
|
+ {
|
|
|
+ purchaseSchoolSeatsDic.Add(item.purchaseId, new List<PurchaseSchoolSeats>() { item });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ purchaseSchoolSeatsDic[item.purchaseId].Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { geo = purchaseSeatsList, school = purchaseSchoolSeatsDic });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 取得CoreService縣市所屬學校
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-school-geo")]
|
|
|
+ public async Task<IActionResult> GetCsSchoolByGeo(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ List<CsSchoolBase> result = new List<CsSchoolBase>();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string err = string.Empty;
|
|
|
+ string countryId = (jsonElement.TryGetProperty("countryId", out JsonElement _countryId)) ? _countryId.GetString() : string.Empty;
|
|
|
+ string provinceId = (jsonElement.TryGetProperty("provinceId", out JsonElement _provinceId)) ? _provinceId.GetString() : string.Empty;
|
|
|
+ string cityId = (jsonElement.TryGetProperty("cityId", out JsonElement _cityId)) ? _cityId.GetString() : string.Empty;
|
|
|
+ string distId = (jsonElement.TryGetProperty("distId", out JsonElement _distId)) ? _distId.GetString() : string.Empty;
|
|
|
+ //輸入項檢驗
|
|
|
+ if (string.IsNullOrWhiteSpace(countryId)) { err = "Invalid countryId."; }
|
|
|
+ else if(countryId.Equals("CN"))
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(provinceId)) { err = "Invalid provinceId."; }
|
|
|
+ else if (string.IsNullOrWhiteSpace(cityId)) { err = "Invalid cityId."; }
|
|
|
+ }
|
|
|
+ else if (countryId.Equals("TW"))
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(cityId)) { err = "Invalid cityId."; }
|
|
|
+ }
|
|
|
+ if(!string.IsNullOrWhiteSpace(err)) ///錯誤訊息輸出
|
|
|
+ {
|
|
|
+ return Ok(new { err = err, data = result });
|
|
|
+ }
|
|
|
+ //取得CS學校
|
|
|
+ var client = _azureCosmos.GetCosmosClient(name:"CoreServiceV2CnRead");
|
|
|
+ string sql = $"SELECT * FROM c WHERE c.countryId = '{countryId}'";
|
|
|
+ if (!string.IsNullOrWhiteSpace(provinceId)) sql += $" AND c.provinceId = '{provinceId}'";
|
|
|
+ if (!string.IsNullOrWhiteSpace(cityId)) sql += $" AND c.cityId = '{cityId}'";
|
|
|
+ if (!string.IsNullOrWhiteSpace(distId)) sql += $" AND c.distId = '{distId}'";
|
|
|
+ await foreach (CsSchoolBase item in client.GetContainer("Core", "School").GetItemQueryIteratorSql<CsSchoolBase>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
|
|
|
+ {
|
|
|
+ result.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { err = err, data = result });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 未加入区域的学校
|
|
|
/// </summary>
|