浏览代码

合并SDK包

黄贺彬 6 年之前
父节点
当前提交
ed81ed56ef
共有 100 个文件被更改,包括 7669 次插入41 次删除
  1. 0 1
      TEAMModelOS.Context.Filter/TEAMModelOS.Context.Filter.csproj
  2. 1 5
      TEAMModelOS.Extension.JwtAuth/TEAMModelOS.Extension.JwtAuth.csproj
  3. 0 1
      TEAMModelOS.Extension.MessagePush/TEAMModelOS.Extension.MessagePush.csproj
  4. 48 0
      TEAMModelOS.Model.Syllabus/Dtos/SyllabusNode.cs
  5. 17 0
      TEAMModelOS.Model.Syllabus/Models/KnowledgePoint.cs
  6. 52 0
      TEAMModelOS.Model.Syllabus/Models/Syllabus.cs
  7. 57 0
      TEAMModelOS.Model.Syllabus/Models/SyllabusResource.cs
  8. 32 0
      TEAMModelOS.Model.Syllabus/Models/TeachingResource.cs
  9. 38 0
      TEAMModelOS.Model.Syllabus/Models/Textbook.cs
  10. 1 2
      TEAMModelOS.Model.Syllabus/TEAMModelOS.Model.Syllabus.csproj
  11. 0 5
      TEAMModelOS.Module.AzureBlob/TEAMModelOS.Module.AzureBlob.csproj
  12. 0 6
      TEAMModelOS.Module.AzureCosmosDB/TEAMModelOS.Module.AzureCosmosDB.csproj
  13. 0 7
      TEAMModelOS.Module.AzureTable/TEAMModelOS.Module.AzureTable.csproj
  14. 0 4
      TEAMModelOS.Module.Cache/TEAMModelOS.Module.Cache.csproj
  15. 0 5
      TEAMModelOS.Module.GrpcServer/TEAMModelOS.Module.GrpcServer.csproj
  16. 0 5
      TEAMModelOS.Module.LiteDB/TEAMModelOS.Module.LiteDB.csproj
  17. 22 0
      TEAMModelOS.SDK/Context/Attribute/AllowCors/AllowCorsAttribute.cs
  18. 31 0
      TEAMModelOS.SDK/Context/Configuration/BaseConfigModel.cs
  19. 31 0
      TEAMModelOS.SDK/Context/Constant/Constants.cs
  20. 24 0
      TEAMModelOS.SDK/Context/Constant/FileType.cs
  21. 44 0
      TEAMModelOS.SDK/Context/Constant/FileTypeMap.cs
  22. 25 0
      TEAMModelOS.SDK/Context/Constant/GetFileType.cs
  23. 59 0
      TEAMModelOS.SDK/Context/Constant/ResponseCode.cs
  24. 54 0
      TEAMModelOS.SDK/Context/Exception/BizException.cs
  25. 148 0
      TEAMModelOS.SDK/Context/Filters/HttpGlobalExceptionInvoke.cs
  26. 20 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcRequest/AzureTokenJsonRPCRequest.cs
  27. 15 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcRequest/BaseJosnRPCRequest.cs
  28. 11 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcRequest/JosnRPCRequest.cs
  29. 15 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcRequest/PaginationJosnRPCRequest.cs
  30. 14 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/BaseJosnRPCResponse.cs
  31. 16 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/DataJosnRPCResponse.cs
  32. 16 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/ErrorJosnRPCResponse.cs
  33. 13 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/ErrorModel.cs
  34. 13 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/JosnRPCResponse.cs
  35. 169 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/JsonRPCResponseBuilder.cs
  36. 16 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/JsonRPCResult.cs
  37. 17 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/PageJosnRPCResponse.cs
  38. 15 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/PageJsonRPCResult.cs
  39. 17 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/TokenJosnRPCResponse.cs
  40. 16 0
      TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/TokenJsonRPCResult.cs
  41. 13 0
      TEAMModelOS.SDK/Extension/DataResult/PageToken/AzurePagination.cs
  42. 17 0
      TEAMModelOS.SDK/Extension/DataResult/PageToken/AzureTableToken.cs
  43. 31 0
      TEAMModelOS.SDK/Extension/DataResult/PageToken/Pagination.cs
  44. 12 0
      TEAMModelOS.SDK/Extension/DataResult/PageToken/PaginationData.cs
  45. 13 0
      TEAMModelOS.SDK/Extension/DataResult/RequestData/AzureTokenRequest.cs
  46. 12 0
      TEAMModelOS.SDK/Extension/DataResult/RequestData/BaseRequest.cs
  47. 10 0
      TEAMModelOS.SDK/Extension/DataResult/RequestData/PaginationRequest.cs
  48. 16 0
      TEAMModelOS.SDK/Extension/DataResult/ResponseData/BaseResponse.cs
  49. 14 0
      TEAMModelOS.SDK/Extension/DataResult/ResponseData/DataResponse.cs
  50. 15 0
      TEAMModelOS.SDK/Extension/DataResult/ResponseData/PageDatasResponse.cs
  51. 162 0
      TEAMModelOS.SDK/Extension/DataResult/ResponseData/ResponseBuilder.cs
  52. 16 0
      TEAMModelOS.SDK/Extension/DataResult/ResponseData/TimeStampResponse.cs
  53. 14 0
      TEAMModelOS.SDK/Extension/DataResult/ResponseData/TokenPageDatasResponse.cs
  54. 53 0
      TEAMModelOS.SDK/Extension/JwtAuth/Filters/JwtAuthorizationFilter.cs
  55. 83 0
      TEAMModelOS.SDK/Extension/JwtAuth/JwtAuthExtension.cs
  56. 74 0
      TEAMModelOS.SDK/Extension/JwtAuth/JwtHelper/JwtHelper.cs
  57. 27 0
      TEAMModelOS.SDK/Extension/JwtAuth/Models/ClaimModel.cs
  58. 12 0
      TEAMModelOS.SDK/Extension/JwtAuth/Models/HttpConstant.cs
  59. 12 0
      TEAMModelOS.SDK/Extension/JwtAuth/Models/JwtClient.cs
  60. 13 0
      TEAMModelOS.SDK/Extension/JwtAuth/Models/JwtResponse.cs
  61. 30 0
      TEAMModelOS.SDK/Extension/JwtAuth/Models/JwtSetting.cs
  62. 38 0
      TEAMModelOS.SDK/Extension/Language/Implements/LanguageService.cs
  63. 12 0
      TEAMModelOS.SDK/Extension/Language/Interfaces/ILanguageService.cs
  64. 18 0
      TEAMModelOS.SDK/Extension/Language/LanguageExtension.cs
  65. 10 0
      TEAMModelOS.SDK/Extension/Language/Model/SmsCountryCode.cs
  66. 152 0
      TEAMModelOS.SDK/Extension/MessagePush/Implements/SendCloudService.cs
  67. 42 0
      TEAMModelOS.SDK/Extension/MessagePush/Interfaces/ISendCloudService.cs
  68. 20 0
      TEAMModelOS.SDK/Extension/MessagePush/MessagePushExtension.cs
  69. 30 0
      TEAMModelOS.SDK/Extension/MessagePush/Model/SendCloudResponse.cs
  70. 36 0
      TEAMModelOS.SDK/Extension/MessagePush/Model/SmsConfig.cs
  71. 12 0
      TEAMModelOS.SDK/Extension/MessagePush/Model/SmsSendCloud.cs
  72. 94 0
      TEAMModelOS.SDK/Helper/Common/DateTimeHelper/DateTimeHelper.cs
  73. 755 0
      TEAMModelOS.SDK/Helper/Common/FileHelper/FileHelper.cs
  74. 550 0
      TEAMModelOS.SDK/Helper/Common/FileHelper/FileHelperCore.cs
  75. 116 0
      TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonSerialization.cs
  76. 74 0
      TEAMModelOS.SDK/Helper/Common/JsonHelper/MessagePackHelper.cs
  77. 35 0
      TEAMModelOS.SDK/Helper/Common/ReflectorExtensions/ReflectorExtensions.cs
  78. 77 0
      TEAMModelOS.SDK/Helper/Common/StringHelper/StringHelper.cs
  79. 65 0
      TEAMModelOS.SDK/Helper/Common/ValidateHelper/ValidateHelper.cs
  80. 96 0
      TEAMModelOS.SDK/Helper/Network/HttpHelper/HttpContextHelper.cs
  81. 186 0
      TEAMModelOS.SDK/Helper/Network/HttpHelper/HttpHelper.cs
  82. 86 0
      TEAMModelOS.SDK/Helper/Network/NetworkHelper/NetworkHelper.cs
  83. 175 0
      TEAMModelOS.SDK/Helper/Query/LinqHelper/DynamicLinq.cs
  84. 2336 0
      TEAMModelOS.SDK/Helper/Query/LinqHelper/DynamicQueryable.cs
  85. 13 0
      TEAMModelOS.SDK/Helper/Query/LinqHelper/Filter.cs
  86. 218 0
      TEAMModelOS.SDK/Helper/Security/AESCrypt/AESCrypt.cs
  87. 29 0
      TEAMModelOS.SDK/Helper/Security/BCryptHelper/BCryptHelper.cs
  88. 69 0
      TEAMModelOS.SDK/Helper/Security/Base64Crypt/Base64Crypt.cs
  89. 133 0
      TEAMModelOS.SDK/Helper/Security/DesCrypt/DES3Crypt.cs
  90. 97 0
      TEAMModelOS.SDK/Helper/Security/DesCrypt/DESCrypt.cs
  91. 87 0
      TEAMModelOS.SDK/Helper/Security/Md5Hash/Md5Hash.cs
  92. 62 0
      TEAMModelOS.SDK/Helper/Security/RSACrypt/RSACrypt.cs
  93. 12 0
      TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobConfig.cs
  94. 20 0
      TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobOptions.cs
  95. 24 0
      TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobServiceBuilder.cs
  96. 48 0
      TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobServiceCollectionExtensions.cs
  97. 42 0
      TEAMModelOS.SDK/Module/AzureBlob/Configuration/BlobClientSingleton.cs
  98. 72 0
      TEAMModelOS.SDK/Module/AzureBlob/Container/AzureBlobModel.cs
  99. 12 0
      TEAMModelOS.SDK/Module/AzureBlob/Container/FileContainer.cs
  100. 0 0
      TEAMModelOS.SDK/Module/AzureBlob/Container/IBlobContainer.cs

+ 0 - 1
TEAMModelOS.Context.Filter/TEAMModelOS.Context.Filter.csproj

@@ -11,7 +11,6 @@
   <ItemGroup>
     <ProjectReference Include="..\TEAMModelOS.Context.Constant\TEAMModelOS.Context.Constant.csproj" />
     <ProjectReference Include="..\TEAMModelOS.Context.Exception\TEAMModelOS.Context.Exception.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Common\TEAMModelOS.Helper.Common.csproj" />
   </ItemGroup>
 
 </Project>

+ 1 - 5
TEAMModelOS.Extension.JwtAuth/TEAMModelOS.Extension.JwtAuth.csproj

@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
     <TargetFramework>netcoreapp2.2</TargetFramework>
@@ -13,8 +13,4 @@
     <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
   </ItemGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="..\TEAMModelOS.Helper.Common\TEAMModelOS.Helper.Common.csproj" />
-  </ItemGroup>
-
 </Project>

+ 0 - 1
TEAMModelOS.Extension.MessagePush/TEAMModelOS.Extension.MessagePush.csproj

@@ -6,7 +6,6 @@
 
   <ItemGroup>
     <ProjectReference Include="..\TEAMModelOS.Extension.Language\TEAMModelOS.Extension.Language.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Network\TEAMModelOS.Helper.Network.csproj" />
     <ProjectReference Include="..\TEAMModelOS.Module.AzureTable\TEAMModelOS.Module.AzureTable.csproj" />
   </ItemGroup>
 

+ 48 - 0
TEAMModelOS.Model.Syllabus/Dtos/SyllabusNode.cs

