using Learun.Util;
using System;
using System.Collections.Generic;
namespace Learun.Application.IM
{
///
/// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
/// Copyright (c) 2013-2018 上海力软信息技术有限公司
/// 创建人:力软-框架开发组
/// 日 期:2018.05.30
/// 描 述:即时通讯用户注册
///
public class IMSysUserBLL: IMSysUserIBLL
{
private IMSysUserService iMSysUserService = new IMSysUserService();
private IMMsgService iMMsgService = new IMMsgService();
#region 获取数据
///
/// 获取列表数据
///
/// 查询关键字
///
public IEnumerable GetList(string keyWord)
{
try
{
return iMSysUserService.GetList(keyWord);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取列表分页数据
/// 分页参数
/// 查询关键字
///
///
public IEnumerable GetPageList(Pagination pagination, string keyWord)
{
try
{
return iMSysUserService.GetPageList(pagination,keyWord);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 获取实体数据
/// 主键
///
///
public IMSysUserEntity GetEntity(string keyValue)
{
try
{
return iMSysUserService.GetEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 删除实体数据(虚拟)
/// 主键
///
///
public void DeleteEntity(string keyValue)
{
try
{
iMSysUserService.DeleteEntity(keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
public void SaveEntity(string keyValue, IMSysUserEntity entity)
{
try
{
iMSysUserService.SaveEntity(keyValue, entity);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
#region 验证数据
///
/// 规则编号不能重复
///
/// 编号
/// 主键
///
public bool ExistEnCode(string code, string keyValue)
{
try
{
return iMSysUserService.ExistEnCode(code, keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
#region 扩展方法
///
/// 发送消息
///
/// 编码
/// 用户列表
/// 消息内容
public void SendMsg(string code, List userIdList, string content) {
try
{
if (!string.IsNullOrEmpty(content) && userIdList.Count >0) {
IMSysUserEntity entity = iMSysUserService.GetEntityByCode(code);
if (entity != null) {
foreach (var userId in userIdList) {
IMMsgEntity iMMsgEntity = new IMMsgEntity();
iMMsgEntity.F_SendUserId = code;
iMMsgEntity.F_RecvUserId = userId;
iMMsgEntity.F_Content = content;
iMMsgService.SaveEntity(iMMsgEntity);
SendHubs.callMethod("sendMsg2", code, userId, content, 1);
}
}
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
}
}