/// <summary> /// Gets a list of commands sent to the device for the specified filter criteria. /// </summary> /// <param name="deviceGuid">Device unique identifier.</param> /// <param name="filter">Notification filter criteria.</param> /// <returns>A list of <see cref="Command"/> objects that match specified filter criteria.</returns> public async Task <List <Command> > GetCommandsAsync(string deviceGuid, CommandFilter filter) { if (string.IsNullOrEmpty(deviceGuid)) { throw new ArgumentException("DeviceGuid is null or empty!", "deviceGuid"); } return(await _restClient.GetAsync <List <Command> >( string.Format("device/{0}/command", deviceGuid) + RestClient.MakeQueryString(filter))); }
/// <summary> /// Gets a list of commands sent to the device for the specified filter criteria. /// </summary> /// <param name="deviceGuid">Device unique identifier.</param> /// <param name="filter">Notification filter criteria.</param> /// <returns>A list of <see cref="Command"/> objects that match specified filter criteria.</returns> public async Task<List<Command>> GetCommands(string deviceGuid, CommandFilter filter) { if (string.IsNullOrEmpty(deviceGuid)) throw new ArgumentException("DeviceGuid is null or empty!", "deviceGuid"); return await _restClient.Get<List<Command>>( string.Format("device/{0}/command", deviceGuid) + _restClient.MakeQueryString(filter)); }
async void LoadCommands() { await StopCommandsSubscription(); bool loaded = false; CommandFilter filter = new CommandFilter() { End = filterCommandsEnd, Start = filterCommandsStart, SortOrder = SortOrder.DESC }; var list = new IncrementalLoadingCollection<Command>(async (take, skip) => { filter.Skip = (int)skip; filter.Take = (int)take; try { Debug.WriteLine("CMD LOAD START"); var commands = await ClientService.Current.GetCommandsAsync(deviceId, filter); Debug.WriteLine("CMD LOAD END"); return commands; } catch (Exception ex) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { new MessageDialog(ex.Message, "Error").ShowAsync(); }); throw ex; } }, 20); list.IsLoadingChanged += (s, isLoading) => { LoadingItems += isLoading ? 1 : -1; if (!isLoading && !loaded) { StartCommandsSubscription(); if (s.Count > 0) { // makes server response faster filter.End = s.First().Timestamp; } loaded = true; } }; CommandsObservable = list; }