예제 #1
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, "此处为动态添加的活动");
        }
예제 #2
0
        /// <summary>
        /// 输出主线流程活动
        /// </summary>
        /// <param name="msActivities"></param>
        public static void Output(this WfMainStreamActivityDescriptorCollection msActivities, string name)
        {
            StringBuilder strB = new StringBuilder();

            if (name.IsNotEmpty())
            {
                strB.AppendLine(name);
            }

            foreach (WfMainStreamActivityDescriptor msActDesp in msActivities)
            {
                if (strB.Length > 0)
                {
                    strB.Append("->");
                }

                strB.Append(msActDesp.Activity.Key);

                if (msActDesp.Activity.AssociatedActivityKey.IsNotEmpty())
                {
                    strB.AppendFormat("({0})", msActDesp.Activity.AssociatedActivityKey);
                }
            }

            Console.WriteLine("Main Stream: {0}", strB.ToString());
        }
예제 #3
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"));
        }
예제 #4
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("主线流程中的主线活动");
        }
예제 #5
0
        public void ReturnExecutorTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            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);
            WfReturnExecutor returnExec = new WfReturnExecutor(process.CurrentActivity, process.Activities[1]);

            returnExec.Execute();

            process = WfRuntime.GetProcessByProcessID(process.ID);
            Assert.IsTrue(process.CurrentActivity.CreatorInstanceID != "");
            Assert.AreEqual(process.ElapsedActivities[process.ElapsedActivities.Count - 1].ID, process.CurrentActivity.CreatorInstanceID);

            WfMainStreamActivityDescriptorCollection coll = process.Descriptor.GetMainStreamActivities();

            Assert.AreEqual(6, coll.Count);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban));
        }
예제 #6
0
        public void BasicAddActivityExecutorTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcess();

            int originalActCount = process.Activities.Count;

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

            WfActivityDescriptorCreateParams createParams = new WfActivityDescriptorCreateParams();

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

            executor.Execute();

            Assert.IsNotNull(executor.AddedActivity.GetMainStreamActivityDescriptor());
            Assert.AreEqual(originalActCount + 1, process.Activities.Count);

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

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

            Assert.AreEqual(process.Descriptor.Activities.Count, process.MainStream.Activities.Count);
            Assert.AreEqual(processDespMSA.Count, processMSA.Count);
        }
예제 #7
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("主线流程中的主线活动");
        }
예제 #8
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);
        }
예제 #9
0
        /// <summary>
        /// 发生在PreRender环节,生成流程编辑界面
        /// </summary>
        /// <param name="levels"></param>
        private void RenderActivitiesEditor(WfMainStreamActivityDescriptorCollection msActivities)
        {
            if (CurrentActivity.Process.Status == WfProcessStatus.Running)
            {
                Dictionary <string, Dictionary <string, string> > changeParams = GetActivityKeysCanBeChanged(CurrentActivity.Descriptor);

                if (CurrentActivity.Descriptor.ActivityType == WfActivityType.InitialActivity &&
                    CurrentActivity.OpinionRootActivity == CurrentActivity)
                {
                    if (_Table.Rows.Count > 0)
                    {
                        Control container = _Table.Rows[0].Cells[0];

                        HtmlGenericControl div = new HtmlGenericControl("div");

                        container.Controls.Add(div);

                        IWfActivityDescriptor actDesp = GetCanModifiedActivityDescriptorFromGroup(CurrentActivity.Descriptor);

                        ActivityEditMode editMode = GetActivityDespEditMode(actDesp, msActivities, changeParams);
                        RenderOneActivityEditor(div, CurrentActivity.Descriptor, editMode);

                        div.Attributes["class"] = "command";
                    }
                }

                foreach (IWfMainStreamActivityDescriptor msActivity in msActivities)
                {
                    Control container = null;

                    if (_activityEditorPlaceHolders.TryGetValue(msActivity.Activity.Key, out container))
                    {
                        HtmlGenericControl div = new HtmlGenericControl("div");

                        container.Controls.Add(div);

                        if (ReadOnly == false || WfClientContext.Current.InAdminMode)
                        {
                            IWfActivityDescriptor actDesp = GetCanModifiedActivityDescriptorFromGroup(msActivity.Activity);

                            ActivityEditMode editMode = GetActivityDespEditMode(actDesp, msActivities, changeParams);

                            if (editMode != ActivityEditMode.None)
                            {
                                RenderOneActivityEditor(div, actDesp, editMode);

                                div.Attributes["class"] = "command";
                            }
                        }
                    }
                }
            }
        }
