/// <summary> /// 发送消息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="receiverId">接收者主键</param> /// <param name="contents">内容</param> /// <returns>主键</returns> public string Send(BaseUserInfo userInfo, string receiverId, string contents) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif string returnValue = string.Empty; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.Id = Guid.NewGuid().ToString(); messageEntity.CategoryCode = MessageCategory.Send.ToString(); messageEntity.FunctionCode = MessageFunction.Message.ToString(); messageEntity.ReceiverId = receiverId; messageEntity.Contents = contents; messageEntity.IsNew = (int)MessageStateCode.New; messageEntity.ReadCount = 0; messageEntity.DeletionStateCode = 0; messageEntity.Enabled = 1; BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); messageManager.Send(messageEntity, true); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_Send, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 发送消息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="receiverId">接收者主键</param> /// <param name="contents">内容</param> /// <param name="functionCode">内容</param> /// <returns>主键</returns> public string Send(BaseUserInfo userInfo, string receiverId, string contents, string functionCode) { string result = string.Empty; var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) => { var manager = new BaseMessageManager(dbHelper, userInfo); BaseMessageEntity entity = manager.Send(receiverId, contents, functionCode); result = entity.Id; }); return(result); }