コード例 #1
0
        public object Invoke(IInvocationInfo invocationInfo)
        {
            var typeName = invocationInfo
                           .Method
                           .GetGenericArgumentsName()
                           .First();

            if (Kernel.CanGet <IWorkflowAction>(typeName))
            {
                var action    = Kernel.Get <IWorkflowAction>(typeName);
                var parameter = invocationInfo.Arguments.First() + "";

                Log.Debug($"Invoking workflow action {typeName}");
                if (!action.Evaluate(parameter))
                {
                    return(false.ToString());
                }

                Context.AddWorkflowBranch(action.BranchType);
                return(true.ToString());
            }
            else
            {
                using (var e = new ActionNotFoundException(typeName))
                    Log.Fatal($"Implementation not found for workflow action {typeName}", e);
            }

            return(null);
        }
コード例 #2
0
        public object Invoke(IInvocationInfo invocationInfo)
        {
            var typeName = invocationInfo
                           .Method
                           .GetGenericArgumentsName()
                           .First();

            var userFriendlyName = typeName.Split('.').Last();

            if (Kernel.CanGet <IVoidAction>(typeName))
            {
                var action  = Kernel.Get <IVoidAction>(typeName);
                var invoker = Kernel.Get <IInvoker>("Invoker");
                invoker.SetAction(action, Context);
                var parameters = Parser.Parse(
                    invocationInfo.Arguments.First() as string[],
                    invoker.ParameterTypes);

                Log.Debug($"Invoking void action {typeName}");

                try
                {
                    invoker.Invoke(parameters.ToArray());
                }
                catch (Exception e)
                {
                    if (e.InnerException is SlimException)
                    {
                        Log.Warn($"Action {typeName} threw a slim exception: {e.InnerException.ExpandErrorMessage()}");
                        throw e;
                    }
                    else
                    {
                        Log.Fatal($"Action {typeName} threw exception: {e.ExpandErrorMessage()}");
                        throw new ActionException($"Action {userFriendlyName} threw an exception: {e.ExpandErrorMessage()}");
                    }
                }
            }
            else
            {
                using (var e = new ActionNotFoundException(userFriendlyName))
                    Log.Fatal($"Implementation not found for void action {typeName}", e);
            }

            return(null);
        }
コード例 #3
0
        public async Task <ActionResponse> ExecuteAction(UserInfo info, ActionRequest request)
        {
            Logger logger = new Logger(info, this.CommonControllerModel);

            logger.LogEvent("Start-" + info.ActionName, null);
            var start  = DateTime.Now;
            var action = this.CommonControllerModel.AppFactory.Actions[info.ActionName];
            var app    = this.CommonControllerModel.AppFactory.Apps[info.AppName];

            info.App = app;

            request.ControllerModel = this.CommonControllerModel;
            request.Info            = info;
            request.Logger          = logger;

            if (action != null)
            {
                int loopCount = 0;

                ActionResponse responseToReturn = await RunActionAsync(request, logger, action, loopCount);

                responseToReturn.DataStore = request.DataStore;

                if (!responseToReturn.IsSuccess)
                {
                    // temporary code
                }

                logger.LogEvent("End-" + info.ActionName, null, request, responseToReturn);
                logger.LogRequest(action.OperationUniqueName, DateTime.Now - start,
                                  responseToReturn.Status.IsSucessfullStatus(), request, responseToReturn);
                logger.Flush();
                return(responseToReturn);
            }

            logger.LogEvent("End-" + info.ActionName, null, request, null);
            logger.LogRequest(info.ActionName, DateTime.Now - start, false, request, null);
            var ex = new ActionNotFoundException();

            logger.LogException(ex, null, request, null);
            logger.Flush();
            throw ex;
        }