Ejemplo n.º 1
0
 public static void DiagnosticOut(string message, int LoggingLevel)                             //report status mesages to a file
 {
     try
     {
         string DiagnosticMessage = "";                                                                                  //message to be output to the file
         for (int x = 0; x < message.Length; x++)                                                                        //foreach character in the message
         {
             if (message[x] != ',')                                                                                      //if it is not a comma
             {
                 DiagnosticMessage += message[x];                                                                        //carry it over
             }
         }                                                                                                               //add all sorts of diagnostic datas
         DiagnosticMessage += ", TimeStamp:" + DateTime.Now.ToString() + ", LoggingLevelNeeded: " + LoggingLevel.ToString() + ", LoggingLevelSelected" + LogggingLevel.ToString();
         if (LoggingLevel <= LogggingLevel)                                                                              //if we are asking to see this data
         {
             using (StreamWriter DiagnosticWriter = File.AppendText(ConfigurationManager.AppSettings["DiagnosticFile"])) // @"C:\Users\d.paddock\Desktop\Diagnostic.csv")) defualt
             {
                 DiagnosticWriter.WriteLine(DiagnosticMessage);                                                          //output it to file
             }
         }
     }
     catch (Exception ex)                                                                                                //catch any errors and cry becouse we cant log them.
     {
         try                                                                                                             //try a simplified log
         {
             using (StreamWriter DiagnosticWriter = File.AppendText(ConfigurationManager.AppSettings["DiagnosticFile"])) // @"C:\Users\d.paddock\Desktop\Diagnostic.csv")) defualt
             {
                 DiagnosticWriter.WriteLine(ex.ToString());                                                              //output it to file
             }
         }
         catch (Exception Ex)//sadly giveup
         {
         }
     }
 }
Ejemplo n.º 2
0
 public void DiagnosticOut(string message, int LoggingLevel)
 {
     try
     {
         string DiagnosticMessage = "";
         for (int x = 0; x < message.Length; x++)
         {
             if (message[x] != ',')
             {
                 DiagnosticMessage += message[x];
             }
         }
         DiagnosticMessage += ", TimeStamp:" + DateTime.Now.ToString() + ", LoggingLevelNeeded: " + LoggingLevel.ToString() + ", LoggingLevelSelected" + LogggingLevel.ToString();
         if (LoggingLevel <= LogggingLevel)
         {
             MainForm.Invoke((MethodInvoker) delegate
             {
                 MainForm.DiagnosticListView.Items.Add(new ListViewItem(new string[] { ListviewIndex.ToString(), DiagnosticMessage }));
             });
             ListviewIndex++;
         }
     }
     catch (Exception ex) { DiagnosticOut(ex.ToString(), 1); }
 }