Merge pull request 'main' (#4) from Admin.NET/Admin.NET.Pro:main into main

Reviewed-on: http://101.43.53.74:3000/shuerchoi/Admin.NET.Pro/pulls/4
This commit is contained in:
shuerchoi 2024-07-18 13:12:40 +08:00
commit 235650d1c9
35 changed files with 200 additions and 88 deletions

View File

@ -11,7 +11,7 @@ namespace Admin.NET.Core;
/// </summary>
[SugarTable(null, "系统微信支付表")]
[SysTable]
[SugarIndex("sys_wechat_pay_order_id", nameof(OrderId), OrderByType.Desc)]
[SugarIndex("index_{table}_O", nameof(OrderId), OrderByType.Desc)]
public partial class SysWechatPay : EntityBase
{
/// <summary>

View File

@ -11,7 +11,7 @@ namespace Admin.NET.Core;
/// </summary>
[SugarTable(null, "系统微信退款表")]
[SysTable]
[SugarIndex("sys_wechat_refund_order_id", nameof(OrderId), OrderByType.Desc)]
[SugarIndex("index_{table}_O", nameof(OrderId), OrderByType.Desc)]
public class SysWechatRefund : EntityBase
{
/// <summary>

View File

@ -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 =>

View File

@ -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(),

View File

@ -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;
}
}

View File

@ -32,11 +32,11 @@ public class LogJob : IJob
var sysConfigService = serviceScope.ServiceProvider.GetRequiredService<SysConfigService>();
var daysAgo = await sysConfigService.GetConfigValue<int>(ConfigConst.SysLogRetentionDays); // 日志保留天数
await logVisRep.CopyNew().AsDeleteable().Where(u => u.CreateTime < DateTime.UtcNow.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.UtcNow.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除差异日志
await logVisRep.CopyNew().AsDeleteable().Where(u => u.CreateTime < DateTime.Now.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除访问日志
await logOpRep.CopyNew().AsDeleteable().Where(u => u.CreateTime < DateTime.Now.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除操作日志
await logDiffRep.CopyNew().AsDeleteable().Where(u => 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);

View File

@ -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);

View File

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

View File

@ -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,

View File

@ -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
// };

View File

@ -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) => // 写入失败时启用备用文件
{

View File

@ -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
{

View File

@ -138,7 +138,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"
});
}

View File

@ -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进程进行备份

View File

@ -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()
{

View File

@ -74,6 +74,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" };
}
}

View File

@ -74,6 +74,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" };
}
}

View File

@ -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);
}

View File

@ -97,7 +97,11 @@ public class SysRegionService : IDynamicApiController, ITransient
if (input.Code.Length != 12 && input.Code.Length != 9 && input.Code.Length != 6)
throw Oops.Oh(ErrorCodeEnum.R2003);
if (input.Pid != input.Pid && input.Pid != 0)
var sysRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Id);
if (sysRegion == null)
throw Oops.Oh(ErrorCodeEnum.D1002);
if (sysRegion.Pid != input.Pid && input.Pid != 0)
{
var pRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Pid);
pRegion ??= await _sysRegionRep.GetFirstAsync(u => u.Code == input.Pid.ToString());
@ -114,7 +118,6 @@ public class SysRegionService : IDynamicApiController, ITransient
if (input.Id == input.Pid)
throw Oops.Oh(ErrorCodeEnum.R2001);
var sysRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Id);
var isExist = await _sysRegionRep.IsAnyAsync(u => (u.Name == input.Name && u.Code == input.Code) && u.Id != sysRegion.Id);
if (isExist)
throw Oops.Oh(ErrorCodeEnum.R2002);

View File

@ -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());

View File

