private async void Form1_Load(object sender, EventArgs e) { ServerStatus ss = new ServerStatus(); ss.Address = "149.202.223.29"; ss.Timeout = 3000; await ss.Update(); var rulez = ss.Info.Map; var sname = ss.Info.ServerName; var state = ss.State; var name = "Dashboard : " + sname; label4.Text = rulez.ToString(); if (ss.Timeout.Equals(3000)) { lbltitle.Text = name; lbltitle.ForeColor = Color.Green; } else { lbltitle.Text = "Serveur OFF :("; lbltitle.ForeColor = Color.Green; } var ply = ss.Info.PlayerCount; this.circularProgressBar1.Text = ply.ToString(); int maxply = ss.Info.MaxPlayerCount; circularProgressBar1.Maximum = maxply; circularProgressBar1.Value = ply; listBox1.Items.Clear(); foreach (var players in ss.Players.Players) { listBox1.Items.Add(players); } { }; }
private bool SaveItem() { bool success = false; if (IsMonitoringAdmin) { try { bool isUpdate = (IView == ItemView.Edit); item = (isUpdate) ? new SPA.ServerStatus(ItemID) : new SPA.ServerStatus(); item.Name = txtName.Text.Trim(); item.Description = txtDescription.Text.Trim(); item.ModifiedBy = CurrentUser.DisplayName; if (!isUpdate) { item.CreatedBy = item.ModifiedBy; if (item.Insert()) { success = true; } } else { if (item.Update()) { success = true; } } ItemID = (success) ? item.ID : 0; } catch (Exception ex) { SPA.Error.WriteError(ex); if (ShowDebug) { lblErrorMessage.Text = ex.ToString(); } } } return(success); }
private async void btnDashboard_Click(object sender, EventArgs e) { pnlNav.Height = btnDashboard.Height; pnlNav.Top = btnDashboard.Top; pnlNav.Left = btnDashboard.Left; btnDashboard.BackColor = Color.FromArgb(46, 51, 73); btnContact.BackColor = Color.FromArgb(24, 30, 54); btnData.BackColor = Color.FromArgb(24, 30, 54); btnWebsite.BackColor = Color.FromArgb(24, 30, 54); ServerStatus ss = new ServerStatus(); var ip = "149.202.223.29"; ss.Address = ip; await ss.Update(); var sname = ss.Info.ServerName; var name = "Dashboard : " + sname; lbltitle.Text = name; Task tsk = Task.Run(async() => { try { ss.Address = ip; await ss.Update(); var ply = ss.Info.PlayerCount; int maxply = ss.Info.MaxPlayerCount; circularProgressBar1.Maximum = maxply; circularProgressBar1.Value = ply; this.circularProgressBar1.Text = ply.ToString(); listBox1.Items.Clear(); foreach (var players in ss.Players.Players) { listBox1.Items.Add(players); } { }; // label1.Text = ply.ToString(); } catch (Exception error) { } }); if (tsk.Wait(TimeSpan.FromSeconds(14))) { ss.Timeout = 3000; } else { ss.Timeout = 3000; }; }
private async void updateBtn_ClickAsync(object sender, EventArgs e) { await st.Update(); }