コード例 #1
0
ファイル: Utils.cs プロジェクト: jemc771/MongoREST
 public static void logRelevantInformation(LogFile log, Dictionary<string, Type> extraTypes)
 {
   if (log != null)
   {
     // Get the operating system version.
     OperatingSystem os = Environment.OSVersion;
     log.writeToLogFile(LogType.LOG_CONFIG, "Config", "Server {0}", os.VersionString);
     Version ver = Environment.Version;
     log.writeToLogFile(LogType.LOG_CONFIG, "Config", "CLR Version {0}", ver.ToString());
     // Get the version of the main assembly.
     AssemblyName assemName = Assembly.GetEntryAssembly().GetName();
     log.writeToLogFile(LogType.LOG_CONFIG, "Config", "Main Application {0}, Version {1}", assemName.Name, assemName.Version.ToString());
     // Get the version of the GeneralUtilities assembly.
     assemName = Assembly.GetAssembly(log.GetType()).GetName();
     log.writeToLogFile(LogType.LOG_CONFIG, "Config", "{0} dll, Version {1}", assemName.Name, assemName.Version.ToString());
     foreach (KeyValuePair<string, Type> t in extraTypes)
     {
       // Get the version of the this Terminal Server assembly.
       assemName = Assembly.GetAssembly(t.Value).GetName();
       log.writeToLogFile(LogType.LOG_CONFIG, "Config", "{0} {1}, Version {2}", assemName.Name, t.Key, assemName.Version.ToString());
     }
   }
 }
コード例 #2
0
ファイル: Utils.cs プロジェクト: jemc771/MongoREST
 public static void LogProcessInformation(LogFile log)
 {
   Process proc = Process.GetCurrentProcess();
   try
   {
     string str = "";
     int count = proc.Threads.Count;
     int count2 = (proc.Threads).OfType<System.Diagnostics.ProcessThread>().Where(t => t.ThreadState == System.Diagnostics.ThreadState.Running).Count();
     str = string.Format(" {{ \"ProcessInformation\" : {{\"Cantidad de Threads\" : \"{0}\", \"ProcessThread Running\": \"{1}\"  ", count, count2);
     str = string.Format("{0}, \"WorkingSet64\": \"{1}\" ", str, ((float)proc.WorkingSet64 / 1024 / 1024).ToString("#.####"));
     str = string.Format("{0}, \"PagedMemorySize64\": \"{1}\" ", str, ((float)proc.PagedMemorySize64 / 1024 / 1024).ToString("#.####"));
     str = string.Format("{0}, \"VirtualMemorySize64\" : \"{1}\" ", str, ((float)proc.VirtualMemorySize64 / 1024 / 1024).ToString("#.####"));
     str = string.Format("{0}, \"UserProcessorTime\" : \"{1}\" ", str, proc.UserProcessorTime);
     str = string.Format("{0}, \"TotalProcessorTime\" : \"{1}\" }} }}", str, proc.TotalProcessorTime);
     log.writeToLogFile(LogType.LOG_ALERT, "LogProcessInformation", str);
   }
   catch (Exception ex)
   {
     log.writeToLogFile(LogType.LOG_ALERT, "LogProcessInformation", "Error processing information: {0}", ex.Message);
   }
   proc.Dispose();
   proc = null;
   log.Flush();
 }
コード例 #3
0
ファイル: Utils.cs プロジェクト: jemc771/IRIEXTREME
 public static bool sendReport(UdpClient client, IPEndPoint to, Byte[] msg, int timeOut, int retries, LogFile log)
 {
     Byte[] received = new Byte[msg.Count()];
       int loop = 0;
       int nBytesSent;
       String dataReceived;
       string strRecv;
       bool response = false;
       do
       {
     try
     {
       nBytesSent = client.Send(msg, msg.Length);
       log.writeToLogFile(string.Format("message sent: {0}", System.Text.ASCIIEncoding.ASCII.GetString(msg)));
     }
     catch (Exception ex)
     {
       log.writeToLogFile("Excepcion al enviar udp : {0}", ex.Message);
     }
     Thread.Sleep(250);
     client.Client.ReceiveTimeout = timeOut * 2;
     for (int i = 0; i < 5; i++)
     {
       if (client.Available > 0)
       {
     try
     {
       received = client.Receive(ref to);
       dataReceived = System.Text.Encoding.ASCII.GetString(received);
       strRecv = System.Text.Encoding.ASCII.GetString(received).Trim('\0');
       log.writeToLogFile(string.Format("message response: {0}", strRecv));
       response = true;
       break;
     }
     catch (Exception ex)
     {
       log.writeToLogFile("Excepcion al recibir udp : {0}", ex.Message);
     }
       }
       else
       {
     //si ya lo envió, dale mas tiempo al server
     log.writeToLogFile("Extra time para recibir udp : {0}", timeOut * (loop + 1));
     Thread.Sleep(timeOut * (loop + 1));
       }
     }
     loop++;
       } while (!response && loop < retries);
       return response;
 }