|
@@ -100,7 +100,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
}
|
|
|
group = group.Where(g => !string.IsNullOrEmpty(g.id)).ToList();
|
|
|
- groups.Add((sId, group.Select(s=>s.id).ToList(), group.Select(s => s.name).ToList()));
|
|
|
+ groups.Add((sId, group.Select(s => s.id).ToList(), group.Select(s => s.name).ToList()));
|
|
|
}
|
|
|
//var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS("hbcn", BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
|
|
|
var gr = groups.Select(o => new
|
|
@@ -238,7 +238,7 @@ namespace TEAMModelOS.Controllers
|
|
|
string json = "所有老师(未分组)";
|
|
|
study.targets.Add(json.ToJsonString().ToObject<JsonElement>());
|
|
|
//study.targets.Add("所有老师(未分组)");
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -249,7 +249,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
//处理区级target
|
|
|
string sName = pa.sName + "-" + name;
|
|
|
- allName.Add(sName);
|
|
|
+ allName.Add(sName);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -364,7 +364,7 @@ namespace TEAMModelOS.Controllers
|
|
|
//区级Id
|
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- // List<string> baseIds = await getId(client, id.GetString());
|
|
|
+ // List<string> baseIds = await getId(client, id.GetString());
|
|
|
List<object> studies = new();
|
|
|
|
|
|
var query = $"select c.id,c.img,c.name,c.type,c.startTime,c.endTime,c.presenter,c.topic,c.address,c.owner,c.school from c ";
|
|
@@ -404,57 +404,85 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
if (!requert.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- List<string> baseIds = await getId(client, areaId.GetString());
|
|
|
+ List<(string id, string name)> baseIds = await getId(client, areaId.GetString());
|
|
|
List<Study> studies = new();
|
|
|
List<(string id, string name)> ps = await getInfo(client, areaId.GetString());
|
|
|
//List<string> aName = new();
|
|
|
var query = $"select value(c) from c where c.pId = '{id}'";
|
|
|
- foreach (string code in baseIds)
|
|
|
+ foreach ((string code,string name) in baseIds)
|
|
|
{
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Study>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Study-{code}") }))
|
|
|
{
|
|
|
studies.Add(item);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- List<Survey> trSurveys = new List<Survey>();
|
|
|
- List<ExamLite> trExams = new List<ExamLite>();
|
|
|
+
|
|
|
+ List<(List<TmdInfo> teac, Survey sur)> trSurveys = new List<(List<TmdInfo> teac, Survey sur)>();
|
|
|
+ List<(List<TmdInfo> teac, ExamLite examLite)> trExams = new List<(List<TmdInfo> teac, ExamLite examLite)>();
|
|
|
List<(List<TmdInfo> teac, Study stu)> moreInfo = new List<(List<TmdInfo> teac, Study stu)>();
|
|
|
- foreach (Study study in studies) {
|
|
|
+ List<(List<TmdInfo> teac, TeacherWork tw)> works = new List<(List<TmdInfo> teac, TeacherWork tw)>();
|
|
|
+ foreach (Study study in studies)
|
|
|
+ {
|
|
|
(List<TmdInfo> tchList, _) = await TriggerStuActivity.GetTchList(client, _dingDing, study.tchLists, study.school);
|
|
|
if (!string.IsNullOrEmpty(study.surveyId))
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Survey>(queryText: $"select value(c) from c where c.id = '{study.surveyId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{study.school}") }))
|
|
|
+
|
|
|
+ var sresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(study.surveyId, new PartitionKey($"Survey-{study.school}"));
|
|
|
+ if (sresponse.Status == 200)
|
|
|
{
|
|
|
- trSurveys.Add(item);
|
|
|
+ using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
|
+ Survey surs = json.ToObject<Survey>();
|
|
|
+ trSurveys.Add((tchList, surs));
|
|
|
}
|
|
|
}
|
|
|
- if (!string.IsNullOrEmpty(study.examId)) {
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamLite>(queryText: $"select value(c) from c where c.id = '{study.examId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamLite-{study.school}") }))
|
|
|
+ if (!string.IsNullOrEmpty(study.examId))
|
|
|
+ {
|
|
|
+ var sresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(study.examId, new PartitionKey($"ExamLite-{study.school}"));
|
|
|
+ if (sresponse.Status == 200)
|
|
|
{
|
|
|
- trExams.Add(item);
|
|
|
+ using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
|
+ ExamLite lite = json.ToObject<ExamLite>();
|
|
|
+ trExams.Add((tchList, lite));
|
|
|
}
|
|
|
}
|
|
|
- moreInfo.Add((tchList,study));
|
|
|
- } ;
|
|
|
- var survey = trSurveys.Select(s => new {
|
|
|
- count = s.answers.Count,
|
|
|
- ansCount = s.answers.Count,
|
|
|
+ if (!string.IsNullOrEmpty(study.workId))
|
|
|
+ {
|
|
|
+ var sresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(study.examId, new PartitionKey($"TeacherWork-{study.school}"));
|
|
|
+ if (sresponse.Status == 200)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
|
+ TeacherWork work = json.ToObject<TeacherWork>();
|
|
|
+ works.Add((tchList, work));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ moreInfo.Add((tchList, study));
|
|
|
+ };
|
|
|
+ var survey = trSurveys.Select(s => new
|
|
|
+ {
|
|
|
+ count = s.teac.Count,
|
|
|
+ ansCount = s.sur.answers.Count,
|
|
|
+ });
|
|
|
+ var twork = works.Select(s => new
|
|
|
+ {
|
|
|
+ count = s.teac.Count,
|
|
|
+ ansCount = s.tw.teachers.Where(h => !string.IsNullOrEmpty(h.hw)).ToList().Count,
|
|
|
});
|
|
|
- var exam = trExams.Select(s => new {
|
|
|
- count = s.teachers.Count,
|
|
|
- ansCount = s.teachers.Where(h => h.answer.Count > 0).ToList().Count,
|
|
|
+ var exam = trExams.Select(s => new
|
|
|
+ {
|
|
|
+ count = s.teac.Count,
|
|
|
+ ansCount = s.examLite.teachers.Where(h => h.answer.Count > 0).ToList().Count,
|
|
|
});
|
|
|
- var info = studies.Select(s => new {
|
|
|
- s.id,
|
|
|
- name = ps.FirstOrDefault(c => c.id == s.id).name,
|
|
|
- count = s.teachers.Count,
|
|
|
+ var info = moreInfo.Select(s => new
|
|
|
+ {
|
|
|
+ s.stu.id,
|
|
|
+ name = ps.FirstOrDefault(c => c.id == s.stu.id).name,
|
|
|
+ count = s.teac.Count,
|
|
|
//hwCount = s.teachers.Where(h => h.hwTime > 0).ToList().Count,
|
|
|
- signCount = s.teachers.Where(h => h.signTime > 0).ToList().Count,
|
|
|
- lateCount = s.teachers.Where(h =>!string.IsNullOrEmpty(h.sign) && h.sign.Equals("1")).ToList().Count,
|
|
|
- acount = s.teachers.Where(h => h.aTime > 0).ToList().Count
|
|
|
+ signCount = s.stu.teachers.Where(h => h.signTime > 0).ToList().Count,
|
|
|
+ lateCount = s.stu.teachers.Where(h => !string.IsNullOrEmpty(h.sign) && h.sign.Equals("1")).ToList().Count,
|
|
|
+ acount = s.stu.teachers.Where(h => h.aTime > 0).ToList().Count
|
|
|
});
|
|
|
- return Ok(new { survey,exam, info, studies = moreInfo.Select(m => new { m.teac,m.stu}) });
|
|
|
+ return Ok(new { survey, exam, info, studies = moreInfo.Select(m => new { m.teac, m.stu }) });
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -478,18 +506,18 @@ namespace TEAMModelOS.Controllers
|
|
|
List<object> votes = new();
|
|
|
//List<string> aName = new();
|
|
|
var query = $"select c.id,c.name,c.startTime,c.progress,c.owner,c.school from c ";
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{id}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{id}") }))
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- 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())
|
|
|
- {
|
|
|
- votes.Add(obj.ToObject<object>());
|
|
|
- }
|
|
|
+ votes.Add(obj.ToObject<object>());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return Ok(new { votes });
|
|
|
}
|
|
@@ -511,20 +539,20 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
if (!requert.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- List<string> baseIds = await getId(client, areaId.GetString());
|
|
|
+ List<(string id, string name)> baseIds = await getId(client, areaId.GetString());
|
|
|
//List<object> votes = new();
|
|
|
- List<(string id, string name)> ps = await getInfo(client, areaId.GetString()) ;
|
|
|
+ List<(string id, string name)> ps = await getInfo(client, areaId.GetString());
|
|
|
//List<string> aName = new();
|
|
|
List<Vote> votes = new List<Vote>();
|
|
|
Vote vote = null;
|
|
|
- List<(string code,string url, int count)> recordUrl = new List<(string code, string url, int count)>();
|
|
|
+ List<(string code,string name, string url, int count)> recordUrl = new List<(string code, string name, string url, int count)>();
|
|
|
var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.GetString(), new PartitionKey($"Vote-{areaId}"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
vote = json.ToObject<Vote>();
|
|
|
var query = $"select c.tchLists,c.recordUrl from c where c.pId = '{id}'";
|
|
|
- foreach (string code in baseIds)
|
|
|
+ foreach ((string code, string name) in baseIds)
|
|
|
{
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{code}") }))
|
|
|
{
|
|
@@ -537,15 +565,15 @@ namespace TEAMModelOS.Controllers
|
|
|
JsonElement account = accounts.Current;
|
|
|
List<string> tcs = account.GetProperty("tchLists").ToObject<List<string>>();
|
|
|
(List<TmdInfo> tchList, _) = await TriggerStuActivity.GetTchList(client, _dingDing, tcs, code);
|
|
|
- recordUrl.Add((code,account.GetProperty("recordUrl").GetString(),tchList.Count));
|
|
|
+ recordUrl.Add((code,name, account.GetProperty("recordUrl").GetString(), tchList.Count));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//var info = ps.Select(p => new { p.id, p.name });
|
|
|
- return Ok(new { vote , code = recordUrl.Select(r => new { r.code, r.url,r.count }) });
|
|
|
+ return Ok(new { vote, code = recordUrl.Select(r => new { r.code,r.name, r.url, r.count }) });
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -570,19 +598,19 @@ namespace TEAMModelOS.Controllers
|
|
|
// List<string> aName = new();
|
|
|
var query = $"select c.id,c.name,c.startTime,c.progress,c.sType,c.owner,c.school from c ";
|
|
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{id}") }))
|
|
|
- {
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{id}") }))
|
|
|
+ {
|
|
|
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ 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())
|
|
|
- {
|
|
|
- surveys.Add(obj.ToObject<object>());
|
|
|
- }
|
|
|
+ surveys.Add(obj.ToObject<object>());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return Ok(new { surveys });
|
|
|
}
|
|
@@ -603,17 +631,17 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
if (!requert.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- List<string> baseIds = await getId(client, areaId.GetString());
|
|
|
+ List<(string id, string name)> baseIds = await getId(client, areaId.GetString());
|
|
|
List<object> surveys = new();
|
|
|
Survey survey = null;
|
|
|
- List<(string code, string url, int count)> recordUrl = new List<(string code, string url, int count)>();
|
|
|
+ List<(string code, string name,string url, int count)> recordUrl = new List<(string code, string name,string url, int count)>();
|
|
|
var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.GetString(), new PartitionKey($"Survey-{areaId}"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
survey = json.ToObject<Survey>();
|
|
|
var query = $"select c.tchLists,c.recordUrl from c where c.pId = '{id}'";
|
|
|
- foreach (string code in baseIds)
|
|
|
+ foreach ((string code, string name) in baseIds)
|
|
|
{
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{code}") }))
|
|
|
{
|
|
@@ -626,7 +654,7 @@ namespace TEAMModelOS.Controllers
|
|
|
JsonElement account = accounts.Current;
|
|
|
List<string> tcs = account.GetProperty("tchLists").ToObject<List<string>>();
|
|
|
(List<TmdInfo> tchList, _) = await TriggerStuActivity.GetTchList(client, _dingDing, tcs, code);
|
|
|
- recordUrl.Add((code,account.GetProperty("recordUrl").GetString(),tchList.Count));
|
|
|
+ recordUrl.Add((code, name,account.GetProperty("recordUrl").GetString(), tchList.Count));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -634,7 +662,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
|
|
|
//var info = ps.Select(p => new { p.id, p.name });
|
|
|
- return Ok(new { survey, code = recordUrl.Select(r => new { r.code,r.url,r.count }) });
|
|
|
+ return Ok(new { survey, code = recordUrl.Select(r => new { r.code,r.name, r.url, r.count }) });
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -660,19 +688,19 @@ namespace TEAMModelOS.Controllers
|
|
|
var query = $"select c.id,c.name,c.createTime,c.sType,c.owner,c.school from c ";
|
|
|
|
|
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamLite-{id}") }))
|
|
|
- {
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamLite-{id}") }))
|
|
|
+ {
|
|
|
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ 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())
|
|
|
- {
|
|
|
- exams.Add(obj.ToObject<object>());
|
|
|
- }
|
|
|
+ exams.Add(obj.ToObject<object>());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return Ok(new { exams });
|
|
|
}
|
|
@@ -694,12 +722,12 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
if (!requert.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- List<string> baseIds = await getId(client, areaId.GetString());
|
|
|
+ List<(string id, string name)> baseIds = await getId(client, areaId.GetString());
|
|
|
List<object> exams = new();
|
|
|
List<(string id, string name)> ps = await getInfo(client, areaId.GetString());
|
|
|
//List<string> aName = new();
|
|
|
var query = $"select c.school,c.teachers from c where c.acId = '{id}'";
|
|
|
- foreach (string code in baseIds)
|
|
|
+ foreach ((string code, string name) in baseIds)
|
|
|
{
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TrExam-{code}") }))
|
|
|
{
|
|
@@ -714,7 +742,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
var info = ps.Select(p => new { p.id, p.name });
|
|
|
- return Ok(new {info,exams });
|
|
|
+ return Ok(new { info, exams });
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -791,7 +819,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
trVote.progress = "going";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (pa.gName.Count == 0)
|
|
|
{
|
|
|
string sName = pa.sName + "-" + "所有老师(未分组)";
|
|
@@ -802,13 +830,13 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var tn = pa.gName.ToJsonString().ToObject<List<JsonElement>>();
|
|
|
+ var tn = pa.gName.ToJsonString().ToObject<List<JsonElement>>();
|
|
|
trVote.targets = tn;
|
|
|
foreach (string name in pa.gName)
|
|
|
{
|
|
|
//处理区级target
|
|
|
string sName = pa.sName + "-" + name;
|
|
|
- allName.Add(sName);
|
|
|
+ allName.Add(sName);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -832,7 +860,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
atn.Add(agn.ToObject<JsonElement>());
|
|
|
}*/
|
|
|
- areaVote.targets =atn;
|
|
|
+ areaVote.targets = atn;
|
|
|
await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync(areaVote, new PartitionKey($"{areaVote.code}"));
|
|
|
var ids = votes.Select(s => new { s.id, s.school });
|
|
|
return Ok(new { id, ids, code = (int)HttpStatusCode.OK });
|
|
@@ -860,9 +888,10 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("pk", out JsonElement pk)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
var response = await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{pk}-{code}"));
|
|
|
- List<string> bascId = await getId(client,code.GetString());
|
|
|
+ List<(string id, string name)> bascId = await getId(client, code.GetString());
|
|
|
List<(string id, string name)> ids = new();
|
|
|
- foreach (string sId in bascId) {
|
|
|
+ foreach ((string sId, string name) in bascId)
|
|
|
+ {
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select c.id,c.code from c where c.pId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}-{sId}") }))
|
|
|
{
|
|
|
|
|
@@ -877,13 +906,14 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
if (ids.Count > 0)
|
|
|
{
|
|
|
foreach ((string s, string c) in ids)
|
|
|
{
|
|
|
- if (c.Contains("Study")) {
|
|
|
+ if (c.Contains("Study"))
|
|
|
+ {
|
|
|
var sresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(s.ToString(), new PartitionKey($"{c}"));
|
|
|
if (sresponse.Status == 200)
|
|
|
{
|
|
@@ -898,7 +928,7 @@ namespace TEAMModelOS.Controllers
|
|
|
await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(study.surveyId, new PartitionKey($"Survey-{study.school}"));
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(s.ToString(), new PartitionKey($"{c}"));
|
|
|
}
|
|
|
}
|
|
@@ -977,7 +1007,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
trSurvey.progress = "going";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (pa.gName.Count == 0)
|
|
|
{
|
|
|
string sName = pa.sName + "-" + "所有老师(未分组)";
|
|
@@ -1010,7 +1040,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // trSurvey.blob = SurveyService.getBlob(trSurvey.id);
|
|
|
+ // trSurvey.blob = SurveyService.getBlob(trSurvey.id);
|
|
|
await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync(trSurvey, new PartitionKey($"{trSurvey.code}"));
|
|
|
}
|
|
|
surveys.Add(trSurvey);
|
|
@@ -1091,7 +1121,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (string.IsNullOrEmpty(trExam.id))
|
|
|
{
|
|
|
trExam.id = Guid.NewGuid().ToString();
|
|
|
- // trExam.blob = ExamService.getBlob(trExam.id);
|
|
|
+ // trExam.blob = ExamService.getBlob(trExam.id);
|
|
|
await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(trExam, new PartitionKey($"{trExam.code}"));
|
|
|
}
|
|
|
else
|
|
@@ -1114,11 +1144,11 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
}
|
|
|
|
|
|
- private async Task<List<string>> getId(CosmosClient client, string id)
|
|
|
+ private async Task<List<(string id, string name)>> getId(CosmosClient client, string id)
|
|
|
{
|
|
|
//获取区级以下所有学校编码和基础信息
|
|
|
- List<string> baseIds = new();
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.areaId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ List<(string id,string name)> baseIds = new();
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.name from c where c.areaId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1127,7 +1157,7 @@ namespace TEAMModelOS.Controllers
|
|
|
while (accounts.MoveNext())
|
|
|
{
|
|
|
JsonElement account = accounts.Current;
|
|
|
- baseIds.Add(account.GetProperty("id").GetString());
|
|
|
+ baseIds.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -1163,12 +1193,12 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
string json = "所有老师(未分组)";
|
|
|
trExam.targets.Add(json.ToJsonString().ToObject<JsonElement>());
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var tn = pa.gName.ToJsonString().ToObject<List<JsonElement>>();
|
|
|
- trExam.targets = tn;
|
|
|
+ trExam.targets = tn;
|
|
|
|
|
|
}
|
|
|
return Task.FromResult(trExam);
|
|
@@ -1208,7 +1238,8 @@ namespace TEAMModelOS.Controllers
|
|
|
return Task.FromResult(work);
|
|
|
}
|
|
|
|
|
|
- private async Task<List<(string id, string name)>> getInfo(CosmosClient client, string id) {
|
|
|
+ private async Task<List<(string id, string name)>> getInfo(CosmosClient client, string id)
|
|
|
+ {
|
|
|
List<(string id, string name)> scInfos = new List<(string id, string name)>();
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.name from c where c.areaId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
{
|