コード例 #1
0
        //public string RequestUrl { get; set; }

        public static WebEvent FromWebBaseEvent(WebBaseEvent webBaseEvent)
        {
            var webEvent = new WebEvent();

            webEvent.ApplicationPath        = HostingEnvironment.ApplicationPhysicalPath;
            webEvent.ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
            webEvent.Details         = webBaseEvent.ToString();
            webEvent.EventCode       = webBaseEvent.EventCode;
            webEvent.EventDetailCode = webBaseEvent.EventDetailCode;
            webEvent.EventID         = webBaseEvent.EventID;
            webEvent.EventOccurrence = webBaseEvent.EventOccurrence;
            webEvent.EventSequence   = webBaseEvent.EventSequence;
            webEvent.EventTime       = webBaseEvent.EventTime;
            webEvent.EventTimeUtc    = webBaseEvent.EventTimeUtc;
            webEvent.EventType       = webBaseEvent.GetType().Name;
            //webEvent.MachineName = HttpContext.Current.Server.MachineName;
            webEvent.Message = webBaseEvent.Message;
            //webEvent.RequestUrl = HttpContext.Current.Request.Url.ToString();

            if (webBaseEvent is WebBaseErrorEvent)
            {
                webEvent.ExceptionType = ((WebBaseErrorEvent)webBaseEvent).ErrorException.GetType().Name;
            }

            return(webEvent);
        }
コード例 #2
0
ファイル: WebEvent.cs プロジェクト: Spaider/MongoDB.Web
        public static WebEvent FromWebBaseEvent(WebBaseEvent webBaseEvent)
        {
            var webEvent = new WebEvent
            {
                ApplicationPath        = HostingEnvironment.ApplicationPhysicalPath,
                ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath,
                Details         = webBaseEvent.ToString(),
                EventCode       = webBaseEvent.EventCode,
                EventDetailCode = webBaseEvent.EventDetailCode,
                EventID         = webBaseEvent.EventID,
                EventOccurrence = webBaseEvent.EventOccurrence,
                EventSequence   = webBaseEvent.EventSequence,
                EventTime       = webBaseEvent.EventTime,
                EventTimeUtc    = webBaseEvent.EventTimeUtc,
                EventType       = webBaseEvent.GetType().Name,
                Message         = webBaseEvent.Message
            };


            var baseErrorEvent = webBaseEvent as WebBaseErrorEvent;

            if (baseErrorEvent != null)
            {
                webEvent.ExceptionType = baseErrorEvent.ErrorException.GetType().Name;
            }

            return(webEvent);
        }
コード例 #3
0
        // </Snippet4>

        // <Snippet5>

        // Processes the incoming events.
        // This method performs custom processing and,
        // if buffering is enabled, it calls the
        // base.ProcessEvent to buffer the event
        // information.
        public override void ProcessEvent(
            WebBaseEvent eventRaised)
        {
            if (UseBuffering)
            {
                // Buffering enabled, call the
                // base event to buffer event information.
                base.ProcessEvent(eventRaised);
            }
            else
            {
                // Buffering disabled, store the
                // current event now.
                customInfo.AppendLine(
                    "*** Buffering disabled ***");
                customInfo.AppendLine(
                    eventRaised.ToString());
                // Store the information in the specified file.
                StoreToFile(customInfo,
                            logFilePath, FileMode.Append);
            }
        }
コード例 #4
0
 public override void ProcessEvent(WebBaseEvent eventRaised)
 {
     TextFileLogger.Log(eventRaised.ToString());
 }
