Explorar el Código

😂恢复本地时间格式

zuohuaijun hace 1 año
padre
commit
310132a202
Se han modificado 24 ficheros con 203 adiciones y 205 borrados
  1. 154 158
      Admin.NET/Admin.NET.Core/EventBus/RedisEventSourceStorer.cs
  2. 2 2
      Admin.NET/Admin.NET.Core/Extension/ObjectExtension.cs
  3. 1 1
      Admin.NET/Admin.NET.Core/Hub/OnlineUserHub.cs
  4. 1 1
      Admin.NET/Admin.NET.Core/Job/EnumToDictJob.cs
  5. 4 4
      Admin.NET/Admin.NET.Core/Job/LogJob.cs
  6. 1 1
      Admin.NET/Admin.NET.Core/Job/OnlineUserJob.cs
  7. 1 1
      Admin.NET/Admin.NET.Core/Logging/ElasticSearchLoggingWriter.cs
  8. 1 1
      Admin.NET/Admin.NET.Core/Logging/LogExceptionHandler.cs
  9. 1 1
      Admin.NET/Admin.NET.Core/Logging/LoggingSetup.cs
  10. 2 2
      Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs
  11. 1 1
      Admin.NET/Admin.NET.Core/Service/Common/SysCommonService.cs
  12. 1 1
      Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs
  13. 1 1
      Admin.NET/Admin.NET.Core/Service/Job/JobClusterServer.cs
  14. 1 1
      Admin.NET/Admin.NET.Core/Service/Logging/SysLogExService.cs
  15. 1 1
      Admin.NET/Admin.NET.Core/Service/Logging/SysLogOpService.cs
  16. 2 2
      Admin.NET/Admin.NET.Core/Service/Notice/SysNoticeService.cs
  17. 1 1
      Admin.NET/Admin.NET.Core/Service/Server/SysServerService.cs
  18. 7 7
      Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs
  19. 10 8
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs
  20. 1 1
      Admin.NET/Admin.NET.Core/Util/AdminResultProvider.cs
  21. 3 3
      Admin.NET/Admin.NET.Core/Util/ComputerUtil.cs
  22. 3 3
      Admin.NET/Admin.NET.Core/Util/DateTimeUtil.cs
  23. 2 2
      Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/ApprovalFlowService.cs
  24. 1 1
      Admin.NET/Plugins/Admin.NET.Plugin.DingTalk/Job/SyncDingTalkUserJob.cs

+ 154 - 158
Admin.NET/Admin.NET.Core/EventBus/RedisEventSourceStorer.cs

@@ -1,165 +1,161 @@
-// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
-//
-// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
-//
-// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
-
-using NewLife.Caching.Queues;
-using Newtonsoft.Json;
-using System.Threading.Channels;
-
-namespace Admin.NET.Core;
-
-/// <summary>
-/// Redis自定义事件源存储器
-/// </summary>
-/// <remarks>
-/// 在集群部署时,一般每一个消息只由一个服务节点消费一次。
+// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
+//
+// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
+//
+// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
+
+using NewLife.Caching.Queues;
+using Newtonsoft.Json;
+using System.Threading.Channels;
+
+namespace Admin.NET.Core;
+
+/// <summary>
+/// Redis自定义事件源存储器
+/// </summary>
+/// <remarks>
+/// 在集群部署时,一般每一个消息只由一个服务节点消费一次。
 /// 有些特殊情情要通知到服务器群中的每一个节点(比如需要强制加载某些配置、重点服务等),
