Esempio n. 1
0
        //
        // GET: /User/

        public ActionResult ShowHome()
        {
            IPrincipal userAdapter = new PrincipalUserAdapter("ae");

            HttpContext.User        = userAdapter;
            Thread.CurrentPrincipal = userAdapter;

            IDefinitionSessionLocal definitionComponent = null;
            IExecutionSessionLocal  executionComponent  = null;

            try
            {
                definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal;
                executionComponent  = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal;
                IList taskList           = executionComponent.GetTaskList();
                IList processDefinitions = definitionComponent.GetProcessDefinitions();

                ViewData["taskList"]           = taskList;
                ViewData["processDefinitions"] = processDefinitions;
                ViewData["preview"]            = null;
                //Context.Flash["taskList"] = taskList;
                //Context.Flash["processDefinitions"] = processDefinitions;
                //Context.Flash["preview"] = preview;
            }
            finally
            {
                ServiceLocator.Instance.Release(executionComponent);
                ServiceLocator.Instance.Release(definitionComponent);
            }

            return(View());
        }
Esempio n. 2
0
        public void ShowHome(String preview, Int32 processDefinitionId, Int32 flowId)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("ShowHome preview:" + preview + " processDefinitionId:" + processDefinitionId + " flowId:" + flowId);
            }
            IDefinitionSessionLocal definitionComponent = null;
            IExecutionSessionLocal  executionComponent  = null;

            try
            {
                definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal;
                executionComponent  = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal;
                //			IList taskList = executionComponent.GetTaskList(new Relations(new System.String[]{"processInstance.processDefinition"}));
                IList taskList           = executionComponent.GetTaskList();
                IList processDefinitions = definitionComponent.GetProcessDefinitions();
                // Collect data for the preview
                if (preview != null)
                {
                    if (preview.Equals("process"))
                    {
                        if (processDefinitionId == 0)
                        {
                            ArrayList errors = new ArrayList();
                            errors.Add("when parameter 'preview' is equal to 'process', a valid parameter 'processDefinitionId' should be provided as well,");
                            Context.Flash["errormessages"] = errors;
                        }

                        IProcessDefinition processDefinition = null;

                        // Get the processDefinition
                        processDefinition = definitionComponent.GetProcessDefinition(processDefinitionId);
                        Context.Flash["processDefinition"] = processDefinition;
                    }
                    else if (preview.Equals("activity"))
                    {
                        if (flowId == 0)
                        {
                            ArrayList errors = new ArrayList();
                            errors.Add("when parameter 'preview' is equal to 'activity', a valid parameter 'flowId' should be provided as well,");
                            Context.Flash["errormessages"] = errors;
                        }
                        //					IFlow flow = executionComponent.GetFlow(flowId, new Relations(new System.String[]{"processInstance.processDefinition"}));
                        IFlow flow = executionComponent.GetFlow(flowId);
                        Context.Flash["activity"] = flow.Node;
                        AddImageCoordinates((IState)flow.Node);
                        Context.Flash["processDefinition"] = flow.ProcessInstance.ProcessDefinition;
                    }
                }

                Context.Flash["taskList"]           = taskList;
                Context.Flash["processDefinitions"] = processDefinitions;
                Context.Flash["preview"]            = preview;
            }
            finally
            {
                ServiceLocator.Instance.Release(executionComponent);
                ServiceLocator.Instance.Release(definitionComponent);
            }
        }
Esempio n. 3
0
		/// <summary> finds a flow upon which the current authenticated user has to act.
		/// It searches the flow in the current authenticated user's tasklist for which the levelsUp-parent has rootFlowId.
		/// @throws FinderException if the flow could not be found 
		/// </summary>
		public IFlow GetFlow(int levelsUp, Int64 rootFlowId, IExecutionSessionLocal executionComponent)
		{
			IFlow theOne = null;

			IList flows = executionComponent.GetTaskList(new Relations(new String[] {"processInstance.processDefinition", "node", "parent"}));
			IEnumerator iter = flows.GetEnumerator();
			while (iter.MoveNext())
			{
				IFlow flow = (IFlow) iter.Current;
				IFlow rootFlow = flow;

				for (int i = 0; i < levelsUp; i++)
				{
					rootFlow = rootFlow.Parent;
				}

				if (rootFlow != null)
				{
					if (rootFlow.Id == rootFlowId)
					{
						theOne = flow;
					}
				}
			}

			if (theOne == null)
			{
				throw new SystemException("No flow in the tasklist could be found that has flow " +
					rootFlowId + " as " + levelsUp + "-levels-up-parent : " + flows);
			}

			return theOne;
		}