public override void ProcessEvent(WebBaseEvent raisedEvent) { var repo = DependencyResolver.Current.GetService <IService <Log> >(); var applicationInformation = WebBaseEvent.ApplicationInformation; var log = new Log { EventCode = raisedEvent.EventCode, EventType = raisedEvent.GetType().ToString(), EventSequence = raisedEvent.EventSequence, EventOccurrence = raisedEvent.EventOccurrence, Message = raisedEvent.Message, EventDetailCode = raisedEvent.EventDetailCode, ApplicationPath = applicationInformation.ApplicationPath, ApplicationVirtualPath = applicationInformation.ApplicationVirtualPath, MachineName = applicationInformation.MachineName }; if (raisedEvent is IUserInfoEvent) { log.Username = (raisedEvent as IUserInfoEvent).Username; log.Tenant = (raisedEvent as IUserInfoEvent).Tenant; } repo.SaveOrUpdate(log); }
//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); }
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); }
private static LogEntry CreateLogEntry(WebBaseEvent eventRaised) { LoggingEventType eventType = GetEventTypeFromWebEvent(eventRaised); string message = string.Format(CultureInfo.InvariantCulture, "{0} (Event Code: {1})", eventRaised.Message, eventRaised.EventCode); string source = eventRaised.GetType().Name; Exception exception = GetExceptionFromWebEvent(eventRaised); return(new LogEntry(eventType, message, source, exception)); }
/// <summary> /// Format the eb base event data. /// </summary> /// <param name="e">The web base event that has occured.</param> /// <returns>The web base event string format.</returns> private string FormatEntry(WebBaseEvent e) { return(String.Format("{0}\t{1}\t{2} (Event Code: {3})", e.EventTime, e.GetType().ToString(), e.Message, e.EventCode)); }
// Helper methods private string FormatEntry(WebBaseEvent e) { return String.Format("{0}\t{1}\t{2} (Event Code: {3})", e.EventTime, e.GetType().ToString(), e.Message, e.EventCode); }
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); }