Пример #1
0
        private async Task ProcessTraxRequest(ProcessInterfaceDataChangeLogsRequest request, string paymentRequestMessage, string legalEntityCode, long eventId)
        {
            try
            {
                // Esb call inside its own try/catch
                request.UUID = await _paymentRequestService.CallESBClient(request, paymentRequestMessage, legalEntityCode);
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);

                var updateEventStatus = new Event(eventId, (long)InterfaceStatus.TransmitError, e.Message);
                var eventHistory      = new EventHistory(eventId, "Sending the message to ESB", null, ResultCode.Error.ToString(), e.Message);
                await _interfaceEventLogService.UpdateEventStatusAsync(updateEventStatus, request.CompanyId);

                await _interfaceEventLogService.CreateEventHistoryAsync(eventHistory, request.CompanyId);
                await ProcessStatusUpdate(request, InterfaceStatus.TransmitError, e.Message);

                throw;
            }

            _unitOfWork.BeginTransaction();
            try
            {
                var updateEventStatus = new Event(eventId, (long)InterfaceStatus.StandBy, request.UUID);
                var eventHistory      = new EventHistory(eventId, "Sending the message to ESB", null, ResultCode.Ok.ToString(), request.UUID);
                await _interfaceEventLogService.UpdateEventStatusAsync(updateEventStatus, request.CompanyId);

                await _interfaceEventLogService.CreateEventHistoryAsync(eventHistory, request.CompanyId);
                await ProcessStatusUpdate(request, InterfaceStatus.StandBy, paymentRequestMessage);

                _unitOfWork.Commit();
            }
            catch
            {
                _unitOfWork.Rollback();
                throw;
            }
        }