示例#1
0
        private static void OnSaveAndPublish(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Save" }))
            {
                TaskManagerFlowControllerService taskManagerFlowControllerService = new TaskManagerFlowControllerService(taskContainer);
                serviceContainer.AddService(taskManagerFlowControllerService);

                WorkflowFacade.FireSaveAndPublishEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));

                serviceContainer.RemoveService(taskManagerFlowControllerService);
            }
        }
示例#2
0
        private static void OnFinish(FlowToken flowToken, Dictionary<string, object> bindings, FlowControllerServicesContainer serviceContainer)
        {
            WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken;

            using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Finish" }))
            {
                TaskManagerFlowControllerService taskManagerFlowControllerService = new TaskManagerFlowControllerService(taskContainer);
                serviceContainer.AddService(taskManagerFlowControllerService);

                WorkflowFacade.FireFinishEvent(workflowFlowToken.WorkflowInstanceId, bindings);
                WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer);
                WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId);
                taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId));
            }


            IFormFlowRenderingService formServices = serviceContainer.GetService<IFormFlowRenderingService>();

            if (!formServices.HasFieldMessages)
            {
                serviceContainer.GetService<IFormFlowRenderingService>().RerenderView();
            }
        }
示例#3
0
        /// <exclude />
        public static FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer, TaskManagerEvent taskManagerEvent)
        {
            if (entityToken == null) throw new ArgumentNullException("entityToken");
            if (actionToken == null) throw new ArgumentNullException("actionToken");


            string username = UserValidationFacade.GetUsername();
#if NO_SECURITY
#else
            HookingFacade.EnsureInitialization();

            IEnumerable<UserPermissionDefinition> userPermissionDefinitions = PermissionTypeFacade.GetUserPermissionDefinitions(username);
            IEnumerable<UserGroupPermissionDefinition> userGroupPermissionDefinitions = PermissionTypeFacade.GetUserGroupPermissionDefinitions(username);
            SecurityResult securityResult = SecurityResolver.Resolve(UserValidationFacade.GetUserToken(), actionToken, entityToken, userPermissionDefinitions, userGroupPermissionDefinitions);
            if ((securityResult != SecurityResult.Allowed) && (entityToken.GetType() != typeof(SecurityViolationWorkflowEntityToken)))
            {
                return ExecuteSecurityViolation(actionToken, entityToken, flowControllerServicesContainer);
            }
#endif

            bool ignoreLocking = actionToken.IsIgnoreEntityTokenLocking();

            if ((ignoreLocking) ||
                (ActionLockingFacade.IsLocked(entityToken) == false))
            {
                IActionExecutor actionExecutor = ActionExecutorCache.GetActionExecutor(actionToken);

                ActionEventSystemFacade.FireOnBeforeActionExecution(entityToken, actionToken);

                FlowToken flowToken;
                using (TaskContainer taskContainer = TaskManagerFacade.CreateNewTasks(entityToken, actionToken, taskManagerEvent))
                {
                    ITaskManagerFlowControllerService taskManagerService = null;
                    if (flowControllerServicesContainer.GetService(typeof(ITaskManagerFlowControllerService)) == null)
                    {
                        taskManagerService = new TaskManagerFlowControllerService(taskContainer);
                        flowControllerServicesContainer.AddService(taskManagerService);
                    }

                    try
                    {
                        if ((actionExecutor is IActionExecutorSerializedParameters))
                        {
                            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);
                            string serializedActionToken = ActionTokenSerializer.Serialize(actionToken);

                            flowToken = Execute(actionExecutor as IActionExecutorSerializedParameters,
                                                serializedEntityToken, serializedActionToken, actionToken,
                                                flowControllerServicesContainer);
                        }
                        else
                        {
                            flowToken = Execute(actionExecutor, entityToken, actionToken,
                                                flowControllerServicesContainer);
                        }
                    }
                    finally
                    {
                        if (taskManagerService != null)
                        {
                            flowControllerServicesContainer.RemoveService(taskManagerService);
                        }
                    }

                    taskContainer.SetOnIdleTaskManagerEvent(new FlowTaskManagerEvent(flowToken));
                    taskContainer.UpdateTasksWithFlowToken(flowToken);

                    taskContainer.SaveTasks();
                }

                ActionEventSystemFacade.FireOnAfterActionExecution(entityToken, actionToken, flowToken);

                IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                if (managementConsoleMessageService != null)
                {
                    FlowControllerFacade.RegisterNewFlowInformation(flowToken, entityToken, actionToken, managementConsoleMessageService.CurrentConsoleId);
                }
                else
                {
                    LoggingService.LogWarning("ActionExecutorFacade", "Missing ManagementConsoleMessageService, can not register the flow");
                }

                return flowToken;
            }
            else
            {
                return ExecuteEntityTokenLocked(actionToken, entityToken, flowControllerServicesContainer);
            }
        }