Exemplo n.º 1
0
        private void Run()
        {
            PendingActServiceConfigurationElement pendingActServiceParam = PendingActServiceSettings.GetConfig().PendingActServices[this.Params.Name];

            pendingActServiceParam.NullCheck(string.Format("pendingActServiceConfig配置节错误,没有找到线程{0}对应的节点.", this.Params.Name));

            WfPendingActivityInfoCollection pendingActs = LoadPendingActs(pendingActServiceParam.ApplicationName, pendingActServiceParam.ProgramName);

            if (pendingActs.Count > 0)
            {
                Thread.CurrentPrincipal = new DeluxePrincipal(new DeluxeIdentity(pendingActServiceParam.Operator));

                //WfActivity中CanMoveTo没有判断StartTime。我希望在workflowSettings加开关,是否使用它。
                foreach (var pendingAct in pendingActs)
                {
                    try
                    {
                        WfRuntime.ProcessPendingActivity(pendingAct);
                    }
                    catch (System.Exception ex)
                    {
                        this.Params.Log.Write(ex);
                    }
                    finally
                    {
                        WfRuntime.ClearCache();
                    }
                }
            }
        }
Exemplo n.º 2
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.º 3
0
        private static WfPendingActivityInfoCollection LoadPendingActs(string appName, string progName)
        {
            WfPendingActivityInfoCollection result = null;

            if (appName.ToLower() == "all" && progName.ToLower() == "all")
            {
                result = WfPendingActivityInfoAdapter.Instance.LoadAll();
            }
            else
            {
                //当appName和progName都是空时,相当于all。返回所有记录
                result = WfPendingActivityInfoAdapter.Instance.Load(appName, progName);                 //注意PendingActivity表关于AppName和progName的索引
            }

            return(result);
        }
Exemplo n.º 4
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.º 5
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));
        }