예제 #10
0
        public void AddActivityWithTwoOutTransitionsExecutorTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcess();

            int originalActCount = process.Activities.Count;

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

            targetActivity.Descriptor.ToTransitions.FirstOrDefault().Properties.SetValue("Name", "同意");

            //增加一条出线
            IWfTransitionDescriptor tReturn = targetActivity.Descriptor.ToTransitions.AddBackwardTransition(process.InitialActivity.Descriptor);

            tReturn.Properties.SetValue("Name", "不同意");

            WfActivityDescriptorCreateParams createParams = new WfActivityDescriptorCreateParams();

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

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

            executor.Execute();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            IWfActivity addedActivity = process.Activities[executor.AddedActivity.ID];

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

            Assert.AreEqual(originalActCount + 1, process.Activities.Count);
            Assert.AreEqual(1, targetActivity.Descriptor.ToTransitions.Count);
            Assert.IsFalse(targetActivity.Descriptor.ToTransitions[0].IsBackward);

            Assert.AreEqual(2, addedActivity.Descriptor.ToTransitions.Count, "新加的活动应该也有两条出线");
            Assert.AreEqual("同意", addedActivity.Descriptor.ToTransitions[0].Name);
            Assert.AreEqual("不同意", addedActivity.Descriptor.ToTransitions[1].Name);

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

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

            Assert.AreEqual(process.Descriptor.Activities.Count, process.MainStream.Activities.Count);
            Assert.AreEqual(processDespMSA.Count, processMSA.Count);
        }
예제 #11
0
        public void FindElapsedTransitionTest()
        {
            //流程运行时
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            //新增加活动描述,没有为此添加实例
            string activityKey           = process.Descriptor.FindNotUsedActivityKey();
            WfActivityDescriptor actDesp = new WfActivityDescriptor(activityKey, WfActivityType.NormalActivity);

            process.CurrentActivity.Descriptor.Append(actDesp);

            //使用GetMainStreamActivities方法时,会出错,因为只添加了描述,没添加实例。这里需要正常抛出异常
            WfMainStreamActivityDescriptorCollection coll = process.Descriptor.GetMainStreamActivities();

            Assert.IsNotNull(coll);
        }
예제 #12
0
        public void BasicMainStreamActivities()
        {
            //主流程描述点
            IWfProcessDescriptor desp = WfProcessTestCommon.CreateProcessDescriptor();

            WfMainStreamActivityDescriptorCollection coll = desp.GetMainStreamActivities();

            Assert.AreEqual(desp.Activities.Count, coll.Count);

            //添加动态点
            string activityKey           = desp.FindNotUsedActivityKey();
            WfActivityDescriptor actDesp = new WfActivityDescriptor(activityKey, WfActivityType.NormalActivity);

            desp.InitialActivity.Append(actDesp);

            coll = desp.GetMainStreamActivities();
            Assert.AreEqual(desp.Activities.Count, coll.Count, "流程描述时,添加节点描述也为主线流程中的活动");
        }
예제 #13
0
        /// <summary>
        /// 验证主活动点的Key
        /// </summary>
        /// <param name="activityKeys"></param>
        public static void ValidateMainStreamActivities(IWfProcess process, params string[] expectedActKeys)
        {
            WfMainStreamActivityDescriptorCollection mainStreamActivities = process.GetMainStreamActivities(true);            //process.Descriptor.GetMainStreamActivities();

            List <string> mainStreamKeys = new List <string>();

            foreach (WfMainStreamActivityDescriptor msActDesp in mainStreamActivities)
            {
                string actKey = msActDesp.Activity.Key;

                mainStreamKeys.Add(actKey);
            }

            Assert.AreEqual(expectedActKeys.Length, mainStreamActivities.Count, "主活动点和预期的个数不符");

            for (int i = 0; i < expectedActKeys.Length; i++)
            {
                Assert.AreEqual(expectedActKeys[i], mainStreamKeys[i], string.Format("第{0}个主活动的Key不一致", i));
            }
        }
