Пример #1
0
        private void GetTorrentsAndLabelsCached()
        {
            UpdatedTorrentsAndLabels UpdatedTorrents = ServiceClient.GetUpdatedTorrentsAndLabels(_cacheID.ToString(), _token);

            RemovedTorrentsList removedTorrents = null;

            if (UpdatedTorrents.RemovedTorrents != null && UpdatedTorrents.RemovedTorrents.Any())
            {
                removedTorrents = new RemovedTorrentsList()
                {
                    UpdatedTorrents.RemovedTorrents
                }
            }
            ;
            ChangedTorrentsList updatedTorrents = null;

            if (UpdatedTorrents.ChangedTorrents != null && UpdatedTorrents.ChangedTorrents.Any())
            {
                updatedTorrents = new ChangedTorrentsList()
                {
                    UpdatedTorrents.ChangedTorrents
                }
            }
            ;

            _torrents.Parse(UpdatedTorrents.Torrents, removedTorrents, updatedTorrents);
            _labels.Parse(UpdatedTorrents.Labels);
            SetCache(UpdatedTorrents.CacheID);
        }
Пример #2
0
        private void GetTorrentsAndLabelsCached()
        {
            if (_token == null)
            {
                return;
            }

            try
            {
                UpdatedTorrentsAndLabels UpdatedTorrents = ServiceClient.GetUpdatedTorrentsAndLabels(_cacheID.ToString(), _token);

                _torrents.Parse(null, UpdatedTorrents.RemovedTorrents, UpdatedTorrents.ChangedTorrents);
                _labels.Parse(UpdatedTorrents.Labels);
                SetCache(UpdatedTorrents.CacheID);
            }
            catch (System.ServiceModel.ProtocolException e)
            {
                // Token possibly expired, get new token.
                Trace.TraceError(e.Message + e.StackTrace);
                GetToken();
            }
        }