Exemplo n.º 1
0
        protected virtual Task <string> GetJsonFeedsAsync(CancellationToken cancellationToken)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignAuthToken(this.serviceApi.Menu);

            return(webClient.GetStringAsync(this.serviceApi.MenuFeedsUri, cancellationToken));
        }
        public virtual Task <Stream> GetImageStreamAsync(Guid id)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignAuthToken(this.serviceApi.Map);

            return(webClient.GetStreamAsync(this.serviceApi.ImageUriBase + id));
        }
Exemplo n.º 3
0
        protected virtual Task <string> GetJsonMenuEntriesAsync(string feedId, DateTime dayDate, CancellationToken cancellationToken)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignAuthToken(this.serviceApi.Menu);

            return(webClient.GetStringAsync(string.Format(this.serviceApi.MenuUri, feedId, dayDate), cancellationToken));
        }
Exemplo n.º 4
0
        protected virtual async Task <string> GetBalanceJsonAsync(CancellationToken cancellationToken)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignBearerToken(await this.oAuth.BearerTokenAsync())
            .AssignAcceptTypeJson();

            return(await webClient.GetStringAsync(this.serviceApi.AccountApiUri, cancellationToken));
        }
        /// <summary>
        /// Returns the raw JSON data from the NewsFeed-Service
        /// </summary>
        /// <param name="feed">Name of the feed</param>
        /// <param name="before">Maximum date of the newest entry which will be returned</param>
        /// <param name="cancellationToken">Token which can be used to cancel the process</param>
        /// <returns>JSON-String with the news entries</returns>
        protected virtual Task <string> GetJsonNewsEntriesAsync(SqlNewsFeed feed, DateTime before, CancellationToken cancellationToken)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignAuthToken(this.serviceApi.News);

            return(webClient.GetStringAsync(string.Format(this.serviceApi.NewsUri, feed.Key, before), cancellationToken));
        }
        protected virtual Task <byte[]> GetByteArrayIconAsync(SqlNewsFeed feed, int size)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignAuthToken(this.serviceApi.News);

            return(webClient.GetByteArrayAsync(string.Format(this.serviceApi.IconUri, feed.Key, size)));
        }
Exemplo n.º 7
0
        protected virtual async Task <string> GetDirectoryListingJsonAsync(FilerViewModel.FilerArgs args, CancellationToken cancellationToken)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignBearerToken(await this.oAuth.BearerTokenAsync());

            return(await webClient.GetStringAsync(this.serviceApi.FilerApiUriBase + args.CurrentDirectory, cancellationToken));
        }
        public async Task <IEnumerable <WhTimeperiod> > GetTimeperiodsAsync(string identity, CancellationToken cancellationToken)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignBearerToken(await this.oAuth.BearerTokenAsync());

            var response = await webClient.GetStringAsync(string.Format(this.serviceApi.TimeperiodUri, identity), cancellationToken);

            return(cancellationToken.IsCancellationRequested ? null : response.CreateFromJsonString <IEnumerable <WhTimeperiod> >());
        }
        public virtual async Task <MapOverview> GetHashesAsync(CancellationToken cancellationToken)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignAuthToken(this.serviceApi.Map);

            var response = await webClient.GetStringAsync(this.serviceApi.BuildingsUri, cancellationToken);

            return(response.CreateFromJsonString <MapOverview>());
        }
        public async void Download(IOListing io, Action <ResultState> complete)
        {
            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device);

            var stream = await webClient.GetStreamAsync(io.Url);

            await this.WriteFileAsync(this.Map(io.FullPath), stream);

            complete.Invoke(ResultState.Success);
        }
        public void Start()
        {
            try
            {
                var webClient = new NativeHttpClient(this.httpClientConfiguration);

                webClient
                .AssignAgent(this.device)
                .AssignAuthToken(this.serviceApi.News);

                webClient.GetStreamAsync(this.Url).ContinueWith(task => this.ProcessResponse(task.Result));
            }
            catch (Exception e)
            {
                this.FireDownloadFailed(e);
            }
        }
        public async Task <IEnumerable <WhAdunisCourse> > GetCourseDataAsync(string identity, int termId, AdunisType type, CancellationToken cancellationToken)
        {
            var requestUrlTemplate = type == AdunisType.Timetable ? this.serviceApi.TimetableUri : this.serviceApi.ExamUri;
            var requestUrl         = string.Format(requestUrlTemplate, identity, termId);

            var webClient = new NativeHttpClient(this.httpClientConfiguration);

            webClient
            .AssignAgent(this.device)
            .AssignAcceptTypeJson()
            .AssignBearerToken(await this.oAuth.BearerTokenAsync());

            var response = await webClient.GetStringAsync(requestUrl, cancellationToken);

            if (cancellationToken.IsCancellationRequested)
            {
                return(null);
            }

            var holder = response.CreateFromJsonString <Holder>();

            return(holder?.Courses);
        }