void HandleException(TableSourceDevicesMain source, ServerInteractionException ex) { Console.WriteLine("Exception while getting devices from server"); Console.WriteLine(ex); WarningMessage.Display("Could not refresh devices", "Exception while getting devices from server", this); // Show an empty list source.serverDevices = new List <List <Device> >(); TableView.ReloadData(); }
/// <summary> /// This method should be called if the list of devices should be updated from the server. /// This method is called for example when pull-to-refresh is performed. /// </summary> public void RefreshDeviceList() { TableSourceDevicesMain source = new TableSourceDevicesMain(this); source.serverDevices = new List <List <Device> >(); if (Globals.LocalLogin) { source.numberOfServers = int.Parse(strings.defaultNumberOfServers); try { devices = Globals.LocalServerinteractor.GetDevices(); source.serverDevices.Add(devices); } catch (ServerInteractionException ex) { HandleException(source, ex); } } else // Global login (possibly multiple servers) { // Complete list of devices, used in SpeechRecognition devices = new List <Device>(); source.numberOfServers = Globals.GetNumberOfSelectedServers(); foreach (HestiaServerInteractor interactor in Globals.GetInteractorsOfSelectedServers()) { try { List <Device> tempDevices = interactor.GetDevices(); source.serverDevices.Add(tempDevices); devices.AddRange(tempDevices); } catch (ServerInteractionException ex) { HandleException(source, ex); } } } DevicesTable.Source = source; }