|
@@ -1211,7 +1211,7 @@ namespace TEAMModelOS.SDK
|
|
|
List<object> retStuds = new List<object>();
|
|
|
|
|
|
|
|
|
- CosmosContainer cosmosContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
|
|
|
+ Container cosmosContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
|
|
|
|
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
//並行處理
|
|
@@ -1331,12 +1331,12 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
var response = await cosmosContainer.CreateItemStreamAsync(memoryStream, new PartitionKey($"Base-{schoolId}"));
|
|
|
|
|
|
- if (response.Status == (int)HttpStatusCode.Created)
|
|
|
+ if (response.StatusCode == HttpStatusCode.Created)
|
|
|
{
|
|
|
//如果是Created則啥都不做,讓他去下面進行資料的彙整。
|
|
|
}
|
|
|
//查到已存在的id,則進行基本資料更新。
|
|
|
- else if (response.Status == (int)HttpStatusCode.Conflict)
|
|
|
+ else if (response.StatusCode == HttpStatusCode.Conflict)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -1489,7 +1489,7 @@ namespace TEAMModelOS.SDK
|
|
|
/// keep 保持现状,导入时
|
|
|
/// delete 因学生被删除,强制删除电子学生证。</param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task upsertImei(string stuid, string imeiid, string schoolId, string grand_type, CosmosContainer cosmosContainer)
|
|
|
+ public static async Task upsertImei(string stuid, string imeiid, string schoolId, string grand_type, Container cosmosContainer)
|
|
|
{
|
|
|
List<Imei> imeis = new List<Imei>();
|
|
|
string sql = $"select value c from c where c.stuid='{stuid}' and c.school='{schoolId}' ";
|
|
@@ -1535,7 +1535,7 @@ namespace TEAMModelOS.SDK
|
|
|
if (notin && !string.IsNullOrWhiteSpace(imeiid))
|
|
|
{
|
|
|
var imeiResponse = await cosmosContainer.ReadItemStreamAsync(imeiid, new PartitionKey("Imei"));
|
|
|
- if (imeiResponse.Status == 200)
|
|
|
+ if (imeiResponse.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
Imei imeiDb = JsonDocument.Parse(imeiResponse.Content).RootElement.Deserialize<Imei>();
|
|
|
imeiDb.stuid = stuid;
|
|
@@ -1682,11 +1682,11 @@ namespace TEAMModelOS.SDK
|
|
|
await upsertImei(studCreateInfo.id, studCreateInfo.imei, schoolId, "keep", _azureCosmos
|
|
|
.GetCosmosClient()
|
|
|
.GetContainer(Constant.TEAMModelOS, "Student"));
|
|
|
- if (response.Status == (int)HttpStatusCode.Created || response.Status == (int)HttpStatusCode.OK) return true;
|
|
|
- if (response.Status == (int)HttpStatusCode.Conflict) return false;
|
|
|
+ if (response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.OK) return true;
|
|
|
+ if (response.StatusCode == HttpStatusCode.Conflict) return false;
|
|
|
else
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"IES5,{_option.Location},StudentController/createStudent()\nCosmosDB Create response status = {response.Status}\nID:{studCreateInfo.id}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ await _dingDing.SendBotMsg($"IES5,{_option.Location},StudentController/createStudent()\nCosmosDB Create response status = {response.StatusCode}\nID:{studCreateInfo.id}", GroupNames.醍摩豆服務運維群組);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -1754,9 +1754,9 @@ namespace TEAMModelOS.SDK
|
|
|
writer.Flush();
|
|
|
|
|
|
var ret = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemStreamAsync(memoryStream, new PartitionKey($"Class-{schoolId}"));
|
|
|
- if (ret.Status != (int)HttpStatusCode.Created)
|
|
|
+ if (ret.StatusCode !=HttpStatusCode.Created)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"IES5,{_option.Location},StudentController/createClassInfo()\nStatus:{ret.Status}\nSchoolId:{schoolId},ClassId:{classId}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ await _dingDing.SendBotMsg($"IES5,{_option.Location},StudentController/createClassInfo()\nStatus:{ret.StatusCode}\nSchoolId:{schoolId},ClassId:{classId}", GroupNames.醍摩豆服務運維群組);
|
|
|
}
|
|
|
return (cId, classNo, className, periodId, gradeId, classYear);
|
|
|
}
|
|
@@ -1832,7 +1832,7 @@ namespace TEAMModelOS.SDK
|
|
|
requestOptions: new QueryRequestOptions()
|
|
|
{ PartitionKey = new PartitionKey($"Base-{schoolId}") }))
|
|
|
{
|
|
|
- continuationToken = item.GetContinuationToken();
|
|
|
+ continuationToken = item.ContinuationToken;
|
|
|
using var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
@@ -1851,7 +1851,7 @@ namespace TEAMModelOS.SDK
|
|
|
List<object> ret = new List<object>();
|
|
|
//查教室資訊,使用上面的學生id並透過子查詢查詢。
|
|
|
queryText = $"SELECT c.id, c.name, c.gradeId, c.students FROM c JOIN (SELECT VALUE t FROM t IN c.students WHERE t.id IN ({string.Join(",", listStudent.Select(o => $"'{o.id}'"))}))";
|
|
|
- await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
|
|
|
.GetItemQueryStreamIteratorSql(
|
|
|
queryText: queryText,
|
|
|
//continuationToken: token,
|
|
@@ -1987,7 +1987,7 @@ namespace TEAMModelOS.SDK
|
|
|
requestOptions: new QueryRequestOptions()
|
|
|
{ PartitionKey = new PartitionKey($"Base-{schoolId}"), MaxItemCount = -1 }))
|
|
|
{
|
|
|
- continuationToken = item.GetContinuationToken();
|
|
|
+ continuationToken = item.ContinuationToken;
|
|
|
using var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
@@ -2197,7 +2197,7 @@ namespace TEAMModelOS.SDK
|
|
|
//if (!string.IsNullOrWhiteSpace(classId)) queryText += $" AND c.id = '{classId}'";
|
|
|
Dictionary<string, JsonElement> listStudent = new Dictionary<string, JsonElement>();
|
|
|
|
|
|
- await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
|
|
|
.GetItemQueryStreamIteratorSql(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.Content);
|
|
@@ -2247,7 +2247,7 @@ namespace TEAMModelOS.SDK
|
|
|
id = student.GetProperty("id").GetString();
|
|
|
var ret = await container.DeleteItemStreamAsync(id, new PartitionKey($"Base-{schoolId}"));
|
|
|
await upsertImei(id, null, schoolId, "delete", container);
|
|
|
- if (ret.Status == (int)HttpStatusCode.NoContent) sucIds.Add(id);
|
|
|
+ if (ret.StatusCode == HttpStatusCode.NoContent) sucIds.Add(id);
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<GroupList>(queryText: $"select value(c) from c join A0 in c.members where A0.id = '{id}' and A0.code='{schoolId}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{schoolId}") }))
|
|
|
{
|
|
|
scGroupLists.Add(item);
|
|
@@ -2340,7 +2340,7 @@ namespace TEAMModelOS.SDK
|
|
|
if (impStuds.Count == 0) return (null, null, null);
|
|
|
|
|
|
string queryText = $"SELECT VALUE c FROM c WHERE c.id IN ({string.Join(",", impStuds.Select(o => $"'{o}'"))})";
|
|
|
- await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
|
|
|
.GetItemQueryStreamIteratorSql(
|
|
|
queryText: queryText,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
|
|
@@ -2395,7 +2395,7 @@ namespace TEAMModelOS.SDK
|
|
|
.GetContainer(Constant.TEAMModelOS, "Student")
|
|
|
.ReplaceItemStreamAsync(stream, id, new PartitionKey($"Base-{schoolId}"));
|
|
|
|
|
|
- if (ret.Status == (int)HttpStatusCode.OK)
|
|
|
+ if (ret.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
sucStuds.Add(id);
|
|
|
}
|
|
@@ -2404,7 +2404,7 @@ namespace TEAMModelOS.SDK
|
|
|
impStuds.Remove(id);
|
|
|
errorIds.Add(id);
|
|
|
await _dingDing.SendBotMsg(
|
|
|
- $"IES5,{_option.Location},StudentController/removeStudentClassInfo(),CosmosDB response:{ret.Status}\nBase-{schoolId},id:{id}",
|
|
|
+ $"IES5,{_option.Location},StudentController/removeStudentClassInfo(),CosmosDB response:{ret.StatusCode}\nBase-{schoolId},id:{id}",
|
|
|
GroupNames.醍摩豆服務運維群組);
|
|
|
}
|
|
|
}
|
|
@@ -2430,7 +2430,7 @@ namespace TEAMModelOS.SDK
|
|
|
|
|
|
Dictionary<string, JsonElement> dicClassInfo = new Dictionary<string, JsonElement>();
|
|
|
|
|
|
- await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
|
|
|
.GetItemQueryStreamIteratorSql(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.Content);
|
|
@@ -2562,7 +2562,7 @@ namespace TEAMModelOS.SDK
|
|
|
if (student.TryGetProperty("pw", out var tmpPw) && !"******".Equals($"{tmpPw}"))
|
|
|
{
|
|
|
var response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReadItemStreamAsync(id.GetString(), new PartitionKey($"Base-{schoolId}"));
|
|
|
- if (response.Status == 200)
|
|
|
+ if (response.StatusCode == HttpStatusCode.OK)
|
|
|
{
|
|
|
var rjson = await JsonDocument.ParseAsync(response.Content);
|
|
|
rjson.RootElement.TryGetProperty("salt", out JsonElement _salt);
|
|
@@ -2646,7 +2646,7 @@ namespace TEAMModelOS.SDK
|
|
|
var classInfo = await getClassInfoUseId(_azureCosmos, _dingDing, _option, schoolId, classStuds.Keys.ToList());
|
|
|
|
|
|
//準備查詢db資料
|
|
|
- CosmosContainer cosmosContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
|
|
|
+ Container cosmosContainer = _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student");
|
|
|
|
|
|
//查要移除教室或是沒加入教室的學生
|
|
|
|
|
@@ -2691,7 +2691,7 @@ namespace TEAMModelOS.SDK
|
|
|
|
|
|
List<JsonElement> listStudent = new List<JsonElement>();
|
|
|
|
|
|
- await foreach (Response responseItem in cosmosContainer
|
|
|
+ await foreach (var responseItem in cosmosContainer
|
|
|
.GetItemQueryStreamIteratorSql(
|
|
|
queryText: queryText,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
|
|
@@ -2989,7 +2989,7 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
var ret = await cosmosContainer.ReplaceItemStreamAsync(memoryStream, id, new PartitionKey($"Base-{schoolId}"));
|
|
|
//將更新完的id從字典內移除,保留沒查到的。
|
|
|
- if (ret.Status == (int)HttpStatusCode.OK)
|
|
|
+ if (ret.StatusCode ==HttpStatusCode.OK)
|
|
|
{
|
|
|
nonexistentIds.Remove(id);
|
|
|
retStuds.Add(new { id, tmpData.gender, tmpData.mail, tmpData.imei, tmpData.mobile, tmpData.name, tmpData.picture, tmpData.year, tmpData.no, classId, classNo, className, gradeId, periodId, tmpData.irs });
|
|
@@ -3049,7 +3049,7 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
|
{
|
|
|
- if (ex.Status == (int)HttpStatusCode.Conflict) existId.Add(item.id);
|
|
|
+ if (ex.StatusCode == HttpStatusCode.Conflict) existId.Add(item.id);
|
|
|
else exceptions.Add(ex);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -3085,7 +3085,7 @@ namespace TEAMModelOS.SDK
|
|
|
|
|
|
string queryText = $"SELECT c.id, c.no FROM c WHERE c.classId = '{classId}' AND c.code = 'Base-{schoolId}'";
|
|
|
if (nos != null) queryText += $"AND c.no IN ({string.Join(",", nos.Select(o => $"'{o}'"))})";
|
|
|
- await foreach (Response item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
|
|
|
.GetItemQueryStreamIteratorSql(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.Content);
|
|
@@ -3121,7 +3121,7 @@ namespace TEAMModelOS.SDK
|
|
|
.GetContainer(Constant.TEAMModelOS, "School")
|
|
|
.ReadItemStreamAsync(schoolId, new PartitionKey("Base"));
|
|
|
|
|
|
- if (response.Status != (int)HttpStatusCode.OK) return null;
|
|
|
+ if (response.StatusCode != HttpStatusCode.OK) return null;
|
|
|
|
|
|
using Stream stream = response.Content;
|
|
|
var jsonDoc = await JsonDocument.ParseAsync(stream);
|