示例#1
0
        public void BasicDynamicActivityTest()
        {
            IWfProcessDescriptor processDesp = ProcessHelper.CreateSimpleProcessDescriptor();

            processDesp.Activities["NormalActivity"].RelativeLinks.Add(new WfRelativeLinkDescriptor("DynLink")
            {
                Url = "http://localhost"
            });

            IWfActivityDescriptor templateActDesp = processDesp.Activities["NormalActivity"];

            FillDynamicActivitySimpleResource(templateActDesp, (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);

            IWfProcess process = processDesp.StartupProcess();

            IWfActivityDescriptor firstDynamicActDesp = ValidateDynamicActivities(process.InitialActivity.Descriptor, templateActDesp);

            Assert.AreEqual(templateActDesp.RelativeLinks.Count, firstDynamicActDesp.RelativeLinks.Count);

            ValidateInDynamicTransitionsProperties(firstDynamicActDesp.FromTransitions, templateActDesp);

            ValidateLastDynamicTransitions(templateActDesp);

            ValidateTemplateCandidatesAndDynamicActivityCandidates(firstDynamicActDesp, templateActDesp);
        }
示例#2
0
        public void AddActivityWithConsignExecutorTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcess();

            int originalActCount = process.Activities.Count;

            IWfActivity targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity");

            WfActivityDescriptorCreateParams createParams = new WfActivityDescriptorCreateParams();

            createParams.AllAgreeWhenConsign = true;
            createParams.Users = new OguDataCollection <IUser>();
            createParams.Users.Add((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);
            createParams.Users.Add((IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object);

            WfAddActivityExecutor executor = new WfAddActivityExecutor(process.CurrentActivity, targetActivity, createParams);

            executor.Execute();

            Assert.AreEqual(originalActCount + 1, process.Activities.Count);

            WfMainStreamActivityDescriptorCollection processDespMSA = process.Descriptor.GetMainStreamActivities();
            WfMainStreamActivityDescriptorCollection processMSA     = process.GetMainStreamActivities(true);

            processDespMSA.Output("流程描述中的主线活动");
            processMSA.Output("主线流程中的主线活动");

            Assert.AreEqual(1, executor.AddedActivity.Descriptor.BranchProcessTemplates.Count);
            Assert.AreEqual(1, executor.AddedActivity.GetMainStreamActivityDescriptor().BranchProcessTemplates.Count);

            Assert.AreEqual(process.Descriptor.Activities.Count, process.MainStream.Activities.Count);
            Assert.AreEqual(processDespMSA.Count, processMSA.Count);
        }
示例#3
0
        public void BaseAddApproverExecutorOnlyAddApproverModeTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcess();

            int originalActCount = process.Activities.Count;

            WfProcessTestCommon.MoveToNextDefaultActivity(process);

            IWfActivity           targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity");
            WfAddApproverExecutor executor       = new WfAddApproverExecutor(process.CurrentActivity, targetActivity);

            executor.AddApproverMode = WfAddApproverMode.OnlyAddApprover;

            executor.Assignees.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object);
            executor.Execute();

            Assert.AreEqual(originalActCount + 1, process.Activities.Count);
            Assert.AreEqual(originalActCount + 1, process.MainStream.Activities.Count);

            WfMainStreamActivityDescriptorCollection processDespMSA = process.Descriptor.GetMainStreamActivities();
            WfMainStreamActivityDescriptorCollection processMSA     = process.GetMainStreamActivities(true);

            processDespMSA.Output("流程描述中的主线活动");
            processMSA.Output("主线流程中的主线活动");
        }
示例#4
0
        private static WfUserResourceDescriptor GetUserResDespInstance()
        {
            WfUserResourceDescriptor userResDesp = new WfUserResourceDescriptor();

            userResDesp.User = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object;
            return(userResDesp);
        }
