Ver Fonte

配置站内消息和新增批量复制文件Function
完善批量创区接口。新增批量复制文件服务方法,以及消息实体类

Li há 3 anos atrás
pai
commit
2d7be83de3

+ 72 - 117
TEAMModeBI/Controllers/BISchool/BatchAreaController.cs

@@ -23,6 +23,10 @@ using System.Text;
 using Azure.Storage.Sas;
 using Azure.Storage.Blobs.Specialized;
 using Azure;
+using TEAMModelOS.SDK.Models.Cosmos.BI;
+using Azure.Messaging.ServiceBus;
+using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK.Models.Service;
 
 namespace TEAMModeBI.Controllers.BISchool
 {
@@ -35,14 +39,18 @@ namespace TEAMModeBI.Controllers.BISchool
         private readonly Option _option;
         private readonly AzureStorageFactory _azureStorage;
         private readonly IConfiguration _configuration;
+        private readonly NotificationService _notificationService;
+        private readonly AzureServiceBusFactory _serviceBus;
 
-        public BatchAreaController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IConfiguration configuration)
+        public BatchAreaController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IConfiguration configuration,NotificationService notificationService, AzureServiceBusFactory serviceBus)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _azureStorage = azureStorage;
             _option = option?.Value;
             _configuration = configuration;
+            _notificationService = notificationService;
+            _serviceBus = serviceBus;
         }
 
         /// <summary>
@@ -148,8 +156,10 @@ namespace TEAMModeBI.Controllers.BISchool
                 if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
                 if (!jsonElement.TryGetProperty("standardName", out JsonElement standardName)) return BadRequest();
                 if (!jsonElement.TryGetProperty("institution", out JsonElement institution)) return BadRequest();
+                if (!jsonElement.TryGetProperty("tmdId", out JsonElement _tmdid)) return BadRequest();
+                if (!jsonElement.TryGetProperty("tmdName", out JsonElement _tmdName)) return BadRequest();
                 if (!jsonElement.TryGetProperty("oldstandard", out JsonElement oldstandard)) return BadRequest();
-                
+
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 //查询新的是否存在
                 await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
@@ -190,14 +200,7 @@ namespace TEAMModeBI.Controllers.BISchool
                 {
                     if (!string.IsNullOrEmpty(item.blob))
                     {
-                        //string _oldurl = item.blob;  //要复制文件的位置
                         item.blob = item.blob.Replace($"{oldstandard}", $"{standard}");
-                        //string _newurl = item.blob;  //文件目标位置
-                        //var blobcc = _azureStorage.GetBlobContainerClient("teammodelos");  //获取blob连接地址
-                        ////int index = $"{_oldurl}".IndexOf("/", 0);  //第一次出现的位置
-                        //string oldUrl = $"{_oldurl}".IndexOf("/", 0) == 0 ? oldUrl = $"{_oldurl}".Substring(1) : oldUrl = $"{_oldurl}"; //判定指定位置是否出现指定字符,出现则删除,不出现直接使用地址
-                        //var urlSaS = _azureStorage.GetBlobSAS($"teammodelos", oldUrl, BlobSasPermissions.Read | BlobSasPermissions.List);    // 取得容器sas和有效期
-                        //blobcc.GetBlobClient($"{_newurl}").SyncCopyFromUri(new Uri(urlSaS));//执行复制操作
                     };
 
                     item.standard = $"{standard}";
@@ -226,14 +229,7 @@ namespace TEAMModeBI.Controllers.BISchool
                             {
                                 if (!string.IsNullOrEmpty($"{rnode.link}"))
                                 {
-                                    //string _oldurl = rnode.link;   //要复制文件的位置
                                     rnode.link = rnode.link.Replace($"{oldstandard}", $"{standard}");
-                                    //string _newurl = rnode.link;   //文件目标位置
-                                    //var blobcc = _azureStorage.GetBlobContainerClient($"{rnode.cntr}");  //获取blob连接地址
-                                    ////int index = $"{_oldurl}".IndexOf("/", 0);  //第一次出现的位置
-                                    //string oldUrl = $"{_oldurl}".IndexOf("/", 0) == 0 ? oldUrl = $"{_oldurl}".Substring(1) : oldUrl = $"{_oldurl}"; //判定指定位置是否出现指定字符,出现则删除,不出现直接使用地址
-                                    //var urlSaS = _azureStorage.GetBlobSAS($"{rnode.cntr}", oldUrl, BlobSasPermissions.Read | BlobSasPermissions.List);    // 取得容器sas和有效期
-                                    ////blobcc.GetBlobClient($"{_newurl}").SyncCopyFromUri(new Uri(urlSaS));//执行复制操作
                                 }
                                 rnodes.Add(rnode);
                             }
@@ -257,30 +253,52 @@ namespace TEAMModeBI.Controllers.BISchool
                     await Task.WhenAll(abilityTasks);
                 }
 
