/// <summary> /// 根据状态获取活动实例 /// </summary> /// <param name="processInstanceID"></param> /// <param name="activityGUID"></param> /// <param name="activityState"></param> /// <param name="session"></param> /// <returns></returns> internal ActivityInstanceEntity GetActivityByState(int processInstanceID, string activityGUID, ActivityStateEnum activityState, IDbSession session) { var sql = @"SELECT * FROM WfActivityInstance WHERE ProcessInstanceID = @processInstanceID AND ActivityGUID = @activityGUID AND ActivityState = @state ORDER BY ID DESC"; var instanceList = Repository.Query <ActivityInstanceEntity>(session.Connection, sql, new { processInstanceID = processInstanceID, activityGUID = activityGUID.ToString(), state = (short)activityState }, session.Transaction).ToList(); if (instanceList.Count == 1) { return(instanceList[0]); } else { return(null); } }
/// <summary> /// 根据状态获取活动实例 /// </summary> /// <param name="processInstanceID">流程实例ID</param> /// <param name="activityGUID">活动GUID</param> /// <param name="activityState">活动状态</param> /// <param name="session">会话</param> /// <returns>活动实例</returns> internal ActivityInstanceEntity GetActivityByState(int processInstanceID, string activityGUID, ActivityStateEnum activityState, IDbSession session) { //activityState: 4-completed(完成) //var sql = @"SELECT * FROM WfActivityInstance // WHERE ProcessInstanceID = @processInstanceID // AND ActivityGUID = @activityGUID // AND ActivityState = @state // ORDER BY ID DESC"; ActivityInstanceEntity entity = null; var repository = session.GetRepository <ActivityInstanceEntity>(); var instanceList = repository.Query( e => e.ProcessInstanceID == processInstanceID && e.ActivityGUID == activityGUID && e.ActivityState == (short)activityState) .OrderByDescending(e => e.ID) .ToList(); if (instanceList != null && instanceList.Count == 1) { entity = instanceList[0]; } return(entity); }
/// <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, WfAppRunner runner, IDbSession session) { var activityInstance = GetById(activityInstanceID); activityInstance.ActivityState = (short)nodeState; activityInstance.LastUpdatedByUserID = runner.UserID; activityInstance.LastUpdatedByUserName = runner.UserName; activityInstance.LastUpdatedDateTime = System.DateTime.Now; Update(activityInstance, session); }
/// <summary> /// 设置活动实例状态 /// </summary> /// <param name="activityInstanceID">活动实例ID</param> /// <param name="nodeState">节点状态</param> /// <param name="runner">运行者</param> /// <param name="session">数据上下文</param> private void SetActivityState(int activityInstanceID, ActivityStateEnum nodeState, WfAppRunner runner, IDbSession session) { var entity = GetById(activityInstanceID); entity.ActivityState = (short)nodeState; entity.LastUpdatedByUserID = runner.UserID; entity.LastUpdatedByUserName = runner.UserName; entity.LastUpdatedDateTime = System.DateTime.Now; session.GetRepository <ActivityInstanceEntity>().Update(entity); session.SaveChanges(); }
internal IEnumerable <TaskViewEntity> GetProcessTasksWithState(int appInstanceID, int processInstanceID, ActivityStateEnum state) { string whereSql = @"WHERE ApplicationInstaceID=@appInstanceID AND ProcessInstanceID=@processInstanceID AND ActivityState=@state"; var list = Repository.Query <TaskViewEntity>(whereSql, new { appInstanceID = appInstanceID, processInstanceID = processInstanceID, state = state }); return(list); }
/// <summary> /// 设置状态为完成。 /// </summary> public void Complete() { State = ActivityStateEnum.Processed; }
/// <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); }
/// <summary> /// 根据状态获取活动实例 /// </summary> /// <param name="processInstanceID"></param> /// <param name="activityGUID"></param> /// <param name="activityState"></param> /// <param name="session"></param> /// <returns></returns> internal ActivityInstanceEntity GetActivityByState(int processInstanceID, string activityGUID, ActivityStateEnum activityState, IDbSession session) { var sql = @"SELECT * FROM WfActivityInstance WHERE ProcessInstanceID = @processInstanceID AND ActivityGUID = @activityGUID AND ActivityState = @state ORDER BY ActivityInstanceID DESC"; var instanceList = Repository.Query<ActivityInstanceEntity>(session.Connection, sql, new { processInstanceID = processInstanceID, activityGUID = activityGUID.ToString(), state = (short)activityState }, session.Transaction).ToList(); if (instanceList.Count == 1) { return instanceList[0]; } else { return null; } }
internal IEnumerable<TaskViewEntity> GetProcessTasksWithState(int appInstanceID, int processInstanceID, ActivityStateEnum state) { string whereSql = @"WHERE ApplicationInstaceID=@appInstanceID AND ProcessInstanceID=@processInstanceID AND ActivityState=@state"; var list = Repository.Query<TaskViewEntity>(whereSql, new { appInstanceID = appInstanceID, processInstanceID = processInstanceID, state = state }); return list; }