public void AddHost(Host host) { host.Id = Configuration.HostIdentity; Configuration.HostIdentity++; HostsList.Add(host); UpdateXml <Host>(HostsList); }
public Host GetHostById(int Id) { var host = HostsList.FirstOrDefault(c => c.Id == Id); host.RelatedHostingUnit = GetHostingUnits(c => c.OwnerId == Id).ToList(); return(host); }
private void Add(object sender, RoutedEventArgs e) { var newRecord = new Hosts.IpHostRecord("127.0.0.1"); _Records.Add(newRecord); HostsList.DataContext = null; HostsList.DataContext = _Records; HostsList.ScrollIntoView(newRecord); }
public void DeleteHost(int Id) { int index = HostsList.FindIndex(c => c.Id == Id); if (index > -1) { HostsList.RemoveAt(index); } UpdateXml <Host>(HostsList); }
public List <Host> GetAllHosts(Func <Host, bool> predicate = null) { if (predicate != null) { return(HostsList.Where(predicate).ToList()); } else { return(HostsList); } }
private void AppendHostsList() { if (HostsList == null) { HostsList = new List <string>(); } if (HostsListFile.IsBlank()) { return; } //todo: handle missing file HostsList.AddRange(File.ReadAllLines(HostsListFile)); }
static void Main(string[] args) { calendar = new Calendar(filepath); hostsList = new HostsList(); try { Console.WriteLine(" <<< Welcome to HPN Calendar System >>> "); Console.WriteLine(" <<< Version TUMS 1.0 >>> "); Console.WriteLine("____________________________________________________"); Console.WriteLine("In which port number you want to run this host?"); Console.WriteLine("The port number must be between 1025 & 65535."); Console.WriteLine("Default port number is {0}. Enter 0 to use default.", DefaultPort.portNumber); Console.WriteLine("Enter -1 to exit program."); Console.Write("Please enter the port number : "); int port = Reader.nextInt(); while ((port < 1025 || port > 65535) && port > 0) { Console.WriteLine("The port number that you have entered is not valid."); Console.Write("Please enter the port number : "); port = Reader.nextInt(); } if (port < 0) { Console.WriteLine("The HPN Calendar System has stoped by user."); Environment.Exit(0); } else if (port == 0) { port = DefaultPort.portNumber; } Console.WriteLine("The port number has assigned to : " + port); server = new HpnXmlRpcServer(port); server.Add("Calendar", calendar); server.Add("CalendarNetwork", hostsList); server.startServing(); //Start the xml-rpc server for test. Console.WriteLine("The XML-RPC server has checked : Ok."); Console.WriteLine("The host has run on this address : http://" + LocalNet.IpAddress + ":" + port + "/"); //the local host must be add to the host list as a host. //but not here, when we make the client instance so we will pass the port number //and then in the hpn.cs.xml.client.HpnXmlRpcClient class in its contractor will add the local host and its port to the host list while (true) { Console.Write("Do you want to create a new Calendar Network? [Y/N] : "); char response = Reader.nextChar(); if (response == 'n' || response == 'N') { server.signOff(); //Sign off the server to show the joining menu Console.WriteLine("The host is working in its offline mode, to connect to an existing network please use the following command list."); break; } else if (response == 'y' || response == 'Y') { break; } else { Console.WriteLine("The character that you have entered ['" + response + "'] is not correct. You can just enter a character from the set {'n','N','y','Y'}."); } } //The port of this machine must be send to register the local host as the first host in the host list //And the calendar must be send to be able to get the list of appointments in offline mode because in offline mode //the local server is signed off and can't response to the local client requests. client = HpnXmlRpcClient.getHpnXmlRpcClient(port, calendar); while (true) { client.controlPanel(); } } catch (Exception e) { Console.WriteLine(e.Message); } //End of try }//End of main
public CreateHostCommandHandler(HostsList hosts) { _hosts = hosts; }
public GetHostsListQueryHandler(HostsList hosts) { _hosts = hosts; }
public DeleteHostCommandHandler(HostsList hosts) { _hosts = hosts; }