Exemplo n.º 1
0
        public void ProcessSerializeTest()
        {
            IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ProcessDescriptor = processDesc;
            IWfProcess process = WfRuntime.StartWorkflow(startupParams);

            ((WfProcess)process).ResourceID = UuidHelper.NewUuidString();

            WfProcessContext context = process.Context;

            context.Add("UCC", "the same");

            XElementFormatter formatter = new XElementFormatter();

            //formatter.OutputShortType = false;

            XElement root = formatter.Serialize(process);

            Console.WriteLine(root.ToString());

            IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(root);

            Assert.IsNotNull(clonedProcess.Context["UCC"]);
            Assert.AreEqual(process.Context.Count, clonedProcess.Context.Count);
            Assert.AreEqual(process.Context["UCC"], clonedProcess.Context["UCC"]);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void CopyMainStreamActivitiesTest()
        {
            IWfProcessDescriptor processDesp = ReturnExecutorTestHelper.PrepareCopyTestProcessDesp();

            IWfProcess process = ReturnExecutorTestHelper.StartSpecialReturnProcess(processDesp);

            process.Activities.FindActivityByDescriptorKey("B").CopyMainStreamActivities(process.InitialActivity, null, WfControlOperationType.Return);

            Assert.AreEqual(8, process.Activities.Count, "总共有8个活动");
            IWfActivityDescriptor copiedA = process.Activities.FindActivityByDescriptorKey("B").Descriptor.ToTransitions.First().ToActivity;

            Assert.AreEqual("A", copiedA.AssociatedActivityKey);
            Assert.AreEqual(process.InitialActivity.Descriptor.ToTransitions.Count, copiedA.ToTransitions.Count, "复制出来的A和原始的A的出线个数相同");

            IWfActivityDescriptor copiedE = copiedA.ToTransitions.Find(t => t.ToActivity.AssociatedActivityKey == "E").ToActivity;
            IWfActivityDescriptor copiedB = copiedA.ToTransitions.Find(t => t.ToActivity.AssociatedActivityKey == "B").ToActivity;

            Assert.IsTrue(copiedE.ToTransitions.First().ToActivity.Key == "C", "复制出的E指向C");
            Assert.IsTrue(copiedB.ToTransitions.First().ToActivity.Key == "C", "复制出的B指向C");

            IWfActivityDescriptor actDespE = process.Activities.FindActivityByDescriptorKey("E").Descriptor;

            Assert.IsTrue(actDespE.ToTransitions.First().ToActivity.Key == "C", "E指向C");

            IWfActivityDescriptor actDespC = process.Activities.FindActivityByDescriptorKey("C").Descriptor;

            Assert.IsNotNull(actDespC.ToTransitions.First().ToActivity.Key == "D", "C指向D");
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 构造流程的起始点和终止点,并且连线
        /// </summary>
        /// <param name="processKey"></param>
        /// <param name="processName"></param>
        /// <returns></returns>
        public override IWfProcessDescriptor Build(string processKey, string processName)
        {
            IWfProcessDescriptor processDesp = base.Build(processKey, processName);
            WfActivityDescriptor actDesp     = processDesp.InitialActivity as WfActivityDescriptor;

            actDesp.Name = "传阅";
            processDesp.Properties.SetValue("UseMatrix", false);
            processDesp.Properties.SetValue("Independent", false);

            WfForwardTransitionDescriptor transition = (WfForwardTransitionDescriptor)processDesp.InitialActivity.ToTransitions.AddForwardTransition(processDesp.CompletedActivity);

            transition.Name = "已阅";

            //设置一些传阅活动的属性设置
            PropertyDefineCollection definedProperties = GetDefinedProperties();

            processDesp.InitialActivity.Properties.MergeDefinedProperties(definedProperties, true);
            processDesp.InitialActivity.Properties.ForEach(p =>
            {
                if (p.StringValue == null)
                {
                    p.StringValue = p.Definition.DefaultValue;
                }
            });

            return(processDesp);
        }
        public override IWfProcessDescriptor Build(string processKey, string processName)
        {
            processKey.CheckStringIsNullOrEmpty("processKey");
            processName.CheckStringIsNullOrEmpty("processName");

            IWfProcessDescriptor processDesp = base.Build(processKey, processName);

            IWfActivityDescriptor currentActDesp = processDesp.InitialActivity;

            for (int i = 0; i < _StepUsers.Length; i++)
            {
                WfActivityDescriptor actDesp = new WfActivityDescriptor(processDesp.FindNotUsedActivityKey(), WfActivityType.NormalActivity);
                actDesp.ActivityType = WfActivityType.NormalActivity;

                actDesp.Name = _StepUsers[i].DisplayName;
                actDesp.Resources.Add(new WfUserResourceDescriptor(_StepUsers[i]));

                processDesp.Activities.Add(actDesp);

                WfTransitionDescriptor transitionDesp = (WfTransitionDescriptor)currentActDesp.ToTransitions.AddForwardTransition(actDesp);

                transitionDesp.Name = "审核";

                currentActDesp = actDesp;
            }

            currentActDesp.ToTransitions.AddForwardTransition(processDesp.CompletedActivity);

            return(processDesp);
        }
Exemplo n.º 7
0
        public void ExpenseProcessSerializationTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.LoadProcessDescriptorFromFile("Expense.xml");

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            process.ApplicationRuntimeParameters["Amount"] = 500;

            WfRuntime.PersistWorkflows();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            WfProcessTestCommon.MoveToNextDefaultActivityWithExecutor(process);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            IWfActivityDescriptor currentActDesp = process.CurrentActivity.Descriptor;

            ToTransitionsDescriptorCollection transitions = currentActDesp.ToTransitions;

            foreach (string key in transitions.GetAllKeys())
            {
                Assert.IsTrue(key.IsNotEmpty());

                IWfTransitionDescriptor transition = transitions[key];

                Assert.AreEqual(key, transition.Key);
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            IWfProcess currentProcess = this.process;

            //if (currentProcess == null && ProcessContext.Current.OriginalActivity != null) //12-29
            //    currentProcess = ProcessContext.Current.OriginalActivity.Process;          //12-29
            if (currentProcess == null && WfClientContext.Current.OriginalActivity != null)
            {
                currentProcess = WfClientContext.Current.OriginalActivity.Process;
            }

            if (currentProcess != null)
            {
                IWfProcessDescriptor processDesp = currentProcess.CurrentActivity.Descriptor.Process;

                if (string.IsNullOrEmpty(ProcessDespKey) == false)
                {
                    //processDesp = WorkflowSettings.GetConfig().ProcessDescriptorManager.GetProcessDescriptor(ProcessDespKey);
                    processDesp = WfProcessDescriptorManager.GetDescriptor(ProcessDespKey);
                }

                RenderActivities(this, currentProcess, processDesp);
            }

            base.OnPreRender(e);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="processDesp"></param>
        /// <param name="simulationParameters"></param>
        /// <returns></returns>
        public static WfSimulationResult StartSimulation(IWfProcessDescriptor processDesp, WfSimulationParameters simulationParameters)
        {
            bool oldValue = WfRuntime.ProcessContext.EnableSimulation;

            try
            {
                WfRuntime.ProcessContext.EnableSimulation = true;
                InitSimulationContext(simulationParameters);

                WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(
                    PrepareStartWorkflowParams(processDesp, WfRuntime.ProcessContext.SimulationContext));

                IWfProcess process = null;

                executor.AfterModifyWorkflow += (dataContext =>
                {
                    process = dataContext.CurrentProcess;
                });

                executor.Execute();

                return(new WfSimulationResult(process)
                {
                    OutputString = WfRuntime.ProcessContext.SimulationContext.GetOutputString()
                });
            }
            finally
            {
                WfRuntime.ProcessContext.EnableSimulation = oldValue;
            }
        }
Exemplo n.º 11
0
        public WfProcess(IWfProcessDescriptor processDesp)
        {
            this.LoadActions();

            this._MainStream = InitializeMainStream(processDesp);

            this._Descriptor = processDesp;
            this._StartTime = DateTime.Now;
            ((WfProcessDescriptor)processDesp).SetProcessInstance(this);

            processDesp.Activities.ForEach(actDesp =>
            {
                WfActivityBase act = WfActivitySettings.GetConfig().GetActivityBuilder(actDesp).CreateActivity(actDesp);

                act.Process = this;
                act.MainStreamActivityKey = actDesp.Key;

                Activities.Add(act);

                switch (actDesp.ActivityType)
                {
                    case WfActivityType.InitialActivity:
                        this.InitialActivity = act;
                        break;
                    case WfActivityType.CompletedActivity:
                        this.CompletedActivity = act;
                        break;
                }
            });
        }
Exemplo n.º 12
0
        public void SaveAndLoadTenantProcessTest()
        {
            IWfProcessDescriptor processDesp = CreateTestProcessDescriptor();

            string tenantCode = UuidHelper.NewUuidString();

            PrepareTenantContext(tenantCode);

            WfProcessDescriptorManager.SaveDescriptor(processDesp);

            //加载同一个租户的流程定义,如果不存在,会抛出异常
            IWfProcessDescriptor loadedSameTenant = WfProcessDescriptorManager.LoadDescriptor(processDesp.Key);

            Assert.AreEqual(processDesp.Key, loadedSameTenant.Key);

            PrepareTenantContext(UuidHelper.NewUuidString());

            try
            {
                loadedSameTenant = WfProcessDescriptorManager.LoadDescriptor(processDesp.Key);

                throw new ApplicationException("不应该加载到别的租户的流程");
            }
            catch (SystemSupportException)
            {
            }
        }
Exemplo n.º 13
0
        private static void OutputAllTransitions(IWfProcessDescriptor processDesp)
        {
            Dictionary <IWfTransitionDescriptor, IWfTransitionDescriptor> transitions = new Dictionary <IWfTransitionDescriptor, IWfTransitionDescriptor>();

            foreach (IWfActivityDescriptor actDesp in processDesp.Activities)
            {
                actDesp.ToTransitions.ForEach(t =>
                {
                    if (transitions.ContainsKey(t) == false)
                    {
                        transitions.Add(t, t);
                    }
                });
            }

            foreach (IWfActivityDescriptor actDesp in processDesp.Activities)
            {
                actDesp.FromTransitions.ForEach(t =>
                {
                    if (transitions.ContainsKey(t) == false)
                    {
                        transitions.Add(t, t);
                    }
                });
            }

            foreach (KeyValuePair <IWfTransitionDescriptor, IWfTransitionDescriptor> kp in transitions)
            {
                Console.WriteLine(kp.Key.Key);
            }
        }
Exemplo n.º 14
0
        public void SimpleSecretaryWithReturnLineTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithSecretaryAndReturnLine();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

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

            Assert.AreEqual(5, processDesp.Activities.Count);
            Assert.AreEqual(5, process.MainStream.Activities.Count);

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

            IWfActivityDescriptor firstSecretary = normalActivity.Descriptor.FromTransitions.FirstOrDefault().FromActivity;

            Assert.AreEqual(1, firstSecretary.ToTransitions.Count);

            IWfActivityDescriptor secondSecretary = normalActivity.Descriptor.ToTransitions.FirstOrDefault().ToActivity;

            Assert.AreEqual(2, secondSecretary.ToTransitions.Count);

            Assert.AreEqual(2, normalActivity.Descriptor.ToTransitions.Count);

            foreach (IWfTransitionDescriptor transition in normalActivity.Descriptor.ToTransitions)
            {
                Assert.AreEqual(secondSecretary.Key, transition.ToActivity.Key);
            }
        }
Exemplo n.º 15
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);
        }
		private void saveWfProcess(IWfProcessDescriptor wfProcess)
		{
			try
			{
				using (TransactionScope scope = TransactionScopeFactory.Create())
				{
					var pManager = WorkflowSettings.GetConfig().GetDescriptorManager();
					pManager.SaveDescriptor(wfProcess);

					//change import time
                    WfProcessDescriptorInfoAdapter.Instance.UpdateImportTime(wfProcess.Key, DeluxeIdentity.CurrentUser);

					//write log
					UserOperationLog log = new UserOperationLog()
					{
						ResourceID = wfProcess.Key,
						Operator = DeluxeIdentity.CurrentUser,
						OperationDateTime = DateTime.Now,
						Subject = "导入流程模板",
						OperationName = "导入",
						OperationDescription = "导入流程模板"
					};
					UserOperationLogAdapter.Instance.Update(log);

					scope.Complete();
				}
			}
			catch (Exception ex)
			{
				throw ex;
			}

		}
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        public void WfExternalUserTest()
        {
            WfExternalUser externalUser = new WfExternalUser();

            externalUser.Key         = "user0";
            externalUser.Name        = "zLing";
            externalUser.Gender      = Gender.Female;
            externalUser.Email       = "*****@*****.**";
            externalUser.MobilePhone = "13552630000";
            externalUser.Phone       = "0409987";
            externalUser.Title       = "programer";

            IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            processDesc.ExternalUsers.Add(externalUser);

            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ProcessDescriptor = processDesc;
            IWfProcess process = WfRuntime.StartWorkflow(startupParams);

            XElementFormatter formatter = new XElementFormatter();

            XElement   rootProc      = formatter.Serialize(process);
            IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(rootProc);

            XElement resultProc = formatter.Serialize(clonedProcess);

            Assert.AreEqual(processDesc.ExternalUsers[0].Name, clonedProcess.Descriptor.ExternalUsers[0].Name);
            Assert.AreEqual(processDesc.ExternalUsers[0].Gender, clonedProcess.Descriptor.ExternalUsers[0].Gender);

            Assert.AreEqual(rootProc.ToString(), resultProc.ToString());
        }