-                Area area = null ;
-
-                //查询要复制的区级信息
-                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='{oldstandard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
-                {
-
-                    area = item ;
-                }
-                if (area != null)
+                //政策文件
+                StandardFile standardFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<StandardFile>($"{_tmdid}", new PartitionKey($"StandardFile"));
+                standardFile.standard = $"{standard}";
+                standardFile.id = areaId;
+                await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
+
+                //区域配置
+                AreaSetting areaSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>($"{_tmdid}", new PartitionKey($"AreaSetting"));
+                areaSetting.accessConfig = null;
+                areaSetting.id = areaId;
+                await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
+                
+                //分区键
+                string code = "copyAbility-mark";
+                
+                //执行复制操作
+                BatchCopyFile batchCopyFile = new BatchCopyFile();
+                batchCopyFile.blobCntr = "teammodelos";
+                batchCopyFile.oldFileName = $"{oldstandard}";
+                batchCopyFile.newFileName = $"{standard}";
+                batchCopyFile.tmdid = $"{_tmdid}";
+                batchCopyFile.tmdIds = new List<string> { $"{ _tmdid}" };
+                batchCopyFile.codeKey = code;
+                batchCopyFile.tmdName = $"{_tmdName}";
+                var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
+                messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
+                var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+                await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile);
+
+                //发送消息实体
+                Notification notification = new Notification
                 {
-                    //政策文件
-                    StandardFile standardFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<StandardFile>(area.id, new PartitionKey($"StandardFile"));
-                    standardFile.standard = $"{standard}";
-                    standardFile.id = areaId;
-                    await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
-
-                    //区域配置
-                    AreaSetting areaSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(area.id, new PartitionKey($"AreaSetting"));
-                    areaSetting.accessConfig = null;
-                    areaSetting.id = areaId;
-                    await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
-                }
+                    hubName = "hita",
+                    type = "msg",
+                    from = $"ies5:{_option.Location}:private",
+                    to = new List<string> {$"{ _tmdid}"},
+                    label = $"{code}_start",
+                    body = new { location = _option.Location, biz = code, tmdid = $"{_tmdid}", tmdname = $"{_tmdName}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
+                    expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
+                };
 
-                await BarchCopyFile("teammodelos", $"{oldstandard}", $"{standard}");
+                var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
+                var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
+                var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
+                var location = _option.Location;
+                await _notificationService.SendNotification(clientID, clientSecret, location, url, notification); //站内发送消息
 
                 return Ok(new { state = 200, abilitie = abilities1.Count, abilitieTasksCount = abilityTasks1.Count});
             }
@@ -292,7 +310,7 @@ namespace TEAMModeBI.Controllers.BISchool
         }
 
         /// <summary>
-        /// 测试复制Blob中的文件
+        /// 测试复制Blob中的文件  批量创区接口测试完成后删除
         /// </summary>
         /// <param name="jsonElement"></param>
         /// <returns></returns>
@@ -325,7 +343,11 @@ namespace TEAMModeBI.Controllers.BISchool
 
         }
 
-
+        /// <summary>
+        /// 批量复制文件接口  批量创区接口测试完成后删除
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("copybolbFile")]
         public async Task<IActionResult> TestCopyBolbFile(JsonElement jsonElement)
@@ -337,39 +359,15 @@ namespace TEAMModeBI.Controllers.BISchool
             List<string> errmess = new List<string>();
             List<string> fils = new List<string>();
             List<Task<Response<BlobCopyInfo>>> file_list = new List<Task<Response<BlobCopyInfo>>>();
