|
@@ -340,33 +340,34 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
records.Add(item);
|
|
|
}
|
|
|
- //if (records.Any()) {
|
|
|
- // var groupIds= records.SelectMany(x => x.groupIds).ToHashSet();
|
|
|
- // if (groupIds.Any()) {
|
|
|
- // var groups = await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds.ToList(), school," c.id ");
|
|
|
- // //获取已经被删除的名单。
|
|
|
- // var idsExp = groupIds.Except(groups.Select(x => x.id));
|
|
|
- // if (idsExp.Any()) {
|
|
|
+ if (records.Any()) {
|
|
|
+ var groupIds= records.SelectMany(x => x.groupIds).ToHashSet();
|
|
|
+ if (groupIds.Any()) {
|
|
|
+ var groups = await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds.ToList(), school," c.id ");
|
|
|
+ //获取已经被删除的名单。
|
|
|
+ var idsExp = groupIds.Except(groups.Select(x => x.id));
|
|
|
+ if (idsExp.Any()) {
|
|
|
+
|
|
|
|
|
|
- // foreach(var item in records)
|
|
|
- // {
|
|
|
- // int countRmv = item.groupIds.RemoveAll(x => idsExp.Contains(x));
|
|
|
- // if (countRmv > 0)
|
|
|
- // {
|
|
|
- // try {
|
|
|
- // LessonRecord record = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<LessonRecord>(item.id, new PartitionKey(code));
|
|
|
- // record.groupIds = item.groupIds;
|
|
|
- // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<LessonRecord>(record, item.id, new PartitionKey(code));
|
|
|
- // } catch (CosmosException ex) when (ex.Status == 404) {
|
|
|
- // continue;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
+ foreach(var item in records)
|
|
|
+ {
|
|
|
+ int countRmv = item.groupIds.RemoveAll(x => idsExp.Contains(x));
|
|
|
+ if (countRmv > 0)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ LessonRecord record = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<LessonRecord>(item.id, new PartitionKey(code));
|
|
|
+ record.groupIds = item.groupIds;
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<LessonRecord>(record, item.id, new PartitionKey(code));
|
|
|
+ } catch (CosmosException ex) when (ex.Status == 404) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
count = records.Count;
|
|
|
- return Ok(new { count=count });
|
|
|
+ return Ok(new { count=count, records });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -389,7 +390,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
- sql.Append("select distinct value(c) from c ");
|
|
|
+ sql.Append("select value(c) from c ");
|
|
|
int pageCount = 10;
|
|
|
Dictionary<string, object> dict = GetLessonCond(request);
|
|
|
if (request.TryGetProperty("pageCount", out JsonElement _pageCount))
|
|
@@ -519,14 +520,19 @@ namespace TEAMModelOS.Controllers
|
|
|
long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
//查询时处理已经过期的课例。防止ServiceBus未触发的。
|
|
|
var expireRecords= lessonRecords.Where(x=> x.expire > 0 && now > x.expire);
|
|
|
- foreach (var item in expireRecords) {
|
|
|
- //item.status = 404;
|
|
|
- //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
|
|
|
- var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
- var messageChange = new ServiceBusMessage(new { delete_id=item.id,tmdid=item.tmdid,scope=item.scope,opt="delete",school=item.school }.ToJsonString());
|
|
|
- messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
|
|
|
- await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
|
|
|
- return Ok(new { status = 200 });
|
|
|
+ try {
|
|
|
+ foreach (var item in expireRecords)
|
|
|
+ {
|
|
|
+ //item.status = 404;
|
|
|
+ //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
|
|
|
+ var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
+ var messageChange = new ServiceBusMessage(new { delete_id = item.id, tmdid = item.tmdid, scope = item.scope, opt = "delete", school = item.school }.ToJsonString());
|
|
|
+ messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
|
|
|
+ return Ok(new { status = 200 });
|
|
|
+ }
|
|
|
+ } catch (Exception ex) {
|
|
|
+ await _dingDing.SendBotMsg($"{_option.Location},ServiceBus ,LessonRecordEvent 发送消息失败,检查是否配置正常。", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
var tmdids = lessonRecords.Select(x => x.tmdid).ToHashSet();
|
|
|
if (tmdids != null && tmdids.Count > 0)
|