@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Model.Syllabus.Dtos
+{
+    public class SyllabusNode
+    {
+        public ICollection<SyllabusNode> Children { get; set; }
+        /// <summary>
+        /// id
+        /// </summary>
+        public string Id { get; set; }
+        /// <summary>
+        /// 标题
+        /// </summary>
+        public string Title { get; set; }
+        /// <summary>
+        /// 是否展开
+        /// </summary>
+        public bool Expand { get; set; }
+        /// <summary>
+        /// 是否禁用响应
+        /// </summary>
+        public bool Disabled { get; set; }
+        /// <summary>
+        /// 是否禁用复选框
+        /// </summary>
+        public bool DisableCheckbox { get; set; }
+        /// <summary>
+        /// 选中当前节点
+        /// </summary>
+        public bool Selected { get; set; }
+        public bool @Checked { get; set; }
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Order { get; set; }
+        /// <summary>
+        /// 类型
+        /// </summary>
+        public int Type { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+}

+ 17 - 0
TEAMModelOS.Model.Syllabus/Models/KnowledgePoint.cs

@@ -0,0 +1,17 @@
+using Microsoft.WindowsAzure.Storage.Table;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Model.Syllabus.Models
+{
+    /// <summary>
+    /// 知识点
+    /// </summary>
+    public class KnowledgePoint : TableEntity
+    {
+        public string Id { get; set; }
+        public string Pid { get; set; }
+        public string Name { get; set; }
+    }
+}

+ 52 - 0
TEAMModelOS.Model.Syllabus/Models/Syllabus.cs

@@ -0,0 +1,52 @@
+using Microsoft.WindowsAzure.Storage.Table;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Model.Syllabus.Models
+{
+    /// <summary>
+    /// 课纲结构
+    /// </summary>
+    public class Syllabus : TableEntity
+    {
+        /// <summary>
+        /// id
+        /// </summary>
+        public string Id { get; set; }
+        /// <summary>
+        /// 标题
+        /// </summary>
+        public string Title { get; set; }
+        /// <summary>
+        /// 是否展开
+        /// </summary>
+        public bool Expand { get; set; }
+        /// <summary>
+        /// 是否禁用响应
+        /// </summary>
+        public bool Disabled { get; set; }
+        /// <summary>
+        /// 是否禁用复选框
+        /// </summary>
+        public bool DisableCheckbox { get; set; }
+        /// <summary>
+        /// 选中当前节点
+        /// </summary>
+        public bool Selected { get; set; }
+        public bool @Checked { get; set; }
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Order { get; set; }
+        /// <summary>
+        /// 类型
+        /// </summary>
+        public int Type { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+
+    }
+}

+ 57 - 0
TEAMModelOS.Model.Syllabus/Models/SyllabusResource.cs

@@ -0,0 +1,57 @@
+using Microsoft.WindowsAzure.Storage.Table;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Model.Syllabus.Models
+{
+    /// <summary>
+    /// 课纲资源
+    /// </summary>
+    public class SyllabusResource : TableEntity
+    {
+        public string Id { get; set; }
+        public string Name { get; set; }
+        /// <summary>
+        /// 教案,学案,课件,微课,习题,素材,拓展
+        /// </summary>
+        public string Type { get; set; }
+        /// <summary>
+        /// 图片,文档,视频,音频,动画,互动
+        /// </summary>
+        public string Ext { get; set; }
+        public object Res { get; set; }
+        /// <summary>
+        /// 100个人可见,200学校可见(集备资源),300本区县可见,400本市可见,500本省可见,全部可见(共享资源)
+        /// </summary>
+        public int Level { get; set; }
+        /// <summary>
+        /// 综合评分
+        /// </summary>
+        public double Score { get; set; }
+        /// <summary>
+        /// 上传者
+        /// </summary>
+        public string Uploader { get; set; }
+        /// <summary>
+        /// 上传时间
+        /// </summary>
+        public string Time { get; set; }
+        /// <summary>
+        /// 大小
+        /// </summary>
+        public double Size { get; set; }
+        /// <summary>
+        /// 浏览次数
+        /// </summary>
+        public int Preview { get; set; }
+        /// <summary>
+        /// 下载次数
+        /// </summary>
+        public int Download { get; set; }
+        /// <summary>
+        /// 收藏次数
+        /// </summary>
+        public int Collect { get; set; }
+    }
+}

+ 32 - 0
TEAMModelOS.Model.Syllabus/Models/TeachingResource.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Model.Syllabus.Models
+{
+    /// <summary>
+    /// 教学资源
+    /// </summary>
+    public class TeachingResource
+    {
+        public string Id { get; set; }
+        public string SyResId { get; set; }
+        /// <summary>
+        /// 教案,学案,课件,微课,习题,素材,拓展
+        /// </summary>
+        public string Type { get; set; }
+        /// <summary>
+        /// 图片,文档,视频,音频,动画,互动
+        /// </summary>
+        public string Ext { get; set; }
+        public object Res { get; set; }
+        /// <summary>
+        /// 上传时间
+        /// </summary>
+        public string Time { get; set; }
+        /// <summary>
+        /// 上传时间
+        /// </summary>
+        public double Size { get; set; }
+    }
+}

+ 38 - 0
TEAMModelOS.Model.Syllabus/Models/Textbook.cs

@@ -0,0 +1,38 @@
+using Microsoft.WindowsAzure.Storage.Table;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Model.Syllabus.Models
+{
+    /// <summary>
+    /// 教材
+    /// </summary>
+    public class Textbook : TableEntity
+    {
+        /// <summary>
+        /// 学段
+        /// </summary>
+        public string Period { get; set; }
+        /// <summary>
+        /// 学科
+        /// </summary>
+        public string Subject { get; set; }
+        /// <summary>
+        /// 版本
+        /// </summary>
+        public string Version { get; set; }
+        /// <summary>
+        /// 名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 年级
+        /// </summary>
+        public string Grade { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+}

+ 1 - 2
TEAMModelOS.Model.Syllabus/TEAMModelOS.Model.Syllabus.csproj

@@ -5,8 +5,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <Folder Include="Dtos\" />
-    <Folder Include="Models\" />
+    <PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
   </ItemGroup>
 
 </Project>

+ 0 - 5
TEAMModelOS.Module.AzureBlob/TEAMModelOS.Module.AzureBlob.csproj

@@ -9,11 +9,6 @@
     <PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
   </ItemGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="..\TEAMModelOS.Context.Exception\TEAMModelOS.Context.Exception.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Security\TEAMModelOS.Helper.Security.csproj" />
-  </ItemGroup>
-
   <ItemGroup>
     <Reference Include="Microsoft.AspNetCore.Http">
       <HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.http\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.dll</HintPath>

+ 0 - 6
TEAMModelOS.Module.AzureCosmosDB/TEAMModelOS.Module.AzureCosmosDB.csproj

@@ -8,10 +8,4 @@
     <PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.2.3" />
   </ItemGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="..\TEAMModelOS.Context.Exception\TEAMModelOS.Context.Exception.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Query\TEAMModelOS.Helper.Query.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Security\TEAMModelOS.Helper.Security.csproj" />
-  </ItemGroup>
-
 </Project>

+ 0 - 7
TEAMModelOS.Module.AzureTable/TEAMModelOS.Module.AzureTable.csproj

@@ -9,11 +9,4 @@
     <PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
   </ItemGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="..\TEAMModelOS.Context.Exception\TEAMModelOS.Context.Exception.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Extension.DataResult\TEAMModelOS.Extension.DataResult.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Common\TEAMModelOS.Helper.Common.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Security\TEAMModelOS.Helper.Security.csproj" />
-  </ItemGroup>
-
 </Project>

+ 0 - 4
TEAMModelOS.Module.Cache/TEAMModelOS.Module.Cache.csproj

@@ -4,10 +4,6 @@
     <TargetFramework>netcoreapp2.2</TargetFramework>
   </PropertyGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="..\TEAMModelOS.Helper.Common\TEAMModelOS.Helper.Common.csproj" />
-  </ItemGroup>
-
   <ItemGroup>
     <Reference Include="Microsoft.Extensions.Caching.Abstractions">
       <HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.caching.abstractions\2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll</HintPath>

+ 0 - 5
TEAMModelOS.Module.GrpcServer/TEAMModelOS.Module.GrpcServer.csproj

@@ -12,9 +12,4 @@
     <PackageReference Include="Scrutor" Version="3.0.2" />
   </ItemGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="..\TEAMModelOS.Helper.Common\TEAMModelOS.Helper.Common.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Network\TEAMModelOS.Helper.Network.csproj" />
-  </ItemGroup>
-
 </Project>

+ 0 - 5
TEAMModelOS.Module.LiteDB/TEAMModelOS.Module.LiteDB.csproj

@@ -8,9 +8,4 @@
     <PackageReference Include="LiteDB" Version="4.1.4" />
   </ItemGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="..\TEAMModelOS.Context.Exception\TEAMModelOS.Context.Exception.csproj" />
-    <ProjectReference Include="..\TEAMModelOS.Helper.Common\TEAMModelOS.Helper.Common.csproj" />
-  </ItemGroup>
-
 </Project>

+ 22 - 0
TEAMModelOS.SDK/Context/Attribute/AllowCors/AllowCorsAttribute.cs

@@ -0,0 +1,22 @@
+using Microsoft.AspNetCore.Mvc.Filters;
+
+namespace TEAMModelOS.SDK.Context.Attribute.AllowCors
+{
+    /// <summary>
+    /// 跨域处理
+    /// </summary>
+    public class AllowCorsAttribute : ActionFilterAttribute
+    {
+        public override void OnActionExecuting(ActionExecutingContext filterContext)
+        {
+            var context = filterContext.HttpContext;
+            //context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
+            context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS, POST, PUT");
+            context.Response.Headers.Add("Access-Control-Allow-Headers", "Access-Control-Allow-Headers," +
+                                         " Origin,Accept, X-Requested-With, Content-Type, " +
+                                         "Access-Control-Request-Method, Access-Control-Request-Headers," +
+                                         "Content-Type,Accept,access_token,token,Authorization");
+            base.OnActionExecuting(filterContext);
+        }
+    }
+}

+ 31 - 0
TEAMModelOS.SDK/Context/Configuration/BaseConfigModel.cs

@@ -0,0 +1,31 @@
+using Microsoft.Extensions.Configuration;
+
+namespace TEAMModelOS.SDK.Context.Configuration
+{
+    public class BaseConfigModel
+    {
+        public static IConfiguration Configuration { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+
+        public static string ContentRootPath { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+
+        public static string WebRootPath { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="config"></param>
+        /// <param name="contentRootPath"></param>
+        /// <param name="webRootPath"></param>
+        public static void SetBaseConfig(IConfiguration config, string contentRootPath, string webRootPath)
+        {
+            Configuration = config;
+            ContentRootPath = contentRootPath;
+            WebRootPath = webRootPath;
+        }
+    }
+}

+ 31 - 0
TEAMModelOS.SDK/Context/Constant/Constants.cs

@@ -0,0 +1,31 @@
+
+namespace TEAMModelOS.SDK.Context.Constant.Common
+{
+    public static class Constants
+    {
+        /// <summary>
+        /// access_token
+        /// </summary>
+		public static readonly string ACCESS_TOKEN = "access_token";
+        /// <summary>
+        /// 引用页
+        /// </summary>
+		public static readonly string REFERER = "referer";
+        /// <summary>
+        /// token 请求头
+        /// </summary>
+		public static readonly string AUTHORIZATION = "Authorization";
+        /// <summary>
+        /// josn格式
+        /// </summary>
+		public static readonly string CONTENT_TYPE_JSON = "application/json";
+        /// <summary>
+        /// 苏格拉底作品类型--团队组
+        /// </summary>
+		public static readonly string SIGNUPTYPEGRP = "2018TMCNTSGRP";
+        /// <summary>
+        /// 苏格拉底作品类型--个人组
+        /// </summary>
+		public static readonly string SIGNUPTYPEINT = "2018TMCNTSIND";
+    }
+}

+ 24 - 0
TEAMModelOS.SDK/Context/Constant/FileType.cs

@@ -0,0 +1,24 @@
+namespace TEAMModelOS.SDK.Context.Constant.Common
+{
+	public class FileType
+	{
+		public string Id { get; set;}
+		public string Extention { get; set; }
+		public string Type { get; set; }
+
+		public FileType(string id, string extention, string type)
+		{
+			Id = id;
+			Extention = extention;
+			Type = type;
+		}
+		public static string GetExtention(string fileName) {
+			if (string.IsNullOrEmpty(fileName)) {
+				return "";
+			} else {
+				return fileName.Substring(fileName.LastIndexOf(".") + 1);
+			}
+			
+		}
+	}
+}

+ 44 - 0
TEAMModelOS.SDK/Context/Constant/FileTypeMap.cs

@@ -0,0 +1,44 @@
+using System.Collections.Generic;
+
+
+namespace TEAMModelOS.SDK.Context.Constant.Common
+{
+	public class FileTypeMap
+	{
+		private Dictionary<string, FileType> FileTpyeMap { get; set; }
+
+		public FileTypeMap FileTypes(FileType fileType) {
+			if (this.FileTpyeMap == null)
+			{
+				FileTpyeMap = new Dictionary<string, FileType>();
+				//fileTpyeMap.Add(fileType.Type, fileType);
+			}
+			if(!FileTpyeMap.ContainsKey(fileType.Extention)) {
+				FileTpyeMap.Add(fileType.Extention, fileType);
+			}
+			return this;
+		}
+		public Dictionary<string, FileType> GetFileTypes() {
+			FileTypes(new FileType("1", "jpg", "img")).
+			FileTypes(new FileType("2", "png", "img")).
+			FileTypes(new FileType("3", "bmp", "img")).
+			FileTypes(new FileType("4", "jpeg", "img")).
+			FileTypes(new FileType("5", "gif", "img")).
+			FileTypes(new FileType("6", "mp4", "video")).
+			FileTypes(new FileType("7", "avi", "video")).
+			FileTypes(new FileType("8", "mpeg", "video")).
+			FileTypes(new FileType("9", "mov", "video")).
+			FileTypes(new FileType("10", "wmv", "video")).
+			FileTypes(new FileType("11", "doc", "file")).
+			FileTypes(new FileType("12", "docx", "file")).
+			FileTypes(new FileType("13", "ppt", "file")).
+			FileTypes(new FileType("14", "pptx", "file")).
+			FileTypes(new FileType("15", "xls", "file")).
+			FileTypes(new FileType("16", "xlsx", "file")).
+			FileTypes(new FileType("17", "zip", "file")).
+			FileTypes(new FileType("18", "rar", "file")).
+			FileTypes(new FileType("19", "pdf", "file"));
+			return FileTpyeMap;
+		}
+	}
+}

+ 25 - 0
TEAMModelOS.SDK/Context/Constant/GetFileType.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Context.Constant.Common
+{
+	public class GetFileType
+	{
+		//private 
+
+		public GetFileType() { 
+		
+		}
+
+		public string GetExtension(string fileName) {
+			return fileName.Substring(fileName.LastIndexOf(".") + 1, (fileName.Length - fileName.LastIndexOf(".") - 1)); //扩展名
+		}
+
+		public string GetType(string fileName) {
+			string extension = GetExtension(fileName);
+
+			return null;
+		}
+	}
+}

+ 59 - 0
TEAMModelOS.SDK/Context/Constant/ResponseCode.cs

@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Context.Constant.Common
+{
+
+    /// <summary>
+    /// 响应编码
+    /// </summary>
+    public static class ResponseCode
+    {
+        /// <summary>
+        /// 代表HTTP正常请求
+        /// </summary>
+        public readonly static int HTTP_SUCCESS = 200;
+        /// <summary>
+        /// 一般常用代表成功
+        /// </summary>
+        public readonly static int SUCCESS = 0;
+        /// <summary>
+        /// 一般常用代表失败
+        /// </summary>
+        public readonly static int FAILED = 1;
+        /// <summary>
+        /// 数据为空或null
+        /// </summary>
+        public readonly static int DATA_EMPTY_NULL = 2;
+        /// <summary>
+        /// 参数异常
+        /// </summary>
+        public readonly static int PARAMS_ERROR = 3;
+        /// <summary>
+        /// 服务端异常
+        /// </summary>
+        public readonly static int SERVER_ERROR = 500;
+        /// <summary>
+        /// 未知异常
+        /// </summary>
+        public readonly static int UNDEFINED = 9;
+        /// <summary>
+        /// 资源未找到
+        /// </summary>
+        public readonly static int NOT_FOUND = 404;
+        /// <summary>
+        /// 未授权
+        /// </summary>
+        public readonly static int UNAUTH = 401;
+        /// <summary>
+        /// 网关路由异常
+        /// </summary>
+        public readonly static int GATEWAY_ERROR = 504;
+        /// <summary>
+        /// 响应超时
+        /// </summary>
+        public readonly static int TIMEOUT_ERROR = 503;
+        
+    }
+}

+ 54 - 0
TEAMModelOS.SDK/Context/Exception/BizException.cs

@@ -0,0 +1,54 @@
+using System;
+
+namespace TEAMModelOS.SDK.Context.Exception
+{
+    public class BizException : System.Exception
+    {
+        public string message { get; set; } = "error";
+        public int code { get; set; } = 1;
+        public string devMessage { get; set; }
+        public BizException(int code, String message, string stackTrace) : base(message)
+        {
+            if (string.IsNullOrEmpty(stackTrace))
+            {
+                this.devMessage = this.StackTrace;
+            }
+            else
+            {
+                this.devMessage = stackTrace;
+            }
+            this.message = message;
+            this.code = code;
+        }
+        public BizException(int code, String message) : base(message)
+        {
+            this.devMessage = this.StackTrace;
+            this.message = message;
+            this.code = code;
+        }
+        //
+        // 摘要:
+        //     Initializes a new instance of the System.Exception class.
+        public BizException() : base()
+        {
+            this.devMessage = this.StackTrace;
+            this.message = "error";
+            this.code = 1;
+        }
+
+        //
+        // 摘要:
+        //     Initializes a new instance of the System.Exception class with a specified error
+        //     message.
+        //
+        // 参数:
+        //   message:
+        //     The message that describes the error.
+        public BizException(string message) : base(message)
+        {
+            this.message = message;
+            this.devMessage = this.StackTrace;
+            this.code = 1;
+        }
+    }
+}

+ 148 - 0
TEAMModelOS.SDK/Context/Filters/HttpGlobalExceptionInvoke.cs

@@ -0,0 +1,148 @@
+using MessagePack;
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.Context.Constant.Common;
+using TEAMModelOS.SDK.Context.Exception;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
+
+namespace TEAMModelOS.SDK.Context.Filter
+{
+    public class HttpGlobalExceptionInvoke
+    {
+        private readonly RequestDelegate _next;
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="next"></param>
+        public HttpGlobalExceptionInvoke(RequestDelegate next)
+        {
+            _next = next;
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        public async Task Invoke(HttpContext context)
+        {
+
+            System.Exception exs = null;
+            bool isCatched = false;
+            try
+            {
+                await _next(context);
+            }
+            catch (System.Exception ex) //发生异常
+            {
+                exs = ex;
+                //自定义业务异常
+                if (ex is BizException)
+                {
+                    context.Response.StatusCode = ((BizException)ex).code;
+                }
+                //未知异常
+                else
+                {
+                    context.Response.StatusCode = 500;
+                    //LogHelper.SetLog(LogLevel.Error, ex);
+                }
+                await HandleExceptionAsync(context, context.Response.StatusCode, ex.Message, ex.StackTrace);
+                isCatched = true;
+            }
+            finally
+            {
+                if (!isCatched && context.Response.StatusCode != 200)//未捕捉过并且状态码不为200
+                {
+                    string msg = "";
+                    switch (context.Response.StatusCode)
+                    {
+                        case 401:
+                            msg = "Unauthorized";
+                            break;
+                        case 404:
+                            msg = "Service Not Found";
+                            break;
+                        case 502:
+                            msg = "Request Erro";
+                            break;
+                        case 500:
+                            msg = exs.Message;
+                            break;
+                        default:
+                            msg = "Unknown Error";
+                            break;
+                    }
+                    await HandleExceptionAsync(context, context.Response.StatusCode, msg, exs == null ? "" : exs.StackTrace);
+                }
+            }
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="context"></param>
+        /// <param name="statusCode"></param>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        private static async Task HandleExceptionAsync(HttpContext context, int statusCode, string msg, string devmsg)
+        {
+            var data = new ErrorResponse<string>(statusCode, msg, devmsg);
+            context.Response.ContentType = Constants.CONTENT_TYPE_JSON;
+            await context.Response.WriteAsync(MessagePackHelper.ObjectToJson(data));
+        }
+        /// <summary>
+        /// 异常信息封装
+        /// </summary>
+        /// 
+        [MessagePackObject(keyAsPropertyName: true)]
+        public class ErrorResponse<T>
+        {
+            public ErrorResponse()
+            {
+                error = new ErrorModel<T>();
+            }
+            public ErrorResponse(string message)
+            {
+                error = new ErrorModel<T>
+                {
+                    message = message,
+                    devmsg = message
+                };
+            }
+            public ErrorResponse(int code, string message)
+            {
+                error = new ErrorModel<T>
+                {
+                    message = message,
+                    devmsg = message,
+                    code = code
+                };
+
+            }
+            public ErrorResponse(int code, string message, string devMessage)
+            {
+                error = new ErrorModel<T>
+                {
+                    message = message,
+                    devmsg = message,
+                    code = code
+                };
+                error.devmsg = devMessage;
+            }
+
+            public string jsonrpc { get; set; } = "2.0";
+            public double id { get; set; } = 1;
+            private object result { get; set; } = null;
+            public ErrorModel<T> error { get; set; } = null;
+        }
+    }
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class ErrorModel<E>
+    {
+        public long responseTime = DateTime.Now.Ticks;
+        public float code { get; set; } = 1;
+        public string message { get; set; }
+        public string devmsg { get; set; }
+        public E data { get; set; }
+    }
+}

+ 20 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcRequest/AzureTokenJsonRPCRequest.cs

@@ -0,0 +1,20 @@
+using TEAMModelOS.SDK.Extension.DataResult.RequestData;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    public class AzureTokenJsonRPCRequest<T> : BaseJosnRPCRequest
+    {
+
+        public AzureTokenJsonRPCRequest (){
+            @params = new AzureTokenRequest<T>();
+        }
+        public AzureTokenRequest<T> @params { get; set; }
+    }
+}

+ 15 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcRequest/BaseJosnRPCRequest.cs

@@ -0,0 +1,15 @@
+using MessagePack;
+using System;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public abstract class BaseJosnRPCRequest
+    {
+        public long requestTime { get; set; } = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        public string jsonrpc { get; set; } = "2.0";
+        public string method { get; set; }
+        public int id { get; set; } = 1;
+        public int timeOffset { get; set; }
+    }
+}

+ 11 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcRequest/JosnRPCRequest.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest
+{
+    public class JosnRPCRequest<T>:BaseJosnRPCRequest
+    {
+        public T @params { get; set; }
+    }
+}

+ 15 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcRequest/PaginationJosnRPCRequest.cs

@@ -0,0 +1,15 @@
+
+
+using TEAMModelOS.SDK.Extension.DataResult.RequestData;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest
+{
+    public  class PaginationJosnRPCRequest<T> : BaseJosnRPCRequest
+    {
+        public PaginationJosnRPCRequest()
+        {
+            @params = new PaginationRequest<T>();
+        }
+        public PaginationRequest<T> @params { get; set; }
+    }
+}

+ 14 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/BaseJosnRPCResponse.cs

@@ -0,0 +1,14 @@
+using MessagePack;
+using Microsoft.VisualBasic;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class BaseJosnRPCResponse 
+    {
+        public string jsonrpc { get; set; } = "2.0";
+        public double id { get; set; } = 1;
+        private object result { get; set; }
+        public object error { get; set; } = null;
+    }
+}

+ 16 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/DataJosnRPCResponse.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class DataJosnRPCResponse<T> : BaseJosnRPCResponse
+    {
+		public DataJosnRPCResponse() { 
+		  result=  new JsonRPCResult<T>();
+		}
+		public   JsonRPCResult<T> result { get; set; } 
+    }
+}

+ 16 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/ErrorJosnRPCResponse.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class ErrorJosnRPCResponse<E> : BaseJosnRPCResponse
+    {
+        public ErrorJosnRPCResponse() {
+            error = new ErrorModel<E>();
+        }
+        public new ErrorModel<E> error { get; set; }
+    }
+}

+ 13 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/ErrorModel.cs

@@ -0,0 +1,13 @@
+using MessagePack;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class ErrorModel<E>
+    {
+        public float code { get; set; }
+        public string message { get; set; }
+        public string devmsg { get; set; }
+        public E data { get; set; }
+    }
+}

+ 13 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/JosnRPCResponse.cs

@@ -0,0 +1,13 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class JosnRPCResponse<T>:BaseJosnRPCResponse
+    {
+        public  T result { get; set; }
+    }
+}

+ 169 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/JsonRPCResponseBuilder.cs

@@ -0,0 +1,169 @@
+using TEAMModelOS.SDK.Extension.DataResult.PageToken;
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public  class JsonRPCResponseBuilder
+    {
+        private string message="Success";
+        private string devmsg = "Error";
+        private int code = 0;
+        private object data;
+        private long total;
+        private int currPage;
+        private int pageSize;
+        private int totalPage;
+        private Dictionary<string, object> extend;
+        private Pagination page;
+        private AzureTableToken token;
+        private object error=null;
+        
+        public JsonRPCResponseBuilder()
+        {
+        }
+        public JsonRPCResponseBuilder Success()
+        {
+            error = null;
+            return this;
+        }
+
+        public JsonRPCResponseBuilder Success(String message)
+        {
+            this.message = message;
+            return this;
+        }
+        public static JsonRPCResponseBuilder custom()
+        {
+            return new JsonRPCResponseBuilder();
+        }
+
+        public JsonRPCResponseBuilder Data(object data)
+        {
+            this.data = data;
+            return this;
+        }
+		public JsonRPCResponseBuilder Error(object error, string message)
+		{
+			this.code = 1;
+			this.message = message;
+			this.error = error;
+			return this;
+		}
+		public JsonRPCResponseBuilder Error(object error, int code,string message)
+		{
+			this.code = code;
+			this.message = message;
+			this.error = error;
+			return this;
+		}
+		public JsonRPCResponseBuilder Error(object error,int code)
+		{
+			this.code = code;
+			this.message = "Error";
+			this.error = error;
+			return this;
+		}
+		public JsonRPCResponseBuilder Error(object error)
+        {
+			this.code = 1;
+			this.message = "Error";
+            this.error = error;
+            return this;
+        }
+        public JsonRPCResponseBuilder Extend(Dictionary<String, object> extend)
+        {
+            this.extend = extend;
+            return this;
+        }
+        public JsonRPCResponseBuilder Token(AzureTableToken token)
+        {
+            this.token = token;
+            return this;
+        }
+        public JsonRPCResponseBuilder Page(Pagination page)
+        {
+            this.pageSize = page.pageSize;
+            this.currPage = page.currPage;
+            this.total = page.total;
+            this.page = page;
+            this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+            return this;
+        }
+        public JsonRPCResponseBuilder totalCount(int totalCount)
+        {
+            this.total = totalCount;
+            return this;
+        }
+
+        public JsonRPCResponseBuilder CurrPage(int currPage)
+        {
+            this.currPage = currPage;
+            return this;
+        }
+
+        public JsonRPCResponseBuilder PageSize(int pageSize)
+        {
+            this.pageSize = pageSize;
+            return this;
+        }
+
+        public JsonRPCResponseBuilder TotalPage(int totalPage)
+        {
+            this.totalPage = totalPage;
+            return this;
+        }
+        public BaseJosnRPCResponse build()
+        {
+            object baseResponse= null;
+
+            if (error != null) {
+                ErrorJosnRPCResponse<object> errorJosnRPCResponse = new ErrorJosnRPCResponse<object>();
+                errorJosnRPCResponse.error.code = code;
+                errorJosnRPCResponse.error.message = message;
+                errorJosnRPCResponse.error.data = error;
+                errorJosnRPCResponse.error.devmsg = devmsg;
+                baseResponse = errorJosnRPCResponse;
+                return (BaseJosnRPCResponse)baseResponse;
+            }
+            if (this.total > 0 && this.pageSize > 0)
+            {
+                this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+            }
+            if (null != this.data && this.token != null)
+            {
+                TokenJosnRPCResponse<object> tokenJosnRPCResponse = new TokenJosnRPCResponse<object>();
+                tokenJosnRPCResponse.result.data = this.data;
+                tokenJosnRPCResponse.result.extend = this.extend;
+                tokenJosnRPCResponse.result.azureToken = this.token;
+                tokenJosnRPCResponse.result.message = message;
+                baseResponse = tokenJosnRPCResponse;
+            }
+            else if (null != this.data && this.total > 0 && this.currPage > 0 && this.pageSize > 0 && this.totalPage > 0)
+            {
+                PageJosnRPCResponse<object> pageDatasResponse = new PageJosnRPCResponse<object>();
+                pageDatasResponse.result.data = this.data;
+                pageDatasResponse.result.page = new Pagination(this.total, this.currPage, this.pageSize, this.totalPage);
+                pageDatasResponse.result.extend = this.extend;
+                pageDatasResponse.result.message = message;
+                baseResponse = pageDatasResponse;
+            }
+            else if (this.data != null)
+            {
+                DataJosnRPCResponse<object> datasResponse = new DataJosnRPCResponse<object>();
+                datasResponse.result.data = this.data;
+                datasResponse.result.extend = this.extend;
+                datasResponse.result.message = message;
+                baseResponse = datasResponse;
+            }
+            else
+            {
+                baseResponse = new BaseJosnRPCResponse();
+            }
+            return (BaseJosnRPCResponse)baseResponse;
+        }
+    }
+}

+ 16 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/JsonRPCResult.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class JsonRPCResult<T>
+    {
+        public Dictionary<string, object> extend { get; set; } = null;
+        public long responseTime { get; set; } = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        public T data { get; set; }
+        public string message { get; set; } = "";
+    }
+}

+ 17 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/PageJosnRPCResponse.cs

@@ -0,0 +1,17 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class PageJosnRPCResponse<T> : BaseJosnRPCResponse
+    {
+		public PageJosnRPCResponse()
+		{
+			result = new PageJsonRPCResult<T>();
+		}
+		public   PageJsonRPCResult<T> result { get; set; }
+    }
+}

