소스 검색

完成Table的调整

CrazyIter 4 년 전
부모
커밋
793a2000e7
25개의 변경된 파일388개의 추가작업 그리고 1035개의 파일을 삭제
  1. 16 43
      TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosExtensions.cs
  2. 13 4
      TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosFactory.cs
  3. 23 0
      TEAMModelOS.SDK/DI/AzureStorage/AzureStorageFactory.cs
  4. 287 3
      TEAMModelOS.SDK/DI/AzureStorage/AzureStorageTableExtensions.cs
  5. 13 10
      TEAMModelOS.SDK/Extension/MessagePush/Implements/SendCloudService.cs
  6. 1 1
      TEAMModelOS.SDK/Helper/Security/RSACrypt/RSAUtils.cs
  7. 0 17
      TEAMModelOS.SDK/Module/AzureTable/Configuration/AzureTableOptions.cs
  8. 0 80
      TEAMModelOS.SDK/Module/AzureTable/Configuration/HaBookTableContinuationToken.cs
  9. 0 758
      TEAMModelOS.SDK/Module/AzureTable/Implements/AzureTableDBRepository.cs
  10. 0 41
      TEAMModelOS.SDK/Module/AzureTable/Interfaces/IAzureTableDBRepository.cs
  11. 2 3
      TEAMModelOS.Service/Services/Analysis/Implements/AchievementService.cs
  12. 5 4
      TEAMModelOS.Service/Services/Evaluation/Implements/ImportExerciseService.cs
  13. 1 2
      TEAMModelOS/Controllers/Analysis/AchievementController.cs
  14. 1 2
      TEAMModelOS/Controllers/Analysis/ChangeController.cs
  15. 1 2
      TEAMModelOS/Controllers/Core/CommonController.cs
  16. 4 3
      TEAMModelOS/Controllers/Core/FileController.cs
  17. 3 4
      TEAMModelOS/Controllers/School/ClassRoomController.cs
  18. 1 2
      TEAMModelOS/Controllers/School/SchoolController.cs
  19. 4 4
      TEAMModelOS/Controllers/Syllabus/KnowledgeController.cs
  20. 4 4
      TEAMModelOS/Controllers/Syllabus/ResourceController.cs
  21. 1 2
      TEAMModelOS/Controllers/Syllabus/SyllabusController.cs
  22. 1 2
      TEAMModelOS/Controllers/Syllabus/VolumeController.cs
  23. 1 2
      TEAMModelOS/Controllers/Task/HomeworkController.cs
  24. 3 4
      TEAMModelOS/Controllers/Teacher/SchoolUserController.cs
  25. 3 38
      TEAMModelOS/Startup.cs

+ 16 - 43
TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosExtensions.cs

@@ -57,21 +57,12 @@ namespace TEAMModelOS.SDK.DI
         public static async Task<T> FindByIdPk<T>(this AzureCosmosFactory azureCosmosFactory, string id, string pk) where T : ID
         public static async Task<T> FindByIdPk<T>(this AzureCosmosFactory azureCosmosFactory, string id, string pk) where T : ID
         {
         {
             AzureCosmosModel container = await azureCosmosFactory.InitializeCollection<T>();
             AzureCosmosModel container = await azureCosmosFactory.InitializeCollection<T>();
-            try
-            {
-                ItemResponse<T> response = await container.container.ReadItemAsync<T>(id: id, partitionKey: new PartitionKey(pk));
-                return response.Value;
-            }
-            catch (Exception ex)
-            {
-                return default;
-            }
-
+            ItemResponse<T> response = await container.container.ReadItemAsync<T>(id: id, partitionKey: new PartitionKey(pk));
+            return response.Value;
         }
         }
         public static async Task<List<T>> FindByIds<T>(this AzureCosmosFactory azureCosmosFactory, List<string> ids) where T : ID
         public static async Task<List<T>> FindByIds<T>(this AzureCosmosFactory azureCosmosFactory, List<string> ids) where T : ID
         {
         {
             AzureCosmosModel container = await azureCosmosFactory.InitializeCollection<T>();
             AzureCosmosModel container = await azureCosmosFactory.InitializeCollection<T>();
-
             if (container.cache && RedisHelper.Instance != null)
             if (container.cache && RedisHelper.Instance != null)
             {
             {
                 List<T> list = new List<T>();
                 List<T> list = new List<T>();
@@ -102,31 +93,24 @@ namespace TEAMModelOS.SDK.DI
         }
         }
         public static async Task<T> Save<T>(this AzureCosmosFactory azureCosmosFactory, T entity) where T : ID
         public static async Task<T> Save<T>(this AzureCosmosFactory azureCosmosFactory, T entity) where T : ID
         {
         {
-            try
+             
+            AzureCosmosModel container = await azureCosmosFactory. InitializeCollection<T>();
+            entity.pk = container.type.Name;
+            entity.ttl = null;
+            ItemResponse<T> response = await container.container.CreateItemAsync<T>(entity);
+            if (container.cache && RedisHelper.Instance != null)
             {
             {
-                AzureCosmosModel container = await azureCosmosFactory. InitializeCollection<T>();
-                entity.pk = container.type.Name;
-                entity.ttl = null;
-                ItemResponse<T> response = await container.container.CreateItemAsync<T>(entity);
-                if (container.cache && RedisHelper.Instance != null)
+                if (!RedisHelper.Exists(CacheCosmosPrefix + container.container.Id))
                 {
                 {
-                    if (!RedisHelper.Exists(CacheCosmosPrefix + container.container.Id))
-                    {
-                        await RedisHelper.HSetAsync(CacheCosmosPrefix + container.container.Id, entity.id, entity);
-                    }
-                    else
-                    {
-                        await RedisHelper.HSetAsync(CacheCosmosPrefix + container.container.Id, entity.id, entity);
-                        await RedisHelper.ExpireAsync(CacheCosmosPrefix + container.container.Id, timeoutSeconds);
-                    }
-
+                    await RedisHelper.HSetAsync(CacheCosmosPrefix + container.container.Id, entity.id, entity);
+                }
+                else
+                {
+                    await RedisHelper.HSetAsync(CacheCosmosPrefix + container.container.Id, entity.id, entity);
+                    await RedisHelper.ExpireAsync(CacheCosmosPrefix + container.container.Id, timeoutSeconds);
                 }
                 }
-                return response.Value;
-            }
-            catch (Exception e)
-            {
-                throw new BizException(e.Message);
             }
             }
+            return response.Value;
         }
         }
 
 
         public static async Task<List<T>> SaveAll<T>(this AzureCosmosFactory azureCosmosFactory, List<T> enyites) where T : ID
         public static async Task<List<T>> SaveAll<T>(this AzureCosmosFactory azureCosmosFactory, List<T> enyites) where T : ID
@@ -207,11 +191,6 @@ namespace TEAMModelOS.SDK.DI
         }
         }
         public static async Task<List<T>> SaveOrUpdateAll<T>(this AzureCosmosFactory azureCosmosFactory, List<T> enyites) where T : ID
         public static async Task<List<T>> SaveOrUpdateAll<T>(this AzureCosmosFactory azureCosmosFactory, List<T> enyites) where T : ID
         {
         {
-            //await Task.Run(() => Parallel.ForEach(entities, new ParallelOptions { MaxDegreeOfParallelism = 2 }, (item) =>
-            //{
-            //    Task.WaitAll(Update(item));
-            //}));
-
             int pages = (int)Math.Ceiling((double)enyites.Count / pageSize);
             int pages = (int)Math.Ceiling((double)enyites.Count / pageSize);
             AzureCosmosModel container = await azureCosmosFactory. InitializeCollection<T>();
             AzureCosmosModel container = await azureCosmosFactory. InitializeCollection<T>();
             bool flag = false;
             bool flag = false;
@@ -242,12 +221,6 @@ namespace TEAMModelOS.SDK.DI
                     tasks.Add(container.container.UpsertItemStreamAsync(item.Value, item.Key)
                     tasks.Add(container.container.UpsertItemStreamAsync(item.Value, item.Key)
                         .ContinueWith((Task<Response> task) =>
                         .ContinueWith((Task<Response> task) =>
                         {
                         {
-                            //using (ResponseMessage response = task.Result)
-                            //{
-                            //    if (!response.IsSuccessStatusCode)
-                            //    {
-                            //    }
-                            //}
                         }
                         }
                         ));
                         ));
                 });
                 });

+ 13 - 4
TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosFactory.cs

@@ -75,11 +75,11 @@ namespace TEAMModelOS.SDK.DI
             }
             }
         }
         }
 
 
-      
+
 
 
 
 
         /// <summary>
         /// <summary>
-        /// 获取需要的信息 
+        /// 调用表容器信息
         /// </summary>
         /// </summary>
         /// <typeparam name="T"></typeparam>
         /// <typeparam name="T"></typeparam>
         /// <returns></returns>
         /// <returns></returns>
@@ -99,6 +99,13 @@ namespace TEAMModelOS.SDK.DI
             }
             }
             return await InitializeCollection(cosmosDBAttribute, type.Name, partitionKey);
             return await InitializeCollection(cosmosDBAttribute, type.Name, partitionKey);
         }
         }
+        /// <summary>
+        /// 调用表容器信息
+        /// </summary>
+        /// <param name="cosmosDBAttribute"></param>
+        /// <param name="typeName"></param>
+        /// <param name="PartitionKey"></param>
+        /// <returns></returns>
         public async Task<AzureCosmosModel> InitializeCollection(CosmosDBAttribute cosmosDBAttribute, string typeName, string PartitionKey)
         public async Task<AzureCosmosModel> InitializeCollection(CosmosDBAttribute cosmosDBAttribute, string typeName, string PartitionKey)
         {
         {
             /////内存中已经存在这个表则直接返回
             /////内存中已经存在这个表则直接返回
@@ -121,7 +128,10 @@ namespace TEAMModelOS.SDK.DI
                 return cosmosModel;
                 return cosmosModel;
             }
             }
         }
         }
