😎统一时间为UTC格式:Now => UtcNow

This commit is contained in:
zuohuaijun 2024-07-16 18:06:39 +08:00
parent 731950d699
commit cfb09f9f45
26 changed files with 49 additions and 49 deletions

View File

@ -20,7 +20,7 @@
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.14.6" /> <PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.14.6" />
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.4.6" /> <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.4.6" />
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.4.6" /> <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.4.6" />
<PackageReference Include="Furion.Pure" Version="4.9.4.5" /> <PackageReference Include="Furion.Pure" Version="4.9.4.6" />
<PackageReference Include="Hardware.Info" Version="100.1.0.1" /> <PackageReference Include="Hardware.Info" Version="100.1.0.1" />
<PackageReference Include="IPTools.China" Version="1.6.0" /> <PackageReference Include="IPTools.China" Version="1.6.0" />
<PackageReference Include="IPTools.International" Version="1.6.0" /> <PackageReference Include="IPTools.International" Version="1.6.0" />
@ -35,7 +35,7 @@
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.2" /> <PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.2" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.4.0" /> <PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.4.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.6.0" /> <PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.6.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.162" /> <PackageReference Include="SqlSugarCore" Version="5.1.4.166" />
<PackageReference Include="SSH.NET" Version="2024.1.0" /> <PackageReference Include="SSH.NET" Version="2024.1.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.3" /> <PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.3" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1048" /> <PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1048" />

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -55,11 +55,11 @@ public class RoleApiJob : IJob
var originColor = Console.ForegroundColor; var originColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine($"【{DateTime.Now}】初始化管理员角色接口资源"); Console.WriteLine($"【{DateTime.UtcNow}】初始化管理员角色接口资源");
Console.ForegroundColor = originColor; Console.ForegroundColor = originColor;
// 自定义日志 // 自定义日志
_logger.LogInformation($"【{DateTime.Now}】初始化管理员角色接口资源"); _logger.LogInformation($"【{DateTime.UtcNow}】初始化管理员角色接口资源");
await Task.CompletedTask; await Task.CompletedTask;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
[DisplayName("微信支付统一下单获取Id(商户直连)")] [DisplayName("微信支付统一下单获取Id(商户直连)")]
public async Task<CreatePayTransactionOutput> CreatePayTransaction([FromBody] WechatPayTransactionInput input) public async Task<CreatePayTransactionOutput> CreatePayTransaction([FromBody] WechatPayTransactionInput input)
{ {
string outTradeNumber = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000); // 微信需要的订单号(唯一) string outTradeNumber = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000); // 微信需要的订单号(唯一)
//检查订单信息是否已存在(使用“商户交易单号+状态”唯一性判断) //检查订单信息是否已存在(使用“商户交易单号+状态”唯一性判断)
var wechatPay = await _sysWechatPayRep.GetFirstAsync(u => u.OrderId == input.OrderId && u.OrderStatus == input.OrderStatus); var wechatPay = await _sysWechatPayRep.GetFirstAsync(u => u.OrderId == input.OrderId && u.OrderStatus == input.OrderStatus);
@ -84,7 +84,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
Description = input.Description, Description = input.Description,
Attachment = input.Attachment, Attachment = input.Attachment,
GoodsTag = input.GoodsTag, GoodsTag = input.GoodsTag,
ExpireTime = DateTimeOffset.Now.AddMinutes(10), ExpireTime = DateTimeOffset.UtcNow.AddMinutes(10),
NotifyUrl = _payCallBackOptions.WechatPayUrl, NotifyUrl = _payCallBackOptions.WechatPayUrl,
Amount = new CreatePayTransactionJsapiRequest.Types.Amount() { Total = input.Total }, Amount = new CreatePayTransactionJsapiRequest.Types.Amount() { Total = input.Total },
Payer = new CreatePayTransactionJsapiRequest.Types.Payer() { OpenId = input.OpenId } Payer = new CreatePayTransactionJsapiRequest.Types.Payer() { OpenId = input.OpenId }
@ -126,7 +126,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
[DisplayName("微信支付统一下单获取Id(服务商模式)")] [DisplayName("微信支付统一下单获取Id(服务商模式)")]
public async Task<CreatePayTransactionOutput> CreatePayPartnerTransaction([FromBody] WechatPayTransactionInput input) public async Task<CreatePayTransactionOutput> CreatePayPartnerTransaction([FromBody] WechatPayTransactionInput input)
{ {
string outTradeNumber = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000); // 微信需要的订单号(唯一) string outTradeNumber = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000); // 微信需要的订单号(唯一)
//检查订单信息是否已存在(使用“商户交易单号+状态”唯一性判断) //检查订单信息是否已存在(使用“商户交易单号+状态”唯一性判断)
var wechatPay = await _sysWechatPayRep.GetFirstAsync(u => u.OrderId == input.OrderId && u.OrderStatus == input.OrderStatus); var wechatPay = await _sysWechatPayRep.GetFirstAsync(u => u.OrderId == input.OrderId && u.OrderStatus == input.OrderStatus);
@ -145,7 +145,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
Description = input.Description, Description = input.Description,
Attachment = input.Attachment, Attachment = input.Attachment,
GoodsTag = input.GoodsTag, GoodsTag = input.GoodsTag,
ExpireTime = DateTimeOffset.Now.AddMinutes(10), ExpireTime = DateTimeOffset.UtcNow.AddMinutes(10),
NotifyUrl = _payCallBackOptions.WechatPayUrl, NotifyUrl = _payCallBackOptions.WechatPayUrl,
Amount = new CreatePayPartnerTransactionJsapiRequest.Types.Amount() { Total = input.Total }, Amount = new CreatePayPartnerTransactionJsapiRequest.Types.Amount() { Total = input.Total },
Payer = new CreatePayPartnerTransactionJsapiRequest.Types.Payer() { OpenId = input.OpenId } Payer = new CreatePayPartnerTransactionJsapiRequest.Types.Payer() { OpenId = input.OpenId }
@ -288,7 +288,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
var request = new CreateRefundDomesticRefundRequest() var request = new CreateRefundDomesticRefundRequest()
{ {
OutTradeNumber = input.OutTradeNumber, OutTradeNumber = input.OutTradeNumber,
OutRefundNumber = "REFUND_" + DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"), OutRefundNumber = "REFUND_" + DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff"),
Amount = new CreateRefundDomesticRefundRequest.Types.Amount() Amount = new CreateRefundDomesticRefundRequest.Types.Amount()
{ {
Total = input.Total, Total = input.Total,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,7 +48,7 @@ public class SysApprovalService : ITransient
var approvalFlow = new ApprovalFlowRecord var approvalFlow = new ApprovalFlowRecord
{ {
FormName = funcName, FormName = funcName,
CreateTime = DateTime.Now, CreateTime = DateTime.UtcNow,
}; };
// 判断是否需要审批 // 判断是否需要审批
@ -59,7 +59,7 @@ public class SysApprovalService : ITransient
FlowId = approvalFlow.Id, FlowId = approvalFlow.Id,
FormName = funcName, FormName = funcName,
FormType = typeName, FormType = typeName,
CreateTime = DateTime.Now, CreateTime = DateTime.UtcNow,
}; };
// 判断是否需要审批 // 判断是否需要审批

View File

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