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();
            }
        }
Example #2
0
        private void AddBasicDataFields(ArrayList dataFields, WebBaseEvent eventRaised)
        {
            WebApplicationInformation applicationInformation = WebBaseEvent.ApplicationInformation;

            dataFields.Add(eventRaised.EventCode.ToString(CultureInfo.InstalledUICulture));
            dataFields.Add(eventRaised.Message);
            dataFields.Add(eventRaised.EventTime.ToString());
            dataFields.Add(eventRaised.EventTimeUtc.ToString());
            dataFields.Add(eventRaised.EventID.ToString("N", CultureInfo.InstalledUICulture));
            dataFields.Add(eventRaised.EventSequence.ToString(CultureInfo.InstalledUICulture));
            dataFields.Add(eventRaised.EventOccurrence.ToString(CultureInfo.InstalledUICulture));
            dataFields.Add(eventRaised.EventDetailCode.ToString(CultureInfo.InstalledUICulture));
            dataFields.Add(applicationInformation.ApplicationDomain);
            dataFields.Add(applicationInformation.TrustLevel);
            dataFields.Add(applicationInformation.ApplicationVirtualPath);
            dataFields.Add(applicationInformation.ApplicationPath);
            dataFields.Add(applicationInformation.MachineName);
            if (eventRaised.IsSystemEvent)
            {
                dataFields.Add(null);
            }
            else
            {
                WebEventFormatter formatter = new WebEventFormatter();
                eventRaised.FormatCustomEventDetails(formatter);
                dataFields.Add(formatter.ToString());
            }
        }
Example #3
0
        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;
        }
        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;
        }