Exemplo n.º 1
0
        void IProcessService.ChangeProcessType(Process process, ProcessType targetVersion)
        {
            if (!this.IsSchedulingSafeCauseByFault(process))
            {
                throw new InvalidOperationException("只有处于Error状态的流程才允许变更流程类型");
            }

            //当前
            var currentVersion = process.ProcessType;
            var current        = process.GetCurrentNode();

            //切换流程类型
            process.ChangeProcessType(targetVersion);
            //切换后
            var target = process.GetCurrentNode();

            process.ChangeStatus(ProcessStatus.Running);
            this.CancelAllAbout(process);
            _repository.Update(process);
            //创建流程运行请求重新启动流程
            this._schedulerService.Add(new ProcessStartResumption(process));

            this._log.InfoFormat("将流程实例“{0}”#{1}的流程版本从{2}切换为{3},当前节点从{4}指向{5}"
                                 , process.Title
                                 , process.ID
                                 , currentVersion.Version
                                 , targetVersion.Version
                                 , current
                                 , target);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 判断代理内容是否有效
 /// </summary>
 /// <param name="toActing"></param>
 /// <returns></returns>
 public virtual bool CheckValid(ProcessType toActing)
 {
     return(toActing != null &&
            this.IsValid &&
            (this.Range == ActingRange.All ||
             this.ActingItems.FirstOrDefault(o => o.ProcessTypeName == toActing.Name) != null));
 }
Exemplo n.º 3
0
        public ProcessActingItem(ProcessType type)
        {
            if (type == null)
            {
                throw new InvalidOperationException("ProcessType不能为空");
            }

            this.ProcessTypeName = type.Name;
        }
Exemplo n.º 4
0
 void IProcessTypeService.Create(ProcessType type, bool current)
 {
     type.IsCurrent = current;
     _repository.Add(type);
     if (current)
     {
         (this as IProcessTypeService).SetAsCurrent(type.Name, type.Version);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="title"></param>
        /// <param name="type"></param>
        /// <param name="originator"></param>
        /// <param name="priority"></param>
        /// <param name="inputs"></param>
        public Process(string title, ProcessType type, User originator, int priority, IDictionary <string, string> inputs)
            : this()
        {
            this.Title       = title;
            this.ProcessType = type;
            this.Originator  = originator;
            this.Priority    = priority;

            this.UpdateDataFields(inputs);
            this.UpdateCurrentNode(0);

            this.Validate();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 初始化子流程
        /// </summary>
        /// <param name="title"></param>
        /// <param name="type"></param>
        /// <param name="originator"></param>
        /// <param name="priority"></param>
        /// <param name="inputs"></param>
        /// <param name="parent"></param>
        public Process(string title, ProcessType type, User originator, int priority, IDictionary <string, string> inputs, Process parent)
            : this(title, type, originator, priority, inputs)
        {
            if (parent == null)
            {
                throw new InvalidOperationException("parent不能为空");
            }
            if (parent.ID == this.ID)
            {
                throw new InvalidOperationException("不能将流程设置为自己的父流程");
            }

            this.ParentProcessId = parent.ID;
        }
Exemplo n.º 7
0
        void IProcessService.DynamicChangeProcessType(Process process, ProcessType targetVersion)
        {
            if (!this.IsStatusOrSchedulingSafe(process))
            {
                throw new InvalidOperationException(string.Format("该流程处于{0}状态,不能进行版本变更", process.Status));
            }
            //当前流程定义
            var currentVersion = process.ProcessType;

            //切换流程定义
            process.ChangeProcessType(targetVersion);
            // 保存修改
            _repository.Update(process);

            this._log.InfoFormat("将流程实例“{0}”#{1}的流程版本从{2}动态切换为{3}"
                                 , process.Title
                                 , process.ID
                                 , currentVersion.Version
                                 , targetVersion.Version);
        }
Exemplo n.º 8
0
        //修改对应的类型信息并尝试将当前节点索引修正到新类型的对应索引上
        protected internal virtual void ChangeProcessType(ProcessType target)
        {
            if (this.Status == ProcessStatus.Deleted ||
                this.Status == ProcessStatus.Completed)
            {
                throw new InvalidOperationException("该流程实例的流程类型不可变更");
            }
            if (!target.Name.Equals(this.ProcessType.Name))
            {
                throw new InvalidOperationException("只允许变更到同一流程类型的其他版本");
            }
            if (target.Version.Equals(this.ProcessType.Version))
            {
                throw new InvalidOperationException("已经是目标版本,无需变更");
            }

            var current = this.ProcessType.GetActivitySetting(this.GetCurrentNode());

            //当前流程定义损坏的情况
            if (current == null)
            {
                this.UpdateCurrentNode(0);
            }
            else
            {
                var setting = target.GetActivitySetting(current.ActivityName);

                if (setting == null)
                {
                    //HACK:目前对于不对等的流程版本禁止切换
                    throw new InvalidOperationException("没有在目标流程定义中找到节点的“" + current.ActivityName + "”定义,无法切换");
                }

                this.UpdateCurrentNode(target == null ? 0 : setting.FlowNodeIndex);
            }
            this.ProcessType = target;
        }
Exemplo n.º 9
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="title"></param>
 /// <param name="type"></param>
 /// <param name="originator"></param>
 public Process(string title, ProcessType type, User originator)
     : this(title, type, originator, 0, null)
 {
 }
Exemplo n.º 10
0
 void IProcessTypeService.Create(ProcessType type)
 {
     (this as IProcessTypeService).Create(type, true);
 }
Exemplo n.º 11
0
 /// <summary>
 /// 获取工作流定义的缓存键
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static string GetCacheKey(ProcessType type)
 {
     return(type.Name + "_" + type.ID);
 }