|
@@ -1070,6 +1070,34 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ #region
|
|
|
|
+ //start处理历史数据
|
|
|
|
+ var blobclient = _azureStorage.GetBlobContainerClient(blobname);
|
|
|
|
+ List<BlobItem> blobItems = new List<BlobItem>();
|
|
|
|
+ HashSet<string> ids = new HashSet<string>();
|
|
|
|
+ string path = $"records";
|
|
|
|
+ await foreach (BlobItem item in blobclient.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, tbname)
|
|
|
|
+ .GetItemQueryIterator<string>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey(code) }))
|
|
|
|
+ {
|
|
|
|
+ lessonIds.Add(item);
|
|
|
|
+ }
|
|
|
|
+ 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, tbname).DeleteItemsStreamAsync(notblob, code);
|
|
|
|
+ await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, blobname, paths);
|
|
|
|
+ //end 处理历史数据
|
|
|
|
+ #endregion
|
|
await client.GetContainer(Constant.TEAMModelOS, tbname).DeleteItemAsync<LessonRecord>(lessonId, new PartitionKey(code));
|
|
await client.GetContainer(Constant.TEAMModelOS, tbname).DeleteItemAsync<LessonRecord>(lessonId, new PartitionKey(code));
|
|
await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, blobname, new List<string> { $"records/{_lessonId}" });
|
|
await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, blobname, new List<string> { $"records/{_lessonId}" });
|
|
await client.GetContainer(Constant.TEAMModelOS, tbname).DeleteItemStreamAsync(lessonRecord.id,new PartitionKey ($"Bloblog-{blobname}"));
|
|
await client.GetContainer(Constant.TEAMModelOS, tbname).DeleteItemStreamAsync(lessonRecord.id,new PartitionKey ($"Bloblog-{blobname}"));
|