コード例 #1
0
        /// <summary>
        /// Gets a list of notifications generated by 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="Notification"/> objects that match specified filter criteria.</returns>
        public async Task<List<Notification>> GetNotifications(string deviceGuid, NotificationFilter filter)
        {
            if (string.IsNullOrEmpty(deviceGuid))
                throw new ArgumentException("DeviceGuid is null or empty!", "deviceGuid");

            return await _restClient.Get<List<Notification>>(
                string.Format("device/{0}/notification", deviceGuid) + _restClient.MakeQueryString(filter));
        }
コード例 #2
0
        /// <summary>
        /// Gets a list of notifications generated by 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="Notification"/> objects that match specified filter criteria.</returns>
        public async Task <List <Notification> > GetNotificationsAsync(string deviceGuid, NotificationFilter filter)
        {
            if (string.IsNullOrEmpty(deviceGuid))
            {
                throw new ArgumentException("DeviceGuid is null or empty!", "deviceGuid");
            }

            return(await _restClient.GetAsync <List <Notification> >(
                       string.Format("device/{0}/notification", deviceGuid) + RestClient.MakeQueryString(filter)));
        }
コード例 #3
0
 async void LoadNotifications()
 {
     await StopNotificationsSubscription();
     bool loaded = false;
     NotificationFilter filter = new NotificationFilter()
     {
         End = filterNotificationsEnd,
         Start = filterNotificationsStart,
         SortOrder = SortOrder.DESC
     };
     var list = new IncrementalLoadingCollection<Notification>(async (take, skip) =>
     {
         filter.Skip = (int)skip;
         filter.Take = (int)take;
         try
         {
             Debug.WriteLine("NTF LOAD START");
             var notifications = await ClientService.Current.GetNotificationsAsync(deviceId, filter);
             Debug.WriteLine("NTF LOAD END");
             return notifications;
         }
         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)
         {
             StartNotificationsSubscription();
             if (s.Count > 0)
             {
                 // makes server response faster
                 filter.End = s.First().Timestamp;
             }
             loaded = true;
         }
     };
     NotificationsObservable = list;
 }