示例#5
0
        public void WfBranchProcessTransferParamsJsonTest()
        {
            WfConverterHelper.RegisterConverters();

            IUser user = (IUser)OguObjectSettings.GetConfig().Objects[OguObject.requestor.ToString()].Object;

            IWfBranchProcessTemplateDescriptor template = WfProcessTestCommon.CreateTemplate("Consign", user);

            WfBranchProcessTransferParams data = new WfBranchProcessTransferParams(template);

            data.BranchParams.Clear();

            WfBranchProcessStartupParams bpsp = new WfBranchProcessStartupParams(user);

            bpsp.Department           = user.Parent;
            bpsp.RelativeParams["RP"] = UuidHelper.NewUuidString();
            bpsp.ApplicationRuntimeParameters["context"] = UuidHelper.NewUuidString();
            bpsp.ResourceID       = UuidHelper.NewUuidString();
            bpsp.DefaultTaskTitle = UuidHelper.NewUuidString();
            bpsp.StartupContext   = UuidHelper.NewUuidString();

            data.BranchParams.Add(bpsp);

            string serilizedData = JSONSerializerExecute.Serialize(data);

            Console.WriteLine(serilizedData);

            WfBranchProcessTransferParams deserilizedData = JSONSerializerExecute.Deserialize <WfBranchProcessTransferParams>(serilizedData);

            Assert.AreEqual(data.Template.Key, deserilizedData.Template.Key);
            Assert.AreEqual(data.Template.BranchProcessKey, deserilizedData.Template.BranchProcessKey);

            AssertBranchProcessStartupParams(data.BranchParams[0], deserilizedData.BranchParams[0]);
        }
示例#6
0
        public void ReplaceAssigneeExecutorTestReplay()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            IWfActivityDescriptor normalActDesp = processDesp.Activities["NormalActivity"];

            IUser originalApprover = (IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object;

            normalActDesp.Resources.Clear();
            normalActDesp.Resources.Add(new WfUserResourceDescriptor(originalApprover));

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            WfProcessTestCommon.MoveToNextDefaultActivityWithExecutor(process);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            IUser newApprover = (IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver2.ToString()].Object;

            WfReplaceAssigneesExecutor executor = new WfReplaceAssigneesExecutor(process.CurrentActivity, process.CurrentActivity, originalApprover, new IUser[] { newApprover });

            executor.Execute();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            UserTaskCollection tasks = UserTaskAdapter.Instance.LoadUserTasks(build => build.AppendItem("ACTIVITY_ID", process.CurrentActivity.ID));

            Assert.AreEqual(1, tasks.Count);
            Assert.AreEqual(newApprover.ID, tasks[0].SendToUserID);
        }
