Exemple #1
0
        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);
        }
Exemple #2
0
 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);
     }
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 public ResponseWarning(WarningReason reason, string message, string detailedMessage)
 {
     Reason          = reason;
     Message         = message;
     DetailedMessage = detailedMessage;
 }
Exemple #5
0
 public static DateTime GetLastWarningOf(string id, WarningReason reason)
 {
     return(GetLastWarningOf(id, reason, ""));
 }
Exemple #6
0
 private static int FindLastWarningLineNumber(string id, WarningReason reason, ref long ticks)
 {
     return(FindLastWarningLineNumber(id, reason, ref ticks, ""));
 }
Exemple #7
0
 public static void LogWarning(string id, WarningReason reason)
 {
     LogWarning(id, reason, "");
 }