Exemplo n.º 1
0
        public void ActivityConditionTest()
        {
            TestContext.Properties["Amount"] = 2500;    //不满足条件
            WfRuntime.ProcessContext.EvaluateActivityCondition += new Expression.CalculateUserFunction(ProcessContext_EvaluateTransition);

            IWfProcess process = WfProcessTestCommon.StartupSimpleProcessDescriptorWithActivityCondition();

            Assert.AreEqual(WfActivityStatus.Running, process.InitialActivity.Status);

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams      transferParams   = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.requestor);

            process.MoveTo(transferParams);

            Assert.AreEqual(WfActivityStatus.Completed, process.InitialActivity.Status);

            Assert.AreEqual(WfActivityStatus.Pending, process.CurrentActivity.Status);

            IWfActivity activity = WfRuntime.ProcessContext.OriginalActivity;

            WfRuntime.PersistWorkflows();

            TestContext.Properties["Amount"] = 7500;

            WfPendingActivityInfoCollection pendingActivities = WfPendingActivityInfoAdapter.Instance.Load(builder => builder.AppendItem("ACTIVITY_ID", process.CurrentActivity.ID));

            pendingActivities.ForEach(pai => WfRuntime.ProcessPendingActivity(pai));
        }
Exemplo n.º 2
0
        public void ActivityConditionTest()
        {
            WfPendingActivityInfoAdapter.Instance.ClearAll();

            TestContext.Properties["Amount"] = 1000;

            IWfProcessDescriptor processDesp = ProcessHelper.CreateSimpleProcessDescriptor();

            processDesp.Activities["NormalActivity"].Condition.Expression = "Amount > 5000";

            WfRuntime.ProcessContext.EvaluateActivityCondition += new Expression.CalculateUserFunction(ProcessContext_EvaluateTransition);

            IWfProcess process = processDesp.StartupProcess();

            IWfActivity normalActivity = process.MoveToNextDefaultActivity();

            Console.WriteLine(normalActivity.Status);

            Assert.AreEqual(WfActivityStatus.Pending, normalActivity.Status);

            WfRuntime.PersistWorkflows();

            string activityID = process.CurrentActivity.ID;

            WfPendingActivityInfoCollection pendingActivities = WfPendingActivityInfoAdapter.Instance.Load(builder => builder.AppendItem("ACTIVITY_ID", process.CurrentActivity.ID));

            Assert.IsTrue(pendingActivities.Count > 0);

            TestContext.Properties["Amount"] = 8000;

            pendingActivities.ForEach(pa => WfRuntime.ProcessPendingActivity(pa));

            process = WfRuntime.GetProcessByProcessID(process.ID);

            Assert.AreEqual(WfActivityStatus.Completed, process.Activities[activityID].Status);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置被挂起节点的状态为Running
        /// </summary>
        /// <param name="activityID"></param>
        public static void ProcessPendingActivity(string activityID)
        {
            WfPendingActivityInfoCollection pendingActivities = WfPendingActivityInfoAdapter.Instance.Load(builder => builder.AppendItem("ACTIVITY_ID", activityID));

            pendingActivities.ForEach(pai => WfRuntime.ProcessPendingActivity(pai));
        }