示例#1
0
        /// <summary>
        /// Carousel move implementation
        /// </summary>
        /// <param name="transactionData"></param>
        public async Task <IDeviceResponse> MoveCarousel(TransactionData transactionData)
        {
            _deviceResponse.HasError       = false;
            _deviceResponse.Message        = string.Empty;
            _deviceResponse.CurrentCarrier = 0;

            try
            {
                // Slot Data
                Slot slot = await _utility.BuildStorageSpaceItem(transactionData.Devices.FirstOrDefault(dev => dev.Type.Equals("Carousel"))?.StorageSpaces);

                _logger.LogInformation(Constants.CarousalProcess.SlotObjectCreated);

                // Carousel creation
                _deviceResponse = await _carouselManager.CreateCarousel(transactionData);

                if (!_deviceResponse.HasError)
                {
                    _logger.LogInformation(Constants.CarousalProcess.CarouselCreated);
                }
                else
                {
                    _logger.LogInformation(_deviceResponse.Message);
                    return(_deviceResponse);
                }

                // Moving carousel
                _deviceResponse = await _carouselManager.MoveCarousel(transactionData : transactionData, slot : slot);

                if (!_deviceResponse.HasError)
                {
                    _logger.LogInformation(Constants.CarousalProcess.CarouselMoved);
                }
                else
                {
                    _logger.LogInformation(_deviceResponse.Message);
                    return(_deviceResponse);
                }
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                _logger.LogError(ex, ex.Message);

                //Initializing the response object
                _deviceResponse.HasError  = true;
                _deviceResponse.ErrorCode = ex.ErrorCode;
                _deviceResponse.Message   = ex.Message;
            }

            return(_deviceResponse);
        }