Exemplo n.º 19
0
        public void ChangeLeaderToApproverThenChangeToLeaderSecretaryTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithSecretary();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

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

            WfRuntime.DecorateProcess(process);

            Console.WriteLine("没有秘书的");
            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            ChangeActivityResource(process.Descriptor.Activities["NormalActivity"], (IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object);

            WfRuntime.DecorateProcess(process);

            Console.WriteLine("有秘书的");
            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            Assert.AreEqual(5, processDesp.Activities.Count);
            Assert.AreEqual(5, process.MainStream.Activities.Count);
        }
Exemplo n.º 20
0
        private static WfProcessStartupParams PrepareStartWorkflowParams(IWfProcessDescriptor processDesp, WfSimulationContext simulationContext)
        {
            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ProcessDescriptor = processDesp;
            startupParams.DefaultTaskTitle  = startupParams.ProcessDescriptor.DefaultTaskTitle;

            if (OguUser.IsNotNullOrEmpty(simulationContext.SimulationParameters.Creator))
            {
                startupParams.Creator = simulationContext.SimulationParameters.Creator;
            }
            else
            {
                if (DeluxePrincipal.IsAuthenticated)
                {
                    startupParams.Creator = DeluxeIdentity.CurrentUser;
                }
            }

            startupParams.Assignees.Add(startupParams.Creator);
            startupParams.ResourceID = UuidHelper.NewUuidString();

            MergeVariablesToApplicationRuntimeParameters(startupParams.ApplicationRuntimeParameters, simulationContext.SimulationParameters.Variables);

            return(startupParams);
        }
