Esempio n. 1
0
 /// <summary>
 /// 向前流转时的NodeMediator的构造函数
 /// </summary>
 /// <param name="forwardContext"></param>
 /// <param name="session"></param>
 internal NodeMediator(ActivityForwardContext forwardContext, IDbSession session)
 {
     _activityForwardContext = forwardContext;
     _session = session;
     _processModel = forwardContext.ProcessModel;
     Linker.FromActivity = forwardContext.Activity;
 }
 /// <summary>
 /// 开始节点的构造执行上下文对象
 /// </summary>
 /// <param name="processModel"></param>
 /// <param name="processInstance"></param>
 /// <param name="activity"></param>
 /// <param name="activityResource"></param>
 private ActivityForwardContext(ProcessModel processModel,
     ProcessInstanceEntity processInstance,
     ActivityEntity activity,
     ActivityResource activityResource)
 {
     ProcessModel = processModel;
     ProcessInstance = processInstance;
     Activity = activity;
     ActivityResource = activityResource;
 }
        /// <summary>
        /// 任务执行的上下文对象
        /// </summary>
        /// <param name="task"></param>
        /// <param name="processModel"></param>
        /// <param name="activityResource"></param>
        private ActivityForwardContext(TaskViewEntity task,
            ProcessModel processModel,
            ActivityResource activityResource)
        {
            this.TaskView = task;

            //check task condition has load activity instance
            this.FromActivityInstance = (new ActivityInstanceManager()).GetById(task.ActivityInstanceID);
            this.ProcessInstance = (new ProcessInstanceManager()).GetById(task.ProcessInstanceID);
            this.Activity = processModel.GetActivity(task.ActivityGUID);
            this.ProcessModel = processModel;
            this.ActivityResource = activityResource;
        }
 /// <summary>
 /// 创建ActivitySchedule
 /// </summary>
 /// <param name="splitJoinType"></param>
 /// <returns></returns>
 internal static NextActivityScheduleBase CreateActivitySchedule(ProcessModel processModel,
     GatewaySplitJoinTypeEnum splitJoinType)
 {
     NextActivityScheduleBase activitySchedule = null;
     if (splitJoinType == GatewaySplitJoinTypeEnum.Split)
     {
         activitySchedule = new NextActivityScheduleSplit(processModel);
     }
     else if (splitJoinType == GatewaySplitJoinTypeEnum.Join)
     {
         activitySchedule = new NextActivityScheduleJoin(processModel);
     }
     else
     {
         throw new Exception("未知的splitJoinType!");
     }
     return activitySchedule;
 }
 internal static NodeMediatorGateway CreateGatewayNodeMediator(ActivityEntity gActivity, 
     ProcessModel processModel,
     IDbSession session)
 {
     NodeMediatorGateway nodeMediator = null;
     if (gActivity.ActivityType == ActivityTypeEnum.GatewayNode)
     {
         if (gActivity.GatewayDirectionType == GatewayDirectionEnum.AndSplit)
         {
             nodeMediator = new NodeMediatorAndSplit(gActivity, processModel, session);
         }
         else if (gActivity.GatewayDirectionType == GatewayDirectionEnum.OrSplit)
         {
             nodeMediator = new NodeMediatorOrSplit(gActivity, processModel, session);
         }
         else if (gActivity.GatewayDirectionType == GatewayDirectionEnum.XOrSplit)
         {
             nodeMediator = new NodeMediatorXOrSplit(gActivity, processModel, session);
         }
         else if (gActivity.GatewayDirectionType == GatewayDirectionEnum.AndJoin)
         {
             nodeMediator = new NodeMediatorAndJoin(gActivity, processModel, session);
         }
         else if (gActivity.GatewayDirectionType == GatewayDirectionEnum.OrJoin)
         {
             nodeMediator = new NodeMediatorOrJoin(gActivity, processModel, session);
         }
         else if (gActivity.GatewayDirectionType == GatewayDirectionEnum.XOrJoin)
         {
             nodeMediator = new NodeMediatorXOrJoin(gActivity, processModel, session);
         }
         else
         {
             throw new XmlDefinitionException(string.Format("不明确的节点分支Gateway类型!{0}", gActivity.GatewayDirectionType.ToString()));
         }
     }
     else
     {
         throw new XmlDefinitionException(string.Format("不明确的节点类型!{0}", gActivity.ActivityType.ToString()));
     }
     return nodeMediator;
 }
 /// <summary>
 /// 获取活动节点下的角色数据
 /// </summary>
 /// <param name="processGUID"></param>
 /// <param name="version"></param>
 /// <param name="activityGUID"></param>
 /// <returns></returns>
 public IList<Role> GetActivityRoles(string processGUID, string version, string activityGUID)
 {
     var processModel = new ProcessModel(processGUID, version);
     return processModel.GetActivityRoles(activityGUID);
 }
 internal NextActivityScheduleJoin(ProcessModel processModel)
     : base(processModel)
 {
 }
