Beispiel #1
0
        public void AddOrReplace(SysTaskProcess process)
        {
            process.NullCheck("process");

            if (this.ContainsKey(process.ID) == false)
            {
                this.Add(process);
            }
        }
        /// <summary>
        /// 构造一个任务活动
        /// </summary>
        /// <param name="sysTaskProcess"></param>
        /// <param name="index"></param>
        /// <param name="name"></param>
        /// <param name="task"></param>
        /// <returns></returns>
        public static SysTaskActivity CreateActivity(this SysTaskProcess sysTaskProcess, int index, string name, SysTask task)
        {
            sysTaskProcess.NullCheck("sysTaskProcess");

            SysTaskActivity activity = new SysTaskActivity(task);

            activity.ID        = UuidHelper.NewUuidString();
            activity.ProcessID = sysTaskProcess.ID;
            activity.Sequence  = index;
            activity.Name      = name;

            SysTaskProcessRuntime.ProcessContext.AffectedActivities.AddOrReplace(activity);

            return(activity);
        }
		/// <summary>
		/// 启动流程,持久化,然后发送执行活动的任务
		/// </summary>
		/// <param name="process"></param>
		public static void StartProcess(SysTaskProcess process)
		{
			process.NullCheck("process");

			process.Status = SysTaskProcessStatus.Running;

            ProcessContext.AffectedProcesses.AddOrReplace(process);

            if (process.Activities.Count == 0)
                process.Status = SysTaskProcessStatus.Completed;

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                Persist();

                if (process.Activities.Count > 0)
                    ExecuteSysTaskActivityTask.SendTask(process.Activities[0]);

                scope.Complete();
            }
		}