示例#7
0
        private static ComplexFormData PrepareComplexFormData()
        {
            ComplexFormData result = new ComplexFormData();

            result.ID      = UuidHelper.NewUuidString();
            result.Subject = string.Format("测试ComplexFormData-{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);

            IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            result.Creator = user;

            result.StringProperty = "Windows A,B,C";

            result.SubDataA.Add(new SubClassDataTypeA()
            {
                ResourceID = result.ID, Class = "SubDataA", SubStringPropertyA = "Data A1", SearchContent = "贾彦军"
            });
            result.SubDataA.Add(new SubClassDataTypeA()
            {
                ResourceID = result.ID, Class = "SubDataA", SubStringPropertyA = "Data A2"
            });

            result.SubDataB.Add(new SubClassDataTypeB()
            {
                ResourceID = result.ID, Class = "SubDataB", SubStringPropertyB = "Data B1", SearchContent = "徐磊"
            });
            result.SubDataB.Add(new SubClassDataTypeB()
            {
                ResourceID = result.ID, Class = "SubDataB", SubStringPropertyB = "Data B2"
            });

            return(result);
        }
示例#8
0
        private static SampleFormData PrepareSampleData()
        {
            SampleFormData result = new SampleFormData();

            result.ID            = UuidHelper.NewUuidString();
            result.Subject       = string.Format("测试FormData-{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
            result.SearchContent = "晏德智";

            IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            result.Creator = user;

            result.StringProperty = "Windows 7,8,9";

            SampleSubFormData sub1 = new SampleSubFormData();

            sub1.SubItemID = 1;
            sub1.Name      = "Sub Data 1";

            result.SubData.Add(sub1);

            SampleSubFormData sub2 = new SampleSubFormData();

            sub2.SubItemID = 2;
            sub2.Name      = "Sub Data 2";

            result.SubData.Add(sub2);

            return(result);
        }
示例#9
0
        public void WfGroupResourceDescriptorConverterTest()
        {
            WfConverterHelper.RegisterConverters();

            IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            OguObjectCollection <IGroup> groupColl = user.MemberOf;

            foreach (var group in groupColl)
            {
                WfGroupResourceDescriptor groupDesp = new WfGroupResourceDescriptor(group);

                string result = JSONSerializerExecute.Serialize(groupDesp);

                Console.WriteLine(result);

                WfGroupResourceDescriptor deserializedGroupDesp = JSONSerializerExecute.Deserialize <WfGroupResourceDescriptor>(result);

                string reSerialized = JSONSerializerExecute.Serialize(deserializedGroupDesp);

                Assert.AreEqual(result, reSerialized);

                ResourceConverterTest(groupDesp);
            }
        }
示例#10
0
        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, "只会有两条记录.在一个资源下同一个人只会有一条记录存在。但是如果存在委托时,则个数就不定");
        }
        public void ReplaceUserResourceTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateProcessDescriptorWithBranchTemplateAndUsers();

            IUser approver1 = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object;

            List <IUser> replaceUsers = new List <IUser>();

            IUser ceo = (IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object;

            replaceUsers.Add((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);
            replaceUsers.Add(ceo);

            int affectedUsers = processDesp.ReplaceAllUserResourceDescriptors(approver1, replaceUsers);

            Console.WriteLine(affectedUsers);

            Assert.AreEqual(2, processDesp.InitialActivity.Resources.Count);
            Assert.IsTrue(ContainsUserResource(processDesp.InitialActivity.Resources, ceo));

            IWfActivityDescriptor normalActivity = processDesp.Activities["NormalActivity"];

            Assert.AreEqual(1, normalActivity.BranchProcessTemplates["Consign"].Resources.Count);
            Assert.IsTrue(ContainsUserResource(normalActivity.BranchProcessTemplates["Consign"].Resources, ceo));

            IUser approver2 = (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object;

            affectedUsers = processDesp.ReplaceAllUserResourceDescriptors(approver2, new IUser[] { });

            Assert.AreEqual(0, normalActivity.BranchProcessTemplates["Distribute"].Resources.Count);
        }
示例#12
0
        public void LockSettingsUnLockTest()
        {
            string lockId = "LockID2";
            IUser  user   = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object;

            MCS.Library.SOA.DataObjects.Lock _lock = GetInstanceOfLock(lockId, user);

            LockAdapter.SetLock(_lock);
            CheckLockResult result = LockAdapter.CheckLock(lockId, user.ID);

            Assert.IsNotNull(result.CurrentLock);

            LockAdapter.Unlock(lockId, user.ID);

            CheckLockResult checkResult = LockAdapter.CheckLock(lockId, user.ID);

            Assert.IsNull(checkResult.CurrentLock);

            IUser user2 = (IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object;

            result.CurrentLock.PersonID = user2.ID;
            LockAdapter.SetLock(result.CurrentLock);

            CheckLockResult reResult = LockAdapter.CheckLock(lockId, user2.ID);

            Assert.IsNotNull(reResult.CurrentLock);

            LockAdapter.Unlock(lockId, user2.ID);
        }
示例#13
0
        public void ActivityOperatorResourceTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams      tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver1);
            IUser requestor          = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            tp.Operator = requestor;

            process.MoveTo(tp);

            WfActivityOperatorResourceDescriptor resource = new WfActivityOperatorResourceDescriptor();

            resource.ActivityKey = process.InitialActivity.Descriptor.Key;
            process.CurrentActivity.Descriptor.Resources.Add(resource);
            OguDataCollection <IUser> users = process.CurrentActivity.Descriptor.Resources.ToUsers();

            Assert.IsTrue(users.Count > 0);
            Assert.AreEqual(requestor.ID, users[0].ID, "验证资源中的人员是否是之前活动的操作人");

            WfRuntime.PersistWorkflows();
            process = WfRuntime.GetProcessByProcessID(process.ID);

            users = process.CurrentActivity.Descriptor.Resources.ToUsers();

            Assert.IsTrue(users.Count > 0, "重新加载后资源中应该有人");
            Assert.AreEqual(requestor.ID, users[0].ID, "重新加载后验证资源中的人员是否是之前活动的操作人");
        }
示例#14
0
        public void ReturnTestWithBranchActivity()
        {
            IWfProcessDescriptor desp = WfProcessTestCommon.CreateProcessDescriptor();

            desp.InitialActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object));

            GetProcDespWithBranchActivities(desp.Activities[1], 2);

            WfProcessStartupParams startupParams = WfProcessTestCommon.GetInstanceOfWfProcessStartupParams(desp);
            IWfProcess             process       = WfRuntime.StartWorkflow(startupParams);

            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver1, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver2, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            Assert.AreEqual(2, process.ElapsedActivities.Count);
            WfRuntime.ProcessContext.ActivityChangingContext.CreatorInstanceID = process.CurrentActivity.ID;
            process.CurrentActivity.CopyMainStreamActivities(process.Activities[1], null, WfControlOperationType.Return); //退件
            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.requestor, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            Assert.IsTrue(process.CurrentActivity.CreatorInstanceID.IsNotEmpty());
            Assert.AreEqual(process.ElapsedActivities[2].ID, process.CurrentActivity.CreatorInstanceID);

            Assert.AreEqual(10, process.Activities.Count);
        }