Esempio n. 8
0
 internal NodeMediatorOrSplit(ActivityEntity activity, ProcessModel processModel, IDbSession session)
     : base(activity, processModel, session)
 {
 }
        /// <summary>
        /// 流程返签,先检查约束条件,然后调用wfruntimeinstance执行
        /// </summary>
        /// <param name="appName"></param>
        /// <param name="appInstanceID"></param>
        /// <param name="processGUID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public static WfRuntimeManager CreateRuntimeInstanceReverse(WfAppRunner runner,
            ref WfExecutedResult result)
        {
            var rmins = new WfRuntimeManagerReverse();
            rmins.WfExecutedResult = result = new WfExecutedResult();
            var pim = new ProcessInstanceManager();
            var processInstance = pim.GetProcessInstanceLatest(runner.AppName, runner.AppInstanceID, runner.ProcessGUID);
            if (processInstance == null || processInstance.ProcessState != (short)ProcessStateEnum.Completed)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.Reverse_NotInCompleted;
                result.Message = string.Format("当前应用:{0},实例ID:{1}, 没有完成的流程实例,无法让流程重新运行!",
                    runner.AppName, runner.AppInstanceID);
                return rmins;
            }

            var tim = new TransitionInstanceManager();
            var endTransitionInstance = tim.GetEndTransition(runner.AppName, runner.AppInstanceID, runner.ProcessGUID);

            var processModel = new ProcessModel(runner.ProcessGUID);
            var endActivity = processModel.GetActivity(endTransitionInstance.ToActivityGUID);

            var aim = new ActivityInstanceManager();
            var endActivityInstance = aim.GetById(endTransitionInstance.ToActivityInstanceID);

            bool hasGatewayNode = false;
            var lastTaskActivityInstance = tim.GetPreviousActivityInstance(endActivityInstance, false,
                out hasGatewayNode).ToList()[0];
            var lastTaskActivity = processModel.GetActivity(lastTaskActivityInstance.ActivityGUID);

            //封装返签结束点之前办理节点的任务接收人
            rmins.AppRunner.NextActivityPerformers = ActivityResource.CreateNextActivityPerformers(lastTaskActivityInstance.ActivityGUID,
                lastTaskActivityInstance.EndedByUserID,
                lastTaskActivityInstance.EndedByUserName);

            rmins.ActivityResource = new ActivityResource(runner, rmins.AppRunner.NextActivityPerformers);
            rmins.AppRunner.AppName = runner.AppName;
            rmins.AppRunner.AppInstanceID = runner.AppInstanceID;
            rmins.AppRunner.ProcessGUID = runner.ProcessGUID;
            rmins.AppRunner.UserID = runner.UserID;
            rmins.AppRunner.UserName = runner.UserName;

            rmins.BackwardContext.ProcessInstance = processInstance;
            rmins.BackwardContext.BackwardToTaskActivity = lastTaskActivity;
            rmins.BackwardContext.BackwardToTaskActivityInstance = lastTaskActivityInstance;
            rmins.BackwardContext.BackwardToTargetTransitionGUID =
                hasGatewayNode == false ? endTransitionInstance.TransitionGUID : String.Empty;
            rmins.BackwardContext.BackwardFromActivity = endActivity;
            rmins.BackwardContext.BackwardFromActivityInstance = endActivityInstance;
            rmins.BackwardContext.BackwardTaskReciever = WfBackwardTaskReciever.Instance(lastTaskActivityInstance.ActivityName,
                lastTaskActivityInstance.EndedByUserID,
                lastTaskActivityInstance.EndedByUserName);

            return rmins;
        }