-/// 在这种情况下就要以“broadcast:”开头来定义EventId,
-/// 本系统会把“broadcast:”开头的事件视为“广播消息”保证集群中的每一个服务节点都能消费得到这个消息
-/// </remarks>
-public sealed class RedisEventSourceStorer : IEventSourceStorer, IDisposable
-{
-    /// <summary>
-    /// 消费者
-    /// </summary>
-    private readonly EventConsumer<ChannelEventSource> _eventConsumer;
-
-    /// <summary>
-    /// 内存通道事件源存储器
-    /// </summary>
-    private readonly Channel<IEventSource> _channel;
-
-
-    private IProducerConsumer<ChannelEventSource> _queueSingle;
-
+/// 在这种情况下就要以“broadcast:”开头来定义EventId,
+/// 本系统会把“broadcast:”开头的事件视为“广播消息”保证集群中的每一个服务节点都能消费得到这个消息
+/// </remarks>
+public sealed class RedisEventSourceStorer : IEventSourceStorer, IDisposable
+{
+    /// <summary>
+    /// 消费者
+    /// </summary>
+    private readonly EventConsumer<ChannelEventSource> _eventConsumer;
+
+    /// <summary>
+    /// 内存通道事件源存储器
+    /// </summary>
+    private readonly Channel<IEventSource> _channel;
+
+    private IProducerConsumer<ChannelEventSource> _queueSingle;
+
     private RedisStream<string> _queueBroadcast;
 
-    /// <summary>
-    /// 路由键
-    /// </summary>
-    private readonly string _routeKey;
-
-    /// <summary>
-    /// 构造函数
-    /// </summary>
-    /// <param name="cacheProvider">Redis 连接对象</param>
-    /// <param name="routeKey">路由键</param>
-    /// <param name="capacity">存储器最多能够处理多少消息,超过该容量进入等待写入</param>
-    public RedisEventSourceStorer(ICacheProvider cacheProvider, string routeKey, int capacity)
-    {
-        // 配置通道,设置超出默认容量后进入等待
-        var boundedChannelOptions = new BoundedChannelOptions(capacity)
-        {
-            FullMode = BoundedChannelFullMode.Wait
-        };
-
-        // 创建有限容量通道
-        _channel = Channel.CreateBounded<IEventSource>(boundedChannelOptions);
-
-        //_redis = redis as FullRedis;
-        _routeKey = routeKey;
-
-        // 创建广播消息订阅者,即所有服务器节点都能收到消息(用来发布重启、Reload配置等消息)
-        FullRedis redis = (FullRedis)cacheProvider.Cache;
-        var clusterOpt = App.GetConfig<ClusterOptions>("Cluster", true);
-        _queueBroadcast = redis.GetStream<string>(routeKey + ":broadcast");
-        _queueBroadcast.Group = clusterOpt.ServerId;//根据服务器标识分配到不同的分组里
-        _queueBroadcast.Expire = TimeSpan.FromSeconds(10);//消息10秒过期()
-        _queueBroadcast.ConsumeAsync(OnConsumeBroadcast);
-
-        // 创建队列消息订阅者,只要有一个服务节点消费了消息即可
-        _queueSingle = redis.GetQueue<ChannelEventSource>(routeKey + ":single");
+    /// <summary>
+    /// 路由键
+    /// </summary>
+    private readonly string _routeKey;
+
+    /// <summary>
+    /// 构造函数
+    /// </summary>
+    /// <param name="cacheProvider">Redis 连接对象</param>
+    /// <param name="routeKey">路由键</param>
+    /// <param name="capacity">存储器最多能够处理多少消息,超过该容量进入等待写入</param>
+    public RedisEventSourceStorer(ICacheProvider cacheProvider, string routeKey, int capacity)
+    {
+        // 配置通道,设置超出默认容量后进入等待
+        var boundedChannelOptions = new BoundedChannelOptions(capacity)
+        {
+            FullMode = BoundedChannelFullMode.Wait
+        };
+
+        // 创建有限容量通道
+        _channel = Channel.CreateBounded<IEventSource>(boundedChannelOptions);
+
+        //_redis = redis as FullRedis;
+        _routeKey = routeKey;
+
+        // 创建广播消息订阅者,即所有服务器节点都能收到消息(用来发布重启、Reload配置等消息)
+        FullRedis redis = (FullRedis)cacheProvider.Cache;
+        var clusterOpt = App.GetConfig<ClusterOptions>("Cluster", true);
+        _queueBroadcast = redis.GetStream<string>(routeKey + ":broadcast");
+        _queueBroadcast.Group = clusterOpt.ServerId;//根据服务器标识分配到不同的分组里
+        _queueBroadcast.Expire = TimeSpan.FromSeconds(10);//消息10秒过期()
+        _queueBroadcast.ConsumeAsync(OnConsumeBroadcast);
+
+        // 创建队列消息订阅者,只要有一个服务节点消费了消息即可
+        _queueSingle = redis.GetQueue<ChannelEventSource>(routeKey + ":single");
         _eventConsumer = new EventConsumer<ChannelEventSource>(_queueSingle);
 
         // 订阅消息写入 Channel
-        _eventConsumer.Received += (send, cr) =>
-        {
-            var oriColor = Console.ForegroundColor;
-            ChannelEventSource ces = (ChannelEventSource)cr;
-            ConsumeChannelEventSource(ces);
-        };
-        _eventConsumer.Start();
-    }
-
-    private Task OnConsumeBroadcast(string source, Message message, CancellationToken token)
-    {
-        ChannelEventSource ces = JsonConvert.DeserializeObject<ChannelEventSource>(source);
-        ConsumeChannelEventSource(ces);
-        return Task.CompletedTask;
-    }
-
-    private void ConsumeChannelEventSource(ChannelEventSource ces)
-    {
-        //一些测试的事件就输出一下
-        if (ces.EventId != null && ces.EventId.IndexOf(":Test") > 0)
-        {
-            var oriColor = Console.ForegroundColor;
-            Console.ForegroundColor = ConsoleColor.Green;
-            Console.WriteLine($"有消息要处理{ces.EventId},{ces.Payload}");
-            Console.ForegroundColor = oriColor;
-        }
-        _channel.Writer.WriteAsync(ces);
-    }
-
-    /// <summary>
-    /// 将事件源写入存储器
-    /// </summary>
-    /// <param name="eventSource">事件源对象</param>
-    /// <param name="cancellationToken">取消任务 Token</param>
-    /// <returns><see cref="ValueTask"/></returns>
-    public async ValueTask WriteAsync(IEventSource eventSource, CancellationToken cancellationToken)
-    {
-        // 空检查
-        if (eventSource == default)
-        {
-            throw new ArgumentNullException(nameof(eventSource));
-        }
-
-        // 这里判断是否是 ChannelEventSource 或者 自定义的 EventSource
-        if (eventSource is ChannelEventSource source)
-        {
-            // 异步发布
-            await Task.Factory.StartNew(() =>
-            {
-                if (source.EventId != null && source.EventId.StartsWith("broadcast:"))
-                {
-                    string str = JsonConvert.SerializeObject(source);
-                    _queueBroadcast.Add(str);
-                }
-                else
-                {
-                    _queueSingle.Add(source);
-                }
-            }, cancellationToken, TaskCreationOptions.LongRunning, System.Threading.Tasks.TaskScheduler.Default);
-
-        }
-        else
-        {
-            // 这里处理动态订阅问题
-            await _channel.Writer.WriteAsync(eventSource, cancellationToken);
-        }
-    }
-
-    /// <summary>
-    /// 从存储器中读取一条事件源
-    /// </summary>
-    /// <param name="cancellationToken">取消任务 Token</param>
-    /// <returns>事件源对象</returns>
-    public async ValueTask<IEventSource> ReadAsync(CancellationToken cancellationToken)
-    {
-        // 读取一条事件源
-        var eventSource = await _channel.Reader.ReadAsync(cancellationToken);
-        return eventSource;
-    }
-
-    /// <summary>
-    /// 释放非托管资源
-    /// </summary>
-    public async void Dispose()
-    {
-        await _eventConsumer.Stop();
-        GC.SuppressFinalize(this);
-    }
+        _eventConsumer.Received += (send, cr) =>
+        {
+            var oriColor = Console.ForegroundColor;
+            ChannelEventSource ces = (ChannelEventSource)cr;
+            ConsumeChannelEventSource(ces);
+        };
+        _eventConsumer.Start();
+    }
+
+    private Task OnConsumeBroadcast(string source, Message message, CancellationToken token)
+    {
+        ChannelEventSource ces = JsonConvert.DeserializeObject<ChannelEventSource>(source);
+        ConsumeChannelEventSource(ces);
+        return Task.CompletedTask;
+    }
+
+    private void ConsumeChannelEventSource(ChannelEventSource ces)
+    {
+        // 打印测试事件
+        if (ces.EventId != null && ces.EventId.IndexOf(":Test") > 0)
+        {
+            var oriColor = Console.ForegroundColor;
+            Console.ForegroundColor = ConsoleColor.Green;
+            Console.WriteLine($"有消息要处理{ces.EventId},{ces.Payload}");
+            Console.ForegroundColor = oriColor;
+        }
+        _channel.Writer.WriteAsync(ces);
+    }
+
+    /// <summary>
+    /// 将事件源写入存储器
+    /// </summary>
+    /// <param name="eventSource">事件源对象</param>
+    /// <param name="cancellationToken">取消任务 Token</param>
+    /// <returns><see cref="ValueTask"/></returns>
+    public async ValueTask WriteAsync(IEventSource eventSource, CancellationToken cancellationToken)
+    {
+        // 空检查
+        if (eventSource == default)
+            throw new ArgumentNullException(nameof(eventSource));
+
+        // 这里判断是否是 ChannelEventSource 或者 自定义的 EventSource
+        if (eventSource is ChannelEventSource source)
+        {
+            // 异步发布
+            await Task.Factory.StartNew(() =>
+            {
+                if (source.EventId != null && source.EventId.StartsWith("broadcast:"))
+                {
+                    string str = JsonConvert.SerializeObject(source);
+                    _queueBroadcast.Add(str);
+                }
+                else
+                {
+                    _queueSingle.Add(source);
+                }
+            }, cancellationToken, TaskCreationOptions.LongRunning, System.Threading.Tasks.TaskScheduler.Default);
+        }
+        else
+        {
+            // 处理动态订阅问题
+            await _channel.Writer.WriteAsync(eventSource, cancellationToken);
+        }
+    }
+
+    /// <summary>
+    /// 从存储器中读取一条事件源
+    /// </summary>
+    /// <param name="cancellationToken">取消任务 Token</param>
+    /// <returns>事件源对象</returns>
+    public async ValueTask<IEventSource> ReadAsync(CancellationToken cancellationToken)
+    {
+        // 读取一条事件源
+        var eventSource = await _channel.Reader.ReadAsync(cancellationToken);
+        return eventSource;
+    }
+
+    /// <summary>
+    /// 释放非托管资源
+    /// </summary>
+    public async void Dispose()
+    {
+        await _eventConsumer.Stop();
+        GC.SuppressFinalize(this);
+    }
 }

+ 2 - 2
Admin.NET/Admin.NET.Core/Extension/ObjectExtension.cs

@@ -261,9 +261,9 @@ public static partial class ObjectExtension
     public static string ParseToDateTimeForRep(this string str)
     {
         if (string.IsNullOrWhiteSpace(str))
-            str = $"{DateTime.UtcNow.Year}/{DateTime.UtcNow.Month}/{DateTime.UtcNow.Day}";
+            str = $"{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}";
 
-        var date = DateTime.UtcNow;
+        var date = DateTime.Now;
         var reg = new Regex(@"(\{.+?})");
         var match = reg.Matches(str);
         match.ToList().ForEach(u =>

+ 1 - 1
Admin.NET/Admin.NET.Core/Hub/OnlineUserHub.cs

@@ -52,7 +52,7 @@ public class OnlineUserHub : Hub<IOnlineUserHub>
             UserId = _userManager.UserId,
             UserName = _userManager.Account,
             RealName = _userManager.RealName,
-            Time = DateTime.UtcNow,
+            Time = DateTime.Now,
             Ip = httpContext.GetRemoteIpAddressToIPv4(true),
             Browser = httpContext.GetClientBrowser(),
             Os = httpContext.GetClientOs(),

+ 1 - 1
Admin.NET/Admin.NET.Core/Job/EnumToDictJob.cs

@@ -143,7 +143,7 @@ public class EnumToDictJob : IJob
 
         var originColor = Console.ForegroundColor;
         Console.ForegroundColor = ConsoleColor.Green;
-        Console.WriteLine($"【{DateTime.UtcNow}】系统枚举转换字典");
+        Console.WriteLine($"【{DateTime.Now}】系统枚举转换字典");
         Console.ForegroundColor = originColor;
     }
 }

+ 4 - 4
Admin.NET/Admin.NET.Core/Job/LogJob.cs

@@ -32,11 +32,11 @@ public class LogJob : IJob
         var sysConfigService = serviceScope.ServiceProvider.GetRequiredService<SysConfigService>();
 
         var daysAgo = await sysConfigService.GetConfigValue<int>(CommonConst.SysLogRetentionDays); // 日志保留天数
-        await logVisRep.CopyNew().AsDeleteable().Where(u => (DateTime)u.CreateTime < DateTime.UtcNow.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除访问日志
-        await logOpRep.CopyNew().AsDeleteable().Where(u => (DateTime)u.CreateTime < DateTime.UtcNow.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除操作日志
-        await logDiffRep.CopyNew().AsDeleteable().Where(u => (DateTime)u.CreateTime < DateTime.UtcNow.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除差异日志
+        await logVisRep.CopyNew().AsDeleteable().Where(u => (DateTime)u.CreateTime < DateTime.Now.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除访问日志
+        await logOpRep.CopyNew().AsDeleteable().Where(u => (DateTime)u.CreateTime < DateTime.Now.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除操作日志
+        await logDiffRep.CopyNew().AsDeleteable().Where(u => (DateTime)u.CreateTime < DateTime.Now.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除差异日志
 
-        string msg = $"【{DateTime.UtcNow}】清理系统日志成功,删除 {daysAgo} 天前的日志数据!";
+        string msg = $"【{DateTime.Now}】清理系统日志成功,删除 {daysAgo} 天前的日志数据!";
         var originColor = Console.ForegroundColor;
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine(msg);

+ 1 - 1
Admin.NET/Admin.NET.Core/Job/OnlineUserJob.cs

@@ -34,7 +34,7 @@ public class OnlineUserJob : IJob
         // 缓存租户列表
         await serviceScope.ServiceProvider.GetRequiredService<SysTenantService>().CacheTenant();
 
-        string msg = $"【{DateTime.UtcNow}】清理在线用户成功!服务已重启...";
+        string msg = $"【{DateTime.Now}】清理在线用户成功!服务已重启...";
         var originColor = Console.ForegroundColor;
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(msg);

+ 1 - 1
Admin.NET/Admin.NET.Core/Logging/ElasticSearchLoggingWriter.cs

@@ -61,7 +61,7 @@ public class ElasticSearchLoggingWriter : IDatabaseLoggingWriter, IDisposable
 
         var sysLogOp = new SysLogOp
         {
-            Id = DateTime.UtcNow.Ticks,
+            Id = DateTime.Now.Ticks,
             ControllerName = loggingMonitor.controllerName,
             ActionName = loggingMonitor.actionTypeName,
             DisplayTitle = loggingMonitor.displayTitle,

+ 1 - 1
Admin.NET/Admin.NET.Core/Logging/LogExceptionHandler.cs

@@ -42,7 +42,7 @@
 //            Browser = context.HttpContext.Request.Headers["User-Agent"],
 //            TraceId = App.GetTraceId(),
 //            ThreadId = App.GetThreadId(),
-//            LogDateTime = DateTime.UtcNow,
+//            LogDateTime = DateTime.Now,
 //            LogLevel = LogLevel.Error
 //        };
 

+ 1 - 1
Admin.NET/Admin.NET.Core/Logging/LoggingSetup.cs

@@ -44,7 +44,7 @@ public static class LoggingSetup
                 {
                     options.WithTraceId = true; // 显示线程Id
                     options.WithStackFrame = true; // 显示程序集
-                    options.FileNameRule = fileName => string.Format(fileName, DateTime.UtcNow, logLevel.ToString()); // 每天创建一个文件
+                    options.FileNameRule = fileName => string.Format(fileName, DateTime.Now, logLevel.ToString()); // 每天创建一个文件
                     options.WriteFilter = logMsg => logMsg.LogLevel == logLevel; // 日志级别
                     options.HandleWriteError = (writeError) => // 写入失败时启用备用文件
                     {

+ 2 - 2
Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs

@@ -240,7 +240,7 @@ public class SysAuthService : IDynamicApiController, ITransient
         // 更新用户登录信息
         user.LastLoginIp = _httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(true);
         (user.LastLoginAddress, double? longitude, double? latitude) = CommonUtil.GetIpAddress(user.LastLoginIp);
-        user.LastLoginTime = DateTime.UtcNow;
+        user.LastLoginTime = DateTime.Now;
         user.LastLoginDevice = CommonUtil.GetClientDeviceInfo(_httpContextAccessor.HttpContext?.Request?.Headers?.UserAgent);
         await _sysUserRep.AsUpdateable(user).UpdateColumns(u => new
         {
@@ -277,7 +277,7 @@ public class SysAuthService : IDynamicApiController, ITransient
         // 获取水印文字(若系统水印为空则全局为空)
         var watermarkText = await _sysConfigService.GetConfigValue<string>(ConfigConst.SysWebWatermark);
         if (!string.IsNullOrWhiteSpace(watermarkText))
-            watermarkText += $"-{user.RealName}"; // $"-{user.RealName}-{_httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(true)}-{DateTime.UtcNow}";
+            watermarkText += $"-{user.RealName}"; // $"-{user.RealName}-{_httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(true)}-{DateTime.Now}";
         return new LoginUserOutput
         {
             Id = user.Id,

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/Common/SysCommonService.cs

@@ -83,7 +83,7 @@ public class SysCommonService : IDynamicApiController, ITransient
 
         return await Task.FromResult(new FileStreamResult(resultStream, "application/octet-stream")
         {
-            FileDownloadName = $"{(string.IsNullOrEmpty(fileName) ? "错误标记_" + DateTime.UtcNow.ToString("yyyyMMddhhmmss") : fileName)}.xlsx"
+            FileDownloadName = $"{(string.IsNullOrEmpty(fileName) ? "错误标记_" + DateTime.Now.ToString("yyyyMMddhhmmss") : fileName)}.xlsx"
         });
     }
 }

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/DataBase/SysDatabaseService.cs

@@ -528,7 +528,7 @@ public class SysDatabaseService : IDynamicApiController, ITransient
         Directory.CreateDirectory(backupDirectory);
 
         // 构建备份文件名
-        string backupFileName = $"backup_{DateTime.UtcNow:yyyyMMddHHmmss}.sql";
+        string backupFileName = $"backup_{DateTime.Now:yyyyMMddHHmmss}.sql";
         string backupFilePath = Path.Combine(backupDirectory, backupFileName);
 
         // 启动pg_dump进程进行备份

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/Job/JobClusterServer.cs

@@ -11,7 +11,7 @@ namespace Admin.NET.Core.Service;
 /// </summary>
 public class JobClusterServer : IJobClusterServer
 {
-    private readonly Random rd = new(DateTime.UtcNow.Millisecond);
+    private readonly Random rd = new(DateTime.Now.Millisecond);
 
     public JobClusterServer()
     {

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/Logging/SysLogExService.cs

@@ -62,6 +62,6 @@ public class SysLogExService : IDynamicApiController, ITransient
 
         IExcelExporter excelExporter = new ExcelExporter();
         var res = await excelExporter.ExportAsByteArray(logExList);
-        return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.UtcNow.ToString("yyyyMMddHHmm") + "异常日志.xlsx" };
+        return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "异常日志.xlsx" };
     }
 }

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/Logging/SysLogOpService.cs

@@ -62,6 +62,6 @@ public class SysLogOpService : IDynamicApiController, ITransient
 
         IExcelExporter excelExporter = new ExcelExporter();
         var res = await excelExporter.ExportAsByteArray(logOpList);
-        return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.UtcNow.ToString("yyyyMMddHHmm") + "操作日志.xlsx" };
+        return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "操作日志.xlsx" };
     }
 }

+ 2 - 2
Admin.NET/Admin.NET.Core/Service/Notice/SysNoticeService.cs

@@ -101,7 +101,7 @@ public class SysNoticeService : IDynamicApiController, ITransient
     public async Task Public(NoticeInput input)
     {
         // 更新发布状态和时间
-        await _sysNoticeRep.UpdateAsync(u => new SysNotice() { Status = NoticeStatusEnum.PUBLIC, PublicTime = DateTime.UtcNow }, u => u.Id == input.Id);
+        await _sysNoticeRep.UpdateAsync(u => new SysNotice() { Status = NoticeStatusEnum.PUBLIC, PublicTime = DateTime.Now }, u => u.Id == input.Id);
 
         var notice = await _sysNoticeRep.GetFirstAsync(u => u.Id == input.Id);
 
@@ -131,7 +131,7 @@ public class SysNoticeService : IDynamicApiController, ITransient
         await _sysNoticeUserRep.UpdateAsync(u => new SysNoticeUser
         {
             ReadStatus = NoticeUserStatusEnum.READ,
-            ReadTime = DateTime.UtcNow
+            ReadTime = DateTime.Now
         }, u => u.NoticeId == input.Id && u.UserId == _userManager.UserId);
     }
 

+ 1 - 1
Admin.NET/Admin.NET.Core/Service/Server/SysServerService.cs

@@ -62,7 +62,7 @@ public class SysServerService : IDynamicApiController, ITransient
     public dynamic GetServerUsed()
     {
         var programStartTime = Process.GetCurrentProcess().StartTime;
-        var totalMilliseconds = (DateTime.UtcNow - programStartTime).TotalMilliseconds.ToString();
+        var totalMilliseconds = (DateTime.Now - programStartTime).TotalMilliseconds.ToString();
         var ts = totalMilliseconds.Contains('.') ? totalMilliseconds.Split('.')[0] : totalMilliseconds;
         var programRunTime = DateTimeUtil.FormatTime(ts.ParseToLong());
 

+ 7 - 7
Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs

@@ -113,12 +113,12 @@ public class SysWechatPayService : IDynamicApiController, ITransient
     {
         var request = new CreatePayTransactionJsapiRequest()
         {
-            OutTradeNumber = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000), // 订单号
+            OutTradeNumber = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000), // 订单号
             AppId = _wechatPayOptions.AppId,
             Description = input.Description,
             Attachment = input.Attachment,
             GoodsTag = input.GoodsTag,
-            ExpireTime = DateTimeOffset.UtcNow.AddMinutes(10),
+            ExpireTime = DateTimeOffset.Now.AddMinutes(10),
             NotifyUrl = _payCallBackOptions.WechatPayUrl,
             Amount = new CreatePayTransactionJsapiRequest.Types.Amount() { Total = input.Total },
             Payer = new CreatePayTransactionJsapiRequest.Types.Payer() { OpenId = input.OpenId }
@@ -161,12 +161,12 @@ public class SysWechatPayService : IDynamicApiController, ITransient
     {
         var request = new CreatePayTransactionNativeRequest()
         {
-            OutTradeNumber = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000), // 订单号
+            OutTradeNumber = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000), // 订单号
             AppId = _wechatPayOptions.AppId,
             Description = input.Description,
             Attachment = input.Attachment,
             GoodsTag = input.GoodsTag,
-            ExpireTime = DateTimeOffset.UtcNow.AddMinutes(10),
+            ExpireTime = DateTimeOffset.Now.AddMinutes(10),
             NotifyUrl = _payCallBackOptions.WechatPayUrl,
             Amount = new CreatePayTransactionNativeRequest.Types.Amount() { Total = input.Total },
             //Payer = new CreatePayTransactionNativeRequest.Types.Payer() { OpenId = input.OpenId }
@@ -210,7 +210,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
     {
         var request = new CreatePayPartnerTransactionJsapiRequest()
         {
-            OutTradeNumber = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000), // 订单号
+            OutTradeNumber = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000), // 订单号
             AppId = _wechatPayOptions.AppId,
             MerchantId = _wechatPayOptions.MerchantId,
             SubAppId = _wechatPayOptions.AppId,
@@ -218,7 +218,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
             Description = input.Description,
             Attachment = input.Attachment,
             GoodsTag = input.GoodsTag,
-            ExpireTime = DateTimeOffset.UtcNow.AddMinutes(10),
+            ExpireTime = DateTimeOffset.Now.AddMinutes(10),
             NotifyUrl = _payCallBackOptions.WechatPayUrl,
             Amount = new CreatePayPartnerTransactionJsapiRequest.Types.Amount() { Total = input.Total },
             Payer = new CreatePayPartnerTransactionJsapiRequest.Types.Payer() { OpenId = input.OpenId }
@@ -331,7 +331,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
             },
 
             OutTradeNumber = input.TradeId,
-            OutRefundNumber = "R" + DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000), // 订单号
+            OutRefundNumber = "R" + DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000), // 订单号
             NotifyUrl = _payCallBackOptions.WechatPayUrl,
             Reason = input.Reason,
         };

+ 10 - 8
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -117,7 +117,7 @@ public static class SqlSugarSetup
                 //        par.Value = string.Concat(par.Value.ToString()[..100], "......");
                 //}
 
-                var log = $"【{DateTime.UtcNow}——执行SQL】\r\n{UtilMethods.GetNativeSql(sql, pars)}\r\n";
+                var log = $"【{DateTime.Now}——执行SQL】\r\n{UtilMethods.GetNativeSql(sql, pars)}\r\n";
                 var originColor = Console.ForegroundColor;
                 if (sql.StartsWith("SELECT", StringComparison.OrdinalIgnoreCase))
                     Console.ForegroundColor = ConsoleColor.Green;
@@ -132,7 +132,7 @@ public static class SqlSugarSetup
             db.Aop.OnError = ex =>
             {
                 if (ex.Parametres == null) return;
-                var log = $"【{DateTime.UtcNow}——错误SQL】\r\n{UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres)}\r\n";
+                var log = $"【{DateTime.Now}——错误SQL】\r\n{UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres)}\r\n";
                 Log.Error(log, ex);
                 App.PrintToMiniProfiler("SqlSugar", "Error", log);
             };
@@ -152,7 +152,7 @@ public static class SqlSugarSetup
                     var fileName = db.Ado.SqlStackTrace.FirstFileName; // 文件名
                     var fileLine = db.Ado.SqlStackTrace.FirstLine; // 行号
                     var firstMethodName = db.Ado.SqlStackTrace.FirstMethodName; // 方法名
-                    var log = $"【{DateTime.UtcNow}——超时SQL】\r\n【所在文件名】:{fileName}\r\n【代码行数】:{fileLine}\r\n【方法名】:{firstMethodName}\r\n" + $"【SQL语句】:{UtilMethods.GetNativeSql(sql, pars)}";
+                    var log = $"【{DateTime.Now}——超时SQL】\r\n【所在文件名】:{fileName}\r\n【代码行数】:{fileLine}\r\n【方法名】:{firstMethodName}\r\n" + $"【SQL语句】:{UtilMethods.GetNativeSql(sql, pars)}";
                     Log.Warning(log);
                     App.PrintToMiniProfiler("SqlSugar", "Slow", log);
                 }
@@ -172,9 +172,11 @@ public static class SqlSugarSetup
                         entityInfo.SetValue(YitIdHelper.NextId());
                 }
                 // 若创建时间为空则赋值当前时间