示例#15
0
        public void MainStreamActivitiesWithConditionActivityPassed()
        {
            IWfProcessDescriptor desp = WfProcessTestCommon.CreateProcessDescriptor();

            desp.InitialActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object));

            IWfActivityDescriptor actDesp = desp.Activities[1];

            AddActivitiesDespToSameActivityDesp(actDesp, 2);
            ToTransitionsDescriptorCollection transDespColl = actDesp.ToTransitions;

            SetTransitionCondition(transDespColl[0], false, 1);
            SetTransitionCondition(transDespColl[1], true, 3);

            WfProcessStartupParams startupParams = WfProcessTestCommon.GetInstanceOfWfProcessStartupParams(desp);

            IWfProcess process = WfRuntime.StartWorkflow(startupParams);

            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver1, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver2, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.requestor, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            Assert.AreEqual(3, process.ElapsedActivities.Count);

            WfMainStreamActivityDescriptorCollection coll = process.Descriptor.GetMainStreamActivities();

            Assert.AreEqual(process.Activities.Count - 1, coll.Count);

            Assert.AreEqual(transDespColl[1].ToActivity.Key, coll[2].Activity.Key, "此处为动态添加的活动");
        }
示例#16
0
        public void BaseAddApproverExecutorStandardModeWithWithdrawTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcess();

            int originalActCount = process.Activities.Count;

            WfProcessTestCommon.MoveToNextDefaultActivity(process);

            int originalElapsedActCount = process.ElapsedActivities.Count;

            IWfActivity           targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity");
            WfAddApproverExecutor executor       = new WfAddApproverExecutor(process.CurrentActivity, targetActivity);

            executor.Assignees.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object);
            executor.Execute();

            Console.WriteLine("Elapsed activities: {0}", process.ElapsedActivities.Count);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            WfWithdrawExecutor withdrawExecutor = new WfWithdrawExecutor(process.CurrentActivity, process.CurrentActivity);

            withdrawExecutor.Execute();

            Console.WriteLine("Elapsed activities: {0}", process.ElapsedActivities.Count);

            Assert.AreEqual(originalElapsedActCount, process.ElapsedActivities.Count);
            Assert.AreEqual(originalActCount, process.Activities.Count, "撤回后,恢复为加签之前的状态");
            Assert.AreEqual(originalActCount, process.MainStream.Activities.Count, "撤回后,主线流程的活动也没有变化");

            WfMainStreamActivityDescriptorCollection processDespMSA = process.Descriptor.GetMainStreamActivities();
            WfMainStreamActivityDescriptorCollection processMSA     = process.GetMainStreamActivities(true);

            processDespMSA.Output("流程描述中的主线活动");
            processMSA.Output("主线流程中的主线活动");
        }
