Ejemplo n.º 1
0
        //private void SendMessageToMobileUser(IList<string> phoneNumbers, string content)
        //{

        //}

        private void SendMessageToWeChatUser(IList <string> lillyIds, string message, int appId)
        {
            try
            {
                if (!lillyIds.Any())
                {
                    return;
                }

                var result = WechatCommon.PublishMessageText(appId, message, string.Join("|", lillyIds.Where(x => !string.IsNullOrWhiteSpace(x)).ToList()), null, null);
                if (result.errcode != ReturnCode_QY.请求成功)
                {
                    //TODO: should be used db log
                    _logger.Error("hse wechat error:{0}", result.errmsg);
                }
            }
            catch (ErrorJsonResultException e)
            {
                _logger.Error("hse wechat exception message:{0},code:{1}", e.JsonResult.errmsg, e.JsonResult.errcode);
            }
        }
Ejemplo n.º 2
0
        private Result <object> PushMessage(MessageText objModel, int historyId)
        {
            var result = new Result <object> {
                Status = 200
            };

            if (objModel.Status == null || objModel.Status == ConstData.STATUS_NEW)
            {
                objModel.Status      = ConstData.STATUS_PUBLISH;
                objModel.PublishDate = DateTime.Now;

                //向前台推送提醒信息
                var aiv = (MessageTextView) new MessageTextView().ConvertAPIModel(objModel);

                var pushResult = WechatCommon.PublishMessageText(objModel.AppId.GetValueOrDefault(), aiv.Content, aiv.toUser, aiv.toDepartment, aiv.toTag);

                if (pushResult.errcode != ReturnCode_QY.请求成功)
                {
                    _pushHistoryDetailService.Repository.Insert(new PushHistoryDetailEntity
                    {
                        HistoryId        = historyId,
                        ErrorDepartments = pushResult.invalidparty,
                        ErrorTags        = pushResult.invalidtag,
                        ErrorUsers       = pushResult.invaliduser,
                        ErrorType        = ErrorType.Returned.ToString(),
                    });
                }

                _BaseService.Repository.Update(objModel, new List <string> {
                    "Status", "PublishDate"
                });
            }
            else
            {
                result.Status  = 99;
                result.Message = "message不能重复推送!";
            }

            return(result);
        }