@ -68,7 +68,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
[DisplayName("微信支付统一下单获取Id(商户直连)")]
public async Task<CreatePayTransactionOutput> CreatePayTransaction([FromBody] WechatPayTransactionInput input)
{
string outTradeNumber = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000); // 微信需要的订单号(唯一)
string outTradeNumber = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000); // 微信需要的订单号(唯一)
//检查订单信息是否已存在(使用“商户交易单号+状态”唯一性判断)
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,
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 }
@ -126,7 +126,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
[DisplayName("微信支付统一下单获取Id(服务商模式)")]
public async Task<CreatePayTransactionOutput> CreatePayPartnerTransaction([FromBody] WechatPayTransactionInput input)
{
string outTradeNumber = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000); // 微信需要的订单号(唯一)
string outTradeNumber = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next(100, 1000); // 微信需要的订单号(唯一)
//检查订单信息是否已存在(使用“商户交易单号+状态”唯一性判断)
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,
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 }
@ -288,7 +288,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
var request = new CreateRefundDomesticRefundRequest()
{
OutTradeNumber = input.OutTradeNumber,
OutRefundNumber = "REFUND_" + DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmssfff"),
OutRefundNumber = "REFUND_" + DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"),
Amount = new CreateRefundDomesticRefundRequest.Types.Amount()
{
Total = input.Total,

View File

@ -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);
}
@ -174,9 +174,9 @@ public static class SqlSugarSetup
// 若创建时间为空则赋值当前时间
else if (entityInfo.PropertyName == nameof(EntityBase.CreateTime))
{
var createTime = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue);
if (createTime.Equals(DateTime.Parse("0001/1/1 0:00:00")))
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)
@ -213,7 +213,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))
@ -268,7 +268,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");
};
}
@ -316,7 +316,7 @@ public static class SqlSugarSetup
{
var seedDataTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>))))
.WhereIF(config.SeedSettings.EnableIncreSeed, u => u.IsDefined(typeof(IncreSeedAttribute), false))
.OrderBy(u => u.GetCustomAttributes(typeof(SeedDataAttribute), false).Length > 0 ? (u.GetCustomAttributes(typeof(SeedDataAttribute), false)[0] as SeedDataAttribute).Order : 0).ToList();
.OrderBy(u => u.GetCustomAttributes(typeof(SeedDataAttribute), false).Length > 0 ? ((SeedDataAttribute)u.GetCustomAttributes(typeof(SeedDataAttribute), false)[0]).Order : 0).ToList();
foreach (var seedType in seedDataTypes)
{
@ -394,14 +394,14 @@ public static class SqlSugarSetup
// 初始化业务应用种子数据
var seedDataTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>))))
.Where(u => u.IsDefined(typeof(AppSeedAttribute), false))
.OrderBy(u => u.GetCustomAttributes(typeof(SeedDataAttribute), false).Length > 0 ? (u.GetCustomAttributes(typeof(SeedDataAttribute), false)[0] as SeedDataAttribute).Order : 0).ToList();
.OrderBy(u => u.GetCustomAttributes(typeof(SeedDataAttribute), false).Length > 0 ? ((SeedDataAttribute)u.GetCustomAttributes(typeof(SeedDataAttribute), false)[0]).Order : 0).ToList();
foreach (var seedType in seedDataTypes)
{
var instance = Activator.CreateInstance(seedType);
var hasDataMethod = seedType.GetMethod("HasData");
var seedData = ((IEnumerable)hasDataMethod?.Invoke(instance, null))?.Cast<object>().ToList();
if (seedData == null) continue;
var seedData = ((IEnumerable)hasDataMethod?.Invoke(instance, null))?.Cast<object>().ToList() ?? new List<object>();
if (seedData.Count == 0) continue;
var entityType = seedType.GetInterfaces().First().GetGenericArguments().First();
var entityInfo = db.EntityMaintenance.GetEntityInfo(entityType);
@ -411,7 +411,7 @@ public static class SqlSugarSetup
{
foreach (var sd in seedData)
{
sd.GetType().GetProperty(nameof(EntityTenantId.TenantId)).SetValue(sd, dbConfigId);
sd.GetType().GetProperty(nameof(EntityTenantId.TenantId))!.SetValue(sd, dbConfigId);
}
}
// 若实体包含Pid字段则设置为当前租户Id
@ -419,7 +419,7 @@ public static class SqlSugarSetup
{
foreach (var sd in seedData)
{
sd.GetType().GetProperty(nameof(SysOrg.Pid)).SetValue(sd, dbConfigId);
sd.GetType().GetProperty(nameof(SysOrg.Pid))!.SetValue(sd, dbConfigId);
}
}
// 若实体包含Id字段则设置为当前租户Id递增1
@ -427,7 +427,7 @@ public static class SqlSugarSetup
{
foreach (var sd in seedData)
{
sd.GetType().GetProperty(nameof(EntityBaseId.Id)).SetValue(sd, ++dbConfigId);
sd.GetType().GetProperty(nameof(EntityBaseId.Id))!.SetValue(sd, ++dbConfigId);
}
}

View File

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

View File

@ -198,19 +198,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;
}

View File

@ -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");

View File