示例#17
0
        public void ComplexDynamicActivityWithTwoAssigneesTest()
        {
            IWfProcessDescriptor processDesp = CreateComplexDynamicActivityProcess(
                (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object,
                (IUser)OguObjectSettings.GetConfig().Objects["cfo"].Object);

            IWfProcess process = processDesp.StartupProcess();

            IWfActivityDescriptor templateActDesp = process.Descriptor.Activities["NormalActivity"];
            IWfActivityDescriptor a1Activity      = process.Descriptor.Activities["A1"];
            IWfActivityDescriptor a2Activity      = process.Descriptor.Activities["A2"];

            IWfActivityDescriptor firstDynamicActDesp1 = ValidateDynamicActivities(a1Activity, templateActDesp);
            IWfActivityDescriptor firstDynamicActDesp2 = ValidateDynamicActivities(a2Activity, templateActDesp);

            Assert.AreEqual(firstDynamicActDesp1.Key, firstDynamicActDesp2.Key);

            IWfActivityDescriptor secondDynamicActDesp = firstDynamicActDesp1.GetToActivities().FirstOrDefault();

            //第二个动态点的出线对应活动
            WfActivityDescriptorCollection secondDynamicActDespOutDesps = secondDynamicActDesp.GetToActivities();

            Assert.AreEqual(2, secondDynamicActDespOutDesps.Count);
            Assert.IsTrue(secondDynamicActDespOutDesps.ContainsKey("B1"));
            Assert.IsTrue(secondDynamicActDespOutDesps.ContainsKey("B2"));

            ValidateLastDynamicTransitions(templateActDesp);
            ValidateTemplateCandidatesAndDynamicActivityCandidates(firstDynamicActDesp1, templateActDesp);
        }
示例#18
0
        public void SingleStepWithdrawByDynamicAddReplay()
        {
            //会签都是针对同样的两个人操作,且串行
            IUser  user           = (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object;
            string procResourceId = GetStartWorkflowResourceID(user);

            WfProcessCollection processes = WfRuntime.GetProcessByResourceID(procResourceId);
            string processID = processes[0].ID;

            MoveToExecutor(processes[0]);
            Assert.AreEqual(1, processes[0].ElapsedActivities.Count);            //initial

            IWfProcess   proc = WfRuntime.GetProcessByProcessID(processID);
            List <IUser> users;

            ConsignExecutorWithCondition(proc, out users);

            proc = WfRuntime.GetProcessByProcessID(processID);
            WfWithdrawExecutor withdrawExec = new WfWithdrawExecutor(proc.CurrentActivity, proc.CurrentActivity);

            withdrawExec.Execute();

            proc = WfRuntime.GetProcessByProcessID(processID);
            Assert.AreEqual(1, proc.ElapsedActivities.Count);
        }
        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);
        }
示例#20
0
        public void ParallelBranchActivitySecretaryTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithBranchTemplate();

            IWfBranchProcessTemplateDescriptor template = processDesp.Activities["NormalActivity"].BranchProcessTemplates["Consign"];

            template.Resources.Clear();
            template.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object));

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);

            IWfProcess consignBranchProcess    = process.Activities.FindActivityByDescriptorKey("NormalActivity").BranchProcessGroups["Consign"].Branches.FirstOrDefault();
            IWfProcess distributeBranchProcess = process.Activities.FindActivityByDescriptorKey("NormalActivity").BranchProcessGroups["Distribute"].Branches.FirstOrDefault();

            Console.WriteLine("Consign Process");
            OutputProcessCandidates(consignBranchProcess);
            ReturnExecutorTestHelper.OutputMainStream(consignBranchProcess);

            Console.WriteLine("");

            Console.WriteLine("Distribute Process");
            OutputProcessCandidates(distributeBranchProcess);
            ReturnExecutorTestHelper.OutputMainStream(distributeBranchProcess);

            Assert.AreEqual(4, consignBranchProcess.Activities.Count);
            Assert.AreEqual(2, distributeBranchProcess.Activities.Count);

            Assert.AreEqual(4, consignBranchProcess.MainStream.Activities.Count);
            Assert.AreEqual(2, distributeBranchProcess.MainStream.Activities.Count);
        }