コード例 #5
0
        private void InsertEvent(WebBaseEvent eventToInsert)
        {
            WebRequestInformation   requestInfo   = null;
            Exception               exception     = null;
            VAWebRequestInformation vaRequestInfo = null;
            DataRow row = _dataTable.NewRow();

            row["EventID"]                = eventToInsert.EventID;
            row["EventTimeUtc"]           = eventToInsert.EventTimeUtc;
            row["EventTime"]              = eventToInsert.EventTime;
            row["EventType"]              = eventToInsert.GetType().ToString();
            row["EventSequence"]          = eventToInsert.EventSequence;
            row["EventOccurrence"]        = eventToInsert.EventOccurrence;
            row["EventCode"]              = eventToInsert.EventCode;
            row["EventDetailCode"]        = eventToInsert.EventDetailCode;
            row["EventMessage"]           = eventToInsert.Message;
            row["MachineName"]            = WebBaseEvent.ApplicationInformation.MachineName;
            row["ApplicationPath"]        = WebBaseEvent.ApplicationInformation.ApplicationPath;
            row["ApplicationVirtualPath"] = WebBaseEvent.ApplicationInformation.ApplicationVirtualPath;

            if (eventToInsert is WebRequestEvent)
            {
                requestInfo = ((WebRequestEvent)eventToInsert).RequestInformation;
            }
            else if (eventToInsert is WebRequestErrorEvent)
            {
                requestInfo = ((WebRequestErrorEvent)eventToInsert).RequestInformation;
            }
            else if (eventToInsert is WebErrorEvent)
            {
                requestInfo = ((WebErrorEvent)eventToInsert).RequestInformation;
            }
            else if (eventToInsert is WebAuditEvent)
            {
                requestInfo = ((WebAuditEvent)eventToInsert).RequestInformation;
            }

            if (eventToInsert is WebBaseErrorEvent)
            {
                exception = ((WebBaseErrorEvent)eventToInsert).ErrorException;
            }

            if (eventToInsert is VAWebRequestErrorEvent)
            {
                vaRequestInfo = ((VAWebRequestErrorEvent)eventToInsert).VARequestInformation;
            }
            else if (eventToInsert is VAWebRequestDocumentoDownloadEvent)
            {
                vaRequestInfo = ((VAWebRequestDocumentoDownloadEvent)eventToInsert).VARequestInformation;
            }

            if (requestInfo != null)
            {
                row["RequestUrl"]      = requestInfo.RequestUrl;
                row["UserHostAddress"] = requestInfo.UserHostAddress;
                row["PrincipalIdentityIsAuthenticated"] = requestInfo.Principal.Identity.IsAuthenticated;

                if (requestInfo.Principal.Identity.IsAuthenticated)
                {
                    row["PrincipalIdentityName"] = requestInfo.Principal.Identity.Name;
                }
            }

            if (exception != null)
            {
                row["ExceptionType"]    = exception.GetType().ToString();
                row["ExceptionMessage"] = exception.Message;
                row["Details"]          = eventToInsert.ToString(true, true);
                row["WebEventTypeID"]   = VAWebEventTypeEnum.Errore;
            }

            if (vaRequestInfo != null)
            {
                if (vaRequestInfo.UtenteID != null)
                {
                    row["UtenteID"]         = vaRequestInfo.UtenteID;
                    row["UtenteNomeUtente"] = vaRequestInfo.NomeUtente;
                }

                if (vaRequestInfo.UrlReferrer != null)
                {
                    row["RequestUrlReferrer"] = vaRequestInfo.UrlReferrer;
                }

                if (vaRequestInfo.UserAgent != null)
                {
                    row["RequestUserAgent"] = vaRequestInfo.UserAgent;
                }

                if (vaRequestInfo.IntEntityID != null)
                {
                    row["IntEntityID"] = vaRequestInfo.IntEntityID;
                }

                if (vaRequestInfo.GuidEntityID != null)
                {
                    row["GuidEntityID"] = vaRequestInfo.GuidEntityID;
                }

                if (vaRequestInfo.EventTypeID != null)
                {
                    row["WebEventTypeID"] = vaRequestInfo.EventTypeID;
                }
            }

            _dataTable.Rows.Add(row);
        }