+ 15 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/PageJsonRPCResult.cs

@@ -0,0 +1,15 @@
+using TEAMModelOS.SDK.Extension.DataResult.PageToken;
+using MessagePack;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class PageJsonRPCResult<T> : JsonRPCResult<T>
+    {
+        public Pagination page { get; set; }
+
+        public PageJsonRPCResult()
+        {
+        }
+    }
+}

+ 17 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/TokenJosnRPCResponse.cs

@@ -0,0 +1,17 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class TokenJosnRPCResponse<T>: BaseJosnRPCResponse
+    {
+		public TokenJosnRPCResponse()
+		{
+			result = new TokenJsonRPCResult<T>();
+		}
+		public  TokenJsonRPCResult<T> result { get; set; }
+    }
+}

+ 16 - 0
TEAMModelOS.SDK/Extension/DataResult/JsonRpcResponse/TokenJsonRPCResult.cs

@@ -0,0 +1,16 @@
+using TEAMModelOS.SDK.Extension.DataResult.PageToken;
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class TokenJsonRPCResult<T> : JsonRPCResult<T>
+    {
+       
+        public AzureTableToken azureToken { get; set; }
+        public TokenJsonRPCResult() { }
+    }
+}

+ 13 - 0
TEAMModelOS.SDK/Extension/DataResult/PageToken/AzurePagination.cs

@@ -0,0 +1,13 @@
+using MessagePack;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.PageToken
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class AzurePagination<T>
+    {
+        public AzurePagination(){}
+        public List<T> data { get; set; }
+        public AzureTableToken token { get; set; }
+    }
+}

+ 17 - 0
TEAMModelOS.SDK/Extension/DataResult/PageToken/AzureTableToken.cs

@@ -0,0 +1,17 @@
+using MessagePack;
+using System.ComponentModel.DataAnnotations;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.PageToken
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class AzureTableToken
+    {
+        //[Required]
+        public string NextPartitionKey { get; set; }
+        //[Required]
+        public string NextRowKey { get; set; }
+        public string NextTableName { get; set; }
+        //[Required]
+        public int? TargetLocation { get; set; }
+    }
+}

+ 31 - 0
TEAMModelOS.SDK/Extension/DataResult/PageToken/Pagination.cs

@@ -0,0 +1,31 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.PageToken
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class Pagination
+    {
+        public long total { get; set; }
+        public int currPage { get; set; }
+        public int pageSize { get; set; } 
+        public int totalPage { get; set; }
+      
+        public Pagination() { }
+        public Pagination(long total, int currPage, int pageSize)
+        {
+            this.total = total;
+            this.currPage = currPage;
+            this.pageSize = pageSize;
+            this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+        }
+        public Pagination(long total, int currPage, int pageSize, int totalPage)
+        {
+            this.total = total;
+            this.currPage = currPage;
+            this.pageSize = pageSize;
+            this.totalPage = totalPage;
+        }
+    }
+}

+ 12 - 0
TEAMModelOS.SDK/Extension/DataResult/PageToken/PaginationData.cs

@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.PageToken
+{
+    public class PaginationData<T>:Pagination
+    {
+        public PaginationData(int currPage, int pageSize, int total) : base(currPage, pageSize, total)
+        {
+        }
+        public List<T> data { get; set; }
+    }
+}

+ 13 - 0
TEAMModelOS.SDK/Extension/DataResult/RequestData/AzureTokenRequest.cs

@@ -0,0 +1,13 @@
+using TEAMModelOS.SDK.Extension.DataResult.PageToken;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.RequestData
+{
+   public class AzureTokenRequest<T> :BaseRequest
+   {
+        public T data { get; set; }
+        public AzureTableToken azureToken { get; set; }
+   }
+}

+ 12 - 0
TEAMModelOS.SDK/Extension/DataResult/RequestData/BaseRequest.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.RequestData
+{
+    public class BaseRequest
+    {
+        public long requestTime { get; set; } = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        public string method { get; set; }
+        public string repeatToken { get; set; }
+    }
+}

+ 10 - 0
TEAMModelOS.SDK/Extension/DataResult/RequestData/PaginationRequest.cs

@@ -0,0 +1,10 @@
+using TEAMModelOS.SDK.Extension.DataResult.PageToken;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.RequestData
+{
+    public class PaginationRequest<T> : BaseRequest
+    {
+        public T data { get; set; }
+        public Pagination  page{ get; set; }
+    }
+}

+ 16 - 0
TEAMModelOS.SDK/Extension/DataResult/ResponseData/BaseResponse.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class BaseResponse : TimeStampResponse
+    {
+        public Dictionary<string, object> extend { get; set; }
+        public string message { get; set; } = "success";
+        public int code { get; set; }
+        public BaseResponse()
+        {
+        }
+    }
+}

+ 14 - 0
TEAMModelOS.SDK/Extension/DataResult/ResponseData/DataResponse.cs

@@ -0,0 +1,14 @@
+using MessagePack;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class DataResponse<T> : BaseResponse
+    {
+        public T data { get; set; }
+
+        public DataResponse()
+        {
+        }
+    }
+}

+ 15 - 0
TEAMModelOS.SDK/Extension/DataResult/ResponseData/PageDatasResponse.cs

@@ -0,0 +1,15 @@
+using TEAMModelOS.SDK.Extension.DataResult.PageToken;
+using MessagePack;
+
+namespace TEAMModelOS.SDK.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class PageDatasResponse<T> : DataResponse<T>
+    {
+        public Pagination page { get; set; }
+
+        public PageDatasResponse()
+        {
+        }
+    }
+}

+ 162 - 0
TEAMModelOS.SDK/Extension/DataResult/ResponseData/ResponseBuilder.cs

@@ -0,0 +1,162 @@
+using TEAMModelOS.SDK.Extension.DataResult.PageToken;
+using MessagePack;
+using System;
+using System.Collections.Generic;
+
+
+namespace TEAMModelOS.SDK.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class ResponseBuilder
+    {
+        private string message = "success";
+        private object data;
+        private int code = 0;
+       // private IList<object> datas;
+        private long total;
+        private int currPage;
+        private int pageSize;
+        private int totalPage;
+        private Dictionary<string, object> extend;
+        private Pagination page;
+        private AzureTableToken  token;
+        public ResponseBuilder()
+        {
+        }
+
+        public static ResponseBuilder custom()
+        {
+            return new ResponseBuilder();
+        }
+
+        public BaseResponse build()
+        {
+            if (this.total > 0 && this.pageSize > 0 )
+            {
+                this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+            }
+            object baseResponse;
+           
+             if (null != this.data && this.token!=null)
+            {
+                TokenPageDatasResponse<object> pageDatasResponse = new TokenPageDatasResponse<object>();
+                pageDatasResponse.code= this.code;
+                pageDatasResponse.data= this.data;
+                pageDatasResponse.message= this.message;
+                pageDatasResponse.extend=this.extend;
+                pageDatasResponse.azureToken = this.token;
+                baseResponse = pageDatasResponse;
+            }
+            else if (null != this.data && this.total > 0 && this.currPage > 0 && this.pageSize > 0 && this.totalPage > 0)
+            {
+                PageDatasResponse<object> pageDatasResponse = new PageDatasResponse<object>();
+                pageDatasResponse.code = this.code;
+                pageDatasResponse.data = this.data;
+                pageDatasResponse.message = this.message;
+                pageDatasResponse.page = new Pagination(this.total, this.currPage, this.pageSize, this.totalPage);
+                pageDatasResponse.extend = this.extend;
+                baseResponse = pageDatasResponse;
+            }
+            else if (this.data != null)
+            {
+                DataResponse<object> datasResponse = new DataResponse<object>();
+                datasResponse.code=this.code;
+                datasResponse.data=this.data;
+                datasResponse.message=this.message;
+                datasResponse.extend=this.extend;
+                baseResponse = datasResponse;
+            }
+            else
+            {
+                baseResponse = new BaseResponse();
+                ((BaseResponse)baseResponse).message=this.message;
+                ((BaseResponse)baseResponse).code=this.code;
+                ((BaseResponse)baseResponse).extend=this.extend;
+            }
+            return (BaseResponse)baseResponse;
+        }
+
+        
+
+        public ResponseBuilder Extend(Dictionary<String, object> extend)
+        {
+            this.extend = extend;
+            return this;
+        }
+        public ResponseBuilder Token(AzureTableToken token)
+        {
+            this.token = token;
+            return this;
+        }
+        public ResponseBuilder Data(object data)
+        {
+            this.data = data;
+            return this;
+        }
+       
+        public ResponseBuilder Page(Pagination page)
+        {
+            this.pageSize = page.pageSize;
+            this.currPage = page.currPage;
+            this.total = page.total;
+            this.page = page;
+            this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+            return this;
+        }
+        public ResponseBuilder totalCount(int totalCount)
+        {
+            this.total = totalCount;
+            return this;
+        }
+
+        public ResponseBuilder CurrPage(int currPage)
+        {
+            this.currPage = currPage;
+            return this;
+        }
+
+        public ResponseBuilder PageSize(int pageSize)
+        {
+            this.pageSize = pageSize;
+            return this;
+        }
+
+        public ResponseBuilder TotalPage(int totalPage)
+        {
+            this.totalPage = totalPage;
+            return this;
+        }
+
+        public ResponseBuilder success()
+        {
+            return this;
+        }
+
+        public ResponseBuilder success(String message)
+        {
+            this.message = message;
+            return this;
+        }
+
+        public ResponseBuilder success(String message, int code)
+        {
+            this.message = message;
+            this.code = code;
+            return this;
+        }
+
+        public ResponseBuilder failed(String message, int code)
+        {
+            this.code = code;
+            this.message = message;
+            return this;
+        }
+
+        public ResponseBuilder failed(String message)
+        {
+            this.code = 1;
+            this.message = message;
+            return this;
+        }
+    }
+}

+ 16 - 0
TEAMModelOS.SDK/Extension/DataResult/ResponseData/TimeStampResponse.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System;
+
+
+namespace TEAMModelOS.SDK.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class TimeStampResponse
+    {
+        public long responseTime { get; set; } = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        public TimeStampResponse()
+        {
+
+        }
+    }
+}

+ 14 - 0
TEAMModelOS.SDK/Extension/DataResult/ResponseData/TokenPageDatasResponse.cs

@@ -0,0 +1,14 @@
+using TEAMModelOS.SDK.Extension.DataResult.PageToken;
+using MessagePack;
+
+
+namespace TEAMModelOS.SDK.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class TokenPageDatasResponse<T> : DataResponse<T>
+    {
+        public AzureTableToken azureToken { get; set; }
+
+        public TokenPageDatasResponse() { }
+    }
+}

+ 53 - 0
TEAMModelOS.SDK/Extension/JwtAuth/Filters/JwtAuthorizationFilter.cs

@@ -0,0 +1,53 @@
+using TEAMModelOS.SDK.Extension.JwtAuth.Models;
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.SDK.Extension.JwtAuth.Filters
+{
+    public class JwtAuthorizationFilter
+    {
+        private readonly RequestDelegate _next;
+        public JwtAuthorizationFilter(RequestDelegate next)
+        {
+            _next = next;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="httpContext"></param>
+        /// <returns></returns>
+        public Task Invoke(HttpContext httpContext)
+        {
+            //检测是否包含'Authorization'请求头,如果不包含则直接放行
+            if (!httpContext.Request.Headers.ContainsKey(HttpConstant.Authorization) &&!httpContext.Request.Query.ContainsKey(HttpConstant.access_token))
+            {
+                return _next(httpContext);
+            }
+            var tokenHeader = "";
+            if (httpContext.Request.Query.ContainsKey(HttpConstant.access_token))
+            {
+                tokenHeader = httpContext.Request.Query[HttpConstant.access_token];
+                tokenHeader = tokenHeader.ToString().Trim();
+            }
+            if (httpContext.Request.Headers.ContainsKey(HttpConstant.Authorization)) {
+                tokenHeader = httpContext.Request.Headers[HttpConstant.Authorization];
+                tokenHeader = tokenHeader.ToString().Substring("Bearer ".Length).Trim();
+            }
+
+            ClaimModel claimModel = JwtHelper.JwtHelper.SerializeJWT(tokenHeader);
+
+            //将tokenModel存入缓存中
+            //授权
+            //已经弃用该方式获取User信息,采用官方认证,必须在上边ConfigureService 中,配置JWT的认证服务 (.AddAuthentication 和 .AddJwtBearer 二者缺一不可)
+            //var identity = new ClaimsIdentity(claimModel.Claims);
+            //var principal = new ClaimsPrincipal(identity);
+            //httpContext.User = principal;
+            return _next(httpContext);
+        }
+    }
+}

+ 83 - 0
TEAMModelOS.SDK/Extension/JwtAuth/JwtAuthExtension.cs

@@ -0,0 +1,83 @@
+using TEAMModelOS.SDK.Extension.JwtAuth.Models;
+using IdentityModel;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.IdentityModel.Tokens;
+using System;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.SDK.Extension.JwtAuth
+{
+    public static class JwtAuthExtension
+    {
+        public static void JwtAuth(this IServiceCollection services , IConfigurationSection configuration)
+        {
+            services.Configure<JwtSetting>(configuration);
+            var creds = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["SecurityKey"]));
+            // 令牌验证参数
+            var tokenValidationParameters = new TokenValidationParameters
+            {
+                NameClaimType = JwtClaimTypes.Name,
+                RoleClaimType = JwtClaimTypes.Role,
+                ValidateIssuerSigningKey = true,
+                IssuerSigningKey = creds,
+                ValidateIssuer = true,
+                ValidIssuer = configuration["Issuer"],//发行人
+                ValidateAudience = true,
+                ValidAudience = configuration["Audience"],//订阅人
+                                                           // 是否验证Token有效期,使用当前时间与Token的Claims中的NotBefore和Expires对比
+                ValidateLifetime = true,
+                //允许的服务器时间偏移量
+                ClockSkew = TimeSpan.Zero,
+                //是否要求Token的Claims中必须包含Expires
+                RequireExpirationTime = true,
+            };
+            services.AddAuthentication(x => {
+                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
+                x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
+            }).AddJwtBearer(o =>
+            {
+                o.TokenValidationParameters = tokenValidationParameters;
+                o.Events = new JwtBearerEvents
+                {
+                    OnAuthenticationFailed = context =>
+                    {
+                        // 如果过期,则把<是否过期>添加到,返回头信息中
+                        if (context.Exception.GetType() == typeof(SecurityTokenExpiredException))
+                        {
+                            context.Response.Headers.Add("Token-Expired", "true");
+                        }
+                        return Task.CompletedTask;
+                    },
+                    //Url中添加access_token=[token],直接在浏览器中访问
+                    OnMessageReceived = context => {
+                        context.Token = context.Request.Query["access_token"];
+                        return Task.CompletedTask;
+                    },
+                    //URL未授权调用
+                    OnChallenge = context => {
+                        return Task.CompletedTask;
+                    },
+                    //在Token验证通过后调用
+                    OnTokenValidated = context => {
+                        //编写业务
+                        return Task.CompletedTask;
+                    },
+
+                };
+            });
+            //自定义授权
+            services.AddAuthorization(auth =>
+            {
+                auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
+                    .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
+                    .RequireAuthenticatedUser()
+                    .Build());
+            });
+        }
+        
+    }
+}

+ 74 - 0
TEAMModelOS.SDK/Extension/JwtAuth/JwtHelper/JwtHelper.cs

@@ -0,0 +1,74 @@
+using TEAMModelOS.SDK.Extension.JwtAuth.Models;
+using IdentityModel;
+using Microsoft.IdentityModel.Tokens;
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using TEAMModelOS.SDK.Helper.Common.DateTimeHelper;
+
+namespace TEAMModelOS.SDK.Extension.JwtAuth.JwtHelper
+{
+    public class JwtHelper
+    {
+        /// <summary>
+        /// 颁发JWT Token
+        /// </summary>
+        /// <param name="claimModel"></param>
+        /// <param name="tokenModel"></param>
+        /// <returns></returns>
+        public static JwtResponse IssueJWT(ClaimModel claimModel, JwtSetting setting)
+        {
+           // JwtClient jwtClient = null;
+
+            JwtClient jwtClient= setting.JwtClient.Where(x => x.Name.Equals(claimModel.Scope)).First();
+            //foreach (JwtClient client in setting.JwtClient) {
+            //    if (claimModel.Scope.Equals(client.Name)) {
+            //        jwtClient = client;
+            //        break; 
+            //    }
+            //}
+            List<Claim> claims = new List<Claim>();
+            var dateTime = DateTimeHelper.ConvertToTimeStamp10(DateTime.Now);
+            claims.AddRange(claimModel.Claims);
+            claims.Add(new Claim(JwtClaimTypes.IssuedAt, dateTime + "", ClaimValueTypes.Integer64));
+            claims.Add(new Claim(JwtClaimTypes.NotBefore, dateTime + "", ClaimValueTypes.Integer64));
+            claims.Add(new Claim(JwtClaimTypes.Expiration, dateTime + jwtClient.Exp + "", ClaimValueTypes.Integer64));
+            claims.Add(new Claim(JwtClaimTypes.Audience, setting.Audience));
+            claims.Add(new Claim(JwtClaimTypes.Issuer, setting.Issuer));
+            claims.Add(new Claim(JwtClaimTypes.Scope, claimModel.Scope));
+            claims.AddRange(claimModel.Roles.ToArray().Select(s=>new Claim(JwtClaimTypes.Role,s)));
+            var creds = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(setting.SecurityKey)), SecurityAlgorithms.HmacSha512);
+            var jwt = new JwtSecurityToken(
+                claims:claims,
+                signingCredentials:creds
+                );
+            var jwtHandler = new JwtSecurityTokenHandler();
+              jwtHandler.WriteToken(jwt);
+
+
+            return new JwtResponse {
+                access_token = jwtHandler.WriteToken(jwt),
+                scope = claimModel.Scope
+            };
+        }
+        /// <summary>
+        /// 解析jwt
+        /// </summary>
+        /// <param name="jwtStr"></param>
+        /// <returns></returns>
+        public static ClaimModel SerializeJWT(string jwtStr)
+        {
+            var jwtHandler = new JwtSecurityTokenHandler();
+            JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(jwtStr);
+            ClaimModel claimModel = new ClaimModel();
+            object role = new object();
+            claimModel.Claims = jwtToken.Claims.ToList();
+            jwtToken.Payload.TryGetValue("role", out role);
+            if(role!=null)claimModel.Roles=role.ToString().Split(",").ToList();
+            return claimModel;
+        }
+    }
+}

+ 27 - 0
TEAMModelOS.SDK/Extension/JwtAuth/Models/ClaimModel.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Security.Claims;
+
+namespace TEAMModelOS.SDK.Extension.JwtAuth.Models
+{
+    public class ClaimModel
+    {
+        public ClaimModel() {
+            Claims = new List<Claim>();
+            Roles = new List<string>();
+        }
+
+        /// <summary>
+        /// 用户身份信息
+        /// </summary>
+        public List<Claim> Claims { get; set; }
+        /// <summary>
+        /// 用户角色信息
+        /// </summary>
+        public List<string> Roles { get; set; }
+        /// <summary>
+        /// 令牌类型
+        /// </summary>
+        public string Scope { get; set; }
+    }
+}