-
+        /// <summary>
+        /// 初始化数据配置信息
+        /// </summary>
+        /// <returns></returns>
         public async Task InitializeDatabase()
         public async Task InitializeDatabase()
         {
         {
             int CollectionThroughput = 400;
             int CollectionThroughput = 400;
@@ -140,7 +150,6 @@ namespace TEAMModelOS.SDK.DI
                     }
                     }
                 }
                 }
             }
             }
-
             //获取数据库所有的表
             //获取数据库所有的表
             List<Type> types = ReflectorExtensions.GetAllTypeAsAttribute<CosmosDBAttribute>(BaseConfigModel.Configuration.GetSection("Azure:Cosmos:ScanModel").Get<string[]>() );
             List<Type> types = ReflectorExtensions.GetAllTypeAsAttribute<CosmosDBAttribute>(BaseConfigModel.Configuration.GetSection("Azure:Cosmos:ScanModel").Get<string[]>() );
             foreach (Type type in types)
             foreach (Type type in types)

+ 23 - 0
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageFactory.cs

@@ -13,6 +13,8 @@ using Azure.Storage.Sas;
 using Azure.Storage;
 using Azure.Storage;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;
 using Azure.Storage.Queues;
 using Azure.Storage.Queues;
+using TEAMModelOS.SDK.Context.Attributes.Azure;
+using System.Threading.Tasks;
 
 
 namespace TEAMModelOS.SDK.DI
 namespace TEAMModelOS.SDK.DI
 {
 {
@@ -218,5 +220,26 @@ namespace TEAMModelOS.SDK.DI
                 return null;
                 return null;
             }
             }
         }
         }
+        public  async Task<CloudTable> InitializeTable<T>()
+        {
+            string TableName = GetTableSpace<T>();
+            CloudTable cloudTable = GetCloudTableClient().GetTableReference(TableName);
+            await cloudTable.CreateIfNotExistsAsync();
+            return cloudTable;
+        }
+        private string GetTableSpace<T>()
+        {
+            Type type = typeof(T);
+            string Name = type.Name;
+            object[] attributes = type.GetCustomAttributes(true);
+            foreach (object attribute in attributes) //2.通过映射,找到成员属性上关联的特性类实例,
+            {
+                if (attribute is TableNameAttribute tableSpace)
+                {
+                    Name = tableSpace.Name;
+                }
+            }
+            return Name;
+        }
     }
     }
 }
 }

+ 287 - 3
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageTableExtensions.cs

@@ -7,12 +7,14 @@ using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Linq;
 using System.Linq;
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
+using System.Reflection;
 
 
 namespace TEAMModelOS.SDK.DI
 namespace TEAMModelOS.SDK.DI
 {
 {
     public static class AzureStorageTableExtensions
     public static class AzureStorageTableExtensions
     {
     {
-
+ 
         #region CloudTable 批次操作    
         #region CloudTable 批次操作    
 
 
         /// <summary>
         /// <summary>
@@ -158,8 +160,6 @@ namespace TEAMModelOS.SDK.DI
             return queryResponse.Count();
             return queryResponse.Count();
         }
         }
 
 
-
-
         #endregion
         #endregion
 
 
         #region CloudTable Get All
         #region CloudTable Get All
@@ -226,7 +226,291 @@ namespace TEAMModelOS.SDK.DI
         }
         }
         #endregion
         #endregion
 
 
+        public static async Task<T> Save<T>(this AzureStorageFactory azureStorageFactory, TableEntity entity) where T : TableEntity, new()
+        {
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            TableOperation operation = TableOperation.Insert(entity);
+            TableResult result = await TableName.ExecuteAsync(operation);
+            return (T)result.Result;
+        }
+        public static async Task<T> SaveOrUpdate<T>(this AzureStorageFactory azureStorageFactory, TableEntity entity) where T : TableEntity, new()
+        {
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            TableOperation operation = TableOperation.InsertOrReplace(entity);
+            TableResult result = await TableName.ExecuteAsync(operation);
+            return (T)result.Result;
+        }
+
+        public static async Task<T> Update<T>(this AzureStorageFactory azureStorageFactory, TableEntity entity) where T : TableEntity, new()
+        {
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            TableOperation operation = TableOperation.Replace(entity);
+            TableResult result = await TableName.ExecuteAsync(operation);
+            return (T)result.Result;
+        }
+
+        public static async Task<T> Delete<T>(this AzureStorageFactory azureStorageFactory, TableEntity entity) where T : TableEntity, new()
+        {
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            TableOperation operation = TableOperation.Delete(entity);
+            TableResult result = await TableName.ExecuteAsync(operation);
+            return (T)result.Result;
+        }
+
+        public static async Task<List<T>> DeleteAll<T>(this AzureStorageFactory azureStorageFactory,  List<T> entitys) where T : TableEntity, new()
+        {
+            if (entitys.IsEmpty())
+            {
+                return null;
+            }
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            IList<Dictionary<string, List<T>>> listInfo = new List<Dictionary<string, List<T>>>();
+            foreach (IGrouping<string, T> group in entitys.GroupBy(c => c.PartitionKey))
+            {
+                Dictionary<string, List<T>> dictInfo = new Dictionary<string, List<T>>
+                {
+                    { group.Key, group.ToList() }
+                };
+                listInfo.Add(dictInfo);
+            }
+
+            foreach (Dictionary<string, List<T>> dict in listInfo)
+            {
+                IList<TableResult> result = null;
+                foreach (string key in dict.Keys)
+                {
+                    List<T> values = dict[key];
+                     
+                    int pageSize = 100;
+                    int pages = (int)Math.Ceiling((double)values.Count / pageSize);
+                    for (int i = 0; i < pages; i++)
+                    {
+                        List<T> lists = values.Skip((i) * pageSize).Take(pageSize).ToList();
+                        TableBatchOperation batchOperation = new TableBatchOperation();
+                        for (int j = 0; j < lists.Count; j++)
+                        {
+                            batchOperation.Delete(lists[j]);
+                        }
+                        result = await TableName.ExecuteBatchAsync(batchOperation);
+                    }
+                }
+            }
+            return entitys;
+        }
+
+        public static async Task<List<T>> SaveOrUpdateAll<T>(this AzureStorageFactory azureStorageFactory, List<T> entitys) where T : TableEntity, new()
+        {
+            if (entitys.IsEmpty())
+            {
+                return null;
+            }
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            IList<Dictionary<string, List<T>>> listInfo = new List<Dictionary<string, List<T>>>();
+            foreach (IGrouping<string, T> group in entitys.GroupBy(c => c.PartitionKey))
+            {
+                Dictionary<string, List<T>> dictInfo = new Dictionary<string, List<T>>
+                {
+                    { group.Key, group.ToList() }
+                };
+                listInfo.Add(dictInfo);
+            }
+
+            foreach (Dictionary<string, List<T>> dict in listInfo)
+            {
+                IList<TableResult> result = null;
+                foreach (string key in dict.Keys)
+                {
+                    List<T> values = dict[key];
+
+                    int pageSize = 100;
+                    int pages = (int)Math.Ceiling((double)values.Count / pageSize);
+                    for (int i = 0; i < pages; i++)
+                    {
+                        List<T> lists = values.Skip((i) * pageSize).Take(pageSize).ToList();
+                        TableBatchOperation batchOperation = new TableBatchOperation();
+                        for (int j = 0; j < lists.Count; j++)
+                        {
+                            batchOperation.InsertOrReplace(lists[j]);
+                        }
+                        result = await TableName.ExecuteBatchAsync(batchOperation);
+                    }
+                }
+            }
+            return entitys;
+        }
+        public static async Task<List<T>> UpdateAll<T>(this AzureStorageFactory azureStorageFactory, List<T> entitys) where T : TableEntity, new()
+        {
+            if (entitys.IsEmpty())
+            {
+                return null;
+            }
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            IList<Dictionary<string, List<T>>> listInfo = new List<Dictionary<string, List<T>>>();
+            foreach (IGrouping<string, T> group in entitys.GroupBy(c => c.PartitionKey))
+            {
+                Dictionary<string, List<T>> dictInfo = new Dictionary<string, List<T>>
+                {
+                    { group.Key, group.ToList() }
+                };
+                listInfo.Add(dictInfo);
+            }
+
+            foreach (Dictionary<string, List<T>> dict in listInfo)
+            {
+                IList<TableResult> result = null;
+                foreach (string key in dict.Keys)
+                {
+                    List<T> values = dict[key];
+                  
+                    int pageSize = 100;
+                    int pages = (int)Math.Ceiling((double)values.Count / pageSize);
+                    for (int i = 0; i < pages; i++)
+                    {
+                        List<T> lists = values.Skip((i) * pageSize).Take(pageSize).ToList();
+                        TableBatchOperation batchOperation = new TableBatchOperation();
+                        for (int j = 0; j < lists.Count; j++)
+                        {
+                            batchOperation.Replace(lists[j]);
+                        }
+                        result = await TableName.ExecuteBatchAsync(batchOperation);
+                    }
+                }
+            }
+            return entitys;
+        }
+        public static async Task<List<T>> SaveAll<T>(this AzureStorageFactory azureStorageFactory, List<T> entitys) where T : TableEntity, new()
+        {
+            if (entitys.IsEmpty())
+            {
+                return null;
+            }
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            IList<Dictionary<string, List<T>>> listInfo = new List<Dictionary<string, List<T>>>();
+            foreach (IGrouping<string, T> group in entitys.GroupBy(c => c.PartitionKey))
+            {
+                Dictionary<string, List<T>> dictInfo = new Dictionary<string, List<T>>
+                {
+                    { group.Key, group.ToList() }
+                };
+                listInfo.Add(dictInfo);
+            }
+
+            foreach (Dictionary<string, List<T>> dict in listInfo)
+            {
+                IList<TableResult> result = null;
+                foreach (string key in dict.Keys)
+                {
+                    List<T> values = dict[key];
+                  
+                    int pageSize = 100;
+                    int pages = (int)Math.Ceiling((double)values.Count / pageSize);
+                    for (int i = 0; i < pages; i++)
+                    {
+                        List<T> lists = values.Skip((i) * pageSize).Take(pageSize).ToList();
+                        TableBatchOperation batchOperation = new TableBatchOperation();
+                        for (int j = 0; j < lists.Count; j++)
+                        {
+                            batchOperation.Insert(lists[j]);
+                        }
+                        result = await TableName.ExecuteBatchAsync(batchOperation);
+                    }
+                }
+            }
+            return entitys;
+        }
+
+        public static async Task<List<T>> FindListByDict<T>(this AzureStorageFactory azureStorageFactory, Dictionary<string, object> dict) where T : TableEntity, new()
+        {
+            CloudTable TableName = await azureStorageFactory.InitializeTable<T>();
+            var exQuery = new TableQuery<T>();
+            StringBuilder builder = new StringBuilder();
+            if (null != dict && dict.Count > 0)
+            {
+                var keys = dict.Keys;
+                int index = 1;
+                foreach (string key in keys)
+                {
+                    if (dict[key] != null && !string.IsNullOrEmpty(dict[key].ToString()))
+                    {
+                        string typeStr = SwitchType<T>(dict[key], key);
+                        if (string.IsNullOrEmpty(typeStr))
+                        {
+                            continue;
+                        }
+                        if (index == 1)
+                        {
+                            //builder.Append(TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
+                            builder.Append(typeStr);
+
+                        }
+                        else
+                        {
+                            //builder.Append("  " + TableOperators.And + "  " + TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
+                            builder.Append("  " + TableOperators.And + "  " + typeStr);
+
+                        }
+                        index++;
+                    }
+                    else
+                    {
+                        throw new Exception("The parameter must have value!");
+                    }
+                }
+
+                exQuery.Where(builder.ToString());
+                return await QueryList<T>(exQuery, TableName);
+            }
+            else
+            {
+                return null;
+            }
+        }
+
 
 
 
 
+        private static async Task<List<T>> QueryList<T>(TableQuery<T> exQuery, CloudTable TableName  ) where T : TableEntity, new()
+        {
+            TableContinuationToken continuationToken = null;
+            List<T> entitys = new List<T>();
+            do
+            {
+                var result = await TableName.ExecuteQuerySegmentedAsync(exQuery, continuationToken);
+                if (result.Results.Count > 0)
+                {
+                    entitys.AddRange(result.ToList());
+                }
+                continuationToken = result.ContinuationToken;
+            } while (continuationToken != null);
+            return entitys;
+        }
+
+        private static string SwitchType<T>(object obj, string key)
+        {
+            Type objType = typeof(T);
+            PropertyInfo property = objType.GetProperty(key);
+
+            //Type s = obj.GetType();
+            //TypeCode typeCode = Type.GetTypeCode(s);
+            if (property == null)
+            {
+                //return null;
+                throw new Exception(objType.FullName + " PropertyInfo doesn't include this parameter :" + key);
+            }
+            TypeCode typeCode = Type.GetTypeCode(property.PropertyType);
+
+
+            switch (typeCode)
+            {
+
+                case TypeCode.String: return TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, obj.ToString());
+                case TypeCode.Int32: return TableQuery.GenerateFilterConditionForInt(key, QueryComparisons.Equal, int.Parse(obj.ToString()));
+                case TypeCode.Double: return TableQuery.GenerateFilterConditionForDouble(key, QueryComparisons.Equal, (double)obj);
+                case TypeCode.Byte: return TableQuery.GenerateFilterConditionForBinary(key, QueryComparisons.Equal, (byte[])obj);
+                case TypeCode.Boolean: return TableQuery.GenerateFilterConditionForBool(key, QueryComparisons.Equal, (bool)obj);
+                case TypeCode.DateTime: return TableQuery.GenerateFilterConditionForDate(key, QueryComparisons.Equal, (DateTimeOffset)obj);
+                case TypeCode.Int64: return TableQuery.GenerateFilterConditionForLong(key, QueryComparisons.Equal, long.Parse(obj.ToString()));
+                default: return null;
+            }
+        }
     }
     }
 }
 }

