/// <summary> /// 发送消息 /// </summary> /// <param name="code">编码</param> /// <param name="userIdList">用户列表</param> /// <param name="content">消息内容</param> public void SendMsg(string code, List <string> 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); } } }
/// <summary> /// 发送消息 /// </summary> /// <param name="_"></param> /// <returns></returns> public Response SendMsg(dynamic _) { MsgModel msyModel = this.GetReqData <MsgModel>();// 获取模板请求数据 IMMsgEntity entity = new IMMsgEntity(); entity.F_SendUserId = userInfo.userId; entity.F_RecvUserId = msyModel.userId; entity.F_Content = msyModel.content; iMMsgIBLL.SaveEntity(entity); // 向即时消息服务器发送一条信息 SendHubs.callMethod("sendMsg2", userInfo.userId, msyModel.userId, msyModel.content, 0); var jsonData = new { time = entity.F_CreateDate, msgId = entity.F_MsgId }; return(Success(jsonData)); }
/// <summary> /// 更新实时通信用户列表 /// </summary> private void UpdateIMUserList(string keyValue, bool isAdd, UserEntity userEntity) { try { IMUserModel entity = new IMUserModel(); OrganizeBLL bll = new OrganizeBLL(); DepartmentBLL dbll = new DepartmentBLL(); entity.UserId = keyValue; if (userEntity != null) { //如果只是修改个人头像,下面只有头像一个数据不为null,其它都为空dbll.GetEntity(userEntity.DepartmentId).FullName;会抛异常 if (userEntity.RealName != null) { entity.RealName = userEntity.RealName; } if (userEntity.DepartmentId != null) { entity.DepartmentId = dbll.GetEntity(userEntity.DepartmentId).FullName; } if (userEntity.Gender != null) { entity.Gender = (int)userEntity.Gender; } if (userEntity.HeadIcon != null) { entity.HeadIcon = userEntity.HeadIcon; } if (userEntity.OrganizeId != null) { entity.OrganizeId = bll.GetEntity(userEntity.OrganizeId).FullName; } } SendHubs.callMethod("upDateUserList", entity, isAdd); } catch { } }
/// <summary> /// 更新实时通信用户列表 /// </summary> private void UpdateIMUserList(string keyValue, bool isAdd, AppUserEntity userEntity) { try { IMUserModel entity = new IMUserModel(); AppOrganizeBLL bll = new AppOrganizeBLL(); AppDepartmentBLL dbll = new AppDepartmentBLL(); entity.UserId = keyValue; if (userEntity != null) { entity.RealName = userEntity.UserName; entity.DepartmentId = "";// dbll.GetEntity(userEntity.DepartmentId).FullName; //entity.Gender = (int)userEntity.Gender; //entity.HeadIcon = userEntity.HeadIcon; //entity.OrganizeId = bll.GetEntity(userEntity.OrganizeId).FullName; ; } SendHubs.callMethod("upDateUserList", entity, isAdd); } catch { } }
/// <summary> /// 更新实时通信用户列表 /// </summary> private void UpdateIMUserList(string keyValue, bool isAdd, UserEntity userEntity) { try { IMUserModel entity = new IMUserModel(); OrganizeBLL bll = new OrganizeBLL(); DepartmentBLL dbll = new DepartmentBLL(); entity.F_UserId = keyValue; if (userEntity != null) { entity.F_RealName = userEntity.F_RealName; entity.F_DepartmentId = dbll.GetEntity(userEntity.F_DepartmentId).F_FullName; entity.F_Gender = (int)userEntity.F_Gender; entity.F_HeadIcon = userEntity.F_HeadIcon; entity.F_OrganizeId = bll.GetEntity(userEntity.F_OrganizeId).F_FullName;; } SendHubs.callMethod("upDateUserList", entity, isAdd); } catch { } }