Exemplo n.º 21
0
        public void ActivityToTransitionsSort()
        {
            IWfProcessDescriptor desp = WfProcessTestCommon.CreateProcessDescriptor();

            AddActivitiesDespToSameActivityDesp(desp.Activities[1], 4);

            ToTransitionsDescriptorCollection transDespColl = desp.Activities[1].ToTransitions;

            Assert.AreEqual(4, transDespColl.Count);

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

            WfTransitionDescriptorCollection transitions = desp.Activities[1].ToTransitions.GetAllCanTransitTransitions();

            Assert.IsTrue(transitions[0].DefaultSelect);
            Assert.AreEqual(transDespColl[1].DefaultSelect, transitions[0].DefaultSelect);

            Assert.IsTrue(transitions[1].DefaultSelect);
            Assert.AreEqual(transDespColl[3].DefaultSelect, transitions[1].DefaultSelect);

            Assert.IsFalse(transitions[2].DefaultSelect);
            Assert.AreEqual(transDespColl[2].Priority, transitions[2].Priority);

            Assert.IsFalse(transitions[3].DefaultSelect);
            Assert.AreEqual(transDespColl[0].Priority, transitions[3].Priority);
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
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, "此处为动态添加的活动");
        }
        private void RenderActivities(Control container, IWfProcess process, IWfProcessDescriptor processDesp)
        {
            HtmlTable table = new HtmlTable();

            container.Controls.Add(table);

            RednerActivity(table, processDesp.InitialActivity, process, -1);

            for (int i = 0; i < processDesp.Activities.Count; i++)
            {
                IWfActivityDescriptor actDesp = processDesp.Activities[i];

                //if (actDesp is IWfInitialActivityDescriptor == false &&
                //    actDesp is IWfCompletedActivityDescriptor == false)
                //    RednerActivity(table, actDesp, process, i);           //12-29

                if (actDesp.ActivityType == WfActivityType.InitialActivity == false &&
                    actDesp.ActivityType == WfActivityType.CompletedActivity == false)
                {
                    RednerActivity(table, actDesp, process, i);
                }
            }

            RednerActivity(table, processDesp.CompletedActivity, process, -2);
        }
