コード例 #1
0
        //
        // GET: /Form/
        public ActionResult ActivityForm(long flowId)
        {
            IExecutionSessionLocal executionComponent = null;

            try
            {
                executionComponent = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal;
                IFlow flow = executionComponent.GetFlow(flowId);

                ViewData["activity"]          = flow.Node;
                ViewData["processDefinition"] = flow.ProcessInstance.ProcessDefinition;
                ViewData["preview"]           = "activity";
                //AddImageCoordinates((IState)flow.Node);

                //create Form
                IActivityForm activityForm = executionComponent.GetActivityForm(flowId);
                AddFormData(activityForm);
            }
            finally
            {
                ServiceLocator.Instance.Release(executionComponent);
            }

            return(View());
        }
コード例 #2
0
        public void ShowActivityForm(long flowId)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("ShowActivityForm flowId:" + flowId);
            }
            IExecutionSessionLocal executionComponent = null;

            try
            {
                executionComponent = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal;
                IFlow flow = executionComponent.GetFlow(flowId);

                Context.Flash["activity"]          = flow.Node;
                Context.Flash["processDefinition"] = flow.ProcessInstance.ProcessDefinition;
                Context.Flash["preview"]           = "activity";
                AddImageCoordinates((IState)flow.Node);

                //create Form
                IActivityForm activityForm = executionComponent.GetActivityForm(flowId);
                AddFormData(activityForm);
            }
            finally
            {
                ServiceLocator.Instance.Release(executionComponent);
            }

            RenderView("activityForm");
        }
コード例 #3
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);
            }
        }
コード例 #4
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());
        }
コード例 #5
0
        public void StartProcessInstance(long processDefinitionId)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("StartProcessInstance processDefinitionId:" + processDefinitionId);
            }

            IExecutionSessionLocal  executionComponent  = null;
            IDefinitionSessionLocal definitionComponent = null;

            try
            {
                executionComponent  = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal;
                definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal;
                IProcessDefinition processDefinition = definitionComponent.GetProcessDefinition(processDefinitionId);

                Context.Flash["activity"]          = processDefinition.StartState;
                Context.Flash["processDefinition"] = processDefinition;
                Context.Flash["preview"]           = "activity";
                AddImageCoordinates(processDefinition.StartState);

                //create Form
                IActivityForm activityForm = executionComponent.GetStartForm(processDefinitionId);
                AddFormData(activityForm);
                RenderView("activityForm");
            }
            finally
            {
                ServiceLocator.Instance.Release(executionComponent);
                ServiceLocator.Instance.Release(definitionComponent);
            }
        }
コード例 #6
0
ファイル: TestUtil.cs プロジェクト: qwinner/NetBPM
		/// <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;
		}
コード例 #7
0
ファイル: TestUtil.cs プロジェクト: qwinner/NetBPM
		public void DelegateFlow(Int64 flowId, int levelsUp, String actorId, String delegateActorId, IExecutionSessionLocal executionComponent)
		{
			LoginUser(actorId);
			IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent);

			// delegate the activity
			executionComponent.DelegateActivity(flowInList.Id, delegateActorId);
		}
コード例 #8
0
ファイル: TestUtil.cs プロジェクト: qwinner/NetBPM
		public IList PerformActivity(String actorId, Int64 flowId, int levelsUp, IDictionary attributeValues, IExecutionSessionLocal executionComponent)
		{
			IList assignedFlows = null;
			LoginUser(actorId);
			IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent);
			assignedFlows = executionComponent.PerformActivity(flowInList.Id, attributeValues);
			return assignedFlows;
		}
コード例 #9
0
ファイル: ActionVersionTest.cs プロジェクト: qwinner/NetBPM
		public void DisposeContainer()
		{	
			servicelocator.Release(definitionComponent);
			definitionComponent=null;
			servicelocator.Release(executionComponent);
			executionComponent=null;

			_container.Dispose();
			_container = null;
		}
コード例 #10
0
ファイル: ActionVersionTest.cs プロジェクト: qwinner/NetBPM
		public void SetContainer()
		{
			//configure the container
			_container = new NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir()+"app_config.xml"));
			testUtil = new TestUtil();
			servicelocator = ServiceLocator.Instance;
			definitionComponent = servicelocator.GetService(typeof (IDefinitionSessionLocal)) as IDefinitionSessionLocal;
			executionComponent = servicelocator.GetService(typeof (IExecutionSessionLocal)) as IExecutionSessionLocal;
			testUtil.LoginUser("ae");

		}
コード例 #11
0
ファイル: AbstractExampleTest.cs プロジェクト: qwinner/NetBPM
		public void SetContainer()
		{
			//configure the container
			_container = new NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir()+"app_config.xml"));
			testUtil = new TestUtil();
			servicelocator = ServiceLocator.Instance;
			definitionComponent = servicelocator.GetService(typeof (IDefinitionSessionLocal)) as IDefinitionSessionLocal;
			executionComponent = servicelocator.GetService(typeof (IExecutionSessionLocal)) as IExecutionSessionLocal;
			schedulerComponent = servicelocator.GetService(typeof (ISchedulerSessionLocal)) as ISchedulerSessionLocal;
			organisationComponent = servicelocator.GetService(typeof (IOrganisationSessionLocal)) as IOrganisationSessionLocal;
			testUtil.LoginUser("ae");

			// deploy Archiv
			FileInfo parFile = new FileInfo(TestHelper.GetExampleDir()+GetParArchiv());
			FileStream fstream = parFile.OpenRead();
			byte[] b = new byte[parFile.Length];
			fstream.Read(b, 0, (int) parFile.Length);
			definitionComponent.DeployProcessArchive(b);

		}
