JAELYS 4 lat temu
rodzic
commit
7cf7134c99

+ 44 - 1
TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosExtensions.cs

@@ -25,7 +25,7 @@ using TEAMModelOS.SDK.Models;
 namespace TEAMModelOS.SDK.DI
 {
     public static class AzureCosmosExtensions
-    {    
+    {
         public static double RU(this Response response)
         {
             try
@@ -53,6 +53,13 @@ namespace TEAMModelOS.SDK.DI
             }
         }
 
+        /// <summary>
+        /// 取得当前容器指定分区键的Count数,支持SQL Where条件,不支持排序
+        /// </summary>
+        /// <param name="container"></param>
+        /// <param name="partitionkey"></param>
+        /// <param name="queryWhere"></param>
+        /// <returns></returns>
         public static async Task<int> GetCount(this CosmosContainer container, string partitionkey, string queryWhere = "WHERE 1=1")
         {
             int totalCount = 0;
@@ -71,5 +78,41 @@ namespace TEAMModelOS.SDK.DI
             }
             return totalCount;
         }
+
+        public static async Task<List<Response>> DeleteItemsStreamAsync(this CosmosContainer container, List<string> ids, string partitionkey )
+        {
+            List<Response> responses = new List<Response>();
+
+            foreach (var id in ids)
+            {
+                try
+                {
+                    responses.Add(await container.DeleteItemStreamAsync(id, new PartitionKey(partitionkey)));
+                }
+                catch 
+                {
+                    continue;
+                }
+            }
+            return responses;
+        }
+
+        public static async Task<List<ItemResponse<T>>> DeleteItemsAsync<T>(this CosmosContainer container, List<string> ids, string partitionkey)
+        {
+            List<ItemResponse<T>> responses = new List<ItemResponse<T>>();
+
+            foreach (var id in ids)
+            {
+                try
+                {
+                    responses.Add(await container.DeleteItemAsync<T>(id, new PartitionKey(partitionkey)));
+                }
+                catch
+                {
+                    continue;
+                }
+            }
+            return responses;
+        }
     }
 }

+ 1 - 2
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageBlobExtensions.cs

@@ -38,8 +38,7 @@ namespace TEAMModelOS.SDK.DI
             }
         }
 
-        /// <summary>
-        /// https://teammodelstorage.blob.core.chinacloudapi.cn/ydzt/112315401795%2F
+        /// <summary>        
         /// 批量刪除Blobs
         /// </summary>      
         /// <param name="prefix">篩選開頭名稱,Null代表容器</param>        

+ 0 - 1
TEAMModelOS/TEAMModelOS.csproj

@@ -43,7 +43,6 @@
   </ItemGroup>
 
   <ItemGroup>
-    <Folder Include="Controllers\Task\" />
     <Folder Include="JwtRsaFile\" />
     <Folder Include="Services\Evaluation\" />
     <Folder Include="wwwroot\" />