From 6ab660724c4d9d2b0e2ecb9351fd929ffb4da538 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Thu, 6 Apr 2017 13:28:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=AE=B0=E5=BD=95=E5=BC=82=E5=B8=B8=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=90=8E=E6=B8=85=E9=99=A4=E5=BC=82=E5=B8=B8=E7=BC=93?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E5=BC=82=E5=B8=B8=E6=97=A5=E5=BF=97Exception?= =?UTF-8?q?s=E8=A1=A8=E7=BB=93=E6=9E=84=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/App_Start/DBPublisher.cs | 2 ++ Bootstrap.DataAccess/ExceptionHelper.cs | 11 +++++++---- DatabaseScripts/Install.sql | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Bootstrap.Admin/App_Start/DBPublisher.cs b/Bootstrap.Admin/App_Start/DBPublisher.cs index ad118737..d4ee6bda 100644 --- a/Bootstrap.Admin/App_Start/DBPublisher.cs +++ b/Bootstrap.Admin/App_Start/DBPublisher.cs @@ -1,4 +1,5 @@ using Bootstrap.DataAccess; +using Longbow.Caching; using Longbow.ExceptionManagement; using Longbow.ExceptionManagement.Configuration; using System; @@ -21,6 +22,7 @@ namespace Bootstrap.Admin { if (publisherElement.Mode == PublisherMode.Off) return; ExceptionHelper.Log(ex, additionalInfo); + CacheManager.Clear(k => k == ExceptionHelper.RetrieveExceptionsDataKey); } } } \ No newline at end of file diff --git a/Bootstrap.DataAccess/ExceptionHelper.cs b/Bootstrap.DataAccess/ExceptionHelper.cs index 44389332..ccd803a6 100644 --- a/Bootstrap.DataAccess/ExceptionHelper.cs +++ b/Bootstrap.DataAccess/ExceptionHelper.cs @@ -14,7 +14,10 @@ namespace Bootstrap.DataAccess /// public static class ExceptionHelper { - internal const string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions"; + /// + /// + /// + public static readonly string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions"; /// /// /// @@ -32,7 +35,7 @@ namespace Bootstrap.DataAccess cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@AppDomainName", AppDomain.CurrentDomain.FriendlyName)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ErrorPage", additionalInfo["ErrorPage"])); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", DBAccess.ToDBValue(additionalInfo["UserId"]))); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserIp", additionalInfo["UserIp"])); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserIp", DBAccess.ToDBValue(additionalInfo["UserIp"]))); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ExceptionType", ex.GetType().FullName)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Message", ex.Message)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccess.ToDBValue(ex.StackTrace), ParameterDirection.Input)); @@ -68,8 +71,8 @@ namespace Bootstrap.DataAccess Id = (int)reader[0], AppDomainName = (string)reader[1], ErrorPage = (string)reader[2], - UserId = (string)reader[3], - UserIp = (string)reader[4], + UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3], + UserIp = reader.IsDBNull(4) ? string.Empty : (string)reader[4], ExceptionType = (string)reader[5], Message = (string)reader[6], StackTrace = (string)reader[7], diff --git a/DatabaseScripts/Install.sql b/DatabaseScripts/Install.sql index dd7c4db3..b83ea8af 100644 --- a/DatabaseScripts/Install.sql +++ b/DatabaseScripts/Install.sql @@ -258,8 +258,8 @@ CREATE TABLE [dbo].[Exceptions]( [ID] [int] IDENTITY(1,1) NOT NULL, [AppDomainName] [varchar](50) NOT NULL, [ErrorPage] [varchar](50) NOT NULL, - [UserID] [varchar](50) NOT NULL, - [UserIp] [varchar](15) NOT NULL, + [UserID] [varchar](50) NULL, + [UserIp] [varchar](15) NULL, [ExceptionType] [nvarchar](max) NOT NULL, [Message] [nvarchar](max) NOT NULL, [StackTrace] [nvarchar](max) NULL,