Ejemplo n.º 1
0
 private void WriteToLogFile(LogBuffer l)
 {
     try
     {
         string logdir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         if (Directory.Exists(dir))
         {
             logdir = dir;
         }
         else
         {
             dir = "Error! Defaulting to Desktop...";
         }
         var d = dStart;
         while (FileLocker)
         {
         }
         FileLocker = true;
         string path = string.Format("{0}\\pinglogger_{1}_{2}.txt", logdir, l.name,
                                     d.Year.ToString() + d.Month.ToString() + d.Day.ToString() + d.Hour.ToString() + d.Minute.ToString() + d.Second.ToString());
         File.AppendAllText(path, l.data + Environment.NewLine);
         FileLocker = false;
     }
     catch (Exception ex) { MessageBox.Show(ex.ToString()); }
 }
Ejemplo n.º 2
0
        private void LogOutput(PingItem pi)
        {
            LogBuffer lb = new LogBuffer();
            //                           This failed if the input was null (Thomas)
            PingLogItem pii = pi.PingLog.Where(i => null != i).OrderByDescending(i => i.ID).First();

            if (pii.Failed)
            {
                string ip = "";
                foreach (var i in pi.DNSAddess)
                {
                    ip = ip == "" ? i : ";" + i;
                }
                lb.data = string.Format("\n{0} - {1} - {2} | Count: {3} | Fails: {4} | LastRT: {5} | AvgRT: {6} | PingIP: {7} | DnsIP: {8} | DNSHost: {9}",
                                        pii.TimeStamp, pi.Host, pii.Message, pi.TotalAttemps, pi.TotalFails, pii.RoundTrip, pi.AvgRoundTrip, pi.LastPingIP, ip, pi.DNSHostName);
                lb.name = pi.Host;
                Log.Add(lb);
            }
        }