/// <summary>
        /// 转换成创建流程的参数集合。
        /// </summary>
        /// <returns></returns>
        public WfCreateActivityParamCollection ToCreateActivityParams(PropertyDefineCollection definedProperties)
        {
            definedProperties.NullCheck("definedProperties");

            OguDataCollection <IUser> users = new OguDataCollection <IUser>();

            WfCreateActivityParamCollection tempResult = new WfCreateActivityParamCollection();

            foreach (WfResourceDescriptor resource in this)
            {
                if (resource is IWfCreateActivityParamsGenerator &&
                    ((IWfCreateActivityParamsGenerator)resource).UseCreateActivityParams)
                {
                    ((IWfCreateActivityParamsGenerator)resource).Fill(tempResult, definedProperties);
                }
                else
                {
                    resource.FillUsers(users);
                }
            }

            WfCreateActivityParamCollection result = new WfCreateActivityParamCollection();

            result.CopyFrom(UsersToCreateActivityParams(users, definedProperties));
            result.CopyFrom(tempResult);

            result.Sort((x, y) => x.ActivitySN - y.ActivitySN);

            return(result);
        }
 public void Fill(WfCreateActivityParamCollection capc, PropertyDefineCollection definedCollection)
 {
     if (this._AUSchemaRole != null)
     {
         this.AUSchemaRole.DoCurrentRoleAction(this.ProcessInstance, (role, auCodeName) =>
             role.FillCreateActivityParams(capc, definedCollection)
         );
     }
 }
Exemple #3
0
 public void Fill(WfCreateActivityParamCollection capc, PropertyDefineCollection definedCollection)
 {
     if (this._AUSchemaRole != null)
     {
         this.AUSchemaRole.DoCurrentRoleAction(this.ProcessInstance, (role, auCodeName) =>
                                               role.FillCreateActivityParams(capc, definedCollection)
                                               );
     }
 }
        public void Fill(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        {
            definedProperties.NullCheck("definedProperties");

            if (this._Role != null)
            {
                SOARoleContext.DoAction(this._Role, this.ProcessInstance, (context) =>
                    ((SOARole)(this._Role)).FillCreateActivityParams(capc, definedProperties)
                );
            }
        }
        public void Fill(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        {
            definedProperties.NullCheck("definedProperties");

            if (this._Role != null)
            {
                SOARoleContext.DoAction(this._Role, this.ProcessInstance, (context) =>
                                        ((SOARole)(this._Role)).FillCreateActivityParams(capc, definedProperties)
                                        );
            }
        }
Exemple #6
0
        public void CodeNameActivityDescriptionTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateInitAndCompletedProcessDescriptor();

            WfCreateActivityParamCollection caps = PrepareTwoActivitiesCreateParams();

            caps.CreateActivities(processDesp, false);

            IWfActivityDescriptor matchedActDesp = caps.FindActivityByActivityDescription(processDesp, null, "CodeName(\"TestCodeName\")");

            Assert.AreEqual(processDesp.Activities.Find(actDesp => actDesp.CodeName == "TestCodeName").Key, matchedActDesp.Key);
        }
Exemple #7
0
        public void IntSNActivityDescriptionTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateInitAndCompletedProcessDescriptor();

            WfCreateActivityParamCollection caps = PrepareTwoActivitiesCreateParams();

            caps.CreateActivities(processDesp, false);

            IWfActivityDescriptor matchedActDesp = caps.FindActivityByActivityDescription(processDesp, null, "10");

            Assert.AreEqual(processDesp.InitialActivity.ToTransitions.FirstOrDefault().ToActivity.Key, matchedActDesp.Key);
        }
Exemple #8
0
        public void InvalidActivityDescriptionTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateInitAndCompletedProcessDescriptor();

            WfCreateActivityParamCollection caps = PrepareTwoActivitiesCreateParams();

            caps.CreateActivities(processDesp, false);

            string targetKey = caps[0].CreatedDescriptor.Key;

            caps.FindActivityByActivityDescription(processDesp, null, string.Format("Invalid(\"{0}\")", targetKey));
        }
Exemple #9
0
        public void FirstCapTransitionsTest()
        {
            IWfProcessDescriptor processDesp = ProcessHelper.CreateInitAndCompletedProcessDescriptor();

            WfCreateActivityParamCollection caps = PrepareTwoActivitiesWithTransitionsCreateParams();

            caps.CreateActivities(processDesp, false);

            processDesp.OutputEveryActivities();

            ValidateFirstCapTwoTransitionsProperties(caps[0]);
        }