-            var client = _azureStorage.GetBlobContainerClient($"{_cntr}");
+            var client = _azureStorage.GetBlobContainerClient($"{_cntr}");//获取地址
             await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/{_oldstandard}/")) 
             {
                 fils.Add(item.Name);
-
-                var blobcc = _azureStorage.GetBlobContainerClient($"teammodelos");  //获取地址
-                string[] oldurl = $"{item.Name}".Split($"{_oldstandard}");
-
-                string newurl = null;
-                if (oldurl.Length == 2)
-                {
-                    newurl = $"{oldurl[0]}{_newstandard}{oldurl[1]}";
-                }
-                else if (oldurl.Length > 2)
-                {
-                    StringBuilder stringBuilder = new StringBuilder();
-                    stringBuilder.Append(oldurl[0]);
-                    stringBuilder.Append($"/{_newstandard}");
-                    for (int i = 1; i < oldurl.Length; i++) 
-                    {
-                        stringBuilder.Append(oldurl[i]);
-                    }
-                    newurl = stringBuilder.ToString();
-                }
-                else 
-                {
-                    errmess.Add(item.Name);
-                }
+                string oldurl1 = $"{item.Name}".Replace($"/{_oldstandard}/", $"/{_newstandard}/");
                 var urlSaS = _azureStorage.GetBlobSAS($"{_cntr}", item.Name, BlobSasPermissions.Read | BlobSasPermissions.List);    // 取得容器sas 和有效期
 
-                //blobcc.GetBlobClient($"{newurl}").SyncCopyFromUri(new Uri(urlSaS));
-                file_list.Add(blobcc.GetBlobClient($"{newurl}").SyncCopyFromUriAsync(new Uri(urlSaS)));
-                //file_list.Add
+                client.GetBlobClient(oldurl1).SyncCopyFromUri(new Uri(urlSaS));
+                //file_list.Add(blobcc.GetBlobClient($"{oldurl1}").SyncCopyFromUriAsync(new Uri(urlSaS)));
             }
 
             if (file_list.Count <= 256)
@@ -386,34 +384,12 @@ namespace TEAMModeBI.Controllers.BISchool
                 }
             }
 
-
-
-
-
-
-
-
-
-
-            //var bolobcc = _azureStorage.GetBlobContainerClient($"{_cntr}");  //获取地址
-
-            //string oldUrl = $"{_oldfile}";
-            //var urlSaS = _azureStorage.GetBlobSAS($"{_cntr}", oldUrl, BlobSasPermissions.All);    // 取得容器sas 和有效期
-            ////var urlSaS = $"{bolobcc.Uri}/{_oldfile}";
-            //BlobCopyFromUriOptions blobCopyFromUriOptions = new BlobCopyFromUriOptions();
-            //blobCopyFromUriOptions.ShouldSealDestination = true;
-            //var response = bolobcc.GetBlobClient($"{_newfile}").StartCopyFromUri(new Uri(urlSaS),blobCopyFromUriOptions);
-            ////var response = bolobcc.GetBlobClient($"{_newfile}").SyncCopyFromUri(new Uri(urlSaS));
-            ////var response = await bolobcc.GetBlobClient($"{_newfile}").SyncCopyFromUriAsync(new Uri(urlSaS));
-
             return Ok(new { fils.Count, fils });
-
-
         }
 
 
         /// <summary>
-        /// 批量复制文件夹
+        /// 批量复制文件夹方法   批量创区接口测试完成后删除
         /// </summary>
         /// <param name="_cntr"></param>
         /// <param name="_oldstandard"></param>