示例#21
0
        public void SingleStepWithDrawTest()
        {
            IUser  user           = (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object;
            string procResourceId = GetStartWorkflowResourceID(user);

            WfProcessCollection processes;

            for (int i = 0; i < 2; i++)
            {
                processes = WfRuntime.GetProcessByResourceID(procResourceId);
                MoveToExecutor(processes[0]);
            }

            processes = WfRuntime.GetProcessByResourceID(procResourceId);
            IWfProcess process = processes[0];

            Assert.AreEqual(2, process.ElapsedActivities.Count);

            WfWithdrawExecutor exec = new WfWithdrawExecutor(process.CurrentActivity, process.CurrentActivity);

            exec.Execute();

            processes = WfRuntime.GetProcessByResourceID(procResourceId);
            MoveToExecutor(processes[0]);

            processes = WfRuntime.GetProcessByResourceID(procResourceId);
            WfActivityCollection coll = processes[0].ElapsedActivities;

            Assert.AreEqual(coll[coll.Count - 1].Descriptor.ToTransitions[0].ToActivity.Key, processes[0].CurrentActivity.Descriptor.Key);

            //撤回的单步是指业务上的一步,如在上一步动态添加的两个点,则当前就会撤回到动态添加两个点的活动
        }
示例#22
0
        public void ClearThenResetInitialActivitySecretaryTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            processDesp.InitialActivity.Properties.SetValue("AutoAppendSecretary", true);

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            ChangeActivityResource(process.Descriptor.InitialActivity, (IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object);
            WfRuntime.DecorateProcess(process);

            ChangeActivityResource(process.Descriptor.Activities["Initial"], (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);
            WfRuntime.DecorateProcess(process);

            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            Assert.AreEqual(3, processDesp.Activities.Count);
            Assert.AreEqual(process.InitialActivity.Descriptor.Key, process.Descriptor.InitialActivity.Key);
            Assert.AreEqual(WfActivityType.InitialActivity, process.Descriptor.InitialActivity.ActivityType);
            Assert.AreEqual(WfActivityType.InitialActivity, process.Descriptor.Activities["Initial"].ActivityType);

            Assert.AreEqual(3, process.MainStream.Activities.Count);
            Assert.AreEqual(WfActivityType.InitialActivity, process.MainStream.InitialActivity.ActivityType);
        }
示例#23
0
        public void Insert()
        {
            UploadFileHistory history = new UploadFileHistory();

            history.Operator         = null;
            history.OriginalFileName = UuidHelper.NewUuidString() + ".txt";

            history.ApplicationName = "App";
            history.ProgramName     = "Prog";
            history.StatusText      = "一切正常";
            history.Status          = UploadFileHistoryStatus.Success;
            history.Operator        = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            using (Stream stream = PrepareFileStream(history.OriginalFileName, history.OriginalFileName))
            {
                UploadFileHistoryAdapter.Instance.Insert(history, stream);
            }

            using (Stream stream = history.GetMaterialContentStream())
            {
                using (StreamReader sr = new StreamReader(history.GetMaterialContentStream()))
                {
                    string content = sr.ReadToEnd();

                    Assert.AreEqual(history.OriginalFileName, content);
                }
            }
        }
示例#24
0
        public void SimpleProcessPersistTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcessWithAssignee();

            //process.DefaultTaskTitle = "测试保存的流程";

            ProcessTestHelper.OutputExecutionTime(() => WfRuntime.PersistWorkflows(), "保存简单流程");

            try
            {
                IWfProcess loadedProcess = WfRuntime.GetProcessByProcessID(process.ID);

                Assert.AreEqual(process.ID, loadedProcess.ID);
                Assert.AreEqual(process.Status, loadedProcess.Status);
                Assert.AreEqual(DataLoadingType.External, loadedProcess.LoadingType);

                WfTransferParams transferParams = new WfTransferParams(process.Descriptor.CompletedActivity);

                transferParams.Assignees.Add(new WfAssignee((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object));
                transferParams.Assignees.Add(new WfAssignee((IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object));

                loadedProcess.MoveTo(transferParams);
                WfRuntime.PersistWorkflows();

                Assert.AreEqual(process.ID, loadedProcess.ID);
                Assert.AreEqual(WfProcessStatus.Completed, loadedProcess.Status);
                Assert.AreEqual(DataLoadingType.External, loadedProcess.LoadingType);
            }
            finally
            {
                //WfRuntime.DeleteProcessByProcessID(process.ID);
            }
        }
示例#25
0
        public void AddApproverReturnTest()
        {
            IWfProcessDescriptor processDesp = ReturnExecutorTestHelper.PrepareAddApproverReturnProcessDesp();

            IWfProcess process = ReturnExecutorTestHelper.StartSpecialReturnProcess(processDesp);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);

            Assert.AreEqual("B", process.CurrentActivity.Descriptor.Key);

            WfAddApproverExecutor executor = new WfAddApproverExecutor(process.CurrentActivity, process.CurrentActivity);

            executor.Assignees.Add((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object);

            executor.ExecuteNotPersist();

            Assert.AreEqual(6, process.Activities.Count, "加签后变成6个活动");

            WfProcessTestCommon.MoveToNextDefaultActivity(process);     //B的衍生点
            Assert.AreEqual("B", process.CurrentActivity.Descriptor.AssociatedActivityKey);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);     //C的衍生点
            Assert.AreEqual("C", process.CurrentActivity.Descriptor.Key);

            ReturnExecutorTestHelper.ExecuteReturnOperation(process.CurrentActivity, "B");

            Assert.AreEqual(8, process.Activities.Count, "退回后8个活动");
            Assert.AreEqual("B", process.CurrentActivity.Descriptor.AssociatedActivityKey);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);     //C的衍生点
            Assert.AreEqual("C", process.CurrentActivity.Descriptor.AssociatedActivityKey);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);     //D
            Assert.AreEqual("D", process.CurrentActivity.Descriptor.Key);
        }
