Browse Source

update .net 5 code

JAELYS 4 years ago
parent
commit
243fe45761

+ 9 - 19
TEAMModelOS.SDK/DI/DingDing/DingDing.cs

@@ -7,6 +7,9 @@ using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
 using System.Security.Cryptography;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.IO;
 using TEAMModelOS.SDK.Extension;
 
 namespace TEAMModelOS.SDK.DI
@@ -30,19 +33,13 @@ namespace TEAMModelOS.SDK.DI
         /// <returns></returns>
         public async Task SendBotMsg(string msg, GroupNames groupkey)
         {
-            JObject jObject = new JObject()
-            {
-                new JProperty("msgtype","text"),
-                new JProperty("text",new JObject(
-                    new JProperty("content",msg)))
-            };
-            var content = new StringContent(jObject.ToString(), Encoding.UTF8, "application/json");
+            var content = new { msgtype = "text", text = new { content = msg } };
             var keys = groupkey.GetDescriptionText().Split(',');
-            if (keys.Length == 1) await _httpClient.PostAsync($"{url}{keys[0]}", content);
+            if (keys.Length == 1) await _httpClient.PostAsJsonAsync($"{url}{keys[0]}", content);
             else
             {
                 var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                await _httpClient.PostAsync($"{url}{keys[0]}&timestamp={timestamp}&sign={BotAddSign(keys[1], timestamp)}", content);
+                await _httpClient.PostAsJsonAsync($"{url}{keys[0]}&timestamp={timestamp}&sign={BotAddSign(keys[1], timestamp)}", content);
             }
         }
 
@@ -55,20 +52,13 @@ namespace TEAMModelOS.SDK.DI
         /// <returns></returns>
         public async Task SendBotMsg(string msg, string accesstoken, string secret = null)
         {
-            JObject jObject = new JObject()
-            {
-                new JProperty("msgtype","text"),
-                new JProperty("text",new JObject(
-                    new JProperty("content",msg)))
-            };
-
-            var content = new StringContent(jObject.ToString(), Encoding.UTF8, "application/json");
+            var content = new { msgtype = "text", text = new { content = msg } };
             if (string.IsNullOrWhiteSpace(secret))
-                await _httpClient.PostAsync($"{url}{accesstoken}", content);
+                await _httpClient.PostAsJsonAsync($"{url}{accesstoken}", content);
             else
             {
                 var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                await _httpClient.PostAsync($"{url}{accesstoken}&timestamp={timestamp}&sign={BotAddSign(secret, timestamp)}", content);
+                await _httpClient.PostAsJsonAsync($"{url}{accesstoken}&timestamp={timestamp}&sign={BotAddSign(secret, timestamp)}", content);
             }
 
 

+ 12 - 11
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -11,20 +11,21 @@
   
 
   <ItemGroup>
-    <PackageReference Include="AspectCore.Extensions.Reflection" Version="2.1.0" />
+    <PackageReference Include="AspectCore.Extensions.Reflection" Version="2.2.0" />
     <PackageReference Include="Azure.Cosmos" Version="4.0.0-preview3" />
-    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.0.0" />
-    <PackageReference Include="Azure.Storage.Blobs.Batch" Version="12.4.0" />
-    <PackageReference Include="Azure.Storage.Queues" Version="12.5.0" />
-    <PackageReference Include="ClouDASLibx" Version="1.1.4" />
-    <PackageReference Include="DocumentFormat.OpenXml" Version="2.11.3" />
-    <PackageReference Include="HtmlAgilityPack" Version="1.11.28" />
+    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.1.1" />
+    <PackageReference Include="Azure.Storage.Blobs.Batch" Version="12.5.1" />
+    <PackageReference Include="Azure.Storage.Queues" Version="12.6.1" />
+    <PackageReference Include="ClouDASLibx" Version="1.2.4" />
+    <PackageReference Include="DocumentFormat.OpenXml" Version="2.12.3" />
+    <PackageReference Include="HtmlAgilityPack" Version="1.11.32" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.10" />
     <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
-    <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="3.1.10" />
+    <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="5.0.4" />
     <PackageReference Include="StackExchange.Redis" Version="2.2.4" />
-    <PackageReference Include="System.Drawing.Common" Version="5.0.0" />
-    <PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="2.0.0-preview" /> 
-    <PackageReference Include="Caching.CSRedis" Version="3.6.50" />
+    <PackageReference Include="SvgNet" Version="2.1.1" />
+    <PackageReference Include="System.Drawing.Common" Version="5.0.2" />
+    <PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="2.0.0-preview" />
+    <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
   </ItemGroup>
 </Project>

File diff suppressed because it is too large
+ 3265 - 2428
TEAMModelOS/Controllers/Analysis/AchievementController.cs


+ 4 - 7
TEAMModelOS/Startup.cs

@@ -103,13 +103,10 @@ namespace TEAMModelOS
             //HttpContextAccessor,并用来访问HttpContext。(提供組件或非控制器服務存取HttpContext)
             services.AddHttpContextAccessor();
             services.Configure<Option>(options => Configuration.GetSection("Option").Bind(options));
-
-            //注入CSRedis  
-            var csredis = new CSRedis.CSRedisClient(Configuration.GetSection("Azure:Redis:ConnectionString").Get<string>());
-            CSRedis.CSRedisClient.Serialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
-            CSRedis.CSRedisClient.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
-            RedisHelper.Initialization(csredis);
-            services.AddHtexTranslator();
+           
+            //注入word 標籤解析
+            string path = $"{ environment.ContentRootPath}/JsonFile/Core";
+            services.AddHtexTranslator(path);
         }
 
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

+ 5 - 6
TEAMModelOS/TEAMModelOS.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk.Web">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <TargetFramework>net5.0</TargetFramework>
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="Caching.CSRedis" Version="3.6.50" />
@@ -40,11 +40,10 @@
     <None Remove="ClientApp\src\static\BaseDataDefault.json" />
   </ItemGroup>
   <ItemGroup>
-    <Content Include="ClientApp\src\static\BaseDataDefault.json">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-      <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
-      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
-    </Content>
+    <PackageReference Include="DotNetZip" Version="1.15.0" />
+    <PackageReference Include="HTEXLib" Version="2.5.2" />
+    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
+    <PackageReference Include="VueCliMiddleware" Version="5.0.0" />
   </ItemGroup>
 
   <ItemGroup>