示例#1
0
        /// <summary>
        /// List all builds
        /// </summary>
        public async Task <List <BuildDto> > GetBuilds()
        {
            //Setup resources
            string uri = $"{ _optionsDto.SourceUri }/_apis/build/definitions?name=*{ _optionsDto.ProjectName }*";

            //Make Request
            var response = await _httpClient.GetAsync <BuildRequestDto>(uri);

            //Return Build List
            return(response?.BuildList);
        }
示例#2
0
        public async Task DownloadSource(Component componente)
        {
            string url = String.Format($"{Config.SonarBaseUrl}{Config.SourcesUrl}", componente.key);
            //var client = new CustomHttpClient<List<KeyValuePair<int, string>>>(Config);
            var client         = new CustomHttpClient <SourcesResponse>(Config);
            var sourceResponse = await client.GetAsync(url);

            componente.source       = new Source();
            componente.source.lines = new List <SourceLine>();
            //{
            //    lines = sourceResponse.sources.Select(
            //        s=> new SourceLine() { lineNum = (int)s[0], lineText = ((string)s[1])} ).ToList()
            //};
            int lineNum = 1;

            foreach (var item in sourceResponse.sources)
            {
                var text = (string)item[1];
                componente.source.lines.Add(new SourceLine()
                {
                    lineNum = lineNum, lineText = text
                });
                lineNum++;
            }
        }
        public async Task DownloadMetrics(Project proyecto)
        {
            string url = String.Format($"{Config.SonarBaseUrl}{Config.MetricsUrl}", proyecto.Key);

            var client = new CustomHttpClient <Measures>(Config);

            proyecto.Measure = await client.GetAsync(url);
        }
        public async Task <IList <Contact> > GetAllContactsDetails()
        {
            using (var httpClient = new CustomHttpClient())
            {
                httpClient.BaseAddress = _baseAddress;
                var response = await httpClient.GetAsync(GetAllContactsDetailsUrl);

                response.EnsureSuccessStatusCode();
                var result = await response.Content.ReadAsAsync <IList <Contact> >();

                return(result);
            }
        }
示例#5
0
        public async Task DownloadNewIssues(Project proyecto)
        {
            string url            = String.Format($"{Config.SonarBaseUrl}{Config.IssuesUrl}", proyecto.Key);
            var    client         = new CustomHttpClient <IssuesResponse>(Config);
            var    issuesResponse = await client.GetAsync(url);

            proyecto.Issues     = issuesResponse.issues;
            proyecto.Components = issuesResponse.components;

            await Task.WhenAll(
                from comp in proyecto.Components
                where comp.qualifier == "FIL"
                select DownloadSource(comp));
        }
        public async Task <Contact> GetDetails(decimal id)
        {
            using (var httpClient = new CustomHttpClient())
            {
                httpClient.BaseAddress = _baseAddress;

                var requesUrl = string.Format(GetDetailsUrl, id);

                var response = await httpClient.GetAsync(requesUrl);

                response.EnsureSuccessStatusCode();
                var result = await response.Content.ReadAsAsync <Contact>();

                return(result);
            }
        }
示例#7
0
        public async Task<HttpResponseMessage> Get(string uri)
        {
            //var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            //var i = serializer.MaxJsonLength ;

            //new System.Web.Script.Serialization.JavaScriptSerializer { MaxJsonLength = int.MaxValue };

            try
            {
                using (var client = new CustomHttpClient())
                {
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.ExpectContinue = false;
                    //credentials
                    client.DefaultRequestHeaders.Authorization = Credentials.GetAuthenticationHeader();
                    client.DefaultRequestHeaders.Add("Fuente", "Web");
                    client.DefaultRequestHeaders.Add("IdEmpresa", /*HttpContext.Current.Session["IdEmpresa" + HttpContext.Current.Session.SessionID]?.ToString() ??*/ Guid.Empty.ToString());
                    client.DefaultRequestHeaders.Add("IdUsuario", /*HttpContext.Current.Session["idUsuario" + HttpContext.Current.Session.SessionID]?.ToString() ??*/ "0");
                    client.DefaultRequestHeaders.Add("Nombre", (/*(UsuarioModelo)HttpContext.Current.Session["usuario" + HttpContext.Current.Session.SessionID])?.Nombre ??*/ "----");
                    client.DefaultRequestHeaders.Add("Correo", (/*(UsuarioModelo)HttpContext.Current.Session["usuario" + HttpContext.Current.Session.SessionID])?.Correo ??*/ "*****@*****.**");

                    //obtenemos el timeOut de la solicitud
                    var timeOut = 60;

                    //tiempo de espera del servicio
                    client.Timeout = TimeSpan.FromMinutes(timeOut);
                    var response = client.GetAsync(uri).Result;
                    return response;
                }
            }
            catch (AggregateException ee)
            {
                //retorna una exception 
                var exc = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    ReasonPhrase = ee.InnerException != null ? ee.InnerException.Message : ee.Message
                };

                return exc;
            }
            catch (Exception ee)
            {
                //retorna una exception              
                throw ee;
            }
        }
        public async Task <List <Project> > DownloadProjects()
        {
            string url              = $"{Config.SonarBaseUrl}{Config.ProjectsUrl}";
            var    client           = new CustomHttpClient <List <Project> >(Config);
            var    projectsResponse = await client.GetAsync(url);

            string[] filters = Config.ProjectFilter.Split('@');

            var proyectos = projectsResponse
                            .Where(p => filters.Any(f => p.Key.StartsWith(f)))
                            .ToList();

            await Task.WhenAll(
                from prj in proyectos
                select DownloadMetrics(prj));

            return(proyectos);
        }
示例#9
0
        public async Task <IEnumerable <ToGo> > Get()
        {
            CustomHttpClient client = new CustomHttpClient(Request.Headers.Authorization.Parameter);

            return(await client.GetAsync());
        }