Example #1
0
 /// <exclude />
 public void OnStatus(TaskManagerEvent taskManagerEvent)
 {
     foreach (Task task in _tasks)
     {
         task.TaskManager.OnStatus(task.Id, taskManagerEvent);
     }
 }
Example #2
0
 /// <exclude />
 public void OnStatus(TaskManagerEvent taskManagerEvent)
 {
     foreach (Task task in _tasks)
     {
         task.TaskManager.OnStatus(task.Id, taskManagerEvent);
     }
 }
        public TaskContainer CreateNewTasks(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent)
        {
            List<Task> newTasks = new List<Task>();

            lock (_lock)
            {
                foreach (Func<EntityToken, ActionToken, Task> taskCreator in _taskCreators)
                {
                    try
                    {
                        Task task = taskCreator(entityToken, actionToken);
                        if (task == null) continue;

                        bool result = task.TaskManager.OnCreated(task.Id, taskManagerEvent);
                        if (result == false) continue;

                        _tasks.Add(task);
                        newTasks.Add(task);
                    }
                    catch (Exception ex)
                    {
                        Log.LogError("TaskManagerFacade", "Starting new task failed with following exception");
                        Log.LogError("TaskManagerFacade", ex);
                    }
                }
            }

            return new TaskContainer(newTasks, null);
        }
Example #4
0
        internal TaskContainer(List<Task> tasks, TaskManagerEvent taskManagerEvent)
        {
            _tasks = tasks;

            foreach (Task task in _tasks)
            {
                task.TaskManager.OnRun(task.Id, taskManagerEvent);
            }
        }
Example #5
0
        internal TaskContainer(List <Task> tasks, TaskManagerEvent taskManagerEvent)
        {
            _tasks = tasks;

            foreach (Task task in _tasks)
            {
                task.TaskManager.OnRun(task.Id, taskManagerEvent);
            }
        }
        public TaskContainer RuntTasks(FlowToken flowToken, TaskManagerEvent taskManagerEvent)
        {
            string serializedFlowToken = flowToken.Serialize();

            List<Task> tasks;
            lock (_lock)
            {
                tasks = _tasks.Where(f => f.FlowToken == serializedFlowToken).ToList();
            }

            return new TaskContainer(tasks, taskManagerEvent);
        }
Example #7
0
        public TaskContainer RuntTasks(FlowToken flowToken, TaskManagerEvent taskManagerEvent)
        {
            string serializedFlowToken = flowToken.Serialize();

            List <Task> tasks;

            lock (_lock)
            {
                tasks = _tasks.Where(f => f.FlowToken == serializedFlowToken).ToList();
            }

            return(new TaskContainer(tasks, taskManagerEvent));
        }
        public void Execute(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent)
        {
            var flowServicesContainer = new FlowControllerServicesContainer(
                new ManagementConsoleMessageService(this.ConsoleId),
                new ElementDataExchangeService(this.ElementProviderName),
                this
                );

            FlowToken flowToken = ActionExecutorFacade.Execute(entityToken, actionToken, flowServicesContainer, taskManagerEvent);

            IFlowUiDefinition uiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer);

            if (uiDefinition is FlowUiDefinitionBase flowUiDefinition)
            {
                string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true);
                ViewTransitionHelper.HandleNew(this.ConsoleId, this.ElementProviderName, serializedEntityToken, flowToken, flowUiDefinition);
            }
        }
        public void Execute(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent)
        {
            FlowControllerServicesContainer flowServicesContainer = new FlowControllerServicesContainer();
            flowServicesContainer.AddService(new ManagementConsoleMessageService(this.ConsoleId));
            flowServicesContainer.AddService(new ElementDataExchangeService(this.ElementProviderName));
            flowServicesContainer.AddService(this);

            FlowToken flowToken = ActionExecutorFacade.Execute(entityToken, actionToken, flowServicesContainer, taskManagerEvent);

            IFlowUiDefinition uiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer);

            ActionResult result = new ActionResult();

            if (typeof(FlowUiDefinitionBase).IsAssignableFrom(uiDefinition.GetType()))
            {
                string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true);
                ViewTransitionHelper.HandleNew(this.ConsoleId, this.ElementProviderName, serializedEntityToken, flowToken, (FlowUiDefinitionBase)uiDefinition);
            }
        }
