using System.Diagnostics; using DS.Module.Core.Log; using SqlSugar; namespace DS.WMS.Core { public static class LogExtensions { public static void Log(this Exception ex, ISqlSugarClient db) { string className = string.Empty; var stacktrace = new StackTrace(); if (stacktrace.FrameCount >= 0) className = stacktrace.GetFrame(0).GetMethod().DeclaringType.Name; var exLog = new SysLogException() { ClassName = className, ExceptionName = ex.GetType().FullName, ExceptionMsg = ex.Message, ExceptionSource = ex.Source, StackTrace = ex.StackTrace, ParamsObj = ex.TargetSite.GetParameters().ToString(), }; var scope = (SqlSugarScope)db; scope.GetConnection(1288018625843826680).Insertable(exLog).ExecuteCommand(); } } }