|
@@ -15,8 +15,10 @@ using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
|
+using TEAMModelBI.Filter;
|
|
|
using TEAMModelBI.Models;
|
|
|
using TEAMModelBI.Tool;
|
|
|
+using TEAMModelBI.Tool.Extension;
|
|
|
using TEAMModelOS.Models;
|
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
|
using TEAMModelOS.SDK.Context.Constant;
|
|
@@ -118,6 +120,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "admin")]
|
|
|
[HttpPost("copy-infos")]
|
|
|
public async Task<IActionResult> CopyInfos(JsonElement jsonElement)
|
|
|
{
|
|
@@ -126,12 +129,16 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
if (!jsonElement.TryGetProperty("papers", out JsonElement jsPapers)) return BadRequest();
|
|
|
if (!jsonElement.TryGetProperty("newSc", out JsonElement _newSchool)) return BadRequest();
|
|
|
|
|
|
+ var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
|
List<CopyPaper> papers = jsPapers.ToObject<List<CopyPaper>>();
|
|
|
List<newSchool> newSchools = _newSchool.ToObject<List<newSchool>>();
|
|
|
+ StringBuilder msg = new($"{_tmdName}[{_tmdId}]操作复制试卷:");
|
|
|
|
|
|
List<Task<CopyFromUriOperation>> filelist = new(); //可复制256M以上文件
|
|
|
List<dynamic> existScPaper = new();
|
|
|
var cosmosClinet = _azureCosmos.GetCosmosClient();
|
|
|
+ var tableClient = _azureStorage.GetCloudTableClient();
|
|
|
+ var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
|
|
|
foreach (var itemSc in newSchools)
|
|
|
{
|
|
|
List<string> existPaper = new();
|
|
@@ -148,6 +155,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
if (resState.Status == 200)
|
|
|
paper.id = Guid.NewGuid().ToString();
|
|
|
|
|
|
+ msg.Append($"将学校[{cItem.oldSc}]中的[{cItem.oldId}]试卷复制到新学校试卷新id:{paper.id}");
|
|
|
await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{paper.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{itemSc.newSc}") }))
|
|
|
{
|
|
|
existPaper.Add(item);
|
|
@@ -212,6 +220,8 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
}
|
|
|
if (existPaper.Count > 0)
|
|
|
existScPaper.Add(new { schoolId = itemSc.newSc, papers = existPaper });
|
|
|
+
|
|
|
+ msg.Append($"新学校Id[{itemSc.newSc}];");
|
|
|
}
|
|
|
if (filelist.Count <= 256)
|
|
|
await Task.WhenAll(filelist);
|
|
@@ -225,12 +235,14 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
await Task.WhenAll(rspBlobCopyInfos);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ //保存操作记录
|
|
|
+ await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "paper-copy-infos", msg.ToString(), _dingDing, httpContext: HttpContext);
|
|
|
return Ok(new { state = RespondCode.Ok , existScPaper });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- //await _dingDing.SendBotMsg($"BI,{_option.Location} /paper/copy-infos \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"BI,{_option.Location} /paper/copy-infos \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
}
|