예제 #1
0
        public BaseResponse Post(string actionName, [FromBody] JToken jsonBody)
        {
            FlowConfiguration flowConfiguration = flowConfigurationProvider.GetConfiguration(actionName);

            if (flowConfiguration == null)
            {
                throw new JMException("FlowConfigurationEmpty");
            }
            BaseRequest request = jsonBody.ToObject(Type.GetType(flowConfiguration.RequestIdentifier)) as BaseRequest;

            return(jmAppClientProvider.CallAction <BaseResponse>(actionName, request));
        }
예제 #2
0
        public BaseResponse ExecuteFlow(IServiceProvider serviceProvider, string actionName, object request)
        {
            FlowConfiguration flowConfiguration = flowConfigurationProvider.GetConfiguration(actionName);

            contextProvider.GetContext().ActiveFlowConfiguration = flowConfiguration;
            Type         responseType = Type.GetType(flowConfiguration.ResponseIdentifier);
            BaseResponse response     = Activator.CreateInstance(responseType) as BaseResponse;

            foreach (FlowItemDefinition flowItem in flowExecutionConfigurationProvider.GetActiveConfiguration().FlowItems)
            {
                Type         flowItemType     = Type.GetType(flowItem.TypeIdentifier);
                BaseFlowItem flowItemInstance = Activator.CreateInstance(flowItemType) as BaseFlowItem;
                flowItemInstance.ExecuteFlow(serviceProvider, ref request, ref response);
            }

            return(response);
        }
예제 #3
0
        public string Post([FromBody] RequestPayload requestMessage)
        {
            try
            {
                contextProvider.SetContext(requestMessage.Context);
                FlowConfiguration configuration = flowConfigurationProvider.GetConfiguration(requestMessage.Action);
                ValidationHelper.ExecuteValidations(configuration, requestMessage.Request);
                BaseResponse    response        = flowProvider.ExecuteFlow(serviceProvider, requestMessage.Action, requestMessage.Request);
                ResponsePayload responseMessage = new ResponsePayload
                {
                    Context  = contextProvider.GetContext(),
                    Response = response
                };

                return(responseMessage.ToJson());
            }
            catch (Exception e)
            {
                try
                {
                    JMResult result  = serviceProvider.GetRequiredService <IExceptionHandler>().HandleException(e);
                    Context  context = contextProvider.GetContext();
                    context.ActiveResult = result;
                    return(new ResponsePayload
                    {
                        Context = context,
                        Response = null
                    }.ToJson());
                }
                catch (Exception innerException)
                {
                    DefaultLogger.Error(innerException);
                    return(new ResponsePayload().ToJson());
                }
            }
        }