@@ -423,35 +399,14 @@ namespace TEAMModeBI.Controllers.BISchool
         {
             List<string> errmess = new List<string>();
             List<Task<Response<BlobCopyInfo>>> file_list = new List<Task<Response<BlobCopyInfo>>>();
-            var client = _azureStorage.GetBlobContainerClient($"{_cntr}");
+            var client = _azureStorage.GetBlobContainerClient($"{_cntr}");  //获取地址
             await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/{_oldstandard}/"))
             {
-                var blobcc = _azureStorage.GetBlobContainerClient($"teammodelos");  //获取地址
-                string[] oldurl = $"{item.Name}".Split($"{_oldstandard}");
-
-                string newurl = null;
-                if (oldurl.Length == 2)
-                {
-                    newurl = $"{oldurl[0]}{_newstandard}{oldurl[1]}";
-                }
-                else if (oldurl.Length > 2)
-                {
-                    StringBuilder stringBuilder = new StringBuilder();
-                    stringBuilder.Append(oldurl[0]);
-                    stringBuilder.Append($"/{_newstandard}");
-                    for (int i = 1; i < oldurl.Length; i++)
-                    {
-                        stringBuilder.Append(oldurl[i]);
-                    }
-                    newurl = stringBuilder.ToString();
-                }
-                else
-                {
-                    errmess.Add(item.Name);
-                }//yxpt/standard6/jyzx/002ea332-0d1f-717c-0589-5f54c3c5ef4a/3 各班分数等级占比分析.mp4
+                string oldurl1 = $"{item.Name}".Replace($"/{_oldstandard}/", $"/{_newstandard}/");
+                //yxpt/standard6/jyzx/002ea332-0d1f-717c-0589-5f54c3c5ef4a/3 各班分数等级占比分析.mp4
                 var urlSaS = _azureStorage.GetBlobSAS($"{_cntr}", item.Name, BlobSasPermissions.Read | BlobSasPermissions.List);    // 取得容器sas 和有效期
-                //blobcc.GetBlobClient($"{newurl}").SyncCopyFromUri(new Uri(urlSaS));
-                file_list.Add(blobcc.GetBlobClient($"{newurl}").SyncCopyFromUriAsync(new Uri(urlSaS)));       
+                //client.GetBlobClient($"{newurl}").SyncCopyFromUri(new Uri(urlSaS));
+                file_list.Add(client.GetBlobClient($"{oldurl1}").SyncCopyFromUriAsync(new Uri(urlSaS)));       
             }
 
             if (file_list.Count <= 256)

+ 56 - 1
TEAMModelFunction/MonitorServicesBus.cs

@@ -18,6 +18,10 @@ using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.Services.Common;
 using System.Linq;
 using TEAMModelOS.SDK.Models.Service;
+using TEAMModelOS.SDK.Models.Cosmos.BI;
+using TEAMModelOS.Models;
+using Microsoft.Extensions.Options;
+using Microsoft.Extensions.Configuration;
 
 namespace TEAMModelFunction
 {
@@ -29,13 +33,19 @@ namespace TEAMModelFunction
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureServiceBusFactory _serviceBus;
-        public MonitorServicesBus(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage   , AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus)
+        private readonly Option _option;
+        private readonly NotificationService _notificationService;
+        private readonly IConfiguration _configuration;
+        public MonitorServicesBus(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IOptionsSnapshot<Option> option, NotificationService notificationService, IConfiguration configuration)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _azureStorage = azureStorage;
             _azureRedis = azureRedis;
             _serviceBus = serviceBus;
+            _option = option?.Value;
+            _notificationService = notificationService;
+            _configuration = configuration;
         }
         [FunctionName("Exam")]
          public async Task Exam([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "exam", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
@@ -687,5 +697,50 @@ namespace TEAMModelFunction
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Product()\n{ex.Message}\n{ex.StackTrace}\n{msg}", GroupNames.醍摩豆服務運維群組);
             }
         }
+
+
+        /// <summary>
+        /// 批量复制文件
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [FunctionName("CopyStandardFile")]
+        public async Task BatchCopyBlob([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "copy-standard-file", Connection = "Azure:ServiceBus:ConnectionString")] string msg) 
+        {
+            try
+            {
+                //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-Blob复制文件-CopyStandardFile\n{msg}", GroupNames.成都开发測試群組);
+                var jsonMsg = JsonDocument.Parse(msg);
+                BatchCopyFile bIBatchCopyFile = msg.ToObject<BatchCopyFile>();
+
+                //批量复制文件
+                var result = await BatchCopyFileService.CopyFile(_dingDing, _azureStorage, bIBatchCopyFile);
+                if (result == 200)
+                {
+                    //发送消息实体
+                    Notification notification = new Notification
+                    {
+                        hubName = "hita",
+                        type = "msg",
+                        from = $"ies5:{_option.Location}:private",
+                        to = bIBatchCopyFile.tmdIds,
+                        label = $"{bIBatchCopyFile.codeKey}_finish",
+                        body = new { location = _option.Location, biz = $"{bIBatchCopyFile.codeKey}", tmdid = $"{bIBatchCopyFile.tmdid}", tmdname = $"{bIBatchCopyFile.tmdName}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
+                        expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
+                    };
+
+                    var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
+                    var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
+                    var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
+                    var location = _option.Location;
+                    await _notificationService.SendNotification(clientID, clientSecret, location, url, notification); //站内发送消息
+                }
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-Blob复制文件-CopyStandardFile\n{ex.Message}\n{ex.StackTrace}\n{msg}", GroupNames.醍摩豆服務運維群組);
+            }
+        }
+    
     }
 }