+ 13 - 10
TEAMModelOS.SDK/Extension/MessagePush/Implements/SendCloudService.cs

@@ -1,17 +1,19 @@
-
+
 using TEAMModelOS.SDK.Extension.MessagePush.Interfaces;
 using TEAMModelOS.SDK.Extension.MessagePush.Interfaces;
 using TEAMModelOS.SDK.Extension.MessagePush.Model;
 using TEAMModelOS.SDK.Extension.MessagePush.Model;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Extension.Language.Interfaces;
 using TEAMModelOS.SDK.Extension.Language.Interfaces;
-using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
+
 using Microsoft.Extensions.Options;
 using Microsoft.Extensions.Options;
 using TEAMModelOS.SDK.Extension.Language.Model;
 using TEAMModelOS.SDK.Extension.Language.Model;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Security.Md5Hash;
 using TEAMModelOS.SDK.Helper.Security.Md5Hash;
 using TEAMModelOS.SDK.Helper.Network.HttpHelper;
 using TEAMModelOS.SDK.Helper.Network.HttpHelper;
 using TEAMModelOS.SDK.Extension.HttpClient.Implements;
 using TEAMModelOS.SDK.Extension.HttpClient.Implements;
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
+using TEAMModelOS.SDK.DI;
 
 
 namespace TEAMModelOS.SDK.Extension.MessagePush.Implements
 namespace TEAMModelOS.SDK.Extension.MessagePush.Implements
 {
 {
@@ -19,9 +21,9 @@ namespace TEAMModelOS.SDK.Extension.MessagePush.Implements
     {
     {
         public SmsSendCloud smsSendCloud;
         public SmsSendCloud smsSendCloud;
         public ILanguageService _languageService;
         public ILanguageService _languageService;
-        public IAzureTableDBRepository _azureTableDBRepository;
+        public AzureStorageFactory _azureTableDBRepository;
         public HttpClientSendCloud _httpClientService;
         public HttpClientSendCloud _httpClientService;
-        public SendCloudService(IOptions<SmsSendCloud> _option, ILanguageService languageService , IAzureTableDBRepository azureTableDBRepository , HttpClientSendCloud httpClientService )
+        public SendCloudService(IOptions<SmsSendCloud> _option, ILanguageService languageService , AzureStorageFactory azureTableDBRepository , HttpClientSendCloud httpClientService )
         {
         {
             _azureTableDBRepository = azureTableDBRepository;
             _azureTableDBRepository = azureTableDBRepository;
             _languageService = languageService;
             _languageService = languageService;
@@ -53,11 +55,11 @@ namespace TEAMModelOS.SDK.Extension.MessagePush.Implements
                     {
                     {
                         { "BizNum", BizNum },{ "BizCode", BizCode["code"] }, { "Language", Language["code"] } ,
                         { "BizNum", BizNum },{ "BizCode", BizCode["code"] }, { "Language", Language["code"] } ,
                     };
                     };
-                    SmsConfig smsConfig = await _azureTableDBRepository.FindOneByDict<SmsConfig>(dict);
+                    List<SmsConfig> smsConfig = await _azureTableDBRepository.FindListByDict<SmsConfig>(dict);
 
 
-                    if (smsConfig != null && smsConfig.RowKey != null)
+                    if (smsConfig.IsNotEmpty()  && smsConfig[0].RowKey != null)
                     {
                     {
-                        smsConfigs.Add(smsConfig);
+                        smsConfigs.Add(smsConfig[0]);
                     }
                     }
                     else {
                     else {
                         DateTimeOffset now = DateTimeOffset.Now;
                         DateTimeOffset now = DateTimeOffset.Now;
@@ -104,12 +106,13 @@ namespace TEAMModelOS.SDK.Extension.MessagePush.Implements
             {
             {
                 { "BizNum", BizNum },{ "BizCode", BizCode }, { "Language", SmsLang } ,
                 { "BizNum", BizNum },{ "BizCode", BizCode }, { "Language", SmsLang } ,
             };
             };
-            SmsConfig smsConfig   =  await _azureTableDBRepository.FindOneByDict<SmsConfig>(dict);
+            List<SmsConfig> smsConfig = await _azureTableDBRepository.FindListByDict<SmsConfig>(dict);
 
 
-            if (smsConfig != null && smsConfig.RowKey != null )
+            if (smsConfig.IsNotEmpty() && smsConfig[0].RowKey != null)
             {
             {
+             
                 //默认调用英文,不管是否包含,发送时会去处理相关信息
                 //默认调用英文,不管是否包含,发送时会去处理相关信息
-                int.TryParse(smsConfig.Template ,out templateId);
+                int.TryParse(smsConfig[0].Template ,out templateId);
             }
             }
             //else {
             //else {
             //    throw new BizException("");
             //    throw new BizException("");

+ 1 - 1
TEAMModelOS.SDK/Helper/Security/RSACrypt/RSAUtils.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.IO;
 using System.IO;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 namespace TEAMModelOS.SDK.Helper.Security.RSACrypt
 namespace TEAMModelOS.SDK.Helper.Security.RSACrypt

+ 0 - 17
TEAMModelOS.SDK/Module/AzureTable/Configuration/AzureTableOptions.cs

@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace TEAMModelOS.SDK.Module.AzureTable.Configuration
-{
-    public class AzureTableOptions
-    {
-        public string ConnectionString { get; set; } 
-        /// <summary>
-        /// 
-        /// </summary>
-        public AzureTableOptions()
-        {
-        }
-    }
-}

+ 0 - 80
TEAMModelOS.SDK/Module/AzureTable/Configuration/HaBookTableContinuationToken.cs

@@ -1,80 +0,0 @@
-
-using Microsoft.Azure.Cosmos.Table;
-using System;
-using System.ComponentModel.DataAnnotations;
-using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Helper.Common.ValidateHelper;
-
-namespace TEAMModelOS.SDK.Module.AzureTable.Configuration
-{
-    
-    public class HaBookTableContinuationToken
-    {
-        [Required]
-        public string NextPartitionKey { get; set; }
-        [Required]
-        public string NextRowKey { get; set; }
-        [Required]
-        public string NextTableName { get; set; }
-        [Required]
-        public StorageLocation? TargetLocation { get; set; }
-        public TableContinuationToken GetContinuationToken() {
-            TableContinuationToken continuationToken = new TableContinuationToken
-            {
-                NextPartitionKey = this.NextPartitionKey,
-                NextRowKey = this.NextRowKey,
-                NextTableName = this.NextTableName,
-                TargetLocation = this.TargetLocation
-            };
-            return ValidateHelper.ValidObj(continuationToken);
-        }
-        public HaBookTableContinuationToken() {
-        }
-        public HaBookTableContinuationToken(TableContinuationToken continuationToken) {
-            if (null != continuationToken) {
-                this.NextPartitionKey = continuationToken.NextPartitionKey;
-                this.NextRowKey = continuationToken.NextRowKey;
-                this.NextTableName = continuationToken.NextTableName;
-                this.TargetLocation = continuationToken.TargetLocation;
-            }
-        }
-
-        public HaBookTableContinuationToken(AzureTableToken continuationToken)
-        {
-            if (null != continuationToken) {
-                this.NextPartitionKey = continuationToken.NextPartitionKey;
-                this.NextRowKey = continuationToken.NextRowKey;
-                this.NextTableName = continuationToken.NextTableName;
-                int index = 0;
-                foreach (StorageLocation item in Enum.GetValues(typeof(StorageLocation)))
-                {
-                    if (continuationToken.TargetLocation == index)
-                    {
-                        this.TargetLocation = item;
-                        break;
-                    }
-                    index++;
-                }
-            }
-        }
-        public AzureTableToken GetAzureTableToken() {
-            AzureTableToken continuationToken = new AzureTableToken
-            {
-                NextPartitionKey = this.NextPartitionKey,
-                NextRowKey = this.NextRowKey,
-                NextTableName = this.NextTableName
-            };
-            ///枚举遍历
-            ///
-            int index = 0;
-            foreach (StorageLocation item in Enum.GetValues(typeof(StorageLocation))) {
-                if (this.TargetLocation == item) {
-                    continuationToken.TargetLocation = index;
-                    break;
-                }
-                index++;
-            }
-            return ValidateHelper.ValidObj(continuationToken); 
-        }
-    }
-}

+ 0 - 758
TEAMModelOS.SDK/Module/AzureTable/Implements/AzureTableDBRepository.cs

@@ -1,758 +0,0 @@
-using TEAMModelOS.SDK.Module.AzureTable.Configuration;
-using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
-using TEAMModelOS.SDK;
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using TEAMModelOS.SDK.Helper.Security.AESCrypt;
-using TEAMModelOS.SDK.Context.Exception;
-using System.Reflection;
-using TEAMModelOS.SDK.Context.Attributes.Azure;
-using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
-using TEAMModelOS.SDK.Context.Configuration;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Azure.Cosmos.Table;
-
-namespace TEAMModelOS.SDK.Module.AzureTable.Implements
-{    //Linq全部查詢有1000限制
-    /*
-    public async Task<List<T>> GetByPartitionKey(string partitionKey)
-    {
-        var theQuery = table.CreateQuery<T>().Where(ent => ent.PartitionKey == partitionKey);
-        TableQuerySegment<T> querySegment = null;
-        var returnList = new List<T>();
-        while (querySegment == null || querySegment.ContinuationToken != null)
-        {
-            querySegment = await theQuery.AsTableQuery()
-                   .ExecuteSegmentedAsync(querySegment != null ?
-                    querySegment.ContinuationToken : null);
-            returnList.AddRange(querySegment);
-        }
-        return returnList;
-        //Linq全部查詢沒有1000限制(要驗證)
-        public Task<List<T>> GetByPartitionKey(string partitionKey)
-        {
-            return Task.Run(() => table.CreateQuery<T>()
-                   .Where(ent => ent.PartitionKey == partitionKey)
-                   .ToList());
-        }
-    }*/
-
-    /// <summary>
-    /// 带处理问题 
-    /// 1.使用 Microsoft.Azure.Cosmos.Table
-    /// 2.AddSingleton 可能不適合CloudTableClient  线程不安全
-    /// 3.能否使用 Efcore 
-    /// 4.有CreateQuery可以用,也有AsTableQuery轉換 還有Microsoft.Azure.Cosmos.Table.Queryable 支持 Linq lambda語法
-    /// 5. 另外可以驗證一下最低查詢投影處理Count時 var query = from entity in table.CreateQuery<T>(tableName) select new { entity.PartitionKey };
-    /// 
-    /// 另外你有優化的話,順便驗證一下
-
-
-
-
-    /// </summary>
-    public class AzureTableDBRepository : IAzureTableDBRepository
-    {
-        private CloudTableClient CloudTableClient { get; set; }
-        private CloudTable cloudTable { get; set; }
-        private AzureTableOptions options { get; set; }
-
-        public AzureTableDBRepository()
-        {
-            options = BaseConfigModel.Configuration.GetSection("Azure:Table").Get<AzureTableOptions>();
-            CloudTableClient = CloudStorageAccount.Parse(options.ConnectionString).CreateCloudTableClient();
-        }
-        private string GetTableSpace<T>()
-        {
-            Type type = typeof(T);
-            string Name = type.Name;
-
-            object[] attributes = type.GetCustomAttributes(true);
-            foreach (object attribute in attributes) //2.通过映射,找到成员属性上关联的特性类实例,
-            {
-                if (attribute is TableNameAttribute tableSpace)
-                {
-                    Name = tableSpace.Name;
-                }
-            }
-            return Name;
-        }
-        private async Task<string> InitializeTable<T>()
-        {
-
-            string TableName = GetTableSpace<T>();
-            if (cloudTable == null || !cloudTable.Name.Equals(TableName))
-            {
-                cloudTable = CloudTableClient.GetTableReference(TableName);
-                await cloudTable.CreateIfNotExistsAsync();
-            }
-            return TableName;
-        }
-
-
-
-        //Linq全部查詢有1000限制
-        //public async Task<List<T>> GetByPartitionKey<T>(string partitionKey) where T : TableEntity, new()
-        //{
-        //    var theQuery = cloudTable.CreateQuery<T>().Where(ent => ent.PartitionKey == partitionKey);
-        //    TableQuerySegment<T> querySegment = null;
-        //    var returnList = new List<T>();
-        //    while (querySegment == null || querySegment.ContinuationToken != null)
-        //    {
-        //        querySegment = await theQuery.AsTableQuery()
-        //               .ExecuteSegmentedAsync(querySegment != null ?
-        //                querySegment.ContinuationToken : null);
-        //        returnList.AddRange(querySegment);
-        //    }
-        //    return returnList;
-
-        //}
-        //Linq全部查詢沒有1000限制(要驗證)
-
-        /// <summary>
-        /// Linq全部查詢沒有1000限制(要驗證)
-        /// 就是最低消耗查詢處理Count var query = from entity in table.CreateQuery<T>(tableName) select new { entity.PartitionKey };
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="partitionKey"></param>
-        /// <returns></returns>
-        public Task<List<T>> GetByPartitionKey<T>(string partitionKey) where T : TableEntity, new()
-        {
-            return Task.Run(() => cloudTable.CreateQuery<T>()
-                   .Where(ent => ent.PartitionKey == partitionKey)
-                   .ToList());
-        }
-        public async Task<List<T>> FindAll<T>() where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            var exQuery = new TableQuery<T>();
-            return await QueryList<T>(exQuery, TableName);
-        }
-
-        private async Task<List<T>> QueryList<T>(TableQuery<T> exQuery, string TableName) where T : TableEntity, new()
-        {
-            TableContinuationToken continuationToken = null;
-            List<T> entitys = new List<T>();
-            do
-            {
-                var result = await CloudTableClient.GetTableReference(TableName).ExecuteQuerySegmentedAsync(exQuery, continuationToken);
-                if (result.Results.Count > 0)
-                {
-                    entitys.AddRange(result.ToList());
-                }
-                continuationToken = result.ContinuationToken;
-            } while (continuationToken != null);
-            return entitys;
-        }
-
-
-        private async Task<T> QueryObject<T>(TableQuery<T> exQuery, string TableName) where T : TableEntity, new()
-        {
-            TableContinuationToken continuationToken = null;
-            T entity = new T();
-            do
-            {
-                var result = await CloudTableClient.GetTableReference(TableName).ExecuteQuerySegmentedAsync(exQuery, continuationToken);
-                if (result.Results.Count > 0)
-                {
-                    entity= result.ToList()[0];
-                    break;
-                }
-                continuationToken = result.ContinuationToken;
-            } while (continuationToken != null);
-            return entity;
-        }
-
-        public async Task<int> Count<T>(TableContinuationToken continuationToken) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            var exQuery = new TableQuery<T>();
-            List<T> entitys = new List<T>();
-            do
-            {
-                var result = await CloudTableClient.GetTableReference(TableName).ExecuteQuerySegmentedAsync(exQuery, continuationToken);
-                if (result.Results.Count > 0)
-                {
-                    entitys.AddRange(result.ToList());
-                }
-                continuationToken = result.ContinuationToken;
-            } while (continuationToken != null);
-            return entitys.Count;
-        }
-
-        public async Task<int> Count<T>() where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            TableContinuationToken continuationToken = null;
-            var exQuery = new TableQuery<T>();
-            List<T> entitys = new List<T>();
-            do
-            {
-                var result = await CloudTableClient.GetTableReference(TableName).ExecuteQuerySegmentedAsync(exQuery, continuationToken);
-                if (result.Results.Count > 0)
-                {
-                    entitys.AddRange(result.ToList());
-                }
-                continuationToken = result.ContinuationToken;
-            } while (continuationToken != null);
-            return entitys.Count;
-        }
-
-        public async Task<T> FindByRowKey<T>(string id) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            var exQuery = new TableQuery<T>();
-            if (!string.IsNullOrEmpty(id))
-            {
-                string typeStr = SwitchType<T>(id, "RowKey");
-                if (string.IsNullOrEmpty(typeStr))
-                {
-                    return null;
-                }
-                exQuery.Where(typeStr);
-                // exQuery.Where(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, id));
-                return await QueryObject<T>(exQuery, TableName);
-            }
-            else
-            {
-                return null;
-            }
-
-
-        }
-
-        public async Task<List<T>> FindListByDict<T>(Dictionary<string, object> dict) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            var exQuery = new TableQuery<T>();
-            StringBuilder builder = new StringBuilder();
-            if (null != dict && dict.Count > 0)
-            {
-                var keys = dict.Keys;
-                int index = 1;
-                foreach (string key in keys)
-                {
-                    if (dict[key] != null && !string.IsNullOrEmpty(dict[key].ToString()))
-                    {
-                        string typeStr = SwitchType<T>(dict[key], key);
-                        if (string.IsNullOrEmpty(typeStr))
-                        {
-                            continue;
-                        }
-                        if (index == 1)
-                        {
-                            //builder.Append(TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
-                            builder.Append(typeStr);
-
-                        }
-                        else
-                        {
-                            //builder.Append("  " + TableOperators.And + "  " + TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
-                            builder.Append("  " + TableOperators.And + "  " + typeStr);
-
-                        }
-                        index++;
-                    }
-                    else
-                    {
-                        throw new Exception("The parameter must have value!");
-                    }
-                }
-
-                exQuery.Where(builder.ToString());
-                return await QueryList<T>(exQuery, TableName);
-            }
-            else
-            {
-                return null;
-            }
-        }
-
-        public async Task<List<T>> FindListByKey<T>(string key, object value) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-
-            var exQuery = new TableQuery<T>();
-            if (!string.IsNullOrEmpty(key) && value != null && !string.IsNullOrEmpty(value.ToString()))
-            {
-
-                string typeStr = SwitchType<T>(value, key);
-                if (string.IsNullOrEmpty(typeStr))
-                {
-                    return null;
-                }
-                exQuery.Where(typeStr);
-                //exQuery.Where(TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, value));
-                return await QueryList<T>(exQuery, TableName);
-            }
-            else
-            {
-                return null;
-            }
-
-        }
-
-        public async Task<T> FindOneByDict<T>(IDictionary<string, object> dict) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            var exQuery = new TableQuery<T>();
-            StringBuilder builder = new StringBuilder();
-            if (null != dict && dict.Count > 0)
-            {
-                var keys = dict.Keys;
-                int index = 1;
-                foreach (string key in keys)
-                {
-                    if (dict[key] != null && !string.IsNullOrEmpty(dict[key].ToString()))
-                    {
-
-
-                        string typeStr = SwitchType<T>(dict[key], key);
-                        if (string.IsNullOrEmpty(typeStr))
-                        {
-                            continue;
-                        }
-                        if (index == 1)
-                        {
-                            //builder.Append(TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
-                            builder.Append(typeStr);
-                        }
-                        else
-                        {
-                            // builder.Append("  " + TableOperators.And + "  " + TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
-                            builder.Append("  " + TableOperators.And + "  " + typeStr);
-                        }
-                        index++;
-                    }
-                    else
-                    {
-                        throw new Exception("The parameter must have value!");
-                    }
-                }
-                exQuery.Where(builder.ToString());
-                return await QueryObject<T>(exQuery, TableName);
-            }
-            else
-            {
-                return null;
-            }
-
-        }
-
-        private static string SwitchType<T>(object obj, string key)
-        {
-            Type objType = typeof(T);
-            PropertyInfo property = objType.GetProperty(key);
-
-            //Type s = obj.GetType();
-            //TypeCode typeCode = Type.GetTypeCode(s);
-            if (property == null)
-            {
-                //return null;
-                throw new Exception(objType.FullName + " PropertyInfo doesn't include this parameter :" + key);
-            }
-            TypeCode typeCode = Type.GetTypeCode(property.PropertyType);
-
-
-            switch (typeCode)
-            {
-
-                case TypeCode.String: return TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, obj.ToString());
-                case TypeCode.Int32: return TableQuery.GenerateFilterConditionForInt(key, QueryComparisons.Equal, int.Parse(obj.ToString()));
-                case TypeCode.Double: return TableQuery.GenerateFilterConditionForDouble(key, QueryComparisons.Equal, (double)obj);
-                case TypeCode.Byte: return TableQuery.GenerateFilterConditionForBinary(key, QueryComparisons.Equal, (byte[])obj);
-                case TypeCode.Boolean: return TableQuery.GenerateFilterConditionForBool(key, QueryComparisons.Equal, (bool)obj);
-                case TypeCode.DateTime: return TableQuery.GenerateFilterConditionForDate(key, QueryComparisons.Equal, (DateTimeOffset)obj);
-                case TypeCode.Int64: return TableQuery.GenerateFilterConditionForLong(key, QueryComparisons.Equal, long.Parse(obj.ToString()));
-
-                default: return null;
-            }
-        }
-
-        public async Task<T> FindOneByKey<T>(string key, object value) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            var exQuery = new TableQuery<T>();
-            if (!string.IsNullOrEmpty(key) && value != null && !string.IsNullOrEmpty(value.ToString()))
-            {
-
-                string typeStr = SwitchType<T>(value, key);
-                if (string.IsNullOrEmpty(typeStr))
-                {
-                    return null;
-                }
-                exQuery.Where(typeStr);
-                //exQuery.Where(TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal,
-                //                                                          value));
-
-
-                return await QueryObject<T>(exQuery, TableName);
-            }
-            else
-            {
-                return null;
-            }
-
-        }
-
-        public async Task<List<T>> GetEntities<T>(IDictionary<string, object> dict) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            var exQuery = new TableQuery<T>();
-            StringBuilder builder = new StringBuilder();
-            if (null != dict && dict.Count > 0)
-            {
-                var keys = dict.Keys;
-                int index = 1;
-                foreach (string key in keys)
-                {
-                    if (dict[key] != null && !string.IsNullOrEmpty(dict[key].ToString()))
-                    {
-                        string typeStr = SwitchType<T>(dict, key);
-                        if (string.IsNullOrEmpty(typeStr))
-                        {
-                            continue;
-                        }
-                        if (index == 1)
-                        {
-                            //builder.Append(TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
-                            builder.Append(typeStr);
-
-                        }
-                        else
-                        {
-                            // builder.Append("  " + TableOperators.And + "  " + TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
-                            builder.Append("  " + TableOperators.And + "  " + typeStr);
-
-                        }
-                        index++;
-                    }
-                    else
-                    {
-                        throw new Exception("The parameter must have value!");
-                    }
-                }
-                exQuery.Where(builder.ToString());
-                return await QueryList<T>(exQuery, TableName);
-            }
-            else
-            {
-                return null;
-            }
-        }
-
-
-
-        public async Task<List<T>> SaveAll<T>(List<T> entitys) where T : TableEntity, new()
-        {
-            if (entitys.IsEmpty())
-            {
-                return null;
-            }
-            string TableName = await InitializeTable<T>();
-            IList<Dictionary<string, List<T>>> listInfo = new List<Dictionary<string, List<T>>>();
-            foreach (IGrouping<string, T> group in entitys.GroupBy(c => c.PartitionKey))
-            {
-                Dictionary<string, List<T>> dictInfo = new Dictionary<string, List<T>>
-                {
-                    { group.Key, group.ToList() }
-                };
-                listInfo.Add(dictInfo);
-            }
-
-            foreach (Dictionary<string, List<T>> dict in listInfo)
-            {
-                IList<TableResult> result = null;
-                foreach (string key in dict.Keys)
-                {
-                    List<T> values = dict[key];
-                    //Parallel.ForEach(Partitioner.Create(0, values.Count, 100),
-                    //  async range =>
-                    //  {
-                    //      TableBatchOperation batchOperation = new TableBatchOperation();
-                    //      for (Int32 i = range.Item1; i < range.Item2; i++)
-                    //          batchOperation.Insert(values[i]);
-                    //      result = await CloudTableClient.GetTableReference(TableName).ExecuteBatchAsync(batchOperation);
-                    //  });
-                    int pageSize = 100;
-                    int pages = (int)Math.Ceiling((double)values.Count / pageSize);
-                    for (int i = 0; i < pages; i++)
-                    {
-                        List<T> lists = values.Skip((i) * pageSize).Take(pageSize).ToList();
-                        TableBatchOperation batchOperation = new TableBatchOperation();
-                        for (int j = 0; j < lists.Count; j++)
-                        {
-                            batchOperation.Insert(lists[j]);
-                        }
-                        result = await CloudTableClient.GetTableReference(TableName).ExecuteBatchAsync(batchOperation);
-                    }
-                }
-            }
-            return entitys;
-        }
-
-        public async Task<List<T>> UpdateAll<T>(List<T> entitys) where T : TableEntity, new()
-        {
-            if (entitys.IsEmpty())
-            {
-                return null;
-            }
-            string TableName = await InitializeTable<T>();
-            IList<Dictionary<string, List<T>>> listInfo = new List<Dictionary<string, List<T>>>();
-            foreach (IGrouping<string, T> group in entitys.GroupBy(c => c.PartitionKey))
-            {
-                Dictionary<string, List<T>> dictInfo = new Dictionary<string, List<T>>
-                {
-                    { group.Key, group.ToList() }
-                };
-                listInfo.Add(dictInfo);
-            }
-
-            foreach (Dictionary<string, List<T>> dict in listInfo)
-            {
-                IList<TableResult> result = null;
-                foreach (string key in dict.Keys)
-                {
-                    List<T> values = dict[key];
-                    //Parallel.ForEach(Partitioner.Create(0, values.Count, 100),
-                    //  async range =>
-                    //  {
-                    //      TableBatchOperation batchOperation = new TableBatchOperation();
-                    //      for (Int32 i = range.Item1; i < range.Item2; i++)
-                    //          batchOperation.Replace(values[i]);
-                    //      result = await CloudTableClient.GetTableReference(TableName).ExecuteBatchAsync(batchOperation);
-                    //  });
-                    int pageSize = 100;
-                    int pages = (int)Math.Ceiling((double)values.Count / pageSize);
-                    for (int i = 0; i < pages; i++)
-                    {
-                        List<T> lists = values.Skip((i) * pageSize).Take(pageSize).ToList();
-                        TableBatchOperation batchOperation = new TableBatchOperation();
-                        for (int j = 0; j < lists.Count; j++)
-                        {
-                            batchOperation.Replace(lists[j]);
-                        }
-                        result = await CloudTableClient.GetTableReference(TableName).ExecuteBatchAsync(batchOperation);
-                    }
-                }
-            }
-            return entitys;
-        }
-
-        public async Task<List<T>> SaveOrUpdateAll<T>(List<T> entitys) where T : TableEntity, new()
-        {
-            if (entitys.IsEmpty())
-            {
-                return null;
-            }
-            string TableName = await InitializeTable<T>();
-            IList<Dictionary<string, List<T>>> listInfo = new List<Dictionary<string, List<T>>>();
-            foreach (IGrouping<string, T> group in entitys.GroupBy(c => c.PartitionKey))
-            {
-                Dictionary<string, List<T>> dictInfo = new Dictionary<string, List<T>>
-                {
-                    { group.Key, group.ToList() }
-                };
-                listInfo.Add(dictInfo);
-            }
-
-            foreach (Dictionary<string, List<T>> dict in listInfo)
-            {
-                IList<TableResult> result = null;
-                foreach (string key in dict.Keys)
-                {
-                    List<T> values = dict[key];
-                    //Parallel.ForEach(Partitioner.Create(0, values.Count, 50),
-                    //  async range =>
-                    //  {
-                    //      TableBatchOperation batchOperation = new TableBatchOperation();
-                    //      for (Int32 i = range.Item1; i < range.Item2; i++)
-                    //          batchOperation.InsertOrReplace(values[i]);
-                    //      result = await CloudTableClient.GetTableReference(TableName).ExecuteBatchAsync(batchOperation);
-                    //  });
-
-                    int pageSize = 100;
-                    int pages = (int)Math.Ceiling((double)values.Count / pageSize);
-                    for (int i = 0; i < pages; i++)
-                    {
-                        List<T> lists = values.Skip((i) * pageSize).Take(pageSize).ToList();
-                        TableBatchOperation batchOperation = new TableBatchOperation();
-                        for (int j = 0; j < lists.Count; j++)
-                        {
-                            batchOperation.InsertOrReplace(lists[j]);
-                        }
-                        result = await CloudTableClient.GetTableReference(TableName).ExecuteBatchAsync(batchOperation);
-                    }
-                }
-            }
-            return entitys;
-        }
-
-
-
-
-        public async Task<List<T>> DeleteAll<T>(List<T> entitys) where T : TableEntity, new()
-        {
-            if (entitys.IsEmpty())
-            {
-                return null;
-            }
-            string TableName = await InitializeTable<T>();
-            IList<Dictionary<string, List<T>>> listInfo = new List<Dictionary<string, List<T>>>();
-            foreach (IGrouping<string, T> group in entitys.GroupBy(c => c.PartitionKey))
-            {
-                Dictionary<string, List<T>> dictInfo = new Dictionary<string, List<T>>
-                {
-                    { group.Key, group.ToList() }
-                };
-                listInfo.Add(dictInfo);
-            }
-
-            foreach (Dictionary<string, List<T>> dict in listInfo)
-            {
-                IList<TableResult> result = null;
-                foreach (string key in dict.Keys)
-                {
-                    List<T> values = dict[key];
-                    //Parallel.ForEach(Partitioner.Create(0, values.Count, 100),
-                    //  async range =>
-                    //  {
-                    //      TableBatchOperation batchOperation = new TableBatchOperation();
-                    //      for (Int32 i = range.Item1; i < range.Item2; i++)
-                    //          batchOperation.Delete(values[i]);
-                    //      result = await CloudTableClient.GetTableReference(TableName).ExecuteBatchAsync(batchOperation);
-                    //  });
-
-                    int pageSize = 100;
-                    int pages = (int)Math.Ceiling((double)values.Count / pageSize);
-                    for (int i = 0; i < pages; i++)
-                    {
-                        List<T> lists = values.Skip((i) * pageSize).Take(pageSize).ToList();
-                        TableBatchOperation batchOperation = new TableBatchOperation();
-                        for (int j = 0; j < lists.Count; j++)
-                        {
-                            batchOperation.Delete(lists[j]);
-                        }
-                        result = await CloudTableClient.GetTableReference(TableName).ExecuteBatchAsync(batchOperation);
-                    }
-                }
-            }
-            return entitys;
-        }
-
-        public async Task<T> Save<T>(TableEntity entity) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            TableOperation operation = TableOperation.Insert(entity);
-            TableResult result = await CloudTableClient.GetTableReference(TableName).ExecuteAsync(operation);
-            return (T)result.Result;
-        }
-        public async Task<T> SaveOrUpdate<T>(TableEntity entity) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            TableOperation operation = TableOperation.InsertOrReplace(entity);
-            TableResult result = await CloudTableClient.GetTableReference(TableName).ExecuteAsync(operation);
-            return (T)result.Result;
-        }
-
-        public async Task<T> Update<T>(TableEntity entity) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            TableOperation operation = TableOperation.Replace(entity);
-            TableResult result = await CloudTableClient.GetTableReference(TableName).ExecuteAsync(operation);
-            return (T)result.Result;
-        }
-
-        public async Task<T> Delete<T>(TableEntity entity) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            TableOperation operation = TableOperation.Delete(entity);
-            TableResult result = await CloudTableClient.GetTableReference(TableName).ExecuteAsync(operation);
-            return (T)result.Result;
-        }
-
-
-        //public async Task<List<T>> FindListByDictAndLike<T>(Dictionary<string, object> dict, Dictionary<string, object> likeDict) where T : TableEntity, new()
-        //{
-        //    throw new NotImplementedException();
-        //}
-
-        //public async Task<List<T>> FindListByDictAndLikeAndNotEQ<T>(Dictionary<string, object> dict, Dictionary<string, object> likeDict, Dictionary<string, object> notEQDict) where T : TableEntity, new()
-        //{
-        //    throw new NotImplementedException();
-        //}
-
-        //public async Task<List<T>> FindListByDictAndLikeAndStartWith<T>(Dictionary<string, object> dict, Dictionary<string, object> likeDict, Dictionary<string, object> startDict) where T : TableEntity, new()
-        //{
-        //    throw new NotImplementedException();
-        //}
-
-        public async Task<AzurePagination<T>> FindListByDict<T>(Dictionary<string, object> dict, AzureTableToken azureTableToken) where T : TableEntity, new()
-        {
-            string TableName = await InitializeTable<T>();
-            var exQuery = new TableQuery<T>();
-            StringBuilder builder = new StringBuilder();
-            if (null != dict && dict.Count > 0)
-            {
-                var keys = dict.Keys;
-                int index = 1;
-                foreach (string key in keys)
-                {
-                    if (dict[key] != null && !string.IsNullOrEmpty(dict[key].ToString()))
-                    {
-                        string typeStr = SwitchType<T>(dict, key);
-                        if (string.IsNullOrEmpty(typeStr))
-                        {
-                            continue;
-                        }
-                        if (index == 1)
-                        {
-                            // builder.Append(TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
-                            builder.Append(typeStr);
-
-                        }
-                        else
-                        {
-                            builder.Append("  " + TableOperators.And + "  " + typeStr);
-                            //builder.Append("  " + TableOperators.And + "  " + TableQuery.GenerateFilterCondition(key, QueryComparisons.Equal, dict[key].ToString()));
-                        }
-                        index++;
-                    }
-                    else
-                    {
-                        throw new Exception("The parameter must have value!");
-                    }
-                }
-                exQuery.Where(builder.ToString());
-                return await QueryList<T>(azureTableToken, exQuery, TableName);
-            }
-            else
-            {
-                return null;
-            }
-
-        }
-        private async Task<AzurePagination<T>> QueryList<T>(AzureTableToken azureTableToken, TableQuery<T> exQuery, string TableName) where T : TableEntity, new()
-        {
-            TableContinuationToken tableToken = new HaBookTableContinuationToken(azureTableToken).GetContinuationToken();
-            List<T> entitys = new List<T>();
-
-            var result = await CloudTableClient.GetTableReference(TableName).ExecuteQuerySegmentedAsync(exQuery, tableToken);
-            if (result.Results.Count > 0)
-            {
-                entitys.AddRange(result.ToList());
-            }
-            tableToken = result.ContinuationToken;
-            AzurePagination<T> pagination = new AzurePagination<T>
-            {
-                token = new HaBookTableContinuationToken(tableToken).GetAzureTableToken(),
-                data = entitys
-            };
-            return pagination;
-        }
-    }
-}

