Esempio n. 1
0
        private void HandleQueueAsync(IMessageQueueService messageQueueService, long queueId)
        {
            var queue = messageQueueService.GetSingle(queueId);

            if (queue == null)
            {
                throw new MessageQueueHandleException(queueId, $"message queue with id {queueId} not found.");
            }

            RegexHelper.CheckMobile(queue.Mobile);
            ServiceResult messageResult = ServiceResult.Success;

            if (queue.TemplateCode <= 0)
            {
                messageResult = SendRawAsync(queue);
            }

            if (messageResult.Succeeded)
            {
                messageQueueService.HandleQueueAndUpdateContent(queueId, "message send  success!");
            }
            else
            {
                messageQueueService.ErrorQueue(queueId, $"message send fail !",
                                               messageResult.ToString());
            }
        }
Esempio n. 2
0
        private async Task HandleQueueAsync(IMessageQueueService messageQueueService, long queueId)
        {
            var queue = messageQueueService.GetSingle(queueId);

            // var result = await _adminMessageApiClient.GetAccount(_serverAuthenticationManager.Token.Token);
            if (queue == null)
            {
                throw new MessageQueueHandleException(queueId, $"message queue with id {queueId} not found.");
            }

            RegexHelper.CheckMobile(queue.Mobile);
            MessageResult messageResult = null;

            if (queue.TemplateCode > 0)
            {
                messageResult = await SendTemplateAsync(queue);
            }
            else
            {
                messageResult = await SendRawAsync(queue);
            }

            if (messageResult == null)
            {
                messageQueueService.ErrorQueue(queueId, "message send with no result!");
            }
            else if (messageResult.Type == ResultType.Success)
            {
                messageQueueService.HandleQueueAndUpdateContent(queueId, "message send open service  success!",
                                                                messageResult.Message);
            }
            else
            {
                messageQueueService.ErrorQueue(queueId, $"message send {messageResult.Type}!",
                                               messageResult.Message);
            }
        }