public async Task <JsonResult> Json(string packageName, string interfaceName, string methodName, [FromBody] string @params) { var httpJsonResponse = new HttpJsonResponse <dynamic> { callId = RefreshCallId() }; ExceptionMessage exceptionMessage = null; try { var serviceLayer = GetServiceLayer(); _logger.LogDebug($"ask instance for interface {interfaceName}"); var serviceType = GetServiceType(packageName, interfaceName, serviceLayer); var service = GetServiceInstance(serviceType); _logger.LogDebug( $"JSON facade call(callId:{httpJsonResponse.callId}): {interfaceName}.{methodName}{@params}"); await Invoke(serviceType, service, methodName, @params).ContinueWith(it => httpJsonResponse.val = it.Result); } catch (AbstractBusinessException e) { _logger.LogInformation( $"Business exception occured when calling JSON facade call(callId:{httpJsonResponse.callId}): {interfaceName}.{methodName}{@params}: {e.Message}"); Response.StatusCode = 500; exceptionMessage = FormatException(e); } catch (Exception e) { _logger.LogError( $"Unhandled exception occured when calling JSON facade call(callId:{httpJsonResponse.callId}): {interfaceName}.{methodName}{@params}: {e.Message}"); Response.StatusCode = 500; exceptionMessage = FormatException(e); } httpJsonResponse.err = exceptionMessage; return(new JsonResult(httpJsonResponse)); }
public void SetResponse(int statusCode, HttpJsonResponse response) { Context.Response.StatusCode = statusCode; Response = response; }