using Learun.Application.Base.AuthorizeModule;
using Learun.Application.Organization;
using Learun.Util;
using System;
using System.Collections.Generic;
namespace Learun.Application.WorkFlow
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:陈彬彬
/// 日 期:2017.04.17
/// 描 述:任务实例
///
public class WfTaskBLL : WfTaskIBLL
{
private WfTaskService wfTaskService = new WfTaskService();
private UserIBLL userIBLL = new UserBLL();
private UserRelationIBLL userRelationIBLL = new UserRelationBLL();
#region 获取数据
///
/// 获取未完成的流程实例任务列表
///
/// 流程实例主键
///
public IEnumerable GetList(string processId)
{
try
{
return wfTaskService.GetList(processId);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取当前任务节点主键
///
/// 流程实例主键
///
public List GetCurrentNodeIds(string processId)
{
try
{
return wfTaskService.GetCurrentNodeIds(processId);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取任务实体
///
/// 主键
///
public WfTaskEntity GetEntity(string keyValue)
{
try
{
return wfTaskService.GetEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取任务实体
///
/// 流程实例主键
/// 节点主键
///
public WfTaskEntity GetEntity(string processId, string nodeId)
{
try
{
return wfTaskService.GetEntity(processId, nodeId);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取任务实体
///
/// 流程实例主键
/// 节点主键
///
public WfTaskEntity GetEntityUnFinish(string processId, string nodeId)
{
try
{
return wfTaskService.GetEntityUnFinish(processId, nodeId);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取委托信息列表
///
///
///
public List GetDelegateTask(string userId)
{
try
{
List list = wfTaskService.GetDelegateTask(userId);
foreach (var item in list)
{
UserEntity userEntity = userIBLL.GetEntityByUserId(item.userId);
item.companyId = userEntity.F_CompanyId;
item.departmentId = userEntity.F_DepartmentId;
item.roleIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 1);
item.postIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 2);
}
return list;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取未处理任务列表
///
/// 用户信息
/// 翻页信息
/// 查询条件
///
public IEnumerable GetActiveList(UserInfo userInfo, Pagination pagination, string queryJson)
{
try
{
List delegateList = GetDelegateTask(userInfo.userId);
return wfTaskService.GetActiveList(userInfo, pagination, queryJson, delegateList);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取已处理任务列表
///
/// 用户主键
/// 翻页信息
/// 查询条件
///
public IEnumerable GetHasList(string userId, Pagination pagination, string queryJson)
{
try
{
return wfTaskService.GetHasList(userId, pagination, queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 保存或更新流程实例任务
///
/// 主键
/// 实体
public void SaveEntity(WfTaskEntity entity)
{
try
{
wfTaskService.SaveEntity(entity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 保存或更新流程实例任务
///
/// 实体
/// 公司主键
/// 部门主键
public void SaveEntitys(WfTaskEntity entity, string companyId, string departmentId)
{
try
{
wfTaskService.SaveEntitys(entity, companyId, departmentId);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 更新任务状态
///
/// 主键
/// 状态 1 完成 2 关闭(会签
public void UpdateState(string keyValue, int state)
{
try
{
wfTaskService.UpdateState(keyValue, state);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 更新任务完成状态
///
/// 流程实例主键
/// 节点主键
/// 任务节点Id
/// 用户主键
/// 用户名称
public void UpdateStateByNodeId(string processId, string nodeId, string taskId, string userId, string userName)
{
try
{
wfTaskService.UpdateStateByNodeId(processId, nodeId, taskId, userId, userName);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
}
}