Exemplo n.º 25
0
        public void MainStreamActivitiesWithAmountCondition()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithCondition();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            process.ApplicationRuntimeParameters["Amount"] = 2500;

            WfMainStreamActivityDescriptorCollection mainActs = process.GetMainStreamActivities(true);

            mainActs.Output("不经过领导的主线活动");

            Assert.IsTrue(mainActs.ContainsKey("NormalActivity"));
            Assert.IsFalse(mainActs.ContainsKey("ManagerActivity"));

            //改变条件
            process.ApplicationRuntimeParameters["Amount"] = 10000;

            mainActs = process.GetMainStreamActivities(true);

            mainActs.Output("经过领导的主线活动");

            Assert.IsTrue(mainActs.ContainsKey("NormalActivity"));
            Assert.IsTrue(mainActs.ContainsKey("ManagerActivity"));
        }
Exemplo n.º 26
0
        private static IWfProcess StartNewProcess(IWfProcessDescriptor processDesp, IWfProcess originalProcess, string newResourceID, IUser processCreator, IOrganization department)
        {
            WfProcessStartupParams wp =
                new WfProcessStartupParams(processDesp);

            IWfProcess process = WfRuntime.StartWorkflow(typeof(OAWfProcess), wp);

            process.OwnerDepartment = department;
            WfTransferParams tParams = new WfTransferParams(wp.Descriptor.InitialActivity);

            tParams.Operator = DeluxeIdentity.CurrentUser;

            tParams.Receivers.Add(processCreator);

            process.MoveTo(tParams);

            process.Context["ApplicationName"] = originalProcess.Context["ApplicationName"];
            process.Context["ProgramName"]     = originalProcess.Context["ProgramName"];

            ((OAWfProcess)process).ResourceID = newResourceID;
            process.Context[WfVariableDefine.ProcessDraftDepartmentNameVariableName] =
                WfVariableDefine.GetProcessDraftDepartmentName(originalProcess);

            process.Context[WfVariableDefine.ProcessDraftUserIDVariableName] =
                WfVariableDefine.GetProcessDraftUserID(originalProcess);

            process.Context[WfVariableDefine.ProcessDraftUserNameVariableName] =
                WfVariableDefine.GetProcessDraftUserName(originalProcess);

            return(process);
        }
