コード例 #1
0
ファイル: AdaptersTest.cs プロジェクト: wooln/AK47Source
        public void ProcessAclTest()
        {
            WfAclAdapter.Instance.ClearAll();

            IWfProcess process = ProcessHelper.CreateFreeStepsProcessDescriptor(
                OguObjectSettings.GetConfig().Objects["approver1"].User,
                OguObjectSettings.GetConfig().Objects["ceo"].User,
                OguObjectSettings.GetConfig().Objects["ceo"].User).StartupProcess();

            ((WfProcess)process).ResourceID = "resource2";

            process = process.MoveToDefaultActivityByExecutor();

            process = process.MoveToDefaultActivityByExecutor();

            process = process.MoveToDefaultActivityByExecutor();

            string userID = process.CurrentActivity.Assignees[0].User.ID;

            WfAclItemCollection currentItems = WfAclAdapter.Instance.Load(builder =>
            {
                builder.AppendItem("RESOURCE_ID", "resource2");
                builder.AppendItem("OBJECT_ID", userID);
            });

            Assert.AreEqual(1, currentItems.Count, "相同的人只保留一条记录");

            WfAclItemCollection allItems = WfAclAdapter.Instance.LoadByResourceID("resource2");

            Assert.AreEqual(2, allItems.Count, "只会有两条记录.在一个资源下同一个人只会有一条记录存在。但是如果存在委托时,则个数就不定");
        }
コード例 #2
0
        public void WithdrawAndCancelTest()
        {
            IWfProcess process = ProcessHelper.CreateFreeStepsProcessDescriptor(OguObjectSettings.GetConfig().Objects["approver1"].User).StartupProcess();

            process = process.MoveToDefaultActivityByExecutor();

            string activityIDBeforeWithdraw = process.CurrentActivity.ID;

            Assert.AreEqual(WfActivityType.NormalActivity, process.CurrentActivity.Descriptor.ActivityType);

            Console.WriteLine("ActivityID Before Withdraw = {0}, Process ID = {1}", activityIDBeforeWithdraw, process.ID);

            process = process.WithdrawByExecutor(true);

            Assert.AreEqual(WfActivityType.InitialActivity, process.CurrentActivity.Descriptor.ActivityType);

            Assert.AreEqual(WfProcessStatus.Aborted, process.Status);

            UserTaskCollection notifies = UserTaskAdapter.Instance.GetUserTasks(UserTaskIDType.ActivityID, UserTaskFieldDefine.ActivityID | UserTaskFieldDefine.Status, activityIDBeforeWithdraw);

            Assert.AreEqual(1, notifies.Count);

            UserTaskCollection tasks = UserTaskAdapter.Instance.GetUserTasks(UserTaskIDType.ActivityID, UserTaskFieldDefine.ActivityID | UserTaskFieldDefine.Status, process.InitialActivity.ID);

            Assert.AreEqual(1, tasks.Count);
            Assert.AreEqual(TaskStatus.Yue, tasks[0].Status);

            UserTaskCollection accomplishedTasks = UserTaskAdapter.Instance.GetUserAccomplishedTasks(UserTaskIDType.ActivityID, UserTaskFieldDefine.ActivityID | UserTaskFieldDefine.Status, false, activityIDBeforeWithdraw);

            Assert.AreEqual(1, tasks.Count);
        }
コード例 #3
0
        public void StartWorkflowAndMoveToNextDefaultExecutorTest()
        {
            IWfProcessDescriptor processDesp = ProcessHelper.CreateFreeStepsProcessDescriptor(OguObjectSettings.GetConfig().Objects["approver1"].User);

            WfProcessStartupParams startupParams = processDesp.PrepareStartupParams();

            WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(null, startupParams, null);

            IWfProcess process = executor.Execute();

            IWfProcess processLoaded = WfRuntime.GetProcessByProcessID(process.ID);

            Console.WriteLine("Process ID: {0}, Status: {1}", process.ID, process.Status);
            Console.WriteLine("Current ActivityKey : {0}, Status: {1}", process.CurrentActivity.Descriptor.Key, process.CurrentActivity.Status);

            Assert.AreEqual(process.CurrentActivity.ID, processLoaded.CurrentActivity.ID);
            Assert.AreEqual(WfActivityStatus.Running, processLoaded.CurrentActivity.Status);
            Assert.IsTrue(processLoaded.CurrentActivity.Assignees.Count > 0);
            Assert.AreEqual(processLoaded.CurrentActivity.FromTransitionDescriptor, processLoaded.InitialActivity.ToTransitionDescriptor);
        }
コード例 #4
0
 private static IWfProcessDescriptor CreateTestProcessDescriptor()
 {
     return(ProcessHelper.CreateFreeStepsProcessDescriptor(OguObjectSettings.GetConfig().Objects["approver1"].User));
 }