示例#26
0
        /// <summary>
        /// 获取下一节点的参数实例
        /// </summary>
        /// <param name="nextActivityDesp">下一个节点的流程描述</param>
        /// <param name="oguObject">传入人员的名称</param>
        /// <returns></returns>
        public static WfTransferParams GetInstanceOfWfTransferParams(IWfActivityDescriptor nextActivityDesp, OguObject oguObject)
        {
            WfTransferParams tp   = new WfTransferParams(nextActivityDesp);
            IUser            user = (IUser)OguObjectSettings.GetConfig().Objects[oguObject.ToString()].Object;

            tp.Assignees.Add(user);
            return(tp);
        }
示例#27
0
        public void LoadUserApplicationAuthInfo()
        {
            IUser testUser = (IUser)OguObjectSettings.GetConfig().Objects["admin"].Object;

            WfApplicationAuthCollection authInfo = WfApplicationAuthAdapter.Instance.LoadUserApplicationAuthInfo(testUser);

            Console.WriteLine(authInfo.Count);
        }
示例#28
0
        private static WfProcessDescriptorInfo PrepareProcessDescriptorInfo()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            WfProcessDescriptorInfo processInfo = WfProcessDescriptorInfo.FromProcessDescriptor(processDesp);

            processInfo.Creator  = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;
            processInfo.Modifier = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object;

            return(processInfo);
        }
示例#29
0
        /// <summary>
        /// 创建一个带秘书的活动,且该活动有一根指向首节点的退回线
        /// </summary>
        /// <returns></returns>
        public static IWfProcessDescriptor CreateSimpleProcessDescriptorWithSecretaryAndReturnLine()
        {
            IWfProcessDescriptor processDesp = CreateSimpleProcessDescriptor();

            IWfActivityDescriptor normalActivity = processDesp.Activities["NormalActivity"];

            normalActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object));
            normalActivity.Properties.SetValue("AutoAppendSecretary", true);
            normalActivity.ToTransitions.AddBackwardTransition(processDesp.InitialActivity);

            return(processDesp);
        }
示例#30
0
        /// <summary>
        /// 获取参数实例,即设置即将流转的节点为带分支流程
        /// </summary>
        /// <param name="process"></param>
        /// <param name="sequence"></param>
        /// <param name="blockingType"></param>
        /// <returns></returns>
        public static WfTransferParams GetInstanceOfWfTransferParams(IWfProcess process, WfBranchProcessExecuteSequence sequence, WfBranchProcessBlockingType blockingType)
        {
            WfTransferParams tp = new WfTransferParams(process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity);

            tp.Assignees.Add((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object);

            tp.BranchTransferParams.Add(new WfBranchProcessTransferParams(
                                            CreateConsignTemplate(sequence, blockingType),
                                            new IUser[] { (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object,
                                                          (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object }));

            return(tp);
        }