|
@@ -1,4 +1,4 @@
|
|
-using Azure.Cosmos;
|
|
|
|
|
|
+using Microsoft.Azure.Cosmos;
|
|
using MathNet.Numerics.LinearAlgebra.Double;
|
|
using MathNet.Numerics.LinearAlgebra.Double;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
@@ -106,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)");
|
|
sqltxt.Append($" WHERE c.pk='School' and (c.areaId = '' or c.areaId = null or IS_DEFINED(c.areaId) = false)");
|
|
|
|
|
|
List<NotAreaSchool> tempNotAreaSchools = new();
|
|
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)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -136,7 +136,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
if (iscontinuation)
|
|
if (iscontinuation)
|
|
{
|
|
{
|
|
- continuationToken = item.GetContinuationToken();
|
|
|
|
|
|
+ continuationToken = item.ContinuationToken;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -186,9 +186,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
List<NotAreaSchool> notAreaSchools = new();
|
|
List<NotAreaSchool> notAreaSchools = new();
|
|
foreach (string pk in partitionKeys)
|
|
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)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -275,9 +275,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
//}
|
|
//}
|
|
|
|
|
|
var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_areaId}", new PartitionKey("AreaSetting"));
|
|
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>();
|
|
AreaSetting delSet = fileJson.ToObject<AreaSetting>();
|
|
if (!string.IsNullOrEmpty(delSet.accessConfig))
|
|
if (!string.IsNullOrEmpty(delSet.accessConfig))
|
|
return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
|
|
return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
|
|
@@ -308,7 +308,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
msg.Append($"{school.name}【{school.id}】学校移除多区域的名单:");
|
|
msg.Append($"{school.name}【{school.id}】学校移除多区域的名单:");
|
|
List<Teacher> teachers = new();
|
|
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);
|
|
teachers.Add(item);
|
|
}
|
|
}
|
|
@@ -368,7 +368,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
AssistSchool schoolAssists = new(); //返回学校列表集合
|
|
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}'";
|
|
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;
|
|
schoolAssists = itemSchool;
|
|
}
|
|
}
|
|
@@ -376,9 +376,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
if (schoolAssists.id != null)
|
|
if (schoolAssists.id != null)
|
|
{
|
|
{
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolAssists.id, new PartitionKey("ProductSum"));
|
|
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))
|
|
if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
|
|
{
|
|
{
|
|
schoolAssists.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
schoolAssists.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
@@ -401,7 +401,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
//無實體學校 => 取得虛擬學校
|
|
//無實體學校 => 取得虛擬學校
|
|
else
|
|
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;
|
|
schoolAssists = itemSchool;
|
|
}
|
|
}
|
|
@@ -442,11 +442,11 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
string _auth = HttpContext.GetXAuth("AuthToken");
|
|
string _auth = HttpContext.GetXAuth("AuthToken");
|
|
var (tmdId, tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(_auth, _option);
|
|
var (tmdId, tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(_auth, _option);
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey($"Base"));
|
|
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}'";
|
|
string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{school.id}'";
|
|
List<Teacher> teachers = new();
|
|
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);
|
|
teachers.Add(item);
|
|
}
|
|
}
|
|
@@ -499,16 +499,16 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
{
|
|
{
|
|
School school = new();
|
|
School school = new();
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(sid, new PartitionKey("Base"));
|
|
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>();
|
|
school = json.ToObject<School>();
|
|
}
|
|
}
|
|
|
|
|
|
long teach = 0;
|
|
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())
|
|
foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
{
|
|
{
|
|
if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
|
|
if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
|
|
@@ -719,7 +719,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
// cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
// cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
|
|
|
List<BaseInfo> scManages = new();
|
|
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);
|
|
scManages.Add(item);
|
|
}
|
|
}
|
|
@@ -767,9 +767,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
{
|
|
{
|
|
var resScInfo = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
|
|
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>();
|
|
School scInfo = tchJson.ToObject<School>();
|
|
areaId = scInfo.areaId;
|
|
areaId = scInfo.areaId;
|
|
}
|
|
}
|
|
@@ -780,9 +780,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
Teacher teacher = new();
|
|
Teacher teacher = new();
|
|
SchoolTeacher schoolTeacher = new();
|
|
SchoolTeacher schoolTeacher = new();
|
|
var resTeacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
|
|
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>();
|
|
teacher = tchJson.ToObject<Teacher>();
|
|
|
|
|
|
var existArea = teacher.schools.Find(f => f.schoolId.Equals($"{schoolId}"));
|
|
var existArea = teacher.schools.Find(f => f.schoolId.Equals($"{schoolId}"));
|
|
@@ -811,9 +811,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
if (teacher != null)
|
|
if (teacher != null)
|
|
{
|
|
{
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{schoolId}"));
|
|
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>();
|
|
schoolTeacher = json.ToObject<SchoolTeacher>();
|
|
if (!schoolTeacher.roles.Contains("admin"))
|
|
if (!schoolTeacher.roles.Contains("admin"))
|
|
{
|
|
{
|
|
@@ -893,9 +893,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
if (rmvFromSc) //從老師的學校列表移除該學校
|
|
if (rmvFromSc) //從老師的學校列表移除該學校
|
|
{
|
|
{
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey("Base"));
|
|
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 teacher = json.ToObject<Teacher>();
|
|
teacher.schools.RemoveAll(s => scIds.Contains(s.schoolId));
|
|
teacher.schools.RemoveAll(s => scIds.Contains(s.schoolId));
|
|
await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
@@ -906,7 +906,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
foreach (var scId in scIds)
|
|
foreach (var scId in scIds)
|
|
{
|
|
{
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{scId}"));
|
|
- if (response.Status == 200)
|
|
|
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
{
|
|
if (rmvFromSc) //將該老師從學校的老師名單中移除
|
|
if (rmvFromSc) //將該老師從學校的老師名單中移除
|
|
{
|
|
{
|
|
@@ -916,7 +916,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.Content);
|
|
scTeacher = json.ToObject<SchoolTeacher>();
|
|
scTeacher = json.ToObject<SchoolTeacher>();
|
|
if (scTeacher.roles.Contains("admin"))
|
|
if (scTeacher.roles.Contains("admin"))
|
|
{
|
|
{
|
|
@@ -968,9 +968,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
if (schools.Count > 0)
|
|
if (schools.Count > 0)
|
|
{
|
|
{
|
|
var resTeacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Base"));
|
|
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>();
|
|
teacher = tchJson.ToObject<Teacher>();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -997,9 +997,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
existSchool.name = school.name;
|
|
existSchool.name = school.name;
|
|
|
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{tmdId}", new PartitionKey($"Teacher-{school.id}"));
|
|
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>();
|
|
schoolTeacher = json.ToObject<SchoolTeacher>();
|
|
if (!schoolTeacher.roles.Contains("admin"))
|
|
if (!schoolTeacher.roles.Contains("admin"))
|
|
{
|
|
{
|
|
@@ -1030,7 +1030,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
msg.Append($"{school.name}[{school.id}]");
|
|
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"));
|
|
teacher = await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
|
|
else
|
|
else
|
|
teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
|
|
teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
|
|
@@ -1097,44 +1097,44 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
List<string> scTchIds = new();
|
|
List<string> scTchIds = new();
|
|
List<string> scStuIds = new();
|
|
List<string> scStuIds = new();
|
|
string scTecSql = $"select value(c.id) from c where ARRAY_LENGTH(c.roles) > 0 and c.status = 'join'";
|
|
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);
|
|
scTchIds.Add(item);
|
|
}
|
|
}
|
|
|
|
|
|
string scStuSql = $"select value(c.id) from c";
|
|
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);
|
|
scStuIds.Add(item);
|
|
}
|
|
}
|
|
|
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"Base"));
|
|
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
|
|
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"));
|
|
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
|
|
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)
|
|
foreach (var item in scTchIds)
|
|
{
|
|
{
|
|
//学校教师信息
|
|
//学校教师信息
|
|
var tchRespnse = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{item}", new PartitionKey($"Teacher-{tempId}"));
|
|
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
|
|
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"));
|
|
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>();
|
|
Teacher teacher = json.ToObject<Teacher>();
|
|
var tempSc = teacher.schools.Find(f => f.schoolId.Equals($"{tempId}"));
|
|
var tempSc = teacher.schools.Find(f => f.schoolId.Equals($"{tempId}"));
|
|
if (tempSc != null)
|
|
if (tempSc != null)
|
|
@@ -1144,38 +1144,38 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
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)
|
|
foreach (var item in scStuIds)
|
|
{
|
|
{
|
|
var stuRespnse = await cosmosClient.GetContainer("TEAMModelOS", "Student").DeleteItemStreamAsync($"{item}", new PartitionKey($"Base-{tempId}"));
|
|
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
|
|
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
|
|
else
|
|
{
|
|
{
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync($"{tempId}", new PartitionKey($"VirtualBase"));
|
|
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
|
|
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'";
|
|
//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);
|
|
// scTchIds.Add(item);
|
|
//}
|
|
//}
|
|
|
|
|
|
//string scStuSql = $"select value(c.id) from c";
|
|
//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);
|
|
// scStuIds.Add(item);
|
|
//}
|
|
//}
|
|
@@ -1267,9 +1267,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
if (schoolInfo != null)
|
|
if (schoolInfo != null)
|
|
{
|
|
{
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolInfo.id, new PartitionKey("ProductSum"));
|
|
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))
|
|
if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
|
|
schoolInfo.serial = serial.ToObject<List<ProductSumInfos>>();
|
|
schoolInfo.serial = serial.ToObject<List<ProductSumInfos>>();
|
|
|
|
|
|
@@ -1344,9 +1344,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
RecSchool recSchool = new();
|
|
RecSchool recSchool = new();
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
|
|
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>();
|
|
recSchool = json.ToObject<RecSchool>();
|
|
}
|
|
}
|
|
else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
|
|
else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
|
|
@@ -1457,7 +1457,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
//获取当前学期所有的课程记录
|
|
//获取当前学期所有的课程记录
|
|
List<LessAnalyse> records = new List<LessAnalyse>();
|
|
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);
|
|
records.Add(item);
|
|
}
|
|
}
|
|
@@ -1470,7 +1470,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
List<LessonCount> scount = new();
|
|
List<LessonCount> scount = new();
|
|
List<LessonCount> tcount = 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);
|
|
scount.Add(item);
|
|
}
|
|
}
|
|
@@ -1479,7 +1479,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
foreach (var tId in teacIds)
|
|
foreach (var tId in teacIds)
|
|
{
|
|
{
|
|
var sqlTxtt = $"select value(c) from c where c.id='{tId}'";
|
|
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);
|
|
tcount.Add(item);
|
|
}
|
|
}
|
|
@@ -1864,15 +1864,15 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
AnSchool school = new(); //学校基础基础信息
|
|
AnSchool school = new(); //学校基础基础信息
|
|
|
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
|
|
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>();
|
|
school = json.ToObject<AnSchool>();
|
|
}
|
|
}
|
|
else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
|
|
else return Ok(new { state = RespondCode.NotFound, msg = "未找到该学校" });
|
|
List<LessAnalyse> lessAnalyses = new();
|
|
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);
|
|
lessAnalyses.Add(lessItem);
|
|
}
|
|
}
|
|
@@ -1883,9 +1883,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
var subCnt = subs.Select(x => new { name = x.key, value = x.count });
|
|
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"));
|
|
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))
|
|
if (json.RootElement.TryGetProperty("serial", out JsonElement _serial) && !_serial.ValueKind.Equals(JsonValueKind.Null))
|
|
{
|
|
{
|
|
school.serial = _serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
school.serial = _serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
@@ -1920,7 +1920,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
if (!string.IsNullOrEmpty($"{areaId}"))
|
|
if (!string.IsNullOrEmpty($"{areaId}"))
|
|
sql.Append($" where c.areaId = '{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);
|
|
scBriefs.Add(item);
|
|
}
|
|
}
|
|
@@ -1986,9 +1986,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
allCnt += await CommonFind.GetSqlValueCount(cosmosClient, "School", serialAllSql, $"Product-{scProd.id}");
|
|
allCnt += await CommonFind.GetSqlValueCount(cosmosClient, "School", serialAllSql, $"Product-{scProd.id}");
|
|
|
|
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
|
|
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))
|
|
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();
|
|
List<string> serials = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
@@ -2015,7 +2015,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
// var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
|
|
// var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
|
|
// if (response.Status == 200)
|
|
// 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))
|
|
// if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
|
|
// {
|
|
// {
|
|
// scProd.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
// scProd.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
@@ -2061,9 +2061,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
List<School> schools = new();
|
|
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)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -2107,9 +2107,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
foreach (var school in schools)
|
|
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())
|
|
foreach (var elmt in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
{
|
|
{
|
|
if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
|
|
if (elmt.TryGetProperty("size", out JsonElement _size) && _size.ValueKind.Equals(JsonValueKind.Number))
|
|
@@ -2302,7 +2302,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
List<string> scIds = new();
|
|
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}'";
|
|
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);
|
|
scIds.Add(item);
|
|
}
|
|
}
|
|
@@ -2350,7 +2350,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
List<ScSimple> scSimple = new();
|
|
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);
|
|
scSimple.Add(itemSchool);
|
|
}
|
|
}
|
|
@@ -2417,9 +2417,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
////取得各產品目前可得數量
|
|
////取得各產品目前可得數量
|
|
var response = await db.ReadItemStreamAsync(school_code.ToString(), new PartitionKey($"ProductSum"));
|
|
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>();
|
|
productSum = json.ToObject<SchoolProductSum>();
|
|
prodinfo = productSum.prodinfo;
|
|
prodinfo = productSum.prodinfo;
|
|
serviceSum = productSum.service;
|
|
serviceSum = productSum.service;
|
|
@@ -2429,9 +2429,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
List<string> serialPermitList = getSerialPermitProdcodeList();
|
|
List<string> serialPermitList = getSerialPermitProdcodeList();
|
|
string serialPermitJsonStr = JsonConvert.SerializeObject(serialPermitList);
|
|
string serialPermitJsonStr = JsonConvert.SerializeObject(serialPermitList);
|
|
string serialQueryText = $"SELECT * FROM c WHERE c.dataType = 'serial' AND ARRAY_CONTAINS({serialPermitJsonStr}, c.prodCode)";
|
|
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)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
deviceForCoreService uuidForCore;
|
|
deviceForCoreService uuidForCore;
|
|
@@ -2445,9 +2445,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
//服務
|
|
//服務
|
|
List<SchoolProductSumDataService> service = new List<SchoolProductSumDataService>();
|
|
List<SchoolProductSumDataService> service = new List<SchoolProductSumDataService>();
|
|
SchoolProductSum schoolProductSum;
|
|
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)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -2472,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)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
@@ -2488,9 +2488,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
////取得教師分配空間
|
|
////取得教師分配空間
|
|
long teach = 0;
|
|
long teach = 0;
|
|
var querysp = $"SELECT SUM(c.size) as size FROM c";
|
|
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())
|
|
foreach (var obj in jsonts.RootElement.GetProperty("Documents").EnumerateArray())
|
|
{
|
|
{
|
|
teach = obj.GetProperty("size").GetInt64() * 1073741824; //G換算
|
|
teach = obj.GetProperty("size").GetInt64() * 1073741824; //G換算
|
|
@@ -2621,13 +2621,13 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
var client = _azureCosmos.GetCosmosClient(name:"CoreServiceV2");
|
|
var client = _azureCosmos.GetCosmosClient(name:"CoreServiceV2");
|
|
string sqlPurchase = $"SELECT * FROM c ";
|
|
string sqlPurchase = $"SELECT * FROM c ";
|
|
List<PurchaseSeats> purchaseSeatsList = new List<PurchaseSeats>();
|
|
List<PurchaseSeats> purchaseSeatsList = new List<PurchaseSeats>();
|
|
- await foreach (PurchaseSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIterator<PurchaseSeats>(queryText: sqlPurchase, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchase") }))
|
|
|
|
|
|
+ await foreach (PurchaseSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<PurchaseSeats>(queryText: sqlPurchase, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchase") }))
|
|
{
|
|
{
|
|
purchaseSeatsList.Add(item);
|
|
purchaseSeatsList.Add(item);
|
|
}
|
|
}
|
|
Dictionary<string, List<PurchaseSchoolSeats>> purchaseSchoolSeatsDic = new Dictionary<string, List<PurchaseSchoolSeats>>();
|
|
Dictionary<string, List<PurchaseSchoolSeats>> purchaseSchoolSeatsDic = new Dictionary<string, List<PurchaseSchoolSeats>>();
|
|
string sqlSchool = $"SELECT * FROM c ";
|
|
string sqlSchool = $"SELECT * FROM c ";
|
|
- await foreach (PurchaseSchoolSeats item in client.GetContainer("Habb", "Auth").GetItemQueryIterator<PurchaseSchoolSeats>(queryText: sqlSchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("purchaseSchool") }))
|
|
|
|
|
|
+ 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))
|
|
if(!purchaseSchoolSeatsDic.ContainsKey(item.purchaseId))
|
|
{
|
|
{
|
|
@@ -2684,7 +2684,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
if (!string.IsNullOrWhiteSpace(provinceId)) sql += $" AND c.provinceId = '{provinceId}'";
|
|
if (!string.IsNullOrWhiteSpace(provinceId)) sql += $" AND c.provinceId = '{provinceId}'";
|
|
if (!string.IsNullOrWhiteSpace(cityId)) sql += $" AND c.cityId = '{cityId}'";
|
|
if (!string.IsNullOrWhiteSpace(cityId)) sql += $" AND c.cityId = '{cityId}'";
|
|
if (!string.IsNullOrWhiteSpace(distId)) sql += $" AND c.distId = '{distId}'";
|
|
if (!string.IsNullOrWhiteSpace(distId)) sql += $" AND c.distId = '{distId}'";
|
|
- await foreach (CsSchoolBase item in client.GetContainer("Core", "School").GetItemQueryIterator<CsSchoolBase>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
|
|
|
|
|
|
+ await foreach (CsSchoolBase item in client.GetContainer("Core", "School").GetItemQueryIteratorSql<CsSchoolBase>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("base") }))
|
|
{
|
|
{
|
|
result.Add(item);
|
|
result.Add(item);
|
|
}
|
|
}
|