Exemplo n.º 1
0
        public async Task <Result> Handle(RetrySendCallBackFailureCommand request, CancellationToken cancellationToken)
        {
            var isDocExist = await _CallBackFailureRepository.UpdateFaulierProcessing(request.ReferenceNumber);

            if (!isDocExist)
            {
                return(new Result(false, new List <string> {
                    "Document not found or in Processing"
                }));
            }

            var doc = await _CallBackFailureRepository.FindDocument(request.ReferenceNumber);

            Result result;

            try
            {
                result = await _RetryLogic.Retry(doc.Fields.Message);
            }
            catch (Exception)
            {
                _ = _CallBackFailureRepository.ReverseFaulierProcessing(request.ReferenceNumber);
                return(new Result(false, new List <string> {
                    "message not push"
                })
                {
                    ReferenceNumber = request.ReferenceNumber
                });
            }
            return(result);
        }
Exemplo n.º 2
0
        public async Task <Result> Handle(RetrySendListCallBackFailuresCommand request, CancellationToken cancellationToken)
        {
            var isDocExist = await _CallBackFailureRepository.UpdateFaulierProcessing(request.ReferenceNumbers);

            if (!isDocExist)
            {
                return(new Result(false, new List <string> {
                    "Document not found or in Processing"
                }));
            }

            List <string> erros  = null;
            Result        result = new Result(true, null);

            foreach (var item in request.ReferenceNumbers)
            {
                var doc = await _CallBackFailureRepository.FindDocument(item);

                if (doc == null)
                {
                    continue;
                }
                try
                {
                    _ = await _RetryLogic.Retry(doc.Fields.Message);
                }
                catch (Exception ex)
                {
                    erros ??= new List <string>();
                    erros.Add($"{item} not push");
                    _ = _CallBackFailureRepository.ReverseFaulierProcessing(item);
                }
            }
            result.Errors = erros?.ToArray();
            return(result);
        }