public override void ProcessEvent(BaseEvent baseEvent)
 {
     lock (this)
       {
     if (m_LastErrorTick > 0)
     {
       DateTime time1 = new DateTime(m_LastErrorTick);
       TimeSpan span1 = (TimeSpan) (DateTime.Now - time1);
       if (span1.TotalMilliseconds < 3000)
       {
     throw new EventNotProcessedException("Event not processed: waiting for remoting recovery.");
       }
     }
       }
       try
       {
     if (m_Sink != null)
     {
       m_Sink.ProcessEvent(baseEvent);
     }
     m_LastErrorTick = -1;
       }
       catch (Exception exception1)
       {
     m_LastErrorTick = DateTime.Now.Ticks;
     throw new EventNotProcessedException("Event cannot be processed.", exception1);
       }
 }
 public override void ProcessEvent(BaseEvent baseEvent)
 {
     string text1 = GetFormattedMessage(baseEvent);
       if (text1.Length > 0x7ffe)
       {
     text1 = text1.Substring(0, 0x7ffe);
       }
       m_EventLog.Source = baseEvent.Source;
       EventLogEntryType type1 = baseEvent.Severity.ConvertSeverity2EventLogEntryType();
       m_EventLog.WriteEntry(text1, type1, baseEvent.EventID, baseEvent.EventCategoryID);
 }
