|
@@ -228,11 +228,6 @@ namespace TEAMModelOS.Controllers
|
|
|
private async Task<(List<object> studs, Dictionary<string ,List<string>> classDuplNos, List<string> errorIds)> upsertStudents(
|
|
|
string schoolId,
|
|
|
JsonElement.ArrayEnumerator students)
|
|
|
-
|
|
|
- //Dictionary<string, (string name, string no, string year, string salt, string pw, string classNo, string className)> studs,
|
|
|
- //Dictionary<string, List<(string id, string no)>> impClassStudNo,
|
|
|
- //Dictionary<string, (string classId, string className, string periodId, string gradeId)> classNoId,
|
|
|
- //Dictionary<string, List<(string id, string no)>> classStudNo)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -293,7 +288,7 @@ namespace TEAMModelOS.Controllers
|
|
|
//並行處理
|
|
|
foreach (var stud in sortedImpData.studs)
|
|
|
{
|
|
|
- //這邊一樣要確認已存在和欲加入還有欲修改的座號,到這邊已不會出現輸入的學生座號有重複的狀況。
|
|
|
+ //這邊一樣要確認已存在和欲加入還有欲修改的座號。
|
|
|
//欲修改的不會有重複
|
|
|
string classId = null;
|
|
|
bool isContinue = false;
|
|
@@ -1670,7 +1665,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var classStuds
|
|
|
= new Dictionary<string, List<(string id, string salt, string pw, string name, string year, string pic, string gender, string mail, string mobile, string classId, string no)>>();
|
|
|
//紀錄教室"輸入"的學生座號是否有重複
|
|
|
- var classDuplNo = new Dictionary<string, List<string>>();
|
|
|
+ var impClassDuplNo = new Dictionary<string, List<string>>();
|
|
|
//紀錄不存在的學生id
|
|
|
var nonexistentIds = new List<string>();
|
|
|
//紀錄跟現有雲端學生座號重複的
|
|
@@ -1774,9 +1769,8 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
var duplicateNo = classStuds.ElementAt(ii).Value.GroupBy(o => o.no).Where(o => o.Count() > 1).Select(o => o.Key).ToList();
|
|
|
|
|
|
- classDuplNo.Add(classStuds.ElementAt(ii).Key, duplicateNo);
|
|
|
-
|
|
|
var wrongStuds = classStuds.ElementAt(ii).Value.Where(o => duplicateNo.Contains(o.no)).Select(o => o).ToList();
|
|
|
+ impClassDuplNo.Add(classStuds.ElementAt(ii).Key, wrongStuds.Select(o => o.id).ToList());
|
|
|
|
|
|
wrongStuds.ForEach(o => { classStuds.ElementAt(ii).Value.Remove(o); nonexistentIds.Remove(o.id); });
|
|
|
classStuds[classStuds.ElementAt(ii).Key] = classStuds.ElementAt(ii).Value;
|
|
@@ -1915,7 +1909,13 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
break;
|
|
|
case bool _ when element.Name.Equals("no", StringComparison.Ordinal):
|
|
|
- if (string.IsNullOrWhiteSpace(studentInfos[id].no))
|
|
|
+ //移除座號的話會給空的
|
|
|
+ if (studentInfos[id].no.Length == 0)
|
|
|
+ {
|
|
|
+ writer.WriteNull("no");
|
|
|
+ tmpData.no = null;
|
|
|
+ }
|
|
|
+ else if (string.IsNullOrWhiteSpace(studentInfos[id].no))
|
|
|
{
|
|
|
element.WriteTo(writer);
|
|
|
tmpData.no = element.Value.GetString();
|
|
@@ -1941,8 +1941,6 @@ namespace TEAMModelOS.Controllers
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //將座號寫到Json內
|
|
|
writer.WriteString("no", studentInfos[id].no);
|
|
|
}
|
|
|
break;
|
|
@@ -1998,9 +1996,9 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- errorClassId.ForEach(o => classDuplNo.Remove(o));
|
|
|
+ errorClassId.ForEach(o => impClassDuplNo.Remove(o));
|
|
|
|
|
|
- return (retStuds, classDuplNo.Where(o => o.Value.Count != 0).ToDictionary(o => o.Key, o => o.Value), nonexistentIds, errorIds, errorNos, errorClassId);
|
|
|
+ return (retStuds, impClassDuplNo.Where(o => o.Value.Count != 0).ToDictionary(o => o.Key, o => o.Value), nonexistentIds, errorIds, errorNos, errorClassId);
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
|
{
|