|
@@ -230,7 +230,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
if (string.IsNullOrEmpty(ps.sheet))
|
|
if (string.IsNullOrEmpty(ps.sheet))
|
|
{
|
|
{
|
|
- sheet.id = await genSheetId(client, sheet.code, tbname);
|
|
|
|
|
|
+ sheet.id = await SheetService.genSheetId(client,_dingDing,_option, sheet.code, tbname);
|
|
exam.papers.ForEach(x =>
|
|
exam.papers.ForEach(x =>
|
|
{
|
|
{
|
|
if (x.id.Equals($"{_paperId}"))
|
|
if (x.id.Equals($"{_paperId}"))
|
|
@@ -265,7 +265,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
Paper paper = await client.GetContainer("TEAMModelOS", tbname).ReadItemAsync<Paper>($"{_paperId}", new PartitionKey($"{code}"));
|
|
Paper paper = await client.GetContainer("TEAMModelOS", tbname).ReadItemAsync<Paper>($"{_paperId}", new PartitionKey($"{code}"));
|
|
if (string.IsNullOrEmpty(paper.sheet))
|
|
if (string.IsNullOrEmpty(paper.sheet))
|
|
{
|
|
{
|
|
- sheet.id = await genSheetId(client, sheet.code, tbname);
|
|
|
|
|
|
+ sheet.id =await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
|
|
paper.sheet = sheet.id;
|
|
paper.sheet = sheet.id;
|
|
paper = await client.GetContainer("TEAMModelOS", tbname).ReplaceItemAsync<Paper>(paper, $"{_paperId}", new PartitionKey($"{code}"));
|
|
paper = await client.GetContainer("TEAMModelOS", tbname).ReplaceItemAsync<Paper>(paper, $"{_paperId}", new PartitionKey($"{code}"));
|
|
}
|
|
}
|
|
@@ -283,7 +283,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
else if (string.IsNullOrEmpty($"{ _examId}") && string.IsNullOrEmpty($"{ _paperId}"))
|
|
else if (string.IsNullOrEmpty($"{ _examId}") && string.IsNullOrEmpty($"{ _paperId}"))
|
|
{
|
|
{
|
|
if (string.IsNullOrEmpty(sheet.id)) {
|
|
if (string.IsNullOrEmpty(sheet.id)) {
|
|
- sheet.id = await genSheetId(client, sheet.code, tbname);
|
|
|
|
|
|
+ sheet.id = await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -292,8 +292,8 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(sheet.id))
|
|
if (string.IsNullOrEmpty(sheet.id))
|
|
{
|
|
{
|
|
- sheet.id = await genSheetId(client, sheet.code, tbname);
|
|
|
|
-
|
|
|
|
|
|
+ sheet.id = await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
|
|
|
|
+
|
|
}
|
|
}
|
|
sheet = await client.GetContainer("TEAMModelOS", tbname).UpsertItemAsync(sheet, new PartitionKey($"{sheet.code}"));
|
|
sheet = await client.GetContainer("TEAMModelOS", tbname).UpsertItemAsync(sheet, new PartitionKey($"{sheet.code}"));
|
|
return Ok(new { config = sheet, status=200 });
|
|
return Ok(new { config = sheet, status=200 });
|
|
@@ -309,32 +309,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private async Task<string> genSheetId(CosmosClient client,string sheetCode,string tbname) {
|
|
|
|
- string _num09 = "0123456789";
|
|
|
|
- string id = $"{Utils.CreatSaltString(7, _num09)}";
|
|
|
|
- for (int i = 0; i < 10; i++)
|
|
|
|
- {
|
|
|
|
- Response response = await client.GetContainer("TEAMModelOS", tbname).ReadItemStreamAsync($"{id}", new PartitionKey(sheetCode)); ;
|
|
|
|
- if (response.Status == 404)
|
|
|
|
- {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (i == 9)
|
|
|
|
- {
|
|
|
|
- string msg= "common/SheetConfig/upsert()\n id生成异常,重复生成次数超过10次";
|
|
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},{msg}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
- throw new Exception(msg);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- id = $"{Utils.CreatSaltString(7, _num09)}";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return id;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
///删除答题卡
|
|
///删除答题卡
|
|
/// </summary>
|
|
/// </summary>
|