Esempio n. 10
0
        /// <summary>
        /// 流程定义的XML文件获取和保存
        /// </summary>
        /// <param name="processGUID"></param>
        /// <returns></returns>
        public ProcessFileEntity GetProcessFile(string processGUID)
        {
            var processModel = new ProcessModel(processGUID);
            var entity = processModel.GetProcessFile();

            return entity;
        }
 /// <summary>
 /// 获取当前节点的下一个节点信息[mamingbo 2014/11/25 16:47:00]
 /// </summary>
 /// <param name="processGUID"></param>
 /// <param name="activityGUID"></param>
 /// <param name="condition"></param>
 /// <returns></returns>
 public IList<NodeView> GetNextActivity(String processGUID,
     String version,
     String activityGUID,
     IDictionary<string, string> condition)
 {
     var processModel = new ProcessModel(processGUID, version);
     var nextSteps = processModel.GetNextActivityTree(activityGUID, condition);
     return nextSteps;
 }
 internal NextActivityScheduleSplit(ProcessModel processModel)
     : base(processModel)
 {
 }
 internal NextActivityScheduleBase(ProcessModel processModel)
 {
     _processModel = processModel;
 }
        /// <summary>
        /// 加签操作
        /// </summary>
        /// <param name="runner"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static WfRuntimeManager CreateRuntimeInstanceSignForward(WfAppRunner runner,
            ref WfExecutedResult result)
        {
            var rmins = new WfRuntimeManagerSignForward();
            rmins.WfExecutedResult = result = new WfExecutedResult();

            if (string.IsNullOrEmpty(runner.AppName)
                || String.IsNullOrEmpty(runner.AppInstanceID)
                || runner.ProcessGUID == null
                || runner.NextActivityPerformers == null)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.SignForward_ErrorArguments;
                result.Message = "方法参数错误,无法加签流程!";
                return rmins;
            }

            if (runner.NextActivityPerformers.Count() == 0)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.SignForward_NoneSigners;
                result.Message = "没有添加要发送加签的人员";
                return rmins;
            }

            rmins.AppRunner = runner;

            var aim = new ActivityInstanceManager();
            TaskViewEntity taskView = null;
            var runningNode = aim.GetRunningNode(runner, out taskView);

            //判断是否是当前登录用户的任务
            if (runningNode.AssignedToUserIDs.Contains(runner.UserID.ToString()) == false)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.RunApp_HasNoTask;
                result.Message = "当前没有登录用户要办理的任务,无法运行流程!";
                return rmins;
            }

            var processModel = new ProcessModel(taskView.ProcessGUID, taskView.Version);
            var activityResource = new ActivityResource(runner, runner.NextActivityPerformers, runner.Conditions, runner.DynamicVariables);

            var tm = new TaskManager();
            rmins.TaskView = taskView;
            rmins.RunningActivityInstance = runningNode;
            rmins.ProcessModel = processModel;
            rmins.ActivityResource = activityResource;

            return rmins;
        }
Esempio n. 15
0
        /// <summary>
        /// 创建流程模型实例
        /// </summary>
        /// <param name="processGUID">流程GUID</param>
        /// <param name="version">版本</param>
        /// <returns>流程模型</returns>
        internal static IProcessModel Create(string processGUID, string version)
        {
            IProcessModel processModel = new ProcessModel(processGUID, version);

            return(processModel);
        }
Esempio n. 16
0
 /// <summary>
 /// 保存流程定义的xml文件
 /// </summary>
 /// <param name="diagram"></param>
 public void SaveProcessFile(ProcessFileEntity entity)
 {
     var processModel = new ProcessModel(entity.ProcessGUID);
     processModel.SaveProcessFile(entity);
 }
 /// <summary>
 /// 获取流程的第一个可办理节点
 /// </summary>
 /// <returns></returns>
 public ActivityEntity GetFirstActivity(string processGUID, string version)
 {
     var processModel = new ProcessModel(processGUID, version);
     var firstActivity = processModel.GetFirstActivity();
     return firstActivity;
 }
        /// <summary>
        /// 获取下一步活动列表树
        /// </summary>
        /// <param name="taskID"></param>
        /// <returns></returns>
        public IList<NodeView> GetNextActivityTree(int taskID, 
            IDictionary<string, string> condition = null,
            IUserRoleService roleService = null)
        {
            var taskView = (new TaskManager()).GetTaskView(taskID);
            var processModel = new ProcessModel(taskView.ProcessGUID, taskView.Version);
            var nextSteps = processModel.GetNextActivityTree(taskView.ProcessInstanceID,
                taskView.ActivityGUID,
                condition,
                roleService);

            return nextSteps;
        }
 /// <summary>
 /// 获取当前节点的下一个节点信息
 /// </summary>
 /// <param name="processGUID"></param>
 /// <param name="activityGUID"></param>
 /// <returns></returns>
 public ActivityEntity GetNextActivity(string processGUID, 
     string version, 
     string activityGUID)
 {
     var processModel = new ProcessModel(processGUID, version);
     var nextActivity = processModel.GetNextActivity(activityGUID);
     return nextActivity;
 }
