예제 #1
0
        /// <summary>
        /// Commit Inbound Message
        /// </summary>
        /// <param name="messageQueue"></param>
        /// <returns></returns>
        public async Task <ResponseModel <MessageQueue> > CommitInboundMessage(MessageQueue messageQueue, ConnectionStrings connectionStrings)
        {
            ResponseModel <MessageQueue> returnResponse = new ResponseModel <MessageQueue>();

            try
            {
                _inventoryManagementDataService.OpenConnection(connectionStrings.PrimaryDatabaseConnectionString);
                _inventoryManagementDataService.BeginTransaction((int)IsolationLevel.ReadCommitted);

                TransactionQueueInbound transactionQueue = new TransactionQueueInbound();
                transactionQueue.ExchangeName             = messageQueue.ExchangeName;
                transactionQueue.SenderTransactionQueueId = messageQueue.TransactionQueueId;
                transactionQueue.TransactionCode          = messageQueue.TransactionCode;
                transactionQueue.Payload = messageQueue.Payload;

                await _inventoryManagementDataService.CreateInboundTransactionQueue(transactionQueue);

                await _inventoryManagementDataService.UpdateDatabase();

                _inventoryManagementDataService.CommitTransaction();

                returnResponse.ReturnStatus = true;
            }
            catch (Exception ex)
            {
                _inventoryManagementDataService.RollbackTransaction();
                returnResponse.ReturnStatus = false;
                returnResponse.ReturnMessage.Add(ex.Message);
            }
            finally
            {
                _inventoryManagementDataService.CloseConnection();
            }

            returnResponse.Entity = messageQueue;

            return(returnResponse);
        }