-                else if (entityInfo.PropertyName == nameof(EntityBase.CreateTime) && entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue) == null)
+                else if (entityInfo.PropertyName == nameof(EntityBase.CreateTime))
                 {
-                    entityInfo.SetValue(DateTime.UtcNow);
+                    var createTime = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue)!;
+                    if (createTime == null || createTime.Equals(DateTime.MinValue))
+                        entityInfo.SetValue(DateTime.Now);
                 }
                 // 若当前用户非空(web线程时)
                 if (App.User != null)
@@ -216,7 +218,7 @@ public static class SqlSugarSetup
             else if (entityInfo.OperationType == DataFilterType.UpdateByObject)
             {
                 if (entityInfo.PropertyName == nameof(EntityBase.UpdateTime))
-                    entityInfo.SetValue(DateTime.UtcNow);
+                    entityInfo.SetValue(DateTime.Now);
                 else if (entityInfo.PropertyName == nameof(EntityBase.UpdateUserId))
                     entityInfo.SetValue(App.User?.FindFirst(ClaimConst.UserId)?.Value);
                 else if (entityInfo.PropertyName == nameof(EntityBase.UpdateUserName))
@@ -271,7 +273,7 @@ public static class SqlSugarSetup
             var logDb = ITenant.IsAnyConnection(SqlSugarConst.LogConfigId) ? ITenant.GetConnectionScope(SqlSugarConst.LogConfigId) : db;
             await logDb.CopyNew().Insertable(logDiff).ExecuteCommandAsync();
             Console.ForegroundColor = ConsoleColor.Red;
-            Console.WriteLine(DateTime.UtcNow + $"\r\n*****开始差异日志*****\r\n{Environment.NewLine}{JSON.Serialize(logDiff)}{Environment.NewLine}*****结束差异日志*****\r\n");
+            Console.WriteLine(DateTime.Now + $"\r\n*****开始差异日志*****\r\n{Environment.NewLine}{JSON.Serialize(logDiff)}{Environment.NewLine}*****结束差异日志*****\r\n");
         };
     }
 
