Exemplo n.º 1
0
        /// <summary>
        /// 用途:保存流程实例的流程数据
        /// 范围:大管理员|流程模型管理员
        /// </summary>
        /// <param name="workitemInstanceGuid">当前流程活动guid</param>
        /// <param name="dataEntity">流程中所用到的数据内容</param>
        /// <returns></returns>
        public ResultMessage SaveDataEntity(string workflowInstanceGuid, IDictionary <string, string> dataEntity)
        {
            WorkflowInstance wfi = this.GetWorkflowInstance(workflowInstanceGuid);

            ///加入权限控制大管理员|流程模型管理员
            if (!(this.Context.CurUser.IsAdministrator() || wfi.GetWorkflow().Administrators.Contains(this.Context.CurUser, _uc)))
            {
                return new ResultMessage()
                       {
                           State = false, Message = "不在许可操作范围内!"
                       }
            }
            ;

            wfi.SetDataEntity(dataEntity);

            bool b = this.SetWorkflowInstance(wfi, eStoreType.Update);

            if (b)
            {
                return new ResultMessage()
                       {
                           State = true, Message = "保存流程数据成功!"
                       }
            }
            ;
            else
            {
                return new ResultMessage()
                       {
                           State = false, Message = "保存流程数据失败!"
                       }
            };
        }
Exemplo n.º 2
0
        /// <summary>
        ///  用途:撤回流程实例
        ///  范围:大管理员|流程模型管理员
        /// </summary>
        /// <param name="workflowInstanceGuid"></param>
        /// <returns></returns>
        public ResultMessage RecallWorkflowInstance(string workflowInstanceGuid)
        {
            WorkflowInstance wfi = this.GetWorkflowInstance(workflowInstanceGuid);

            ///加入权限控制大管理员|流程模型管理员
            if (!(this.Context.CurUser.IsAdministrator() || wfi.GetWorkflow().Administrators.Contains(this.Context.CurUser, _uc)))
            {
                return new ResultMessage()
                       {
                           State = false, Message = "不在许可操作范围内!"
                       }
            }
            ;
            ///不允许回收尚不在运行的流程实例
            if (wfi.WorkflowState.Equals(eWorkflowState.Running))
            {
                return new ResultMessage()
                       {
                           State = false, Message = "该流程实例无需回收!"
                       }
            }
            ;
            wfi.Restart();
            bool b = this.SetWorkflowInstance(wfi, eStoreType.Update);

            if (b)
            {
                return new ResultMessage()
                       {
                           State = true, Message = "撤回流程实例成功!"
                       }
            }
            ;
            else
            {
                return new ResultMessage()
                       {
                           State = false, Message = "撤回流程实例失败!"
                       }
            };
        }
        /// <summary>
        /// 用途:创建流程实例并返回首个流程活动工作项
        /// 约定:
        /// 1、一个流程有且仅有一个根活动
        /// 2、代理人不能发起委托人的新流程,只能处理委托日期后正在流转的流程数据
        /// 3、有发起流程模型权限方可以操作
        /// </summary>
        /// <param name="workflowGuid">流程模型guid</param>
        /// <returns>首个流程活动工作项</returns>
        public ResponseByWorkitem CreateWorkflowInstance(string workflowGuid, string name = null)
        {
            ///创建流程实例
            WorkflowInstance wfi = new WorkflowInstance(workflowGuid, name);

            //wfi.Guid ...
            //wfi.Name ...
            //wfi.WorkflowGuid ...
            wfi.Author = this.Context.CurUser;
            //wfi.WorkflowState ...
            //wfi.Participator ...
            //wfi.Locker ...
            //wfi.BeginTime ...;
            //wfi.EndTime ...;
            //wfi.DataEntity ...

            wfi.SetContext(this.Context);

            ///加入权限控制
            if (!(this.Context.CurUser.IsAdministrator() ||//是否大管理员
                  wfi.GetWorkflow().IsAdministrators(this.Context.CurUser) ||//是否流程模型管理员
                  wfi.GetWorkflow().IsLegalAuthor(this.Context.CurUser)   //流程的合法发起用户
                  ))
            {
                return(new ResponseByWorkitem()
                {
                    CallBackMessage = new ResultMessage()
                    {
                        State = false, Message = "不能发起流程!"
                    }
                });
            }

            ///开启流程实例服务
            wfi.Start();
            wfi.Save();

            //创建活动实例
            WorkitemInstance wii = new WorkitemInstance(wfi.Guid, wfi.GetWorkflow().GetStartNode());

            //wii.Guid ...
            //wii.Name ...
            //wii.ActivityGuid ...
            //wii.WorkflowInstanceGuid ...
            //wii.AduitContent = "";
            //wii.AduitSign = "";
            //wii.ReadTime = null;
            //wii.NextActivities = null;
            wii.User = this.Context.CurUser;
            //wii.ProxyUser = null;
            //wii.IsProxy = false;
            //wii.WorkitemInstanceState ...
            //wii.FromWorkitemInstanceGuid = "";
            //wii.AttachmentTrainsitions = null;
            //wii.SelectVoteItem = "";
            //wii.OtherVoteItemContent = "";
            //wii.BeginTime ...;
            //wii.EndTime ...;
            //wii.DataEntity ...

            wii.SetContext(this.Context);
            ///开启活动实例
            wii.Start();
            wii.Save();
            ///活动前事件处理
            var rm = wii.BeforeTrigger();

            ResponseByWorkitem response;

            ///如果不满足
            if (!rm.State)
            {
                response = new ResponseByWorkitem()
                {
                    ActivityInstance = wii,
                    //NextMaybeActivities=null,
                    UIRight         = this.Context.Config.RightByReadOnly,
                    CallBackMessage = rm,
                };
            }
            else
            {
                response = new ResponseByWorkitem()
                {
                    ActivityInstance    = wii,
                    NextMaybeActivities = wii.GetNextEffectiveActivities(),
                    UIRight             = wii.GetActivity().UIRight,
                    CallBackMessage     = new ResultMessage()
                    {
                        State = true, Message = ""
                    },
                };
            }
            return(response);
        }