+ 0 - 41
TEAMModelOS.SDK/Module/AzureTable/Interfaces/IAzureTableDBRepository.cs

@@ -1,41 +0,0 @@
-using TEAMModelOS.SDK.Module.AzureTable.Configuration;
-using TEAMModelOS.SDK;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.Azure.Cosmos.Table;
-
-namespace TEAMModelOS.SDK.Module.AzureTable.Interfaces
-{
-    public interface IAzureTableDBRepository
-    {
-        Task<List<T>> GetEntities<T>(IDictionary<string, object> dict) where T : TableEntity, new();
-        Task<T> FindOneByDict<T>(IDictionary<string, object> dict) where T : TableEntity, new();
-        Task<T> FindByRowKey<T>(string RowKey) where T : TableEntity, new();
-        Task<T> Save<T>(TableEntity entity) where T : TableEntity, new();
-        Task<T> Update<T>(TableEntity entity) where T : TableEntity, new();
-        Task<T> Delete<T>(TableEntity entity) where T : TableEntity, new();
-        Task<T> FindOneByKey<T>(string key, object value) where T : TableEntity, new();
-        Task<List<T>> FindListByDict<T>(Dictionary<string, object> dict) where T : TableEntity, new();
-        Task<List<T>> FindListByKey<T>(string key, object value) where T : TableEntity, new();
-        Task<List<T>> FindAll<T>() where T : TableEntity, new();
-        Task<List<T>> DeleteAll<T>(List<T> entitys) where T : TableEntity, new();
-        Task<List<T>> UpdateAll<T>(List<T> entitys) where T : TableEntity, new();
-        Task<List<T>> SaveAll<T>(List<T> entitys) where T : TableEntity, new();
-        //Task<List<T>> FindListByDictAndLike<T>(
-        //    Dictionary<string, object> dict,
-        //    Dictionary<string, object> likeDict) where T : TableEntity, new();
-        //Task<List<T>> FindListByDictAndLikeAndStartWith<T>(
-        //    Dictionary<string, object> dict,
-        //    Dictionary<string, object> likeDict,
-        //    Dictionary<string, object> startDict) where T : TableEntity, new();
-        //Task<List<T>> FindListByDictAndLikeAndNotEQ<T>(
-        //    Dictionary<string, object> dict,
-        //    Dictionary<string, object> likeDict,
-        //    Dictionary<string, object> notEQDict) where T : TableEntity, new();
-        //Task<int> Count<T>() where T : TableEntity, new();
-        //Task<AzurePagination<T>> FindListByDict<T>(Dictionary<string, object> dict, AzurePagination<T> pagination) where T : TableEntity, new();
-        Task<AzurePagination<T>> FindListByDict<T>(Dictionary<string, object> dict, AzureTableToken azureTableToken) where T : TableEntity, new();
-        Task<T> SaveOrUpdate<T>(TableEntity entity) where T : TableEntity, new();
-        Task<List<T>> SaveOrUpdateAll<T>(List<T> entitys) where T : TableEntity, new();
-    }
-}