Exemple #10
0
        public void SecondCapTransitionsTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateInitAndCompletedProcessDescriptor();

            WfCreateActivityParamCollection caps = PrepareTwoActivitiesWithTransitionsCreateParams();

            caps.CreateActivities(processDesp, false);

            processDesp.Output();

            ValidateSecondCapTwoTransitionsProperties(caps[1]);
        }
Exemple #11
0
        public void LastActivityDescriptionTest()
        {
            IWfProcessDescriptor processDesp = ProcessHelper.CreateInitAndCompletedProcessDescriptor();

            WfCreateActivityParamCollection caps = PrepareTwoActivitiesCreateParams();

            caps.CreateActivities(processDesp, false);

            IWfActivityDescriptor matchedActDesp = caps.FindActivityByActivityDescription(processDesp, null, "LastActivity");

            Assert.AreEqual(processDesp.CompletedActivity.Key, matchedActDesp.Key);
        }
Exemple #12
0
        /// <summary>
        /// 准备带线的一个活动的创建参数,一条退回到首节点,一条继续往下(默认选择)
        /// </summary>
        /// <returns></returns>
        private static WfCreateActivityParamCollection PrepareOneActivityWithTransitionsCreateParams()
        {
            WfCreateActivityParamCollection result = new WfCreateActivityParamCollection();

            WfCreateActivityParam cap1 = new WfCreateActivityParam();

            cap1.ActivitySN = 10;
            PrepareFirstCapTwoTransitions(cap1);

            result.Add(cap1);

            return(result);
        }
Exemple #13
0
        public void FillCreateActivityParams(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        {
            SOARoleContext context = SOARoleContext.Current;

            if (context != null && context.QueryParams.Count > 0)
            {
                SOARolePropertyRowCollection matchedRows = this.Rows.Query(context.QueryParams);

                matchedRows = matchedRows.ExtractMatrixRows();

                matchedRows.FillCreateActivityParams(capc, this.PropertyDefinitions, definedProperties);
            }
        }
Exemple #14
0
        public void DefaultNextActivityDescriptionTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateInitAndCompletedProcessDescriptor();

            WfCreateActivityParamCollection caps = PrepareTwoActivitiesCreateParams();

            caps.CreateActivities(processDesp, false);

            IWfActivityDescriptor matchedActDesp = caps.FindActivityByActivityDescription(processDesp, caps[0],
                                                                                          WfCreateActivityParam.DefaultNextActivityDescription);

            Assert.AreEqual(caps[0].DefaultNextDescriptor.Key, matchedActDesp.Key);
        }
