public void PerformBatchPing(GroupItem group)
 {
     foreach (var host in group.Hosts)
     {
         Ping p = new Ping();
         p.PingCompleted += new PingCompletedEventHandler(PerformPingCompleted);
         p.SendAsync(host.HostName, host);
     }
 }
 public void PerformBatchShutdown(GroupItem g, string CommandText)
 {
     foreach (var host in g.Hosts)
     {
         if (host.AllowShutdown)
         {
             string command = CommandText.Replace("{MachineName}", host.HostName);
             PerformSystemCommand(command);
         }
         else
         {
             System.Diagnostics.Debug.WriteLine("Shutdown not permitted for host:"+host.HostName);
         }
     }
 }
        public void LoadHosts()
        {
            Groups = new List<GroupItem>();

            XDocument xdoc = XDocument.Load("HostGroup.xml");
            var groups = xdoc.Elements("groups");
            foreach(XElement g in groups.Elements("group"))
            {
                GroupItem grp = new GroupItem();
                grp.Title = g.Attribute("title").Value;
                grp.Hosts = new List<HostDetails>();

                var items = g.Elements("item");

                foreach (var val in items)
                {
                    HostDetails host = new HostDetails();
                    host.HostName = val.Value;
                    host.AllowShutdown = val.Attribute("allowshutdown") != null ? bool.Parse(val.Attribute("allowshutdown").Value) : true;
                    grp.Hosts.Add(host);
                }
                Groups.Add(grp);
            }
        }