Ejemplo n.º 1
0
        private void RefreshListView(Server server)
        {
            for (int i = 0; i < listView.Items.Count; i++)
            {
                if (listView.Items[i].Tag.Equals(server))
                {
                    listView.Items[i].ImageIndex = (int)server.Status;

                    listView.Items[i].SubItems[1].Text = server.Status == Server.StatusType.Error
                        ? "Unknown" : string.Format("{0}({1})/{2}", server.LoginedUser, server.AllocatedUser, server.MaxUser);
                    listView.Items[i].SubItems[2].Text = server.Status == Server.StatusType.Error
                       ? "Unknown" : string.Format("{0:F1}%", server.Cpu);
                    listView.Items[i].SubItems[3].Text = server.Status == Server.StatusType.Error
                        ? "Unknown" : string.Format("{0:F1}MB", (float)server.Memory / 1048576);
                    listView.Items[i].SubItems[4].Text = server.Status == Server.StatusType.Error
                        ? "Unknown" : string.Format("{0:F1}ms", server.ResponseInterval);
                    listView.Items[i].SubItems[5].Text = server.Description;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 private void SendMail(Server server)
 {
     if (!string.IsNullOrEmpty(Config.EmailServer) && !string.IsNullOrEmpty(Config.EmailAddress) && !string.IsNullOrEmpty(Config.EmailUser))
     {
         try
         {
             SendMailMethod call = delegate(Server srv)
             {
                 MailMessage mailMessage = new MailMessage(Config.EmailUser, Config.EmailAddress);
                 mailMessage.Subject = string.Format("EEPServer {0} at {1:yyyy-MM-dd HH:mm:ss}", srv.Status, DateTime.Now);
                 mailMessage.Body = srv.ToString();
                 SmtpClient smtpClient = new SmtpClient(Config.EmailServer);
                 smtpClient.EnableSsl = Config.EnableSSL;
                 smtpClient.UseDefaultCredentials = false;
                 smtpClient.Credentials = new NetworkCredential(Config.EmailUser, Config.EmailPassword);
                 smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                 smtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted);
                 smtpClient.SendAsync(mailMessage, null);
             };
             this.Invoke(call, new object[] { server });
         }
         catch { }
     }
 }
Ejemplo n.º 3
0
 private void Log(Server server)
 {
     lock (this)
     {
         try
         {
             using (StreamWriter writer = new StreamWriter(LOG_FILE, true, Encoding.UTF8))
             {
                 StringBuilder builder = new StringBuilder();
                 builder.Append('-', 30);
                 builder.AppendLine();
                 builder.Append(server.ToString());
                 builder.AppendLine();
                 writer.WriteLine(builder.ToString());
             }
         }
         catch { }
     }
 }