@@ -383,7 +385,7 @@ public static class SqlSugarSetup
             .Where(u => !u.GetCustomAttributes<IgnoreTableAttribute>().Any())
             .Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false) &&
             !u.IsDefined(typeof(SysTableAttribute), false) && !u.IsDefined(typeof(LogTableAttribute), false) && !u.IsDefined(typeof(TenantAttribute), false)).ToList();
-        if (!entityTypes.Any()) return;
+        if (entityTypes.Count == 0) return;
 
         foreach (var entityType in entityTypes)
         {

+ 1 - 1
Admin.NET/Admin.NET.Core/Util/AdminResultProvider.cs

@@ -116,7 +116,7 @@ public class AdminResultProvider : IUnifyResultProvider
             Result = data,
             Type = succeeded ? "success" : "error",
             Extras = UnifyContext.Take(),
-            Time = DateTime.UtcNow
+            Time = DateTime.Now
         };
     }
 }

+ 3 - 3
Admin.NET/Admin.NET.Core/Util/ComputerUtil.cs

@@ -205,19 +205,19 @@ public static class ComputerUtil
             //返回:1705379131
             //使用date格式化即可
             string output = ShellUtil.Bash("date -r $(sysctl -n kern.boottime | awk '{print $4}' | tr -d ',') +\"%Y-%m-%d %H:%M:%S\"").Trim();
