public object AcceptMsgList(SendMsgListRequest req) { Stopwatch stop = new Stopwatch(); stop.Start(); object response; string retMsg = string.Empty; try { var ret = _msgServiceLazy.Value.AcceptMsgList(req, out retMsg); if (ret == ErrCode.Sucess) { response = this.Success(true); } else { response = this.Error(ret, retMsg); } } catch (Exception ex) { response = this.Error(ErrCode.Failure, ex.Message.ToString()); } stop.Stop(); //LogHelper.Info.Write("SendList", "Time=" + DateTime.Now.ToString("HH:mm:ss,fff") + "\r\n" + resJson + "\r\n TimeSpan:" + stop.ElapsedMilliseconds.ToString()); return(response); }
/// <summary> /// 接收外部推送消息,如果时效时间为空。默认24小时 /// </summary> /// <param name="model"></param> /// <param name="retMsg"></param> /// <returns></returns> public ErrCode AcceptMsgList(SendMsgListRequest model, out string retMsg) { retMsg = string.Empty; ErrCode errorCode = CheckAcceptMsg(model, out retMsg); if (errorCode != ErrCode.Sucess) { return(errorCode); } int length = model.TokenList.Count; //判断接收人的个数是否超出上限 var tokenMaxNum = Convert.ToInt32(_configLogic.GetConfigValue(ConfigKey.TokenMaxNum)); if (length > tokenMaxNum) { retMsg = string.Format("Token的个数太多,网关限制上限:{0}", tokenMaxNum); return(ErrCode.Failure); } List <SendMsgRequest> sendMsgRequestList = new List <SendMsgRequest>(); foreach (var item in model.TokenList) { SendMsgRequest sendMsgRequest = _mapper.Map <SendMsgRequest>(model); sendMsgRequest.Token = item; sendMsgRequestList.Add(sendMsgRequest); } AcceptMsgListToTheardPool(sendMsgRequestList, out retMsg); return(ErrCode.Sucess); }
public void MsgToTheardPoolByTokenList(List <string> tokenList, SendMsgListRequest model, out string retMsg) { List <SendMsgRequest> sendMsgRequestList = new List <SendMsgRequest>(); foreach (var item in tokenList) { SendMsgRequest sendMsgRequest = _mapper.Map <SendMsgRequest>(model); sendMsgRequest.Token = item; sendMsgRequestList.Add(sendMsgRequest); } AcceptMsgListToTheardPool(sendMsgRequestList, out retMsg); }
/// <summary> /// 接受外部推送消息,推送全部用户 /// </summary> /// <param name="model"></param> /// <param name="retMsg"></param> /// <returns></returns> public ErrCode AcceptAllMsgList(SendMsgListRequest model, out string retMsg) { retMsg = string.Empty; ErrCode errorCode = CheckAcceptMsg(model, out retMsg); if (errorCode != ErrCode.Sucess) { return(errorCode); } var tokenList = model.TokenList; //判断接收人的个数是否超出上限 var tokenMaxNum = Convert.ToInt32(_configLogic.GetConfigValue(ConfigKey.TokenMaxNum)); while (tokenList.Count > tokenMaxNum) { var partTokenList = tokenList.GetRange(0, tokenMaxNum); MsgToTheardPoolByTokenList(partTokenList, model, out retMsg); tokenList.RemoveRange(0, tokenMaxNum); } MsgToTheardPoolByTokenList(tokenList, model, out retMsg); return(ErrCode.Sucess); }