Exemplo n.º 27
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);
        }
        public void DeleteActivityDescriptorWithComplexTransitionsTest()
        {
            IWfProcessDescriptor processDesp = PrepareComplexProcessForDelete();

            IWfActivityDescriptor normalActDesp   = processDesp.Activities["NormalActivity1"];
            IWfActivityDescriptor normalActivity  = processDesp.Activities["NormalActivity"];
            IWfActivityDescriptor normalActivity2 = processDesp.Activities["NormalActivity2"];

            IWfTransitionDescriptor transitionNN2 = normalActivity.ToTransitions.GetTransitionByToActivity(normalActivity2);

            int originalActCount = processDesp.Activities.Count;

            normalActDesp.Delete();

            processDesp.Output();

            Assert.AreEqual(originalActCount - 1, processDesp.Activities.Count);
            Assert.AreEqual(1, normalActivity.ToTransitions.Count);
            Assert.AreEqual(2, normalActivity2.FromTransitions.Count);
            Assert.AreEqual(2, normalActivity2.ToTransitions.Count);

            IWfTransitionDescriptor newTransitionNN2 = normalActivity.ToTransitions.GetTransitionByToActivity(normalActivity2);

            Assert.AreEqual(transitionNN2.Key, newTransitionNN2.Key, "原有的线保留");
        }
Exemplo n.º 29
0
        public void SimpleCopyMainStreamActivitiesTest()
        {
            IWfProcessDescriptor processDesp = ReturnExecutorTestHelper.PrepareStraightProcessDesp();

            IWfProcess process = ReturnExecutorTestHelper.StartSpecialReturnProcess(processDesp);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);     //To B
            WfProcessTestCommon.MoveToNextDefaultActivity(process);     //To C

            IWfActivity activityB = process.Activities.FindActivityByDescriptorKey("B");

            //从B复制到C
            process.Activities.FindActivityByDescriptorKey("C").CopyMainStreamActivities(activityB, null, WfControlOperationType.Return);

            process.Descriptor.Output();

            WfProcessTestCommon.MoveToNextDefaultActivity(process);     //To CopiedB

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

            IWfActivityDescriptor copiedB = process.CurrentActivity.Descriptor;

            Assert.AreEqual("B", copiedB.AssociatedActivityKey);
            Assert.AreEqual("C", copiedB.ToTransitions.First().ToActivity.AssociatedActivityKey, "复制出的B指向C");
        }
Exemplo n.º 30
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);
        }
Exemplo n.º 31
0
        public void ActivitySerializeTest()
        {
            IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ProcessDescriptor = processDesc;
            IWfProcess process = WfRuntime.StartWorkflow(startupParams);

            Sky sky = new Sky();

            sky.air   = "清新";
            sky.Cloud = 1;
            Sky space = new Sky();

            space.air   = "干净";
            space.Cloud = 1;

            process.InitialActivity.Context.Add("DDO", sky);
            process.InitialActivity.Context.Add("DFO", space);

            XElementFormatter formatter = new XElementFormatter();
            XElement          root      = formatter.Serialize(process);

            Console.WriteLine(root.ToString());

            IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(root);

            Assert.IsNotNull(clonedProcess.InitialActivity.Context["DDO"]);
            Assert.AreEqual(process.InitialActivity.Context.Count, clonedProcess.InitialActivity.Context.Count);
            Assert.AreEqual(((Sky)process.InitialActivity.Context["DDO"]).air, ((Sky)clonedProcess.InitialActivity.Context["DDO"]).air);
            Assert.AreEqual(((Sky)process.InitialActivity.Context["DDO"]).Cloud, ((Sky)clonedProcess.InitialActivity.Context["DDO"]).Cloud);
            Assert.AreEqual(((Sky)process.InitialActivity.Context["DFO"]).air, ((Sky)clonedProcess.InitialActivity.Context["DFO"]).air);
            Assert.AreEqual(((Sky)process.InitialActivity.Context["DFO"]).Cloud, ((Sky)clonedProcess.InitialActivity.Context["DFO"]).Cloud);
        }
Exemplo n.º 32
0
        public void WfExternalUserTest()
        {
            WfConverterHelper.RegisterConverters();

            WfExternalUser externalUser = new WfExternalUser();

            externalUser.Key         = "user0";
            externalUser.Name        = "zLing";
            externalUser.Gender      = Gender.Female;
            externalUser.Email       = "*****@*****.**";
            externalUser.MobilePhone = "13552630000";
            externalUser.Phone       = "0409987";
            externalUser.Title       = "programer";

            string         result           = JSONSerializerExecute.Serialize(externalUser);
            WfExternalUser deserializedUser = JSONSerializerExecute.Deserialize <WfExternalUser>(result);
            string         reSerialized     = JSONSerializerExecute.Serialize(deserializedUser);

            Assert.AreEqual(result, reSerialized);


            //创建流程描述
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            processDesp.ExternalUsers.Add(externalUser);                 //作用于流程
            processDesp.InitialActivity.ExternalUsers.Add(externalUser); //作用于节点

            string procDesp = JSONSerializerExecute.Serialize(processDesp);
            WfProcessDescriptor reProcessDesp = JSONSerializerExecute.Deserialize <WfProcessDescriptor>(procDesp);
            string reuslt = JSONSerializerExecute.Serialize(reProcessDesp);

            Assert.AreEqual(procDesp, reuslt);
            Assert.AreEqual(processDesp.ExternalUsers[0].Name, processDesp.InitialActivity.ExternalUsers[0].Name);
        }
        private UserOperationLog CreateImportLog(IWfProcessDescriptor processDesp)
        {
            UserOperationLog log = new UserOperationLog();

            log.ResourceID = processDesp.Key;
            log.Subject = string.Format("{0}:{1}", this.OperationType.ToDescription(), processDesp.Key);

            return log;
        }
Exemplo n.º 34
0
		public DeleteObjectHelper(IWfProcess process, IWfProcessDescriptor processDesp, bool syncMSObject)
		{
			process.NullCheck("process");
			processDesp.NullCheck("processDesp");

			this._Process = process;
			this._ProcessDescriptor = processDesp;
			this._SyncMainStream = syncMSObject;
		}
		public EditProcessPropertiesHelper(IWfProcess process, IWfProcessDescriptor processDesp, PropertyValueCollection properties, bool syncMSObject)
		{
			process.NullCheck("process");
			processDesp.NullCheck("processDesp");
			properties.NullCheck("properties");

			this._Process = process;
			this._ProcessDescriptor = processDesp;
			this._Properties = properties;
			this._SyncMainStream = syncMSObject;
		}
		public WfAdminDeleteTransitionExecutor(IWfActivity operatorActivity, IWfProcessDescriptor processDescriptor, IWfTransitionDescriptor targetTransitionDescriptor, bool syncMSObject) :
			base(operatorActivity, WfControlOperationType.AdminDeleteTransition)
		{
			processDescriptor.NullCheck("processDescriptor");
			targetTransitionDescriptor.NullCheck("targetTransitionDescriptor");

			this._TargetTransitionDescriptor = targetTransitionDescriptor;
			this._ProcessDescriptor = processDescriptor;

			this._SyncMainStreamObject = syncMSObject;
		}
        public WfSaveTemplateExecutor(IWfProcessDescriptor processDesp)
            : base(WfDesignerOperationType.CreateTemplate)
        {
            processDesp.NullCheck("processDesp");

            if (WfProcessDescriptorManager.ExsitsProcessKey(processDesp.Key))
                this.OperationType = WfDesignerOperationType.ModifyTemplate;
            else
                this.OperationType = WfDesignerOperationType.CreateTemplate;

            this.ProcessDescriptor = processDesp;
        }
        public void SaveDescriptor(IWfProcessDescriptor processDesp)
        {
            processDesp.NullCheck("processDesp");

            XElementFormatter formatter = WfProcessDescriptorManager.CreateFormatter();

            XElement xml = formatter.Serialize(processDesp);

            SaveXml(processDesp, xml);

            SendCacheNotifyByProcessKey(processDesp.Key);
        }
        /// <summary>
        /// 保存Xml到数据库
        /// </summary>
        /// <param name="processDesp"></param>
        /// <param name="xml"></param>
        protected override void SaveXml(IWfProcessDescriptor processDesp, XElement xml)
        {
            WfProcessDescriptorInfo info = WfProcessDescriptorInfo.FromProcessDescriptor(processDesp, xml);

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                WfProcessDescriptorInfoAdapter.Instance.Update(info);

                WfProcessDescriptorDimensionAdapter.Instance.Update(WfProcessDescriptorDimension.FromProcessDescriptor(processDesp));

                scope.Complete();
            }
        }