-            runTime = DateTimeUtil.FormatTime((DateTime.UtcNow - output.ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
+            runTime = DateTimeUtil.FormatTime((DateTime.Now - output.ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
         }
         else if (IsUnix())
         {
             string output = ShellUtil.Bash("uptime -s").Trim();
-            runTime = DateTimeUtil.FormatTime((DateTime.UtcNow - output.ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
+            runTime = DateTimeUtil.FormatTime((DateTime.Now - output.ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
         }
         else
         {
             string output = ShellUtil.Cmd("wmic", "OS get LastBootUpTime/Value");
             string[] outputArr = output.Split('=', (char)StringSplitOptions.RemoveEmptyEntries);
             if (outputArr.Length == 2)
-                runTime = DateTimeUtil.FormatTime((DateTime.UtcNow - outputArr[1].Split('.')[0].ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
+                runTime = DateTimeUtil.FormatTime((DateTime.Now - outputArr[1].Split('.')[0].ParseToDateTime()).TotalMilliseconds.ToString().Split('.')[0].ParseToLong());
         }
         return runTime;
     }

+ 3 - 3
Admin.NET/Admin.NET.Core/Util/DateTimeUtil.cs

@@ -17,9 +17,9 @@ public class DateTimeUtil
     public static DateTime GetBeginTime(DateTime? dateTime, int days = 0)
     {
         if (dateTime == DateTime.MinValue || dateTime == null)
-            return DateTime.UtcNow.AddDays(days);
+            return DateTime.Now.AddDays(days);
 
-        return dateTime ?? DateTime.UtcNow;
+        return dateTime ?? DateTime.Now;
     }
 
     /// <summary>
@@ -122,7 +122,7 @@ public class DateTimeUtil
     {
         if (dt == null) return string.Empty;
 
-        if (dt.Value.Year == DateTime.UtcNow.Year)
+        if (dt.Value.Year == DateTime.Now.Year)
             return dt.Value.ToString("MM-dd HH:mm");
         else
             return dt.Value.ToString("yyyy-MM-dd HH:mm");

+ 2 - 2
Admin.NET/Plugins/Admin.NET.Plugin.ApprovalFlow/Service/ApprovalFlow/ApprovalFlowService.cs

@@ -117,9 +117,9 @@ public class ApprovalFlowService : IDynamicApiController, ITransient
     /// <returns></returns>
     private async Task<string> LastCode(string prefix)
     {
-        var today = DateTime.UtcNow.Date;
+        var today = DateTime.Now.Date;
         var count = await _approvalFlowRep.AsQueryable().Where(u => u.CreateTime >= today).CountAsync();
-        return prefix + DateTime.UtcNow.ToString("yyMMdd") + string.Format("{0:d2}", count + 1);
+        return prefix + DateTime.Now.ToString("yyMMdd") + string.Format("{0:d2}", count + 1);
     }
 
     /// <summary>

+ 1 - 1
Admin.NET/Plugins/Admin.NET.Plugin.DingTalk/Job/SyncDingTalkUserJob.cs

@@ -167,7 +167,7 @@ public class SyncDingTalkUserJob : IJob
 
         var originColor = Console.ForegroundColor;
         Console.ForegroundColor = ConsoleColor.Blue;
-        Console.WriteLine("【" + DateTime.UtcNow + "】同步钉钉用户");
+        Console.WriteLine("【" + DateTime.Now + "】同步钉钉用户");
         Console.ForegroundColor = originColor;
     }
 }