|
@@ -10,6 +10,7 @@ using System;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Net.Http;
|
|
using System.Net.Http;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Threading.Tasks;
|
|
|
|
|
|
namespace Flyinsono.DBCopy.Tool.Utilities
|
|
namespace Flyinsono.DBCopy.Tool.Utilities
|
|
{
|
|
{
|
|
@@ -31,7 +32,7 @@ namespace Flyinsono.DBCopy.Tool.Utilities
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="prefix">查询的文件名前缀</param>
|
|
/// <param name="prefix">查询的文件名前缀</param>
|
|
/// <param name="excludeList">需要排除的文件名列表</param>
|
|
/// <param name="excludeList">需要排除的文件名列表</param>
|
|
- public void RunClear(List<string> searchPrefixList, List<string> excludeList)
|
|
|
|
|
|
+ public async Task<bool> RunClear(List<string> searchPrefixList, List<string> excludeList)
|
|
{
|
|
{
|
|
//签名
|
|
//签名
|
|
CosSignature signature = new CosSignature(secretId, secretKey, "/");
|
|
CosSignature signature = new CosSignature(secretId, secretKey, "/");
|
|
@@ -41,7 +42,7 @@ namespace Flyinsono.DBCopy.Tool.Utilities
|
|
|
|
|
|
_bucketList.ForEach(bucket =>
|
|
_bucketList.ForEach(bucket =>
|
|
{
|
|
{
|
|
- searchPrefixList.ForEach(item =>
|
|
|
|
|
|
+ searchPrefixList.ForEach(async item =>
|
|
{
|
|
{
|
|
//查询
|
|
//查询
|
|
using (HttpClient client = new HttpClient())
|
|
using (HttpClient client = new HttpClient())
|
|
@@ -52,11 +53,11 @@ namespace Flyinsono.DBCopy.Tool.Utilities
|
|
do
|
|
do
|
|
{
|
|
{
|
|
// 发送查询请求
|
|
// 发送查询请求
|
|
- HttpResponseMessage response = client.GetAsync($"{bucket}/?delimiter=|&encoding-type=url&marker={nextMarker}&max-keys=1000&prefix={item}").Result;
|
|
|
|
|
|
+ HttpResponseMessage response = await client.GetAsync($"{bucket}/?delimiter=|&encoding-type=url&marker={nextMarker}&max-keys=1000&prefix={item}");
|
|
// 输出响应结果
|
|
// 输出响应结果
|
|
Console.WriteLine($"Status code: {response.StatusCode}");
|
|
Console.WriteLine($"Status code: {response.StatusCode}");
|
|
nextMarker = string.Empty;
|
|
nextMarker = string.Empty;
|
|
- var json = response.Content.ReadAsStringAsync().Result;
|
|
|
|
|
|
+ var json = await response.Content.ReadAsStringAsync();
|
|
File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "source.txt"), json);
|
|
File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "source.txt"), json);
|
|
dynamic dynamicRoot = new System.Dynamic.ExpandoObject();
|
|
dynamic dynamicRoot = new System.Dynamic.ExpandoObject();
|
|
XElement root = XElement.Parse(json);
|
|
XElement root = XElement.Parse(json);
|
|
@@ -93,6 +94,7 @@ namespace Flyinsono.DBCopy.Tool.Utilities
|
|
});
|
|
});
|
|
});
|
|
});
|
|
File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "output.txt"), string.Join('\n', fileList));
|
|
File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "output.txt"), string.Join('\n', fileList));
|
|
|
|
+ return await Task.FromResult(true);
|
|
}
|
|
}
|
|
|
|
|
|
private void RemoveCosFile(string bucket,string fileName)
|
|
private void RemoveCosFile(string bucket,string fileName)
|