/// <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, IExecutionApplicationService 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); }
/// <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, IExecutionApplicationService 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; }
public void ContainerTest() { container = new WindsorContainer(TestHelper.GetConfigDir() + "WindsorContainerTest.xml"); IOrganisationService organisationSession = (IOrganisationService)container["OrganisationSession"]; Assert.IsNotNull(organisationSession); organisationSession = (IOrganisationService)container[typeof(IOrganisationService)]; Assert.IsNotNull(organisationSession); ISchedulerSessionLocal schedulerSession = (ISchedulerSessionLocal)container["SchedulerSession"]; Assert.IsNotNull(schedulerSession); schedulerSession = (ISchedulerSessionLocal)container[typeof(ISchedulerSessionLocal)]; Assert.IsNotNull(schedulerSession); IProcessDefinitionService definitionSession = (IProcessDefinitionService)container["DefinitionSession"]; Assert.IsNotNull(definitionSession); definitionSession = (IProcessDefinitionService)container[typeof(IProcessDefinitionService)]; Assert.IsNotNull(definitionSession); IExecutionApplicationService executionSession = (IExecutionApplicationService)container["ExecutionSession"]; Assert.IsNotNull(executionSession); executionSession = (IExecutionApplicationService)container[typeof(IExecutionApplicationService)]; Assert.IsNotNull(executionSession); ILogSessionLocal logSession = (ILogSessionLocal)container["LogSession"]; Assert.IsNotNull(logSession); logSession = (ILogSessionLocal)container[typeof(ILogSessionLocal)]; Assert.IsNotNull(logSession); }
public void Run(IActionContext actionContext) { IFlow flow = actionContext.GetFlow(); INode currentNode = flow.Node; if ("do bloody thing".Equals(currentNode.Name)) //'do bloody thing' hasn't been performed { IExecutionApplicationService executionComponent = (IExecutionApplicationService)serviceLocator.GetService(typeof(IExecutionApplicationService)); try { //ae is a robot. Human (in) is incapable. Let robot replace him. executionComponent.DelegateActivity(flow.Id, "ae"); //call external component (robot web service) to act on the flow System.Console.Out.WriteLine("calling robot web service to act on the flow... [ok]"); //Now, revenge time: director fires originally assigned executor System.Console.Out.WriteLine("Isaac, you're fired!"); } catch (ExecutionException e) { throw new System.SystemException("failed executing task: " + typeof(OvertakingAction) + " " + e.Message); } finally { serviceLocator.Release(executionComponent); } } }
public void CancelFlow(String actorId, Int64 flowId, int levelsUp, IExecutionApplicationService executionComponent) { LoginUser(actorId); IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent); executionComponent.CancelFlow(flowInList.Id); }
public void DelegateFlow(Int64 flowId, int levelsUp, String actorId, String delegateActorId, IExecutionApplicationService executionComponent) { LoginUser(actorId); IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent); // delegate the activity executionComponent.DelegateActivity(flowInList.Id, delegateActorId); }
public IList PerformActivity(String actorId, Int64 flowId, int levelsUp, IDictionary attributeValues, IExecutionApplicationService executionComponent) { IList assignedFlows = null; LoginUser(actorId); IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent); assignedFlows = executionComponent.PerformActivity(flowInList.Id, attributeValues); return assignedFlows; }
public void SetContainer() { //configure the container _container = new NetBpmContainer(new XmlInterpreter("WindsorConfig.xml")); servicelocator = ServiceLocator.Instance; definitionComponent = servicelocator.GetService(typeof(IProcessDefinitionService)) as IProcessDefinitionService; executionComponent = servicelocator.GetService(typeof(IExecutionApplicationService)) as IExecutionApplicationService; }
public void SetContainer() { //configure the container _container = new NetBpmContainer(new XmlInterpreter("WindsorConfig.xml")); servicelocator = ServiceLocator.Instance; processDefinitionService = servicelocator.GetService(typeof(IProcessDefinitionService)) as IProcessDefinitionService; executionComponent = servicelocator.GetService(typeof(IExecutionApplicationService)) as IExecutionApplicationService; }
public void DisposeContainer() { servicelocator.Release(definitionComponent); definitionComponent = null; servicelocator.Release(executionComponent); executionComponent = null; _container.Dispose(); _container = null; }
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(IProcessDefinitionService)) as IProcessDefinitionService; executionComponent = servicelocator.GetService(typeof(IExecutionApplicationService)) as IExecutionApplicationService; testUtil.LoginUser("ae"); }
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 (IProcessDefinitionService)) as IProcessDefinitionService; executionComponent = servicelocator.GetService(typeof (IExecutionApplicationService)) as IExecutionApplicationService; testUtil.LoginUser("ae"); }
public void SetContainer() { //configure the container _container = new NetBpmContainer(new XmlInterpreter("app_config.xml")); testUtil = new TestUtil(); servicelocator = ServiceLocator.Instance; definitionComponent = servicelocator.GetService(typeof (IProcessDefinitionService)) as IProcessDefinitionService; executionComponent = servicelocator.GetService(typeof (IExecutionApplicationService)) as IExecutionApplicationService; schedulerComponent = servicelocator.GetService(typeof (ISchedulerSessionLocal)) as ISchedulerSessionLocal; organisationComponent = servicelocator.GetService(typeof (IOrganisationService)) as IOrganisationService; testUtil.LoginUser("ae"); // Par是一個壓縮檔,除了有定義檔之外,還有可以用來展出Web-UI定義及相關圖形 FileInfo parFile = new FileInfo(TestHelper.GetExampleDir()+GetParArchiv()); FileStream fstream = parFile.OpenRead(); byte[] b = new byte[parFile.Length]; fstream.Read(b, 0, (int) parFile.Length); //此處在解壓縮Par definitionComponent.DeployProcessArchive(b); }
public void SetContainer() { //configure the container _container = new NetBpmContainer(new XmlInterpreter("app_config.xml")); testUtil = new TestUtil(); servicelocator = ServiceLocator.Instance; definitionComponent = servicelocator.GetService(typeof(IProcessDefinitionService)) as IProcessDefinitionService; executionComponent = servicelocator.GetService(typeof(IExecutionApplicationService)) as IExecutionApplicationService; schedulerComponent = servicelocator.GetService(typeof(ISchedulerSessionLocal)) as ISchedulerSessionLocal; organisationComponent = servicelocator.GetService(typeof(IOrganisationService)) as IOrganisationService; testUtil.LoginUser("ae"); // Par是一個壓縮檔,除了有定義檔之外,還有可以用來展出Web-UI定義及相關圖形 FileInfo parFile = new FileInfo(TestHelper.GetExampleDir() + GetParArchiv()); FileStream fstream = parFile.OpenRead(); byte[] b = new byte[parFile.Length]; fstream.Read(b, 0, (int)parFile.Length); //此處在解壓縮Par definitionComponent.DeployProcessArchive(b); }
public void CheckDelegateActivity(String authenticatedActorId, Int64 flowId, String delegateActorId) { //only director can delegate an activity IExecutionApplicationService executionComponent = (IExecutionApplicationService)serviceLocator.GetService(typeof(IExecutionApplicationService)); try { IFlow flow = executionComponent.GetFlow(flowId, new Relations("attributeInstances")); IActor director = null; ISet attributeInstances = flow.AttributeInstances; for (IEnumerator iter = attributeInstances.GetEnumerator(); iter.MoveNext();) { IAttributeInstance attributeInstance = (IAttributeInstance)iter.Current; if ("director".Equals(attributeInstance.Attribute.Name)) { director = (IActor)attributeInstance.GetValue(); } } if (director.Id.Equals(authenticatedActorId) == false) { throw new AuthorizationException("Only director is allowed to delegate activity"); } } catch (AuthorizationException e) { throw e; } catch (System.Exception e) { log.Error("failed doing authorization : ", e); throw new System.SystemException("failed doing authorization : " + e.Message); } finally { serviceLocator.Release(executionComponent); } }
public void CheckPerformActivity(String authenticatedActorId, Int64 flowId, IDictionary attributeValues, String transitionName) { //only actor assigned for that activity can perform an activity IExecutionApplicationService executionComponent = (IExecutionApplicationService)serviceLocator.GetService(typeof(IExecutionApplicationService)); try { IFlow flow = executionComponent.GetFlow(flowId); if (flow.GetActor().Id.Equals(authenticatedActorId) == false) { throw new AuthorizationException("only actor assigned for that activity can perform an activity"); } } catch (ExecutionException e) { log.Error("failed doing authorization : ", e); throw new System.SystemException("failed doing authorization : " + e.Message); } finally { serviceLocator.Release(executionComponent); } }
public IList PerformActivity(String actorId, Int64 flowId, int levelsUp, IDictionary attributeValues, IExecutionApplicationService executionComponent) { IList assignedFlows = null; LoginUser(actorId); IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent); assignedFlows = executionComponent.PerformActivity(flowInList.Id, attributeValues); return(assignedFlows); }
public void CancelInstance(String actorId, Int64 processInstanceId, IExecutionApplicationService executionComponent) { LoginUser(actorId); // perform the cancel instance operaction executionComponent.CancelProcessInstance(processInstanceId); }