|
@@ -88,7 +88,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
return Ok(new { error = ResponseCode.DATA_EXIST, V = "课程编码已经存在!" });
|
|
@@ -98,12 +98,12 @@ namespace TEAMModelOS.Controllers
|
|
|
CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, school = course.school, creatorId = course.creatorId };
|
|
|
courseChange.addClass = course.schedule.Select(x => x.classId).ToList();
|
|
|
courseChange.addList = course.schedule.Select(x => x.stulist).ToList();
|
|
|
- course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
|
|
|
+ course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
return Ok(new { error = ResponseCode.DATA_EXIST, V = "课程编码已经存在!" });
|
|
@@ -117,7 +117,7 @@ namespace TEAMModelOS.Controllers
|
|
|
messageBlob.ApplicationProperties.Add("name", "Course");
|
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
|
|
|
- course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
|
|
|
+ course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -126,7 +126,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
|
|
|
- Course odlCourse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Course>(course.id, new PartitionKey($"Course-{code}"));
|
|
|
+ Course odlCourse = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<Course>(course.id, new PartitionKey($"Course-{code}"));
|
|
|
CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, school = code };
|
|
|
var oldCls = odlCourse.schedule.Select(x => x.classId).ToList();
|
|
|
var oldLst = odlCourse.schedule.Select(x => x.stulist).ToList();
|
|
@@ -168,7 +168,7 @@ namespace TEAMModelOS.Controllers
|
|
|
courseChange.addList = addLst;
|
|
|
courseChange.delClass = delCls;
|
|
|
courseChange.delList = delLst;
|
|
|
- course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
|
|
|
+ course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
|
|
|
var messageBlob = new ServiceBusMessage(courseChange.ToJsonString()); ;
|
|
|
messageBlob.ApplicationProperties.Add("name", "Course");
|
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
@@ -176,7 +176,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Course odlCourse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Course>(course.id, new PartitionKey($"Course-{code}"));
|
|
|
+ Course odlCourse = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Course>(course.id, new PartitionKey($"Course-{code}"));
|
|
|
CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, creatorId = code };
|
|
|
var oldCls = odlCourse.schedule.Select(x => x.classId).ToList();
|
|
|
var oldLst = odlCourse.schedule.Select(x => x.stulist).ToList();
|
|
@@ -218,7 +218,7 @@ namespace TEAMModelOS.Controllers
|
|
|
courseChange.addList = addLst;
|
|
|
courseChange.delClass = delCls;
|
|
|
courseChange.delList = delLst;
|
|
|
- course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
|
|
|
+ course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
|
|
|
var messageBlob = new ServiceBusMessage(courseChange.ToJsonString()); ;
|
|
|
messageBlob.ApplicationProperties.Add("name", "Course");
|
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
@@ -250,7 +250,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
var query = $"SELECT A0.room,A0.classId,A0.teacherId,A0.stulist,A0.time FROM c join A0 in c.schedule join A1 in A0.time where A0.teacherId = '{tId}'and A1.id = '{timeId}' and A1.week = '{week}' ";
|
|
|
List<Schedule> teachers = new();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
{
|
|
|
using var jsonCheck = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (jsonCheck.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -269,7 +269,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
var queryClass = $"SELECT A0.room,A0.classId,A0.teacherId,A0.stulist,A0.time FROM c join A0 in c.schedule join A1 in A0.time where A1.id = '{timeId}' and A1.week = '{week}' and (A0.classId = '{cId}' or A0.stulist = '{cId}')";
|
|
|
List<Schedule> courses = new();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
{
|
|
|
using var jsonCheck = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (jsonCheck.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -326,7 +326,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
if (!string.IsNullOrEmpty(school) && !string.IsNullOrEmpty($"{_studentId}"))
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
|
{
|
|
|
using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -356,14 +356,14 @@ namespace TEAMModelOS.Controllers
|
|
|
jwt.Payload.TryGetValue("picture", out object picture);
|
|
|
try
|
|
|
{
|
|
|
- TmdUser tmduser = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<TmdUser>(id, new PartitionKey("Base"));
|
|
|
+ Teacher teacher = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
|
{
|
|
|
if (ex.Status == 404)
|
|
|
{
|
|
|
//如果沒有,則初始化Teacher基本資料到Cosmos
|
|
|
- TmdUser tmduser = new TmdUser
|
|
|
+ Teacher teacher = new Teacher
|
|
|
{
|
|
|
id = id,
|
|
|
pk = "Base",
|
|
@@ -371,15 +371,16 @@ namespace TEAMModelOS.Controllers
|
|
|
name = name?.ToString(),
|
|
|
picture = picture?.ToString(),
|
|
|
//创建账号并第一次登录IES5则默认赠送1G
|
|
|
+ size = 1,
|
|
|
defaultSchool = null,
|
|
|
- schools = new List<TmdUser.School>(),
|
|
|
+ schools = new List<Teacher.School>(),
|
|
|
};
|
|
|
var container = _azureStorage.GetBlobContainerClient(id);
|
|
|
await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
|
|
|
- tmduser = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync<TmdUser>(tmduser, new PartitionKey("Base"));
|
|
|
+ teacher = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
|
|
|
}
|
|
|
}
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
|
|
|
{
|
|
|
using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -438,7 +439,7 @@ namespace TEAMModelOS.Controllers
|
|
|
json.TryGetProperty("tmdId", out JsonElement _tmdId);
|
|
|
if (!string.IsNullOrEmpty(school))
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
|
{
|
|
|
using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -459,7 +460,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
|
|
|
{
|
|
|
using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -570,7 +571,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
var queryNo = $"SELECT c.no FROM c where c.no ='{stuList.no}'";
|
|
|
List<string> noStus = new();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"{stuList.code}") }))
|
|
|
{
|
|
|
using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -584,7 +585,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryNo,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey("StuList") }))
|
|
|
{
|
|
|
using var jsonNo = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -632,7 +633,7 @@ namespace TEAMModelOS.Controllers
|
|
|
};
|
|
|
var query = $"SELECT distinct value(c) FROM c where c.id='{stuList.id}'";
|
|
|
List<StuList> odlStus = new List<StuList>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: query,
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: query,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{stuList.school}") }))
|
|
|
{
|
|
|
odlStus.Add(item);
|
|
@@ -651,7 +652,7 @@ namespace TEAMModelOS.Controllers
|
|
|
//判断新增名单成员不在已经存在的名单
|
|
|
foreach (var old in oldStu.students)
|
|
|
{
|
|
|
- if (old.id.Equals(stu.id) && old.code.Equals(stu.code))
|
|
|
+ if (old.id == stu.id && old.code == stu.code)
|
|
|
{
|
|
|
flag = true;
|
|
|
}
|
|
@@ -661,21 +662,6 @@ namespace TEAMModelOS.Controllers
|
|
|
change.stujoin.Add(stu);
|
|
|
}
|
|
|
}
|
|
|
- foreach (var old in oldStu.students) {
|
|
|
- bool flag = false;
|
|
|
- //判断已存在名单成员不在变更后的名单里
|
|
|
- foreach (var stu in stuList.students)
|
|
|
- {
|
|
|
- if (old.id.Equals(stu.id) && old.code.Equals(stu.code))
|
|
|
- {
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (flag == false)
|
|
|
- {
|
|
|
- change.stuleave.Add(old);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
if (stuList.tmids != null)
|
|
@@ -689,7 +675,7 @@ namespace TEAMModelOS.Controllers
|
|
|
//判断新增名单成员不在已经存在的名单
|
|
|
foreach (var old in oldStu.tmids)
|
|
|
{
|
|
|
- if (old.Equals(tmdid) )
|
|
|
+ if (old == tmdid)
|
|
|
{
|
|
|
flag = true;
|
|
|
}
|
|
@@ -699,22 +685,6 @@ namespace TEAMModelOS.Controllers
|
|
|
change.tmdjoin.Add(tmdid);
|
|
|
}
|
|
|
}
|
|
|
- foreach (var old in oldStu.tmids)
|
|
|
- {
|
|
|
- bool flag = false;
|
|
|
- //判断已存在名单成员不在变更后的名单里
|
|
|
- foreach (var tmdid in stuList.tmids)
|
|
|
- {
|
|
|
- if (old.Equals(tmdid) )
|
|
|
- {
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (flag == false)
|
|
|
- {
|
|
|
- change.tmdhleave.Add(old);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
if (change.tmdjoin.Count != 0 || change.tmdhleave.Count != 0 || change.stujoin.Count != 0 || change.stuleave.Count != 0)
|
|
@@ -725,7 +695,7 @@ namespace TEAMModelOS.Controllers
|
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
|
|
|
}
|
|
|
}
|
|
|
- stuList = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(stuList, new PartitionKey($"StuList-{stuList.school}"));
|
|
|
+ stuList = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").UpsertItemAsync(stuList, new PartitionKey($"StuList-{stuList.school}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -745,7 +715,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
var query = $"SELECT distinct value(c) FROM c where c.id='{stuList.id}'";
|
|
|
List<StuList> odlStus = new List<StuList>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: query,
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: query,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList") }))
|
|
|
{
|
|
|
odlStus.Add(item);
|
|
@@ -774,22 +744,6 @@ namespace TEAMModelOS.Controllers
|
|
|
change.stujoin.Add(stu);
|
|
|
}
|
|
|
}
|
|
|
- foreach (var old in oldStu.students)
|
|
|
- {
|
|
|
- bool flag = false;
|
|
|
- //判断已存在名单成员不在变更后的名单里
|
|
|
- foreach (var stu in stuList.students)
|
|
|
- {
|
|
|
- if (old.id.Equals(stu.id) && old.code.Equals(stu.code))
|
|
|
- {
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (flag == false)
|
|
|
- {
|
|
|
- change.stuleave.Add(old);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
if (stuList.tmids != null)
|
|
@@ -812,25 +766,12 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
change.tmdjoin.Add(tmdid);
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- foreach (var old in oldStu.tmids)
|
|
|
- {
|
|
|
- bool flag = false;
|
|
|
- //判断已存在名单成员不在变更后的名单里
|
|
|
- foreach (var tmdid in stuList.tmids)
|
|
|
- {
|
|
|
- if (old.Equals(tmdid))
|
|
|
- {
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (flag == false)
|
|
|
- {
|
|
|
- change.tmdhleave.Add(old);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
if (change.tmdjoin.Count != 0 || change.tmdhleave.Count != 0 || change.stujoin.Count != 0 || change.stuleave.Count != 0)
|
|
|
{
|
|
@@ -841,7 +782,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
stuList.code = "StuList";
|
|
|
- stuList = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(stuList, new PartitionKey($"StuList"));
|
|
|
+ stuList = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stuList, new PartitionKey($"StuList"));
|
|
|
}
|
|
|
return stuList;
|
|
|
}
|
|
@@ -869,7 +810,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var query = $"select c.id,c.name,c.students,c.tmids,c.periodId from c";
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -886,7 +827,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -932,7 +873,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var query = $"select c.id,c.name,c.students,c.tmids,c.no,c.code,c.scope,c.school,c.creatorId from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -949,7 +890,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -991,7 +932,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
/*List<string> classIds = new List<string>();
|
|
|
var query = $"select c.id from c join A0 in c.schedule where A0.teacherId = '{id}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1009,12 +950,12 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}*/
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuList-{code}"));
|
|
|
+ await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuList-{code}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuLis"));
|
|
|
- /*await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"StuLis"));
|
|
|
+ /*await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1078,7 +1019,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
{
|
|
|
//continuationToken = item.GetContinuationToken();
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1095,7 +1036,7 @@ namespace TEAMModelOS.Controllers
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
{
|
|
|
//continuationToken = item.GetContinuationToken();
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1111,7 +1052,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (requert.TryGetProperty("schoolId", out JsonElement schoolId))
|
|
|
{
|
|
|
var querySchool = $"select distinct c.code,c.id,c.no,c.name,c.period,c.subject,c.scope from c join A0 in c.schedule where A0.teacherId = '{code}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
|
|
|
{
|
|
|
//continuationToken = item.GetContinuationToken();
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1163,10 +1104,10 @@ namespace TEAMModelOS.Controllers
|
|
|
List<object> courses = new List<object>();
|
|
|
List<(string id, string name, string scope)> teacherCourse = new();
|
|
|
List<(string id, string name, string scope)> tcCourse = new();
|
|
|
- List<(string id, string name, string scope, List<(string id, string name, string type)> stuName)> ps = new();
|
|
|
+ List<(string id, string name,string scope,List<(string id, string name, string type)> stuName)> ps = new();
|
|
|
var query = $"select c.id,c.name,c.scope from c";
|
|
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1175,42 +1116,39 @@ namespace TEAMModelOS.Controllers
|
|
|
while (accounts.MoveNext())
|
|
|
{
|
|
|
JsonElement account = accounts.Current;
|
|
|
- teacherCourse.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(), account.GetProperty("scope").GetString()));
|
|
|
+ teacherCourse.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(),account.GetProperty("scope").GetString()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- foreach ((string s, string n, string sc) in teacherCourse)
|
|
|
+ foreach ((string s, string n,string sc) in teacherCourse)
|
|
|
{
|
|
|
- List<(string id, string name, string type)> sName = new();
|
|
|
+ List<(string id, string name,string type)> sName = new();
|
|
|
List<Schedule> schedules = new List<Schedule>();
|
|
|
var querySc = $"SELECT A0.room,A0.classId,A0.teacherId,A0.stulist,A0.time FROM c join A0 in c.schedule where c.id = '{s}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Schedule>(queryText: querySc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Schedule>(queryText: querySc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code.GetString()}") }))
|
|
|
{
|
|
|
schedules.Add(item);
|
|
|
}
|
|
|
- if (schedules.Count > 0)
|
|
|
+ var queryInfo = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.stulist}'"))})";
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
{
|
|
|
- var queryInfo = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.stulist}'"))})";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
+ 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)
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
{
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- sName.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(), "stuList"));
|
|
|
- }
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ sName.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(),"stuList"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- ps.Add((s, n, sc, sName));
|
|
|
+ ps.Add((s,n,sc, sName));
|
|
|
}
|
|
|
if (requert.TryGetProperty("schoolId", out JsonElement schoolId))
|
|
|
{
|
|
|
var querySchool = $"select distinct c.code,c.id,c.no,c.name,c.scope from c join A0 in c.schedule where A0.teacherId = '{code}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1227,43 +1165,40 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
List<Schedule> schedules = new List<Schedule>();
|
|
|
var querySc = $"SELECT A0.room,A0.classId,A0.teacherId,A0.stulist,A0.time FROM c join A0 in c.schedule where c.id = '{s}' and A0.teacherId = '{code}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Schedule>(queryText: querySc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Schedule>(queryText: querySc, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{schoolId.GetString()}") }))
|
|
|
{
|
|
|
schedules.Add(item);
|
|
|
}
|
|
|
- List<(string id, string name, string type)> sName = new();
|
|
|
- if (schedules.Count > 0)
|
|
|
+ List<(string id, string name,string type)> sName = new();
|
|
|
+ var queryInfo = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.stulist}'"))})";
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId.GetString()}") }))
|
|
|
{
|
|
|
- var queryInfo = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.stulist}'"))})";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryInfo, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId.GetString()}") }))
|
|
|
+ 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)
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
{
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- sName.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(), "stuList"));
|
|
|
- }
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ sName.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(), "stuList"));
|
|
|
}
|
|
|
}
|
|
|
- var queryClass = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.classId}'"))})";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId.GetString()}") }))
|
|
|
+ }
|
|
|
+ var queryClass = $"select c.id ,c.name from c where c.id in ({string.Join(",", schedules.Select(o => $"'{o.classId}'"))})";
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId.GetString()}") }))
|
|
|
+ {
|
|
|
+ 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)
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
{
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- sName.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(), "class"));
|
|
|
- }
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ sName.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString(),"class"));
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- ps.Add((s, n, sc, sName));
|
|
|
+ }
|
|
|
+ ps.Add((s,n, sc,sName));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1274,7 +1209,7 @@ namespace TEAMModelOS.Controllers
|
|
|
p.id,
|
|
|
p.name,
|
|
|
p.scope,
|
|
|
- classes = p.stuName.Select(s => new { s.id, s.name, s.type })
|
|
|
+ classes = p.stuName.Select(s => new { s.id, s.name,s.type })
|
|
|
});
|
|
|
|
|
|
|
|
@@ -1311,7 +1246,7 @@ namespace TEAMModelOS.Controllers
|
|
|
//List<(string id, string code, string name)> listCourse = new List<(string id, string code, string name)>();
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code.GetString()}") }))
|
|
|
{
|
|
|
courseList.Add(item);
|
|
|
}
|
|
@@ -1319,7 +1254,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code.GetString()}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code.GetString()}") }))
|
|
|
{
|
|
|
courseList.Add(item);
|
|
|
}
|
|
@@ -1343,7 +1278,7 @@ namespace TEAMModelOS.Controllers
|
|
|
scheduleExtobj.teacherId = schedule.teacherId;
|
|
|
if (!string.IsNullOrEmpty(schedule.teacherId))
|
|
|
{
|
|
|
- var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(schedule.teacherId, new PartitionKey("Base"));
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(schedule.teacherId, new PartitionKey("Base"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
@@ -1395,7 +1330,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
if (scope.ToString().Equals("school"))
|
|
|
{
|
|
|
- Course course = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Course>(id.ToString(), new PartitionKey($"Course-{code}"));
|
|
|
+ Course course = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Course>(id.ToString(), new PartitionKey($"Course-{code}"));
|
|
|
CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, school = course.school, creatorId = course.creatorId };
|
|
|
courseChange.delClass = course.schedule.Select(x => x.classId).ToList();
|
|
|
courseChange.delList = course.schedule.Select(x => x.stulist).ToList();
|
|
@@ -1403,11 +1338,11 @@ namespace TEAMModelOS.Controllers
|
|
|
messageBlob.ApplicationProperties.Add("name", "Course");
|
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Course-{code}"));
|
|
|
+ await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Course-{code}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Course course = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Course>(id.ToString(), new PartitionKey($"Course-{code}"));
|
|
|
+ Course course = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Course>(id.ToString(), new PartitionKey($"Course-{code}"));
|
|
|
CourseChange courseChange = new CourseChange { id = course.id, code = course.code, name = course.name, scope = course.scope, school = course.school, creatorId = course.creatorId };
|
|
|
courseChange.delClass = course.schedule.Select(x => x.classId).ToList();
|
|
|
courseChange.delList = course.schedule.Select(x => x.stulist).ToList();
|
|
@@ -1415,7 +1350,7 @@ namespace TEAMModelOS.Controllers
|
|
|
messageBlob.ApplicationProperties.Add("name", "Course");
|
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Course-{code}"));
|
|
|
+ await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Course-{code}"));
|
|
|
}
|
|
|
return Ok(new { id });
|
|
|
}
|
|
@@ -1447,11 +1382,11 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
if (request.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
- List<Response> res = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsStreamAsync(request.ids, $"Course-{school_code}");
|
|
|
+ List<Response> res = await client.GetContainer("TEAMModelOS", "School").DeleteItemsStreamAsync(request.ids, $"Course-{school_code}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- List<Response> res = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemsStreamAsync(request.ids, $"Course-{school_code}");
|
|
|
+ List<Response> res = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemsStreamAsync(request.ids, $"Course-{school_code}");
|
|
|
}
|
|
|
|
|
|
return Ok(new { ids = request.ids });
|
|
@@ -1483,14 +1418,14 @@ namespace TEAMModelOS.Controllers
|
|
|
// /* if (requert.scope.Equals) {
|
|
|
|
|
|
// }*/
|
|
|
- // var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(requert.id, new PartitionKey($"CourseManagement-{code}"));
|
|
|
+ // var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(requert.id, new PartitionKey($"CourseManagement-{code}"));
|
|
|
// if (response.Status == 200)
|
|
|
// {
|
|
|
- // course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(requert, requert.id, new PartitionKey($"CourseManagement-{code}"));
|
|
|
+ // course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(requert, requert.id, new PartitionKey($"CourseManagement-{code}"));
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
- // course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(requert, new PartitionKey($"CourseManagement-{code}"));
|
|
|
+ // course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(requert, new PartitionKey($"CourseManagement-{code}"));
|
|
|
// }
|
|
|
// return Ok(new { course });
|
|
|
// }
|
|
@@ -1530,7 +1465,7 @@ namespace TEAMModelOS.Controllers
|
|
|
// dict.Remove("code");
|
|
|
// }
|
|
|
// AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
|
|
|
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
|
|
|
+ // await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
|
|
|
// {
|
|
|
// using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
// if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1553,7 +1488,7 @@ namespace TEAMModelOS.Controllers
|
|
|
// var client = _azureCosmos.GetCosmosClient();
|
|
|
// List<object> courses = new List<object>();
|
|
|
// var query = $"select c.code,c.id,c.name,A0.course.id courseId,A0.course.name courseName ,A0.course.notice notice ,A1,c.scope,c.teacher from c join A0 in c.courses join A1 in A0.teachers where A1.id = '{id}' ";
|
|
|
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
|
|
|
+ // await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
|
|
|
// {
|
|
|
// using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
// if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1582,7 +1517,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
var query = $"select distinct value(c) from c join A0 in c.schedule where A0.room = '{id}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
{
|
|
|
courseList.Add(item);
|
|
|
}
|
|
@@ -1590,7 +1525,7 @@ namespace TEAMModelOS.Controllers
|
|
|
else
|
|
|
{
|
|
|
var query = $"select distinct value(c) from c join A0 in c.schedule where A0.room = '{id}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Course>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
{
|
|
|
courseList.Add(item);
|
|
|
}
|
|
@@ -1606,7 +1541,7 @@ namespace TEAMModelOS.Controllers
|
|
|
List<(string id, string name)> teachers = new List<(string id, string name)>();
|
|
|
if (teacherIds.Count > 0)
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
|
|
|
queryText: $"select c.id,c.name from c where c.id in ({ string.Join(",", teacherIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1676,7 +1611,7 @@ namespace TEAMModelOS.Controllers
|
|
|
// dict.Add("courses[*].teachers[*].id", teachers.id);
|
|
|
// //dict.Add("id", classroom.id);
|
|
|
// AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
|
|
|
- // await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
|
|
|
+ // await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
|
|
|
// {
|
|
|
// using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
// if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1694,7 +1629,7 @@ namespace TEAMModelOS.Controllers
|
|
|
// if (courseManagements[i].courses[j].course.id.Equals(courseId.ToString()))
|
|
|
// {
|
|
|
// courseManagements[i].courses[j].course.notice = notice.ToString();
|
|
|
- // await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(courseManagements[i], courseManagements[i].id, new PartitionKey($"{courseManagements[i].code}"));
|
|
|
+ // await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(courseManagements[i], courseManagements[i].id, new PartitionKey($"{courseManagements[i].code}"));
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
@@ -1722,14 +1657,14 @@ namespace TEAMModelOS.Controllers
|
|
|
course.code = typeof(Course).Name + "-" + course.code;
|
|
|
if (option.ToString().Equals("insert"))
|
|
|
{
|
|
|
- var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(course.id, new PartitionKey($"Course-{code}"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
return Ok(new { error = ResponseCode.DATA_EXIST, V = "课程编码已经存在!" });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
|
|
|
+ course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(course, new PartitionKey($"Course-{code}"));
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -1749,12 +1684,12 @@ namespace TEAMModelOS.Controllers
|
|
|
//cla.scope = classSimple.scope;
|
|
|
cla.teacher.id = classSimple.teacher.id;
|
|
|
cla.teacher.name = classSimple.teacher.name;
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(cla, new PartitionKey($"Class-{code}"));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(cla, new PartitionKey($"Class-{code}"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(classSimple.id, new PartitionKey($"Class-{classSimple.code}"));
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classSimple.id, new PartitionKey($"Class-{classSimple.code}"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
@@ -1774,12 +1709,12 @@ namespace TEAMModelOS.Controllers
|
|
|
}*/
|
|
|
newCla.teacher.id = classSimple.teacher.id;
|
|
|
newCla.teacher.name = classSimple.teacher.name;
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(newCla, new PartitionKey($"Class-{code}"));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(newCla, new PartitionKey($"Class-{code}"));
|
|
|
classSimple.code = code;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Class cla = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Class>(classSimple.id, new PartitionKey($"Class-{classSimple.code}"));
|
|
|
+ Class cla = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Class>(classSimple.id, new PartitionKey($"Class-{classSimple.code}"));
|
|
|
Class newCla = new Class();
|
|
|
newCla.id = cla.id;
|
|
|
newCla.code = cla.pk + "-" + code;
|
|
@@ -1789,12 +1724,12 @@ namespace TEAMModelOS.Controllers
|
|
|
//newCla.students = cla.students;
|
|
|
newCla.teacher.id = classSimple.teacher.id;
|
|
|
newCla.teacher.name = classSimple.teacher.name;
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(newCla, new PartitionKey($"Class-{code}"));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(newCla, new PartitionKey($"Class-{code}"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
|
|
|
+ course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(course, course.id, new PartitionKey($"Course-{code}"));
|
|
|
}
|
|
|
return Ok(new { course });
|
|
|
}
|
|
@@ -1814,7 +1749,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
List<object> courses = new List<object>();
|
|
|
var query = $"select c.code,c.id,c.name,c.subjectId,c.periodId,c.scope,c.notice,c.classes from c ";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1847,7 +1782,7 @@ namespace TEAMModelOS.Controllers
|
|
|
List<string> classIds = new List<string>();
|
|
|
List<(string id, string scope)> listClassInfo = new List<(string id, string scope)>();
|
|
|
var query = $"select distinct c.scope,A0.stulist id from c join A0 in c.schedule where A0.teacherId = '{id}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1866,7 +1801,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
var querySchool = $"select distinct c.scope,A0.classId id from c join A0 in c.schedule where A0.teacherId = '{id}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{id}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1886,7 +1821,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
//List<object> coursesBySchool = new List<object>();
|
|
|
//var queryBySchool = $"select distinct c.id,c.name,c.scope from c join A0 in c.courses join A1 in A0.teachers where A1.id = '{id}' ";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1904,7 +1839,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: querySchool, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{code}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1926,7 +1861,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (classIds.Count > 0)
|
|
|
{
|
|
|
//List<(string id, string name)> listClassList = new List<(string id, string name)>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
|
|
|
queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{code}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1942,7 +1877,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
|
|
|
queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1958,7 +1893,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
|
|
|
queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", classIds.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|