Exemple #15
0
        public void DirectKeyActivityDescriptionTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateInitAndCompletedProcessDescriptor();

            WfCreateActivityParamCollection caps = PrepareTwoActivitiesCreateParams();

            caps.CreateActivities(processDesp, false);

            string targetKey = caps[0].CreatedDescriptor.Key;

            IWfActivityDescriptor matchedActDesp = caps.FindActivityByActivityDescription(processDesp, null, string.Format("{0}", targetKey));

            Assert.AreEqual(processDesp.InitialActivity.ToTransitions.FirstOrDefault().ToActivity.Key, matchedActDesp.Key);
        }
        public void Fill(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        {
            SOARoleContext.DoAction(this.PropertyDefinitions, this.ProcessInstance, (context) =>
            {
                SOARolePropertyRowCollection matchedRows = this.Rows.QueryWithoutCondition(context.QueryParams);

                matchedRows = matchedRows.ExtractMatrixRows();

                matchedRows = this.MergeExternalMatrix(matchedRows, context.QueryParams);

                matchedRows = matchedRows.FilterByConditionColumn();

                matchedRows.FillCreateActivityParams(capc, this.PropertyDefinitions, definedProperties);
            });
        }
Exemple #17
0
        public void DynamicOneCapTransitionsTest()
        {
            IWfProcessDescriptor processDesp = PrepareDynamicProcessDesp();

            int originalActivityCount = processDesp.Activities.Count;

            WfCreateActivityParamCollection caps = PrepareOneActivityWithTransitionsCreateParams();

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

            normalActDesp.GenerateDynamicActivities(caps);

            Assert.AreEqual(originalActivityCount + caps.Count, processDesp.Activities.Count);
            ValidateFirstCapTwoTransitionsProperties(caps[0]);
        }
        //活动矩阵定义的属性优先于活动模板定义的属性,矩阵中没有设置的属性,则使用活动模版的属性
        private static void MergeDynamicActivitiesProperties(WfCreateActivityParamCollection createActivityParams, IWfActivityDescriptor templateActDesp)
        {
            foreach (WfCreateActivityParam cap in createActivityParams)
            {
                PropertyValueCollection templateProperties = new PropertyValueCollection();

                foreach (PropertyValue pv in templateActDesp.Properties)
                {
                    if (cap.RoleDefineActivityPropertyNames.Exists(name => pv.Definition.Name == name))
                    {
                        if (cap.Template.Properties.ContainsKey(pv.Definition.Name))
                        {
                            templateProperties.Add(cap.Template.Properties[pv.Definition.Name]);
                        }
                    }
                    else
                    {
                        templateProperties.Add(pv);
                    }
                }

                cap.Template.Properties.ReplaceExistedPropertyValues(templateProperties);

                cap.Template.RelativeLinks.Clear();
                cap.Template.RelativeLinks.CopyFrom(templateActDesp.RelativeLinks);

                cap.Template.Variables.Clear();
                cap.Template.Variables.CopyFrom(templateActDesp.Variables);

                //cap.Template.EnterEventReceivers.Clear();
                cap.Template.EnterEventReceivers.CopyFrom(templateActDesp.EnterEventReceivers);

                //cap.Template.LeaveEventReceivers.Clear();
                cap.Template.LeaveEventReceivers.CopyFrom(templateActDesp.LeaveEventReceivers);

                cap.Template.EnterEventExecuteServices.Clear();
                cap.Template.EnterEventExecuteServices.CopyFrom(templateActDesp.EnterEventExecuteServices);

                cap.Template.LeaveEventExecuteServices.Clear();
                cap.Template.LeaveEventExecuteServices.CopyFrom(templateActDesp.LeaveEventExecuteServices);

                cap.Template.WithdrawExecuteServices.Clear();
                cap.Template.WithdrawExecuteServices.CopyFrom(templateActDesp.WithdrawExecuteServices);

                cap.Template.BeWithdrawnExecuteServices.Clear();
                cap.Template.BeWithdrawnExecuteServices.CopyFrom(templateActDesp.BeWithdrawnExecuteServices);
            }
        }
Exemple #19
0
        //沈峥注释掉,2015/6/21.必须提供列定义
        //public void FillCreateActivityParams(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        //{
        //    SOARolePropertyDefinitionCollection definitions = null;

        //    SOARole role = this._Role as SOARole;

        //    if (role != null)
        //        definitions = role.PropertyDefinitions;
        //    else
        //        definitions = new SOARolePropertyDefinitionCollection();

        //    this.FillCreateActivityParams(capc, definitions, definedProperties);
        //}

        public void FillCreateActivityParams(WfCreateActivityParamCollection capc, SOARolePropertyDefinitionCollection definitions, PropertyDefineCollection definedProperties)
        {
            capc.NullCheck("capc");
            definitions.NullCheck("definitions");

            SOARolePropertyRowUsersCollection rowsUsers = GenerateRowsUsers();

            rowsUsers.ForEach(rowUsers => capc.Add(WfCreateActivityParam.FromRowUsers(rowUsers, definitions, definedProperties)));

            if (definitions.MatrixType == WfMatrixType.ActivityMatrix)
            {
                capc.MergeSameActivityParamBySN();
            }

            capc.ForEach(cap => InitTransitionTemplatesProperties(cap, definitions, cap.Source));
        }
        /// <summary>
        /// 创建动态活动
        /// </summary>
        /// <param name="createActivitiesParamsFetcher"></param>
        /// <returns></returns>
        private IList <IWfActivityDescriptor> InternalGenerateDynamicActivities(Func <WfCreateActivityParamCollection> createActivitiesParamsFetcher)
        {
            createActivitiesParamsFetcher.NullCheck("createActivitiesParamsFetcher");

            List <IWfActivityDescriptor> result = null;

            //随便找一条进线和活动,构造动态活动的起始点。
            IWfTransitionDescriptor firstTemplateTransition = this.FromTransitions.FirstOrDefault();

            if (firstTemplateTransition != null)
            {
                //寻找动态活动的前一个点,如果有多个点,随机选取一个
                WfActivityDescriptor startActDesp = (WfActivityDescriptor)firstTemplateTransition.FromActivity;

                IWfTransitionDescriptor dynInTransition = startActDesp.FindExsitedDynamicToTransition(this);

                ////没有生成过,或者已经生成过,且生成的活动还没有执行
                if (dynInTransition == null || InstanceIsRunning(dynInTransition.ToActivity) == false)
                {
                    //如果已经生成过
                    if (dynInTransition != null)
                    {
                        DeleteExistedDynamicActivities(dynInTransition, this);
                    }

                    WfCreateActivityParamCollection createActivityParams = createActivitiesParamsFetcher();

                    //活动矩阵定义的属性优先于活动模板定义的属性,矩阵中没有设置的属性,则使用活动模版的属性
                    MergeDynamicActivitiesProperties(createActivityParams, this);

                    WfActivityDescriptorCollection createdActivities = CreateActivities(this.FromTransitions, createActivityParams, this.ToTransitions);

                    ChangeNewDynActivitiesProperties(createdActivities, this);

                    result = new List <IWfActivityDescriptor>();

                    createdActivities.CopyTo(result);
                }
            }

            return(result);
        }
        private static WfCreateActivityParamCollection UsersToCreateActivityParams(OguDataCollection <IUser> users, PropertyDefineCollection definedProperties)
        {
            WfCreateActivityParamCollection result = new WfCreateActivityParamCollection();

            int i = 0;

            foreach (IUser user in users)
            {
                WfCreateActivityParam param = new WfCreateActivityParam();

                param.ActivitySN = i++;
                param.Template.Properties.MergeDefinedProperties(definedProperties);
                param.Template.Resources.Add(new WfUserResourceDescriptor(user));
                param.Template.Variables.Add(new WfVariableDescriptor(WfProcessBuilderBase.AutoBuiltActivityVariableName, "True", DataType.Boolean));

                result.Add(param);
            }

            return(result);
        }
Exemple #22
0
        /// <summary>
        /// 准备两个活动的创建参数,没有线参数
        /// </summary>
        /// <returns></returns>
        private static WfCreateActivityParamCollection PrepareTwoActivitiesCreateParams()
        {
            WfCreateActivityParamCollection result = new WfCreateActivityParamCollection();

            WfCreateActivityParam cap1 = new WfCreateActivityParam();

            cap1.ActivitySN = 10;

            result.Add(cap1);

            WfCreateActivityParam cap2 = new WfCreateActivityParam();

            cap2.ActivitySN = 20;

            cap2.Template.CodeName = "TestCodeName";

            result.Add(cap2);

            return(result);
        }
Exemple #23
0
        /// <summary>
        /// 准备带线的两个活动的创建参数
        /// </summary>
        /// <returns></returns>
        private static WfCreateActivityParamCollection PrepareTwoActivitiesWithTransitionsCreateParams()
        {
            WfCreateActivityParamCollection result = new WfCreateActivityParamCollection();

            WfCreateActivityParam cap1 = new WfCreateActivityParam();

            cap1.ActivitySN = 10;
            PrepareFirstCapTwoTransitions(cap1);

            result.Add(cap1);

            WfCreateActivityParam cap2 = new WfCreateActivityParam();

            cap2.ActivitySN = 20;

            cap2.Template.CodeName = "TestCodeName";

            PrepareSecondCapTwoTransitions(cap2);

            result.Add(cap2);

            return(result);
        }
        private WfActivityDescriptorCollection CreateActivities(WfTransitionDescriptorCollection fromTransitions, WfCreateActivityParamCollection capc, WfTransitionDescriptorCollection toTransitions)
        {
            WfActivityDescriptorCollection result = new WfActivityDescriptorCollection(this.Process);

            IWfActivityDescriptor firstDynamicActivity     = null;
            IWfActivityDescriptor lastDynamicActivity      = null;
            WfCreateActivityParam lastCreatedActivityParam = null;

            foreach (WfCreateActivityParam cap in capc)
            {
                WfActivityDescriptor actDesp = (WfActivityDescriptor)cap.Template.Clone();

                actDesp.Process = this.Process;

                string newActKey = "ND" + cap.ActivitySN;

                if (this.Process.Activities.ContainsKey(newActKey))
                {
                    newActKey = this.Process.FindNotUsedActivityKey();
                }

                actDesp.Key           = newActKey;
                cap.CreatedDescriptor = actDesp;

                this.Process.Activities.Add(actDesp);

                if (lastCreatedActivityParam != null)
                {
                    lastCreatedActivityParam.DefaultNextDescriptor = actDesp;
                }

                lastCreatedActivityParam = cap;

                if (this.IsMainStreamActivity == false && this.ProcessInstance != null)
                {
                    WfActivityBase.CreateActivityInstance(actDesp, this.ProcessInstance);
                }

                if (firstDynamicActivity == null)
                {
                    firstDynamicActivity = actDesp;
                }

                if (lastDynamicActivity != null)
                {
                    WfTransitionDescriptor newTransition = (WfTransitionDescriptor)lastDynamicActivity.ToTransitions.AddForwardTransition(actDesp);

                    //如果不是第一个生成的活动
                    if (firstDynamicActivity != actDesp)
                    {
                        newTransition.GeneratedByTemplate = true;
                        newTransition.TemplateKey         = this.Key;
                    }
                }

                lastDynamicActivity = actDesp;

                result.Add(actDesp);
            }

            if (firstDynamicActivity != null && lastDynamicActivity != null)
            {
                SetEntryTransitionsProperties(firstDynamicActivity, fromTransitions);

                if (lastCreatedActivityParam != null)
                {
                    IWfTransitionDescriptor defaultTransition =
                        toTransitions.GetAllConditionMatchedTransitions().FindDefaultSelectTransition(true);

                    if (defaultTransition != null)
                    {
                        lastCreatedActivityParam.DefaultNextDescriptor = defaultTransition.ToActivity;
                    }
                }

                capc.AdjustTransitionsByTemplate(this.Key);

                //如果在活动模板参数的最后一个活动没有配置出线,则使用默认的出线;否则使用配置的出线
                if (lastDynamicActivity.ToTransitions.Count == 0)
                {
                    SetExitTransitionsProperties(lastDynamicActivity, toTransitions);
                }
                else
                {
                    lastDynamicActivity.ToTransitions.ForEach(t => SetDynamicTransitionProperties(null, t, this, false));
                }
            }
            else
            {
                //当没有动态活动生成时,前后的活动直接串联到一起
                JoinOriginalActivitiesAndSetProperties(fromTransitions, toTransitions);
            }

            //将模版点的进出线的Enabled都设置为False
            fromTransitions.ForEach(t => ((WfTransitionDescriptor)t).Enabled = false);
            toTransitions.ForEach(t => ((WfTransitionDescriptor)t).Enabled   = false);

            return(result);
        }
        public void Fill(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        {
            SOARoleContext.DoAction(this.PropertyDefinitions, this.ProcessInstance, (context) =>
            {
                SOARolePropertyRowCollection matchedRows = this.Rows.QueryWithoutCondition(context.QueryParams);

                matchedRows = matchedRows.ExtractMatrixRows();

                matchedRows = this.MergeExternalMatrix(matchedRows, context.QueryParams);

                matchedRows = matchedRows.FilterByConditionColumn();

                matchedRows.FillCreateActivityParams(capc, this.PropertyDefinitions, definedProperties);
            });
        }
        /// <summary>
        /// 准备两个活动的创建参数,没有线参数
        /// </summary>
        /// <returns></returns>
        private static WfCreateActivityParamCollection PrepareTwoActivitiesCreateParams()
        {
            WfCreateActivityParamCollection result = new WfCreateActivityParamCollection();

            WfCreateActivityParam cap1 = new WfCreateActivityParam();

            cap1.ActivitySN = 10;

            result.Add(cap1);

            WfCreateActivityParam cap2 = new WfCreateActivityParam();

            cap2.ActivitySN = 20;

            cap2.Template.CodeName = "TestCodeName";

            result.Add(cap2);

            return result;
        }
 /// <summary>
 /// 根据活动创建参数生成动态活动
 /// </summary>
 /// <param name="createActivitiesParams"></param>
 /// <returns>返回生成的活动,如果活动已经在执行,则返回null。返回null与返回0记录是不同的</returns>
 public IList <IWfActivityDescriptor> GenerateDynamicActivities(WfCreateActivityParamCollection createActivitiesParams)
 {
     return(InternalGenerateDynamicActivities(() => createActivitiesParams));
 }
        /// <summary>
        /// 准备带线的两个活动的创建参数
        /// </summary>
        /// <returns></returns>
        private static WfCreateActivityParamCollection PrepareTwoActivitiesWithTransitionsCreateParams()
        {
            WfCreateActivityParamCollection result = new WfCreateActivityParamCollection();

            WfCreateActivityParam cap1 = new WfCreateActivityParam();

            cap1.ActivitySN = 10;
            PrepareFirstCapTwoTransitions(cap1);

            result.Add(cap1);

            WfCreateActivityParam cap2 = new WfCreateActivityParam();

            cap2.ActivitySN = 20;

            cap2.Template.CodeName = "TestCodeName";

            PrepareSecondCapTwoTransitions(cap2);

            result.Add(cap2);

            return result;
        }
        /// <summary>
        /// 准备带线的一个活动的创建参数,一条退回到首节点,一条继续往下(默认选择)
        /// </summary>
        /// <returns></returns>
        private static WfCreateActivityParamCollection PrepareOneActivityWithTransitionsCreateParams()
        {
            WfCreateActivityParamCollection result = new WfCreateActivityParamCollection();

            WfCreateActivityParam cap1 = new WfCreateActivityParam();

            cap1.ActivitySN = 10;
            PrepareFirstCapTwoTransitions(cap1);

            result.Add(cap1);

            return result;
        }
 /// <summary>
 /// 根据活动创建参数生成动态活动
 /// </summary>
 /// <param name="createActivitiesParams"></param>
 /// <returns>返回生成的活动,如果活动已经在执行,则返回null。返回null与返回0记录是不同的</returns>
 public IList<IWfActivityDescriptor> GenerateDynamicActivities(WfCreateActivityParamCollection createActivitiesParams)
 {
     return InternalGenerateDynamicActivities(() => createActivitiesParams);
 }
        /// <summary>
        /// 根据WfCreateActivityParamCollection的值创建节点,覆盖当前的流程
        /// </summary>
        /// <param name="capc"></param>
        /// <param name="overrideInitActivity"></param>
        public void CreateActivities(WfCreateActivityParamCollection capc, bool overrideInitActivity)
        {
            WfActivityDescriptor currentActDesp = (WfActivityDescriptor)this.InitialActivity;

            capc.CreateActivities(this, overrideInitActivity);
        }
        private WfActivityDescriptorCollection CreateActivities(WfTransitionDescriptorCollection fromTransitions, WfCreateActivityParamCollection capc, WfTransitionDescriptorCollection toTransitions)
        {
            WfActivityDescriptorCollection result = new WfActivityDescriptorCollection(this.Process);

            IWfActivityDescriptor firstDynamicActivity = null;
            IWfActivityDescriptor lastDynamicActivity = null;
            WfCreateActivityParam lastCreatedActivityParam = null;

            foreach (WfCreateActivityParam cap in capc)
            {
                WfActivityDescriptor actDesp = (WfActivityDescriptor)cap.Template.Clone();

                actDesp.Process = this.Process;

                string newActKey = "ND" + cap.ActivitySN;

                if (this.Process.Activities.ContainsKey(newActKey))
                    newActKey = this.Process.FindNotUsedActivityKey();

                actDesp.Key = newActKey;
                cap.CreatedDescriptor = actDesp;

                this.Process.Activities.Add(actDesp);

                if (lastCreatedActivityParam != null)
                    lastCreatedActivityParam.DefaultNextDescriptor = actDesp;

                lastCreatedActivityParam = cap;

                if (this.IsMainStreamActivity == false && this.ProcessInstance != null)
                    WfActivityBase.CreateActivityInstance(actDesp, this.ProcessInstance);

                if (firstDynamicActivity == null)
                    firstDynamicActivity = actDesp;

                if (lastDynamicActivity != null)
                {
                    WfTransitionDescriptor newTransition = (WfTransitionDescriptor)lastDynamicActivity.ToTransitions.AddForwardTransition(actDesp);

                    //如果不是第一个生成的活动
                    if (firstDynamicActivity != actDesp)
                    {
                        newTransition.GeneratedByTemplate = true;
                        newTransition.TemplateKey = this.Key;
                    }
                }

                lastDynamicActivity = actDesp;

                result.Add(actDesp);
            }

            if (firstDynamicActivity != null && lastDynamicActivity != null)
            {
                SetEntryTransitionsProperties(firstDynamicActivity, fromTransitions);

                if (lastCreatedActivityParam != null)
                {
                    IWfTransitionDescriptor defaultTransition =
                        toTransitions.GetAllConditionMatchedTransitions().FindDefaultSelectTransition(true);

                    if (defaultTransition != null)
                        lastCreatedActivityParam.DefaultNextDescriptor = defaultTransition.ToActivity;
                }

                capc.AdjustTransitionsByTemplate(this.Key);

                //如果在活动模板参数的最后一个活动没有配置出线,则使用默认的出线;否则使用配置的出线
                if (lastDynamicActivity.ToTransitions.Count == 0)
                    SetExitTransitionsProperties(lastDynamicActivity, toTransitions);
                else
                    lastDynamicActivity.ToTransitions.ForEach(t => SetDynamicTransitionProperties(null, t, this, false));
            }
            else
            {
                //当没有动态活动生成时,前后的活动直接串联到一起
                JoinOriginalActivitiesAndSetProperties(fromTransitions, toTransitions);
            }

            //将模版点的进出线的Enabled都设置为False
            fromTransitions.ForEach(t => ((WfTransitionDescriptor)t).Enabled = false);
            toTransitions.ForEach(t => ((WfTransitionDescriptor)t).Enabled = false);

            return result;
        }
Exemple #33
0
        public void FillCreateActivityParams(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        {
            SOARoleContext context = SOARoleContext.Current;

            if (context != null && context.QueryParams.Count > 0)
            {
                SOARolePropertyRowCollection matchedRows = this.Rows.Query(context.QueryParams);

                matchedRows = matchedRows.ExtractMatrixRows();

                matchedRows.FillCreateActivityParams(capc, this.PropertyDefinitions, definedProperties);
            }
        }
        //活动矩阵定义的属性优先于活动模板定义的属性,矩阵中没有设置的属性,则使用活动模版的属性
        private static void MergeDynamicActivitiesProperties(WfCreateActivityParamCollection createActivityParams, IWfActivityDescriptor templateActDesp)
        {
            foreach (WfCreateActivityParam cap in createActivityParams)
            {
                PropertyValueCollection templateProperties = new PropertyValueCollection();

                foreach (PropertyValue pv in templateActDesp.Properties)
                {
                    if (cap.RoleDefineActivityPropertyNames.Exists(name => pv.Definition.Name == name))
                    {
                        if (cap.Template.Properties.ContainsKey(pv.Definition.Name))
                            templateProperties.Add(cap.Template.Properties[pv.Definition.Name]);
                    }
                    else
                        templateProperties.Add(pv);
                }

                cap.Template.Properties.ReplaceExistedPropertyValues(templateProperties);

                cap.Template.RelativeLinks.Clear();
                cap.Template.RelativeLinks.CopyFrom(templateActDesp.RelativeLinks);

                cap.Template.Variables.Clear();
                cap.Template.Variables.CopyFrom(templateActDesp.Variables);

                //cap.Template.EnterEventReceivers.Clear();
                cap.Template.EnterEventReceivers.CopyFrom(templateActDesp.EnterEventReceivers);

                //cap.Template.LeaveEventReceivers.Clear();
                cap.Template.LeaveEventReceivers.CopyFrom(templateActDesp.LeaveEventReceivers);

                cap.Template.EnterEventExecuteServices.Clear();
                cap.Template.EnterEventExecuteServices.CopyFrom(templateActDesp.EnterEventExecuteServices);

                cap.Template.LeaveEventExecuteServices.Clear();
                cap.Template.LeaveEventExecuteServices.CopyFrom(templateActDesp.LeaveEventExecuteServices);

                cap.Template.WithdrawExecuteServices.Clear();
                cap.Template.WithdrawExecuteServices.CopyFrom(templateActDesp.WithdrawExecuteServices);

                cap.Template.BeWithdrawnExecuteServices.Clear();
                cap.Template.BeWithdrawnExecuteServices.CopyFrom(templateActDesp.BeWithdrawnExecuteServices);
            }
        }