Пример #1
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, 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);
        }
Пример #2
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, 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;
		}
Пример #3
0
        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);
        }
Пример #4
0
        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);
                }
            }
        }
Пример #5
0
        public void CancelFlow(String actorId, Int64 flowId, int levelsUp, IExecutionApplicationService executionComponent)
        {
            LoginUser(actorId);
            IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent);

            executionComponent.CancelFlow(flowInList.Id);
        }
Пример #6
0
		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);
		}
Пример #7
0
		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;
		}
Пример #8
0
 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;
 }
Пример #9
0
 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;
 }
Пример #10
0
        public void DisposeContainer()
        {
            servicelocator.Release(definitionComponent);
            definitionComponent = null;
            servicelocator.Release(executionComponent);
            executionComponent = null;

            _container.Dispose();
            _container = null;
        }
Пример #11
0
 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");
 }
Пример #12
0
        public void DisposeContainer()
        {
            servicelocator.Release(definitionComponent);
            definitionComponent = null;
            servicelocator.Release(executionComponent);
            executionComponent = null;

            _container.Dispose();
            _container = null;
        }
Пример #13
0
		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");

		}
Пример #14
0
		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);

		}
Пример #15
0
        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);
        }
Пример #16
0
        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);
            }
        }
Пример #17
0
        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);
            }
        }
Пример #18
0
        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);
        }
Пример #19
0
        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);
        }
Пример #20
0
 public void CancelInstance(String actorId, Int64 processInstanceId, IExecutionApplicationService executionComponent)
 {
     LoginUser(actorId);
     // perform the cancel instance operaction
     executionComponent.CancelProcessInstance(processInstanceId);
 }
Пример #21
0
		public void CancelFlow(String actorId, Int64 flowId, int levelsUp, IExecutionApplicationService executionComponent)
		{
			LoginUser(actorId);
			IFlow flowInList = GetFlow(levelsUp, flowId, executionComponent);
			executionComponent.CancelFlow(flowInList.Id);
		}
Пример #22
0
		public void CancelInstance(String actorId, Int64 processInstanceId, IExecutionApplicationService executionComponent)
		{
			LoginUser(actorId);
			// perform the cancel instance operaction
			executionComponent.CancelProcessInstance(processInstanceId);
		}