private void Log(Event e) { try { if (LogMessageUpdate != null) { string /*description*/ dsc = "no description"; if (!string.IsNullOrWhiteSpace(e.Description)) dsc = e.Description.Trim(); string /*stack trace*/ trc = string.Empty; if (!string.IsNullOrWhiteSpace(e.StackTrace)) trc = " " + e.StackTrace.Trim(); string /*type*/ typ = "unknown type"; if (!string.IsNullOrWhiteSpace(e.Type)) typ = e.Type.Trim(); LogMessageUpdate((DateTime)e.DateAndTime, ": " + typ + "; " + dsc + trc); } using (EventsLoggerEndpoint endpoint = new EventsLoggerEndpoint()) using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { endpoint.LogEvent(e); scope.Complete(); } } catch { } }
private void Log(string type, string message, string objectId, Int32 line) { try { Event workEvent = new Event(type, DateTime.Now, System.Environment.MachineName, Process.GetCurrentProcess().ProcessName, message, null, objectId, line); Log(workEvent); } catch { } }
public override void LogEvent(Event info) { try { _LogDatabase.InsertEvent(info); _Logger.LogMessage(info); } catch (Exception exp) { _Logger.LogMessage(exp.Message); } }
public void LogError(string message, StackTrace stackTrace) { Event workEvent = new Event("Error", DateTime.Now, System.Environment.MachineName, Process.GetCurrentProcess().ProcessName, message, null, stackTrace.GetFrame(0).GetMethod().ReflectedType.Name + "." + stackTrace.GetFrame(0).GetMethod().Name, stackTrace.GetFrame(0).GetFileLineNumber(), stackTrace.ToString()); Log(workEvent); }
public void InsertEvent(Event eventToAdd) { string insertString = string.Empty; string valueString = string.Empty; UpdateInsertString(ref insertString, ref valueString, "datetime", ((DateTime)eventToAdd.DateAndTime).ToString(_dateTimeFormat)); UpdateInsertString(ref insertString, ref valueString, "type", eventToAdd.Type); UpdateInsertString(ref insertString, ref valueString, "computer", eventToAdd.ComputerName); UpdateInsertString(ref insertString, ref valueString, "application", eventToAdd.Application); UpdateInsertString(ref insertString, ref valueString, "description", eventToAdd.Description.Replace("'", "''")); UpdateInsertString(ref insertString, ref valueString, "username", eventToAdd.UserName); UpdateInsertString(ref insertString, ref valueString, "object", eventToAdd.Object); UpdateInsertString(ref insertString, ref valueString, "lineNum", eventToAdd.Line.ToString()); UpdateInsertString(ref insertString, ref valueString, "stackTrace", eventToAdd.StackTrace); base.InsertIntoDatabase("INSERT INTO LogTable (" + insertString + ") VALUES (" + valueString + ")"); }
private void Log (string type, string message) { Event tmpEvent = new Event(type, DateTime.Now, System.Environment.MachineName, Process.GetCurrentProcess().ProcessName, message); Log(tmpEvent); }
public virtual void LogEvent(Event info) { }
public void LogMessage(Event info) { DisplayMessage(info.DateAndTime + ", " + info.ComputerName + ", " + info.Type + ", " + info.Application + ", " + info.Object + ", " + info.Line + ", " + info.Description + "\r"); }