|
@@ -786,14 +786,9 @@ namespace TEAMModelOS.SDK
|
|
|
tmpStudInfo.gradeId = classNoId[stud.Value.classNo + "_" + stud.Value.classYear].gradeId;
|
|
|
tmpStudInfo.periodId = classNoId[stud.Value.classNo + "_" + stud.Value.classYear].periodId;
|
|
|
}
|
|
|
-
|
|
|
- if (!string.IsNullOrWhiteSpace(stud.Value.imei))
|
|
|
- {
|
|
|
- writerNew.WriteString("imei", stud.Value.imei);
|
|
|
- }
|
|
|
- else {
|
|
|
- writerNew.WriteNull("imei");
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (string.IsNullOrWhiteSpace(stud.Value.no))
|
|
|
{
|
|
|
writerNew.WriteNull("no");
|
|
@@ -819,7 +814,11 @@ namespace TEAMModelOS.SDK
|
|
|
|
|
|
writerNew.WriteEndObject();
|
|
|
writerNew.Flush();
|
|
|
-
|
|
|
+ if (!string.IsNullOrWhiteSpace(stud.Value.imei))
|
|
|
+ {
|
|
|
+ Imei imei = new Imei { id = stud.Value.imei, code = "Imei", stuid = stud.Key, school = schoolId };
|
|
|
+ await cosmosContainer.UpsertItemAsync(imei, new PartitionKey($"Imei"));
|
|
|
+ }
|
|
|
var response = await cosmosContainer.CreateItemStreamAsync(memoryStream, new PartitionKey($"Base-{schoolId}"));
|
|
|
|
|
|
if (response.Status == (int)HttpStatusCode.Created)
|
|
@@ -856,10 +855,6 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
student.periodId = stud.Value.periodId;
|
|
|
}
|
|
|
- if (!string.IsNullOrWhiteSpace(stud.Value.imei))
|
|
|
- {
|
|
|
- student.imei = stud.Value.imei;
|
|
|
- }
|
|
|
if (!isUpPwDone)
|
|
|
{
|
|
|
student.pw = stud.Value.pw;
|
|
@@ -953,8 +948,6 @@ namespace TEAMModelOS.SDK
|
|
|
writer.WriteNull("mail");
|
|
|
writer.WriteNull("mobile");
|
|
|
writer.WriteNull("country");
|
|
|
- if (string.IsNullOrWhiteSpace(studCreateInfo.imei)) writer.WriteNull("imei");
|
|
|
- else writer.WriteString("periodId", studCreateInfo.imei);
|
|
|
//Password,若沒給則使用學號當密碼
|
|
|
string salt = Utils.CreatSaltString(8);
|
|
|
string hashPw = string.IsNullOrWhiteSpace(studCreateInfo.pw)
|
|
@@ -1000,7 +993,13 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
writer.WriteEndObject();
|
|
|
writer.Flush();
|
|
|
-
|
|
|
+ if (!string.IsNullOrWhiteSpace(studCreateInfo.imei))
|
|
|
+ {
|
|
|
+ Imei imei = new Imei { id = studCreateInfo.imei, code = "Imei", stuid = studCreateInfo.id, school = schoolId };
|
|
|
+ await _azureCosmos
|
|
|
+ .GetCosmosClient()
|
|
|
+ .GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(imei, new PartitionKey($"Imei"));
|
|
|
+ }
|
|
|
var response = await _azureCosmos
|
|
|
.GetCosmosClient()
|
|
|
.GetContainer(Constant.TEAMModelOS, "Student")
|
|
@@ -1255,6 +1254,13 @@ namespace TEAMModelOS.SDK
|
|
|
List<(string id, string name, string picture, int year, string no, string periodId, string irs, string imei, List<StudentGuardian> guardians)> notJoinClassStuds =
|
|
|
new List<(string id, string name, string picture, int year, string no, string periodId, string irs, string imei, List<StudentGuardian> guardians)>();
|
|
|
|
|
|
+
|
|
|
+ List<Imei> imeis= new List<Imei>();
|
|
|
+ string imeiQueryText = $"SELECT * FROM c WHERE c.code = '{schoolId}'";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student")
|
|
|
+ .GetItemQueryIterator<Imei>(queryText:imeiQueryText,requestOptions:new QueryRequestOptions { PartitionKey= new PartitionKey("Imei")})){
|
|
|
+ imeis.Add(item);
|
|
|
+ }
|
|
|
string queryText = $"SELECT * FROM c WHERE c.code = 'Base-{schoolId}'";
|
|
|
|
|
|
//回傳用ContinuationToken
|
|
@@ -1290,6 +1296,8 @@ namespace TEAMModelOS.SDK
|
|
|
guardians= guardians.FindAll(x => !string.IsNullOrWhiteSpace(x.mobile)) ;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ var imeiObj= imeis.Find(x => x.stuid.Equals(acc.GetProperty("id").GetString()));
|
|
|
if (string.IsNullOrWhiteSpace(classId))
|
|
|
{
|
|
|
notJoinClassStuds.Add(
|
|
@@ -1301,7 +1309,7 @@ namespace TEAMModelOS.SDK
|
|
|
acc.GetProperty("no").GetString(),
|
|
|
acc.TryGetProperty("periodId", out JsonElement _periodId) && _periodId.ValueKind.Equals(JsonValueKind.String) ? _periodId.GetString() : null,
|
|
|
$"{irs}",
|
|
|
- acc.TryGetProperty("imei", out JsonElement _imei) && _imei.ValueKind.Equals(JsonValueKind.String) ? _imei.GetString() : null,
|
|
|
+ imeiObj?.id,//imei
|
|
|
guardians
|
|
|
)
|
|
|
);
|
|
@@ -1318,7 +1326,7 @@ namespace TEAMModelOS.SDK
|
|
|
acc.GetProperty("year").GetInt32(),
|
|
|
acc.GetProperty("no").GetString(), acc.TryGetProperty("periodId", out JsonElement _periodId) && _periodId.ValueKind.Equals(JsonValueKind.String) ? _periodId.GetString() : null,
|
|
|
$"{irs}",
|
|
|
- acc.TryGetProperty("imei", out JsonElement _imei) && _imei.ValueKind.Equals(JsonValueKind.String) ? _imei.GetString() : null,
|
|
|
+ imeiObj?.id,//imei
|
|
|
guardians
|
|
|
)
|
|
|
);
|
|
@@ -1334,9 +1342,8 @@ namespace TEAMModelOS.SDK
|
|
|
acc.GetProperty("picture").GetString(),
|
|
|
acc.GetProperty("year").GetInt32(),
|
|
|
acc.GetProperty("no").GetString(), acc.TryGetProperty("periodId",out JsonElement _periodId)&& _periodId.ValueKind.Equals(JsonValueKind.String) ? _periodId.GetString() : null,
|
|
|
- $"{irs}"
|
|
|
- ,
|
|
|
- acc.TryGetProperty("imei", out JsonElement _imei) && _imei.ValueKind.Equals(JsonValueKind.String) ? _imei.GetString() : null,
|
|
|
+ $"{irs}" ,
|
|
|
+ imeiObj?.id,//imei
|
|
|
guardians
|
|
|
)
|
|
|
}
|
|
@@ -2151,7 +2158,13 @@ namespace TEAMModelOS.SDK
|
|
|
|
|
|
writer.WriteEndObject();
|
|
|
writer.Flush();
|
|
|
-
|
|
|
+ if (!string.IsNullOrWhiteSpace(studentInfos[id].imei))
|
|
|
+ {
|
|
|
+ Imei imei = new Imei { id = studentInfos[id].imei, code = "Imei", stuid = id, school = schoolId };
|
|
|
+ await _azureCosmos
|
|
|
+ .GetCosmosClient()
|
|
|
+ .GetContainer(Constant.TEAMModelOS, "Student").UpsertItemAsync(imei, new PartitionKey($"Imei"));
|
|
|
+ }
|
|
|
try
|
|
|
{
|
|
|
var ret = await cosmosContainer.ReplaceItemStreamAsync(memoryStream, id, new PartitionKey($"Base-{schoolId}"));
|