예제 #14
0
        private string GetOwerActivityID(IWfProcess proc)
        {
            string result = string.Empty;

            //得到父流程的主线活动
            WfMainStreamActivityDescriptorCollection mainActs = GetMainStreamActivitiesByProcess(proc.EntryInfo.OwnerActivity.Process);

            IWfActivityDescriptor ownerActDesp = proc.EntryInfo.OwnerActivity.Descriptor.GetAssociatedActivity();

            string ownerDespKey = ownerActDesp.Key;

            var actDesp = mainActs.Find(act => act.Activity.Key == ownerDespKey || act.Activity.AssociatedActivityKey == ownerDespKey);

            if (actDesp != null)
            {
                result = actDesp.Activity.Instance.ID;
            }

            return(result);
        }
예제 #15
0
        public static void OutputMainStream(IWfProcess process)
        {
            WfMainStreamActivityDescriptorCollection mainStreamActivities = process.GetMainStreamActivities(true);

            StringBuilder strB = new StringBuilder();

            foreach (WfMainStreamActivityDescriptor msActDesp in mainStreamActivities)
            {
                if (strB.Length > 0)
                {
                    strB.Append("->");
                }

                strB.Append(msActDesp.Activity.Key);

                if (msActDesp.Activity.AssociatedActivityKey.IsNotEmpty())
                {
                    strB.AppendFormat("({0})", msActDesp.Activity.AssociatedActivityKey);
                }
            }

            Console.WriteLine("Main Stream: {0}", strB.ToString());
        }
예제 #16
0
        public void BasicDeleteActivityExecutorTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcess();

            int originalActCount = process.Activities.Count;

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

            WfActivityDescriptorCreateParams createParams = new WfActivityDescriptorCreateParams();

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

            addExecutor.Execute();

            IWfActivityDescriptor newActDesp = targetActivity.Descriptor.ToTransitions.FirstOrDefault().ToActivity;

            WfRuntime.ClearCache();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            targetActivity = process.Activities.FindActivityByDescriptorKey(newActDesp.Key);
            WfDeleteActivityExecutor deleteExecutor = new WfDeleteActivityExecutor(process.CurrentActivity, targetActivity);

            deleteExecutor.Execute();

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

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

            Assert.AreEqual(process.Descriptor.Activities.Count, process.MainStream.Activities.Count);
            Assert.AreEqual(processDespMSA.Count, processMSA.Count);

            Assert.IsNull(process.Activities.FindActivityByDescriptorKey(targetActivity.Descriptor.Key));
            Assert.IsNull(process.MainStream.Activities[targetActivity.MainStreamActivityKey]);
        }
예제 #17
0
        public void MainStreamActivitiesWithDynamicActivity()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            string currentActivityID = process.CurrentActivity.ID;
            //新增点
            WfActivityDescriptor actDesp = AddActivity(process);

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

            tp.Assignees.Add(user);

            process.MoveTo(tp);

            ProcessTestHelper.MoveToAndSaveNextActivity(OguObject.approver2, process);

            WfMainStreamActivityDescriptorCollection coll = process.Descriptor.GetMainStreamActivities();

            Assert.AreEqual(6, coll.Count, "动态创建的点不在主流程里头");
            Assert.AreEqual(7, process.Activities.Count, "流程中有7个点,其中一个是动态创建的点");
            Assert.AreEqual(process.Activities[0].Descriptor.ToTransitions[0].ToActivity.Key, actDesp.Key);
            Assert.AreEqual(actDesp.ToTransitions[0].ToActivity.Key, process.CurrentActivity.Descriptor.Key);
        }
예제 #18
0
        public void MainStreamActivitiesWithReturn()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            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);
            int i = process.Activities.Count;

            Assert.AreEqual(6, i);
            Assert.AreEqual(6, process.Descriptor.Activities.Count);
            WfRuntime.ProcessContext.ActivityChangingContext.CreatorInstanceID = process.CurrentActivity.ID;
            process.CurrentActivity.CopyMainStreamActivities(process.Activities[1], null, WfControlOperationType.Return);

            int j = process.Activities.Count;

            Assert.AreEqual(9, j);
            Assert.AreEqual(9, process.Descriptor.Activities.Count);

            //此时还在当前节点,如果流转,也是流转到process.Activities[1]中
            ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.requestor, process);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            Assert.IsTrue(process.CurrentActivity.CreatorInstanceID.IsNotEmpty());
            Assert.AreEqual(process.ElapsedActivities[process.ElapsedActivities.Count - 1].ID, process.CurrentActivity.CreatorInstanceID);

            WfMainStreamActivityDescriptorCollection coll = process.Descriptor.GetMainStreamActivities();

            Assert.AreEqual(6, coll.Count);
        }