Exemplo n.º 40
0
		/// <summary>
		/// 保存流程模板
		/// </summary>
		/// <param name="wfProcess"></param>
		public static void SaveWfProcess(IWfProcessDescriptor wfProcess)
		{
			var pManager = WorkflowSettings.GetConfig().GetDescriptorManager();
			pManager.SaveDescriptor(wfProcess);

			//change import time
            WfProcessDescriptorInfoAdapter.Instance.UpdateImportTime(wfProcess.Key, DeluxeIdentity.CurrentUser);

			//write log
			UserOperationLog log = new UserOperationLog()
			{
				ResourceID = wfProcess.Key,
				Operator = DeluxeIdentity.CurrentUser,
				OperationDateTime = DateTime.Now,
				Subject = "导入流程模板",
				OperationName = "导入",
				OperationDescription = "导入流程模板"
			};
			UserOperationLogAdapter.Instance.Update(log);
		}
Exemplo n.º 41
0
        public static WfProcessStartupParams GetInstanceOfWfProcessStartupParams(IWfProcessDescriptor processDesp)
        {
            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            IUser requestor = (IUser)Consts.Users["Requestor"].ToOguObject();

            startupParams.Creator = requestor;
            startupParams.Department = requestor.TopOU;
            startupParams.DefaultUrl = "http://www.sina.com.cn";
            startupParams.Assignees.Add(new WfAssignee(requestor));
            startupParams.ResourceID = UuidHelper.NewUuidString();
            startupParams.DefaultTaskTitle = "测试保存的流程";
            startupParams.ProcessDescriptor = processDesp;
            startupParams.AutoCommit = true;

            startupParams.ApplicationRuntimeParameters["Amount"] = 1000;
            startupParams.ApplicationRuntimeParameters["CostCenter"] = "1001";

            return startupParams;
        }
        private void RenderActivities(Control container, IWfProcess process, IWfProcessDescriptor processDesp)
        {
            HtmlTable table = new HtmlTable();

            container.Controls.Add(table);

            RednerActivity(table, processDesp.InitialActivity, process, -1);

            for (int i = 0; i < processDesp.Activities.Count; i++)
            {
                IWfActivityDescriptor actDesp = processDesp.Activities[i];

                //if (actDesp is IWfInitialActivityDescriptor == false &&
                //    actDesp is IWfCompletedActivityDescriptor == false)
                //    RednerActivity(table, actDesp, process, i);           //12-29

                if (actDesp.ActivityType == WfActivityType.InitialActivity == false &&
                    actDesp.ActivityType == WfActivityType.CompletedActivity == false)
                    RednerActivity(table, actDesp, process, i);          
            }

            RednerActivity(table, processDesp.CompletedActivity, process, -2);
        }
Exemplo n.º 43
0
        private static void FillProcessDescriptorProperties(WfProcessStartupParams startupParams, IWfProcessDescriptor processDesp)
        {
            if (startupParams.DefaultTaskTitle.IsNotEmpty())
                processDesp.DefaultTaskTitle = startupParams.DefaultTaskTitle;

            if (startupParams.DefaultUrl.IsNotEmpty())
                processDesp.Url = startupParams.DefaultUrl;

            if (startupParams.RuntimeProcessName.IsNotEmpty() && processDesp.Properties.ContainsKey("RuntimeProcessName"))
                processDesp.Properties.SetValue("RuntimeProcessName", startupParams.RuntimeProcessName);
        }
Exemplo n.º 44
0
        private IWfProcessDescriptor InitializeMainStream(IWfProcessDescriptor processDesp)
        {
            WfProcessDescriptor clonedProcessDesp = (WfProcessDescriptor)processDesp.Clone();
            clonedProcessDesp.SetProcessInstance(this);
            clonedProcessDesp.Variables.SetValue("MainStream", "True", DataType.Boolean);

            return clonedProcessDesp;
        }
Exemplo n.º 45
0
        private static IWfProcess StartProcess(IWfProcessDescriptor processDesp)
        {
            WfProcessStartupParams startupParams = GetInstanceOfWfProcessStartupParams(processDesp);

            return WfRuntime.StartWorkflow(startupParams);
        }
Exemplo n.º 46
0
        private static WfProcessStartupParams GetInstanceOfWfProcessStartupParams(IWfProcessDescriptor processDesp)
        {
            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            IUser requestor =
                OguMechanismFactory.GetMechanism().GetObjects<IUser>(SearchOUIDType.LogOnName, "liumh").First();

            startupParams.Creator = requestor;
            startupParams.Department = requestor.TopOU;
            startupParams.Assignees.Add(new WfAssignee(requestor));
            startupParams.ResourceID = UuidHelper.NewUuidString();
            startupParams.DefaultTaskTitle = "测试报销流程";
            startupParams.ProcessDescriptor = processDesp;
            startupParams.AutoCommit = true;

            return startupParams;
        }