Example #10
0
        public void Execute(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent)
        {
            FlowControllerServicesContainer flowServicesContainer = new FlowControllerServicesContainer();

            flowServicesContainer.AddService(new ManagementConsoleMessageService(this.ConsoleId));
            flowServicesContainer.AddService(new ElementDataExchangeService(this.ElementProviderName));
            flowServicesContainer.AddService(this);

            FlowToken flowToken = ActionExecutorFacade.Execute(entityToken, actionToken, flowServicesContainer, taskManagerEvent);

            IFlowUiDefinition uiDefinition = FlowControllerFacade.GetCurrentUiDefinition(flowToken, flowServicesContainer);

            ActionResult result = new ActionResult();

            if (typeof(FlowUiDefinitionBase).IsAssignableFrom(uiDefinition.GetType()))
            {
                string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true);
                ViewTransitionHelper.HandleNew(this.ConsoleId, this.ElementProviderName, serializedEntityToken, flowToken, (FlowUiDefinitionBase)uiDefinition);
            }
        }
Example #11
0
 public virtual bool OnCreated(string taskId, TaskManagerEvent taskManagerEvent) { return true; }
Example #12
0
 public virtual void OnIdle(string taskId, TaskManagerEvent taskManagerEvent) { }
Example #13
0
 public virtual void OnCompleted(string taskId, TaskManagerEvent taskManagerEvent) { }
 /// <exclude />
 public void OnStatus(TaskManagerEvent taskManagerEvent)
 {
     this.TaskContainer.OnStatus(taskManagerEvent);
 }
 internal static TaskContainer CreateNewTasks(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent)
 {
     return(Implementation.CreateNewTasks(entityToken, actionToken, taskManagerEvent));
 }
 /// <exclude />
 public static TaskContainer RuntTasks(FlowToken flowToken, TaskManagerEvent taskManagerEvent)
 {
     return(Implementation.RuntTasks(flowToken, taskManagerEvent));
 }
 public virtual void OnCompleted(string taskId, TaskManagerEvent taskManagerEvent)
 {
 }
Example #18
0
 internal static TaskContainer CreateNewTasks(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent)
 {
     return Implementation.CreateNewTasks(entityToken, actionToken, taskManagerEvent);
 }
Example #19
0
 /// <exclude />
 public void OnStatus(TaskManagerEvent taskManagerEvent)
 {
     this.TaskContainer.OnStatus(taskManagerEvent);
 }
 public virtual void OnStatus(string taskId, TaskManagerEvent taskManagerEvent)
 {
 }
Example #21
0
 public virtual void OnStatus(string taskId, TaskManagerEvent taskManagerEvent) { }
 public virtual void OnIdle(string taskId, TaskManagerEvent taskManagerEvent)
 {
 }
 public virtual bool OnCreated(string taskId, TaskManagerEvent taskManagerEvent)
 {
     return(true);
 }
Example #24
0
 /// <exclude />
 public void SetOnIdleTaskManagerEvent(TaskManagerEvent taskManagerEvent)
 {
     _onIdleTaskManagerEvent = taskManagerEvent;
 }
Example #25
0
 /// <exclude />
 public void SetOnIdleTaskManagerEvent(TaskManagerEvent taskManagerEvent)
 {
     _onIdleTaskManagerEvent = taskManagerEvent;
 }
Example #26
0
        public TaskContainer CreateNewTasks(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent)
        {
            List <Task> newTasks = new List <Task>();

            lock (_lock)
            {
                foreach (Func <EntityToken, ActionToken, Task> taskCreator in _taskCreators)
                {
                    try
                    {
                        Task task = taskCreator(entityToken, actionToken);
                        if (task == null)
                        {
                            continue;
                        }

                        bool result = task.TaskManager.OnCreated(task.Id, taskManagerEvent);
                        if (result == false)
                        {
                            continue;
                        }

                        _tasks.Add(task);
                        newTasks.Add(task);
                    }
                    catch (Exception ex)
                    {
                        Log.LogError("TaskManagerFacade", "Starting new task failed with following exception");
                        Log.LogError("TaskManagerFacade", ex);
                    }
                }
            }

            return(new TaskContainer(newTasks, null));
        }
Example #27
0
 /// <exclude />
 public static TaskContainer RuntTasks(FlowToken flowToken, TaskManagerEvent taskManagerEvent)
 {
     return Implementation.RuntTasks(flowToken, taskManagerEvent);
 }
        /// <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 is SecurityViolationWorkflowEntityToken))
            {
                return(ExecuteSecurityViolation(actionToken, entityToken, flowControllerServicesContainer));
            }
#endif

            bool ignoreLocking = actionToken.IsIgnoreEntityTokenLocking();

            if (!ignoreLocking && ActionLockingFacade.IsLocked(entityToken))
            {
                return(ExecuteEntityTokenLocked(actionToken, entityToken, flowControllerServicesContainer));
            }

            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
            {
                Log.LogWarning(nameof(ActionExecutorFacade), "Missing ManagementConsoleMessageService, can not register the flow");
            }

            return(flowToken);
        }
Example #29
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);
            }
        }