コード例 #12
0
        public ActionResult ActivityForm(string aa)
        {
            IDictionary   userInputFields = new Hashtable();
            IActivityForm activityForm    = (IActivityForm)HttpContext.Session["activityForm"];
            IList         fields          = activityForm.Fields;
            IEnumerator   fildEnumer      = fields.GetEnumerator();

            while (fildEnumer.MoveNext())
            {
                IField field = (IField)fildEnumer.Current;
                // Construct a meaningfull name that is http-compliant
                String attributeName  = field.Attribute.Name;
                String parameterName  = convertToHttpCompliant(attributeName);
                String parameterValue = HttpContext.Request.Params[parameterName];

                if (FieldAccessHelper.IsRequired(field.Access) && (parameterValue == null || "".Equals(parameterValue)))
                {
                    //AddMessage("Field "+field.Name+" is required. Please, provide a value");
                }
                else
                {
                    try
                    {
                        Object         parsedParameter = null;
                        IHtmlFormatter htmlFormatter   = field.GetHtmlFormatter();
                        if (htmlFormatter != null)
                        {
                            // TODO: Test if there is the possibility to simplify the interface, see null
                            parsedParameter = htmlFormatter.ParseHttpParameter(parameterValue, null);

                            if (parsedParameter != null)
                            {
                                userInputFields.Add(attributeName, parsedParameter);
                            }
                        }
                        else
                        {
                            //log.Warn("No htmlformatter defined for field:"+field.Name);
                        }
                    }
                    catch (Exception ex)
                    {
                        //log.Debug( "error parsing user-input-field " + field.Name + " : " + parameterValue,ex);
                        //AddMessage("error parsing user-input-field " + field.Name + " with value: " + parameterValue);
                    }
                }
            }

            if (false)
            {
                //log.Debug( "submitted activity-form has messages, redirecting to activityFormPage..." );
                HttpContext.Session.Add("userInputFields", userInputFields);
                if (activityForm.Flow == null)
                {
                    return(RedirectToAction("ActivityForm", "Form",
                                            new RouteValueDictionary()
                    {
                        { "flowId", activityForm.ProcessDefinition.Id }
                    }));
                    //StartProcessInstance(activityForm.ProcessDefinition.Id);
                }
                else
                {
                    return(RedirectToAction("ActivityForm", "Form", new RouteValueDictionary()));
                    //ShowActivityForm(activityForm.Flow.Id);
                }
            }
            else
            {
                // remove the old inputvalues
                HttpContext.Session.Remove("userInputFields");
                //log.Debug( "submitting the form..." );
                IList activatedFlows = null;
                IFlow flow           = activityForm.Flow;
                // if there is no flow in the activityForm
                IExecutionSessionLocal executionComponent = null;
                try
                {
                    executionComponent = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal;
                    if (flow == null)
                    {
                        // this means that it is a start-activity being performed so we have to
                        // start a new process instance
                        IProcessDefinition processDefinition = activityForm.ProcessDefinition;
                        IProcessInstance   processInstance   = executionComponent.StartProcessInstance(processDefinition.Id, userInputFields);
                        activatedFlows = new ArrayList();
                        //AddAllActiveFlows(processInstance.RootFlow,activatedFlows);
                        //activatedFlows.Add(processInstance.RootFlow);
                    }
                    else
                    {
                        activatedFlows = executionComponent.PerformActivity(flow.Id, userInputFields);
                    }
                }
                finally
                {
                    ServiceLocator.Instance.Release(executionComponent);
                }
                if (activatedFlows.Count > 0)
                {
                    System.Text.StringBuilder feedbackBuffer = new System.Text.StringBuilder();
                    for (int i = 0; i < activatedFlows.Count; ++i)
                    {
                        IFlow activatedFlow = (IFlow)activatedFlows[i];

                        if (activatedFlow.GetActor() != null)
                        {
                            feedbackBuffer.Append(activatedFlow.GetActor().Name);
                        }
                        else
                        {
                            // when flow's node is start-state no actor is assigned to it, this is to handle the NPE thrown
                            feedbackBuffer.Append("Nobody");
                        }
                        if (i + 1 < activatedFlows.Count)
                        {
                            feedbackBuffer.Append(", ");
                        }
                    }

                    if (activatedFlows.Count > 1)
                    {
                        //AddMessage("Now, following people are handling this process :"+feedbackBuffer.ToString());
                    }
                    else
                    {
                        //AddMessage("Now, "+  feedbackBuffer.ToString() +" is handling this process");
                    }
                    return(Redirect("/User/ShowHome"));
                }
                else
                {
                    //AddMessage("This flow in the process finished");
                    return(Redirect("/User/ShowHome"));
                }
            }
        }
コード例 #13
0
ファイル: TestUtil.cs プロジェクト: qwinner/NetBPM
		public void CancelInstance(String actorId, Int64 processInstanceId, IExecutionSessionLocal executionComponent)
		{
			LoginUser(actorId);
			// perform the cancel instance operaction
			executionComponent.CancelProcessInstance(processInstanceId);
		}
コード例 #14
0
ファイル: TestUtil.cs プロジェクト: qwinner/NetBPM
		public void CancelFlow(String actorId, Int64 flowId, int levelsUp, IExecutionSessionLocal executionComponent)
		{
			LoginUser(actorId);
			IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent);
			executionComponent.CancelFlow(flowInList.Id);
		}