Ejemplo n.º 1
0
 private void OnEventRecordWritten(object sender, EventRecordWrittenEventArgs e)
 {
     try
     {
         string[] propertyQueries = new string[] { "Event/EventData/Data[@Name=\"IpAddress\"]" };
         EventLogPropertySelector propertySelector = new EventLogPropertySelector(propertyQueries);
         string str = ((EventLogRecord)e.EventRecord).GetPropertyValues(propertySelector)[0].ToString();
         NegotiationdEventArgs data = new NegotiationdEventArgs
         {
             IpAddress       = str,
             EventId         = e.EventRecord.Id,
             EventName       = e.EventRecord.LogName,
             EventMessageXml = e.EventRecord.ToXml(),
             CreateDate      = e.EventRecord.TimeCreated.Value
         };
         if (Negotiated != null)
         {
             Negotiated(this, data);
         }
     }
     catch (Exception exception)
     {
         WriteEntry(exception.Message);
     }
 }
Ejemplo n.º 2
0
 void activity_Negotiated(object sender, NegotiationdEventArgs data)
 {
     if (Command.Connection.State != ConnectionState.Open)
     {
         Command.Connection.Open();
     }
     Command.Parameters.Clear();
     Command.Parameters.AddWithValue("@IP", data.IpAddress);
     Command.Parameters.AddWithValue("@EventID", data.EventId);
     Command.Parameters.AddWithValue("@EventName", data.EventName);
     Command.Parameters.AddWithValue("@EventMessage", data.EventMessageXml);
     Command.Parameters.AddWithValue("@Created", data.CreateDate);
     Command.ExecuteNonQuery();
     Command.Connection.Close();
 }