|
@@ -429,7 +429,7 @@ namespace TEAMModelOS.Controllers
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(website, new PartitionKey(website.code));
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else {
|
|
|
website =JsonDocument.Parse(activityWebsiteResponse.Content).RootElement.ToObject<ActivityWebsite>();
|
|
|
}
|
|
|
}
|
|
@@ -456,7 +456,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (!request.TryGetProperty("Contest", out JsonElement _contest))
|
|
|
{
|
|
|
- return Ok(new { code =3, msg = "赛课信息参数错误" });
|
|
|
+ return Ok(new { code = 3, msg = "赛课信息参数错误" });
|
|
|
}
|
|
|
contest = _contest.ToObject<Contest>();
|
|
|
if (contest!=null) {
|
|
@@ -502,7 +502,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
//保存活动基础信息
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(activity, new PartitionKey(activity.code));
|
|
|
- return Ok(new { activity, contest ,code=200});
|
|
|
+ return Ok(new { activity, contest, code = 200 });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -522,7 +522,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (_scope.GetString().Equals("school") && _owner.GetString().Equals(school))
|
|
|
{
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).DeleteItemStreamAsync(activity.id, new PartitionKey("Activity"));
|
|
|
- return Ok(new { code = 201, activity }) ; //删除成功
|
|
|
+ return Ok(new { code = 201, activity }); //删除成功
|
|
|
}
|
|
|
else {
|
|
|
if ((_scope.GetString().Equals("area") || _scope.GetString().Equals("public")) && !_owner.GetString().Equals(school))
|
|
@@ -550,7 +550,7 @@ namespace TEAMModelOS.Controllers
|
|
|
string sql = $"select value c from c where c.owner='{_areaId}' {yearSql} ";
|
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sql, "Activity");
|
|
|
result.list.ForEach(z => {
|
|
|
- var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(z.owner, BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
|
|
|
+ var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(z.owner, BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
|
|
|
z.sas=blob_sas;
|
|
|
});
|
|
|
return Ok(new { activities = result.list.OrderByDescending(z => z.stime) });
|
|
@@ -669,7 +669,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
Teacher teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<Teacher>(tmdid, new PartitionKey("Base"));
|
|
|
- string schoolOwnerIn =string.Empty;
|
|
|
+ string schoolOwnerIn = string.Empty;
|
|
|
string schoolIdIn = string.Empty;
|
|
|
if (teacher.schools.IsNotEmpty()) {
|
|
|
schoolIdIn = $"and i.id in ({string.Join(",", teacher.schools.Select(z => $"'{z.schoolId}'"))})";
|
|
@@ -688,7 +688,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
|
activities.AddRange(resultSchool.list);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
string areaOwnerIn = string.Empty;
|
|
|
var hasAreaSchools = teacher.schools.FindAll(z => !string.IsNullOrWhiteSpace(z.areaId));
|
|
@@ -699,14 +699,14 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
//获取所有区级的
|
|
|
if (!string.IsNullOrWhiteSpace(areaOwnerIn) && !string.IsNullOrEmpty(schoolIdIn)) {
|
|
|
-
|
|
|
+
|
|
|
string sqlOpen = $"select value c from c join i in c.confirmedSchools where c.scope='area' and c.joinMode='enroll' and (c.publish=1 or c.publish=2 ) and i.status=1 {yearSql} {areaOwnerIn} {schoolIdIn} ";
|
|
|
var resultOpen = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlOpen, "Activity");
|
|
|
activities.AddRange(resultOpen.list);
|
|
|
}
|
|
|
|
|
|
//获取所有学校的
|
|
|
- if(!string.IsNullOrWhiteSpace(schoolOwnerIn))
|
|
|
+ if (!string.IsNullOrWhiteSpace(schoolOwnerIn))
|
|
|
{
|
|
|
string sqlSchool = $"select value c from c where c.scope='school' and c.joinMode='enroll' and (c.publish=1 or c.publish=2 ) {yearSql} {schoolOwnerIn} ";
|
|
|
var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sqlSchool, "Activity");
|
|
@@ -714,7 +714,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
|
|
|
activities.ForEach(z => {
|
|
|
- var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(z.owner, BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
|
|
|
+ var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(z.owner, BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
|
|
|
z.sas=blob_sas;
|
|
|
});
|
|
|
return Ok(new { activities = activities.OrderByDescending(z => z.stime) });
|
|
@@ -723,11 +723,11 @@ namespace TEAMModelOS.Controllers
|
|
|
case bool when $"{grant_type}".Equals("read-contest", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
|
Contest contest = null;
|
|
|
- ReviewRuleTree reviewRule = null;
|
|
|
+ ReviewRuleTree reviewRule = null;
|
|
|
if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
|
|
|
Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("Contest"));
|
|
|
if (response.Status==200) {
|
|
|
- contest= JsonDocument.Parse(response.Content).RootElement.ToObject<Contest>() ;
|
|
|
+ contest= JsonDocument.Parse(response.Content).RootElement.ToObject<Contest>();
|
|
|
if (contest.modules.Contains("review")) {
|
|
|
Azure.Response reviewRuleResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("ReviewRule-disposable"));
|
|
|
if (reviewRuleResponse.Status==200) {
|
|
@@ -748,16 +748,16 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new { code = 200, contest, reviewRule });
|
|
|
}
|
|
|
//获取评审的模板列表
|
|
|
- case bool when $"{grant_type}".Equals("rule-list", StringComparison.OrdinalIgnoreCase):
|
|
|
+ case bool when $"{grant_type}".Equals("rule-list", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
|
if (!request.TryGetProperty("owner", out JsonElement _owner)) return BadRequest();
|
|
|
- var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<ReviewRule>($"select value c from c where c.owner='{_owner}'", "ReviewRule-template");
|
|
|
+ var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetList<ReviewRule>($"select value c from c where c.owner='{_owner}'", "ReviewRule-template");
|
|
|
List<ReviewRuleTree> reviewRules = new List<ReviewRuleTree>();
|
|
|
foreach (var item in result.list)
|
|
|
{
|
|
|
var tree = ActivityService.ListToTree(item.configs);
|
|
|
- ReviewRuleTree reviewRule=new ReviewRuleTree
|
|
|
- { id=item.id,
|
|
|
+ ReviewRuleTree reviewRule = new ReviewRuleTree
|
|
|
+ { id=item.id,
|
|
|
desc=item.desc,
|
|
|
name= item.name,
|
|
|
owner= item.owner,
|
|
@@ -779,10 +779,10 @@ namespace TEAMModelOS.Controllers
|
|
|
ReviewRuleTree ruleTree = _reviewConfig.ToObject<ReviewRuleTree>();
|
|
|
if (!string.IsNullOrWhiteSpace(ruleTree.id))
|
|
|
{
|
|
|
- Activity activity= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemAsync<Activity>(ruleTree.id, new PartitionKey("Activity"));
|
|
|
+ Activity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemAsync<Activity>(ruleTree.id, new PartitionKey("Activity"));
|
|
|
var reviewRuleDB = await ActivityService.UpsertReviewRule(ruleTree, activity, _azureCosmos);
|
|
|
var tree = ActivityService.ListToTree(reviewRuleDB.configs);
|
|
|
- var reviewRule=new ReviewRuleTree
|
|
|
+ var reviewRule = new ReviewRuleTree
|
|
|
{
|
|
|
id=reviewRuleDB.id,
|
|
|
name= reviewRuleDB.name,
|
|
@@ -805,7 +805,7 @@ namespace TEAMModelOS.Controllers
|
|
|
return BadRequest();
|
|
|
}
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).DeleteItemStreamAsync(_ruleId.GetString(), new PartitionKey("ReviewRule-template"));
|
|
|
- return Ok(new { code=200});
|
|
|
+ return Ok(new { code = 200 });
|
|
|
}
|
|
|
//学校确认参加本次活动
|
|
|
case bool when $"{grant_type}".Equals("school-confirm", StringComparison.OrdinalIgnoreCase):
|
|
@@ -816,10 +816,10 @@ namespace TEAMModelOS.Controllers
|
|
|
Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("Activity"));
|
|
|
if (response.Status==200)
|
|
|
{
|
|
|
- Activity activity= JsonDocument.Parse(response.Content).RootElement.ToObject<Activity>();
|
|
|
+ Activity activity = JsonDocument.Parse(response.Content).RootElement.ToObject<Activity>();
|
|
|
if (_confirm.GetInt32()==1 ||_confirm.GetInt32()==0)
|
|
|
{
|
|
|
- var invitedSchool= activity.invitedSchools.Find(z => z.id.Equals(school));
|
|
|
+ var invitedSchool = activity.invitedSchools.Find(z => z.id.Equals(school));
|
|
|
if (invitedSchool!=null) {
|
|
|
var confirmedSchool = activity.confirmedSchools.Find(z => z.id.Equals(school));
|
|
|
if (confirmedSchool!=null)
|
|
@@ -828,7 +828,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
else {
|
|
|
School schoolbase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
- activity.confirmedSchools= new List<ActivityConfirmedSchool>() { new ActivityConfirmedSchool { id=school, status=_confirm.GetInt32(),name=schoolbase.name,picture= schoolbase.picture} };
|
|
|
+ activity.confirmedSchools= new List<ActivityConfirmedSchool>() { new ActivityConfirmedSchool { id=school, status=_confirm.GetInt32(), name=schoolbase.name, picture= schoolbase.picture } };
|
|
|
}
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(activity, new PartitionKey("Activity"));
|
|
|
return Ok(new { code = 200, activity });
|
|
@@ -847,7 +847,7 @@ namespace TEAMModelOS.Controllers
|
|
|
break;
|
|
|
}
|
|
|
//发布或取消发布活动
|
|
|
- case bool when $"{grant_type}".Equals("update-publish", StringComparison.OrdinalIgnoreCase):
|
|
|
+ case bool when $"{grant_type}".Equals("update-publish", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
|
if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
|
|
|
if (!request.TryGetProperty("publish", out JsonElement _publish)) return BadRequest();
|
|
@@ -859,7 +859,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
activity.publish=_publish.GetInt32();
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(activity, new PartitionKey("Activity"));
|
|
|
- return Ok(new { code=200,activity});
|
|
|
+ return Ok(new { code = 200, activity });
|
|
|
}
|
|
|
else {
|
|
|
return Ok(new { code = 2, msg = "活动发布状态错误!" });
|
|
@@ -874,36 +874,36 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
|
|
|
request.TryGetProperty("invite", out JsonElement _invite);
|
|
|
- request.TryGetProperty("remove", out JsonElement _remove) ;
|
|
|
+ request.TryGetProperty("remove", out JsonElement _remove);
|
|
|
Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("Activity"));
|
|
|
if (response.Status==200)
|
|
|
{
|
|
|
Activity activity = JsonDocument.Parse(response.Content).RootElement.ToObject<Activity>();
|
|
|
if (activity.joinMode.Equals("invite"))
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
var confirmedSchool = activity.confirmedSchools.Find(z => z.id.Equals(school) && z.status==1);
|
|
|
if (confirmedSchool!= null || activity.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
|
List<InviteTeachers> inviteTeachersInvalid = new List<InviteTeachers>();
|
|
|
List<InviteTeachers> removeTeachersInvalid = new List<InviteTeachers>();
|
|
|
ActivityTeacher activityTeacher = null;
|
|
|
- Azure.Response activityTeacherResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync(activity.id, new PartitionKey("ActivityTeacher"));
|
|
|
+ Azure.Response activityTeacherResponse = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync(activity.id, new PartitionKey("ActivityTeacher"));
|
|
|
if (activityTeacherResponse.Status==200)
|
|
|
{
|
|
|
activityTeacher = JsonDocument.Parse(activityTeacherResponse.Content).RootElement.ToObject<ActivityTeacher>();
|
|
|
}
|
|
|
if (activityTeacher==null) {
|
|
|
- activityTeacher= new ActivityTeacher() { id= activity.id, code="ActivityTeacher",pk="ActivityTeacher" };
|
|
|
+ activityTeacher= new ActivityTeacher() { id= activity.id, code="ActivityTeacher", pk="ActivityTeacher" };
|
|
|
}
|
|
|
- if (_invite.ValueKind.Equals(JsonValueKind.Array)) {
|
|
|
+ if (_invite.ValueKind.Equals(JsonValueKind.Array)) {
|
|
|
List<InviteTeachers> inviteTeachers = _invite.ToObject<List<InviteTeachers>>();
|
|
|
foreach (var invite in inviteTeachers) {
|
|
|
if (string.IsNullOrWhiteSpace(invite.school) || !invite.school.Equals(school)) {
|
|
|
inviteTeachersInvalid.Add(invite);
|
|
|
continue;
|
|
|
}
|
|
|
- var inviteTeacher= activityTeacher.inviteTeachers.Find(z => z.id.Equals(invite.id));
|
|
|
+ var inviteTeacher = activityTeacher.inviteTeachers.Find(z => z.id.Equals(invite.id));
|
|
|
if (inviteTeacher==null)
|
|
|
{
|
|
|
activityTeacher.inviteTeachers.Add(invite);
|
|
@@ -927,7 +927,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
var teachers = activityTeacher.inviteTeachers.FindAll(z => z.school.Equals(school));
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(activityTeacher, new PartitionKey("ActivityTeacher"));
|
|
|
- return Ok(new { inviteTeachers=teachers, inviteTeachersInvalid, removeTeachersInvalid });
|
|
|
+ return Ok(new { inviteTeachers = teachers, inviteTeachersInvalid, removeTeachersInvalid });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -944,7 +944,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
//获取邀请的教师列表
|
|
|
- case bool when $"{grant_type}".Equals("invited-teachers", StringComparison.OrdinalIgnoreCase):
|
|
|
+ case bool when $"{grant_type}".Equals("invited-teachers", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
|
string owner = string.Empty;
|
|
|
if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
|
|
@@ -959,17 +959,17 @@ namespace TEAMModelOS.Controllers
|
|
|
else {
|
|
|
owner=$"{_activityOwner}";
|
|
|
}
|
|
|
- Activity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemAsync<Activity>(_activityId.GetString(), new PartitionKey("Activity"));
|
|
|
+ Activity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemAsync<Activity>(_activityId.GetString(), new PartitionKey("Activity"));
|
|
|
int isAll = 0;
|
|
|
if (!string.IsNullOrWhiteSpace(owner)) {
|
|
|
- if (activity.owner.Equals(owner)) {
|
|
|
- isAll = 1;
|
|
|
+ if (activity.owner.Equals(owner)) {
|
|
|
+ isAll = 1;
|
|
|
}
|
|
|
}
|
|
|
List<InviteTeachers> inviteTeachers = new List<InviteTeachers>();
|
|
|
- Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("ActivityTeacher"));
|
|
|
+ Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync(_activityId.GetString(), new PartitionKey("ActivityTeacher"));
|
|
|
if (response.Status==200) {
|
|
|
- ActivityTeacher activityTeacher = JsonDocument.Parse(response.Content).RootElement.ToObject<ActivityTeacher>();
|
|
|
+ ActivityTeacher activityTeacher = JsonDocument.Parse(response.Content).RootElement.ToObject<ActivityTeacher>();
|
|
|
if (isAll==1)
|
|
|
{
|
|
|
if (activityTeacher.inviteTeachers.IsNotEmpty()) {
|
|
@@ -980,7 +980,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(school))
|
|
|
{
|
|
|
- var teachers = activityTeacher.inviteTeachers.FindAll(z => !string.IsNullOrWhiteSpace(z.school) && z.school.Equals(school));
|
|
|
+ var teachers = activityTeacher.inviteTeachers.FindAll(z => !string.IsNullOrWhiteSpace(z.school) && z.school.Equals(school));
|
|
|
if (teachers.IsNotEmpty()) {
|
|
|
inviteTeachers.AddRange(teachers);
|
|
|
}
|
|
@@ -993,71 +993,59 @@ namespace TEAMModelOS.Controllers
|
|
|
case bool when $"{grant_type}".Equals("add-remove-experts", StringComparison.OrdinalIgnoreCase):
|
|
|
{
|
|
|
if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
|
|
|
- if (!request.TryGetProperty("experts", out JsonElement _experts) || !_experts.ValueKind.Equals(JsonValueKind.Array)) { return BadRequest(); }
|
|
|
- List<Expert> experts = _experts.ToObject<List<Expert>>();
|
|
|
- var tmdids = experts.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).Select(z => z.tmdid);
|
|
|
- var phones = experts.Where(x => !string.IsNullOrWhiteSpace(x.mobile)).Select(z => z.mobile);
|
|
|
- var emails = experts.Where(x => !string.IsNullOrWhiteSpace(x.email)).Select(z => z.email);
|
|
|
- List<string> keys = new List<string>();
|
|
|
- if (tmdids.Any())
|
|
|
- {
|
|
|
- keys.AddRange(tmdids);
|
|
|
- }
|
|
|
- if (phones.Any())
|
|
|
- {
|
|
|
- keys.AddRange(phones);
|
|
|
+ List<Expert> upsert_experts = new List<Expert>();
|
|
|
+ List<Expert> remove_experts = new List<Expert>();
|
|
|
+ if (request.TryGetProperty("upsert_experts", out JsonElement _upsert_experts) && _upsert_experts.ValueKind.Equals(JsonValueKind.Array)) {
|
|
|
+ upsert_experts = _upsert_experts.ToObject<List<Expert>>();
|
|
|
}
|
|
|
- if (emails.Any())
|
|
|
+ if (request.TryGetProperty("remove_experts", out JsonElement _remove_experts) && _remove_experts.ValueKind.Equals(JsonValueKind.Array))
|
|
|
{
|
|
|
- keys.AddRange(emails);
|
|
|
+ remove_experts = _remove_experts.ToObject<List<Expert>>();
|
|
|
}
|
|
|
ActivityExpert activityExpert = null;
|
|
|
- experts.ForEach(x => { x.status = 0; x.iname = x.name; x.name = null; });
|
|
|
- List<CoreUser> coreUsers = new List<CoreUser>();
|
|
|
- if (keys.Any())
|
|
|
- {
|
|
|
- try
|
|
|
+ if (upsert_experts.IsNotEmpty()) {
|
|
|
+ var tmdids = upsert_experts.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).Select(z => z.tmdid);
|
|
|
+ var phones = upsert_experts.Where(x => !string.IsNullOrWhiteSpace(x.mobile)).Select(z => z.mobile);
|
|
|
+ var emails = upsert_experts.Where(x => !string.IsNullOrWhiteSpace(x.email)).Select(z => z.email);
|
|
|
+ List<string> keys = new List<string>();
|
|
|
+ if (tmdids.Any())
|
|
|
{
|
|
|
- var content = new StringContent(keys.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
- string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
- if (!string.IsNullOrWhiteSpace(json))
|
|
|
- {
|
|
|
- coreUsers = json.ToObject<List<CoreUser>>();
|
|
|
- }
|
|
|
+ keys.AddRange(tmdids);
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ if (phones.Any())
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"{_option.Location},导入名单时,查验key信息错误{ex.Message}\n{ex.StackTrace}\n\n{keys.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ keys.AddRange(phones);
|
|
|
}
|
|
|
- }
|
|
|
- if (coreUsers.IsNotEmpty())
|
|
|
- {
|
|
|
- foreach (var t in experts)
|
|
|
+ if (emails.Any())
|
|
|
{
|
|
|
- if (!string.IsNullOrWhiteSpace(t.tmdid))
|
|
|
+ keys.AddRange(emails);
|
|
|
+ }
|
|
|
+
|
|
|
+ upsert_experts.ForEach(x => { x.status = 0; x.iname = x.name; x.name = null; });
|
|
|
+ List<CoreUser> coreUsers = new List<CoreUser>();
|
|
|
+ if (keys.Any())
|
|
|
+ {
|
|
|
+ try
|
|
|
{
|
|
|
- CoreUser coreUser = coreUsers.Find(x => x.id.Equals(t.tmdid));
|
|
|
- if (coreUser != null)
|
|
|
+ var content = new StringContent(keys.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
+ if (!string.IsNullOrWhiteSpace(json))
|
|
|
{
|
|
|
- t.id = coreUser.id;
|
|
|
- t.name = coreUser.name;
|
|
|
- t.picture = coreUser.picture;
|
|
|
- t.tmdid = coreUser.id;
|
|
|
- if (!string.IsNullOrWhiteSpace(coreUser.mobile))
|
|
|
- {
|
|
|
- t.mobile = coreUser.mobile;
|
|
|
- }
|
|
|
- if (!string.IsNullOrWhiteSpace(coreUser.mail))
|
|
|
- {
|
|
|
- t.email = coreUser.mail;
|
|
|
- }
|
|
|
+ coreUsers = json.ToObject<List<CoreUser>>();
|
|
|
}
|
|
|
}
|
|
|
- if (string.IsNullOrWhiteSpace(t.id))
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- if (!string.IsNullOrWhiteSpace(t.mobile))
|
|
|
+ await _dingDing.SendBotMsg($"{_option.Location},导入名单时,查验key信息错误{ex.Message}\n{ex.StackTrace}\n\n{keys.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (coreUsers.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (var t in upsert_experts)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrWhiteSpace(t.tmdid))
|
|
|
{
|
|
|
- CoreUser coreUser = coreUsers.Find(x => !string.IsNullOrWhiteSpace(x.mobile) && x.mobile.Equals(t.mobile));
|
|
|
+ CoreUser coreUser = coreUsers.Find(x => x.id.Equals(t.tmdid));
|
|
|
if (coreUser != null)
|
|
|
{
|
|
|
t.id = coreUser.id;
|
|
@@ -1074,14 +1062,224 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (string.IsNullOrWhiteSpace(t.id))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrWhiteSpace(t.mobile))
|
|
|
+ {
|
|
|
+ CoreUser coreUser = coreUsers.Find(x => !string.IsNullOrWhiteSpace(x.mobile) && x.mobile.Equals(t.mobile));
|
|
|
+ if (coreUser != null)
|
|
|
+ {
|
|
|
+ t.id = coreUser.id;
|
|
|
+ t.name = coreUser.name;
|
|
|
+ t.picture = coreUser.picture;
|
|
|
+ t.tmdid = coreUser.id;
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mobile))
|
|
|
+ {
|
|
|
+ t.mobile = coreUser.mobile;
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mail))
|
|
|
+ {
|
|
|
+ t.email = coreUser.mail;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (string.IsNullOrWhiteSpace(t.id))
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrWhiteSpace(t.email))
|
|
|
+ {
|
|
|
+ CoreUser coreUser = coreUsers.Find(x => !string.IsNullOrWhiteSpace(x.mail) && x.mail.Equals(t.email));
|
|
|
+ if (coreUser != null)
|
|
|
+ {
|
|
|
+ t.id = coreUser.id;
|
|
|
+ t.name = coreUser.name;
|
|
|
+ t.picture = coreUser.picture;
|
|
|
+ t.tmdid = coreUser.id;
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mobile))
|
|
|
+ {
|
|
|
+ t.mobile = coreUser.mobile;
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mail))
|
|
|
+ {
|
|
|
+ t.email = coreUser.mail;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync($"{_activityId}", new PartitionKey("ActivityExpert"));
|
|
|
+ if (response.Status == 200)
|
|
|
+ {
|
|
|
+ activityExpert = JsonDocument.Parse(response.Content).RootElement.Deserialize<ActivityExpert>();
|
|
|
+ upsert_experts.ForEach(x =>
|
|
|
+ {
|
|
|
+ Expert tch = null;
|
|
|
+ if (string.IsNullOrWhiteSpace(x.id))
|
|
|
+ {
|
|
|
+ tch = activityExpert.experts.Find(t => !string.IsNullOrWhiteSpace(t.iname) && t.iname.Equals(x.iname));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tch = activityExpert.experts.Find(t => !string.IsNullOrWhiteSpace(x.id) && !string.IsNullOrWhiteSpace(t.id) && t.id.Equals(x.id));
|
|
|
+ }
|
|
|
+ if (tch != null)
|
|
|
+ {
|
|
|
+ tch.status = x.status;
|
|
|
+ tch.name = x.name;
|
|
|
+ tch.iname = x.iname;
|
|
|
+ tch.picture = x.picture;
|
|
|
+ tch.mobile = x.mobile;
|
|
|
+ tch.tmdid = x.tmdid;
|
|
|
+ tch.email = x.email;
|
|
|
+ tch.id = x.id;
|
|
|
+ tch.school = x.school;
|
|
|
+ //直接替换更新
|
|
|
+ tch.modules=x.modules;
|
|
|
+ tch.subjects=x.subjects;
|
|
|
+ // x.modules.ForEach(y => {
|
|
|
+ // if (!tch.modules.Contains(y))
|
|
|
+ // {
|
|
|
+ // tch.modules.Add(y);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // x.subjects.ForEach(r => {
|
|
|
+ // if (!string.IsNullOrWhiteSpace(r.subject) && !string.IsNullOrWhiteSpace(r.period))
|
|
|
+ // {
|
|
|
+ // var sub = tch.subjects.Find(x => !string.IsNullOrWhiteSpace(x.subject) && !string.IsNullOrWhiteSpace(x.period) && x.subject.Equals(r.subject) && x.period.Equals(r.period));
|
|
|
+ // if (sub == null)
|
|
|
+ // {
|
|
|
+ // tch.subjects.Add(r);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (!string.IsNullOrWhiteSpace(r.subject) && string.IsNullOrWhiteSpace(r.period))
|
|
|
+ // {
|
|
|
+ // var sub = tch.subjects.Find(a => !string.IsNullOrWhiteSpace(a.subject) && string.IsNullOrWhiteSpace(a.period) && a.subject.Equals(r.subject));
|
|
|
+ // if (sub == null)
|
|
|
+ // {
|
|
|
+ // tch.subjects.Add(r);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ activityExpert.experts.Add(new Expert
|
|
|
+ {
|
|
|
+ status = x.status,
|
|
|
+ name = x.name,
|
|
|
+ iname = x.iname,
|
|
|
+ picture = x.picture,
|
|
|
+ mobile = x.mobile,
|
|
|
+ tmdid = x.tmdid,
|
|
|
+ email = x.email,
|
|
|
+ id = x.id,
|
|
|
+ title = x.title,
|
|
|
+ subjects = x.subjects,
|
|
|
+ modules = x.modules,
|
|
|
+ school=x.school,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(activityExpert, new PartitionKey("ActivityExpert"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ activityExpert = new ActivityExpert { id = $"{_activityId}", code = "ActivityExpert", pk = "ActivityExpert", experts = upsert_experts };
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(activityExpert, new PartitionKey("ActivityExpert"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ activityExpert = new ActivityExpert { id = $"{_activityId}", code = "ActivityExpert", pk = "ActivityExpert", experts = upsert_experts };
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(activityExpert, new PartitionKey("ActivityExpert"));
|
|
|
+ }
|
|
|
+ if (remove_experts.IsNotEmpty()) {
|
|
|
+ if (activityExpert == null)
|
|
|
+ {
|
|
|
+ Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync($"{_activityId}", new PartitionKey("ActivityExpert"));
|
|
|
+ if (response.Status == 200) {
|
|
|
+ activityExpert = JsonDocument.Parse(response.Content).RootElement.Deserialize<ActivityExpert>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (activityExpert!=null) {
|
|
|
+ remove_experts.ForEach(z => {
|
|
|
+ if (!string.IsNullOrWhiteSpace(z.id))
|
|
|
+ {
|
|
|
+ activityExpert.experts.RemoveAll(x => !string.IsNullOrWhiteSpace(x.id) && x.id.Equals(z.id));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (!string.IsNullOrWhiteSpace(z.mobile)) {
|
|
|
+ activityExpert.experts.RemoveAll(x => !string.IsNullOrWhiteSpace(x.mobile) && x.mobile.Equals(z.mobile));
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(z.email))
|
|
|
+ {
|
|
|
+ activityExpert.experts.RemoveAll(x => !string.IsNullOrWhiteSpace(x.email) && x.email.Equals(z.email));
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(z.tmdid))
|
|
|
+ {
|
|
|
+ activityExpert.experts.RemoveAll(x => !string.IsNullOrWhiteSpace(x.tmdid) && x.tmdid.Equals(z.tmdid));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(activityExpert, new PartitionKey("ActivityExpert"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Ok(new { activityExpert,code=200 });
|
|
|
+ }
|
|
|
+ //评审专家列表
|
|
|
+ case bool when $"{grant_type}".Equals("list-experts", StringComparison.OrdinalIgnoreCase):
|
|
|
+ {
|
|
|
+ if (!request.TryGetProperty("activityId", out JsonElement _activityId)) return BadRequest();
|
|
|
+ ActivityExpert activityExpert = null;
|
|
|
+ Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync($"{_activityId}", new PartitionKey("ActivityExpert"));
|
|
|
+ if (response.Status == 200) {
|
|
|
+ bool change = false;
|
|
|
+ activityExpert = JsonDocument.Parse(response.Content).RootElement.Deserialize<ActivityExpert>();
|
|
|
+ var experts = activityExpert.experts.FindAll(z => string.IsNullOrWhiteSpace(z.id));
|
|
|
+ var tmdids = experts.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).Select(z => z.tmdid);
|
|
|
+ var phones = experts.Where(x => !string.IsNullOrWhiteSpace(x.mobile)).Select(z => z.mobile);
|
|
|
+ var emails = experts.Where(x => !string.IsNullOrWhiteSpace(x.email)).Select(z => z.email);
|
|
|
+ List<string> keys = new List<string>();
|
|
|
+ if (tmdids.Any())
|
|
|
+ {
|
|
|
+ keys.AddRange(tmdids);
|
|
|
+ }
|
|
|
+ if (phones.Any())
|
|
|
+ {
|
|
|
+ keys.AddRange(phones);
|
|
|
+ }
|
|
|
+ if (emails.Any())
|
|
|
+ {
|
|
|
+ keys.AddRange(emails);
|
|
|
+ }
|
|
|
+ List<CoreUser> coreUsers = new List<CoreUser>();
|
|
|
+ if (keys.Any())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var content = new StringContent(keys.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
+ if (!string.IsNullOrWhiteSpace(json))
|
|
|
+ {
|
|
|
+ coreUsers = json.ToObject<List<CoreUser>>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"{_option.Location},导入名单时,查验key信息错误{ex.Message}\n{ex.StackTrace}\n\n{keys.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
|
}
|
|
|
- if (string.IsNullOrWhiteSpace(t.id))
|
|
|
+ }
|
|
|
+ if (coreUsers.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (var t in experts)
|
|
|
{
|
|
|
- if (!string.IsNullOrWhiteSpace(t.email))
|
|
|
+ if (!string.IsNullOrWhiteSpace(t.tmdid))
|
|
|
{
|
|
|
- CoreUser coreUser = coreUsers.Find(x => !string.IsNullOrWhiteSpace(x.mail) && x.mail.Equals(t.email));
|
|
|
+ CoreUser coreUser = coreUsers.Find(x => x.id.Equals(t.tmdid));
|
|
|
if (coreUser != null)
|
|
|
{
|
|
|
+ change=true;
|
|
|
t.id = coreUser.id;
|
|
|
t.name = coreUser.name;
|
|
|
t.picture = coreUser.picture;
|
|
@@ -1096,67 +1294,60 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync($"{_activityId}", new PartitionKey("ActivityExpert"));
|
|
|
- if (response.Status == 200)
|
|
|
- {
|
|
|
- activityExpert = JsonDocument.Parse(response.Content).RootElement.Deserialize<ActivityExpert>();
|
|
|
- experts.ForEach(x =>
|
|
|
- {
|
|
|
- Expert tch = null;
|
|
|
- if (string.IsNullOrWhiteSpace(x.id))
|
|
|
- {
|
|
|
- tch = activityExpert.experts.Find(t => !string.IsNullOrWhiteSpace(t.iname) && t.iname.Equals(x.iname));
|
|
|
- }
|
|
|
- else
|
|
|
+ if (string.IsNullOrWhiteSpace(t.id))
|
|
|
{
|
|
|
- tch = activityExpert.experts.Find(t => !string.IsNullOrWhiteSpace(x.id) && !string.IsNullOrWhiteSpace(t.id) && t.id.Equals(x.id));
|
|
|
- }
|
|
|
- if (tch != null)
|
|
|
- {
|
|
|
- tch.status = x.status;
|
|
|
- tch.name = x.name;
|
|
|
- tch.iname = x.iname;
|
|
|
- tch.picture = x.picture;
|
|
|
- tch.mobile = x.mobile;
|
|
|
- tch.tmdid = x.tmdid;
|
|
|
- tch.email = x.email;
|
|
|
- tch.id = x.id;
|
|
|
+ if (!string.IsNullOrWhiteSpace(t.mobile))
|
|
|
+ {
|
|
|
+ CoreUser coreUser = coreUsers.Find(x => !string.IsNullOrWhiteSpace(x.mobile) && x.mobile.Equals(t.mobile));
|
|
|
+ if (coreUser != null)
|
|
|
+ {
|
|
|
+ change=true;
|
|
|
+ t.id = coreUser.id;
|
|
|
+ t.name = coreUser.name;
|
|
|
+ t.picture = coreUser.picture;
|
|
|
+ t.tmdid = coreUser.id;
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mobile))
|
|
|
+ {
|
|
|
+ t.mobile = coreUser.mobile;
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mail))
|
|
|
+ {
|
|
|
+ t.email = coreUser.mail;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+ if (string.IsNullOrWhiteSpace(t.id))
|
|
|
{
|
|
|
- activityExpert.experts.Add(new Expert
|
|
|
+ if (!string.IsNullOrWhiteSpace(t.email))
|
|
|
{
|
|
|
- status = x.status,
|
|
|
- name = x.name,
|
|
|
- iname = x.iname,
|
|
|
- picture = x.picture,
|
|
|
- mobile = x.mobile,
|
|
|
- tmdid = x.tmdid,
|
|
|
- email = x.email,
|
|
|
- id = x.id,
|
|
|
- title = x.title,
|
|
|
- subjects = x.subjects,
|
|
|
- });
|
|
|
+ CoreUser coreUser = coreUsers.Find(x => !string.IsNullOrWhiteSpace(x.mail) && x.mail.Equals(t.email));
|
|
|
+ if (coreUser != null)
|
|
|
+ {
|
|
|
+ change=true;
|
|
|
+ t.id = coreUser.id;
|
|
|
+ t.name = coreUser.name;
|
|
|
+ t.picture = coreUser.picture;
|
|
|
+ t.tmdid = coreUser.id;
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mobile))
|
|
|
+ {
|
|
|
+ t.mobile = coreUser.mobile;
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(coreUser.mail))
|
|
|
+ {
|
|
|
+ t.email = coreUser.mail;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(activityExpert, new PartitionKey("ActivityExpert"));
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- activityExpert = new ActivityExpert { id = $"{_activityId}", code = "ActivityExpert", pk = "ActivityExpert", experts = experts };
|
|
|
+ if (change) {
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(activityExpert, new PartitionKey("ActivityExpert"));
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
- activityExpert = new ActivityExpert { id = $"{_activityId}", code = "ActivityExpert", pk = "ActivityExpert", experts = experts };
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).UpsertItemAsync(activityExpert, new PartitionKey("ActivityExpert"));
|
|
|
- }
|
|
|
- return Ok(new { activityExpert});
|
|
|
+ return Ok(new { activityExpert, code = 200 });
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
} catch (Exception ex)
|
|
|
{
|
|
@@ -1269,9 +1460,6 @@ namespace TEAMModelOS.Controllers
|
|
|
var serializeToken = tokenHandler.WriteToken(secToken);
|
|
|
return Ok(new { code =200,token =serializeToken, schools= teacherInfo.teacher.schools.Where(z=>z.status.Equals("join"))});
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|