Esempio n. 20
0
 /// <summary>
 /// 获取当前活动实体
 /// </summary>
 /// <param name="processGUID"></param>
 /// <param name="activityGUID"></param>
 /// <returns></returns>
 public ActivityEntity GetActivityEntity(string processGUID, string activityGUID)
 {
     var processModel = new ProcessModel(processGUID);
     return processModel.GetActivity(activityGUID);
 }
        /// <summary>
        /// 根据应用获取流程下一步节点列表
        /// </summary>
        /// <param name="runner">应用执行人</param>
        /// <param name="condition">条件</param>
        /// <returns></returns>
        public IList<NodeView> GetNextActivityTree(WfAppRunner runner, 
            IDictionary<string, string> condition = null,
            IUserRoleService roleService = null)
        {
            var tm = new TaskManager();
            var taskView = tm.GetTaskOfMine(runner.AppInstanceID, runner.ProcessGUID, runner.UserID);
            var processModel = new ProcessModel(taskView.ProcessGUID, taskView.Version);
            var nextSteps = processModel.GetNextActivityTree(taskView.ProcessInstanceID,
                taskView.ActivityGUID,
                condition,
                roleService);

            return nextSteps;
        }
 /// <summary>
 /// 创建流程跳转上下文对象
 /// </summary>
 /// <param name="jumpforwardActivity"></param>
 /// <param name="processModel"></param>
 /// <param name="processInstance"></param>
 /// <param name="activityResource"></param>
 /// <returns></returns>
 internal static ActivityForwardContext CreateJumpforwardContext(ActivityEntity jumpforwardActivity,
     ProcessModel processModel,
     ProcessInstanceEntity processInstance,
     ActivityResource activityResource)
 {
     return new ActivityForwardContext(processModel, processInstance, jumpforwardActivity, activityResource);
 }
        /// <summary>
        /// 获取任务类型的节点列表
        /// </summary>
        /// <returns></returns>
        public List<ActivityEntity> GetTaskActivityList(string processGUID, string version)
        {
            var processModel = new ProcessModel(processGUID, version);
            var activityList = processModel.GetTaskActivityList();

            return activityList;
        }
 /// <summary>
 /// 创建任务执行上下文对象
 /// </summary>
 /// <param name="task"></param>
 /// <param name="processModel"></param>
 /// <param name="activityResource"></param>
 /// <returns></returns>
 internal static ActivityForwardContext CreateRunningContext(TaskViewEntity task,
     ProcessModel processModel,
     ActivityResource activityResource)
 {
     return new ActivityForwardContext(task, processModel, activityResource);
 }
        /// <summary>
        /// 创建运行时实例
        /// </summary>
        /// <param name="appName"></param>
        /// <param name="appInstanceID"></param>
        /// <param name="processGUID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <param name="nextActivityPerformers"></param>
        /// <returns></returns>
        public static WfRuntimeManager CreateRuntimeInstanceAppRunning(
            WfAppRunner runner,
            ref WfExecutedResult result)
        {
            //检查传人参数是否有效
            var rmins = new WfRuntimeManagerAppRunning();
            rmins.WfExecutedResult = result = new WfExecutedResult();
            if (string.IsNullOrEmpty(runner.AppName)
                || String.IsNullOrEmpty(runner.AppInstanceID)
                || runner.ProcessGUID == null)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.RunApp_ErrorArguments;
                result.Message = "方法参数错误,无法运行流程!";
                return rmins;
            }

            //传递runner变量
            rmins.AppRunner = runner;

            var aim = new ActivityInstanceManager();
            TaskViewEntity taskView = null;
            var runningNode = aim.GetRunningNodeOfMine(runner, out taskView);

            //判断是否是当前登录用户的任务
            if (runningNode.AssignedToUsers.Contains(runner.UserID.ToString()) == false)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.RunApp_HasNoTask;
                result.Message = "当前没有登录用户要办理的任务,无法运行流程!";
                return rmins;
            }

            var processModel = new ProcessModel(runningNode.ProcessGUID);
            var activityResource = new ActivityResource(runner, runner.NextActivityPerformers, runner.Conditions);

            var tm = new TaskManager();
            rmins.TaskView = taskView;
            rmins.RunningActivityInstance = runningNode;
            rmins.ProcessModel = processModel;
            rmins.ActivityResource = activityResource;

            return rmins;
        }
 /// <summary>
 /// 启动流程的上下文对象
 /// </summary>
 /// <param name="processModel"></param>
 /// <param name="processInstance"></param>
 /// <param name="activity"></param>
 /// <param name="activityResource"></param>
 /// <returns></returns>
 internal static ActivityForwardContext CreateStartupContext(ProcessModel processModel,
     ProcessInstanceEntity processInstance,
     ActivityEntity activity,
     ActivityResource activityResource)
 {
     return new ActivityForwardContext(processModel, processInstance, activity, activityResource);
 }
 internal NodeMediatorGateway(ActivityEntity gActivity, ProcessModel processModel, IDbSession session)
 {
     _gatewayActivity = gActivity;
     _processModel = processModel;
     _session = session;
 }
 internal NextActivityScheduleBase(ProcessModel processModel)
 {
     _processModel = processModel;
 }