Ejemplo n.º 1
0
        public override async Task <IEnumerable <T> > GetAllPages <T>(string url, int limit = 50, QueryString query = null)
        {
            var result = new IteratorBasedPage <T>()
            {
                Values = new List <T>()
            };
            IRestResponse <IteratorBasedPage <T> > response;
            var pageNumber = 1;

            do
            {
                var request = new YouTrackRestRequest(url, Method.GET);
                request.AddQueryParameter("pagelen", limit.ToString()).AddQueryParameter("page", pageNumber.ToString());

                if (query != null)
                {
                    foreach (var par in query)
                    {
                        request.AddQueryParameter(par.Key, par.Value);
                    }
                }

                response = await ExecuteTaskAsync <IteratorBasedPage <T> >(request);

                if (response.Data?.Values == null)
                {
                    break;
                }

                result.Values.AddRange(response.Data.Values);

                pageNumber++;
            } while (response.Data?.Next != null); //todo 99% this value should be used instead of pagenumber

            return(result.Values);
        }
Ejemplo n.º 2
0
        public override async Task <IEnumerable <T> > GetAllPages <T>(string url, int limit = 50, QueryString query = null)
        {
            var result = new EnterpriseIteratorBasedPage <T>()
            {
                Values = new List <T>()
            };
            IRestResponse <EnterpriseIteratorBasedPage <T> > response;
            ulong pageNumber = 0;

            do
            {
                var request = new YouTrackRestRequest(url, Method.GET);
                request.AddQueryParameter("limit", limit.ToString()).AddQueryParameter("start", pageNumber.ToString());

                if (query != null)
                {
                    foreach (var par in query)
                    {
                        request.AddQueryParameter(par.Key, par.Value);
                    }
                }

                response = await this.ExecuteTaskAsync <EnterpriseIteratorBasedPage <T> >(request);

                if (response.Data?.Values == null)
                {
                    break;
                }

                result.Values.AddRange(response.Data.Values);

                pageNumber = response.Data.NextPageStart;
            } while (response.Data?.IsLastPage == false);

            return(result.Values);
        }