示例#1
0
        public void ProcessInputResponse(StockInputResponse inputReponse)
        {
            if (this.initiateStockInputWaitForInputResponse != null)
            {
                this.SendInputMessage(inputReponse.TenantID, inputReponse, inputReponse.Packs,
                                      (this.initiateStockInputState == InitiateStockInputState.Accepted));

                InitiateStockInputMessage initiateStockInputMessage = new InitiateStockInputMessage();
                initiateStockInputMessage.AdoptHeader(initiateStockInputWaitForInputResponse);
                initiateStockInputMessage.InputSource = this.initiateStockInputWaitForInputResponse.InputSource;
                initiateStockInputMessage.InputPoint  = this.initiateStockInputWaitForInputResponse.InputPoint;
                initiateStockInputMessage.Status      = this.initiateStockInputState;

                initiateStockInputMessage.Articles.AddRange(this.initiateStockInputWaitForInputResponse.Articles);
                initiateStockInputMessage.Packs.AddRange(this.initiateStockInputWaitForInputResponse.Packs);

                if (this.initiateStockInputState != InitiateStockInputState.Accepted)
                {
                    StockInputError inputError = new StockInputError();
                    inputError.Type = StockInputErrorType.Rejected;
                    foreach (RobotPack pack in initiateStockInputMessage.Packs)
                    {
                        initiateStockInputMessage.PackErrors.Add(pack, inputError);
                    }
                }

                this.initiateStockInputWaitForInputResponse = null;
            }
            else
            {
                this.DoInputResponseReceived(inputReponse);
            }
        }
        /// <summary>
        /// Translates this object instance into a Mosaic message.
        /// </summary>
        /// <param name="converterStream">The converter stream instance which request the message conversion.</param>
        /// <returns>
        /// The Mosaic message representation of this object.
        /// </returns>
        public MosaicMessage ToMosaicMessage(IConverterStream converterStream)
        {
            var message = new InitiateStockInputMessage(converterStream);

            message.ID          = this.Id;
            message.Destination = this.Destination;
            message.Source      = this.Source;
            message.InputSource = (this.Details != null) ? TypeConverter.ConvertInt(this.Details.InputSource) : 0;
            message.InputPoint  = (this.Details != null) ? TypeConverter.ConvertInt(this.Details.InputPoint) : 0;
            message.Status      = (this.Details != null) ?
                                  TypeConverter.ConvertEnum <InitiateStockInputState>(this.Details.Status, InitiateStockInputState.Rejected) :
                                  InitiateStockInputState.Rejected;
            if (this.Article != null)
            {
                foreach (var article in this.Article)
                {
                    message.Articles.Add(new Interfaces.Types.Articles.RobotArticle()
                    {
                        Code               = TextConverter.UnescapeInvalidXmlChars(article.Id),
                        Name               = TextConverter.UnescapeInvalidXmlChars(article.Name),
                        PackagingUnit      = TextConverter.UnescapeInvalidXmlChars(article.PackagingUnit),
                        DosageForm         = TextConverter.UnescapeInvalidXmlChars(article.DosageForm),
                        MaxSubItemQuantity = TypeConverter.ConvertInt(article.MaxSubItemQuantity)
                    });

                    if (article.Pack != null)
                    {
                        foreach (var pack in article.Pack)
                        {
                            var msgPack = new Interfaces.Types.Packs.RobotPack()
                            {
                                ID              = (long)TypeConverter.ConvertULong(pack.Id),
                                DeliveryNumber  = TextConverter.UnescapeInvalidXmlChars(pack.DeliveryNumber),
                                BatchNumber     = TextConverter.UnescapeInvalidXmlChars(pack.BatchNumber),
                                ExternalID      = TextConverter.EscapeInvalidXmlChars(pack.ExternalId),
                                ExpiryDate      = TypeConverter.ConvertDate(pack.ExpiryDate),
                                StockInDate     = TypeConverter.ConvertDate(pack.StockInDate),
                                ScanCode        = TextConverter.UnescapeInvalidXmlChars(pack.ScanCode),
                                SubItemQuantity = TypeConverter.ConvertInt(pack.SubItemQuantity),
                                Depth           = TypeConverter.ConvertInt(pack.Depth),
                                Width           = TypeConverter.ConvertInt(pack.Width),
                                Height          = TypeConverter.ConvertInt(pack.Height),
                                Shape           = TypeConverter.ConvertEnum <PackShape>(pack.Shape, PackShape.Cuboid),
                                StockLocationID = string.IsNullOrEmpty(pack.StockLocationId) ? string.Empty : TextConverter.UnescapeInvalidXmlChars(pack.StockLocationId),
                                MachineLocation = string.IsNullOrEmpty(pack.MachineLocation) ? string.Empty : TextConverter.UnescapeInvalidXmlChars(pack.MachineLocation),
                                IsAvailable     = (string.Compare(pack.State, "Available") == 0),
                                IsInFridge      = TypeConverter.ConvertBool(pack.IsInFridge)
                            };

                            message.Packs.Add(msgPack);

                            if (pack.Error != null)
                            {
                                var msgError = new StockInputError()
                                {
                                    Type        = TypeConverter.ConvertEnum <StockInputErrorType>(pack.Error.Type, StockInputErrorType.Rejected),
                                    Description = TextConverter.UnescapeInvalidXmlChars(pack.Error.Text)
                                };

                                message.PackErrors.Add(msgPack, msgError);
                            }
                        }
                    }
                }
            }

            return(message);
        }