Example #1
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;
        }
		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;
		}
Example #3
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;
        }