Quellcode durchsuchen

异步方法问题修复

zuohuaijun vor 3 Jahren
Ursprung
Commit
06665fc2b3

+ 6 - 4
Admin.NET/Admin.NET.Application/Service/TestService.cs

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
 using QuestPDF.Fluent;
 using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
+using QuestPDF.Previewer;
 using System.IO;
 
 namespace Admin.NET.Application.Serice;
@@ -162,9 +163,10 @@ public class TestService : IDynamicApiController, ITransient
 
     /// <summary>
     /// 生成PDF文件
+    /// 预览工具:dotnet tool install questpdf.previewer --global
     /// </summary>
     [NonUnify]
-    public dynamic CreatePDF()
+    public void CreatePDF()
     {
         var logoPath = App.WebHostEnvironment.WebRootPath + @"\images\logo.png";
         byte[] imageByte = null;
@@ -186,7 +188,7 @@ public class TestService : IDynamicApiController, ITransient
                 page.DefaultTextStyle(x => x.FontSize(18));
 
                 page.Header()
-                    .AlignCenter().Text("Admin.NET")
+                    .AlignCenter().Text("Admin.NET3333")
                     .SemiBold().FontSize(24).FontColor(Colors.Red.Medium);
 
                 page.Content()
@@ -207,8 +209,8 @@ public class TestService : IDynamicApiController, ITransient
                         x.CurrentPageNumber();
                     });
             });
-        }).GeneratePdf(filePath);
+        }).ShowInPreviewer();//.GeneratePdf(filePath);
 
-        return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = "xxx.PDF" };
+        //return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = "xxx.PDF" };
     }
 }

+ 0 - 1
Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj

@@ -30,7 +30,6 @@
     <PackageReference Include="Furion.Pure" Version="4.1.9" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.6.4" />
     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.7" />
-    <PackageReference Include="MySql.Data" Version="8.0.29" />
     <PackageReference Include="NETCore.MailKit" Version="2.1.0" />
     <PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.1.6" />
     <PackageReference Include="QuestPDF" Version="2022.6.3" />

+ 1 - 1
Admin.NET/Admin.NET.Core/Admin.NET.Core.xml

@@ -3622,7 +3622,7 @@
             <param name="cacheKey"></param>
             <returns></returns>
         </member>
-        <member name="M:Admin.NET.Core.Service.SysCacheService.Exists(System.String)">
+        <member name="M:Admin.NET.Core.Service.SysCacheService.ExistsAsync(System.String)">
             <summary>
             检查给定 key 是否存在
             </summary>

+ 4 - 4
Admin.NET/Admin.NET.Core/Service/Timer/SysTimerService.cs

@@ -124,7 +124,7 @@ public class SysTimerService : IDynamicApiController, ITransient
     /// 创建定时任务
     /// </summary>
     /// <param name="input"></param>
-    private void CreateTimer(SysTimer input)
+    private async void CreateTimer(SysTimer input)
     {
         Action<SpareTimer, long> action = null;
         switch (input.RequestType)
@@ -175,14 +175,14 @@ public class SysTimerService : IDynamicApiController, ITransient
         if (input.RequestType == RequestTypeEnum.Run)
         {
             var timerParaName = $"{input.TimerName}_para";
-            var timerPara = _sysCacheService.Exists(timerParaName);
+            var timerPara = await _sysCacheService.ExistsAsync(timerParaName);
             var requestPara = string.IsNullOrEmpty(input.RequestPara);
 
             // 若没有任务配置但存在缓存则删除
             if (requestPara && timerPara)
-                _sysCacheService.RemoveAsync(timerParaName);
+                await _sysCacheService.RemoveAsync(timerParaName);
             else if (!requestPara)
-                _sysCacheService.SetAsync(timerParaName, JSON.Deserialize<Dictionary<string, string>>(input.RequestPara));
+                await _sysCacheService.SetAsync(timerParaName, JSON.Deserialize<Dictionary<string, string>>(input.RequestPara));
         }
 
         // 创建定时任务