+ 5 - 1
TEAMModelFunction/local.settings.json

@@ -14,6 +14,10 @@
     "Azure:ServiceBus:NoticeTask": "dep-notice-task",
     "Azure:ServiceBus:ItemCondQueue": "dep-itemcond",
     "Option:Location": "China-Dep",
-    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
+    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
+    "HaBookAuth:CoreService:sendnotification": "https://api2.teammodel.net/service/sendnotification",
+    "HaBookAuth:CoreService:clientID": "c7317f88-7cea-4e48-ac57-a16071f7b884",
+    "HaBookAuth:CoreService:clientSecret": "kguxh:V.PLmxBdaI@jnrTrDSth]A3346"
+
   }  
 }

+ 40 - 0
TEAMModelOS.SDK/Models/Cosmos/BI/BatchCopyFile.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Models.Cosmos.BI
+{
+    public class BatchCopyFile
+    {
+        /// <summary>
+        /// 发送醍摩豆ID
+        /// </summary>
+        public string tmdid { get; set; }
+        /// <summary>
+        /// 发送则名称
+        /// </summary>
+        public string tmdName { get; set; }
+        /// <summary>
+        /// 分区键
+        /// </summary>
+        public string codeKey { get; set; }
+        /// <summary>
+        /// 发送消息给醍摩豆ID集合
+        /// </summary>
+        public List<string> tmdIds { get; set; }
+        /// <summary>
+        /// Blob容器
+        /// </summary>
+        public string blobCntr { get; set; }
+
+        /// <summary>
+        /// 旧文件夹名称
+        /// </summary>
+        public string oldFileName { get; set; }
+
+        /// <summary>
+        /// 新文件夹名称
+        /// </summary>
+        public string newFileName { get; set; }
+    }
+}

+ 63 - 0
TEAMModelOS.SDK/Models/Service/BatchCopyFileService.cs

@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Models.Cosmos.BI;
+using Azure.Storage.Blobs.Models;
+using Azure;
+using Azure.Storage.Sas;
+using System.Linq;
+
+namespace TEAMModelOS.SDK.Models.Service
+{
+    public class BatchCopyFileService
+    {
+        /// <summary>
+        /// 执行批量操作方法
+        /// </summary>
+        /// <param name="_dingDing"></param>
+        /// <param name="_azureStorage"></param>
+        /// <param name="batchCopyFile"></param>
+        /// <returns></returns>
+        public static async Task<int> CopyFile(DingDing _dingDing,AzureStorageFactory _azureStorage, BatchCopyFile batchCopyFile) 
+        {
+
+            try
+            {
+                List<Task<Response<BlobCopyInfo>>> filelist = new List<Task<Response<BlobCopyInfo>>>();
+                var azureClient = _azureStorage.GetBlobContainerClient($"{batchCopyFile.blobCntr}");//获取容器连接地址
+                                                                                                    //查询目录下所有容器路径
+                await foreach (BlobItem blobItem in azureClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/{batchCopyFile.oldFileName}/"))
+                {
+                    string newurl = $"{blobItem.Name}".Replace($"/{batchCopyFile.oldFileName}/", $"/{batchCopyFile.newFileName}/");//替换成新的容器路径
+                    var urlSas = _azureStorage.GetBlobSAS($"{batchCopyFile.blobCntr}", blobItem.Name, BlobSasPermissions.Read | BlobSasPermissions.List);   //获取容器sas和有效期
+                    filelist.Add(azureClient.GetBlobClient(newurl).SyncCopyFromUriAsync(new Uri(urlSas)));  //添加复制文件到集合执行复制操作
+                }
+                if (filelist.Count <= 256)
+                {
+                    await Task.WhenAll(filelist);
+                }
+                else
+                {
+                    int pages = (filelist.Count + 255) / 256;
+                    for (int i = 0; i < pages; i++)
+                    {
+                        List<Task<Response<BlobCopyInfo>>> rspBlobCopyInfos = filelist.Skip((i) * 256).Take(256).ToList();
+                        await Task.WhenAll(rspBlobCopyInfos);
+                    }
+                }
+
+                return 200;
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ExamService-saveMore\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return -1;
+            }
+
+
+        }
+
+    }
+}