示例#1
0
        public async Task SendPushMessageToUser(PushMessage message)
        {
            var token = await _apiTokenProvider.GetToken();

            var result = await _requestHelper.Request(
                "https://webapi.tobit.com/MessageService/message/send",
                HttpMethod.Post,
                $"Bearer {token}",
                message);

            if (result.StatusCode == HttpStatusCode.OK)
            {
                _logger.Info("[PushHelper] Send Push Success", new LogData
                {
                    { "message", message },
                    { "result", result },
                });
            }
            else
            {
                _logger.Error("[PushHelper] Send Push Failed", new LogData
                {
                    { "message", message },
                    { "result", result },
                });
            }
        }
示例#2
0
        protected JwtToken _GetToken()
        {
            JwtToken retval = _apiTokenProvider.GetToken(User.Identity.Name);

            if (retval != null)
            {
                return(retval);
            }
            else
            {
                retval             = new JwtToken();
                retval.AccessToken = "GetTokenError:" + User.Identity.Name;
                return(retval);
            }
        }