internal void CopyToClipBoard(MachineToTestDisplay machineSelected) { if (machineSelected == null) { return; } Clipboard.SetText(machineSelected.NomMachine); Notify.ShowNotification("Copié", machineSelected.NomMachine + " dans le presse-papiers !", System.Windows.Forms.ToolTipIcon.Info, 3); }
/// <summary> /// Méthode qui va ping la machine. /// </summary> /// <param name="machine"></param> /// <returns></returns> private async Task PingMachine(MachineToTestDisplay machine) { var oldValue = machine.StatusMachine; machine.StatusMachine = Status.InTesting; ReponsePing resultPing = await Reseau.PingHostAsync(machine.NomMachine); if (resultPing.IsPingable) { machine.StatusMachine = Status.Connected; if (oldValue == Status.NotConnected) { Notify.ShowNotification("PING", machine.NomMachine + " en ligne", System.Windows.Forms.ToolTipIcon.Info); } // Résoudre le DNS. var adresses = await Reseau.DnsTestAsync(machine.NomMachine); int nbreIp = adresses.Count(); switch (nbreIp) { // Si 0, pas de DNS configuré. case 0: machine.IpAdresse = "Aucun adresse IP trouvé"; machine.DnsStatus = StatusDns.NoDns; break; case 1: machine.IpAdresse = adresses.First(); machine.DnsStatus = StatusDns.GoodDns; break; // DNS qui contient plusieurs IP pour la même adresse. default: machine.IpAdresse = string.Join(" - ", adresses); machine.DnsStatus = StatusDns.ErrorDns; break; } } else { if (oldValue == Status.Connected) { Notify.ShowNotification("PING", machine.NomMachine + " déconnecté", System.Windows.Forms.ToolTipIcon.Error); } machine.StatusMachine = Status.NotConnected; } machine.Temps = resultPing.TimePing; }
internal async Task Ping(MachineToTestDisplay machine) { try { await PingMachine(machine); } catch (Exception ex) { LogErreur(ex); Notify.ShowNotification("Erreur", "Erreur ajouté au fichier log", System.Windows.Forms.ToolTipIcon.Error); } }
private string GetParam(MachineToTestDisplay machine) { var parametre = machine.Description.Split('[', ']'); if (parametre.Length > 1) { return(parametre[1]); } else { return(string.Empty); } }
internal async Task DeleteMachine(MachineToTestDisplay selected) { try { ListeDesMachines.Remove(selected); await SaveToFile(); } catch (Exception ex) { LogErreur(ex); Notify.ShowNotification("Erreur", "Erreur ajouté au fichier log", System.Windows.Forms.ToolTipIcon.Error); } }
internal async Task AddMachine(string machine, string description) { try { MachineToTestDisplay nouvelleMachine = new MachineToTestDisplay(machine, description); ListeDesMachines.Add(nouvelleMachine); await SaveToFile(); } catch (Exception ex) { LogErreur(ex); Notify.ShowNotification("Erreur", "Erreur ajouté au fichier log", System.Windows.Forms.ToolTipIcon.Error); } }