+ 12 - 0
TEAMModelOS.SDK/Extension/JwtAuth/Models/HttpConstant.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.JwtAuth.Models
+{
+    public class HttpConstant
+    {
+        public static readonly string Authorization = "Authorization";
+        public static readonly string access_token = "access_token";
+    }
+}

+ 12 - 0
TEAMModelOS.SDK/Extension/JwtAuth/Models/JwtClient.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.JwtAuth.Models
+{
+    public class JwtClient
+    {
+        public string Name { get; set; }
+        public double Exp { get; set; }
+    }
+}

+ 13 - 0
TEAMModelOS.SDK/Extension/JwtAuth/Models/JwtResponse.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.JwtAuth.Models
+{
+    public class JwtResponse
+    {
+        public string access_token { get; set; }
+        public string token_type { get; set; } = "Bearer";
+        public string scope { get; set; }
+    }
+}

+ 30 - 0
TEAMModelOS.SDK/Extension/JwtAuth/Models/JwtSetting.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.JwtAuth.Models
+{
+    public class JwtSetting
+    {
+        /// <summary>
+        /// 项目名称
+        /// </summary>
+       // public string Project { get; set; }
+        /// <summary>
+        /// JwtClient
+        /// </summary>
+        public List<JwtClient> JwtClient { get; set; }
+        /// <summary>
+        /// WT的接收对象
+        /// </summary>
+        public string Audience { get; set; }
+        /// <summary>
+        /// JWT的签发主体
+        /// </summary>
+        public string Issuer { get; set; }
+        /// <summary>
+        /// JWT Secret Key
+        /// </summary>
+        public string SecurityKey { get; set; }
+    }
+}

+ 38 - 0
TEAMModelOS.SDK/Extension/Language/Implements/LanguageService.cs

@@ -0,0 +1,38 @@
+using TEAMModelOS.SDK.Extension.Language.Interfaces;
+using TEAMModelOS.SDK.Extension.Language.Model;
+using Microsoft.Extensions.Options;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.SDK.Extension.Language.Implements
+{
+    public class LanguageService : ILanguageService
+    {
+        private Dictionary<string, SmsCountryCode> smsMap { get; set; }
+        public List<SmsCountryCode> countryCodes;
+
+        public LanguageService(IOptions<List<SmsCountryCode>> _option)
+        {
+            countryCodes = _option.Value;
+           
+        }
+        private LanguageService SmsLanguage()
+        {
+            foreach (SmsCountryCode sms in countryCodes) {
+                if (this.smsMap == null)
+                {
+                    smsMap = new Dictionary<string, SmsCountryCode>();
+                }
+                if (!smsMap.ContainsKey(sms.CountryCode))
+                {
+                    smsMap.Add(sms.CountryCode, sms);
+                }
+            }
+            return this;
+        }
+        public Dictionary<string, SmsCountryCode> GetSmsLanguage()
+        {
+            SmsLanguage();
+            return smsMap;
+        }
+    }
+}

+ 12 - 0
TEAMModelOS.SDK/Extension/Language/Interfaces/ILanguageService.cs

@@ -0,0 +1,12 @@
+using TEAMModelOS.SDK.Extension.Language.Model;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.Language.Interfaces
+{
+    public interface ILanguageService
+    {
+        Dictionary<string, SmsCountryCode> GetSmsLanguage();
+    }
+}

+ 18 - 0
TEAMModelOS.SDK/Extension/Language/LanguageExtension.cs

@@ -0,0 +1,18 @@
+using TEAMModelOS.SDK.Extension.Language.Implements;
+using TEAMModelOS.SDK.Extension.Language.Interfaces;
+using TEAMModelOS.SDK.Extension.Language.Model;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.SDK.Extension.Language
+{
+    public static class RedisExtension
+    {
+        public static void AddLanguage(this IServiceCollection services, IConfigurationSection LangConfiguration)
+        {
+            services.Configure<List<SmsCountryCode>>(LangConfiguration);
+            services.AddSingleton<ILanguageService, LanguageService>();
+        }
+    }
+}

+ 10 - 0
TEAMModelOS.SDK/Extension/Language/Model/SmsCountryCode.cs

@@ -0,0 +1,10 @@
+namespace TEAMModelOS.SDK.Extension.Language.Model
+{
+    public  class SmsCountryCode
+    {
+        public string Name { get; set; }
+        public string CountryCode { get; set; }
+        public string Language { get; set; }
+        public string SmsLang { get; set; }
+    }
+}

+ 152 - 0
TEAMModelOS.SDK/Extension/MessagePush/Implements/SendCloudService.cs

@@ -0,0 +1,152 @@
+
+using TEAMModelOS.SDK.Extension.MessagePush.Interfaces;
+using TEAMModelOS.SDK.Extension.MessagePush.Model;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.Extension.Language.Interfaces;
+using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
+using Microsoft.Extensions.Options;
+using TEAMModelOS.SDK.Extension.Language.Model;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
+using TEAMModelOS.SDK.Helper.Security.Md5Hash;
+using TEAMModelOS.SDK.Helper.Network.HttpHelper;
+
+namespace TEAMModelOS.SDK.Extension.MessagePush.Implements
+{
+    public class SendCloudService : ISendCloudService
+    {
+        public SmsSendCloud smsSendCloud;
+        public ILanguageService _languageService;
+        public IAzureTableDBRepository _azureTableDBRepository;
+        public SendCloudService(IOptions<SmsSendCloud> _option, ILanguageService languageService , IAzureTableDBRepository azureTableDBRepository )
+        {
+            _azureTableDBRepository = azureTableDBRepository;
+            _languageService = languageService;
+            smsSendCloud = _option.Value;
+        }
+
+
+        public List<Dictionary<string, string>> Languages { get; set; } = new List<Dictionary<string, string>>
+        {
+            new Dictionary<string, string> { { "name", "简体中文" }, { "code","CHS"  } },
+            new Dictionary<string, string> { { "name", "繁体中文" }, { "code","CHT" } },
+            new Dictionary<string, string> { { "name", "英语" }, { "code","EN"  } } };
+        public List<Dictionary<string, string>> BizCodes { get; set; } = new List<Dictionary<string, string>>
+        {
+            //new Dictionary<string, string> { { "name", "验证码业务" }, { "code", "Captcha" } },
+            new Dictionary<string, string> { { "name", "报名通知业务" }, { "code", "SignUp" } }
+        };
+        public async Task<List<SmsConfig>> SaveOrUpdateSmsConfig(List<SmsConfig> configs) {
+            return await _azureTableDBRepository.SaveOrUpdateAll<SmsConfig>(configs); 
+        }
+        public async Task<List<SmsConfig>> InitSmsConfig(string BizNum)
+        {
+            List<SmsConfig> smsConfigs = new List<SmsConfig>() ;
+            List<SmsConfig> SaveSmsConfigs = new List<SmsConfig>();
+            foreach (Dictionary<string, string> BizCode in BizCodes) {
+                foreach (Dictionary<string, string> Language in Languages) {
+                    Dictionary<string, object> dict = new Dictionary<string, object>
+                    {
+                        { "BizNum", BizNum },{ "BizCode", BizCode["code"] }, { "Language", Language["code"] } ,
+                    };
+                    SmsConfig smsConfig = await _azureTableDBRepository.FindOneByDict<SmsConfig>(dict);
+
+                    if (smsConfig != null && smsConfig.RowKey != null)
+                    {
+                        smsConfigs.Add(smsConfig);
+                    }
+                    else {
+                        DateTimeOffset now = DateTimeOffset.Now;
+                        SmsConfig SaveSmsConfig = new SmsConfig {
+                            RowKey = BizNum + "-" + BizCode["code"] + "-" + Language["code"],
+                            PartitionKey = BizNum,
+                            Language = Language["code"],
+                            LanguageName = Language["name"],
+                            BizCode = BizCode["code"],
+                            BizName = BizCode["name"],
+                            BizNum = BizNum,
+                            Template = null,
+                            Timestamp= now
+                        };
+                        SaveSmsConfigs.Add(SaveSmsConfig);
+                        smsConfigs.Add(SaveSmsConfig);
+                    }
+                }
+            }
+            if (SaveSmsConfigs.Count > 0) {
+               await _azureTableDBRepository.SaveOrUpdateAll<SmsConfig>(SaveSmsConfigs);
+            }
+            return smsConfigs; 
+        }
+        /// <summary>
+        /// https://sendcloud.kf5.com/posts/view/1074678/
+        /// </summary>
+        /// <param name="BizCode"></param>
+        /// <param name="CountryCode"></param>
+        /// <param name="phone"></param>
+        /// <param name="vars"></param>
+        /// <returns></returns>
+        public async Task<SendCloudResponse> SendSmsByBizCode(string  BizNum  , string BizCode, int CountryCode, string phone, Dictionary<string, string> vars = null)
+        {
+            SmsCountryCode code = null;
+            bool flag = _languageService.GetSmsLanguage().TryGetValue(CountryCode + "", out code);
+            string SmsLang = "EN";
+            int templateId = 0;
+            if (flag)
+            {
+                SmsLang = code.SmsLang;
+            }
+            Dictionary<string, object> dict = new Dictionary<string, object>
+            {
+                { "BizNum", BizNum },{ "BizCode", BizCode }, { "Language", SmsLang } ,
+            };
+            SmsConfig smsConfig   =  await _azureTableDBRepository.FindOneByDict<SmsConfig>(dict);
+
+            if (smsConfig != null && smsConfig.RowKey != null )
+            {
+                //默认调用英文,不管是否包含,发送时会去处理相关信息
+                int.TryParse(smsConfig.Template ,out templateId);
+            }
+            //else {
+            //    throw new BizException("");
+            //   //  templateId = smsSendCloud.SmsCode[code.SmsLang];
+            //}
+            int msgType = 0;
+            if (CountryCode != 86)
+            {
+                msgType = 2;
+                return await SendSms(templateId, "00" + CountryCode + phone, vars, msgType);
+            }
+            else
+            {
+                return await SendSms(templateId, phone, vars, msgType);
+            }
+            
+        }
+        public async Task<SendCloudResponse> SendSms(int templateId, string phone, Dictionary<string, string> vars = null, int msgType = 0)
+        {
+            List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>
+            {
+                new KeyValuePair<string, string>("msgType", msgType+""),//0表示短信, 1表示彩信,2表示国际短信, 默认值为0
+                new KeyValuePair<string, string>("phone", phone),
+                new KeyValuePair<string, string>("smsUser", smsSendCloud.SmsUser),
+                new KeyValuePair<string, string>("templateId", templateId+""),
+            };
+            if (vars != null)
+            {
+                paramList.Add(new KeyValuePair<string, string>("vars", MessagePackHelper.ObjectToJson(vars)));
+            }
+            var param_str = "";
+            foreach (var param in paramList)
+            {
+                param_str += param.Key.ToString() + "=" + param.Value.ToString() + "&";
+            }
+            string sign_str = smsSendCloud.SmsKey + "&" + param_str + smsSendCloud.SmsKey;
+            string sign = Md5Hash.Encrypt(sign_str);
+            paramList.Add(new KeyValuePair<string, string>("signature", sign));
+            string result = await HttpHelper.HttpPostAsync(smsSendCloud.SmsUrl, paramList);
+            return MessagePackHelper.JsonToObject<SendCloudResponse>(result);
+        }
+    }
+}

+ 42 - 0
TEAMModelOS.SDK/Extension/MessagePush/Interfaces/ISendCloudService.cs

@@ -0,0 +1,42 @@
+using TEAMModelOS.SDK.Extension.MessagePush.Model;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.SDK.Extension.MessagePush.Interfaces
+{
+    public interface ISendCloudService
+    {
+        /// <summary>
+        /// 发送普通文字短信
+        /// </summary>
+        /// <param name="templateId">模板ID</param>
+        /// <param name="msgType">消息类型0表示短信, 1表示彩信,2表示国际短信, 默认值为0 </param>
+        /// <param name="phone">信人手机号,多个手机号用逗号,分隔,每次调用最大支持2000,更多地址建议使用联系人列表功能</param>
+        /// <param name="vars">替换变量的json串 ,含有特殊字符 请 urlencode ,{"name": "lucy"} or {"%money%": "100"}</param>
+        /// <returns></returns>
+         Task<SendCloudResponse> SendSms(int templateId, string phone, Dictionary<string, string> vars =null , int msgType = 0);
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="BizCode">业务Code</param>
+        /// <param name="CountryCode">国家或地区编码</param>
+        /// <param name="phone">手机号</param>
+        /// <param name="vars">替换变量的json串 ,含有特殊字符 请 urlencode ,{"name": "lucy"} or {"%money%": "100"}</param>
+        /// <returns></returns>
+        Task<SendCloudResponse> SendSmsByBizCode(string BizNum  , string BizCode, int CountryCode, string phone, Dictionary<string, string> vars = null);
+        /// <summary>
+        /// 根据业务流水号初始化短信配置
+        /// </summary>
+        /// <param name="BizNum"></param>
+        /// <returns></returns>
+        Task<List<SmsConfig>> InitSmsConfig(string BizNum);
+        /// <summary>
+        /// 更新或保存
+        /// </summary>
+        /// <param name="configs"></param>
+        /// <returns></returns>
+        Task<List<SmsConfig>> SaveOrUpdateSmsConfig(List<SmsConfig> configs);
+    }
+}

+ 20 - 0
TEAMModelOS.SDK/Extension/MessagePush/MessagePushExtension.cs

@@ -0,0 +1,20 @@
+using TEAMModelOS.SDK.Extension.MessagePush.Implements;
+using TEAMModelOS.SDK.Extension.MessagePush.Interfaces;
+using TEAMModelOS.SDK.Extension.MessagePush.Model;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.MessagePush
+{
+    public static class MessagePushExtension
+    {
+        public static void SendCloud(this IServiceCollection services, IConfigurationSection configuration)
+        {
+            services.Configure<SmsSendCloud>(configuration);
+            services.AddSingleton<ISendCloudService, SendCloudService>();
+        }
+    }
+}

+ 30 - 0
TEAMModelOS.SDK/Extension/MessagePush/Model/SendCloudResponse.cs

@@ -0,0 +1,30 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Extension.MessagePush.Model
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public  class SendCloudResponse
+    {
+        public string message { get; set; }
+        public Info info { get; set; }
+        public bool result { get; set; }
+        public int  statusCode { get; set; }
+    }
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class Info
+    {
+        public int successCount { get; set; }
+        public string[] smsIds { get; set; }
+        public int failedCount { get; set; }
+        public Item[] items { get; set; }
+    }
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class Item
+    {
+        public string phone { get; set; }
+        public string message { get; set; }
+    }
+}

+ 36 - 0
TEAMModelOS.SDK/Extension/MessagePush/Model/SmsConfig.cs

@@ -0,0 +1,36 @@
+
+using Microsoft.WindowsAzure.Storage.Table;
+
+namespace TEAMModelOS.SDK.Extension.MessagePush.Model
+{
+    /// <summary>
+    /// 短信配置
+    /// </summary>
+    public class SmsConfig : TableEntity
+    {
+        /// <summary>
+        /// 语言
+        /// </summary>
+        public string Language { get; set; }
+        /// <summary>
+        /// 语言名称
+        /// </summary>
+        public string LanguageName { get; set; }
+        /// <summary>
+        /// 业务code
+        /// </summary>
+        public string BizCode { get; set; }
+        /// <summary>
+        /// 业务名称
+        /// </summary>
+        public string BizName { get; set; }
+        /// <summary>
+        /// 模板ID
+        /// </summary>
+        public string Template { get; set; }
+        /// <summary>
+        /// 业务流水号
+        /// </summary>
+        public string BizNum { get; set; }
+    }
+}

+ 12 - 0
TEAMModelOS.SDK/Extension/MessagePush/Model/SmsSendCloud.cs

@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+namespace TEAMModelOS.SDK.Extension.MessagePush.Model
+{
+    public class SmsSendCloud
+    {
+        public string SmsUrl { get; set; }
+        public string SmsUser { get; set; }
+        public string SmsKey { get; set; }
+       
+    }
+}

+ 94 - 0
TEAMModelOS.SDK/Helper/Common/DateTimeHelper/DateTimeHelper.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Common.DateTimeHelper
+{
+    public static class DateTimeHelper
+    {
+        /// <summary>
+        /// 时间戳转换为日期(时间戳单位秒)
+        /// </summary>
+        /// <param name="TimeStamp"></param>
+        /// <returns></returns>
+        public static DateTime ConvertToDateTime(long timeStamp)
+        {
+            var dtStart = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1));
+            TimeSpan toNow = new TimeSpan(timeStamp);
+            return dtStart.Add(toNow);
+            //var start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            //return start.AddMilliseconds(timeStamp).AddHours(8);
+        }
+        /// <summary>
+        /// 日期转换为时间戳(时间戳单位秒)
+        /// </summary>
+        /// <param name="TimeStamp"></param>
+        /// <returns></returns>
+        public static long ConvertToTimeStamp13(DateTime time)
+        {
+            DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            return (long)(time.AddHours(-8) - Jan1st1970).TotalMilliseconds;
+        }
+        /// <summary>
+        /// 日期转换为时间戳(时间戳单位秒)
+        /// </summary>
+        /// <param name="TimeStamp"></param>
+        /// <returns></returns>
+        public static long ConvertToTimeStamp10(DateTime time)
+        {
+            DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            return (long)(time.AddHours(-8) - Jan1st1970).TotalMilliseconds / 1000;
+        }
+
+        public static DateTime FromUnixTimestamp(this long unixtime)
+        {
+            DateTime sTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Utc, TimeZoneInfo.Local);
+            return sTime.AddMilliseconds(unixtime);
+        }
+
+        public static DateTime FromUnixTimestampOffSet(this long unixtime, int offset)
+        {
+            DateTime sTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Utc, TimeZoneInfo.Local);
+            int serverOffset = (int)TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).TotalMinutes;
+            int subOffset = offset - serverOffset;
+            return sTime.AddMilliseconds(unixtime).AddMinutes(subOffset);
+        }
+        public static long ToUnixTimestamp(this DateTime datetime)
+        {
+            //DateTime sTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            DateTime sTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Utc, TimeZoneInfo.Local);
+            return (long)(datetime - sTime).TotalMilliseconds;
+        }
+        /// <summary>
+        /// 获取当前cpu振荡时间戳 17位数
+        /// </summary>
+        /// <returns></returns>
+        public static long GetCPUMillisecond()
+        {
+            return DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        }
+        /// <summary>
+        /// 获取标准毫秒级时间戳 13位数
+        /// </summary>
+        /// <returns></returns>
+        public static long GetMillisecond()
+        {
+            return (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
+        }
+
+
+        /// <summary>
+        /// 获得 GMT+8 时间
+        /// </summary>
+        /// <returns></returns>
+        public static DateTime ChinaTime()
+        {
+
+            TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");//设置时区
+            DateTime easternTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, easternZone);
+
+            return easternTime;
+        }
+
+    }
+}

+ 755 - 0
TEAMModelOS.SDK/Helper/Common/FileHelper/FileHelper.cs

