private KinveyRootListData <T> DownloadPageData(int pageIndex)
        {
            string   newQuery           = TaskParameters.Query;
            List <T> _data              = KinveyWebClient.GetObjectAsync <List <T> >(newQuery).Result;
            KinveyRootListData <T> krld = new KinveyRootListData <T>(_data);

            return(krld);
        }
示例#2
0
        private List <EventData> getEventList()
        {
            string           newQuery = TaskParameters.Query;
            List <EventData> _data    = KinveyWebClient.GetObjectAsync <List <EventData> >(newQuery).Result;
            //_data = setEventsIds(_data);
            KinveyRootListData <EventData> krld = new KinveyRootListData <EventData>(_data);

            return(_data);
        }
        public override List <T> Execute()
        {
            List <T> result = new List <T>();

            try
            {
                KinveyRootListData <T> listData = DownloadPageData(0);
                UpdateData(listData);

                if (listData != null)
                {
                    if (listData.TotalPages > 1 && TaskParameters.DownloadCountType == KinveyDownloadCountType.All)
                    {
                        for (int pageIndex = listData.CurrentPage + 1; pageIndex < listData.TotalPages; pageIndex++)
                        {
                            UpdateData(DownloadPageData(pageIndex));
                        }
                    }
                }

                return(Result);
            }
            catch (Exception ex)
            {
                AppProvider.Log.WriteLine(LogChannel.Exception, ex);
            }
            return(null);

            /*
             * catch (AggregateException ex)
             * {
             *  var serverException = ex.GetBaseException() as ServerException;
             *
             *  if (serverException != null)
             *  {
             *      if (serverException.StatusCode == HttpStatusCode.NotFound)
             *          return result;
             *      else
             *          AppProvider.Log.WriteLine(LogChannel.Exception, ex);
             *  }
             * }
             * catch (Exception ex)
             * {
             *  AppProvider.Log.WriteLine(LogChannel.Exception, ex);
             * }
             *
             * return null;
             */
        }
        protected void UpdateData(KinveyRootListData <T> data)
        {
            if (data != null)
            {
                Result.AddRange(data.Data);

                if (DynamicList != null)
                {
                    DynamicList.UpdateData(data.Data);
                }

                if (TaskParameters.IsSaveToDb)
                {
                    DbClient.Instance.SaveData <T>(data.Data).ConfigureAwait(false);
                }

                //OnSaveData(data.Data);
            }
        }