public override void ProcessEvent(WebBaseEvent eventRaised)
 {
     if (eventRaised is WebBaseErrorEvent) {
         System.Diagnostics.Trace.TraceError(eventRaised.ToString());
     }
     else {
         System.Diagnostics.Trace.TraceInformation(eventRaised.ToString());
     }
 }
Beispiel #2
0
 public override void ProcessEvent(WebBaseEvent eventRaised)
 {
     if (eventRaised is WebBaseErrorEvent)
     {
         System.Diagnostics.Trace.TraceError(eventRaised.ToString());
     }
     else
     {
         System.Diagnostics.Trace.TraceInformation(eventRaised.ToString());
     }
 }
Beispiel #3
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;
        }
Beispiel #4
0
        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;
        }
        string GenerateBody(WebBaseEventCollection events,
                            int begin,
                            DateTime lastFlush,
                            int discardedSinceLastFlush,
                            int eventsInBuffer,
                            int messageSequence,
                            int eventsInNotification,
                            int eventsLostDueToMessageLimit)
        {
            StringBuilder sb          = new StringBuilder();
            int           totalEvents = events.Count;

            if (_bodyHeader != null)
            {
                sb.Append(_bodyHeader);
            }

            // Warnings
            GenerateWarnings(sb, lastFlush, discardedSinceLastFlush, messageSequence, eventsLostDueToMessageLimit);

            // Event Summary
            GenerateSummary(sb, begin, begin + totalEvents - 1, eventsInNotification, eventsInBuffer);

            // Application Info
            Debug.Assert(events.Count > 0, "events.Count > 0");
            GenerateApplicationInformation(sb);

            // Please note that it's a text message, and thus we shouldn't need to HtmlEncode it.
            for (int i = 0; i < totalEvents; i++)
            {
                WebBaseEvent eventRaised = events[i];
                string       details     = eventRaised.ToString(false, true);

                if (_maxEventLength != ProviderUtil.Infinite &&
                    details.Length > _maxEventLength)
                {
                    details = details.Substring(0, _maxEventLength);
                }

                if (i == 0)
                {
                    sb.Append(s_header_events);
                    sb.Append("\n");
                    sb.Append(_separator);
                }

                sb.Append(details);
                sb.Append("\n");
                sb.Append(_separator);
            }

            if (_bodyFooter != null)
            {
                sb.Append(_bodyFooter);
            }

            return(sb.ToString());
        }
Beispiel #6
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;
        }
 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)
 {
     TextFileLogger.Log (eventRaised.ToString());
 }
Beispiel #10
0
 public static void writeEvent(LMComDataContext ctx, WebBaseEvent ev) {
   EventsLog log = new EventsLog();
   ctx.EventsLogs.InsertOnSubmit(log);
   if (ev is CommerceEvent)
     log.Type = (short)EventCategory.Commerce;
   else if (ev is MailEvent)
     log.Type = (short)EventCategory.Mail;
   else if (ev is ErrorEvent)
     log.Type = (short)EventCategory.Error;
   else if (ev is TraceEvent)
     log.Type = (short)EventCategory.Trace;
   else if (ev is WebBaseErrorEvent)
     log.Type = (short)EventCategory.WebError;
   else if (ev is IntranetEvent)
     log.Type = (short)EventCategory.Intranet;
   else if (ev is SeznamRpcEvent)
     log.Type = (short)EventCategory.SeznamRPC;
   else if (ev is DownloadEvent)
     log.Type = (short)EventCategory.DownloadMP3;
   //else if (ev is DownloadMoodleEvent)
   //  log.Type = (short)EventCategory.DownloadMoodle;
   else if (ev is DebugEvent)
     log.Type = (short)EventCategory.debug;
   //else if (ev is PayPalEvent)
     //log.Type = (short)EventCategory.PayPal;
   else
     log.Type = (short)EventCategory.no;
   log.UtcTime = ev.EventTimeUtc;
   log.Code = ev.EventCode;
   log.DetailCode = ev.EventDetailCode;
   log.Message = ev.Message != null && ev.Message.Length > 1024 ? ev.Message.Substring(0, 1024) : ev.Message;
   log.MachineName = System.Environment.MachineName;
   string det = ev.ToString();
   if (ev is LMEvent) {
     LMEvent lme = (LMEvent)ev;
     if (lme.info != null) {
       log.App = (short)lme.info.AppId;
       log.Site = (short)lme.info.SiteId;
     }
     if (lme.cook != null && lme.cook.id > 0)
       log.UserId = lme.cook.id;
     if (ev is CommerceEvent)
       log.OrderId = ((CommerceEvent)ev).OrderId;
     if (ev is MailEvent)
       log.OrderId = ((MailEvent)ev).OrderId;
     if (lme.RequestUrl != null)
       log.RequestUrl = lme.RequestUrl!=null && lme.RequestUrl.Length>1024 ? lme.RequestUrl.Substring(0, 1024) : lme.RequestUrl;
     if (ev is PayPalEvent)
       log.OrderId = ((PayPalEvent)ev).OrderId;
   } else {
     LMCookie cook = LMStatus.CookieLow;
     if (cook != null)
       log.UserId = cook.id;
     if (HttpContext.Current != null)
       log.RequestUrl = HttpContext.Current.Request.Url.AbsolutePath;
   }
   log.Details = det;// != null && det.Length > 500 ? det.Substring(0, 500) : det;
 }
Beispiel #11
0
 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();
 }
        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;
        }