private void FillBasicWmiDataFields(ref UnsafeNativeMethods.WmiData wmiData, WebBaseEvent eventRaised)
        {
            WebApplicationInformation applicationInformation = WebBaseEvent.ApplicationInformation;

            wmiData.eventType       = (int)WebBaseEvent.WebEventTypeFromWebEvent(eventRaised);
            wmiData.eventCode       = eventRaised.EventCode;
            wmiData.eventDetailCode = eventRaised.EventDetailCode;
            wmiData.eventTime       = this.WmiFormatTime(eventRaised.EventTime);
            wmiData.eventMessage    = eventRaised.Message;
            wmiData.sequenceNumber  = eventRaised.EventSequence.ToString(CultureInfo.InstalledUICulture);
            wmiData.occurrence      = eventRaised.EventOccurrence.ToString(CultureInfo.InstalledUICulture);
            wmiData.eventId         = eventRaised.EventID.ToString("N", CultureInfo.InstalledUICulture);
            wmiData.appDomain       = applicationInformation.ApplicationDomain;
            wmiData.trustLevel      = applicationInformation.TrustLevel;
            wmiData.appVirtualPath  = applicationInformation.ApplicationVirtualPath;
            wmiData.appPath         = applicationInformation.ApplicationPath;
            wmiData.machineName     = applicationInformation.MachineName;
            if (eventRaised.IsSystemEvent)
            {
                wmiData.details = string.Empty;
            }
            else
            {
                WebEventFormatter formatter = new WebEventFormatter();
                eventRaised.FormatCustomEventDetails(formatter);
                wmiData.details = formatter.ToString();
            }
        }
Exemple #2
0
        public override void ProcessEvent(WebBaseEvent eventRaised)
        {
            ArrayList    dataFields = new ArrayList(0x23);
            WebEventType type       = WebBaseEvent.WebEventTypeFromWebEvent(eventRaised);

            this.AddBasicDataFields(dataFields, eventRaised);
            if (eventRaised is WebManagementEvent)
            {
                this.AddWebProcessInformationDataFields(dataFields, ((WebManagementEvent)eventRaised).ProcessInformation);
            }
            if (eventRaised is WebHeartbeatEvent)
            {
                this.AddWebProcessStatisticsDataFields(dataFields, ((WebHeartbeatEvent)eventRaised).ProcessStatistics);
            }
            if (eventRaised is WebRequestEvent)
            {
                this.AddWebRequestInformationDataFields(dataFields, ((WebRequestEvent)eventRaised).RequestInformation);
            }
            if (eventRaised is WebBaseErrorEvent)
            {
                this.AddExceptionDataFields(dataFields, ((WebBaseErrorEvent)eventRaised).ErrorException);
            }
            if (eventRaised is WebAuditEvent)
            {
                this.AddWebRequestInformationDataFields(dataFields, ((WebAuditEvent)eventRaised).RequestInformation);
            }
            if (eventRaised is WebRequestErrorEvent)
            {
                this.AddWebRequestInformationDataFields(dataFields, ((WebRequestErrorEvent)eventRaised).RequestInformation);
                this.AddWebThreadInformationDataFields(dataFields, ((WebRequestErrorEvent)eventRaised).ThreadInformation);
            }
            if (eventRaised is WebErrorEvent)
            {
                this.AddWebRequestInformationDataFields(dataFields, ((WebErrorEvent)eventRaised).RequestInformation);
                this.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)
            {
                this.AddViewStateExceptionDataFields(dataFields, ((WebViewStateFailureAuditEvent)eventRaised).ViewStateException);
            }
            for (int i = 0; i < dataFields.Count; i++)
            {
                object obj2 = dataFields[i];
                if ((obj2 != null) && (((string)obj2).Length > 0x7ffe))
                {
                    dataFields[i] = ((string)obj2).Substring(0, this._maxTruncatedParamLen) + "...";
                }
            }
            int num = UnsafeNativeMethods.RaiseEventlogEvent((int)type, (string[])dataFields.ToArray(typeof(string)), dataFields.Count);

            if (num != 0)
            {
                throw new HttpException(System.Web.SR.GetString("Event_log_provider_error", new object[] { "0x" + num.ToString("X8", CultureInfo.InstalledUICulture) }));
            }
        }
Exemple #3
0
        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
        }