@ -80,6 +80,7 @@ public class Startup : AppStartup
setting.DateFormatHandling = DateFormatHandling.IsoDateFormat;
setting.DateTimeZoneHandling = DateTimeZoneHandling.Local;
setting.DateFormatString = "yyyy-MM-dd HH:mm:ss"; // 时间格式化
// setting.Converters.AddDateTimeTypeConverters(localized: true); // 时间本地化
setting.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // 忽略循环引用
// setting.ContractResolver = new CamelCasePropertyNamesContractResolver(); // 解决动态对象属性名大写
// setting.NullValueHandling = NullValueHandling.Ignore; // 忽略空值
@ -135,13 +136,17 @@ public class Startup : AppStartup
#region Redis消息队列
//// 替换事件源存储器
//options.ReplaceStorer(serviceProvider =>
//{
// var cacheProvider = serviceProvider.GetRequiredService<NewLife.Caching.ICacheProvider>();
// // 创建默认内存通道事件源对象可自定义队列路由keyadminnet
// return new RedisEventSourceStorer(cacheProvider, "adminnet", 3000);
//});
// 替换事件源存储器为Redis
var cacheOptions = App.GetConfig<CacheOptions>("Cache", true);
if (cacheOptions.CacheType == CacheTypeEnum.Redis.ToString())
{
options.ReplaceStorer(serviceProvider =>
{
var cacheProvider = serviceProvider.GetRequiredService<NewLife.Caching.ICacheProvider>();
// 创建默认内存通道事件源对象可自定义队列路由keyadminnet_eventsource_queue
return new RedisEventSourceStorer(cacheProvider, "adminnet_eventsource_queue", 3000);
});
}
#endregion Redis消息队列
@ -180,7 +185,10 @@ public class Startup : AppStartup
//services.AddSingleton<IUserIdProvider, UserIdProvider>();
services.AddSignalR(options =>
{
options.KeepAliveInterval = TimeSpan.FromSeconds(5);
options.EnableDetailedErrors = true;
options.KeepAliveInterval = TimeSpan.FromSeconds(15); // 服务器端向客户端ping的间隔
options.ClientTimeoutInterval = TimeSpan.FromSeconds(30); // 客户端向服务器端ping的间隔
options.MaximumReceiveMessageSize = 1024 * 1014 * 10; // 数据包大小10M默认最大为32K
}).AddNewtonsoftJsonProtocol(options => SetNewtonsoftJsonSetting(options.PayloadSerializerSettings));
// 系统日志

View File

@ -298,7 +298,7 @@ const options = useVxeTable<@(@Model.ClassName)>(
}
}
}
{ field: '', title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
{ title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
{ title: '操作', fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } },
],
},
@ -396,7 +396,7 @@ const handleDelete = (row: any) => {
} else {
@:await delete@(@Model.ClassName)(row);
}
handleQuery();
await handleQuery();
ElMessage.success('删除成功');
})
.catch(() => {});

View File

@ -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);
}
[HttpGet]

View File

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

View File

@ -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;
}
}

View File

@ -2,13 +2,13 @@
"name": "admin.net.pro",
"type": "module",
"version": "2.4.33",
"lastBuildTime": "2024.07.14",
"lastBuildTime": "2024.07.18",
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
"author": "zuohuaijun",
"license": "MIT",
"scripts": {
"dev": "vite",
"build": "vite build",
"build": "node --max-old-space-size=8192 ./node_modules/vite/bin/vite build",
"lint-fix": "eslint --fix --ext .js --ext .jsx --ext .vue src/",
"build-api": "cd api_build/ && build.bat"
},
@ -18,7 +18,7 @@
"@logicflow/extension": "^1.2.27",
"@microsoft/signalr": "^8.0.7",
"@vue-office/docx": "^1.6.2",
"@vue-office/excel": "^1.7.8",
"@vue-office/excel": "^1.7.11",
"@vue-office/pdf": "^2.0.2",
"@vueuse/core": "^10.11.0",
"@wangeditor/editor": "^5.1.23",
@ -57,7 +57,7 @@
"splitpanes": "^3.1.5",
"vcrontab-3": "^3.3.22",
"vform3-builds": "^3.0.10",
"vue": "^3.4.31",
"vue": "^3.4.32",
"vue-clipboard3": "^2.0.0",
"vue-demi": "^0.14.8",
"vue-grid-layout": "3.0.0-beta1",
@ -68,8 +68,8 @@
"vue-signature-pad": "^3.0.2",
"vue3-tree-org": "^4.2.2",
"vuedraggable": "4.0.3",
"vxe-pc-ui": "^4.0.68",
"vxe-table": "^4.7.51",
"vxe-pc-ui": "^4.0.74",
"vxe-table": "^4.7.54",
"vxe-table-plugin-element": "^4.0.4",
"vxe-table-plugin-export-xlsx": "^4.0.5",
"xe-utils": "^3.5.28",
@ -79,14 +79,14 @@
"@iconify/vue": "^4.1.2",
"@plugin-web-update-notification/vite": "^1.7.1",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.10",
"@types/node": "^20.14.11",
"@types/nprogress": "^0.2.3",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@vitejs/plugin-vue": "^5.0.5",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"@vue/compiler-sfc": "^3.4.31",
"@vue/compiler-sfc": "^3.4.32",
"code-inspector-plugin": "^0.14.2",
"eslint": "^9.7.0",
"eslint-plugin-vue": "^9.27.0",
@ -94,9 +94,9 @@
"prettier": "^3.3.3",
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.77.8",
"terser": "^5.31.2",
"terser": "^5.31.3",
"typescript": "^5.5.3",
"vite": "^5.3.3",
"vite": "^5.3.4",
"vite-plugin-cdn-import": "^1.0.1",
"vite-plugin-compression2": "^1.1.2",
"vite-plugin-vue-setup-extend": "^0.4.0",

