示例#1
0
        /// <summary>
        /// 处理进入下一个活动的操作
        /// </summary>
        /// <param name="nextActivity"></param>
        internal static void EnterActivity(SysTaskActivity nextActivity, DateTime now)
        {
            nextActivity.StartTime = now;

            if (nextActivity.CanMoveTo())
            {
                nextActivity.Status = SysTaskActivityStatus.Running;
            }
            else
            {
                nextActivity.Status = SysTaskActivityStatus.Pending;
            }

            foreach (SysTaskProcess branch in nextActivity.Branches)
            {
                if (branch.Activities.Count == 0)
                {
                    branch.Status = SysTaskProcessStatus.Completed;
                }
                else
                if (branch.Activities.Count > 0)
                {
                    ExecuteSysTaskActivityTask.SendTask(branch.Activities[0]);
                }
            }

            SysTaskProcessRuntime.ProcessContext.AffectedActivities.AddOrReplace(nextActivity);
        }
        /// <summary>
        /// 发送执行任务流程活动的任务
        /// </summary>
        /// <param name="sysTaskActivity"></param>
        /// <returns></returns>
        public static ExecuteSysTaskActivityTask SendTask(SysTaskActivity sysTaskActivity)
        {
            ExecuteSysTaskActivityTask task = ExecuteSysTaskActivityTask.CreateTask(sysTaskActivity);

            SysTaskAdapter.Instance.Update(task);

            return(task);
        }
示例#3
0
        internal void NormalizeActivities()
        {
            if (this._Activities != null)
            {
                for (int i = 0; i < this._Activities.Count; i++)
                {
                    SysTaskActivity activity = this._Activities[i];

                    activity.ProcessID = this.ID;
                    activity.Sequence  = i;
                }
            }
        }
        /// <summary>
        /// 如果能够流转,自动流转到下一个活动
        /// </summary>
        /// <param name="activity"></param>
        private static void AutoMoveToNextActivity(SysTaskActivity activity)
        {
            if (activity.CanMoveTo())
            {
                SysTaskActivity nextActivity = activity.Process.MoveToNextActivity();

                SysTaskProcessRuntime.Persist();

                if (activity.Process.Status == SysTaskProcessStatus.Running)
                {
                    ExecuteSysTaskActivityTask.SendTask(nextActivity);
                }
            }
            else
            {
                //对于第一个活动就带子流程的场景,其状态是NotRunning且有可能被阻塞不能流转,需要通过此操作启动子流程的Task
                if (activity.Status == SysTaskActivityStatus.NotRunning)
                {
                    SysTaskProcess.EnterActivity(activity, SNTPClient.AdjustedTime);
                }
            }
        }
        public static ExecuteSysTaskActivityTask CreateTask(SysTaskActivity sysTaskActivity)
        {
            sysTaskActivity.NullCheck("sysTaskActivity");

            ExecuteSysTaskActivityTask task = new ExecuteSysTaskActivityTask(sysTaskActivity.ID);

            task.TaskID     = UuidHelper.NewUuidString();
            task.ResourceID = sysTaskActivity.ID;

            if (sysTaskActivity.Task != null && sysTaskActivity.Task.TaskTitle.IsNotEmpty())
            {
                task.TaskTitle = string.Format("执行任务流程活动,任务ID为{0},名称为{1}",
                                               sysTaskActivity.Task.TaskID,
                                               sysTaskActivity.Task.TaskTitle);
            }
            else
            {
                task.TaskTitle = string.Format("执行任务流程活动{0}", sysTaskActivity.ID);
            }

            return(task);
        }