using Learun.Application.Base.AuthorizeModule;
using Learun.Application.Base.SystemModule;
using Learun.Util;
using System;
using System.Collections.Generic;
using Learun.Application.AppMagager.Function;
namespace Learun.Application.AppMagager
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:陈彬彬
/// 日 期:2018.03.16
/// 描 述:移动端功能管理
///
public class FunctionBLL: FunctionIBLL
{
private FunctionSerivce functionSerivce = new FunctionSerivce();
private DataItemIBLL dataItemIBLL = new DataItemBLL();
private AuthorizeIBLL authorizeIBLL = new AuthorizeBLL();
#region 获取数据
public IEnumerable GetDesktopList(string type)
{
try
{
return functionSerivce.GetDesktopList(type);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取分页列表
///
/// 分页参数
/// 关键字
/// 分类
///
public IEnumerable GetPageList(Pagination pagination, string keyword, string type)
{
try
{
return functionSerivce.GetPageList(pagination, keyword, type);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取列表数据
///
///
public IEnumerable GetList(UserInfo userInfo)
{
try
{
List list = (List)functionSerivce.GetList();
/*关联权限*/
if (!userInfo.isSystem)
{
string objectIds = userInfo.userId + (string.IsNullOrEmpty(userInfo.roleIds) ? "" : ("," + userInfo.roleIds));
List itemIdList = authorizeIBLL.GetItemIdListByobjectIds(objectIds, 5);
list = list.FindAll(t => itemIdList.IndexOf(t.F_Id) >= 0);
}
return list;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取实体对象
///
/// 主键
///
public FunctionEntity GetEntity(string keyValue)
{
try
{
return functionSerivce.GetEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取移动功能模板
///
/// 主键
///
public FunctionSchemeEntity GetScheme(string keyValue)
{
try
{
return functionSerivce.GetScheme(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取树形移动功能列表
///
///
public List GetCheckTree()
{
try
{
List treeList = new List();
var dataItemList = dataItemIBLL.GetDetailList("function");
UserInfo userInfo = LoginUserInfo.Get();
var list = GetList(userInfo);
Dictionary> map = new Dictionary>();
foreach (var item in list)
{
if (!map.ContainsKey(item.F_Type))
{
map[item.F_Type] = new List();
}
TreeModel treeItem = new TreeModel();
treeItem.id = item.F_Id;
treeItem.text = item.F_Name;
treeItem.value = item.F_Id;
treeItem.showcheck = true;
treeItem.checkstate = 0;
treeItem.parentId = item.F_Type + "_MKDataItem";
map[item.F_Type].Add(treeItem);
treeItem.complete = true;
}
foreach (var item in dataItemList)
{
if (map.ContainsKey(item.F_ItemValue))
{
TreeModel treeItem = new TreeModel();
treeItem.id = item.F_ItemValue + "_MKDataItem";
treeItem.text = item.F_ItemName;
treeItem.value = item.F_ItemValue + "_MKDataItem";
treeItem.showcheck = true;
treeItem.checkstate = 0;
treeItem.parentId = "0";
treeItem.hasChildren = true;
treeItem.complete = true;
treeItem.isexpand = true;
treeItem.ChildNodes = map[item.F_ItemValue];
treeList.Add(treeItem);
}
}
return treeList;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 删除
///
/// 主键
public void Delete(string keyValue)
{
try
{
functionSerivce.Delete(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 保存
///
/// 主键
/// 功能信息
/// 功能模板信息
public void SaveEntity(string keyValue, FunctionEntity functionEntity, FunctionSchemeEntity functionSchemeEntity)
{
try
{
functionSerivce.SaveEntity(keyValue, functionEntity, functionSchemeEntity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 更新状态
///
/// 模板信息主键
/// 状态1启用0禁用
public void UpdateState(string keyValue, int state)
{
try
{
functionSerivce.UpdateState(keyValue, state);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
}
}