Exemplo n.º 47
0
        public static IWfProcess StartupProcess(IWfProcessDescriptor processDesp, Dictionary<string, object> runtimeParameters)
        {
            ProcessContextAction();

            WfProcessStartupParams startupParams = new WfProcessStartupParams();
            startupParams.ResourceID = UuidHelper.NewUuidString();
            startupParams.ProcessDescriptor = processDesp;

            runtimeParameters.ForEach(kp => startupParams.ApplicationRuntimeParameters.Add(kp.Key, kp.Value));

            return WfRuntime.StartWorkflow(startupParams);
        }
Exemplo n.º 48
0
        protected IWfProcess CreateBranchProcess(IWfProcessDescriptor descriptor)
        {
            WfProcessStartupParams branchProcessStartupParam = new WfProcessStartupParams(descriptor);

            return WfRuntime.StartWorkflow(this.AnchorActivity.Process.GetType(), branchProcessStartupParam);
        }
 public static void SaveDescriptor(IWfProcessDescriptor processDesp)
 {
     WorkflowSettings.GetConfig().GetDescriptorManager().SaveDescriptor(processDesp);
 }
 /// <summary>
 /// 将Xml保存到文件
 /// </summary>
 /// <param name="processKey"></param>
 /// <param name="xml"></param>
 protected override void SaveXml(IWfProcessDescriptor processDesp, XElement xml)
 {
     xml.Save(GetPath(processDesp.Key));
 }
Exemplo n.º 51
0
		public static List<IWfProcess> StartupMultiProcesses(IWfProcessDescriptor processDesp, int totalProcesses)
		{
			List<IWfProcess> processes = new List<IWfProcess>();

			//准备流程实例
			for (int i = 0; i < totalProcesses; i++)
			{
				WfProcessStartupParams startupParams = new WfProcessStartupParams();
				startupParams.ProcessDescriptor = processDesp;
				IWfProcess process = WfRuntime.StartWorkflow(startupParams);

				processes.Add(process);
			}

			return processes;
		}
 /// <summary>
 /// 根据Key保存Xml
 /// </summary>
 /// <param name="processDesp">流程描述</param>
 /// <param name="xml"></param>
 protected abstract void SaveXml(IWfProcessDescriptor processDesp, XElement xml);
        public static IWfProcess StartSpecialReturnProcess(IWfProcessDescriptor processDesp)
        {
            WfProcessStartupParams startupParams = new WfProcessStartupParams();
            startupParams.ProcessDescriptor = processDesp;
            startupParams.ApplicationRuntimeParameters["IsCLine"] = true;

            return WfRuntime.StartWorkflow(startupParams);
        }
Exemplo n.º 54
0
        public static WfProcessStartupParams GetInstanceOfWfProcessStartupParams(IWfProcessDescriptor procDesp)
        {
            WfProcessStartupParams startupParams = new WfProcessStartupParams();

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

            startupParams.Creator = requestor;
            startupParams.Department = requestor.TopOU;
            startupParams.Assignees.Add(new WfAssignee(requestor));
            startupParams.ResourceID = UuidHelper.NewUuidString();
            startupParams.DefaultTaskTitle = "测试保存的流程";
            startupParams.ProcessDescriptor = procDesp;
            startupParams.AutoCommit = true;

            return startupParams;
        }
Exemplo n.º 55
0
 public static IWfProcess StartupProcess(IWfProcessDescriptor processDesp)
 {
     return StartupProcess(processDesp, new Dictionary<string, object>());
 }
		private static void OutputAllTransitions(IWfProcessDescriptor processDesp)
		{
			Dictionary<IWfTransitionDescriptor, IWfTransitionDescriptor> transitions = new Dictionary<IWfTransitionDescriptor, IWfTransitionDescriptor>();

			foreach (IWfActivityDescriptor actDesp in processDesp.Activities)
			{
				actDesp.ToTransitions.ForEach(t =>
				{
					if (transitions.ContainsKey(t) == false)
						transitions.Add(t, t);
				});
			}

			foreach (IWfActivityDescriptor actDesp in processDesp.Activities)
			{
				actDesp.FromTransitions.ForEach(t =>
				{
					if (transitions.ContainsKey(t) == false)
						transitions.Add(t, t);
				});
			}

			foreach (KeyValuePair<IWfTransitionDescriptor, IWfTransitionDescriptor> kp in transitions)
			{
				Console.WriteLine(kp.Key.Key);
			}
		}