internal override void ExecuteInstanceImp(IDbSession session) { //根据加签类型选项,生成新的ActivityInstance记录 //加签类型有前加签,后加签和并加签 try { var signforwardExecutionContext = ActivityForwardContext.CreateRunningContext(base.TaskView, base.ProcessModel, base.ActivityResource); NodeMediator mediator = NodeMediatorFactory.CreateNodeMediator(signforwardExecutionContext, session); mediator.ExecuteWorkItem(); var result = base.WfExecutedResult; result.Status = WfExecutedStatus.Success; result.Message = mediator.GetNodeMediatedMessage(); } catch (WfRuntimeException rx) { var result = base.WfExecutedResult; result.Status = WfExecutedStatus.Failed; result.ExceptionType = WfExceptionType.SignForward_RuntimeError; result.Message = rx.Message; throw rx; } catch (System.Exception ex) { var result = base.WfExecutedResult; result.Status = WfExecutedStatus.Failed; result.ExceptionType = WfExceptionType.SignForward_RuntimeError; result.Message = ex.Message; throw ex; } }
/// <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; }
internal override void ExecuteInstanceImp(IDbSession session) { //创建新任务节点 var backMostPreviouslyActivityInstanceID = GetBackwardMostPreviouslyActivityInstanceID(); var nodeMediatorBackward = new NodeMediatorBackward(base.BackwardContext, session); nodeMediatorBackward.CreateBackwardActivityTaskTransitionInstance(base.BackwardContext.ProcessInstance, base.BackwardContext.BackwardFromActivityInstance, BackwardTypeEnum.Withdrawed, backMostPreviouslyActivityInstanceID, base.BackwardContext.BackwardToTargetTransitionGUID, TransitionTypeEnum.Withdrawed, TransitionFlyingTypeEnum.NotFlying, base.ActivityResource, session); //更新撤销节点的状态(从准备状态更新为撤销状态) var aim = new ActivityInstanceManager(); aim.Withdraw(base.BackwardContext.BackwardFromActivityInstance.ID, base.ActivityResource.AppRunner, session); //构造回调函数需要的数据 WfExecutedResult result = base.WfExecutedResult; result.BackwardTaskReciever = base.BackwardContext.BackwardTaskReciever; result.Status = WfExecutedStatus.Success; }
internal override void ExecuteInstanceImp(IDbSession session) { try { var runningExecutionContext = ActivityForwardContext.CreateRunningContext(base.TaskView, base.ProcessModel, base.ActivityResource); //执行节点 NodeMediator mediator = NodeMediatorFactory.CreateNodeMediator(runningExecutionContext, session); mediator.Linker.FromActivityInstance = RunningActivityInstance; mediator.ExecuteWorkItem(); //构造回调函数需要的数据 var result = base.WfExecutedResult; result.Status = WfExecutedStatus.Success; result.Message = mediator.GetNodeMediatedMessage(); } catch (WfRuntimeException rx) { var result = base.WfExecutedResult; result.Status = WfExecutedStatus.Failed; result.ExceptionType = WfExceptionType.RunApp_RuntimeError; result.Message = rx.Message; throw rx; } catch (System.Exception ex) { var result = base.WfExecutedResult; result.Status = WfExecutedStatus.Failed; result.ExceptionType = WfExceptionType.RunApp_RuntimeError; result.Message = ex.Message; throw ex; } }
/// <summary> /// 创建节点执行器的抽象类 /// </summary> /// <param name="processInstance"></param> /// <param name="activity"></param> /// <param name="activityResource"></param> /// <param name="dataContext"></param> /// <returns></returns> internal static NodeMediator CreateNodeMediator(ActivityForwardContext forwardContext, IDbSession session) { if (forwardContext.Activity.ActivityType == ActivityTypeEnum.StartNode) { return new NodeMediatorStart(forwardContext, session); } else if (forwardContext.Activity.ActivityType == ActivityTypeEnum.TaskNode) { //加签节点特殊处理 if (forwardContext.Activity.ActivityTypeDetail.ComplexType == Xpdl.ComplexTypeEnum.SignForward) { //加签的动态变量传入 if (forwardContext.ActivityResource.DynamicVariables != null && !string.IsNullOrEmpty(forwardContext.ActivityResource.DynamicVariables["SignForwardType"])) { return new NodeMediatorSignForward(forwardContext, session); } else { return new NodeMediatorTask(forwardContext, session); } } else return new NodeMediatorTask(forwardContext, session); } else if (forwardContext.Activity.ActivityType == ActivityTypeEnum.SubProcessNode) { return new NodeMediatorSubProcess(forwardContext, session); } else { throw new ApplicationException(string.Format("不明确的节点类型: {0}", forwardContext.Activity.ActivityType.ToString())); } }
/// <summary> /// 创建多实例节点之间回滚时的活动实例,任务数据 /// </summary> /// <param name="processInstance"></param> /// <param name="originalBackwardToActivityInstance"></param> /// <param name="backwardType"></param> /// <param name="backSrcActivityInstanceID"></param> /// <param name="activityResource"></param> /// <param name="session"></param> internal void CreateBackwardActivityTaskOfInnerMultipleInstance(ProcessInstanceEntity processInstance, ActivityInstanceEntity originalBackwardToActivityInstance, BackwardTypeEnum backwardType, int backSrcActivityInstanceID, ActivityResource activityResource, IDbSession session) { //创建回滚到的节点信息 var rollbackPreviousActivityInstance = base.CreateBackwardToActivityInstanceObject(processInstance, backwardType, backSrcActivityInstanceID, activityResource.AppRunner); rollbackPreviousActivityInstance.ActivityState = (short)ActivityStateEnum.Ready; rollbackPreviousActivityInstance.MIHostActivityInstanceID = originalBackwardToActivityInstance.MIHostActivityInstanceID; rollbackPreviousActivityInstance.CompleteOrder = originalBackwardToActivityInstance.CompleteOrder; rollbackPreviousActivityInstance.ComplexType = originalBackwardToActivityInstance.ComplexType; rollbackPreviousActivityInstance.SignForwardType = originalBackwardToActivityInstance.SignForwardType; rollbackPreviousActivityInstance.AssignedToUserIDs = originalBackwardToActivityInstance.AssignedToUserIDs; //多实例节点为单一用户任务 rollbackPreviousActivityInstance.AssignedToUserNames = originalBackwardToActivityInstance.AssignedToUserNames; //插入新活动实例数据 base.ActivityInstanceManager.Insert(rollbackPreviousActivityInstance, session); //创建新任务数据 base.CreateNewTask(rollbackPreviousActivityInstance, activityResource, session); }
internal override void ExecuteInstanceImp(IDbSession session) { //构造流程实例 var processInstance = new ProcessInstanceManager() .CreateNewProcessInstanceObject(base.AppRunner, base.ProcessModel.ProcessEntity, base.ParentProcessInstance, base.InvokedSubProcessNode == null? null : base.InvokedSubProcessNode.ActivityInstance); //构造活动实例 //1. 获取开始节点活动 var startActivity = base.ProcessModel.GetStartActivity(); var startExecutionContext = ActivityForwardContext.CreateStartupContext(base.ProcessModel, processInstance, startActivity, base.ActivityResource); //base.RunWorkItemIteraly(startExecutionContext, session); NodeMediator mediator = NodeMediatorFactory.CreateNodeMediator(startExecutionContext, session); mediator.Linker.FromActivityInstance = RunningActivityInstance; mediator.ExecuteWorkItem(); //构造回调函数需要的数据 WfExecutedResult result = base.WfExecutedResult; result.ProcessInstanceIDStarted = processInstance.ID; result.Status = WfExecutedStatus.Success; }
public GatewayExecutedResult CompleteAutomaticlly(ProcessInstanceEntity processInstance, string transitionGUID, ActivityInstanceEntity fromActivityInstance, ActivityResource activityResource, IDbSession session) { var gatewayActivityInstance = base.CreateActivityInstanceObject(base.GatewayActivity, processInstance, activityResource.AppRunner); gatewayActivityInstance.GatewayDirectionTypeID = (short)GatewayDirectionEnum.OrSplit; base.InsertActivityInstance(gatewayActivityInstance, session); base.CompleteActivityInstance(gatewayActivityInstance.ID, activityResource, session); gatewayActivityInstance.ActivityState = (short)ActivityStateEnum.Completed; base.GatewayActivityInstance = gatewayActivityInstance; //写节点转移实例数据 base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, gatewayActivityInstance, TransitionTypeEnum.Forward, TransitionFlyingTypeEnum.NotFlying, activityResource.AppRunner, session); GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Successed); return result; }
/// <summary> /// 自动完成结束节点 /// </summary> /// <param name="processInstance"></param> /// <param name="fromActivityInstance"></param> /// <param name="activityResource"></param> /// <param name="wfLinqDataContext"></param> public GatewayExecutedResult CompleteAutomaticlly(ProcessInstanceEntity processInstance, string transitionGUID, ActivityInstanceEntity fromActivityInstance, ActivityResource activityResource, IDbSession session) { GatewayExecutedResult result = null; var toActivityInstance = base.CreateActivityInstanceObject(base.Linker.ToActivity, processInstance, activityResource.AppRunner); base.ActivityInstanceManager.Insert(toActivityInstance, session); base.ActivityInstanceManager.Complete(toActivityInstance.ID, activityResource.AppRunner, session); //写节点转移实例数据 base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, toActivityInstance, TransitionTypeEnum.Forward, TransitionFlyingTypeEnum.NotFlying, activityResource.AppRunner, session); //设置流程完成 ProcessInstanceManager pim = new ProcessInstanceManager(); pim.Complete(processInstance.ID, activityResource.AppRunner, session); //发送流程结束消息给流程启动人 return result; }
public GatewayExecutedResult CompleteAutomaticlly(ProcessInstanceEntity processInstance, string transitionGUID, ActivityInstanceEntity fromActivityInstance, ActivityResource activityResource, IDbSession session) { //检查是否有运行中的合并节点实例 ActivityInstanceEntity joinNode = base.ActivityInstanceManager.GetActivityRunning( processInstance.ID, base.GatewayActivity.ActivityGUID, session); if (joinNode == null) { var joinActivityInstance = base.CreateActivityInstanceObject(base.GatewayActivity, processInstance, activityResource.AppRunner); //计算总需要的Token数目 joinActivityInstance.TokensRequired = GetTokensRequired(); joinActivityInstance.TokensHad = 1; //进入运行状态 joinActivityInstance.ActivityState = (short)ActivityStateEnum.Running; joinActivityInstance.GatewayDirectionTypeID = (short)GatewayDirectionEnum.AndJoin; base.InsertActivityInstance(joinActivityInstance, session); } else { //更新节点的活动实例属性 base.GatewayActivityInstance = joinNode; int tokensRequired = base.GatewayActivityInstance.TokensRequired; int tokensHad = base.GatewayActivityInstance.TokensHad; //更新Token数目 base.ActivityInstanceManager.IncreaseTokensHad(base.GatewayActivityInstance.ID, activityResource.AppRunner, session); if ((tokensHad + 1) == tokensRequired) { //如果达到完成节点的Token数,则设置该节点状态为完成 base.CompleteActivityInstance(base.GatewayActivityInstance.ID, activityResource, session); base.GatewayActivityInstance.ActivityState = (short)ActivityStateEnum.Completed; } } GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult( GatewayExecutedStatus.Successed); return result; }
/// <summary> /// 创建节点执行器的抽象类 /// </summary> /// <param name="processInstance"></param> /// <param name="activity"></param> /// <param name="activityResource"></param> /// <param name="dataContext"></param> /// <returns></returns> internal static NodeMediator CreateNodeMediator(ActivityForwardContext forwardContext, IDbSession session) { if (forwardContext.Activity.ActivityType == ActivityTypeEnum.StartNode) return new NodeMediatorStart(forwardContext, session); else if (forwardContext.Activity.ActivityType == ActivityTypeEnum.TaskNode) return new NodeMediatorTask(forwardContext, session); else if (forwardContext.Activity.ActivityType == ActivityTypeEnum.SubProcessNode) return new NodeMediatorSubProcess(forwardContext, session); else throw new ApplicationException(string.Format("不明确的节点类型: {0}", forwardContext.Activity.ActivityType.ToString())); }
/// <summary> /// 设置任务完成 /// </summary> /// <param name="taskID">任务ID</param> /// <param name="runner"></param> /// <param name="wfLinqDataContext"></param> internal void Complete(long taskID, WfAppRunner runner, IDbSession session) { TaskEntity task = Repository.GetById<TaskEntity>(taskID); task.TaskState = (byte)TaskStateEnum.Completed; task.EndedDateTime = DateTime.Now; task.EndedByUserID = runner.UserID; task.EndedByUserName = runner.UserName; Update(task, session); }
/// <summary> /// 活动实例完成 /// </summary> /// <param name="activityInstanceID"></param> /// <param name="runner"></param> /// <param name="session"></param> internal void Complete(int activityInstanceID, WfAppRunner runner, IDbSession session) { var activityInstance = GetById(session.Connection, activityInstanceID, session.Transaction); activityInstance.ActivityState = (short)ActivityStateEnum.Completed; activityInstance.LastUpdatedByUserID = runner.UserID; activityInstance.LastUpdatedByUserName = runner.UserName; activityInstance.LastUpdatedDateTime = System.DateTime.Now; activityInstance.EndedByUserID = runner.UserID; activityInstance.EndedByUserName = runner.UserName; activityInstance.EndedDateTime = System.DateTime.Now; Update(activityInstance, session); }
internal override void ExecuteInstanceImp(IDbSession session) { WfExecutedResult result = base.WfExecutedResult; //回跳类型的处理 if (base.IsBackward == true) { //创建新任务节点 var backMostPreviouslyActivityInstanceID = GetBackwardMostPreviouslyActivityInstanceID(); var nodeMediatorBackward = new NodeMediatorBackward(base.BackwardContext, session); nodeMediatorBackward.CreateBackwardActivityTaskTransitionInstance(base.BackwardContext.ProcessInstance, base.BackwardContext.BackwardFromActivityInstance, BackwardTypeEnum.Sendback, backMostPreviouslyActivityInstanceID, base.BackwardContext.BackwardToTargetTransitionGUID, TransitionTypeEnum.Sendback, TransitionFlyingTypeEnum.NotFlying, base.ActivityResource, session); //更新当前办理节点的状态(从准备或运行状态更新为退回状态) var aim = new ActivityInstanceManager(); aim.SendBack(base.BackwardContext.BackwardFromActivityInstance.ID, base.ActivityResource.AppRunner, session); //构造回调函数需要的数据 result.BackwardTaskReciever = base.BackwardContext.BackwardTaskReciever; result.Status = WfExecutedStatus.Success; } else { var jumpActivityGUID = base.AppRunner.NextActivityPerformers.First().Key; var jumpforwardActivity = base.ProcessModel.GetActivity(jumpActivityGUID); var proecessInstance = (new ProcessInstanceManager()).GetById(base.RunningActivityInstance.ProcessInstanceID); var jumpforwardExecutionContext = ActivityForwardContext.CreateJumpforwardContext(jumpforwardActivity, base.ProcessModel, proecessInstance, base.ActivityResource); NodeMediator mediator = NodeMediatorFactory.CreateNodeMediator(jumpforwardExecutionContext, session); mediator.Linker.FromActivityInstance = base.RunningActivityInstance; mediator.Linker.ToActivity = jumpforwardActivity; mediator.ExecuteWorkItem(); result.Status = WfExecutedStatus.Success; result.Message = mediator.GetNodeMediatedMessage(); } }
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="session"></param> internal override void ExecuteInstanceImp(IDbSession session) { var runningNode = BackwardContext.BackwardFromActivityInstance; //创建撤销到上一步的节点记录 var nodeMediatorBackward = new NodeMediatorBackward(base.BackwardContext, session); nodeMediatorBackward.CreateBackwardActivityTaskOfInnerMultipleInstance( base.BackwardContext.ProcessInstance, base.BackwardContext.BackwardToTaskActivityInstance, BackwardTypeEnum.WithdrawedOfMI, base.BackwardContext.BackwardFromActivityInstance.ID, base.ActivityResource, session); //置当前节点为撤销状态 var aim = new ActivityInstanceManager(); aim.Withdraw(runningNode.ID, base.ActivityResource.AppRunner, session); //创建新的一条待办状态的记录,用于下次执行 var newSuspendNode = aim.CreateActivityInstanceObject(runningNode); newSuspendNode.ActivityState = (short)ActivityStateEnum.Suspended; newSuspendNode.MIHostActivityInstanceID = runningNode.MIHostActivityInstanceID; newSuspendNode.CompleteOrder = runningNode.CompleteOrder; newSuspendNode.ComplexType = runningNode.ComplexType; newSuspendNode.SignForwardType = runningNode.SignForwardType; newSuspendNode.AssignedToUserIDs = runningNode.AssignedToUserIDs; newSuspendNode.AssignedToUserNames = runningNode.AssignedToUserNames; aim.Insert(newSuspendNode, session); //同时为此活动实例,创建新的任务 var tm = new TaskManager(); tm.Renew(base.BackwardContext.BackwardFromActivityInstance, newSuspendNode, base.AppRunner, session); //构造回调函数需要的数据 WfExecutedResult result = base.WfExecutedResult; result.BackwardTaskReciever = base.BackwardContext.BackwardTaskReciever; result.Status = WfExecutedStatus.Success; }
/// <summary> /// 创建退回时的流转节点对象、任务和转移数据 /// </summary> /// <param name="processInstance"></param> /// <param name="fromActivityInstance"></param> /// <param name="backMostPreviouslyActivityInstanceID"></param> /// <param name="transitionGUID"></param> /// <param name="transitionType"></param> /// <param name="flyingType"></param> /// <param name="activityResource"></param> /// <param name="session"></param> internal void CreateBackwardActivityTaskTransitionInstance(ProcessInstanceEntity processInstance, ActivityInstanceEntity fromActivityInstance, BackwardTypeEnum backwardType, int backMostPreviouslyActivityInstanceID, string transitionGUID, TransitionTypeEnum transitionType, TransitionFlyingTypeEnum flyingType, ActivityResource activityResource, IDbSession session) { //实例化Activity var toActivityInstance = base.CreateBackwardToActivityInstanceObject(processInstance, backwardType, backMostPreviouslyActivityInstanceID, activityResource.AppRunner); //进入运行状态 toActivityInstance.ActivityState = (short)ActivityStateEnum.Ready; toActivityInstance.AssignedToUsers = base.GenerateActivityAssignedUsers( activityResource.NextActivityPerformers[base.BackwardContext.BackwardToTaskActivity.ActivityGUID]); //插入活动实例数据 base.ActivityInstanceManager.Insert(toActivityInstance, session); //插入任务数据 base.CreateNewTask(toActivityInstance, activityResource, session); //插入转移数据 base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, toActivityInstance, transitionType, flyingType, activityResource.AppRunner, session); }
/// <summary> /// 工作流运行 /// </summary> /// <param name="session"></param> /// <param name="runner"></param> /// <returns></returns> public WfExecutedResult RunProcess(IDbSession session, WfAppRunner runner, IDictionary<string, string> conditions = null) { var result = new WfExecutedResult(); var wfService = new WorkflowService(); var nodeViewList = wfService.GetNextActivityTree(runner, conditions).ToList<NodeView>(); foreach (var node in nodeViewList) { var performerList = wfService.GetPerformerList(node); //根据节点角色定义,读取执行者列表 Dictionary<string, PerformerList> dict = new Dictionary<string, PerformerList>(); dict.Add(node.ActivityGUID, performerList); runner.NextActivityPerformers = dict; if (node.IsSkipTo == true) { result = wfService.JumpProcess(session.Connection, runner, session.Transaction); } else { result = wfService.RunProcessApp(session.Connection, runner, session.Transaction); } } return result; }
/// <summary> /// 活动实例被读取 /// </summary> /// <param name="activityInstanceID"></param> /// <param name="logonUser"></param> /// <param name="session"></param> internal void SetActivityRead(int activityInstanceID, string userID, string userName, IDbSession session) { SetActivityState(activityInstanceID, ActivityStateEnum.Running, userID, userName, session); }
internal int Insert(ActivityInstanceEntity entity, IDbSession session) { int newID = Repository.Insert(session.Connection, entity, session.Transaction); entity.ID = newID; return newID; }
/// <summary> /// 撤销活动实例 /// </summary> /// <param name="activityInstanceID"></param> /// <param name="runner"></param> /// <param name="session"></param> internal void Withdraw(int activityInstanceID, WfAppRunner runner, IDbSession session) { SetActivityState(activityInstanceID, ActivityStateEnum.Withdrawed, runner.UserID, runner.UserName, session); }
internal abstract void ExecuteInstanceImp(IDbSession session);
/// <summary> /// 插入连线实例的方法 /// </summary> /// <param name="processInstance"></param> /// <param name="fromToTransition"></param> /// <param name="fromActivityInstance"></param> /// <param name="toActivityInstance"></param> /// <param name="conditionParseResult"></param> /// <param name="wfLinqDataContext"></param> /// <returns></returns> internal virtual void InsertTransitionInstance(ProcessInstanceEntity processInstance, string transitionGUID, ActivityInstanceEntity fromActivityInstance, ActivityInstanceEntity toActivityInstance, TransitionTypeEnum transitionType, TransitionFlyingTypeEnum flyingType, WfAppRunner runner, IDbSession session) { var tim = new TransitionInstanceManager(); var transitionInstanceObject = tim.CreateTransitionInstanceObject(processInstance, transitionGUID, fromActivityInstance, toActivityInstance, transitionType, flyingType, runner, (byte)ConditionParseResultEnum.Passed); tim.Insert(session.Connection, transitionInstanceObject, session.Transaction); }
internal NodeMediatorOrSplit(ActivityEntity activity, ProcessModel processModel, IDbSession session) : base(activity, processModel, session) { }
public static void WriteDbSessionOpenAfter(this DiagnosticListener @this, Guid operationId, IDbSession dbSession , [CallerMemberName] string operation = "") { if (@this.IsEnabled(SMART_SQL_AFTER_DB_SESSION_OPEN)) { @this.Write(SMART_SQL_AFTER_DB_SESSION_OPEN, new DbSessionOpenAfterEventData(operationId, operation) { DbSession = dbSession }); } }
public static void WriteDbSessionDisposeError(this DiagnosticListener @this, Guid operationId, IDbSession dbSession , Exception ex, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SMART_SQL_ERROR_DB_SESSION_DISPOSE)) { @this.Write(SMART_SQL_ERROR_DB_SESSION_DISPOSE, new DbSessionDisposeErrorEventData(operationId, operation) { DbSession = dbSession, Exception = ex }); } }
internal NodeSendBackToMISPrevious(SendBackOperation sendbackOperation, IDbSession session) : base(sendbackOperation, session) { }
/// <summary> /// OrJoin合并时的节点完成方法 /// 1. 如果有满足条件的OrJoin前驱转移,则会重新生成新的OrJoin节点实例 /// </summary> /// <param name="processInstance">流程实例</param> /// <param name="transitionGUID">转移GUID</param> /// <param name="fromActivity">起始活动</param> /// <param name="fromActivityInstance">起始活动实例</param> /// <param name="runner">运行者</param> /// <param name="session">会话</param> public NodeAutoExecutedResult CompleteAutomaticlly(ProcessInstanceEntity processInstance, string transitionGUID, ActivityEntity fromActivity, ActivityInstanceEntity fromActivityInstance, WfAppRunner runner, IDbSession session) { NodeAutoExecutedResult result = NodeAutoExecutedResult.CreateGatewayExecutedResult(NodeAutoExecutedStatus.Unknown); //检查是否有运行中的合并节点实例 ActivityInstanceEntity joinNode = base.ActivityInstanceManager.GetActivityRunning( processInstance.ID, base.GatewayActivity.ActivityGUID, session); if (joinNode == null) { joinNode = base.CreateActivityInstanceObject(base.GatewayActivity, processInstance, runner); //计算总需要的Token数目 joinNode.TokensRequired = GetTokensRequired(processInstance.ID, base.GatewayActivity); joinNode.TokensHad = 1; //进入运行状态 joinNode.ActivityState = (short)ActivityStateEnum.Running; joinNode.GatewayDirectionTypeID = (short)GatewayDirectionEnum.OrJoin; //写入默认第一次的预选步骤用户列表 joinNode.NextStepPerformers = NextStepUtility.SerializeNextStepPerformers(runner.NextActivityPerformers); base.InsertActivityInstance(joinNode, session); base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, joinNode, TransitionTypeEnum.Forward, TransitionFlyingTypeEnum.NotFlying, runner, session); } else { //更新节点的活动实例属性 joinNode.TokensHad += 1; base.GatewayActivityInstance = joinNode; //更新Token数目 base.ActivityInstanceManager.IncreaseTokensHad(base.GatewayActivityInstance.ID, runner, session); base.InsertTransitionInstance(processInstance, transitionGUID, fromActivityInstance, joinNode, TransitionTypeEnum.Forward, TransitionFlyingTypeEnum.NotFlying, runner, session); } //判断是否到达合并节点的通过Token数目要求 if (joinNode.TokensHad == joinNode.TokensRequired) { //如果达到完成节点的Token数,则设置该节点状态为完成 base.CompleteActivityInstance(base.GatewayActivityInstance.ID, runner, session); base.GatewayActivityInstance.ActivityState = (short)ActivityStateEnum.Completed; result = NodeAutoExecutedResult.CreateGatewayExecutedResult(NodeAutoExecutedStatus.Successed); } else if (joinNode.TokensHad < joinNode.TokensRequired) { result = NodeAutoExecutedResult.CreateGatewayExecutedResult(NodeAutoExecutedStatus.WaitingForOthersJoin); } return(result); }
internal NodeMediatorOrJoin(ActivityEntity activity, IProcessModel processModel, IDbSession session) : base(activity, processModel, session) { }
internal NodeMediatorAndSplit(ActivityEntity activity, ProcessModel processModel, IDbSession session) : base(activity, processModel, session) { }
public UpdateTagCommandInvoker(IDbSession db) { this._db = db; }
internal void Update(ActivityInstanceEntity entity, IDbSession session) { Repository.Update(session.Connection, entity, session.Transaction); }
/// <summary> /// 设置活动实例状态 /// </summary> /// <param name="activityInstanceID"></param> /// <param name="nodeState"></param> /// <param name="runner"></param> /// <param name="session"></param> private void SetActivityState(int activityInstanceID, ActivityStateEnum nodeState, string userID, string userName, IDbSession session) { var activityInstance = GetById(activityInstanceID); activityInstance.ActivityState = (short)nodeState; activityInstance.LastUpdatedByUserID = userID; activityInstance.LastUpdatedByUserName = userName; activityInstance.LastUpdatedDateTime = System.DateTime.Now; Update(activityInstance, session); }
public static Guid WriteDbSessionBeginTransactionBefore(this DiagnosticListener @this, IDbSession dbSession , [CallerMemberName] string operation = "") { if ([email protected](SMART_SQL_BEFORE_DB_SESSION_BEGINTRANSACTION)) { return(Guid.Empty); } var operationId = Guid.NewGuid(); @this.Write(SMART_SQL_BEFORE_DB_SESSION_BEGINTRANSACTION, new DbSessionBeginTransactionBeforeEventData(operationId, operation) { DbSession = dbSession }); return(operationId); }
/// <summary> /// 节点对象的完成方法 /// </summary> /// <param name="ActivityInstanceID"></param> /// <param name="activityResource"></param> /// <param name="wfLinqDataContext"></param> internal virtual void CompleteActivityInstance(int ActivityInstanceID, ActivityResource activityResource, IDbSession session) { //设置完成状态 ActivityInstanceManager.Complete(ActivityInstanceID, activityResource.AppRunner, session); }
public static void WriteDbSessionBeginTransactionError(this DiagnosticListener @this, Guid operationId, IDbSession dbSession , Exception ex, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SMART_SQL_ERROR_DB_SESSION_BEGINTRANSACTION)) { @this.Write(SMART_SQL_ERROR_DB_SESSION_BEGINTRANSACTION, new DbSessionBeginTransactionErrorEventData(operationId, operation) { DbSession = dbSession, Exception = ex }); } }
internal NodeMediatorEnd(ActivityForwardContext forwardContext, IDbSession session) : base(forwardContext, session) { }
public CardAccountRepository(IDbSession session) : base(session) { SqlConf = new SqlConfEntity { area = "card", group = "account" }; }
/// <summary> /// 退回活动实例 /// </summary> /// <param name="activityInstanceID"></param> /// <param name="runner"></param> /// <param name="session"></param> internal void SendBack(int activityInstanceID, WfAppRunner runner, IDbSession session) { SetActivityState(activityInstanceID, ActivityStateEnum.Sendbacked, runner.UserID, runner.UserName, session); }
/// <summary> /// 向前流转时的NodeMediator的构造函数 /// </summary> /// <param name="forwardContext"></param> /// <param name="session"></param> internal NodeMediator(ActivityForwardContext forwardContext, IDbSession session) { _activityForwardContext = forwardContext; _session = session; Linker.FromActivity = forwardContext.Activity; }
/// <summary> /// 获取运行状态的活动实例 /// </summary> /// <param name="activityGUID"></param> /// <returns></returns> internal ActivityInstanceEntity GetActivityRunning(int processInstanceID, string activityGUID, IDbSession session) { return(GetActivityByState(processInstanceID, activityGUID, ActivityStateEnum.Running, session)); }
/// <summary> /// 退回处理时的NodeMediator的构造函数 /// </summary> /// <param name="backwardContext"></param> /// <param name="session"></param> internal NodeMediator(BackwardContext backwardContext, IDbSession session) { _session = session; _backwardContext = backwardContext; Linker.FromActivity = backwardContext.BackwardFromActivity; }
/// <summary>初始化</summary> /// <param name="session"></param> /// <param name="innerException"></param> public XDbSessionException(IDbSession session, Exception innerException) : base(session.Database, innerException) { _Session = session; }
public AllBlogPostViewProjection(IDbSession db) { this._db = db; }
/// <summary> /// 退回活动实例 /// </summary> /// <param name="activityInstanceID"></param> /// <param name="runner"></param> /// <param name="session"></param> internal void SendBack(int activityInstanceID, WfAppRunner runner, IDbSession session) { SetActivityState(activityInstanceID, ActivityStateEnum.Sendbacked, runner.UserID, runner.UserName, session); }
public static int DyUpdate <TEntity>(this IDbSession dbSession, object entity) { return(DyUpdate <TEntity>(dbSession, entity, null)); }
/// <summary>初始化</summary> /// <param name="session"></param> /// <param name="message"></param> /// <param name="innerException"></param> public XDbSessionException(IDbSession session, String message, Exception innerException) : base(session.Database, message, innerException) { _Session = session; }
public static int Update <TEntity>(this IDbSession dbSession, TEntity entity, bool enablePropertyChangedTrack) { return(DyUpdate <TEntity>(dbSession, entity, enablePropertyChangedTrack)); }
/// <summary> /// 撤销活动实例 /// </summary> /// <param name="activityInstanceID"></param> /// <param name="runner"></param> /// <param name="session"></param> internal void Withdraw(int activityInstanceID, WfAppRunner runner, IDbSession session) { SetActivityState(activityInstanceID, ActivityStateEnum.Withdrawed, runner.UserID, runner.UserName, session); }
public GenreService(IDbSession session) : base(session) { }
/// <summary>初始化</summary> /// <param name="session"></param> /// <param name="message"></param> public XDbSessionException(IDbSession session, String message) : base(session == null ? null : session.Database, message) { _Session = session; }
internal MenuColumnSet(IDbSession dbSession) { _dbSession = dbSession; Init(); }
/// <summary>初始化</summary> /// <param name="session"></param> public XDbSessionException(IDbSession session) : base(session == null ? null : session.Database) { _Session = session; }
internal RoleDataSet(IDbSession dbSession) { _dbSession = dbSession; Init(); }
/// <summary> /// 插入实例数据 /// </summary> /// <param name="activityInstance"></param> /// <param name="wfLinqDataContext"></param> internal virtual void InsertActivityInstance(ActivityInstanceEntity activityInstance, IDbSession session) { ActivityInstanceManager.Insert(activityInstance, session); }
public OrderService(IDbSession dbSession, IOrderRepository repository) : base(dbSession, repository) { }
internal NodeMediatorGateway(ActivityEntity gActivity, ProcessModel processModel, IDbSession session) { _gatewayActivity = gActivity; _processModel = processModel; _session = session; }
internal void Update(ActivityInstanceEntity entity, IDbSession session) { Repository.Update(session.Connection, entity, session.Transaction); }
internal NodeMediator(IDbSession session) { _session = session; }
public static TEntity GetById <TEntity, TPrimaryKey>(this IDbSession dbSession, TPrimaryKey id) { return(GetById <TEntity, TPrimaryKey>(dbSession, id, false)); }