|
@@ -127,32 +127,18 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (itemInfo.scope.Equals("private"))
|
|
|
{
|
|
|
+ ItemCondDto itemCondDto = new ItemCondDto { newItem = itemInfo, key = "ItemCond", filed = itemInfo.code.Replace("Item-", ""), scope = "private" };
|
|
|
+ var messageBlobItemCond = new ServiceBusMessage(itemCondDto.ToJsonString());
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync("itemcond", messageBlobItemCond);
|
|
|
itemInfo = await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
|
|
|
- string condId = itemInfo.code.Replace("Item-","");
|
|
|
- ItemCond itemCond = null;
|
|
|
- try
|
|
|
- {
|
|
|
- itemCond = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<ItemCond>(condId, new PartitionKey("ItemCond"));
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- itemCond = new ItemCond() { id = condId, code = $"ItemCond", pk = "ItemCond", ttl = -1, count = 0 };
|
|
|
- };
|
|
|
- ItemService.CountItemCond(itemInfo, null, itemCond);
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // itemInfo.periodId
|
|
|
+ ItemCondDto itemCondDto = new ItemCondDto { newItem = itemInfo, key = $"ItemCond-{itemInfo.code.Replace("Item-", "")}", filed = itemInfo.periodId, scope = "school" };
|
|
|
+ var messageBlobItemCond = new ServiceBusMessage(itemCondDto.ToJsonString());
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync("itemcond", messageBlobItemCond);
|
|
|
itemInfo = await client.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
|
|
|
- ItemCond itemCond = null;
|
|
|
- try {
|
|
|
- itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
|
|
|
- } catch (Exception ) {
|
|
|
- itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-{itemInfo.code.Replace("Item-", "")}", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
|
|
|
- };
|
|
|
- ItemService.CountItemCond(itemInfo, null, itemCond);
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -166,22 +152,13 @@ namespace TEAMModelOS.Controllers
|
|
|
itemInfo.code = "Item-" + itemInfo.code;
|
|
|
}
|
|
|
string condId = itemInfo.code.Replace("Item-", "");
|
|
|
- itemInfo = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
|
|
|
+
|
|
|
ItemInfo olditemInfo = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<ItemInfo>(itemInfo.id, new PartitionKey($"{itemInfo.code}"));
|
|
|
- //更新题目数量
|
|
|
- ItemCond itemCond = null;
|
|
|
- try
|
|
|
- {
|
|
|
-
|
|
|
- itemCond = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<ItemCond>(condId, new PartitionKey("ItemCond"));
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- itemCond = new ItemCond() { id = condId, code = $"ItemCond", pk = "ItemCond", ttl = -1, count = 0};
|
|
|
+ ItemCondDto itemCondDto = new ItemCondDto { newItem = itemInfo,odlItem=olditemInfo, key = "ItemCond", filed = itemInfo.code.Replace("Item-", ""), scope = "private" };
|
|
|
+ var messageBlobItemCond = new ServiceBusMessage(itemCondDto.ToJsonString());
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync("itemcond", messageBlobItemCond);
|
|
|
+ itemInfo = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
|
|
|
|
|
|
- };
|
|
|
- ItemService.CountItemCond(itemInfo, olditemInfo, itemCond);
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -190,21 +167,10 @@ namespace TEAMModelOS.Controllers
|
|
|
itemInfo.code = "Item-" + itemInfo.code;
|
|
|
}
|
|
|
ItemInfo olditemInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemInfo>( itemInfo.id, new PartitionKey($"{itemInfo.code}"));
|
|
|
+ ItemCondDto itemCondDto = new ItemCondDto { newItem = itemInfo,odlItem=olditemInfo, key = $"ItemCond-{itemInfo.code.Replace("Item-", "")}", filed = itemInfo.periodId, scope = "school" };
|
|
|
+ var messageBlobItemCond = new ServiceBusMessage(itemCondDto.ToJsonString());
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync("itemcond", messageBlobItemCond);
|
|
|
itemInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(itemInfo, itemInfo.id, new PartitionKey($"{itemInfo.code}"));
|
|
|
- //更新题目数量
|
|
|
- ItemCond itemCond = null;
|
|
|
- try
|
|
|
- {
|
|
|
-
|
|
|
- itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
|
|
|
- }
|
|
|
- catch (Exception )
|
|
|
- {
|
|
|
- itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-{itemInfo.code.Replace("Item-", "")}", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(),subjects= new List<SubjectCount>() };
|
|
|
-
|
|
|
- };
|
|
|
- ItemService.CountItemCond(itemInfo, olditemInfo, itemCond);
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -215,7 +181,6 @@ namespace TEAMModelOS.Controllers
|
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location},item/upsert()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
/// <summary>
|
|
|
//获取题目摘要信息
|
|
@@ -330,47 +295,21 @@ namespace TEAMModelOS.Controllers
|
|
|
if (scope.ToString().Equals("school"))
|
|
|
{
|
|
|
ItemInfo itemInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemInfo>(id.ToString(), new PartitionKey($"{code}"));
|
|
|
- //更新题目数量
|
|
|
- ItemCond itemCond = null;
|
|
|
- try
|
|
|
- {
|
|
|
-
|
|
|
- itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
|
|
|
- }
|
|
|
- catch (Exception )
|
|
|
- {
|
|
|
- itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
|
|
|
-
|
|
|
- };
|
|
|
- ItemService.CountItemCond(null, itemInfo, itemCond);
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
|
|
|
+ ItemCondDto itemCondDto = new ItemCondDto { odlItem = itemInfo, key = $"ItemCond-{itemInfo.code.Replace("Item-", "")}", filed = itemInfo.periodId, scope = "school" };
|
|
|
+ var messageBlobItemCond = new ServiceBusMessage(itemCondDto.ToJsonString());
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync("itemcond", messageBlobItemCond);
|
|
|
var response = await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
|
|
|
return Ok(new { code = response.Status });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
ItemInfo olditemInfo = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<ItemInfo>($"{id}", new PartitionKey($"{code}"));
|
|
|
- //更新题目数量
|
|
|
- ItemCond itemCond = null;
|
|
|
- string condId = code.ToString().Replace("Item-", "");
|
|
|
- try
|
|
|
- {
|
|
|
-
|
|
|
- itemCond = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<ItemCond>(condId, new PartitionKey("ItemCond"));
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- itemCond = new ItemCond() { id = condId, code = $"ItemCond", pk = "ItemCond", ttl = -1, count = 0 };
|
|
|
-
|
|
|
- };
|
|
|
- ItemService.CountItemCond(null, olditemInfo, itemCond);
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<ItemCond>(itemCond, new PartitionKey(itemCond.code));
|
|
|
+ ItemCondDto itemCondDto = new ItemCondDto { odlItem = olditemInfo, key = "ItemCond", filed = olditemInfo.code.Replace("Item-", ""), scope = "private" };
|
|
|
+ var messageBlobItemCond = new ServiceBusMessage(itemCondDto.ToJsonString());
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync("itemcond", messageBlobItemCond);
|
|
|
var response = await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
|
|
|
return Ok(new { code = response.Status });
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|