public HttpResponseMessage Execute(ExecuteReq req) { try { DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.SqlClient"); //create a command of the proper type. DbConnection conn = factory.CreateConnection(); #region virify required if (string.IsNullOrEmpty(req.serviceProviderName)) { return(apiHelper.fromErrorString("serviceProviderName es requerido", HttpStatusCode.NoContent)); } if (string.IsNullOrEmpty(req.serviceName)) { return(apiHelper.fromErrorString("serviceName es requerido", HttpStatusCode.NoContent)); } if (string.IsNullOrEmpty(req.jsonRequest.ToString())) { return(apiHelper.fromErrorString("jsonRequest es requerido", HttpStatusCode.NoContent)); } #endregion base.CreateSimpleFacade(); //var resToJson = base.simpleFacade.ExecuteServiceJson_newtonjs(req.serviceProviderName, req.serviceName, req.jsonRequest.ToString(), base.hostContext); var res = base.simpleFacade.ExecuteServiceJsonBase(req.serviceProviderName, req.serviceName, req.jsonRequest.ToString(), base.hostContext); return(apiHelper.fromObject <ApiOkResponse>(new ApiOkResponse(res))); } catch (Exception ex) { return(apiHelper.fromEx(ex)); } }
public HttpResponseMessage Execute(ExecuteReq req) { try { var o = new { ExecuteMessage = "El servicio 'Execute' respondio corerctamente " }; return(apiHelper.fromObject(o)); } catch (Exception ex) { return(apiHelper.fromEx(ex)); } }
public async Task <IActionResult> Post([FromBody] ExecuteReq req) { if (req == null) { return(BadRequest("req is null")); } try { var reqId = NewId.NextGuid(); _logger.LogInformation($"Request ({reqId}): url = {req.Url}, count = {req.Count}"); return(await Execute(reqId, req.Url, req.Count).ConfigureAwait(false)); } catch (UriFormatException) { return(BadRequest($"The Request URL is invalid: {req.Url}")); } }
public HttpResponseMessage ExecuteWhiteList(ExecuteReq req) { try { #region virify //if (string.IsNullOrEmpty(req.serviceProviderName)) // return apiHelper.fromErrorString("serviceProviderName es requerido", HttpStatusCode.NoContent); if (string.IsNullOrEmpty(req.serviceName)) { return(apiHelper.fromErrorString("serviceName es requerido", HttpStatusCode.NoContent)); } if (string.IsNullOrEmpty(req.jsonRequest.ToString())) { return(apiHelper.fromErrorString("jsonRequest es requerido", HttpStatusCode.NoContent)); } if (whiteListSVC.whiteList.Any(s => s.serviceName.Equals(req.serviceName)) == false) { HttpResponseMessage wHttpResponseMessage = apiHelper.fromErrorString(String.Format("Error the service {0} was not allowed", req.serviceName), HttpStatusCode.Unauthorized); return(wHttpResponseMessage); } #endregion base.CreateSimpleFacade(); var resToJson = base.simpleFacade.ExecuteServiceJsonBase(req.serviceProviderName, req.serviceName, req.jsonRequest.ToString(), base.hostContext); return(apiHelper.fromObject <ApiOkResponse>(new ApiOkResponse(resToJson))); } catch (Exception ex) { return(apiHelper.fromEx(ex)); } }