Beispiel #3
0
 public override void ProcessEvent(BaseEvent baseEvent)
 {
     lock (this)
       {
     if (m_Queue != null)
     {
       m_MessageCount++;
       m_Queue.Send(baseEvent);
       if ((m_TestPoisonRate > 0) && ((m_MessageCount%m_TestPoisonRate) == 0))
       {
     m_Queue.Send("Poison!");
       }
     }
       }
 }
 public override void ProcessEvent(BaseEvent baseEvent)
 {
     if (baseEvent is TraceCallEvent)
       {
     if (baseEvent is TraceCallEnterEvent)
     {
       PmcManager.CallImplicitEnterCounter(baseEvent.CallingMethod);
     }
     else if (baseEvent is TraceCallReturnEvent)
     {
       bool flag1 = ((TraceCallReturnEvent) baseEvent).Success;
       PmcManager.CallImplicitLeaveCounter(baseEvent.CallingMethod, flag1,
                                       (long) ((TraceCallReturnEvent) baseEvent).MethodTime.TotalMilliseconds);
     }
       }
 }
 public static void Serialize(BaseEvent baseEvent, IDbConnection conn, string prefix)
 {
     PropertyBag properties = baseEvent.Properties;
     if (prefix == null)
     {
         prefix = string.Empty;
     }
     if (prefix != string.Empty)
     {
         prefix = prefix + ".";
     }
     properties.Add(prefix + "ConnectionString", conn.ConnectionString);
     properties.Add(prefix + "ConnectionTimeOut", conn.ConnectionTimeout);
     properties.Add(prefix + "Database", conn.Database);
     properties.Add(prefix + "State", conn.State);
 }
 public override void ProcessEvent(BaseEvent baseEvent)
 {
     StringBuilder builder1 = new StringBuilder(0x3e8);
       if (m_ShowTimeStamp)
       {
     builder1.Append(baseEvent.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss,fff ", DateTimeFormatInfo.InvariantInfo));
       }
       if (m_ShowSeverity)
       {
     builder1.AppendFormat("[{0}] ", baseEvent.Severity.Label);
       }
       if (m_ShowSource)
       {
     builder1.AppendFormat("{0} ", baseEvent.Source);
       }
       if (m_ShowThreadInfo)
       {
     builder1.AppendFormat("[{0}] ", baseEvent.ThreadInfo);
       }
       if (m_ShowWindowsIdentity)
       {
     builder1.AppendFormat("[{0}] ", baseEvent.WindowsIdentityName);
       }
       builder1.Append(baseEvent.Message);
       builder1.Append(' ');
       if (m_ShowParameters)
       {
     int num1 = 0;
     foreach (string text1 in baseEvent.Properties.Keys)
     {
       if (num1 > 0)
       {
     builder1.Append(", ");
       }
       builder1.AppendFormat("{0}:[{1}]", text1, baseEvent.Properties[text1].ToString());
       num1++;
     }
       }
       if (builder1.Length > 0)
       {
     Console.WriteLine(builder1.ToString());
       }
 }
 public static void Serialize(BaseEvent baseEvent, SqlCommand comm, string prefix)
 {
     DbConnectionSerializer.Serialize(baseEvent, comm.Connection);
     PropertyBag properties = baseEvent.Properties;
     if (prefix == null)
     {
         prefix = string.Empty;
     }
     if (prefix != string.Empty)
     {
         prefix = prefix + ".";
     }
     properties.Add(prefix + "Text", comm.CommandText);
     foreach (SqlParameter parameter in comm.Parameters)
     {
         if (parameter.Value != null)
         {
             properties.Add(string.Format("{0}Param.{1}", prefix, parameter.ParameterName), parameter.Value);
         }
     }
 }
 public virtual void AdjustEvent(BaseEvent baseEvent, params object[] publishParams)
 {
 }
 public override void ProcessEvent(BaseEvent baseEvent)
 {
     lock (this)
       {
     if (!m_SqlChecker.Alive)
     {
       throw new EventNotProcessedException("SQL Server seems unavailable.", m_SqlChecker.LastException);
     }
     AuditEventDataContext context1 = new AuditEventDataContext(m_SqlConn);
     try
     {
       context1.BeginTransaction();
     }
     catch (Exception exception1)
     {
       throw new EventNotProcessedException("Cannot start transaction", exception1);
     }
     try
     {
       int num1;
       string text1 = (string) baseEvent.Properties["Method"];
       if (text1 != null)
       {
     baseEvent.Properties.Remove("Method");
       }
       else
       {
     text1 = string.Empty;
       }
       string text2 = (string) baseEvent.Properties["PrincipalName"];
       if (text2 != null)
       {
     baseEvent.Properties.Remove("PrincipalName");
       }
       else
       {
     text2 = string.Empty;
       }
       context1.AddEvent((DBDateTime) baseEvent.TimeStamp, (DBString) baseEvent.Severity.ToString(),
                     (DBString) baseEvent.Source, (DBString) text1, (DBString) baseEvent.ThreadInfo,
                     (DBString) baseEvent.WindowsIdentityName, (DBString) text2, (DBString) baseEvent.Message,
                     out num1);
       foreach (string text3 in baseEvent.Properties.Keys)
       {
     int num2;
     object obj1 = baseEvent.Properties[text3];
     context1.AddEventProperty((DBInt) num1, (DBString) text3,
                               (obj1 == null) ? ((DBString) "(null)") : ((DBString) obj1.ToString()), out num2);
       }
       context1.Commit();
     }
     catch (Exception exception2)
     {
       try
       {
     context1.Rollback();
       }
       catch (Exception exception3)
       {
     throw new EventNotProcessedException("Event recording cannot rolled back", exception3);
       }
       throw new EventNotProcessedException("Event recording rolled back", exception2);
     }
       }
 }
Beispiel #10
0
 public static void ReportException(Exception e, BaseEvent eventInst)
 {
     m_ErrorsOccurred++;
       if (m_ErrorsOccurred <= m_MaxErrors)
       {
     try
     {
       EventLog.WriteEntry("BaseEvent.ReportException()",
                       string.Format("Event type: '{0}' \n{1}\nEvent caller trace:\n{2}",
                                     (eventInst == null) ? "unknown" : eventInst.GetType().ToString(),
                                     e.ToString(), Environment.StackTrace), EventLogEntryType.Error);
     }
     catch
     {
       Trace.WriteLine(e.ToString());
     }
       }
 }
Beispiel #11
0
 public abstract void ProcessEvent(BaseEvent baseEvent);
 public static void Serialize(BaseEvent baseEvent, SqlCommand comm)
 {
     Serialize(baseEvent, comm, string.Empty);
 }
 public static void Serialize(BaseEvent baseEvent, IDbConnection conn)
 {
     Serialize(baseEvent, conn, string.Empty);
 }
Beispiel #14
0
 // Methods
 public EventCorrelationInfo(BaseEvent eventInfo)
 {
     Event = eventInfo;
     CorrelationID = Guid.NewGuid();
 }
 public override void ProcessEvent(BaseEvent baseEvent)
 {
     OutputDebugString(GetFormattedMessage(baseEvent));
 }
Beispiel #16
0
 public virtual string GetFormattedMessage(BaseEvent baseEvent)
 {
     StringBuilder builder1 = new StringBuilder(0x3e8);
       int num1 = 0;
       foreach (string text1 in baseEvent.Properties.Keys)
       {
     if (num1 > 0)
     {
       builder1.Append(m_PropertySeparator);
     }
     object obj1 = baseEvent.Properties[text1];
     string text2 = (obj1 == null) ? "(null)" : obj1.ToString();
     builder1.AppendFormat(m_PropertyFlatFormat, text1, text2, StringHelper.EscapeString(text2));
     num1++;
       }
       return
     string.Format(m_MessageFlatFormat,
               new object[]
                 {
                   baseEvent.TimeStamp.ToString(m_TimestampFormat, DateTimeFormatInfo.InvariantInfo),
                   baseEvent.Severity, baseEvent.ThreadInfo, baseEvent.WindowsIdentityName, baseEvent.Message,
                   StringHelper.EscapeString(baseEvent.Message), baseEvent.Source, builder1.ToString()
                 });
 }
 public override void ProcessEvent(BaseEvent baseEvent)
 {
     string text1 = GetFormattedMessage(baseEvent);
       string text2 = baseEvent.TimeStamp.ToString(m_DirDatePattern);
       string text3 = baseEvent.TimeStamp.ToString(m_FileDatePattern);
       try
       {
     if (m_Mutex != null)
     {
       m_Mutex.WaitOne();
     }
     if (((text2 != m_LatestDirValue) || (text3 != m_LatestFileValue)) || (m_Writer == null))
     {
       if (m_Writer != null)
       {
     m_Writer.Close();
       }
       m_LatestDirValue = text2;
       m_LatestFileValue = text3;
       string text4 = Path.Combine(m_TraceRoot, text2);
       string text5 = string.Format("{0}{1}{2}", m_FileBase, text3, m_Extension);
       Directory.CreateDirectory(text4);
       m_Writer = File.AppendText(Path.Combine(text4, text5));
     }
     m_Writer.WriteLine(text1);
     m_CurrentFlushCount++;
     if ((m_MutexName == string.Empty) && ((m_FlushCount <= 0) || (m_CurrentFlushCount <= m_FlushCount)))
     {
       if (m_FlushInterval <= 0)
       {
     return;
       }
       TimeSpan span1 = (TimeSpan) (DateTime.Now - m_LastFlushTime);
       if (span1.TotalMilliseconds <= m_FlushInterval)
       {
     return;
       }
     }
     m_Writer.Close();
     m_Writer = null;
     m_CurrentFlushCount = 0;
     m_LastFlushTime = DateTime.Now;
       }
       finally
       {
     if (m_Mutex != null)
     {
       m_Mutex.ReleaseMutex();
     }
       }
 }