using Learun.Cache.Base;
using Learun.Cache.Factory;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Data;
namespace Learun.Application.Language
{
///
/// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
/// Copyright (c) 2013-2018 上海力软信息技术有限公司
/// 创 建:超级管理员
/// 日 期:2018-04-10 15:00
/// 描 述:语言映照
///
public class LGMapBLL : LGMapIBLL
{
private LGMapService lGMapService = new LGMapService();
#region 缓存设置
private ICache cache = CacheFactory.CaChe();
private string cacheKey = "learun_adms_lg_"; // + 语言类型编码
#endregion
#region 获取数据
///
/// 获取语言包映射关系数据集合
/// 语言包编码
/// 是否是主语言
///
///
public Dictionary GetMap(string Code,bool isMain)
{
try
{
Dictionary list = cache.Read>(cacheKey + Code, CacheId.language);
if (list == null)
{
list = new Dictionary();
var _list = lGMapService.GetDataList(Code);
if (isMain)
{
foreach (var item in _list)
{
if (!list.ContainsKey(item.name))
{
list.Add(item.name, item.id);
}
}
}
else {
foreach (var item in _list)
{
if (!list.ContainsKey(item.id))
{
list.Add(item.id, item.name);
}
}
}
cache.Write>(cacheKey + Code, list, CacheId.language);
}
return list;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取列表数据
/// 编码
///
///
public IEnumerable GetListByTypeCode(string TypeCode)
{
try
{
return lGMapService.GetListByTypeCode(TypeCode);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取列表数据
///
///
public IEnumerable GetList(string queryJson)
{
try
{
return lGMapService.GetList(queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取列表分页数据
/// 分页参数
/// 语言类型列表
///
///
public DataTable GetPageList(Pagination pagination, string queryJson, string typeList)
{
try
{
return lGMapService.GetPageList(pagination, queryJson, typeList);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取实体数据
/// 主键
///
///
public LGMapEntity GetEntity(string keyValue)
{
try
{
return lGMapService.GetEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 根据名称获取列表
/// F_Name
///
///
public IEnumerable GetListByName(string keyValue)
{
try
{
return lGMapService.GetListByName(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 根据名称与类型获取列表
/// F_Name
/// typeCode
///
///
public IEnumerable GetListByNameAndType(string keyValue, string typeCode)
{
try
{
return lGMapService.GetListByNameAndType(keyValue, typeCode);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 删除实体数据
/// 主键
///
///
public void DeleteEntity(string keyValue)
{
try
{
lGMapService.DeleteEntity(keyValue);
cache.RemoveAll(CacheId.language);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 保存实体数据(新增、修改)
/// 原列表
/// 新列表
/// F_Code
///
///
public void SaveEntity(string nameList, string newNameList, string code)
{
try
{
lGMapService.SaveEntity(nameList, newNameList, code);
cache.RemoveAll(CacheId.language);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
}
}