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; }
//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; }
internal string GenerateSubject(int notificationSequence, int messageSequence, WebBaseEventCollection events, int count) { WebBaseEvent eventRaised = events[0]; if (count == 1) { return(HttpUtility.HtmlEncode(SR.GetString(SR.WebEvent_event_email_subject, new string[] { notificationSequence.ToString(CultureInfo.InstalledUICulture), messageSequence.ToString(CultureInfo.InstalledUICulture), _subjectPrefix, eventRaised.GetType().ToString(), WebBaseEvent.ApplicationInformation.ApplicationVirtualPath } ))); } else { return(HttpUtility.HtmlEncode(SR.GetString(SR.WebEvent_event_group_email_subject, new string[] { notificationSequence.ToString(CultureInfo.InstalledUICulture), messageSequence.ToString(CultureInfo.InstalledUICulture), _subjectPrefix, count.ToString(CultureInfo.InstalledUICulture), WebBaseEvent.ApplicationInformation.ApplicationVirtualPath } ))); } }
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); }
void FillParams(SqlCommand sqlCommand, WebBaseEvent eventRaised) { Exception exception = null; WebRequestInformation reqInfo = null; string details = null; WebApplicationInformation appInfo = WebBaseEvent.ApplicationInformation; int n = 0; sqlCommand.Parameters[n++].Value = eventRaised.EventID.ToString("N", CultureInfo.InstalledUICulture); // @EventId sqlCommand.Parameters[n++].Value = eventRaised.EventTimeUtc; // @EventTimeUtc sqlCommand.Parameters[n++].Value = eventRaised.EventTime; // @EventTime sqlCommand.Parameters[n++].Value = eventRaised.GetType().ToString(); // @EventType sqlCommand.Parameters[n++].Value = eventRaised.EventSequence; // @EventSequence sqlCommand.Parameters[n++].Value = eventRaised.EventOccurrence; // @EventOccurrence sqlCommand.Parameters[n++].Value = eventRaised.EventCode; // @EventCode sqlCommand.Parameters[n++].Value = eventRaised.EventDetailCode; // @EventDetailCode sqlCommand.Parameters[n++].Value = eventRaised.Message; // @Message sqlCommand.Parameters[n++].Value = appInfo.ApplicationPath; // @ApplicationPath sqlCommand.Parameters[n++].Value = appInfo.ApplicationVirtualPath; // @ApplicationVirtualPath sqlCommand.Parameters[n++].Value = appInfo.MachineName; // @MachineName // // @RequestUrl if (eventRaised is WebRequestEvent) { reqInfo = ((WebRequestEvent)eventRaised).RequestInformation; } else if (eventRaised is WebRequestErrorEvent) { reqInfo = ((WebRequestErrorEvent)eventRaised).RequestInformation; } else if (eventRaised is WebErrorEvent) { reqInfo = ((WebErrorEvent)eventRaised).RequestInformation; } else if (eventRaised is WebAuditEvent) { reqInfo = ((WebAuditEvent)eventRaised).RequestInformation; } sqlCommand.Parameters[n++].Value = (reqInfo != null) ? reqInfo.RequestUrl : Convert.DBNull; // @ExceptionType if (eventRaised is WebBaseErrorEvent) { exception = ((WebBaseErrorEvent)eventRaised).ErrorException; } sqlCommand.Parameters[n++].Value = (exception != null) ? exception.GetType().ToString() : Convert.DBNull; // @Details details = eventRaised.ToString(); if (_maxEventDetailsLength != NO_LIMIT && details.Length > _maxEventDetailsLength) { details = details.Substring(0, _maxEventDetailsLength); } sqlCommand.Parameters[n++].Value = details; }
public override void ProcessEvent(WebBaseEvent eventRaised) { if (UseBuffering) { base.ProcessEvent(eventRaised); } else { Debug.Trace("SqlWebEventProvider", "Writing event to SQL: event=" + eventRaised.GetType().Name); WriteToSQL(new WebBaseEventCollection(eventRaised), 0, new DateTime(0)); } }
public override void ProcessEvent(WebBaseEvent eventRaised) { Debug.Trace("MailWebEventProvider", "ProcessEvent: type =" + eventRaised.GetType() + ", ID=" + eventRaised.EventID + ", buffer=" + UseBuffering); if (UseBuffering) { base.ProcessEvent(eventRaised); } else { SendMessage(eventRaised); } }
private void FillParams(SqlCommand sqlCommand, WebBaseEvent eventRaised) { Exception errorException = null; WebRequestInformation requestInformation = null; string str = null; WebApplicationInformation applicationInformation = WebBaseEvent.ApplicationInformation; int num = 0; sqlCommand.Parameters[num++].Value = eventRaised.EventID.ToString("N", CultureInfo.InstalledUICulture); sqlCommand.Parameters[num++].Value = eventRaised.EventTimeUtc; sqlCommand.Parameters[num++].Value = eventRaised.EventTime; sqlCommand.Parameters[num++].Value = eventRaised.GetType().ToString(); sqlCommand.Parameters[num++].Value = eventRaised.EventSequence; sqlCommand.Parameters[num++].Value = eventRaised.EventOccurrence; sqlCommand.Parameters[num++].Value = eventRaised.EventCode; sqlCommand.Parameters[num++].Value = eventRaised.EventDetailCode; sqlCommand.Parameters[num++].Value = eventRaised.Message; sqlCommand.Parameters[num++].Value = applicationInformation.ApplicationPath; sqlCommand.Parameters[num++].Value = applicationInformation.ApplicationVirtualPath; sqlCommand.Parameters[num++].Value = applicationInformation.MachineName; if (eventRaised is WebRequestEvent) { requestInformation = ((WebRequestEvent)eventRaised).RequestInformation; } else if (eventRaised is WebRequestErrorEvent) { requestInformation = ((WebRequestErrorEvent)eventRaised).RequestInformation; } else if (eventRaised is WebErrorEvent) { requestInformation = ((WebErrorEvent)eventRaised).RequestInformation; } else if (eventRaised is WebAuditEvent) { requestInformation = ((WebAuditEvent)eventRaised).RequestInformation; } sqlCommand.Parameters[num++].Value = (requestInformation != null) ? requestInformation.RequestUrl : Convert.DBNull; if (eventRaised is WebBaseErrorEvent) { errorException = ((WebBaseErrorEvent)eventRaised).ErrorException; } sqlCommand.Parameters[num++].Value = (errorException != null) ? errorException.GetType().ToString() : Convert.DBNull; str = eventRaised.ToString(); if ((this._maxEventDetailsLength != -1) && (str.Length > this._maxEventDetailsLength)) { str = str.Substring(0, this._maxEventDetailsLength); } sqlCommand.Parameters[num++].Value = str; }
private void FillParams(SqlCommand sqlCommand, WebBaseEvent eventRaised) { Exception errorException = null; WebRequestInformation requestInformation = null; string str = null; WebApplicationInformation applicationInformation = WebBaseEvent.ApplicationInformation; int num = 0; sqlCommand.Parameters[num++].Value = eventRaised.EventID.ToString("N", CultureInfo.InstalledUICulture); sqlCommand.Parameters[num++].Value = eventRaised.EventTimeUtc; sqlCommand.Parameters[num++].Value = eventRaised.EventTime; sqlCommand.Parameters[num++].Value = eventRaised.GetType().ToString(); sqlCommand.Parameters[num++].Value = eventRaised.EventSequence; sqlCommand.Parameters[num++].Value = eventRaised.EventOccurrence; sqlCommand.Parameters[num++].Value = eventRaised.EventCode; sqlCommand.Parameters[num++].Value = eventRaised.EventDetailCode; sqlCommand.Parameters[num++].Value = eventRaised.Message; sqlCommand.Parameters[num++].Value = applicationInformation.ApplicationPath; sqlCommand.Parameters[num++].Value = applicationInformation.ApplicationVirtualPath; sqlCommand.Parameters[num++].Value = applicationInformation.MachineName; if (eventRaised is WebRequestEvent) { requestInformation = ((WebRequestEvent) eventRaised).RequestInformation; } else if (eventRaised is WebRequestErrorEvent) { requestInformation = ((WebRequestErrorEvent) eventRaised).RequestInformation; } else if (eventRaised is WebErrorEvent) { requestInformation = ((WebErrorEvent) eventRaised).RequestInformation; } else if (eventRaised is WebAuditEvent) { requestInformation = ((WebAuditEvent) eventRaised).RequestInformation; } sqlCommand.Parameters[num++].Value = (requestInformation != null) ? requestInformation.RequestUrl : Convert.DBNull; if (eventRaised is WebBaseErrorEvent) { errorException = ((WebBaseErrorEvent) eventRaised).ErrorException; } sqlCommand.Parameters[num++].Value = (errorException != null) ? errorException.GetType().ToString() : Convert.DBNull; str = eventRaised.ToString(); if ((this._maxEventDetailsLength != -1) && (str.Length > this._maxEventDetailsLength)) { str = str.Substring(0, this._maxEventDetailsLength); } sqlCommand.Parameters[num++].Value = str; }
public override void ProcessEvent(WebBaseEvent eventRaised) { if (_buffer) { // register the event with the buffer instead of writing it out Debug.Trace("BufferedWebEventProvider", "Saving event to buffer: event=" + eventRaised.GetType().Name); _webEventBuffer.AddEvent(eventRaised); } else { WebEventBufferFlushInfo flushInfo = new WebEventBufferFlushInfo( new WebBaseEventCollection(eventRaised), EventNotificationType.Unbuffered, 0, DateTime.MinValue, 0, 0); ProcessEventFlush(flushInfo); } }
public override void ProcessEvent(WebBaseEvent eventRaised) { if (_buffer) { // register the event with the buffer instead of writing it out Debug.Trace("BufferedWebEventProvider", "Saving event to buffer: event=" + eventRaised.GetType().Name); _webEventBuffer.AddEvent(eventRaised); } else { WebEventBufferFlushInfo flushInfo = new WebEventBufferFlushInfo( new WebBaseEventCollection(eventRaised), EventNotificationType.Unbuffered, 0, DateTime.MinValue, 0, 0); ProcessEventFlush(flushInfo); } }
void FillParams(SqlCommand sqlCommand, WebBaseEvent eventRaised) { Exception exception = null; WebRequestInformation reqInfo = null; string details = null; WebApplicationInformation appInfo = WebBaseEvent.ApplicationInformation; int n = 0; sqlCommand.Parameters[n++].Value = eventRaised.EventID.ToString("N", CultureInfo.InstalledUICulture); // @EventId sqlCommand.Parameters[n++].Value = eventRaised.EventTimeUtc; // @EventTimeUtc sqlCommand.Parameters[n++].Value = eventRaised.EventTime; // @EventTime sqlCommand.Parameters[n++].Value = eventRaised.GetType().ToString(); // @EventType sqlCommand.Parameters[n++].Value = eventRaised.EventSequence; // @EventSequence sqlCommand.Parameters[n++].Value = eventRaised.EventOccurrence; // @EventOccurrence sqlCommand.Parameters[n++].Value = eventRaised.EventCode; // @EventCode sqlCommand.Parameters[n++].Value = eventRaised.EventDetailCode; // @EventDetailCode sqlCommand.Parameters[n++].Value = eventRaised.Message; // @Message sqlCommand.Parameters[n++].Value = appInfo.ApplicationPath; // @ApplicationPath sqlCommand.Parameters[n++].Value = appInfo.ApplicationVirtualPath; // @ApplicationVirtualPath sqlCommand.Parameters[n++].Value = appInfo.MachineName; // @MachineName // // @RequestUrl if (eventRaised is WebRequestEvent) { reqInfo = ((WebRequestEvent)eventRaised).RequestInformation; } else if (eventRaised is WebRequestErrorEvent) { reqInfo = ((WebRequestErrorEvent)eventRaised).RequestInformation; } else if (eventRaised is WebErrorEvent) { reqInfo = ((WebErrorEvent)eventRaised).RequestInformation; } else if (eventRaised is WebAuditEvent) { reqInfo = ((WebAuditEvent)eventRaised).RequestInformation; } sqlCommand.Parameters[n++].Value = (reqInfo != null) ? reqInfo.RequestUrl : Convert.DBNull; // @ExceptionType if (eventRaised is WebBaseErrorEvent) { exception = ((WebBaseErrorEvent)eventRaised).ErrorException; } sqlCommand.Parameters[n++].Value = (exception != null) ? exception.GetType().ToString() : Convert.DBNull; // @Details details = eventRaised.ToString(); if (_maxEventDetailsLength != NO_LIMIT && details.Length > _maxEventDetailsLength) { details = details.Substring(0, _maxEventDetailsLength); } sqlCommand.Parameters[n++].Value = details; }
public override void ProcessEvent(WebBaseEvent eventRaised) { if (UseBuffering) { base.ProcessEvent(eventRaised); } else { Debug.Trace("SqlWebEventProvider", "Writing event to SQL: event=" + eventRaised.GetType().Name); WriteToSQL(new WebBaseEventCollection(eventRaised), 0, new DateTime(0)); } }
public override void ProcessEvent(WebBaseEvent eventRaised) { Debug.Trace("WmiWebEventProvider", "ProcessEvent: event=" + eventRaised.GetType().Name); UnsafeNativeMethods.WmiData wmiData = new UnsafeNativeMethods.WmiData(); // Note: WMI sint64 requires a string param FillBasicWmiDataFields(ref wmiData, eventRaised); if (eventRaised is WebApplicationLifetimeEvent) { // Nothing special for this class. } if (eventRaised is WebManagementEvent) { WebProcessInformation processEventInfo = ((WebManagementEvent)eventRaised).ProcessInformation; wmiData.processId = processEventInfo.ProcessID; wmiData.processName = processEventInfo.ProcessName; wmiData.accountName = processEventInfo.AccountName; } if (eventRaised is WebRequestEvent) { FillRequestWmiDataFields(ref wmiData, ((WebRequestEvent)eventRaised).RequestInformation); } if (eventRaised is WebAuditEvent) { FillRequestWmiDataFields(ref wmiData, ((WebAuditEvent)eventRaised).RequestInformation); } if (eventRaised is WebAuthenticationSuccessAuditEvent) { wmiData.nameToAuthenticate = ((WebAuthenticationSuccessAuditEvent)eventRaised).NameToAuthenticate; } if (eventRaised is WebAuthenticationFailureAuditEvent) { wmiData.nameToAuthenticate = ((WebAuthenticationFailureAuditEvent)eventRaised).NameToAuthenticate; } if (eventRaised is WebViewStateFailureAuditEvent) { ViewStateException vse = ((WebViewStateFailureAuditEvent)eventRaised).ViewStateException; wmiData.exceptionMessage = SR.GetString(vse.ShortMessage); wmiData.remoteAddress = vse.RemoteAddress; wmiData.remotePort = vse.RemotePort; wmiData.userAgent = vse.UserAgent; wmiData.persistedState = vse.PersistedState; wmiData.referer = vse.Referer; wmiData.path = vse.Path; } if (eventRaised is WebHeartbeatEvent) { #if DBG try { #endif WebHeartbeatEvent hbEvent = eventRaised as WebHeartbeatEvent; WebProcessStatistics procStats = hbEvent.ProcessStatistics; wmiData.processStartTime = WmiFormatTime(procStats.ProcessStartTime); wmiData.threadCount = procStats.ThreadCount; wmiData.workingSet = procStats.WorkingSet.ToString(CultureInfo.InstalledUICulture); wmiData.peakWorkingSet = procStats.PeakWorkingSet.ToString(CultureInfo.InstalledUICulture); wmiData.managedHeapSize = procStats.ManagedHeapSize.ToString(CultureInfo.InstalledUICulture); wmiData.appdomainCount = procStats.AppDomainCount; wmiData.requestsExecuting = procStats.RequestsExecuting; wmiData.requestsQueued = procStats.RequestsQueued; wmiData.requestsRejected = procStats.RequestsRejected; #if DBG } catch (Exception e) { Debug.Trace("WmiWebEventProvider", e.ToString()); throw; } #endif } if (eventRaised is WebBaseErrorEvent) { Exception exception = ((WebBaseErrorEvent)eventRaised).ErrorException; if (exception == null) { wmiData.exceptionType = String.Empty; wmiData.exceptionMessage = String.Empty; } else { wmiData.exceptionType = exception.GetType().Name; wmiData.exceptionMessage = exception.Message; } } if (eventRaised is WebRequestErrorEvent) { WebRequestErrorEvent reEvent = eventRaised as WebRequestErrorEvent; WebRequestInformation reqInfo = reEvent.RequestInformation; WebThreadInformation threadInfo = reEvent.ThreadInformation; FillRequestWmiDataFields(ref wmiData, reqInfo); FillErrorWmiDataFields(ref wmiData, threadInfo); } if (eventRaised is WebErrorEvent) { WebErrorEvent eEvent = eventRaised as WebErrorEvent; WebRequestInformation reqInfo = eEvent.RequestInformation; WebThreadInformation threadInfo = eEvent.ThreadInformation; FillRequestWmiDataFields(ref wmiData, reqInfo); FillErrorWmiDataFields(ref wmiData, threadInfo); } int hr = UnsafeNativeMethods.RaiseWmiEvent(ref wmiData, AspCompatApplicationStep.IsInAspCompatMode); if (hr != 0) { throw new HttpException(SR.GetString(SR.Wmi_provider_error, "0x" + hr.ToString("X8", CultureInfo.InstalledUICulture))); } }
internal SystemEventTypeInfo(WebBaseEvent dummyEvent) { this._dummyEvent = dummyEvent; this._type = dummyEvent.GetType(); }
internal static void RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, int index0, int index1) { bool flag = false; bool flag2 = false; ProcessImpersonationContext context = null; HttpContext current = HttpContext.Current; object data = CallContext.GetData("_WEvtRIP"); if ((data == null) || !((bool) data)) { eventRaised.IncrementPerfCounters(); eventRaised.IncrementTotalCounters(index0, index1); if (firingRuleInfos == null) { firingRuleInfos = HealthMonitoringManager.Manager()._sectionHelper.FindFiringRuleInfos(eventRaised.GetType(), eventRaised.EventCode); } if (firingRuleInfos.Count != 0) { try { bool[] flagArray = null; if (EtwTrace.IsTraceEnabled(5, 1) && (current != null)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_START, current.WorkerRequest, eventRaised.GetType().FullName, eventRaised.EventCode.ToString(CultureInfo.InstalledUICulture), eventRaised.EventDetailCode.ToString(CultureInfo.InstalledUICulture), null); } try { foreach (HealthMonitoringSectionHelper.FiringRuleInfo info in firingRuleInfos) { HealthMonitoringSectionHelper.RuleInfo info2 = info._ruleInfo; if (info2._ruleFiringRecord.CheckAndUpdate(eventRaised) && (info2._referencedProvider != null)) { if (!flag) { eventRaised.PreProcessEventInit(); flag = true; } if (info._indexOfFirstRuleInfoWithSameProvider != -1) { if (flagArray == null) { flagArray = new bool[firingRuleInfos.Count]; } if (flagArray[info._indexOfFirstRuleInfoWithSameProvider]) { continue; } flagArray[info._indexOfFirstRuleInfoWithSameProvider] = true; } if (EtwTrace.IsTraceEnabled(5, 1) && (current != null)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_START, current.WorkerRequest, info2._ruleSettings.Provider, info2._ruleSettings.Name, info2._ruleSettings.EventName, null); } try { if (context == null) { context = new ProcessImpersonationContext(); } if (!flag2) { CallContext.SetData("_WEvtRIP", true); flag2 = true; } info2._referencedProvider.ProcessEvent(eventRaised); } catch (Exception exception) { try { info2._referencedProvider.LogException(exception); } catch { } } finally { if (EtwTrace.IsTraceEnabled(5, 1) && (current != null)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_END, current.WorkerRequest); } } } } } finally { if (context != null) { context.Undo(); } if (flag2) { CallContext.FreeNamedDataSlot("_WEvtRIP"); } if (EtwTrace.IsTraceEnabled(5, 1) && (current != null)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_END, current.WorkerRequest); } } } catch { throw; } } } }
public override void ProcessEvent(WebBaseEvent eventRaised) { Debug.Trace("EventLogWebEventProvider", "ProcessEvent: event=" + eventRaised.GetType().Name); int hr; ArrayList dataFields = new ArrayList(35); WebEventType eventType = WebBaseEvent.WebEventTypeFromWebEvent(eventRaised); // !!! IMPORTANT note: // The order of fields added to dataFields MUST match that of the fields defined in the events // in msg.mc AddBasicDataFields(dataFields, eventRaised); if (eventRaised is WebManagementEvent) { AddWebProcessInformationDataFields(dataFields, ((WebManagementEvent)eventRaised).ProcessInformation); } if (eventRaised is WebHeartbeatEvent) { AddWebProcessStatisticsDataFields(dataFields, ((WebHeartbeatEvent)eventRaised).ProcessStatistics); } if (eventRaised is WebRequestEvent) { AddWebRequestInformationDataFields(dataFields, ((WebRequestEvent)eventRaised).RequestInformation); } if (eventRaised is WebBaseErrorEvent) { AddExceptionDataFields(dataFields, ((WebBaseErrorEvent)eventRaised).ErrorException); } if (eventRaised is WebAuditEvent) { AddWebRequestInformationDataFields(dataFields, ((WebAuditEvent)eventRaised).RequestInformation); } if (eventRaised is WebRequestErrorEvent) { AddWebRequestInformationDataFields(dataFields, ((WebRequestErrorEvent)eventRaised).RequestInformation); AddWebThreadInformationDataFields(dataFields, ((WebRequestErrorEvent)eventRaised).ThreadInformation); } if (eventRaised is WebErrorEvent) { AddWebRequestInformationDataFields(dataFields, ((WebErrorEvent)eventRaised).RequestInformation); AddWebThreadInformationDataFields(dataFields, ((WebErrorEvent)eventRaised).ThreadInformation); } if (eventRaised is WebAuthenticationSuccessAuditEvent) { dataFields.Add(((WebAuthenticationSuccessAuditEvent)eventRaised).NameToAuthenticate); } if (eventRaised is WebAuthenticationFailureAuditEvent) { dataFields.Add(((WebAuthenticationFailureAuditEvent)eventRaised).NameToAuthenticate); } if (eventRaised is WebViewStateFailureAuditEvent) { AddViewStateExceptionDataFields(dataFields, ((WebViewStateFailureAuditEvent)eventRaised).ViewStateException); } for (int i = 0; i < dataFields.Count; i++) { object field = dataFields[i]; if (field == null) { continue; } int len = ((string)field).Length; if (len > EventLogParameterMaxLength) { // Truncate it and append a warning message to the end dataFields[i] = ((string)field).Substring(0, _maxTruncatedParamLen) + _truncateWarning; } } #if !FEATURE_PAL // FEATURE_PAL does not enable IIS-based hosting features hr = UnsafeNativeMethods.RaiseEventlogEvent((int)eventType, (string[])dataFields.ToArray(typeof(string)), dataFields.Count); if (hr != 0) { throw new HttpException(SR.GetString(SR.Event_log_provider_error, "0x" + hr.ToString("X8", CultureInfo.InstalledUICulture))); } #endif // !FEATURE_PAL }
public override void ProcessEvent(WebBaseEvent eventRaised) { if (Machines.isBuildEACache_BuildCD_Crawler) return; //Filter neskodnych URL chyb string requestUrl = null; if (eventRaised is WebRequestErrorEvent) { WebRequestInformation inf = ((WebRequestErrorEvent)eventRaised).RequestInformation; requestUrl = inf.RequestUrl.ToLower(); if (Filter.isMatch(HttpContext.Current, "urls", requestUrl)) return; //foreach (string s in new string[] { "/dbimg.aspx?lang", "_vti_", "msoffice/cltreq.asp", "/news/images/bg01.gif", "_vpi.xml", "wp-rss"}) //if (inf.RequestUrl.ToLower().IndexOf(s) >= 0) return; } string err = null; if (HttpContext.Current != null) { HttpContext ctx = HttpContext.Current; err = "** LM Information **\n--------------\n"; err += "Agent: " + ctx.Request.Headers["User-Agent"] + "\n"; Uri reff = HttpContext.Current.Request.UrlReferrer; if (reff != null) { //obrazky z ciziho referera neposilat int dotPos = requestUrl.LastIndexOf('.'); if (requestUrl != null && dotPos > 0 && okAuthority.IndexOf(reff.Authority.ToLower()) < 0 && bmpExtensions.IndexOf(requestUrl.Substring(dotPos)) >= 0) return; err += "Referrer: " + reff.AbsoluteUri + "\n"; } err += "\n"; LMCookie cook = LMCookie.DeserializeCookie(ctx); if (cook != null) err += "UserId=" + cook.id.ToString() + "\n"; } err += eventRaised.ToString(); Emailer em = new Emailer(null, "*****@*****.**", eventRaised.GetType().Name, err.Replace("\n", "<br/>")); //if (err.ToLower().IndexOf("http://vyuka.lide.cz/webresource.axd") > 0) return; //em.HTML = err.Replace("\n", "<br/>"); //em.Subject = eventRaised.GetType().Name; //em.From = "*****@*****.**"; foreach (string mail in mailsTo) em.AddTo(mail); em.SendMail(); }
internal static void RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, int index0, int index1) { bool flag = false; bool flag2 = false; ProcessImpersonationContext context = null; HttpContext current = HttpContext.Current; object data = CallContext.GetData("_WEvtRIP"); if ((data == null) || !((bool)data)) { eventRaised.IncrementPerfCounters(); eventRaised.IncrementTotalCounters(index0, index1); if (firingRuleInfos == null) { firingRuleInfos = HealthMonitoringManager.Manager()._sectionHelper.FindFiringRuleInfos(eventRaised.GetType(), eventRaised.EventCode); } if (firingRuleInfos.Count != 0) { try { bool[] flagArray = null; if (EtwTrace.IsTraceEnabled(5, 1) && (current != null)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_START, current.WorkerRequest, eventRaised.GetType().FullName, eventRaised.EventCode.ToString(CultureInfo.InstalledUICulture), eventRaised.EventDetailCode.ToString(CultureInfo.InstalledUICulture), null); } try { foreach (HealthMonitoringSectionHelper.FiringRuleInfo info in firingRuleInfos) { HealthMonitoringSectionHelper.RuleInfo info2 = info._ruleInfo; if (info2._ruleFiringRecord.CheckAndUpdate(eventRaised) && (info2._referencedProvider != null)) { if (!flag) { eventRaised.PreProcessEventInit(); flag = true; } if (info._indexOfFirstRuleInfoWithSameProvider != -1) { if (flagArray == null) { flagArray = new bool[firingRuleInfos.Count]; } if (flagArray[info._indexOfFirstRuleInfoWithSameProvider]) { continue; } flagArray[info._indexOfFirstRuleInfoWithSameProvider] = true; } if (EtwTrace.IsTraceEnabled(5, 1) && (current != null)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_START, current.WorkerRequest, info2._ruleSettings.Provider, info2._ruleSettings.Name, info2._ruleSettings.EventName, null); } try { if (context == null) { context = new ProcessImpersonationContext(); } if (!flag2) { CallContext.SetData("_WEvtRIP", true); flag2 = true; } info2._referencedProvider.ProcessEvent(eventRaised); } catch (Exception exception) { try { info2._referencedProvider.LogException(exception); } catch { } } finally { if (EtwTrace.IsTraceEnabled(5, 1) && (current != null)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_END, current.WorkerRequest); } } } } } finally { if (context != null) { context.Undo(); } if (flag2) { CallContext.FreeNamedDataSlot("_WEvtRIP"); } if (EtwTrace.IsTraceEnabled(5, 1) && (current != null)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_END, current.WorkerRequest); } } } catch { throw; } } } }
public override void ProcessEvent(WebBaseEvent eventRaised) { Debug.Trace("WmiWebEventProvider", "ProcessEvent: event=" + eventRaised.GetType().Name); UnsafeNativeMethods.WmiData wmiData = new UnsafeNativeMethods.WmiData(); // Note: WMI sint64 requires a string param FillBasicWmiDataFields(ref wmiData, eventRaised); if (eventRaised is WebApplicationLifetimeEvent) { // Nothing special for this class. } if (eventRaised is WebManagementEvent) { WebProcessInformation processEventInfo = ((WebManagementEvent)eventRaised).ProcessInformation; wmiData.processId = processEventInfo.ProcessID; wmiData.processName = processEventInfo.ProcessName; wmiData.accountName = processEventInfo.AccountName; } if (eventRaised is WebRequestEvent) { FillRequestWmiDataFields(ref wmiData, ((WebRequestEvent)eventRaised).RequestInformation); } if (eventRaised is WebAuditEvent) { FillRequestWmiDataFields(ref wmiData, ((WebAuditEvent)eventRaised).RequestInformation); } if (eventRaised is WebAuthenticationSuccessAuditEvent) { wmiData.nameToAuthenticate = ((WebAuthenticationSuccessAuditEvent)eventRaised).NameToAuthenticate; } if (eventRaised is WebAuthenticationFailureAuditEvent) { wmiData.nameToAuthenticate = ((WebAuthenticationFailureAuditEvent)eventRaised).NameToAuthenticate; } if (eventRaised is WebViewStateFailureAuditEvent) { ViewStateException vse = ((WebViewStateFailureAuditEvent)eventRaised).ViewStateException; wmiData.exceptionMessage = SR.GetString(vse.ShortMessage); wmiData.remoteAddress = vse.RemoteAddress; wmiData.remotePort = vse.RemotePort; wmiData.userAgent = vse.UserAgent; wmiData.persistedState = vse.PersistedState; wmiData.referer = vse.Referer; wmiData.path = vse.Path; } if (eventRaised is WebHeartbeatEvent) { #if DBG try { #endif WebHeartbeatEvent hbEvent = eventRaised as WebHeartbeatEvent; WebProcessStatistics procStats = hbEvent.ProcessStatistics; wmiData.processStartTime = WmiFormatTime(procStats.ProcessStartTime); wmiData.threadCount = procStats.ThreadCount; wmiData.workingSet = procStats.WorkingSet.ToString(CultureInfo.InstalledUICulture); wmiData.peakWorkingSet = procStats.PeakWorkingSet.ToString(CultureInfo.InstalledUICulture); wmiData.managedHeapSize = procStats.ManagedHeapSize.ToString(CultureInfo.InstalledUICulture); wmiData.appdomainCount = procStats.AppDomainCount; wmiData.requestsExecuting = procStats.RequestsExecuting; wmiData.requestsQueued = procStats.RequestsQueued; wmiData.requestsRejected = procStats.RequestsRejected; #if DBG } catch (Exception e) { Debug.Trace("WmiWebEventProvider", e.ToString()); throw; } #endif } if (eventRaised is WebBaseErrorEvent) { Exception exception = ((WebBaseErrorEvent)eventRaised).ErrorException; if (exception == null) { wmiData.exceptionType = String.Empty; wmiData.exceptionMessage = String.Empty; } else { wmiData.exceptionType = exception.GetType().Name; wmiData.exceptionMessage = exception.Message; } } if (eventRaised is WebRequestErrorEvent) { WebRequestErrorEvent reEvent = eventRaised as WebRequestErrorEvent; WebRequestInformation reqInfo = reEvent.RequestInformation; WebThreadInformation threadInfo = reEvent.ThreadInformation; FillRequestWmiDataFields(ref wmiData, reqInfo); FillErrorWmiDataFields(ref wmiData, threadInfo); } if (eventRaised is WebErrorEvent) { WebErrorEvent eEvent = eventRaised as WebErrorEvent; WebRequestInformation reqInfo = eEvent.RequestInformation; WebThreadInformation threadInfo = eEvent.ThreadInformation; FillRequestWmiDataFields(ref wmiData, reqInfo); FillErrorWmiDataFields(ref wmiData, threadInfo); } int hr = UnsafeNativeMethods.RaiseWmiEvent(ref wmiData, AspCompatApplicationStep.IsInAspCompatMode); if (hr != 0) { throw new HttpException(SR.GetString(SR.Wmi_provider_error, "0x" + hr.ToString("X8", CultureInfo.InstalledUICulture))); } }
internal SystemEventTypeInfo(WebBaseEvent dummyEvent) { this._dummyEvent = dummyEvent; this._type = dummyEvent.GetType(); }
static internal void RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, int index0, int index1) { bool preProcessEventInitCalled = false; bool inProgressSet = false; object o; ProcessImpersonationContext ictx = null; HttpContext context = HttpContext.Current; Debug.Trace( "WebEventRaiseDetails", "Event is raised; event class = " + eventRaised.GetType().Name); // Use CallContext to make sure we detect an infinite loop where a provider calls Raise(). o = CallContext.GetData(WEBEVENT_RAISE_IN_PROGRESS); if (o != null && (bool)o) { Debug.Trace( "WebEventRaiseDetails", "An event is raised while we're raising an event. Ignore it."); return; } eventRaised.IncrementPerfCounters(); eventRaised.IncrementTotalCounters(index0, index1); // Find the list of rules that match this event if (firingRuleInfos == null) { HealthMonitoringManager manager = HealthMonitoringManager.Manager(); Debug.Assert(manager != null, "manager != null"); firingRuleInfos = manager._sectionHelper.FindFiringRuleInfos(eventRaised.GetType(), eventRaised.EventCode); } if (firingRuleInfos.Count == 0) { return; } try { bool[] matchingProviderArray = null; if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.Infrastructure) && context != null) EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_START, context.WorkerRequest, eventRaised.GetType().FullName, eventRaised.EventCode.ToString(CultureInfo.InstalledUICulture), eventRaised.EventDetailCode.ToString(CultureInfo.InstalledUICulture), null); try { foreach (HealthMonitoringSectionHelper.FiringRuleInfo firingRuleInfo in firingRuleInfos) { HealthMonitoringSectionHelper.RuleInfo ruleInfo = firingRuleInfo._ruleInfo; RuleFiringRecord record = ruleInfo._ruleFiringRecord; // Check if we should fire the event based on its throttling settings if (!record.CheckAndUpdate(eventRaised)) { Debug.Trace("WebEventRaiseDetails", "Throttling settings not met; not fired"); continue; } // It's valid for a rule to have no referenced provider if (ruleInfo._referencedProvider != null) { if (!preProcessEventInitCalled) { // The event may need to do pre-ProcessEvent initialization eventRaised.PreProcessEventInit(); preProcessEventInitCalled = true; } // For rule infos that share the same provider, the _indexOfFirstRuleInfoWithSameProvider field // is the index of the first ruleInfo among them. We use that index in the boolean array // matchingProviderArray to remember if we've already fired that provider. // This is for the scenario where several rules are pointing to the same provider, // and even if >1 rule actually fire and pass all throttling check, // the provider is stilled fired only once. if (firingRuleInfo._indexOfFirstRuleInfoWithSameProvider != -1) { if (matchingProviderArray == null) { matchingProviderArray = new bool[firingRuleInfos.Count]; } if (matchingProviderArray[firingRuleInfo._indexOfFirstRuleInfoWithSameProvider]) { Debug.Trace("WebEventRaiseDetails", "Rule with a matching provider already fired."); continue; } matchingProviderArray[firingRuleInfo._indexOfFirstRuleInfoWithSameProvider] = true; } if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.Infrastructure) && context != null) EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_START, context.WorkerRequest, ruleInfo._ruleSettings.Provider, ruleInfo._ruleSettings.Name, ruleInfo._ruleSettings.EventName, null); // In retail build, ignore errors from provider try { if (ictx == null) { ictx = new ProcessImpersonationContext(); } if (!inProgressSet) { CallContext.SetData(WEBEVENT_RAISE_IN_PROGRESS, true); inProgressSet = true; } Debug.Trace("WebEventRaiseDetails", "Calling ProcessEvent under " + HttpApplication.GetCurrentWindowsIdentityWithAssert().Name); ruleInfo._referencedProvider.ProcessEvent(eventRaised); } catch (Exception e) { try { ruleInfo._referencedProvider.LogException(e); } catch { // ignore all errors } } finally { if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.Infrastructure) && context != null) EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_END, context.WorkerRequest); } } } } finally { // Resume client impersonation if (ictx != null) { ictx.Undo(); } if (inProgressSet) { CallContext.FreeNamedDataSlot(WEBEVENT_RAISE_IN_PROGRESS); } if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Verbose, EtwTraceFlags.Infrastructure) && context != null) EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_END, context.WorkerRequest); } } catch { throw; } // Prevent Exception Filter Security Issue (ASURT 122835) }
public override void ProcessEvent(WebBaseEvent eventRaised) { Debug.Trace("MailWebEventProvider", "ProcessEvent: type =" + eventRaised.GetType() + ", ID=" + eventRaised.EventID + ", buffer=" + UseBuffering); if (UseBuffering) { base.ProcessEvent(eventRaised); } else { SendMessage(eventRaised); } }
public override void ProcessEvent(WebBaseEvent eventRaised) { Debug.Trace("EventLogWebEventProvider", "ProcessEvent: event=" + eventRaised.GetType().Name); int hr; ArrayList dataFields = new ArrayList(35); WebEventType eventType = WebBaseEvent.WebEventTypeFromWebEvent(eventRaised); // !!! IMPORTANT note: // The order of fields added to dataFields MUST match that of the fields defined in the events // in msg.mc AddBasicDataFields(dataFields, eventRaised); if (eventRaised is WebManagementEvent) { AddWebProcessInformationDataFields(dataFields, ((WebManagementEvent)eventRaised).ProcessInformation); } if (eventRaised is WebHeartbeatEvent) { AddWebProcessStatisticsDataFields(dataFields, ((WebHeartbeatEvent)eventRaised).ProcessStatistics); } if (eventRaised is WebRequestEvent) { AddWebRequestInformationDataFields(dataFields, ((WebRequestEvent)eventRaised).RequestInformation); } if (eventRaised is WebBaseErrorEvent) { AddExceptionDataFields(dataFields, ((WebBaseErrorEvent)eventRaised).ErrorException); } if (eventRaised is WebAuditEvent) { AddWebRequestInformationDataFields(dataFields, ((WebAuditEvent)eventRaised).RequestInformation); } if (eventRaised is WebRequestErrorEvent) { AddWebRequestInformationDataFields(dataFields, ((WebRequestErrorEvent)eventRaised).RequestInformation); AddWebThreadInformationDataFields(dataFields, ((WebRequestErrorEvent)eventRaised).ThreadInformation); } if (eventRaised is WebErrorEvent) { AddWebRequestInformationDataFields(dataFields, ((WebErrorEvent)eventRaised).RequestInformation); AddWebThreadInformationDataFields(dataFields, ((WebErrorEvent)eventRaised).ThreadInformation); } if (eventRaised is WebAuthenticationSuccessAuditEvent) { dataFields.Add(((WebAuthenticationSuccessAuditEvent)eventRaised).NameToAuthenticate); } if (eventRaised is WebAuthenticationFailureAuditEvent) { dataFields.Add(((WebAuthenticationFailureAuditEvent)eventRaised).NameToAuthenticate); } if (eventRaised is WebViewStateFailureAuditEvent) { AddViewStateExceptionDataFields(dataFields, ((WebViewStateFailureAuditEvent)eventRaised).ViewStateException ); } for (int i = 0; i < dataFields.Count; i++) { object field = dataFields[i]; if (field == null) { continue; } int len = ((string)field).Length; if (len > EventLogParameterMaxLength) { // Truncate it and append a warning message to the end dataFields[i] = ((string)field).Substring(0, _maxTruncatedParamLen) + _truncateWarning; } } #if !FEATURE_PAL // FEATURE_PAL does not enable IIS-based hosting features hr = UnsafeNativeMethods.RaiseEventlogEvent((int)eventType, (string[])dataFields.ToArray(typeof(string)), dataFields.Count); if (hr != 0) { throw new HttpException(SR.GetString(SR.Event_log_provider_error, "0x" + hr.ToString("X8", CultureInfo.InstalledUICulture))); } #endif // !FEATURE_PAL }