@@ -0,0 +1,755 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Net;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Common.FileHelper
+{
+    public class FileHelper
+    {
+        #region 获取文件到集合中
+        /// <summary>
+        /// 读取指定位置文件列表到集合中
+        /// </summary>
+        /// <param name="path">指定路径</param>
+        /// <returns></returns>
+        public static DataTable GetFileTable(string path)
+        {
+            DataTable dt = new DataTable();
+            dt.Columns.Add("name", typeof(string));
+            dt.Columns.Add("ext", typeof(string));
+            dt.Columns.Add("size", typeof(long));
+            dt.Columns.Add("time", typeof(DateTime));
+
+            DirectoryInfo dirinfo = new DirectoryInfo(path);
+            FileInfo fi;
+            DirectoryInfo dir;
+            string FileName, FileExt;
+            long FileSize = 0;
+            DateTime FileModify;
+            try
+            {
+                foreach (FileSystemInfo fsi in dirinfo.GetFileSystemInfos())
+                {
+                    FileName = string.Empty;
+                    FileExt = string.Empty;
+                    if (fsi is FileInfo)
+                    {
+                        fi = (FileInfo)fsi;
+                        //获取文件名称
+                        FileName = fi.Name;
+                        //获取文件扩展名
+                        FileExt = fi.Extension;
+                        //获取文件大小
+                        FileSize = fi.Length;
+                        //获取文件最后修改时间
+                        FileModify = fi.LastWriteTime;
+                    }
+                    else
+                    {
+                        dir = (DirectoryInfo)fsi;
+                        //获取目录名
+                        FileName = dir.Name;
+                        //获取目录最后修改时间
+                        FileModify = dir.LastWriteTime;
+                        //设置目录文件为文件夹
+                        FileExt = "文件夹";
+                    }
+                    DataRow dr = dt.NewRow();
+                    dr["name"] = FileName;
+                    dr["ext"] = FileExt;
+                    dr["size"] = FileSize;
+                    dr["time"] = FileModify;
+                    dt.Rows.Add(dr);
+                }
+            }
+            catch
+            {
+
+                throw;
+            }
+            return dt;
+        }
+
+        #endregion
+
+        #region 检测指定路径是否存在
+        /// <summary>
+        /// 检测指定路径是否存在
+        /// </summary>
+        /// <param name="path">目录的绝对路径</param> 
+        public static bool IsExistDirectory(string path)
+        {
+            return Directory.Exists(path);
+        }
+        #endregion
+
+        #region 检测指定文件是否存在,如果存在则返回true
+        /// <summary>
+        /// 检测指定文件是否存在,如果存在则返回true
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>  
+        public static bool IsExistFile(string filePath)
+        {
+            return File.Exists(filePath);
+        }
+        #endregion
+
+        #region 创建文件夹
+        /// <summary>
+        /// 创建文件夹
+        /// </summary>
+        /// <param name="folderPath">文件夹的绝对路径</param>
+        public static void CreateFolder(string folderPath)
+        {
+            if (!IsExistDirectory(folderPath))
+            {
+                Directory.CreateDirectory(folderPath);
+            }
+        }
+        #endregion 
+
+        #region 判断上传文件后缀名
+        /// <summary>
+        /// 判断上传文件后缀名
+        /// </summary>
+        /// <param name="strExtension">后缀名</param>
+        public static bool IsCanEdit(string strExtension)
+        {
+            strExtension = strExtension.ToLower();
+            if (strExtension.LastIndexOf(".", StringComparison.Ordinal) >= 0)
+            {
+                strExtension = strExtension.Substring(strExtension.LastIndexOf(".", StringComparison.Ordinal));
+            }
+            else
+            {
+                strExtension = ".txt";
+            }
+            string[] strArray = new string[] { ".htm", ".html", ".txt", ".js", ".css", ".xml", ".sitemap" };
+            for (int i = 0; i < strArray.Length; i++)
+            {
+                if (strExtension.Equals(strArray[i]))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+
+        public static bool IsSafeName(string strExtension)
+        {
+            strExtension = strExtension.ToLower();
+            if (strExtension.LastIndexOf(".") >= 0)
+            {
+                strExtension = strExtension.Substring(strExtension.LastIndexOf("."));
+            }
+            else
+            {
+                strExtension = ".txt";
+            }
+            string[] strArray = new string[] { ".jpg", ".gif", ".png" };
+            for (int i = 0; i < strArray.Length; i++)
+            {
+                if (strExtension.Equals(strArray[i]))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public static bool IsZipName(string strExtension)
+        {
+            strExtension = strExtension.ToLower();
+            if (strExtension.LastIndexOf(".") >= 0)
+            {
+                strExtension = strExtension.Substring(strExtension.LastIndexOf("."));
+            }
+            else
+            {
+                strExtension = ".txt";
+            }
+            string[] strArray = new string[] { ".zip", ".rar" };
+            for (int i = 0; i < strArray.Length; i++)
+            {
+                if (strExtension.Equals(strArray[i]))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+        #endregion
+
+        #region 创建文件夹
+        /// <summary>
+        /// 创建文件夹
+        /// </summary>
+        /// <param name="fileName">文件的绝对路径</param>
+        public static void CreateSuffic(string fileName)
+        {
+            try
+            {
+                if (!Directory.Exists(fileName))
+                {
+                    Directory.CreateDirectory(fileName);
+                }
+            }
+            catch (Exception ex)
+            {
+                var s = ex.Message;
+
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// 创建文件夹
+        /// </summary>
+        /// <param name="fileName">文件的绝对路径</param>
+        public static void CreateFiles(string fileName)
+        {
+            try
+            {
+                //判断文件是否存在,不存在创建该文件
+                if (!IsExistFile(fileName))
+                {
+                    FileInfo file = new FileInfo(fileName);
+                    FileStream fs = file.Create();
+                    fs.Close();
+                }
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
+
+        /// <summary>
+        /// 创建一个文件,并将字节流写入文件。
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        /// <param name="buffer">二进制流数据</param>
+        public static void CreateFile(string filePath, byte[] buffer)
+        {
+            try
+            {
+                //判断文件是否存在,不存在创建该文件
+                if (!IsExistFile(filePath))
+                {
+                    FileInfo file = new FileInfo(filePath);
+                    FileStream fs = file.Create();
+                    fs.Write(buffer, 0, buffer.Length);
+                    fs.Close();
+                }
+                else
+                {
+                    File.WriteAllBytes(filePath, buffer);
+                }
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
+        #endregion
+
+        #region 将文件移动到指定目录
+        /// <summary>
+        /// 将文件移动到指定目录
+        /// </summary>
+        /// <param name="sourceFilePath">需要移动的源文件的绝对路径</param>
+        /// <param name="descDirectoryPath">移动到的目录的绝对路径</param>
+        public static void Move(string sourceFilePath, string descDirectoryPath)
+        {
+            string sourceName = GetFileName(sourceFilePath);
+            if (IsExistDirectory(descDirectoryPath))
+            {
+                //如果目标中存在同名文件,则删除
+                if (IsExistFile(descDirectoryPath + "\\" + sourceFilePath))
+                {
+                    DeleteFile(descDirectoryPath + "\\" + sourceFilePath);
+                }
+                else
+                {
+                    //将文件移动到指定目录
+                    File.Move(sourceFilePath, descDirectoryPath + "\\" + sourceFilePath);
+                }
+            }
+        }
+        #endregion
+
+        # region 将源文件的内容复制到目标文件中
+        /// <summary>
+        /// 将源文件的内容复制到目标文件中
+        /// </summary>
+        /// <param name="sourceFilePath">源文件的绝对路径</param>
+        /// <param name="descDirectoryPath">目标文件的绝对路径</param>
+        public static void Copy(string sourceFilePath, string descDirectoryPath)
+        {
+            File.Copy(sourceFilePath, descDirectoryPath, true);
+        }
+        #endregion
+
+        #region 从文件的绝对路径中获取文件名( 不包含扩展名 )
+        /// <summary>
+        /// 从文件的绝对路径中获取文件名( 不包含扩展名 )
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param> 
+        public static string GetFileName(string filePath)
+        {
+            FileInfo file = new FileInfo(filePath);
+            return file.Name;
+        }
+        #endregion
+
+        #region 获取文件的后缀名
+        /// <summary>
+        /// 获取文件的后缀名
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        public static string GetExtension(string filePath)
+        {
+            FileInfo file = new FileInfo(filePath);
+            return file.Extension;
+        }
+
+        /// <summary>
+        /// 返回文件扩展名,不含“.”
+        /// </summary>
+        /// <param name="filepath">文件全名称</param>
+        /// <returns>string</returns>
+        public static string GetFileExt(string filepath)
+        {
+            if (string.IsNullOrEmpty(filepath))
+            {
+                return "";
+            }
+            if (filepath.LastIndexOf(".", StringComparison.Ordinal) > 0)
+            {
+                return filepath.Substring(filepath.LastIndexOf(".", StringComparison.Ordinal) + 1); //文件扩展名,不含“.”
+            }
+            return "";
+        }
+        #endregion
+
+        #region 删除指定文件
+        /// <summary>
+        /// 删除指定文件
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        public static void DeleteFile(string filePath)
+        {
+            if (IsExistFile(filePath))
+            {
+                File.Delete(filePath);
+            }
+        }
+        #endregion
+
+        #region 删除指定目录及其所有子目录
+        /// <summary>
+        /// 删除指定目录及其所有子目录
+        /// </summary>
+        /// <param name="directoryPath">文件的绝对路径</param>
+        public static void DeleteDirectory(string directoryPath)
+        {
+            if (IsExistDirectory(directoryPath))
+            {
+                Directory.Delete(directoryPath);
+            }
+        }
+        #endregion
+
+        #region 清空指定目录下所有文件及子目录,但该目录依然保存.
+        /// <summary>
+        /// 清空指定目录下所有文件及子目录,但该目录依然保存.
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>
+        public static void ClearDirectory(string directoryPath)
+        {
+            if (!IsExistDirectory(directoryPath)) return;
+            //删除目录中所有的文件
+            string[] fileNames = GetFileNames(directoryPath);
+            for (int i = 0; i < fileNames.Length; i++)
+            {
+                DeleteFile(fileNames[i]);
+            }
+            //删除目录中所有的子目录
+            string[] directoryNames = GetDirectories(directoryPath);
+            for (int i = 0; i < directoryNames.Length; i++)
+            {
+                DeleteDirectory(directoryNames[i]);
+            }
+        }
+        #endregion
+
+        #region  剪切  粘贴
+        /// <summary>
+        /// 剪切文件
+        /// </summary>
+        /// <param name="source">原路径</param> 
+        /// <param name="destination">新路径</param> 
+        public bool FileMove(string source, string destination)
+        {
+            bool ret = false;
+            FileInfo file_s = new FileInfo(source);
+            FileInfo file_d = new FileInfo(destination);
+            if (file_s.Exists)
+            {
+                if (!file_d.Exists)
+                {
+                    file_s.MoveTo(destination);
+                    ret = true;
+                }
+            }
+            if (ret == true)
+            {
+                //Response.Write("<script>alert('剪切文件成功!');</script>");
+            }
+            else
+            {
+                //Response.Write("<script>alert('剪切文件失败!');</script>");
+            }
+            return ret;
+        }
+        #endregion
+
+        #region 检测指定目录是否为空
+        /// <summary>
+        /// 检测指定目录是否为空
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>  
+        public static bool IsEmptyDirectory(string directoryPath)
+        {
+            try
+            {
+                //判断文件是否存在
+                string[] fileNames = GetFileNames(directoryPath);
+                if (fileNames.Length > 0)
+                {
+                    return false;
+                }
+                //判断是否存在文件夹
+                string[] directoryNames = GetDirectories(directoryPath);
+                if (directoryNames.Length > 0)
+                {
+                    return false;
+                }
+                return true;
+            }
+            catch (Exception ex)
+            {
+                var s = ex.Message;
+                return true;
+            }
+        }
+        #endregion
+
+        #region 获取指定目录中所有文件列表
+        /// <summary>
+        /// 获取指定目录中所有文件列表
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>  
+        public static string[] GetFileNames(string directoryPath)
+        {
+            if (!IsExistDirectory(directoryPath))
+            {
+                throw new FileNotFoundException();
+            }
+            return Directory.GetFiles(directoryPath);
+        }
+        #endregion
+
+        #region 获取指定目录中的子目录列表
+        /// <summary>
+        /// 获取指定目录中所有子目录列表,若要搜索嵌套的子目录列表,请使用重载方法
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>
+        public static string[] GetDirectories(string directoryPath)
+        {
+            try
+            {
+                return Directory.GetDirectories(directoryPath);
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
+
+        /// <summary>
+        /// 获取指定目录及子目录中所有子目录列表
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>
+        /// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。
+        /// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>
+        /// <param name="isSearchChild">是否搜索子目录</param>
+        public static string[] GetDirectories(string directoryPath, string searchPattern, bool isSearchChild)
+        {
+            try
+            {
+                if (isSearchChild)
+                {
+                    return Directory.GetDirectories(directoryPath, searchPattern, SearchOption.AllDirectories);
+                }
+                else
+                {
+                    return Directory.GetDirectories(directoryPath, searchPattern, SearchOption.TopDirectoryOnly);
+                }
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
+        #endregion
+
+        #region 获取一个文件的长度
+        /// <summary> 
+        /// 获取一个文件的长度,单位为Byte 
+        /// </summary> 
+        /// <param name="filePath">文件的绝对路径</param>         
+        public static int GetFileSize(string filePath)
+        {
+            //创建一个文件对象 
+            FileInfo fi = new FileInfo(filePath);
+            //获取文件的大小 
+            return (int)fi.Length;
+        }
+        /// <summary> 
+        /// 获取一个文件的长度,单位为KB 
+        /// </summary> 
+        /// <param name="filePath">文件的路径</param>         
+        public static double GetFileSizeByKb(string filePath)
+        {
+            //创建一个文件对象 
+            FileInfo fi = new FileInfo(filePath);
+            //获取文件的大小 
+            return Math.Round(Convert.ToDouble(filePath.Length) / 1024, 2);// ConvertHelper.ToDouble(ConvertHelper.ToDouble(fi.Length) / 1024, 1);
+        }
+
+        /// <summary> 
+        /// 获取一个文件的长度,单位为MB 
+        /// </summary> 
+        /// <param name="filePath">文件的路径</param>         
+        public static double GetFileSizeByMb(string filePath)
+        {
+            //创建一个文件对象 
+            FileInfo fi = new FileInfo(filePath);
+            //获取文件的大小 
+            return Math.Round(Convert.ToDouble(Convert.ToDouble(fi.Length) / 1024 / 1024), 2);
+        }
+
+        #endregion
+
+        #region 获取所有文件夹及子文件夹
+        /// <summary>
+        /// 获取所有文件夹及子文件夹
+        /// </summary>
+        /// <param name="dirPath"></param>
+        /// <returns></returns>
+        public static List<ArrayFiles> GetDirs(string dirPath)
+        {
+            var list = new List<ArrayFiles>();
+            return GetArrys(dirPath, 0, list);
+        }
+
+        private static int zdId = 0;
+        private static List<ArrayFiles> GetArrys(string dirPath, int pid, List<ArrayFiles> list)
+        {
+            if (!Directory.Exists(dirPath)) return list;
+            if (Directory.GetDirectories(dirPath).Length <= 0) return list;
+            foreach (string path in Directory.GetDirectories(dirPath))
+            {
+                zdId++;
+                var model = new ArrayFiles()
+                {
+                    Id = zdId,
+                    Name = path.Substring(path.LastIndexOf('\\') + 1, path.Length - (path.LastIndexOf('\\') + 1)),
+                    Pid = pid,
+                    Open = false,
+                    Target = "DeployBase",
+                    Url = "/FytAdmin/FileMiam/DocList?path=" + path
+                };
+                list.Add(model);
+                GetArrys(path, model.Id, list);
+            }
+            return list;
+        }
+
+        public class ArrayFiles
+        {
+            public int Id { get; set; }
+            public int Pid { get; set; }
+            public string Name { get; set; }
+            public Boolean Open { get; set; }
+            public string Target { get; set; }
+            public string Url { get; set; }
+        }
+        #endregion
+
+        #region 将文件读取到字符串中
+        /// <summary>
+        /// 将文件读取到字符串中
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        public static string FileToString(string filePath)
+        {
+            return FileToString(filePath, Encoding.UTF8);
+        }
+        /// <summary>
+        /// 将文件读取到字符串中
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        /// <param name="encoding">字符编码</param>
+        public static string FileToString(string filePath, Encoding encoding)
+        {
+            //创建流读取器
+            StreamReader reader = new StreamReader(filePath, encoding);
+            try
+            {
+                //读取流
+                return reader.ReadToEnd();
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+            finally
+            {
+                //关闭流读取器
+                reader.Close();
+            }
+        }
+        #endregion
+    }
+
+    /// <summary>
+    /// 远程文件下载
+    /// </summary>
+    public class HttpDldFile
+    {
+        /// <summary>
+        /// Http方式下载文件
+        /// </summary>
+        /// <param name="url">http地址</param>
+        /// <param name="localfile">本地文件</param>
+        /// <returns></returns>
+        public bool Download(string url, string localfile)
+        {
+            bool flag = false;
+            long startPosition = 0; // 上次下载的文件起始位置
+            FileStream writeStream; // 写入本地文件流对象
+
+            long remoteFileLength = GetHttpLength(url);// 取得远程文件长度
+            //System.Console.WriteLine("remoteFileLength=" + remoteFileLength);
+            if (remoteFileLength == 745)
+            {
+                System.Console.WriteLine("远程文件不存在.");
+                return false;
+            }
+
+            // 判断要下载的文件夹是否存在
+            if (File.Exists(localfile))
+            {
+
+                writeStream = File.OpenWrite(localfile);             // 存在则打开要下载的文件
+                startPosition = writeStream.Length;                  // 获取已经下载的长度
+
+                if (startPosition >= remoteFileLength)
+                {
+                    System.Console.WriteLine("本地文件长度" + startPosition + "已经大于等于远程文件长度" + remoteFileLength);
+                    writeStream.Close();
+
+                    return false;
+                }
+                else
+                {
+                    writeStream.Seek(startPosition, SeekOrigin.Current); // 本地文件写入位置定位
+                }
+            }
+            else
+            {
+                writeStream = new FileStream(localfile, FileMode.Create);// 文件不保存创建一个文件
+                startPosition = 0;
+            }
+
+
+            try
+            {
+                HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(url);// 打开网络连接
+
+                if (startPosition > 0)
+                {
+                    myRequest.AddRange((int)startPosition);// 设置Range值,与上面的writeStream.Seek用意相同,是为了定义远程文件读取位置
+                }
+
+
+                Stream readStream = myRequest.GetResponse().GetResponseStream();// 向服务器请求,获得服务器的回应数据流
+
+
+                byte[] btArray = new byte[512];// 定义一个字节数据,用来向readStream读取内容和向writeStream写入内容
+                int contentSize = readStream.Read(btArray, 0, btArray.Length);// 向远程文件读第一次
+
+                long currPostion = startPosition;
+
+                while (contentSize > 0)// 如果读取长度大于零则继续读
+                {
+                    currPostion += contentSize;
+                    int percent = (int)(currPostion * 100 / remoteFileLength);
+                    System.Console.WriteLine("percent=" + percent + "%");
+
+                    writeStream.Write(btArray, 0, contentSize);// 写入本地文件
+                    contentSize = readStream.Read(btArray, 0, btArray.Length);// 继续向远程文件读取
+                }
+
+                //关闭流
+                writeStream.Close();
+                readStream.Close();
+
+                flag = true;        //返回true下载成功
+            }
+            catch (Exception)
+            {
+                writeStream.Close();
+                flag = false;       //返回false下载失败
+            }
+
+            return flag;
+        }
+
+        // 从文件头得到远程文件的长度
+        private static long GetHttpLength(string url)
+        {
+            long length = 0;
+
+            try
+            {
+                HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);// 打开网络连接
+                HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
+
+                if (rsp.StatusCode == HttpStatusCode.OK)
+                {
+                    length = rsp.ContentLength;// 从文件头得到远程文件的长度
+                }
+
+                rsp.Close();
+                return length;
+            }
+            catch (Exception e)
+            {
+                var s = e.Message;
+                return length;
+            }
+
+        }
+    }
+}

+ 550 - 0
TEAMModelOS.SDK/Helper/Common/FileHelper/FileHelperCore.cs

@@ -0,0 +1,550 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.SDK.Helper.Common.FileHelper
+{
+    /// <summary>
+    /// Describe:文件帮助类
+    /// </summary>
+    public class FileHelperCore
+    {
+        private static IHostingEnvironment _hostingEnvironment = new HttpContextAccessor().HttpContext.RequestServices.GetService(typeof(IHostingEnvironment)) as IHostingEnvironment;
+
+        /// <summary>
+        /// 目录分隔符
+        /// windows "\" OSX and Linux  "/"
+        /// </summary>
+        private static string DirectorySeparatorChar = Path.DirectorySeparatorChar.ToString();
+        /// <summary>
+        /// 包含应用程序的目录的绝对路径
+        /// </summary>
+        private static string _ContentRootPath = _hostingEnvironment.ContentRootPath;
+
+        #region 检测指定路径是否存在
+
+        /// <summary>
+        /// 检测指定路径是否存在
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static bool IsExist(string path)
+        {
+            return IsDirectory(MapPath(path)) ? Directory.Exists(MapPath(path)) : File.Exists(MapPath(path));
+        }
+        /// <summary>
+        /// 检测指定路径是否存在(异步方式)
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static async Task<bool> IsExistAsync(string path)
+        {
+            return await Task.Run(() => IsDirectory(MapPath(path)) ? Directory.Exists(MapPath(path)) : File.Exists(MapPath(path)));
+        }
+
+        #endregion
+
+        #region 检测目录是否为空
+
+        /// <summary>
+        /// 检测目录是否为空
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static bool IsEmptyDirectory(string path)
+        {
+            return Directory.GetFiles(MapPath(path)).Length <= 0 && Directory.GetDirectories(MapPath(path)).Length <= 0;
+        }
+        /// <summary>
+        /// 检测目录是否为空
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static async Task<bool> IsEmptyDirectoryAsync(string path)
+        {
+            return await Task.Run(() => Directory.GetFiles(MapPath(path)).Length <= 0 && Directory.GetDirectories(MapPath(path)).Length <= 0);
+        }
+
+        #endregion
+
+        #region 创建目录
+
+        /// <summary>
+        /// 创建目录
+        /// </summary>
+        /// <param name="path">路径</param>
+        public static void CreateFiles(string path)
+        {
+            try
+            {
+                if (IsDirectory(MapPath(path)))
+                    Directory.CreateDirectory(MapPath(path));
+                else
+                    File.Create(MapPath(path)).Dispose();
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+        #endregion
+
+        #region 删除文件或目录
+
+        /// <summary>
+        /// 删除目录或文件
+        /// </summary>
+        /// <param name="path">路径</param>
+        public static void DeleteFiles(string path)
+        {
+            try
+            {
+                if (IsExist(path))
+                {
+                    if (IsDirectory(MapPath(path)))
+                        Directory.Delete(MapPath(path));
+                    else
+                        File.Delete(MapPath(path));
+                }
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+        /// <summary>
+        /// 清空目录下所有文件及子目录,依然保留该目录
+        /// </summary>
+        /// <param name="path"></param>
+        public static void ClearDirectory(string path)
+        {
+            if (IsExist(path))
+            {
+                //目录下所有文件
+                string[] files = Directory.GetFiles(MapPath(path));
+                foreach (var file in files)
+                {
+                    DeleteFiles(file);
+                }
+                //目录下所有子目录
+                string[] directorys = Directory.GetDirectories(MapPath(path));
+                foreach (var dir in directorys)
+                {
+                    DeleteFiles(dir);
+                }
+            }
+        }
+
+        #endregion
+
+        #region 判断文件是否为隐藏文件(系统独占文件)
+
+        /// <summary>
+        /// 检测文件或文件夹是否为隐藏文件
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static bool IsHiddenFile(string path)
+        {
+            return IsDirectory(MapPath(path)) ? InspectHiddenFile(new DirectoryInfo(MapPath(path))) : InspectHiddenFile(new FileInfo(MapPath(path)));
+        }
+        /// <summary>
+        /// 检测文件或文件夹是否为隐藏文件(异步方式)
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static async Task<bool> IsHiddenFileAsync(string path)
+        {
+            return await Task.Run(() => IsDirectory(MapPath(path)) ? InspectHiddenFile(new DirectoryInfo(MapPath(path))) : InspectHiddenFile(new FileInfo(MapPath(path))));
+        }
+        /// <summary>
+        /// 私有方法 文件是否为隐藏文件(系统独占文件)
+        /// </summary>
+        /// <param name="fileSystemInfo"></param>
+        /// <returns></returns>
+        private static bool InspectHiddenFile(FileSystemInfo fileSystemInfo)
+        {
+            if (fileSystemInfo.Name.StartsWith("."))
+            {
+                return true;
+            }
+            else if (fileSystemInfo.Exists &&
+                ((fileSystemInfo.Attributes & FileAttributes.Hidden) != 0 ||
+                 (fileSystemInfo.Attributes & FileAttributes.System) != 0))
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        #endregion
+
+        #region 文件操作
+
+        #region 复制文件
+
+        /// <summary>
+        /// 复制文件内容到目标文件夹
+        /// </summary>
+        /// <param name="sourcePath">源文件</param>
+        /// <param name="targetPath">目标文件夹</param>
+        /// <param name="isOverWrite">是否可以覆盖</param>
+        public static void Copy(string sourcePath, string targetPath, bool isOverWrite = true)
+        {
+            File.Copy(MapPath(sourcePath), MapPath(targetPath) + GetFileName(sourcePath), isOverWrite);
+        }
+        /// <summary>
+        /// 复制文件内容到目标文件夹
+        /// </summary>
+        /// <param name="sourcePath">源文件</param>
+        /// <param name="targetPath">目标文件夹</param>
+        /// <param name="newName">新文件名称</param>
+        /// <param name="isOverWrite">是否可以覆盖</param>
+        public static void Copy(string sourcePath, string targetPath, string newName, bool isOverWrite = true)
+        {
+            File.Copy(MapPath(sourcePath), MapPath(targetPath) + newName, isOverWrite);
+        }
+
+        #endregion
+
+        #region 移动文件
+
+        /// <summary>
+        /// 移动文件到目标目录
+        /// </summary>
+        /// <param name="sourcePath">源文件</param>
+        /// <param name="targetPath">目标目录</param>
+        public static void Move(string sourcePath, string targetPath)
+        {
+            string sourceFileName = GetFileName(sourcePath);
+            //如果目标目录不存在则创建
+            if (IsExist(targetPath))
+            {
+                CreateFiles(targetPath);
+            }
+            else
+            {
+                //如果目标目录存在同名文件则删除
+                if (IsExist(Path.Combine(MapPath(targetPath), sourceFileName)))
+                {
+                    DeleteFiles(Path.Combine(MapPath(targetPath), sourceFileName));
+                }
+            }
+
+            File.Move(MapPath(sourcePath), Path.Combine(MapPath(targetPath), sourceFileName));
+
+
+        }
+
+        #endregion
+
+        /// <summary>
+        /// 获取文件名和扩展名
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static string GetFileName(string path)
+        {
+            return Path.GetFileName(MapPath(path));
+        }
+
+        /// <summary>
+        /// 获取文件名不带扩展名
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static string GetFileNameWithOutExtension(string path)
+        {
+            return Path.GetFileNameWithoutExtension(MapPath(path));
+        }
+
+        /// <summary>
+        /// 获取文件扩展名
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static string GetFileExtension(string path)
+        {
+            return Path.GetExtension(MapPath(path));
+        }
+
+        #endregion
+
+        #region 获取文件绝对路径
+
+        /// <summary>
+        /// 获取文件绝对路径
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static string MapPath(string path)
+        {
+            return Path.Combine(_ContentRootPath, path.TrimStart('~', '/').Replace("/", DirectorySeparatorChar));
+        }
+        /// <summary>
+        /// 获取文件绝对路径(异步方式)
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static async Task<string> MapPathAsync(string path)
+        {
+            return await Task.Run(() => Path.Combine(_ContentRootPath, path.TrimStart('~', '/').Replace("/", DirectorySeparatorChar)));
+        }
+
+
+        /// <summary>
+        /// 是否为目录或文件夹
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static bool IsDirectory(string path)
+        {
+            if (path.EndsWith(DirectorySeparatorChar))
+                return true;
+            else
+                return false;
+        }
+
+        #endregion
+
+        #region 物理路径转虚拟路径
+        public static string PhysicalToVirtual(string physicalPath)
+        {
+            return physicalPath.Replace(_ContentRootPath, "").Replace(DirectorySeparatorChar, "/");
+        }
+        #endregion
+
+        #region 文件格式
+        /// <summary>
+        /// 是否可添加水印
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsCanWater(string _fileExt)
+        {
+            var images = new List<string> { "jpg", "jpeg" };
+            if (images.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        /// <summary>
+        /// 是否为图片
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsImage(string _fileExt)
+        {
+            var images = new List<string> { "bmp", "gif", "jpg", "jpeg", "png" };
+            if (images.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        /// <summary>
+        /// 是否为视频
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsVideos(string _fileExt)
+        {
+            var videos = new List<string> { "rmvb", "mkv", "ts", "wma", "avi", "rm", "mp4", "flv", "mpeg", "mov", "3gp", "mpg" };
+            if (videos.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        /// <summary>
+        /// 是否为音频
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsMusics(string _fileExt)
+        {
+            var musics = new List<string> { "mp3", "wav" };
+            if (musics.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        /// <summary>
+        /// 是否为文档
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsDocument(string _fileExt)
+        {
+            var documents = new List<string> { "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "pdf" };
+            if (documents.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        #endregion
+
+        #region 文件图标
+        public static string FindFileIcon(string fileExt)
+        {
+            if (IsImage(fileExt))
+                return "fa fa-image";
+            if (IsVideos(fileExt))
+                return "fa fa-film";
+            if (IsMusics(fileExt))
+                return "fa fa-music";
+            if (IsDocument(fileExt))
+                switch (fileExt.ToLower())
+                {
+                    case ".xls":
+                    case ".xlsx":
+                        return "fa fa-file-excel-o";
+                    case ".ppt":
+                    case ".pptx":
+                        return "fa fa-file-powerpoint-o";
+                    case ".pdf":
+                        return "fa fa-file-pdf-o";
+                    case ".txt":
+                        return "fa fa-file-text-o";
+                    default:
+                        return "fa fa-file-word-o";
+                }
+            if (fileExt.ToLower() == "zip" || fileExt.ToLower() == "rar")
+                return "fa fa-file-zip-o";
+            else
+                return "fa fa-file";
+        }
+        #endregion
+
+        #region 文件大小转换
+        /// <summary>
+        ///  文件大小转为B、KB、MB、GB...
+        /// </summary>
+        /// <param name="size"></param>
+        /// <returns></returns>
+        public static string FileSizeTransf(long size)
+        {
+            String[] units = new String[] { "B", "KB", "MB", "GB", "TB", "PB" };
+            long mod = 1024;
+            int i = 0;
+            while (size > mod)
+            {
+                size /= mod;
+                i++;
+            }
+            return size + units[i];
+
+        }
+        #endregion
+
+        #region 获取目录下所有文件
+        public static List<FilesInfo> FindFiles(string path, string staticFiles = "/wwwroot")
+        {
+            string[] folders = Directory.GetDirectories(MapPath(path), "*", SearchOption.AllDirectories);
+            var Files = new List<FilesInfo>();
+
+            foreach (var folder in folders)
+            {
+                foreach (var fsi in new DirectoryInfo(folder).GetFiles())
+                {
+                    Files.Add(new FilesInfo()
+                    {
+                        Name = fsi.Name,
+                        FullName = fsi.FullName,
+                        FileExt = fsi.Extension,
+                        FileOriginalSize = fsi.Length,
+                        FileSize = FileSizeTransf(fsi.Length),
+                        FileIcon = FindFileIcon(fsi.Extension.Remove(0, 1)),
+                        FileName = PhysicalToVirtual(fsi.FullName).Replace(staticFiles, ""),
+                        FileStyle = IsImage(fsi.Extension.Remove(0, 1)) ? "images" :
+                                    IsDocument(fsi.Extension.Remove(0, 1)) ? "documents" :
+                                    IsVideos(fsi.Extension.Remove(0, 1)) ? "videos" :
+                                    IsMusics(fsi.Extension.Remove(0, 1)) ? "musics" : "others",
+                        CreateDate = fsi.CreationTime,
+                        LastWriteDate = fsi.LastWriteTime,
+                        LastAccessDate = fsi.LastAccessTime
+                    });
+                }
+            }
+            return Files;
+        }
+
+        /// <summary>
+        /// 获得指定文件夹下面的所有文件
+        /// </summary>
+        /// <param name="path"></param>
+        /// <param name="staticFiles"></param>
+        /// <returns></returns>
+        public static List<FilesInfo> ResolveFileInfo(string path, string staticFiles = "/wwwroot")
+        {
+            var foldersPath = MapPath(path);
+            var Files = new List<FilesInfo>();
+            foreach (var fsi in new DirectoryInfo(foldersPath).GetFiles())
+            {
+                Files.Add(new FilesInfo()
+                {
+                    Name = fsi.Name,
+                    FullName = fsi.FullName,
+                    FileExt = fsi.Extension,
+                    FileOriginalSize = fsi.Length,
+                    FileSize = FileSizeTransf(fsi.Length),
+                    FileIcon = FindFileIcon(fsi.Extension.Remove(0, 1)),
+                    FileName = PhysicalToVirtual(fsi.FullName).Replace(staticFiles, ""),
+                    FileStyle = IsImage(fsi.Extension.Remove(0, 1)) ? "images" :
+                                IsDocument(fsi.Extension.Remove(0, 1)) ? "documents" :
+                                IsVideos(fsi.Extension.Remove(0, 1)) ? "videos" :
+                                IsMusics(fsi.Extension.Remove(0, 1)) ? "musics" : "others",
+                    CreateDate = fsi.CreationTime,
+                    LastWriteDate = fsi.LastWriteTime,
+                    LastAccessDate = fsi.LastAccessTime
+                });
+            }
+            return Files;
+        }
+        #endregion
+
+    }
+
+    public class FilesInfo
+    {
+        /// <summary>
+        /// 文件名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 文件物理路径
+        /// </summary>
+        public string FullName { get; set; }
+        /// <summary>
+        /// 扩展名
+        /// </summary>
+        public string FileExt { get; set; }
+        /// <summary>
+        /// 原始大小(字节)
+        /// </summary>
+        public long FileOriginalSize { get; set; }
+        /// <summary>
+        /// 文件大小
+        /// </summary>
+        public string FileSize { get; set; }
+        /// <summary>
+        /// 文件虚拟路径
+        /// </summary>
+        public string FileName { get; set; }
+        /// <summary>
+        /// 文件类型
+        /// </summary>
+        public string FileStyle { get; set; }
+        /// <summary>
+        /// 文件图标
+        /// </summary>
+        public string FileIcon { get; set; }
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        public DateTime CreateDate { get; set; }
+        /// <summary>
+        /// 最后修改时间
+        /// </summary>
+        public DateTime LastWriteDate { get; set; }
+        /// <summary>
+        /// 最后访问时间
+        /// </summary>
+        public DateTime LastAccessDate { get; set; }
+
+    }
+}

+ 116 - 0
TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonSerialization.cs

@@ -0,0 +1,116 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Common.JsonHelper
+{
+    public static class JsonSerialization
+    {
+        static JsonSerializerSettings settings = new JsonSerializerSettings()
+        {
+            ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+            PreserveReferencesHandling = PreserveReferencesHandling.Objects
+        };
+
+        /// <summary>
+        /// 使用json序列化为字符串
+        /// </summary>
+        /// <param name="dateTimeFormat">默认null,即使用json.net默认的序列化机制,如:"\/Date(1439335800000+0800)\/"</param>
+        /// <returns></returns>
+        public static string ToJson(this object input, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss", bool ignoreNullValue = true, bool isIndented = false)
+        {
+            settings.NullValueHandling = ignoreNullValue ? Newtonsoft.Json.NullValueHandling.Ignore : NullValueHandling.Include;
+
+            if (!string.IsNullOrWhiteSpace(dateTimeFormat))
+            {
+                var jsonConverter = new List<JsonConverter>()
+                {
+                    new Newtonsoft.Json.Converters.IsoDateTimeConverter(){ DateTimeFormat = dateTimeFormat }//如: "yyyy-MM-dd HH:mm:ss"
+                };
+                settings.Converters = jsonConverter;
+            }
+
+            //no format
+            var format = isIndented ? Newtonsoft.Json.Formatting.Indented : Formatting.None;
+            var json = JsonConvert.SerializeObject(input, format, settings);
+            return json;
+        }
+
+        /// <summary>
+        /// 从序列化字符串里反序列化
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="input"></param>
+        /// <param name="dateTimeFormat">默认null,即使用json.net默认的序列化机制</param>
+        /// <returns></returns>
+        public static T TryFromJson<T>(this string input, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss", bool ignoreNullValue = true)
+        {
+            try
+            {
+                return input.FromJson<T>(dateTimeFormat, ignoreNullValue);
+            }
+            catch
+            {
+                return default(T);
+            }
+        }
+        /// <summary>
+        /// 从序列化字符串里反序列化
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="input"></param>
+        /// <param name="dateTimeFormat">默认null,即使用json.net默认的序列化机制</param>
+        /// <returns></returns>
+        public static T FromJson<T>(this string input, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss", bool ignoreNullValue = true)
+        {
+            var settings = new JsonSerializerSettings()
+            {
+                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+                PreserveReferencesHandling = PreserveReferencesHandling.Objects,
+            };
+            settings.NullValueHandling = ignoreNullValue ? Newtonsoft.Json.NullValueHandling.Ignore : NullValueHandling.Include;
+
+            if (!string.IsNullOrWhiteSpace(dateTimeFormat))
+            {
+                var jsonConverter = new List<JsonConverter>()
+                {
+                    new Newtonsoft.Json.Converters.IsoDateTimeConverter(){ DateTimeFormat = dateTimeFormat }//如: "yyyy-MM-dd HH:mm:ss"
+                };
+                settings.Converters = jsonConverter;
+            }
+
+            return JsonConvert.DeserializeObject<T>(input, settings);
+        }
+        /// <summary>
+        /// 从序列化字符串里反序列化
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="input"></param>
+        /// <param name="dateTimeFormat">默认null,即使用json.net默认的序列化机制</param>
+        /// <returns></returns>
+        public static object FromJson(this string input, Type type, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss", bool ignoreNullValue = true)
+        {
+            var settings = new JsonSerializerSettings()
+            {
+                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+                PreserveReferencesHandling = PreserveReferencesHandling.Objects,
+            };
+            if (ignoreNullValue)
+            {
+                settings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
+            }
+
+            if (!string.IsNullOrWhiteSpace(dateTimeFormat))
+            {
+                var jsonConverter = new List<JsonConverter>()
+                {
+                    new Newtonsoft.Json.Converters.IsoDateTimeConverter(){ DateTimeFormat = dateTimeFormat }//如: "yyyy-MM-dd HH:mm:ss"
+                };
+                settings.Converters = jsonConverter;
+            }
+
+            return JsonConvert.DeserializeObject(input, type, settings);
+        }
+    }
+}

+ 74 - 0
TEAMModelOS.SDK/Helper/Common/JsonHelper/MessagePackHelper.cs

@@ -0,0 +1,74 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Common.JsonHelper
+{
+    public class MessagePackHelper
+    {
+        /// <summary>
+        /// Json字符串转Byte
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns>byte[]</returns>
+        public static byte[] JsonToByte(string json)
+        {
+            return LZ4MessagePackSerializer.FromJson(json);
+        }
+
+        /// <summary>
+        /// Json字符串转对象
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="json"></param>
+        /// <returns>T</returns>
+        public static T JsonToObject<T>(string json)
+        {
+            Type type = typeof(T);
+            return (T)LZ4MessagePackSerializer.NonGeneric.Deserialize(type, JsonToByte(json));
+        }
+
+        /// <summary>
+        /// 对象转Byte
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns>byte[]</returns>
+        public static byte[] ObjectToByte(Object obj)
+        {
+            return LZ4MessagePackSerializer.Serialize(obj);
+        }
+
+        /// <summary>
+        /// 对象转Json
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns>string</returns>
+        public static string ObjectToJson(Object obj)
+        {
+            return LZ4MessagePackSerializer.ToJson(ObjectToByte(obj));
+        }
+
+        /// <summary>
+        /// byte转Json
+        /// </summary>
+        /// <param name="bt"></param>
+        /// <returns></returns>
+        public static string ByteToJson(byte[] bt)
+        {
+            return LZ4MessagePackSerializer.ToJson(bt);
+        }
+
+        /// <summary>
+        /// byte转对象
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="bt"></param>
+        /// <returns></returns>
+        public static T ByteToObject<T>(byte[] bt)
+        {
+            Type type = typeof(T);
+            return (T)LZ4MessagePackSerializer.NonGeneric.Deserialize(type, bt);
+        }
+    }
+}

+ 35 - 0
TEAMModelOS.SDK/Helper/Common/ReflectorExtensions/ReflectorExtensions.cs

@@ -0,0 +1,35 @@
+using AspectCore.Extensions.Reflection;
+using System;
+using System.Reflection;
+
+namespace TEAMModelOS.SDK.Helper.Common.ReflectorExtensions
+{
+    public static class ReflectorExtensions
+    {
+        public static T GetPropertyValue<T>(this object obj, string name, BindingFlags bindingFlags) where T : class
+        {
+            var chProperty = obj.GetType().GetTypeInfo().GetProperty(name, bindingFlags);
+            var chReflector = chProperty.GetReflector();
+            var value = chReflector.GetValue(obj) as T;
+
+            return value;
+        }
+
+        public static Tuple<T, FieldInfo> GetFieldValue<T>(this object obj, string name, BindingFlags bindingFlags) where T : class
+        {
+            var chField = obj.GetType().GetTypeInfo().GetField(name, bindingFlags);
+            var chReflector = chField.GetReflector();
+            var value = chReflector.GetValue(obj) as T;
+
+            return Tuple.Create(value, chField);
+        }
+
+        public static T GetFieldValue<T>(this Type type, string name, BindingFlags bindingFlags) where T : class
+        {
+            var chField = type.GetTypeInfo().GetField(name, bindingFlags);
+            var chReflector = chField.GetReflector();
+            var value = chReflector.GetValue(null) as T;
+            return value;
+        }
+    }
+}

+ 77 - 0
TEAMModelOS.SDK/Helper/Common/StringHelper/StringHelper.cs

@@ -0,0 +1,77 @@
+using System;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Common.StringHelper
+{
+    public class StringHelper
+    {
+        #region 截取字符串
+        public static string GetSubString(string pSrcString, int pLength, string pTailString)
+        {
+            return GetSubString(pSrcString, 0, pLength, pTailString);
+        }
+        public static string GetSubString(string pSrcString, int pStartIndex, int pLength, string pTailString)
+        {
+            string str = pSrcString;
+            byte[] bytes = Encoding.UTF8.GetBytes(pSrcString);
+            foreach (char ch in Encoding.UTF8.GetChars(bytes))
+            {
+                if (((ch > 'ࠀ') && (ch < '一')) || ((ch > 0xac00) && (ch < 0xd7a3)))
+                {
+                    if (pStartIndex >= pSrcString.Length)
+                    {
+                        return "";
+                    }
+                    return pSrcString.Substring(pStartIndex, ((pLength + pStartIndex) > pSrcString.Length) ? (pSrcString.Length - pStartIndex) : pLength);
+                }
+            }
+            if (pLength < 0)
+            {
+                return str;
+            }
+            byte[] sourceArray = Encoding.Default.GetBytes(pSrcString);
+            if (sourceArray.Length <= pStartIndex)
+            {
+                return str;
+            }
+            int length = sourceArray.Length;
+            if (sourceArray.Length > (pStartIndex + pLength))
+            {
+                length = pLength + pStartIndex;
+            }
+            else
+            {
+                pLength = sourceArray.Length - pStartIndex;
+                pTailString = "";
+            }
+            int num2 = pLength;
+            int[] numArray = new int[pLength];
+            byte[] destinationArray = null;
+            int num3 = 0;
+            for (int i = pStartIndex; i < length; i++)
+            {
+                if (sourceArray[i] > 0x7f)
+                {
+                    num3++;
+                    if (num3 == 3)
+                    {
+                        num3 = 1;
+                    }
+                }
+                else
+                {
+                    num3 = 0;
+                }
+                numArray[i] = num3;
+            }
+            if ((sourceArray[length - 1] > 0x7f) && (numArray[pLength - 1] == 1))
+            {
+                num2 = pLength + 1;
+            }
+            destinationArray = new byte[num2];
+            Array.Copy(sourceArray, pStartIndex, destinationArray, 0, num2);
+            return (Encoding.Default.GetString(destinationArray) + pTailString);
+        }
+        #endregion
+    }
+}

+ 65 - 0
TEAMModelOS.SDK/Helper/Common/ValidateHelper/ValidateHelper.cs

@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel.DataAnnotations;
+
+namespace TEAMModelOS.SDK.Helper.Common.ValidateHelper
+{
+    public static class ValidateHelper
+    {
+        public static string AllowCountry { get; set; }
+        /// <summary>
+        /// 验证对象是否有效
+        /// </summary>
+        /// <param name="obj">要验证的对象</param>
+        /// <param name="validationResults"></param>
+        /// <returns></returns>
+        public static bool IsValid(this object obj, Collection<ValidationResult> validationResults)
+        {
+            return Validator.TryValidateObject(obj, new ValidationContext(obj, null, null), validationResults, true);
+        }
+
+        /// <summary>
+        /// 验证对象是否有效
+        /// </summary>
+        /// <param name="obj">要验证的对象</param>
+        /// <returns></returns>
+        public static T ValidObj<T>(T value)
+        {
+            var results = new Collection<ValidationResult>();
+            var validationContext = new ValidationContext(value, null, null);
+            bool f = Validator.TryValidateObject(value, validationContext, results, true);
+            if (f)
+            {
+                return value;
+            }
+            else
+            {
+                return default(T);
+            }
+        }
+        /// <summary>
+        /// 验证对象是否有效
+        /// </summary>
+        /// <param name="obj">要验证的对象</param>
+        /// <returns></returns>
+        public static bool IsValid(object value)
+        {
+            var results = new Collection<ValidationResult>();
+            var validationContext = new ValidationContext(value, null, null);
+            bool f = Validator.TryValidateObject(value, validationContext, results, true);
+            if (!f)
+            {
+                string s = "";
+                foreach (ValidationResult result in results)
+                {
+                    IEnumerator<string> enumerator = result.MemberNames.GetEnumerator();
+                    enumerator.MoveNext();
+                    s = s + enumerator.Current + ",";
+                }
+                throw new Exception(s + "字段不正确");
+            }
+            return f;
+        }
+    }
+}

+ 96 - 0
TEAMModelOS.SDK/Helper/Network/HttpHelper/HttpContextHelper.cs

@@ -0,0 +1,96 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Primitives;
+using System;
+using System.Linq;
+
+namespace TEAMModelOS.SDK.Helper.Network.HttpHelper
+{
+    public static class HttpContextHelper
+    {
+        /// <summary>
+        /// 设置本地cookie
+        /// </summary>
+        /// <param name="key">键</param>
+        /// <param name="value">值</param>  
+        /// <param name="minutes">过期时长,单位:分钟</param>      
+        public static void SetCookies(HttpResponse Response, string key, string value, int minutes = 30)
+        {
+            Response.Cookies.Append(key, value, new CookieOptions
+            {
+                Expires = DateTime.Now.AddMinutes(minutes)
+            });
+        }
+        /// <summary>
+        /// 删除指定的cookie
+        /// </summary>
+        /// <param name="key">键</param>
+        public static void DeleteCookies(HttpContext httpContext, string key)
+        {
+            httpContext.Response.Cookies.Delete(key);
+        }
+
+        /// <summary>
+        /// 在Http中获取值
+        /// </summary>
+        /// <param name="key">键</param>
+        /// <returns>返回对应的值</returns>
+        public static string GetValueInHttp(HttpRequest Request, string key)
+        {
+            string aktoken = "";
+            if (string.IsNullOrEmpty(aktoken))
+            {
+                //或者在头获取
+                Request.Headers.TryGetValue(key, out StringValues akh);
+                if (!string.IsNullOrEmpty(akh))
+                {
+                    aktoken = akh;
+                }
+            }
+            if (string.IsNullOrEmpty(aktoken))
+            {
+                //其次在参数中获取
+                Request.Query.TryGetValue(key, out StringValues ak);
+                if (!string.IsNullOrEmpty(ak))
+                {
+                    aktoken = ak;
+                }
+            }
+            //从cookie获取
+            if (string.IsNullOrEmpty(aktoken))
+            {
+                Request.Cookies.TryGetValue(key, out string value);
+                if (!string.IsNullOrEmpty(value))
+                {
+                    aktoken = value;
+                }
+            }
+            if (string.IsNullOrEmpty(aktoken))
+            {
+                //在referer获取
+                Request.Headers.TryGetValue("referer", out StringValues referer);
+                string token = "";
+                if (referer.Contains(key + "="))
+                {
+                    string[] pramas = referer[0].Substring(referer[0].IndexOf(key + "=")).Split("&");
+                    int len = pramas.Count();
+                    if (len > 0)
+                    {
+                        for (int i = 0; i < len; i++)
+                        {
+                            if (pramas[i].Contains(key))
+                            {
+                                token = pramas[i].Split("=")[1];
+                                break;
+                            }
+                        }
+                    }
+                }
+                if (!string.IsNullOrEmpty(token))
+                {
+                    aktoken = token;
+                }
+            }
+            return aktoken;
+        }
+    }
+}

+ 186 - 0
TEAMModelOS.SDK/Helper/Network/HttpHelper/HttpHelper.cs

@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.SDK.Helper.Network.HttpHelper
+{
+    public class HttpHelper
+    {
+        /// <summary>
+        /// 同步GET请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="headers"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <returns></returns>
+        public static string HttpGet(string url, Dictionary<string, string> headers = null, int timeout = 0)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                Byte[] resultBytes = client.GetByteArrayAsync(url).Result;
+                return Encoding.UTF8.GetString(resultBytes);
+            }
+        }
+
+        /// <summary>
+        /// 异步GET请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="headers"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <returns></returns>
+        public static async Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null, int timeout = 0)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                Byte[] resultBytes = await client.GetByteArrayAsync(url);
+                return Encoding.Default.GetString(resultBytes);
+            }
+        }
+
+
+        /// <summary>
+        /// 同步POST请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="postData"></param>
+        /// <param name="headers"></param>
+        /// <param name="contentType"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <param name="encoding">默认UTF8</param>
+        /// <returns></returns>
+        public static string HttpPost(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                using (HttpContent content = new StringContent(postData ?? "", encoding ?? Encoding.UTF8))
+                {
+                    if (contentType != null)
+                    {
+                        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
+                    }
+                    using (HttpResponseMessage responseMessage = client.PostAsync(url, content).Result)
+                    {
+                        Byte[] resultBytes = responseMessage.Content.ReadAsByteArrayAsync().Result;
+                        return Encoding.UTF8.GetString(resultBytes);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 异步POST请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="postData"></param>
+        /// <param name="headers"></param>
+        /// <param name="contentType"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <param name="encoding">默认UTF8</param>
+        /// <returns></returns>
+        public static async Task<string> HttpPostAsync(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                using (HttpContent content = new StringContent(postData ?? "", encoding ?? Encoding.UTF8))
+                {
+                    if (contentType != null)
+                    {
+                        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
+                    }
+                    using (HttpResponseMessage responseMessage = await client.PostAsync(url, content))
+                    {
+                        Byte[] resultBytes = await responseMessage.Content.ReadAsByteArrayAsync();
+                        return Encoding.UTF8.GetString(resultBytes);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 异步POST请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="postData"></param>
+        /// <param name="headers"></param>
+        /// <param name="contentType"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <param name="encoding">默认UTF8</param>
+        /// <returns></returns>
+        public static async Task<string> HttpPostAsync(string url, List<KeyValuePair<string, string>> postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                using (HttpContent content = new FormUrlEncodedContent(postData))
+                {
+                    if (contentType != null)
+                    {
+                        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
+                    }
+                    using (HttpResponseMessage responseMessage = await client.PostAsync(url, content))
+                    {
+                        Byte[] resultBytes = await responseMessage.Content.ReadAsByteArrayAsync();
+                        return Encoding.UTF8.GetString(resultBytes);
+                    }
+                }
+            }
+        }
+    }
+}

+ 86 - 0
TEAMModelOS.SDK/Helper/Network/NetworkHelper/NetworkHelper.cs

@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.NetworkInformation;
+using System.Net.Sockets;
+
+namespace TEAMModelOS.SDK.Helper.Network.NetworkHelper
+{
+    public static class NetHelper
+    {
+        /// <summary>
+        /// The ip segment regex
+        /// </summary>
+        private const string IPSegmentRegex = @"\d{0,3}";
+
+        /// <summary>
+        /// Gets the ip.
+        /// </summary>
+        /// <param name="ipSegment">ip段</param>
+        /// <returns></returns>
+        public static string GetIp(string ipSegment)
+        {
+            if (string.IsNullOrWhiteSpace(ipSegment))
+                throw new ArgumentNullException(nameof(ipSegment));
+
+            //如果设置的IP支持* 的时候,再去智能的选择ip
+            if (!ipSegment.Contains("*"))
+            {
+                return ipSegment;
+            }
+
+            ipSegment = ipSegment.Replace("*", IPSegmentRegex).Replace(".", "\\.");
+
+            var hostAddrs = NetworkInterface.GetAllNetworkInterfaces()
+            .Where(i => i.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
+                .SelectMany(i => i.GetIPProperties().UnicastAddresses)
+                .Select(a => a.Address)
+                .Where(a => !(a.IsIPv6LinkLocal || a.IsIPv6Multicast || a.IsIPv6SiteLocal || a.IsIPv6Teredo))
+                .ToList();
+
+            foreach (var ip in hostAddrs)
+            {
+                if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork
+                    && System.Text.RegularExpressions.Regex.IsMatch(ip.ToString(), ipSegment))
+                {
+                    return ip.ToString();
+                }
+            }
+
+            throw new Exception($"找不到ipsegement:{ipSegment}匹配的ip, OR No network adapters with an IPv4 address in the system!");
+        }
+
+        /// <summary>
+        /// 解析ip和port
+        /// </summary>
+        /// <param name="serviceAddress"></param>
+        /// <returns></returns>
+        public static Tuple<string, int> GetIPAndPort(string serviceAddress)
+        {
+            //解析ip
+            var ipPort = serviceAddress.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
+            var ip = NetHelper.GetIp(ipPort[0]);
+            //解析port
+            var port = 0;
+            if (ipPort.Length == 2)
+            {
+                int.TryParse(ipPort[1], out port);
+            }
+            return Tuple.Create(ip, port);
+        }
+
+        /// <summary>
+        ///   获取所有网卡IP地址
+        /// </summary>
+        /// <returns></returns>
+        public static List<string> getIPAddress()
+        {
+            return NetworkInterface.GetAllNetworkInterfaces()
+            .SelectMany(i => i.GetIPProperties().UnicastAddresses)
+            .Select(a => a.Address)
+            //AddressFamily.InterNetwork  过滤掉IPV6  //过滤127.0.0.1  !IPAddress.IsLoopback(a)
+            .Where(a => a.AddressFamily == AddressFamily.InterNetwork)
+            .Select(a => a.ToString()).ToList();
+        }
+    }
+}

+ 175 - 0
TEAMModelOS.SDK/Helper/Query/LinqHelper/DynamicLinq.cs

@@ -0,0 +1,175 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+
+namespace TEAMModelOS.SDK.Helper.Query.LinqHelper
+{
+    public static class DynamicLinq
+    {
+        /// <summary>
+        /// 创建参数表达式
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        public static ParameterExpression CreateLambdaParam<T>(string name)
+        {
+            return Expression.Parameter(typeof(T), name);
+        }
+
+        /// <summary>
+        /// 创建linq表达示的body部分
+        /// </summary>
+        public static Expression GenerateBody<T>(this ParameterExpression param, Filter filterObj)
+        {
+            PropertyInfo property = typeof(T).GetProperty(filterObj.Key);
+
+            //组装左边
+            Expression left = Expression.Property(param, property);
+            //组装右边
+            Expression right = null;
+
+            if (property.PropertyType == typeof(int))
+            {
+                right = Expression.Constant(int.Parse(filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(DateTime))
+            {
+                right = Expression.Constant(DateTime.Parse(filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(string))
+            {
+                right = Expression.Constant((filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(decimal))
+            {
+                right = Expression.Constant(decimal.Parse(filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(Guid))
+            {
+                right = Expression.Constant(Guid.Parse(filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(bool))
+            {
+                right = Expression.Constant(filterObj.Value.Equals("1"));
+            }
+            else if (property.PropertyType == typeof(Guid?))
+            {
+                left = Expression.Property(left, "Value");
+                right = Expression.Constant(Guid.Parse(filterObj.Value));
+            }
+            else
+            {
+                throw new Exception("暂不能解析该Key的类型");
+            }
+
+            //c.XXX=="XXX"
+            Expression filter = Expression.Equal(left, right);
+            switch (filterObj.Contrast)
+            {
+                case "<=":
+                    filter = Expression.LessThanOrEqual(left, right);
+                    break;
+
+                case "<":
+                    filter = Expression.LessThan(left, right);
+                    break;
+
+                case ">":
+                    filter = Expression.GreaterThan(left, right);
+                    break;
+
+                case ">=":
+                    filter = Expression.GreaterThanOrEqual(left, right);
+                    break;
+                case "!=":
+                    filter = Expression.NotEqual(left, right);
+                    break;
+
+                case "like":
+                    filter = Expression.Call(left, typeof(string).GetMethod("Contains", new Type[] { typeof(string) }),
+                                 Expression.Constant(filterObj.Value));
+                    break;
+                case "not in":
+                    var listExpression = Expression.Constant(filterObj.Value.Split(',').ToList()); //数组
+                    var method = typeof(List<string>).GetMethod("Contains", new Type[] { typeof(string) }); //Contains语句
+                    filter = Expression.Not(Expression.Call(listExpression, method, left));
+                    break;
+                case "in":
+                    var lExp = Expression.Constant(filterObj.Value.Split(',').ToList()); //数组
+                    var methodInfo = typeof(List<string>).GetMethod("Contains", new Type[] { typeof(string) }); //Contains语句
+                    filter = Expression.Call(lExp, methodInfo, left);
+                    break;
+            }
+
+            return filter;
+        }
+
+
+
+        public static Expression<Func<T, bool>> GenerateTypeBody<T>(this ParameterExpression param, Filter filterObj)
+        {
+            return (Expression<Func<T, bool>>)(param.GenerateBody<T>(filterObj));
+        }
+
+        /// <summary>
+        /// 创建完整的lambda
+        /// </summary>
+        public static LambdaExpression GenerateLambda(this ParameterExpression param, Expression body)
+        {
+            //c=>c.XXX=="XXX"
+            return Expression.Lambda(body, param);
+        }
+
+        public static Expression<Func<T, bool>> GenerateTypeLambda<T>(this ParameterExpression param, Expression body)
+        {
+            return (Expression<Func<T, bool>>)(param.GenerateLambda(body));
+        }
+
+        public static Expression AndAlso(this Expression expression, Expression expressionRight)
+        {
+            return Expression.AndAlso(expression, expressionRight);
+        }
+
+        public static Expression Or(this Expression expression, Expression expressionRight)
+        {
+            return Expression.Or(expression, expressionRight);
+        }
+
+        public static Expression And(this Expression expression, Expression expressionRight)
+        {
+            return Expression.And(expression, expressionRight);
+        }
+
+
+        public static IQueryable<T> Where<T>(this IQueryable<T> query, Expression expression)
+        {
+            Expression expr = Expression.Call(typeof(Queryable), "Where", new[] { typeof(T) },
+               Expression.Constant(query), expression);
+            //生成动态查询
+            IQueryable<T> result = query.Provider.CreateQuery<T>(expr);
+            return result;
+        }
+
+        public static IQueryable<T> GenerateFilter<T>(this IQueryable<T> query, IEnumerable<Filter> filters)
+        {
+            if (filters != null)
+            {
+                // var filters = JsonHelper.Instance.Deserialize<IEnumerable<Filter>>(filterjson);
+                var param = CreateLambdaParam<T>("c");
+                //条件为ture
+                Expression result = Expression.Constant(true);
+                foreach (var filter in filters)
+                {
+                    result = result.AndAlso(param.GenerateBody<T>(filter));
+
+                }
+
+                query = query.Where(param.GenerateTypeLambda<T>(result));
+            }
+            return query;
+        }
+    }
+}

文件差异内容过多而无法显示
+ 2336 - 0
TEAMModelOS.SDK/Helper/Query/LinqHelper/DynamicQueryable.cs


+ 13 - 0
TEAMModelOS.SDK/Helper/Query/LinqHelper/Filter.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Query.LinqHelper
+{
+    public class Filter
+    {
+        public string Key { get; set; }
+        public string Value { get; set; }
+        public string Contrast { get; set; }
+    }
+}

文件差异内容过多而无法显示
+ 218 - 0
TEAMModelOS.SDK/Helper/Security/AESCrypt/AESCrypt.cs


+ 29 - 0
TEAMModelOS.SDK/Helper/Security/BCryptHelper/BCryptHelper.cs

@@ -0,0 +1,29 @@
+
+namespace TEAMModelOS.SDK.Helper.Security.BCryptHelper
+{
+    /// <summary>
+    /// BCrypt散列加密算法
+    /// </summary>
+    public class BCryptHelper
+    {
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="code"></param>
+        /// <returns></returns>
+        public static string Ecrypt(string code)
+        {
+            return BCrypt.Net.BCrypt.EnhancedHashPassword(code);
+        }
+        /// <summary>
+        /// 验证
+        /// </summary>
+        /// <param name="code"></param>
+        /// <param name="encode"></param>
+        /// <returns></returns>
+        public static bool Verify(string code, string encode)
+        {
+            return BCrypt.Net.BCrypt.EnhancedVerify(code, encode);
+        }
+    }
+}

+ 69 - 0
TEAMModelOS.SDK/Helper/Security/Base64Crypt/Base64Crypt.cs

@@ -0,0 +1,69 @@
+using System;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Security.Base64Crypt
+{
+    public static class Base64Crypt
+    {
+        /// <summary>
+        /// Base64加密
+        /// </summary>
+        /// <param name="codeName">加密采用的编码方式</param>
+        /// <param name="source">待加密的明文</param>
+        /// <returns></returns>
+        public static string EncodeBase64(Encoding encode, string source)
+        {
+            byte[] bytes = encode.GetBytes(source);
+            try
+            {
+                source = Convert.ToBase64String(bytes);
+            }
+            catch (System.Exception e)
+            {
+                String s = e.StackTrace;
+            }
+            return source;
+        }
+
+        /// <summary>
+        /// Base64加密,采用utf8编码方式加密
+        /// </summary>
+        /// <param name="source">待加密的明文</param>
+        /// <returns>加密后的字符串</returns>
+        public static string EncodeBase64(string source)
+        {
+            return EncodeBase64(Encoding.UTF8, source);
+        }
+
+        /// <summary>
+        /// Base64解密
+        /// </summary>
+        /// <param name="codeName">解密采用的编码方式,注意和加密时采用的方式一致</param>
+        /// <param name="result">待解密的密文</param>
+        /// <returns>解密后的字符串</returns>
+        public static string DecodeBase64(Encoding encode, string result)
+        {
+            string decode = "";
+            byte[] bytes = Convert.FromBase64String(result);
+            try
+            {
+                decode = encode.GetString(bytes);
+            }
+            catch
+            {
+                decode = result;
+            }
+            return decode;
+        }
+
+        /// <summary>
+        /// Base64解密,采用utf8编码方式解密
+        /// </summary>
+        /// <param name="result">待解密的密文</param>
+        /// <returns>解密后的字符串</returns>
+        public static string DecodeBase64(string result)
+        {
+            return DecodeBase64(Encoding.UTF8, result);
+        }
+    }
+}

+ 133 - 0
TEAMModelOS.SDK/Helper/Security/DesCrypt/DES3Crypt.cs

@@ -0,0 +1,133 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Security.DesCrypt
+{
+    /// <summary>
+    ///3DES加密解密程序
+    /// --备用
+    /// </summary>
+    public class DES3Crypt
+    {
+        //密钥
+
+        private static string sKey = "qJzGEh6hESZDVJeCnFPGuxzaiFYTLQM3";
+
+        //矢量,矢量可以为空
+
+        private static string sIV = "qcDY6X+aPLw=";
+
+        //构造一个对称算法
+
+        private static SymmetricAlgorithm mCSP = new TripleDESCryptoServiceProvider();
+
+
+
+        public DES3Crypt() { }
+
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="Value">明文</param>
+        /// <returns>加密后的密文</returns>
+        public static string EncryptString(string Value)
+        {
+            try
+            {
+
+                ICryptoTransform ct;
+
+                MemoryStream ms;
+
+                CryptoStream cs;
+
+                byte[] byt;
+
+                mCSP.Key = Convert.FromBase64String(sKey);
+
+                mCSP.IV = Convert.FromBase64String(sIV);
+
+                //指定加密的运算模式
+
+                mCSP.Mode = System.Security.Cryptography.CipherMode.ECB;
+
+                //获取或设置加密算法的填充模式
+
+                mCSP.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
+
+                ct = mCSP.CreateEncryptor(mCSP.Key, mCSP.IV);
+
+                byt = Encoding.UTF8.GetBytes(Value + "_0212YUAN");
+
+                ms = new MemoryStream();
+
+                cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
+
+                cs.Write(byt, 0, byt.Length);
+
+                cs.FlushFinalBlock();
+
+                cs.Close();
+
+                return Convert.ToBase64String(ms.ToArray());
+            }
+            catch (Exception ex)
+            {
+                var s = ex.Message;
+                return Value;
+            }
+
+        }
+
+        /// <summary>
+        /// 解密
+        /// </summary>
+        /// <param name="Value"></param>
+        /// <returns></returns>
+        public static string DecryptString(string Value)
+        {
+            try
+            {
+
+                ICryptoTransform ct;
+
+                MemoryStream ms;
+
+                CryptoStream cs;
+
+                byte[] byt;
+
+                mCSP.Key = Convert.FromBase64String(sKey);
+
+                mCSP.IV = Convert.FromBase64String(sIV);
+
+                mCSP.Mode = System.Security.Cryptography.CipherMode.ECB;
+
+                mCSP.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
+
+                ct = mCSP.CreateDecryptor(mCSP.Key, mCSP.IV);
+
+                byt = Convert.FromBase64String(Value);
+
+                ms = new MemoryStream();
+
+                cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
+
+                cs.Write(byt, 0, byt.Length);
+
+                cs.FlushFinalBlock();
+
+                cs.Close();
+
+                return Encoding.UTF8.GetString(ms.ToArray()).Remove(Encoding.UTF8.GetString(ms.ToArray()).Length - 9, 9);
+            }
+            catch (Exception ex)
+            {
+                var s = ex.Message;
+                return Value;
+            }
+        }
+    }
+}

+ 97 - 0
TEAMModelOS.SDK/Helper/Security/DesCrypt/DESCrypt.cs

@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+using TEAMModelOS.SDK.Helper.Common.StringHelper;
+
+namespace TEAMModelOS.SDK.Helper.Security.DesCrypt
+{
+    public class DESCrypt
+    {
+        #region  ========算法========
+        private static string key;//密钥
+        static DESCrypt()
+        {
+            key = "HaBook.TeamModel.SDK";
+        }
+        private static byte[] Keys = new byte[] { 0x12, 0x34, 0x56, 120, 0x90, 0xab, 0xcd, 0xef };//8个bit位,是DES算法的初始化向量  加解密钥也是8位;
+        /// <summary>
+        /// 解密字符串
+        /// </summary>
+        /// <param name="decryptString">是要被解密的密文数据</param>
+        /// <param name="decryptKey">DES算法的工作密钥</param>
+        /// <returns>明文</returns>
+        public static string Decrypt(string decryptString, string decryptKey)
+        {
+            try
+            {
+                decryptKey = StringHelper.GetSubString(decryptKey, 8, "");
+                decryptKey = decryptKey.PadRight(8, ' ');
+                byte[] bytes = Encoding.UTF8.GetBytes(decryptKey);
+                byte[] keys = Keys;
+                byte[] buffer = Convert.FromBase64String(decryptString);
+                DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
+                MemoryStream stream = new MemoryStream();
+                CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(bytes, keys), CryptoStreamMode.Write);
+                stream2.Write(buffer, 0, buffer.Length);
+                stream2.FlushFinalBlock();
+                return Encoding.UTF8.GetString(stream.ToArray());
+            }
+            catch
+            {
+                return "";
+            }
+        }
+
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="decryptString">要被加密数据</param>
+        /// <param name="decryptKey">DES算法的工作密钥</param>
+        /// <returns>密文</returns>
+        public static string Encrypt(string encryptString, string encryptKey)
+        {
+            encryptKey = StringHelper.GetSubString(encryptKey, 8, "");
+            encryptKey = encryptKey.PadRight(8, ' ');
+            byte[] bytes = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
+            byte[] keys = Keys;
+            byte[] buffer = Encoding.UTF8.GetBytes(encryptString);
+            DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
+            MemoryStream stream = new MemoryStream();
+            CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(bytes, keys), CryptoStreamMode.Write);
+            stream2.Write(buffer, 0, buffer.Length);
+            stream2.FlushFinalBlock();
+            return Convert.ToBase64String(stream.ToArray());//Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,Base64要求把每三个8Bit的字节转换为四个6Bit的字节(3*8 = 4*6 = 24),然后把6Bit再添两位高位0,组成四个8Bit的字节。
+            //Base64编码可用于在HTTP环境下传递较长的标识信息,如较长的唯一标识符(一般为128-bit的UUID)编码为一个字符串,用作HTTP表单和HTTP GET URL中的参数,或者将二进制数据编码为适合放在URL(包括隐藏表单域)中的形式。此时,采用Base64编码不仅比较简短,同时也具有不可读性,即所编码的数据不会被人用肉眼所直接看到。
+        }
+        #endregion
+
+        #region ========加密========
+
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="Text"></param>
+        /// <returns></returns>
+        public static string Encrypt(string Text)
+        {
+            return Encrypt(Text, key);
+        }
+        #endregion
+
+        #region ========解密========
+
+        /// <summary>
+        /// 解密
+        /// </summary>
+        /// <param name="Text"></param>
+        /// <returns></returns>
+        public static string Decrypt(string Text)
+        {
+            return Decrypt(Text, key);
+        }
+        #endregion
+
+    }
+}

+ 87 - 0
TEAMModelOS.SDK/Helper/Security/Md5Hash/Md5Hash.cs

@@ -0,0 +1,87 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Helper.Security.Md5Hash
+{
+    public  class Md5Hash
+    {
+        #region MD5加密字符串处理
+        /// <summary>
+        /// MD5加密字符串处理
+        /// </summary>
+        /// <param name="half">加密是16位还是32位;如果为true为16位</param>
+        /// <param name="input">待加密码字符串</param>
+        /// <returns></returns>
+        public static string Encrypt(string input, bool half)
+        {
+            using (var md5 = MD5.Create())
+            {
+                var result = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
+                var strResult = BitConverter.ToString(result);
+                strResult = strResult.Replace("-", "");
+                if (half)//16位MD5加密(取32位加密的9~25字符)
+                {
+                    strResult = strResult?.Substring(8, 16);
+                }
+                return strResult;
+            }
+        }
+        #endregion
+
+        /// <summary>
+        /// MD5加密
+        /// </summary>
+        /// <param name="strPwd">加密的字符串</param>
+        /// <returns></returns>
+        public static string Encrypt(string strPwd)
+        {
+            MD5 md5 = new MD5CryptoServiceProvider();
+            byte[] data = System.Text.Encoding.Default.GetBytes(strPwd);
+            byte[] result = md5.ComputeHash(data);
+            string ret = "";
+            for (int i = 0; i < result.Length; i++)
+                ret += result[i].ToString("x").PadLeft(2, '0');
+            return ret;
+        }
+
+        public static string GetMd5String(string str)
+        {
+            MD5 md5 = MD5.Create();
+            byte[] data = Encoding.UTF8.GetBytes(str);
+            byte[] enData = md5.ComputeHash(data);
+            return GetbyteToString(enData);
+        }
+
+        public static string GetMD5String(string str, HashAlgorithm hash)
+        {
+
+            byte[] data = Encoding.UTF8.GetBytes(str);
+            byte[] data2 = hash.ComputeHash(data);
+            return GetbyteToString(data2);
+        }
+
+        public static string GetMD5FromFile(string path)
+        {
+            MD5 md5 = MD5.Create();
+            if (!File.Exists(path))
+            {
+                return "";
+            }
+            FileStream stream = File.OpenRead(path);
+            byte[] data2 = md5.ComputeHash(stream);
+            return GetbyteToString(data2);
+            //return BitConverter.ToString(data2).Replace("-", "").ToLower();
+        }
+        private static string GetbyteToString(byte[] data)
+        {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < data.Length; i++)
+            {
+                sb.Append(data[i].ToString("x2"));
+            }
+            return sb.ToString();
+        }
+    }
+}

+ 62 - 0
TEAMModelOS.SDK/Helper/Security/RSACrypt/RSACrypt.cs

@@ -0,0 +1,62 @@
+using System.Collections.Generic;
+using System.Security.Cryptography;
+using System.Text;
+using XC.Framework.Security.RSAUtil;
+
+namespace TEAMModelOS.SDK.Helper.Security.RSACrypt
+{
+    /// <summary>
+    /// RSA加密解密
+    /// https://github.com/stulzq/RSAUtil
+    /// </summary>
+    public class RSACrypt
+    {
+
+        private readonly RsaPkcs1Util _RsaUtil;
+        private readonly Encoding _encoding;
+
+        /// <summary>
+        /// 获得私钥和公钥
+        /// [0]=privateKey  私钥 
+        /// [1]=publicKey  公钥
+        /// </summary>
+        /// <returns></returns>
+        public static List<string> GetKey()
+        {
+            return RsaKeyGenerator.Pkcs1Key(2048, true);
+        }
+
+        /// <summary>
+        /// 实例化
+        /// </summary>
+        /// <param name="encoding">编码类型</param>
+        /// <param name="privateKey">私钥</param>
+        /// <param name="publicKey">公钥</param>
+        public RSACrypt(string privateKey, string publicKey)
+        {
+            _encoding = Encoding.UTF8;
+            _RsaUtil = new RsaPkcs1Util(_encoding, publicKey, privateKey, 1024);
+        }
+
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="code">加密代码</param>
+        /// <returns></returns>
+        public string Encrypt(string code)
+        {
+            return _RsaUtil.Encrypt(code, RSAEncryptionPadding.Pkcs1);
+        }
+
+        /// <summary>
+        /// 解密
+        /// </summary>
+        /// <param name="code">解密代码</param>
+        /// <returns></returns>
+        public string Decrypt(string code)
+        {
+            return _RsaUtil.Decrypt(code, RSAEncryptionPadding.Pkcs1);
+        }
+
+    }
+}

+ 12 - 0
TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobConfig.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Module.AzureBlob.Configuration
+{
+    public class AzureBlobConfig
+    {
+        public readonly static string AZURE_CHINA = "AzureChina";
+        public readonly static string AZURE_GLOBAL = "AzureGlobal";
+    }
+}

+ 20 - 0
TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobOptions.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Module.AzureBlob.Configuration
+{
+   public class AzureBlobOptions
+    {
+        public string ConnectionString { get; set; } 
+        public string AzureTableDialect { get; set; }
+        public string Container { get; set; }
+        public string DialectKey { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public AzureBlobOptions()
+        {
+        }
+    }
+}

+ 24 - 0
TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobServiceBuilder.cs

@@ -0,0 +1,24 @@
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Module.AzureBlob.Configuration
+{
+     public  class AzureBlobServiceBuilder : ServiceCollection
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="services"></param>
+        public AzureBlobServiceBuilder(IServiceCollection services)
+        {
+            Services = services ?? throw new ArgumentNullException(nameof(services));
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public IServiceCollection Services { get; }
+    }
+}

+ 48 - 0
TEAMModelOS.SDK/Module/AzureBlob/Configuration/AzureBlobServiceCollectionExtensions.cs

@@ -0,0 +1,48 @@
+using TEAMModelOS.SDK.Module.AzureBlob.Implements;
+using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace TEAMModelOS.SDK.Module.AzureBlob.Configuration
+{
+    public static class AzureBlobServiceCollectionExtensions
+    {
+        public static AzureBlobServiceBuilder Builder { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="services"></param>
+        /// <returns></returns>
+        private static AzureBlobServiceBuilder AddServerBuilder(this IServiceCollection services)
+        {
+            return new AzureBlobServiceBuilder(services);
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="services"></param>
+        /// <returns></returns>
+        public static AzureBlobServiceBuilder AddAzureBlobStorage(this IServiceCollection services)
+        {
+            if (Builder == null)
+            {
+                Builder = services.AddServerBuilder();
+            }
+            services.AddSingleton<IAzureBlobDBRepository, AzureBlobDBRepository>();
+            return Builder;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="builder"></param>
+        /// <param name="_connectionString"></param>
+        /// <returns></returns>
+        public static AzureBlobServiceBuilder AddConnection(this AzureBlobServiceBuilder builder, AzureBlobOptions databaseOptions)
+        {
+            builder.Services.AddSingleton(databaseOptions);
+            return builder;
+        }
+    }
+}

+ 42 - 0
TEAMModelOS.SDK/Module/AzureBlob/Configuration/BlobClientSingleton.cs

@@ -0,0 +1,42 @@
+using Microsoft.WindowsAzure.Storage;
+using Microsoft.WindowsAzure.Storage.Blob;
+using System;
+
+namespace TEAMModelOS.SDK.Module.AzureBlob.Configuration
+{
+    public sealed class BlobClientSingleton
+    {
+        private static string _connectionString;
+        private CloudBlobClient BlobClient;
+
+        private BlobClientSingleton() { }
+
+        public CloudBlobClient GetBlobClient()
+        {
+            if (BlobClient != null)
+            {
+                return BlobClient;
+            }
+            else
+            {
+                getInstance(_connectionString);
+                return BlobClient;
+            }
+        }
+
+        public static BlobClientSingleton getInstance(string connectionString)
+        {
+            _connectionString = connectionString;
+            return SingletonInstance.instance;
+        }
+
+        private static class SingletonInstance
+        {
+            public static BlobClientSingleton instance = new BlobClientSingleton()
+            {
+               // BlobClient = CloudStorageAccount.Parse(_connectionString).CreateCloudBlobClient()
+               BlobClient = new  CloudBlobClient(new Uri(_connectionString))
+            };
+        }
+    }
+}

+ 72 - 0
TEAMModelOS.SDK/Module/AzureBlob/Container/AzureBlobModel.cs

@@ -0,0 +1,72 @@
+using MessagePack;
+using Microsoft.AspNetCore.Http;
+using Microsoft.WindowsAzure.Storage.Table;
+using System;
+using TEAMModelOS.SDK.Helper.Common.DateTimeHelper;
+
+namespace TEAMModelOS.SDK.Module.AzureBlob.Container
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class AzureBlobModel : TableEntity
+    {
+
+
+        public AzureBlobModel()
+        {
+            long time = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+            Timestamp = DateTimeHelper.ConvertToDateTime(time);
+        }
+
+        public AzureBlobModel(IFormFile f, string Container ,string groupName ,string newName)
+        {
+            long time= DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+            ContentType = f.ContentType;
+            ContentDisposition = f.ContentDisposition;
+            FileName = f.FileName;
+            // Headers = f.Headers.Values;
+            RealName =  groupName + "/"+ newName;
+            Length = f.Length;
+            Name = f.Name;
+            UploadTime = time;
+            PartitionKey = Container;
+            RowKey = Guid.NewGuid().ToString();
+            Extension = f.FileName.Substring(f.FileName.LastIndexOf(".") + 1, (f.FileName.Length - f.FileName.LastIndexOf(".") - 1)); //扩展名
+            Timestamp = DateTimeHelper.ConvertToDateTime(time);
+        }
+
+        //
+        // 摘要:
+        //     Gets the raw Content-Type header of the uploaded file.
+        public string BlobUrl { get; set; }
+
+        //
+        // 摘要:
+        //     Gets the raw Content-Type header of the uploaded file.
+        public string ContentType { get; set; }
+        //
+        // 摘要:
+        //     Gets the raw Content-Disposition header of the uploaded file.
+        public string ContentDisposition { get; set; }
+        //
+        // 摘要:
+        //     Gets the header dictionary of the uploaded file.
+      //  public IHeaderDictionary Headers { get; set; }
+        //
+        // 摘要:
+        //     Gets the file length in bytes.
+        public long Length { get; set; }
+        //
+        // 摘要:
+        //     Gets the form field name from the Content-Disposition header.
+        public string Name { get; set; }
+        //
+        // 摘要:
+        //     Gets the file name from the Content-Disposition header.
+        public string FileName { get; set; }
+        public string RealName { get; set; }
+        //上传时间戳
+        public long UploadTime { get; set; }
+        //上传扩展文件
+        public string Extension { get; set; }
+    }
+}

+ 12 - 0
TEAMModelOS.SDK/Module/AzureBlob/Container/FileContainer.cs

@@ -0,0 +1,12 @@
+namespace TEAMModelOS.SDK.Module.AzureBlob.Container
+{
+    public class FileContainer : IBlobContainer
+    {
+        public string Container { get; private set; } = "filecontainer";
+
+        public string GetContainer()
+        {
+            return Container;
+        }
+    }
+}

+ 0 - 0
TEAMModelOS.SDK/Module/AzureBlob/Container/IBlobContainer.cs


部分文件因为文件数量过多而无法显示