/// <summary>
        /// Obtiene el resultado en formato json de la llamada al api
        /// </summary>
        /// <param name="htmlContent">contenido html</param>
        /// <param name="ocurrence">Posición de la cual hay que mirar</param>
        /// <returns>resultado de la llamada en formato json</returns>
        private string Api(string htmlContent, int ocurrence)
        {
            int first = htmlContent.IndexOf(DirectivesList.Api, ocurrence);

            first = first + DirectivesList.Api.Length;
            int         last  = htmlContent.IndexOf(DirectivesList.EndDirective, first);
            string      url   = htmlContent.Substring(first, last - first).Trim();
            TokenBearer token = null;

            if (url.Contains(_configUrlService.GetUrl()))
            {
                token = _callTokenService.CallTokenCarga();
            }
            else if (url.Contains(_configUrlService.GetUrlDocumentacion()))
            {
                token = _callTokenService.CallTokenApiDocumentacion();
            }
            else if (url.Contains(_configUrlCronService.GetUrl()))
            {
                token = _callTokenService.CallTokenCron();
            }
            string result = _callService.CallGetApi(url, "", token);

            return(result);
        }
示例#2
0
 public CallEtlService(ICallService serviceApi, CallTokenService tokenService, ConfigUrlService serviceUrl)
 {
     _serviceUrl = serviceUrl;
     _serviceApi = serviceApi;
     if (tokenService != null)
     {
         _token = tokenService.CallTokenCarga();
     }
 }
 /// <summary>
 /// Comprueba el estado del servicio proveedor de tokens
 /// </summary>
 /// <returns>si se encuentra en un estado correcto</returns>
 public bool CheckIdentityServer()
 {
     try
     {
         _callTokenService.CallTokenCarga();
         return(true);
     }
     catch (HttpRequestException)
     {
         return(false);
     }
 }