예제 #19
0
        public void MainStreamActivitiesWithConsignActivity()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            //会签
            string currentActivityID     = process.CurrentActivity.ID;
            WfActivityDescriptor actDesp = AddActivity(process);

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

            tp.Assignees.Add(user);

            tp.BranchTransferParams.Add(new WfBranchProcessTransferParams(
                                            ProcessTestHelper.CreateConsignTemplate(WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete),
                                            new IUser[] { (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object,
                                                          (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object }));

            process.MoveTo(tp);

            WfMainStreamActivityDescriptorCollection coll = process.Descriptor.GetMainStreamActivities();

            Assert.AreEqual(process.Activities.Count - 1, coll.Count);
        }
		/// <summary>
		/// 发生在PreRender环节,生成流程编辑界面
		/// </summary>
		/// <param name="levels"></param>
		private void RenderActivitiesEditor(WfMainStreamActivityDescriptorCollection msActivities)
		{
			if (CurrentActivity.Process.Status == WfProcessStatus.Running)
			{
				Dictionary<string, Dictionary<string, string>> changeParams = GetActivityKeysCanBeChanged(CurrentActivity.Descriptor);

				if (CurrentActivity.Descriptor.ActivityType == WfActivityType.InitialActivity &&
					CurrentActivity.OpinionRootActivity == CurrentActivity)
				{
					if (_Table.Rows.Count > 0)
					{
						Control container = _Table.Rows[0].Cells[0];

						HtmlGenericControl div = new HtmlGenericControl("div");

						container.Controls.Add(div);

						IWfActivityDescriptor actDesp = GetCanModifiedActivityDescriptorFromGroup(CurrentActivity.Descriptor);

						ActivityEditMode editMode = GetActivityDespEditMode(actDesp, msActivities, changeParams);
						RenderOneActivityEditor(div, CurrentActivity.Descriptor, editMode);

						div.Attributes["class"] = "command";
					}
				}

				foreach (IWfMainStreamActivityDescriptor msActivity in msActivities)
				{
					Control container = null;

					if (_activityEditorPlaceHolders.TryGetValue(msActivity.Activity.Key, out container))
					{
						HtmlGenericControl div = new HtmlGenericControl("div");

						container.Controls.Add(div);

						if (ReadOnly == false || WfClientContext.Current.InAdminMode)
						{
							IWfActivityDescriptor actDesp = GetCanModifiedActivityDescriptorFromGroup(msActivity.Activity);

							ActivityEditMode editMode = GetActivityDespEditMode(actDesp, msActivities, changeParams);

							if (editMode != ActivityEditMode.None)
							{
								RenderOneActivityEditor(div, actDesp, editMode);

								div.Attributes["class"] = "command";
							}
						}
					}
				}
			}
		}
예제 #21
0
        /// <summary>
        /// 填充关联活动
        /// </summary>
        /// <param name="matchedActivities"></param>
        private void FillAsscioatedActivities(WfMainStreamActivityDescriptorCollection matchedActivities)
        {
            foreach (IWfMainStreamActivityDescriptor msActivity in matchedActivities)
            {
                IList<IWfActivityDescriptor> actDesps = this.Descriptor.Activities.FindAll(actDesp => actDesp.AssociatedActivityKey == msActivity.Activity.Key);

                msActivity.AssociatedActivities.CopyFrom(actDesps);
            }
        }
예제 #22
0
        public static WfClientProcess GetClientProcess(IWfProcess process)
        {
            process.NullCheck("process");

            WfClientProcess clientProcess = new WfClientProcess()
            {
                ProcessID     = process.ID,
                ProcessStatus = process.Status.ToString(),
                Activities    = new List <WfClientActivity>(),
                ResourceID    = process.ResourceID
            };

            if (process.Status == WfProcessStatus.Completed)
            {
                clientProcess.ProcessStatusString = "已完成";
            }
            else
            if (process.Status == WfProcessStatus.Aborted)
            {
                clientProcess.ProcessStatusString = "已驳回";
            }

            clientProcess.UISwitches.FillByProcess(process, process.CurrentActivity.ID, DeluxeIdentity.CurrentUser);

            GenericOpinionCollection opinions = GenericOpinionAdapter.Instance.Load(
                builder => builder.AppendItem("RESOURCE_ID", process.ResourceID));

            clientProcess.CurrentOpinion = GetUserActivityOpinion(opinions, process.CurrentActivity, DeluxeIdentity.CurrentUser);

            WfMainStreamActivityDescriptorCollection activityCollection = process.GetMainStreamActivities(false);

            foreach (var item in activityCollection)
            {
                IWfActivity activity = item.Activity.Instance;

                WfClientActivity clientActivity = new WfClientActivity()
                {
                    ActivityID     = item.Activity.Instance.ID,
                    ActivityName   = item.Activity.Name,
                    ActivityStatus = item.Activity.Instance.Status.ToString(),
                    IsActive       = (item.Activity.Instance.Status == WfActivityStatus.Running),
                    Approvers      = (item.Activity.Instance.Candidates.Count > 0 ? item.Activity.Instance.Candidates[0].User.Name : ""),
                    ApproverCount  = item.Activity.Instance.Candidates.Count,
                    ActivityScene  = item.Activity.Scene,
                    StartTime      = item.Activity.Instance.StartTime
                };

                if (item.Activity.Instance.Candidates.Count > 1)
                {
                    clientActivity.Approvers += "...";
                }

                clientActivity.ApproverList = string.Join(",", item.Activity.Instance.Candidates.Select(a => a.User.Name).ToArray());

                if (item.Activity.Instance.Status == WfActivityStatus.Running)
                {
                    clientProcess.CurrentActivity = clientActivity;
                }
                else if (item.Activity.Instance.Status == WfActivityStatus.Completed || item.Activity.Instance.Status == WfActivityStatus.Aborted)
                {
                    var opinion = opinions.Where(o => o.ActivityID == clientActivity.ActivityID).FirstOrDefault();
                    if (opinion != null)
                    {
                        clientActivity.Comment             = opinion.Content;
                        clientActivity.Action              = opinion.OpinionType;
                        clientActivity.Approver            = opinion.IssuePerson.DisplayName;
                        clientActivity.ApprovalTime        = opinion.IssueDatetime;
                        clientActivity.ApprovalElapsedTime = FormatElapsedTime(opinion.IssueDatetime - activity.StartTime);
                    }
                }

                clientProcess.Activities.Add(clientActivity);
            }

            foreach (GenericOpinion go in opinions)
            {
                WfClientActivity parentActivity = clientProcess.Activities.Where(a => a.ActivityID == go.ActivityID).FirstOrDefault();
                if (parentActivity != null)
                {
                    WfClientActivityHistory history = new WfClientActivityHistory()
                    {
                        ID                  = go.ID,
                        ActivityID          = go.ActivityID,
                        ActivityName        = parentActivity.ActivityName,
                        Action              = go.OpinionType,
                        Comment             = go.Content,
                        Approver            = go.IssuePerson.DisplayName,
                        ApprovalType        = parentActivity.ApprovalType,
                        ApprovalTime        = go.IssueDatetime,
                        ApprovalElapsedTime = FormatElapsedTime(go.IssueDatetime - parentActivity.StartTime)
                    };
                    clientProcess.ActivityHistories.Add(history);
                }
            }
            clientProcess.ActivityHistories = clientProcess.ActivityHistories.OrderBy(a => a.ApprovalTime).ToList();

            foreach (string key in process.ApplicationRuntimeParameters.Keys)
            {
                clientProcess.ProcessParameters.Add(key, process.ApplicationRuntimeParameters[key]);
            }

            return(clientProcess);
        }
예제 #23
0
        /// <summary>
        /// 将主线活动转换为实例活动
        /// </summary>
        /// <param name="msActivities"></param>
        /// <returns></returns>
        private WfMainStreamActivityDescriptorCollection ChangeMainStreamActivitiesToInstanceActivities(WfMainStreamActivityDescriptorCollection msActivities)
        {
            WfMainStreamActivityDescriptorCollection result = new WfMainStreamActivityDescriptorCollection();

            foreach (WfMainStreamActivityDescriptor msActivity in msActivities)
            {
                IList<IWfActivity> matchedActivities = this.Activities.FindAll(activity => activity.MainStreamActivityKey == msActivity.Activity.Key);

                IWfActivity matchedActivity = FindMatchedInstanceActivity(matchedActivities);

                if (matchedActivity != null)
                {
                    WfMainStreamActivityDescriptor resultMSActivity = new WfMainStreamActivityDescriptor(matchedActivity.Descriptor);

                    resultMSActivity.Elapsed = matchedActivities.Exists(activity => activity.Status == WfActivityStatus.Completed ||
                        activity.Status == WfActivityStatus.Aborted);

                    result.Add(resultMSActivity);
                }
            }

            return result;
        }
예제 #24
0
        private ActivityEditMode GetActivityDespEditMode(IWfActivityDescriptor actDesp, WfMainStreamActivityDescriptorCollection msActivities, Dictionary <string, Dictionary <string, string> > changeParams)
        {
            ActivityEditMode result = ActivityEditMode.None;

            if (actDesp != null)
            {
                if (actDesp.Properties.GetValue("AllowToBeAppended", true) &&
                    WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowAppendActivityAfterUnstartActivities", true) &&
                    TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanAppendActivityKeys", changeParams) &&
                    IsExceedMaximizeMainStreamActivityCount(msActivities.Count) == false ||
                    WfClientContext.Current.InAdminMode)
                {
                    result |= ActivityEditMode.Add;
                }

                if (ActivityGroupIsRunningOrPassed(actDesp) == false)
                {
                    if (actDesp.Properties.GetValue("AllowToBeModified", true) &&
                        WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowModifyUnstartActivities", true) &&
                        TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanModifyActivityKeys", changeParams) || WfClientContext.Current.InAdminMode)
                    {
                        result |= ActivityEditMode.Edit;
                    }

                    if (actDesp.Properties.GetValue("AllowToBeDeleted", true) &&
                        WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowDeleteUnstartActivities", true) &&
                        TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanDeleteActivityKeys", changeParams) || WfClientContext.Current.InAdminMode)
                    {
                        result |= ActivityEditMode.Delete;
                    }
                }

                RenderOneActivityEventArgs eventArgs = new RenderOneActivityEventArgs();
                eventArgs.CurrentActivity    = CurrentActivity;
                eventArgs.ActivityDescriptor = actDesp;
                eventArgs.EditMode           = result;

                OnRenderOneActivity(CurrentActivity, actDesp, eventArgs);

                result = eventArgs.EditMode;
            }

            return(result);
        }
예제 #25
0
		private void CreateProcessSteps(WfMainStreamActivityDescriptorCollection msActivities)
		{
			this._opinionPlaceHolders.Clear();
			this._activityEditorPlaceHolders.Clear();
			this._OpinionInput.OpinionContainer.Controls.Clear();

			if (CurrentActivity.OpinionRootActivity.Descriptor.ActivityType == WfActivityType.InitialActivity)
			{
				CreateInitialActivityEditorRow(_Table, CurrentActivity.OpinionRootActivity.Descriptor);
			}

			OpinionListControlHelper.PrepareSignImages(this._Opinions);

			int i = 0;

			foreach (IWfMainStreamActivityDescriptor msActivity in msActivities)
			{
				//渲染每个环节的节点,结束点不渲染
				if (msActivity.Activity.ActivityType != WfActivityType.CompletedActivity)
				{
					HtmlTableRow row = new HtmlTableRow();
					row.ID = "OpinionRow" + i++.ToString();

					_Table.Rows.Add(row);

					HtmlTableCell activityCell = CreateActivityCell(row);

					RenderActivity(activityCell, msActivity);
					RenderLevelOpinionsPlaceHolders(CreateOpinionCell(row), msActivity);

					this._activityEditorPlaceHolders.Add(msActivity.Activity.Key, activityCell);
				}
			}

			ViewState["NextStepsSelectorsString"] = PrepareNextStepsSelectorsString();
		}
예제 #26
0
		private WfMainStreamActivityDescriptorCollection GetAllMainStreamActivities()
		{
			WfApplicationRuntimeParametersCollector.CollectApplicationData(this.CurrentProcess);

			//沈峥注释,修改为获取流程实例中的主线活动
			WfMainStreamActivityDescriptorCollection msa = this.CurrentProcess.GetMainStreamActivities(true);

			WfMainStreamActivityDescriptorCollection result = new WfMainStreamActivityDescriptorCollection();

			foreach (IWfMainStreamActivityDescriptor ms in msa)
			{
				if (ms.Activity.Properties.GetValue("ShowingInOpinionList", true))
					result.Add(ms);
			}

			return result;
		}
		private ActivityEditMode GetActivityDespEditMode(IWfActivityDescriptor actDesp, WfMainStreamActivityDescriptorCollection msActivities, Dictionary<string, Dictionary<string, string>> changeParams)
		{
			ActivityEditMode result = ActivityEditMode.None;

			if (actDesp != null)
			{
				if (actDesp.Properties.GetValue("AllowToBeAppended", true) &&
					WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowAppendActivityAfterUnstartActivities", true) &&
					TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanAppendActivityKeys", changeParams) &&
					IsExceedMaximizeMainStreamActivityCount(msActivities.Count) == false
					|| WfClientContext.Current.InAdminMode)
					result |= ActivityEditMode.Add;

				if (ActivityGroupIsRunningOrPassed(actDesp) == false)
				{
					if (actDesp.Properties.GetValue("AllowToBeModified", true) &&
							WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowModifyUnstartActivities", true) &&
							TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanModifyActivityKeys", changeParams) || WfClientContext.Current.InAdminMode)
						result |= ActivityEditMode.Edit;

					if (actDesp.Properties.GetValue("AllowToBeDeleted", true) &&
							WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("AllowDeleteUnstartActivities", true) &&
							TargetActivityCanBeChangedByCurrentActivity(actDesp, "CanDeleteActivityKeys", changeParams) || WfClientContext.Current.InAdminMode)
						result |= ActivityEditMode.Delete;
				}

				RenderOneActivityEventArgs eventArgs = new RenderOneActivityEventArgs();
				eventArgs.CurrentActivity = CurrentActivity;
				eventArgs.ActivityDescriptor = actDesp;
				eventArgs.EditMode = result;

				OnRenderOneActivity(CurrentActivity, actDesp, eventArgs);

				result = eventArgs.EditMode;
			}

			return result;
		}
예제 #28
0
        /// <summary>
        /// 得到流程实例中的主线活动
        /// </summary>
        /// <param name="includeAllElapsedActivities">是否包含所有经过的活动</param>
        /// <returns></returns>
        private WfMainStreamActivityDescriptorCollection GetProcessInstanceMainStreamActivities(bool includeAllElapsedActivities)
        {
            WfMainStreamActivityDescriptorCollection msActivities = new WfMainStreamActivityDescriptorCollection();
            IList<IWfTransitionDescriptor> matchedTransitions = null;

            this.MainStream.ProbeAllActivities(actArgs =>
            {
                matchedTransitions = FindMatchedTransitions(actArgs.ActivityDescriptor, includeAllElapsedActivities);

                WfMainStreamActivityDescriptor msActivity = new WfMainStreamActivityDescriptor(actArgs.ActivityDescriptor);

                msActivity.Level = actArgs.Level;

                //当后面有同样的环节后,用后面的环节覆盖前面已经存在的主线活动
                IWfMainStreamActivityDescriptor existedMSActivity = msActivities[actArgs.ActivityDescriptor.Key];

                if (existedMSActivity != null)
                {
                    if (existedMSActivity.Level < msActivity.Level)
                    {
                        msActivities.Remove(msa => msa.Activity.Key == msActivity.Activity.Key);
                        msActivities.Add(msActivity);
                    }
                }
                else
                    msActivities.Add(msActivity);

                return true;
            },
            transition =>
                matchedTransitions.Exists(t => t == transition)
            );

            //按照遍历的级别深度排序
            msActivities.Sort(new Comparison<IWfMainStreamActivityDescriptor>((msa1, msa2) => msa1.Level - msa2.Level));

            WfMainStreamActivityDescriptorCollection result = ChangeMainStreamActivitiesToInstanceActivities(msActivities);

            FillAsscioatedActivities(result);

            return result;
        }