/// <summary> /// 规则编号不能重复 /// </summary> /// <param name="code">编号</param> /// <param name="keyValue">主键</param> /// <returns></returns> public bool ExistEnCode(string code, string keyValue) { try { var strSql = new StringBuilder(); strSql.Append(" SELECT t.F_Id FROM LR_IM_SysUser t WHERE t.F_DeleteMark = 0 AND t.F_Code = @code "); if (!string.IsNullOrEmpty(keyValue)) { strSql.Append(" AND t.F_Id != @keyValue "); } IMSysUserEntity entity = this.BaseRepository().FindEntity <IMSysUserEntity>(strSql.ToString(), new { code = code, keyValue = keyValue }); return(entity == null ? true : false); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void SaveEntity(string keyValue, IMSysUserEntity entity) { try { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { entity.Create(); this.BaseRepository().Insert(entity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <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> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> 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); } } }
/// <summary> /// 删除实体数据(虚拟) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void DeleteEntity(string keyValue) { try { IMSysUserEntity entity = new IMSysUserEntity(); entity.F_Id = keyValue; entity.F_DeleteMark = 1; this.BaseRepository().Update(entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }