private static int FindLastWarningLineNumber(string id, WarningReason reason, ref long ticks, string extraData) { StreamReader sr = null; try { int lineNumber = -1; int count = 0; if (Monitor.TryEnter(_warningsFile, 500)) { sr = File.OpenText(_warningsFile); string line = sr.ReadLine(); while (!string.IsNullOrEmpty(line)) { if (line.Contains(id + ";" + reason.ToString() + ";")) { string[] s = line.Split(';'); if (s[3] == extraData) { ticks = long.Parse(s[2]); lineNumber = count; } } count++; line = sr.ReadLine(); } sr.Close(); sr.Dispose(); } else { LogEventLevel("Could not get lock on warningsFile!!", 1); } Monitor.Exit(_warningsFile); return(lineNumber); } catch (Exception er) { Monitor.Exit(_warningsFile); if (sr != null) { try { sr.Close(); sr.Dispose(); } catch (Exception erm) { LogError(erm); } } LogError(er); } return(-1); }
public static void LogWarning(string id, WarningReason reason, string extraData) { try { if (Monitor.TryEnter(_warningsFile, 500)) { File.AppendAllText(_warningsFile, id + ";" + reason.ToString() + ";" + DateTime.Now.Ticks.ToString() + ";" + extraData + ";\n"); Monitor.Exit(_warningsFile); } else { LogEventLevel("Could not get lock on warningsFile!!", 1); } } catch (Exception er) { LogError(er); } }
public static DateTime GetLastWarningOf(string id, WarningReason reason, string extraData) { try { long ticks = -1; FindLastWarningLineNumber(id, reason, ref ticks, extraData); if (ticks != -1) { return(new DateTime(ticks)); } else { return(DateTime.MinValue); } } catch (Exception er) { LogError(er); } return(DateTime.MinValue); }
public ResponseWarning(WarningReason reason, string message, string detailedMessage) { Reason = reason; Message = message; DetailedMessage = detailedMessage; }
public static DateTime GetLastWarningOf(string id, WarningReason reason) { return(GetLastWarningOf(id, reason, "")); }
private static int FindLastWarningLineNumber(string id, WarningReason reason, ref long ticks) { return(FindLastWarningLineNumber(id, reason, ref ticks, "")); }
public static void LogWarning(string id, WarningReason reason) { LogWarning(id, reason, ""); }