View File

@ -159,6 +159,12 @@ const updateFavicon = (url: string): void => {
//
loadSysInfo();
//
document.body.ondrop = function (event) {
event.preventDefault();
event.stopPropagation();
};
</script>
<style lang="scss">

View File

@ -77,7 +77,7 @@ export const SysCommonApiAxiosParamCreator = function (configuration?: Configura
},
/**
*
* @summary Excel
* @summary Excel 🔖
* @param {string} [fileName]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
@ -178,6 +178,49 @@ export const SysCommonApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions,
};
},
/**
*
* @summary 🔖
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysCommonMachineSerialKeyGet: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysCommon/machineSerialKey`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication Bearer required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
*
* @summary 🏆
@ -246,7 +289,7 @@ export const SysCommonApiFp = function(configuration?: Configuration) {
},
/**
*
* @summary Excel
* @summary Excel 🔖
* @param {string} [fileName]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
@ -273,6 +316,19 @@ export const SysCommonApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary 🔖
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultString>>> {
const localVarAxiosArgs = await SysCommonApiAxiosParamCreator(configuration).apiSysCommonMachineSerialKeyGet(options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary 🏆
@ -307,7 +363,7 @@ export const SysCommonApiFactory = function (configuration?: Configuration, base
},
/**
*
* @summary Excel
* @summary Excel 🔖
* @param {string} [fileName]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
@ -326,6 +382,15 @@ export const SysCommonApiFactory = function (configuration?: Configuration, base
async apiSysCommonMD5EncryptTextUppercaseGet(text: string, uppercase: boolean, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultString>> {
return SysCommonApiFp(configuration).apiSysCommonMD5EncryptTextUppercaseGet(text, uppercase, options).then((request) => request(axios, basePath));
},
/**
*
* @summary 🔖
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultString>> {
return SysCommonApiFp(configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(axios, basePath));
},
/**
*
* @summary 🏆
@ -358,7 +423,7 @@ export class SysCommonApi extends BaseAPI {
}
/**
*
* @summary Excel
* @summary Excel 🔖
* @param {string} [fileName]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
@ -379,6 +444,16 @@ export class SysCommonApi extends BaseAPI {
public async apiSysCommonMD5EncryptTextUppercaseGet(text: string, uppercase: boolean, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultString>> {
return SysCommonApiFp(this.configuration).apiSysCommonMD5EncryptTextUppercaseGet(text, uppercase, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary 🔖
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysCommonApi
*/
public async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultString>> {
return SysCommonApiFp(this.configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary 🏆

View File

@ -102,7 +102,7 @@ export const useThemeConfig = defineStore('themeConfig', {
// 是否开启水印
isWatermark: true,
// 水印文案
watermarkText: 'Admin.NET.Pro',
watermarkText: 'Admin.NET',
/**
*
@ -149,7 +149,7 @@ export const useThemeConfig = defineStore('themeConfig', {
// 系统 logo 地址
logoUrl: '',
// Icp备案号
icp: 'ICP备12345678号',
icp: 'ICP备12345678号',
// Icp地址
icpUrl: 'https://beian.miit.gov.cn',
},

View File

@ -15,6 +15,10 @@ const connection = new SignalR.HubConnectionBuilder()
connection.keepAliveIntervalInMilliseconds = 15 * 1000; // 心跳检测15s
connection.serverTimeoutInMilliseconds = 30 * 60 * 1000; // 超时时间30m
// 若30s内没有收到服务器端发过来的信息则认为服务器端异常
connection.serverTimeoutInMilliseconds = 30 * 1000;
// 若15s内没有向服务器发送任何消息则ping一下服务器端
connection.keepAliveIntervalInMilliseconds = 15 * 1000;
// 启动连接
connection.start().then(() => {
@ -40,4 +44,20 @@ connection.onreconnected(() => {
connection.on('OnlineUserList', () => {});
// 接收消息
connection.on('ReceiveMessage', (message: any) => {
var tmpMsg = `${message.message}<br/>`;
tmpMsg += `<p style="color:#808080; font-size:12px">发送人员:${message.sendUserName}<p>`;
tmpMsg += `<p style="color:#808080; font-size:12px">发送时间:${message.sendTime}<p>`;
ElNotification({
title: `消息【${message.title}`,
message: tmpMsg,
type: 'info',
position: 'top-right',
dangerouslyUseHTMLString: true,
duration: 0,
});
});
export { connection as signalR };