|
@@ -706,13 +706,29 @@ namespace TEAMModelOS.Controllers
|
|
|
[HttpPost("test-blob-folder")]
|
|
|
public async Task<IActionResult> TestBlobFolder(JsonElement json)
|
|
|
{
|
|
|
- var client= _azureStorage.GetBlobContainerClient("1595321354") ;
|
|
|
+ var client = _azureStorage.GetBlobContainerClient("1595321354") ;
|
|
|
List<BlobItem> blobItems = new List<BlobItem>();
|
|
|
- await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"records/207784031177150464/")) {
|
|
|
- blobItems.Add(item);
|
|
|
- break;
|
|
|
+ HashSet<string> ids = new HashSet<string>();
|
|
|
+ string path = $"records";
|
|
|
+ await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, path)) {
|
|
|
+ var p= item.Name.Split("/");
|
|
|
+ if (p.Length > 2) {
|
|
|
+ ids.Add(p[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<string> lessonIds = new List<string>();
|
|
|
+ string sql = "select value(c.id) from c ";
|
|
|
+ await foreach(var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
+ .GetItemQueryIterator<string>(queryText:sql ,requestOptions:new QueryRequestOptions { PartitionKey= new PartitionKey("LessonRecord-1595321354") }))
|
|
|
+ {
|
|
|
+ lessonIds.Add(item);
|
|
|
}
|
|
|
- return Ok(blobItems);
|
|
|
+ var notdata = ids.Except(lessonIds);
|
|
|
+ var notblob = lessonIds.Except(ids).ToList() ;
|
|
|
+ List<string> paths = notdata.Select(x => $"records/{x}").ToList() ;
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).DeleteItemsStreamAsync(notblob, "LessonRecord-1595321354");
|
|
|
+ await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, "1595321354", paths);
|
|
|
+ return Ok(new { lessonIds , ids , notdata, notblob });
|
|
|
}
|
|
|
}
|
|
|
|