You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IMSysUserBLL.cs 6.0 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using Learun.Util;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Learun.Application.IM
  5. {
  6. /// <summary>
  7. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  8. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  9. /// 创建人:力软-框架开发组
  10. /// 日 期:2018.05.30
  11. /// 描 述:即时通讯用户注册
  12. /// </summary>
  13. public class IMSysUserBLL: IMSysUserIBLL
  14. {
  15. private IMSysUserService iMSysUserService = new IMSysUserService();
  16. private IMMsgService iMMsgService = new IMMsgService();
  17. #region 获取数据
  18. /// <summary>
  19. /// 获取列表数据
  20. /// </summary>
  21. /// <param name="keyWord">查询关键字</param>
  22. /// <returns></returns>
  23. public IEnumerable<IMSysUserEntity> GetList(string keyWord)
  24. {
  25. try
  26. {
  27. return iMSysUserService.GetList(keyWord);
  28. }
  29. catch (Exception ex)
  30. {
  31. if (ex is ExceptionEx)
  32. {
  33. throw;
  34. }
  35. else
  36. {
  37. throw ExceptionEx.ThrowBusinessException(ex);
  38. }
  39. }
  40. }
  41. /// <summary>
  42. /// 获取列表分页数据
  43. /// <param name="pagination">分页参数</param>
  44. /// <param name="keyWord">查询关键字</param>
  45. /// <summary>
  46. /// <returns></returns>
  47. public IEnumerable<IMSysUserEntity> GetPageList(Pagination pagination, string keyWord)
  48. {
  49. try
  50. {
  51. return iMSysUserService.GetPageList(pagination,keyWord);
  52. }
  53. catch (Exception ex)
  54. {
  55. if (ex is ExceptionEx)
  56. {
  57. throw;
  58. }
  59. else
  60. {
  61. throw ExceptionEx.ThrowBusinessException(ex);
  62. }
  63. }
  64. }
  65. /// <summary>
  66. /// 获取实体数据
  67. /// <param name="keyValue">主键</param>
  68. /// <summary>
  69. /// <returns></returns>
  70. public IMSysUserEntity GetEntity(string keyValue)
  71. {
  72. try
  73. {
  74. return iMSysUserService.GetEntity(keyValue);
  75. }
  76. catch (Exception ex)
  77. {
  78. if (ex is ExceptionEx)
  79. {
  80. throw;
  81. }
  82. else
  83. {
  84. throw ExceptionEx.ThrowBusinessException(ex);
  85. }
  86. }
  87. }
  88. #endregion
  89. #region 提交数据
  90. /// <summary>
  91. /// 删除实体数据(虚拟)
  92. /// <param name="keyValue">主键</param>
  93. /// <summary>
  94. /// <returns></returns>
  95. public void DeleteEntity(string keyValue)
  96. {
  97. try
  98. {
  99. iMSysUserService.DeleteEntity(keyValue);
  100. }
  101. catch (Exception ex)
  102. {
  103. if (ex is ExceptionEx)
  104. {
  105. throw;
  106. }
  107. else
  108. {
  109. throw ExceptionEx.ThrowBusinessException(ex);
  110. }
  111. }
  112. }
  113. /// <summary>
  114. /// 保存实体数据(新增、修改)
  115. /// <param name="keyValue">主键</param>
  116. /// <summary>
  117. /// <returns></returns>
  118. public void SaveEntity(string keyValue, IMSysUserEntity entity)
  119. {
  120. try
  121. {
  122. iMSysUserService.SaveEntity(keyValue, entity);
  123. }
  124. catch (Exception ex)
  125. {
  126. if (ex is ExceptionEx)
  127. {
  128. throw;
  129. }
  130. else
  131. {
  132. throw ExceptionEx.ThrowBusinessException(ex);
  133. }
  134. }
  135. }
  136. #endregion
  137. #region 验证数据
  138. /// <summary>
  139. /// 规则编号不能重复
  140. /// </summary>
  141. /// <param name="code">编号</param>
  142. /// <param name="keyValue">主键</param>
  143. /// <returns></returns>
  144. public bool ExistEnCode(string code, string keyValue)
  145. {
  146. try
  147. {
  148. return iMSysUserService.ExistEnCode(code, keyValue);
  149. }
  150. catch (Exception ex)
  151. {
  152. if (ex is ExceptionEx)
  153. {
  154. throw;
  155. }
  156. else
  157. {
  158. throw ExceptionEx.ThrowBusinessException(ex);
  159. }
  160. }
  161. }
  162. #endregion
  163. #region 扩展方法
  164. /// <summary>
  165. /// 发送消息
  166. /// </summary>
  167. /// <param name="code">编码</param>
  168. /// <param name="userIdList">用户列表</param>
  169. /// <param name="content">消息内容</param>
  170. public void SendMsg(string code, List<string> userIdList, string content) {
  171. try
  172. {
  173. if (!string.IsNullOrEmpty(content) && userIdList.Count >0) {
  174. IMSysUserEntity entity = iMSysUserService.GetEntityByCode(code);
  175. if (entity != null) {
  176. foreach (var userId in userIdList) {
  177. IMMsgEntity iMMsgEntity = new IMMsgEntity();
  178. iMMsgEntity.F_SendUserId = code;
  179. iMMsgEntity.F_RecvUserId = userId;
  180. iMMsgEntity.F_Content = content;
  181. iMMsgService.SaveEntity(iMMsgEntity);
  182. SendHubs.callMethod("sendMsg2", code, userId, content, 1);
  183. }
  184. }
  185. }
  186. }
  187. catch (Exception ex)
  188. {
  189. if (ex is ExceptionEx)
  190. {
  191. throw;
  192. }
  193. else
  194. {
  195. throw ExceptionEx.ThrowBusinessException(ex);
  196. }
  197. }
  198. }
  199. #endregion
  200. }
  201. }