using Learun.Cache.Base;
using Learun.Cache.Factory;
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 WfProcessInstanceBLL : WfProcessInstanceIBLL
{
private WfProcessInstanceService wfProcessService = new WfProcessInstanceService();
#region 缓存定义
private ICache cache = CacheFactory.CaChe();
private string cacheKey = "Learun_adms_wfprocess_";// +实例主键
#endregion
#region 获取数据
///
/// 获取流程实例
///
/// 主键
///
public WfProcessInstanceEntity GetEntity(string keyValue)
{
try
{
WfProcessInstanceEntity entity = cache.Read(cacheKey + keyValue, CacheId.workflow);
if (entity == null)
{
entity = wfProcessService.GetEntity(keyValue);
cache.Write(cacheKey + keyValue, entity, CacheId.workflow);
}
return entity;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取流程信息列表
///
/// 分页参数
/// 查询条件
///
public IEnumerable GetPageList(Pagination pagination, string queryJson)
{
try
{
return wfProcessService.GetPageList(pagination, queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取我的流程信息列表
///
/// 用户主键
/// 分页参数
/// 查询条件
///
public IEnumerable GetMyPageList(string userId, Pagination pagination, string queryJson)
{
try
{
return wfProcessService.GetMyPageList(userId, pagination, queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取流程实例信息
///
/// 实例主键
///
public IEnumerable GetListByProcessIds(string processIds)
{
try
{
return wfProcessService.GetListByProcessIds(processIds);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 获取全部流程实例
///
///
///
public IEnumerable GetListByAllProcessIds(string processIds)
{
try
{
return wfProcessService.GetListByAllProcessIds(processIds);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 删除流程实例
///
///
public void DeleteEntity(string keyValue)
{
try
{
cache.Remove(cacheKey + keyValue, CacheId.workflow);
wfProcessService.DeleteEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 保存流程实例
///
/// 主键
/// 实体
public void SaveEntity(string keyValue, WfProcessInstanceEntity entity)
{
try
{
cache.Remove(cacheKey + keyValue, CacheId.workflow);
wfProcessService.SaveEntity(keyValue, entity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
}
}