Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					8b124d1050 | 
@@ -117,6 +117,25 @@ public class SugarAopService : ISugarAopService
 | 
			
		||||
        db.Aop.DataExecuted = (value, entity) =>
 | 
			
		||||
        {
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        db.Aop.OnLogExecuted = (sql, pars) =>
 | 
			
		||||
        {
 | 
			
		||||
            //执行时间超过1秒
 | 
			
		||||
            if (db.Ado.SqlExecutionTime.TotalSeconds > 1)
 | 
			
		||||
            {
 | 
			
		||||
                //代码CS文件名
 | 
			
		||||
                var fileName = db.Ado.SqlStackTrace.FirstFileName;
 | 
			
		||||
                //代码行数
 | 
			
		||||
                var fileLine = db.Ado.SqlStackTrace.FirstLine;
 | 
			
		||||
                //方法名
 | 
			
		||||
                var FirstMethodName = db.Ado.SqlStackTrace.FirstMethodName;
 | 
			
		||||
 | 
			
		||||
                DbContext.WriteLog($"{fileName}-{FirstMethodName}-{fileLine} 执行时间超过1秒");
 | 
			
		||||
                DbContext.WriteLogWithSql(UtilMethods.GetNativeSql(sql, pars));
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ public sealed class SqlSugarOption : ConnectionConfig
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 是否控制台显示Sql语句
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public bool IsShowSql { get; set; }
 | 
			
		||||
    public bool? IsShowSql { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 更新数据
 | 
			
		||||
 
 | 
			
		||||
@@ -98,6 +98,18 @@ public class Startup : AppStartup
 | 
			
		||||
        CodeFirstUtils.CodeFirst(fullName!);//CodeFirst
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            using var db = DbContext.GetDB<SysOperateLog>();
 | 
			
		||||
            if (!db.DbMaintenance.IsAnyIndex("idx_operatelog_optime_date"))
 | 
			
		||||
            {
 | 
			
		||||
                var indexsql = "CREATE INDEX idx_operatelog_optime_date ON sys_operatelog(strftime('%Y-%m-%d', OpTime));";
 | 
			
		||||
                db.Ado.ExecuteCommand(indexsql);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch { }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //删除在线用户统计
 | 
			
		||||
        var verificatInfoService = App.RootServices.GetService<IVerificatInfoService>();
 | 
			
		||||
        verificatInfoService.RemoveAllClientId();
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ public static class ILoggerExtensions
 | 
			
		||||
    /// <param name="logger"></param>
 | 
			
		||||
    /// <param name="properties">建议使用 ConcurrentDictionary 类型</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static IDisposable ScopeContext(this ILogger logger, IDictionary<object, object> properties)
 | 
			
		||||
    public static IDisposable ScopeContext(this ILogger logger, IDictionary<string, object> properties)
 | 
			
		||||
    {
 | 
			
		||||
        if (logger == null) throw new ArgumentNullException(nameof(logger));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,11 +26,11 @@ public static class LogContextExtensions
 | 
			
		||||
    /// <param name="key">键</param>
 | 
			
		||||
    /// <param name="value">值</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static LogContext Set(this LogContext logContext, object key, object value)
 | 
			
		||||
    public static LogContext Set(this LogContext logContext, string key, object value)
 | 
			
		||||
    {
 | 
			
		||||
        if (logContext == null || key == null) return logContext;
 | 
			
		||||
 | 
			
		||||
        logContext.Properties ??= new Dictionary<object, object>();
 | 
			
		||||
        logContext.Properties ??= new Dictionary<string, object>();
 | 
			
		||||
 | 
			
		||||
        logContext.Properties.Remove(key);
 | 
			
		||||
        logContext.Properties.Add(key, value);
 | 
			
		||||
@@ -43,7 +43,7 @@ public static class LogContextExtensions
 | 
			
		||||
    /// <param name="logContext"></param>
 | 
			
		||||
    /// <param name="properties"></param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static LogContext SetRange(this LogContext logContext, IDictionary<object, object> properties)
 | 
			
		||||
    public static LogContext SetRange(this LogContext logContext, IDictionary<string, object> properties)
 | 
			
		||||
    {
 | 
			
		||||
        if (logContext == null
 | 
			
		||||
            || properties == null
 | 
			
		||||
@@ -63,7 +63,7 @@ public static class LogContextExtensions
 | 
			
		||||
    /// <param name="logContext"></param>
 | 
			
		||||
    /// <param name="key">键</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static object Get(this LogContext logContext, object key)
 | 
			
		||||
    public static object Get(this LogContext logContext, string key)
 | 
			
		||||
    {
 | 
			
		||||
        if (logContext == null
 | 
			
		||||
            || key == null
 | 
			
		||||
@@ -80,7 +80,7 @@ public static class LogContextExtensions
 | 
			
		||||
    /// <param name="logContext"></param>
 | 
			
		||||
    /// <param name="key">键</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static T Get<T>(this LogContext logContext, object key)
 | 
			
		||||
    public static T Get<T>(this LogContext logContext, string key)
 | 
			
		||||
    {
 | 
			
		||||
        var value = logContext.Get(key);
 | 
			
		||||
        return value.ChangeType<T>();
 | 
			
		||||
 
 | 
			
		||||
@@ -84,7 +84,7 @@ public static class StringLoggingExtensions
 | 
			
		||||
    /// <param name="message"></param>
 | 
			
		||||
    /// <param name="properties">建议使用 ConcurrentDictionary 类型</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static StringLoggingPart ScopeContext(this string message, IDictionary<object, object> properties)
 | 
			
		||||
    public static StringLoggingPart ScopeContext(this string message, IDictionary<string, object> properties)
 | 
			
		||||
    {
 | 
			
		||||
        return StringLoggingPart.Default().SetMessage(message).ScopeContext(properties);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ public sealed class LogContext : IDisposable
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 日志上下文数据
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public IDictionary<object, object> Properties { get; set; }
 | 
			
		||||
    public IDictionary<string, object> Properties { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 原生日志上下文数据
 | 
			
		||||
 
 | 
			
		||||
@@ -96,7 +96,7 @@ public sealed partial class StringLoggingPart
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="properties">建议使用 ConcurrentDictionary 类型</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public StringLoggingPart ScopeContext(IDictionary<object, object> properties)
 | 
			
		||||
    public StringLoggingPart ScopeContext(IDictionary<string, object> properties)
 | 
			
		||||
    {
 | 
			
		||||
        if (properties == null) return this;
 | 
			
		||||
        LogContext = new LogContext { Properties = properties };
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@ public static class Log
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="properties">建议使用 ConcurrentDictionary 类型</param>
 | 
			
		||||
    /// <returns></returns>
 | 
			
		||||
    public static (ILogger logger, IDisposable scope) ScopeContext(IDictionary<object, object> properties)
 | 
			
		||||
    public static (ILogger logger, IDisposable scope) ScopeContext(IDictionary<string, object> properties)
 | 
			
		||||
    {
 | 
			
		||||
        return GetLogger(StringLoggingPart.Default().ScopeContext(properties));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
<Project>
 | 
			
		||||
 | 
			
		||||
	<PropertyGroup>
 | 
			
		||||
		<PluginVersion>10.6.24</PluginVersion>
 | 
			
		||||
		<ProPluginVersion>10.6.24</ProPluginVersion>
 | 
			
		||||
		<PluginVersion>10.6.25</PluginVersion>
 | 
			
		||||
		<ProPluginVersion>10.6.25</ProPluginVersion>
 | 
			
		||||
		<AuthenticationVersion>2.1.8</AuthenticationVersion>
 | 
			
		||||
	</PropertyGroup>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -130,8 +130,27 @@ public class Startup : AppStartup
 | 
			
		||||
        }
 | 
			
		||||
        catch { }
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            using var db = DbContext.GetDB<BackendLog>();
 | 
			
		||||
            if (!db.DbMaintenance.IsAnyIndex("idx_backendlog_logtime_date"))
 | 
			
		||||
            {
 | 
			
		||||
                var indexsql = "CREATE INDEX idx_backendlog_logtime_date ON backend_log(strftime('%Y-%m-%d', LogTime));";
 | 
			
		||||
                db.Ado.ExecuteCommand(indexsql);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch { }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            using var db = DbContext.GetDB<RpcLog>();
 | 
			
		||||
            if (!db.DbMaintenance.IsAnyIndex("idx_rpclog_logtime_date"))
 | 
			
		||||
            {
 | 
			
		||||
                var indexsql = "CREATE INDEX idx_rpclog_logtime_date ON rpc_log(strftime('%Y-%m-%d', LogTime));";
 | 
			
		||||
                db.Ado.ExecuteCommand(indexsql);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch { }
 | 
			
		||||
 | 
			
		||||
        serviceProvider.GetService<IHostApplicationLifetime>().ApplicationStarted.Register(() =>
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
<Project>
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <Version>10.6.24</Version>
 | 
			
		||||
    <Version>10.6.25</Version>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user