+ 2 - 3
TEAMModelOS.Service/Services/Analysis/Implements/AchievementService.cs

@@ -1,12 +1,11 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.Service.Analysis.Interfaces;
 using TEAMModelOS.Service.Analysis.Interfaces;
-using TEAMModelOS.SDK.DI;
+
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Models;
-using TEAMModelOS.SDK.DI;
 
 
 namespace TEAMModelOS.Service.Analysis.Implements
 namespace TEAMModelOS.Service.Analysis.Implements
 {
 {

+ 5 - 4
TEAMModelOS.Service/Services/Evaluation/Implements/ImportExerciseService.cs

@@ -1,4 +1,4 @@
-using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Packaging;
 using HtmlAgilityPack;
 using HtmlAgilityPack;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using OpenXmlPowerTools;
 using OpenXmlPowerTools;
@@ -13,6 +13,7 @@ using System.Threading.Tasks;
 using System.Xml.Linq;
 using System.Xml.Linq;
 
 
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Context.Constant;
+using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension.SnowFlake;
 using TEAMModelOS.SDK.Extension.SnowFlake;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.FileHelper;
 using TEAMModelOS.SDK.Helper.Common.FileHelper;
@@ -20,7 +21,7 @@ using TEAMModelOS.SDK.Helper.Common.StringHelper;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.Module.AzureBlob.Container;
 using TEAMModelOS.SDK.Module.AzureBlob.Container;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
-using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
+
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Services.Exam.Interfaces;
 using TEAMModelOS.Service.Services.Exam.Interfaces;
 
 
@@ -31,8 +32,8 @@ namespace TEAMModelOS.Service.Services.Exam.Implements
       
       
        
        
         private readonly IAzureBlobDBRepository azureBlobDBRepository;
         private readonly IAzureBlobDBRepository azureBlobDBRepository;
-        private readonly IAzureTableDBRepository azureTableDBRepository;
-        public ImportExerciseService(IAzureBlobDBRepository _azureBlobDBRepository, IAzureTableDBRepository _azureTableDBRepository)
+        private readonly AzureStorageFactory azureTableDBRepository;
+        public ImportExerciseService(IAzureBlobDBRepository _azureBlobDBRepository, AzureStorageFactory _azureTableDBRepository)
         {
         {
             azureBlobDBRepository = _azureBlobDBRepository;
             azureBlobDBRepository = _azureBlobDBRepository;
             azureTableDBRepository = _azureTableDBRepository;
             azureTableDBRepository = _azureTableDBRepository;

+ 1 - 2
TEAMModelOS/Controllers/Analysis/AchievementController.cs

@@ -8,10 +8,9 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.StringHelper;
 using TEAMModelOS.SDK.Helper.Common.StringHelper;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
+
 using TEAMModelOS.Service.Analysis.Interfaces;
 using TEAMModelOS.Service.Analysis.Interfaces;
 
 
-using TEAMModelOS.SDK.DI;
 using System.Diagnostics;
 using System.Diagnostics;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;

+ 1 - 2
TEAMModelOS/Controllers/Analysis/ChangeController.cs

@@ -1,4 +1,4 @@
-using DocumentFormat.OpenXml.Office2010.ExcelAc;
+using DocumentFormat.OpenXml.Office2010.ExcelAc;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Newtonsoft.Json.Linq;
 using Newtonsoft.Json.Linq;
@@ -14,7 +14,6 @@ using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.DI;
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Models;
 
 
 namespace TEAMModelOS.Controllers.Analysis
 namespace TEAMModelOS.Controllers.Analysis

+ 1 - 2
TEAMModelOS/Controllers/Core/CommonController.cs

@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Newtonsoft.Json.Linq;
 using Newtonsoft.Json.Linq;
 using System;
 using System;
@@ -15,7 +15,6 @@ using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using static System.Text.Json.JsonElement;
 using static System.Text.Json.JsonElement;
-using TEAMModelOS.SDK.DI;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers
 {
 {

+ 4 - 3
TEAMModelOS/Controllers/Core/FileController.cs

@@ -13,8 +13,9 @@ using TEAMModelOS.SDK.Helper.Security.AESCrypt;
 using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
 using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
 using TEAMModelOS.SDK.Module.AzureBlob.Container;
 using TEAMModelOS.SDK.Module.AzureBlob.Container;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
-using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
+
 using TEAMModelOS.Service.Services.PowerPoint.Interface;
 using TEAMModelOS.Service.Services.PowerPoint.Interface;
+using TEAMModelOS.SDK.DI;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers
 {
 {
@@ -22,9 +23,9 @@ namespace TEAMModelOS.Controllers
     [ApiController]
     [ApiController]
     public class FileController:BaseController
     public class FileController:BaseController
     {
     {
-        private readonly IAzureTableDBRepository azureTableDBRepository;
+        private readonly AzureStorageFactory azureTableDBRepository;
         private readonly IAzureBlobDBRepository _azureBlobDBRepository;
         private readonly IAzureBlobDBRepository _azureBlobDBRepository;
-        public FileController(IAzureTableDBRepository _azureTableDBRepository, IAzureBlobDBRepository azureBlobDBRepository 
+        public FileController(AzureStorageFactory _azureTableDBRepository, IAzureBlobDBRepository azureBlobDBRepository 
         )
         )
         {
         {
             azureTableDBRepository = _azureTableDBRepository;
             azureTableDBRepository = _azureTableDBRepository;

+ 3 - 4
TEAMModelOS/Controllers/School/ClassRoomController.cs

@@ -7,7 +7,6 @@ using TEAMModelOS.Service.Models;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Helper.Common.ValidateHelper;
 using TEAMModelOS.SDK.Helper.Common.ValidateHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using System.Linq;
 using System.Linq;
@@ -37,13 +36,13 @@ namespace TEAMModelOS.Controllers
             {
             {
                 List<int> sc = await cosmosrepository.FindCountByDict<Classroom>(new Dictionary<string, object> { { "classroomCode", request.@params.classroomCode } });
                 List<int> sc = await cosmosrepository.FindCountByDict<Classroom>(new Dictionary<string, object> { { "classroomCode", request.@params.classroomCode } });
                 if (sc.IsNotEmpty() && sc[0]>0) {
                 if (sc.IsNotEmpty() && sc[0]>0) {
-                    return builder.Error(ResponseCode.DATA_EXIST, "班级代码已经存在!").build();
+                    return builder.Error(ResponseCode.DATA_EXIST, "班级代码已经存在!").build();
                 }
                 }
                 request.@params.id = request.@params.classroomCode;
                 request.@params.id = request.@params.classroomCode;
                 await cosmosrepository.SaveOrUpdate<Classroom>(request.@params);
                 await cosmosrepository.SaveOrUpdate<Classroom>(request.@params);
                 
                 
             }
             }
-            //强制关联原生班级的id
+            //寮哄埗鍏宠仈鍘熺敓鐝�骇鐨刬d
             List<ClassStudent> classroomStudents = await cosmosrepository.FindByDict<ClassStudent>(new Dictionary<string, object> { { "id", request.@params.classroomCode } });
             List<ClassStudent> classroomStudents = await cosmosrepository.FindByDict<ClassStudent>(new Dictionary<string, object> { { "id", request.@params.classroomCode } });
             if (classroomStudents.IsNotEmpty())
             if (classroomStudents.IsNotEmpty())
             {
             {
@@ -85,7 +84,7 @@ namespace TEAMModelOS.Controllers
                 }
                 }
             }
             }
             else {
             else {
-                return builder.Error(ResponseCode.PARAMS_ERROR, "参数未定义!").build(); 
+                return builder.Error(ResponseCode.PARAMS_ERROR, "鍙傛暟鏈�畾涔夛紒").build(); 
             }
             }
             return builder.build();
             return builder.build();
         }
         }

+ 1 - 2
TEAMModelOS/Controllers/School/SchoolController.cs

@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
@@ -7,7 +7,6 @@ using TEAMModelOS.Service.Models;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
-using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK.Context.Exception;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers

+ 4 - 4
TEAMModelOS/Controllers/Syllabus/KnowledgeController.cs

@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -10,7 +10,7 @@ using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
+
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Services.Interface;
 using TEAMModelOS.Service.Services.Interface;
 
 
@@ -21,11 +21,11 @@ namespace TEAMModelOS.Controllers
     //[Authorize]
     //[Authorize]
     public class KnowledgeController : BaseController
     public class KnowledgeController : BaseController
     {
     {
-        private IAzureTableDBRepository _table;
+        private AzureStorageFactory _table;
         private AzureCosmosFactory _cosmos;
         private AzureCosmosFactory _cosmos;
         private IKnowledgeService knowledgeService;
         private IKnowledgeService knowledgeService;
 
 
-        public KnowledgeController(IAzureTableDBRepository table, AzureCosmosFactory cosmos, IKnowledgeService knowledgeService)
+        public KnowledgeController(AzureStorageFactory table, AzureCosmosFactory cosmos, IKnowledgeService knowledgeService)
         {
         {
             _table = table;
             _table = table;
             _cosmos = cosmos;
             _cosmos = cosmos;

+ 4 - 4
TEAMModelOS/Controllers/Syllabus/ResourceController.cs

@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -8,7 +8,7 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
+
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Models;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers
@@ -17,11 +17,11 @@ namespace TEAMModelOS.Controllers
     [ApiController]
     [ApiController]
     public class ResourceController : BaseController
     public class ResourceController : BaseController
     {
     {
-        private IAzureTableDBRepository _table;
+        private AzureStorageFactory _table;
         private AzureCosmosFactory _cosmos;
         private AzureCosmosFactory _cosmos;
         private readonly IAzureBlobDBRepository _azureBlobDBRepository;
         private readonly IAzureBlobDBRepository _azureBlobDBRepository;
 
 
-        public ResourceController(IAzureTableDBRepository table, AzureCosmosFactory cosmos, IAzureBlobDBRepository azureBlobDBRepository)
+        public ResourceController(AzureStorageFactory table, AzureCosmosFactory cosmos, IAzureBlobDBRepository azureBlobDBRepository)
         {
         {
             _table = table;
             _table = table;
             _cosmos = cosmos;
             _cosmos = cosmos;

+ 1 - 2
TEAMModelOS/Controllers/Syllabus/SyllabusController.cs

@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK.Context.Exception;
@@ -9,7 +9,6 @@ using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using System;
 using System;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using System.Linq;
 using System.Linq;
-using TEAMModelOS.SDK.DI;
 using Newtonsoft.Json;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using Newtonsoft.Json.Linq;
 using TEAMModelOS.Service.Services.Interface;
 using TEAMModelOS.Service.Services.Interface;

+ 1 - 2
TEAMModelOS/Controllers/Syllabus/VolumeController.cs

@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -11,7 +11,6 @@ using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.Controllers;
 using TEAMModelOS.Controllers;
-using TEAMModelOS.SDK.DI;
 using TEAMModelOS.Service.Services.Interface;
 using TEAMModelOS.Service.Services.Interface;
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Models;
 using Org.BouncyCastle.Ocsp;
 using Org.BouncyCastle.Ocsp;

+ 1 - 2
TEAMModelOS/Controllers/Task/HomeworkController.cs

@@ -1,4 +1,4 @@
-
+
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Azure.ServiceBus;
 using Microsoft.Azure.ServiceBus;
 using System;
 using System;
@@ -21,7 +21,6 @@ using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Services.Learn;
 using TEAMModelOS.Service.Services.Learn;
 using TEAMModelOS.Service.Services.Learn.Interfaces;
 using TEAMModelOS.Service.Services.Learn.Interfaces;
 using TEAMModelOS.SDK.Context.Constant.Common;
 using TEAMModelOS.SDK.Context.Constant.Common;
-using TEAMModelOS.SDK.DI;
 
 
 namespace TEAMModelOS.Controllers.Learn
 namespace TEAMModelOS.Controllers.Learn
 {
 {

+ 3 - 4
TEAMModelOS/Controllers/Teacher/SchoolUserController.cs

@@ -6,7 +6,6 @@ using System.Threading.Tasks;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
-using TEAMModelOS.SDK.DI;
 using TEAMModelOS.Service.Models;
 using TEAMModelOS.Service.Models;
 using System.Linq;
 using System.Linq;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
@@ -14,7 +13,7 @@ using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
 using System.Text.Json;
 using System.Text.Json;
 using Newtonsoft.Json.Linq;
 using Newtonsoft.Json.Linq;
 using Newtonsoft.Json;
 using Newtonsoft.Json;
-using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
+
 using System.Collections;
 using System.Collections;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK.Context.Exception;
 using System.Reflection;
 using System.Reflection;
@@ -26,8 +25,8 @@ namespace TEAMModelOS.Controllers
     public class SchoolUserController : Controller
     public class SchoolUserController : Controller
     {
     {
         private AzureCosmosFactory _cosmosrepository;
         private AzureCosmosFactory _cosmosrepository;
-        private IAzureTableDBRepository _tablerepository;
-        public SchoolUserController(AzureCosmosFactory cosmosDBRepository, IAzureTableDBRepository tableDBRepository)
+        private AzureStorageFactory _tablerepository;
+        public SchoolUserController(AzureCosmosFactory cosmosDBRepository, AzureStorageFactory tableDBRepository)
         {
         {
             _cosmosrepository = cosmosDBRepository;
             _cosmosrepository = cosmosDBRepository;
             _tablerepository = tableDBRepository;
             _tablerepository = tableDBRepository;

+ 3 - 38
TEAMModelOS/Startup.cs

@@ -89,50 +89,19 @@ namespace TEAMModelOS
             services.AddMemoryCache();            
             services.AddMemoryCache();            
             services.AddControllers().AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = false; });
             services.AddControllers().AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = false; });
             services.Configure<Option>(options => Configuration.GetSection("Option").Bind(options));
             services.Configure<Option>(options => Configuration.GetSection("Option").Bind(options));
-            
-            //.AddNewtonsoftJson().AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
-            //上传文件最大处理
-            services.Configure<FormOptions>(x =>
-            {
-                x.BufferBodyLengthLimit = long.MaxValue;
-                x.ValueLengthLimit = int.MaxValue;
-                x.MultipartBodyLengthLimit = long.MaxValue; // In case of multipart
-                x.MultipartHeadersLengthLimit = int.MaxValue;
-            });
-
-            // Table配置
-            //services.AddScoped<IAzureTableDBRepository, AzureTableDBRepository>();
+            //Table配置
+            // services.AddScoped<IAzureTableDBRepository, AzureTableDBRepository>();
             //使用Blob配置
             //使用Blob配置
             //services.AddAzureBlobStorage().AddConnection(Configuration.GetSection("Azure:Blob").Get<AzureBlobOptions>());
             //services.AddAzureBlobStorage().AddConnection(Configuration.GetSection("Azure:Blob").Get<AzureBlobOptions>());
-            //使用CosmosDB
-            //services.AddAzureCosmosDBV3().AddCosmosDBV3Connection(Configuration.GetSection("Azure:CosmosDB").Get<AzureCosmosDBOptions>())
-            //    .AddCosmosSerializer(new SystemTextJsonCosmosSerializer(new JsonSerializerOptions() { IgnoreNullValues = true }));
             //使用AzureServiceBus
             //使用AzureServiceBus
             services.AddServiceBus().AddServiceBusOptions(Configuration.GetSection("Azure:ServiceBus").Get<AzureServiceBusOptions>());
             services.AddServiceBus().AddServiceBusOptions(Configuration.GetSection("Azure:ServiceBus").Get<AzureServiceBusOptions>());
             services.AddSingleton<IServiceBusService, ServiceBusService>();
             services.AddSingleton<IServiceBusService, ServiceBusService>();
-            
             //HttpContextAccessor,并用来访问HttpContext。
             //HttpContextAccessor,并用来访问HttpContext。
             services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
             services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
             //services.AddSingleton<IServiceBusReviceService, ServiceBusReviceService>();
             //services.AddSingleton<IServiceBusReviceService, ServiceBusReviceService>();
             //注入CSRedis
             //注入CSRedis
             var csredis = new CSRedis.CSRedisClient(Configuration.GetSection("Azure:Redis:ConnectionString").Get<string>());
             var csredis = new CSRedis.CSRedisClient(Configuration.GetSection("Azure:Redis:ConnectionString").Get<string>());
-            // CSRedis.CSRedisClient.Serialize = obj =>System.Text.Json.JsonSerializer.Serialize(obj);
-            //   CSRedis.CSRedisClient.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
             RedisHelper.Initialization(csredis);
             RedisHelper.Initialization(csredis);
-            // RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
-            //services.AddSingleton<PowerPointService, PowerPointService>();
-
-
-            //全局扫描基于IBusinessService接口的实现类
-            //services.Scan(scan => scan.FromApplicationDependencies()
-            //   .AddClasses(classes => classes.AssignableTo<IBusinessService>())
-            //       .AsImplementedInterfaces()
-            //       .WithScopedLifetime());
-            //services.Scan(scan => scan.FromApplicationDependencies()
-            //   .AddClasses(classes => classes.AssignableTo<IChangeService>()).UsingRegistrationStrategy(RegistrationStrategy.Skip)
-            //       .AsImplementedInterfaces()
-            //      .WithSingletonLifetime());
-           // _services = services;
         }
         }
 
 
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -142,11 +111,7 @@ namespace TEAMModelOS
             {
             {
                 app.UseDeveloperExceptionPage();
                 app.UseDeveloperExceptionPage();
             }
             }
-            //CosmosDict dict = cosmosDBV3Repository.InitializeDatabase().Result;
-            //changeFeedInvoke.MonitorChangeFeed(dict, _services);
-            //azureServiceBusService.init();
-            //serviceBusReviceService.ReciveMessageAsync();
-            app.UseMiddleware<HttpGlobalExceptionInvoke>();
+            //app.UseMiddleware<HttpGlobalExceptionInvoke>();
             //以下需要按照順序載入中間件  如果应用调用 UseStaticFiles,请将 UseStaticFiles 置于 UseRouting之前。
             //以下需要按照順序載入中間件  如果应用调用 UseStaticFiles,请将 UseStaticFiles 置于 UseRouting之前。
             app.UseStaticFiles();
             app.UseStaticFiles();
             //app.UseSpaStaticFiles(); //使用中間件不開
             //app.UseSpaStaticFiles(); //使用中間件不開