예제 #1
0
        protected override void OnModifyWorkflow(WfExecutorDataContext dataContext)
        {
            this.TargetActivity.Process.Committed = true;

            WfBranchProcessTransferParams bptp = new WfBranchProcessTransferParams(
                WfTemplateBuilder.CreateDefaultCirculationTemplate("Circulate", this.Circulators));

            WfRuntime.ProcessContext.AfterStartupBranchProcess += new WfAfterStartupBranchProcessHandler(WfActivityRelativeExecutorBase.AfterStartupBranchProcess);

            this.TargetActivity.StartupBranchProcesses(bptp);
        }
예제 #2
0
        protected override void OnModifyWorkflow(WfExecutorDataContext dataContext)
        {
            this.TargetActivity.Process.Committed = true;

            IWfProcess process = TargetActivity.Process;

            WfRuntime.ProcessContext.BeginChangeActivityChangingContext();
            try
            {
                WfRuntime.ProcessContext.ActivityChangingContext.CreatorInstanceID     = TargetActivity.ID;
                WfRuntime.ProcessContext.ActivityChangingContext.AssociatedActivityKey =
                    TargetActivity.Descriptor.AssociatedActivityKey.IsNotEmpty() ?
                    TargetActivity.Descriptor.AssociatedActivityKey : TargetActivity.Descriptor.Key;

                //string activityKey = process.Descriptor.FindNotUsedActivityKey();

                //WfActivityDescriptor actDesp = new WfActivityDescriptor(activityKey);

                //actDesp.Name = "会签";
                var toReturnTrans = process.CurrentActivity.Descriptor.ToTransitions.FindAll(t => t.IsBackward == true);

                WfActivityDescriptor actDesp = process.CurrentActivity.Descriptor.Clone() as WfActivityDescriptor;
                actDesp.ActivityType = WfActivityType.NormalActivity;
                actDesp.Properties.SetValue("AutoMoveAfterPending", false);
                actDesp.ClonedKey = process.CurrentActivity.Descriptor.Key;
                actDesp.BranchProcessTemplates.Clear();
                process.CurrentActivity.Append(actDesp);

                foreach (WfTransitionDescriptor t in toReturnTrans)
                {
                    WfTransitionDescriptor trans = t.Clone() as WfTransitionDescriptor;
                    if (t.FromActivityKey == t.ToActivityKey)
                    {
                        trans.JoinActivity(actDesp, actDesp);
                    }
                    else
                    {
                        trans.JoinActivity(actDesp, t.ToActivity);
                    }

                    actDesp.ToTransitions.Add(trans);
                }

                //添加子流程
                WfTransferParams tp = new WfTransferParams(actDesp);
                tp.Assignees.CopyFrom(Assignees);

                tp.BranchTransferParams.Add(new WfBranchProcessTransferParams(
                                                WfTemplateBuilder.CreateDefaultConsignTemplate(
                                                    "WfConsignProcessTemplateDescriptorKey",
                                                    this.Sequence,
                                                    this.BlockingType,
                                                    this.ConsignUsers)));

                if (this.CirculateUsers.Count <IUser>() > 0)
                {
                    tp.BranchTransferParams.Add(new WfBranchProcessTransferParams(
                                                    WfTemplateBuilder.CreateDefaultCirculationTemplate(
                                                        "WfCirculationProcessTemplateDescriptorKey",
                                                        this.CirculateUsers)));
                }

                WfRuntime.ProcessContext.AfterStartupBranchProcess += new WfAfterStartupBranchProcessHandler(WfActivityRelativeExecutorBase.AfterStartupBranchProcess);
                process.MoveTo(tp);
            }
            finally
            {
                WfRuntime.ProcessContext.RestoreChangeActivityChangingContext();
            }
        }