/// <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
        private void LoadArticleToReponse(StockInputResponse response, ArticleTree <RobotArticle> currentArticleTree, Article article)
        {
            // 1) Load current Article information
            RobotArticle robotArticle = currentArticleTree.GetArticle();

            robotArticle.DosageForm         = TextConverter.UnescapeInvalidXmlChars(article.DosageForm != null ? article.DosageForm : string.Empty);
            robotArticle.Code               = TextConverter.UnescapeInvalidXmlChars(article.Id != null ? article.Id : string.Empty);
            robotArticle.Name               = TextConverter.UnescapeInvalidXmlChars(article.Name != null ? article.Name : string.Empty);
            robotArticle.PackagingUnit      = TextConverter.UnescapeInvalidXmlChars(article.PackagingUnit != null ? article.PackagingUnit : string.Empty);
            robotArticle.MaxSubItemQuantity = TypeConverter.ConvertInt(article.MaxSubItemQuantity);
            robotArticle.RequiresFridge     = TypeConverter.ConvertBool(article.RequiresFridge);

            // 2) Load current article pack information
            foreach (var pack in article.Pack)
            {
                response.Packs.Add(new Interfaces.Types.Packs.RobotPack()
                {
                    ID = (long)TypeConverter.ConvertULong(pack.Id),
                    RobotArticleCode = robotArticle.Code,
                    ScanCode         = TextConverter.UnescapeInvalidXmlChars(pack.ScanCode),
                    DeliveryNumber   = TextConverter.UnescapeInvalidXmlChars(pack.DeliveryNumber),
                    BatchNumber      = TextConverter.UnescapeInvalidXmlChars(pack.BatchNumber),
                    ExternalID       = TextConverter.UnescapeInvalidXmlChars(pack.ExternalId),
                    ExpiryDate       = TypeConverter.ConvertDate(pack.ExpiryDate),
                    SubItemQuantity  = TypeConverter.ConvertInt(pack.SubItemQuantity),
                    StockLocationID  = string.IsNullOrEmpty(pack.StockLocationId) ? string.Empty : TextConverter.UnescapeInvalidXmlChars(pack.StockLocationId),
                });

                // only add to the article list, the articles related to pack behing input.
                response.Articles.Add(robotArticle);

                response.Handlings.Add(response.Packs[response.Packs.Count - 1],
                                       new StockInputHandling()
                {
                    Handling    = pack.Handling.Input,
                    Description = string.IsNullOrEmpty(pack.Handling.Text) ? string.Empty : TextConverter.UnescapeInvalidXmlChars(pack.Handling.Text)
                });
            }

            // 3) Load current article child Articles.
            foreach (var childArticle in article.ChildArticle)
            {
                ArticleTree <RobotArticle> childArticleTree = new ArticleTree <RobotArticle>();
                LoadArticleToReponse(response, childArticleTree, childArticle);
                currentArticleTree.AddChild(childArticleTree);
            }
        }
        private List <RobotArticle> BuildArticleList(List <RobotPack> packList, bool includeArticleDetails)
        {
            List <RobotArticle> articleList = new List <RobotArticle>();

            foreach (RobotPack pack in packList)
            {
                RobotArticle currentArticle = null;

                foreach (RobotArticle Article in articleList)
                {
                    if (Article.Code == pack.RobotArticleCode)
                    {
                        currentArticle = Article;
                        break;
                    }
                }

                if (currentArticle == null)
                {
                    if (includeArticleDetails)
                    {
                        StorageSystemArticleInformation articleInformation = this.stock.ArticleInformationList.GetArticleInformation(pack.RobotArticleCode, false);
                        currentArticle = new RobotArticle
                        {
                            Code               = articleInformation.Code,
                            Name               = articleInformation.Name,
                            DosageForm         = articleInformation.DosageForm,
                            PackagingUnit      = articleInformation.PackagingUnit,
                            MaxSubItemQuantity = articleInformation.MaxSubItemQuantity
                        };
                        articleList.Add(currentArticle);
                    }
                    else
                    {
                        currentArticle = new RobotArticle
                        {
                            Code = pack.RobotArticleCode
                        };
                        articleList.Add(currentArticle);
                    }
                }

                currentArticle.PackCount++;
            }

            return(articleList);
        }
예제 #3
0
        public void ProcessInitiateStockInputRequest(InitiateStockInputRequest initiateInputRequest)
        {
            InitiateStockInputResponse initiateInputReponse = new InitiateStockInputResponse();

            initiateInputReponse.AdoptHeader(initiateInputRequest);
            initiateInputReponse.IsDeliveryInput     = initiateInputRequest.IsDeliveryInput;
            initiateInputReponse.SetPickingIndicator = initiateInputRequest.SetPickingIndicator;
            initiateInputReponse.InputSource         = initiateInputRequest.InputSource;
            initiateInputReponse.InputPoint          = initiateInputRequest.InputPoint;
            initiateInputReponse.Status = this.initiateStockInputState;

            foreach (RobotPack pack in initiateInputRequest.Packs)
            {
                bool articleInfoFound = false;
                foreach (RobotArticle article in initiateInputReponse.Articles)
                {
                    if (article.Code == pack.RobotArticleCode)
                    {
                        articleInfoFound = true;
                        break;
                    }
                }

                if (!articleInfoFound)
                {
                    // get article Info
                    StorageSystemArticleInformation articleInformation =
                        this.stock.ArticleInformationList.GetArticleInformation(pack.RobotArticleCode, false);

                    if (articleInformation == null)
                    {
                        // article not found ? try with the scan code.
                        articleInformation = this.stock.ArticleInformationList.GetArticleInformation(pack.ScanCode, false);
                    }

                    if (articleInformation != null)
                    {
                        RobotArticle newArticle = new RobotArticle();
                        newArticle.Code               = articleInformation.Code;
                        newArticle.Name               = articleInformation.Name;
                        newArticle.DosageForm         = articleInformation.DosageForm;
                        newArticle.PackagingUnit      = articleInformation.PackagingUnit;
                        newArticle.MaxSubItemQuantity = articleInformation.MaxSubItemQuantity;
                        initiateInputReponse.Articles.Add(newArticle);
                    }
                }
            }

            initiateInputReponse.Packs.AddRange(initiateInputRequest.Packs);
            initiateInputReponse.ConverterStream.Write(initiateInputReponse);

            if (initiateInputReponse.Status == InitiateStockInputState.Accepted)
            {
                this.initiateStockInputWaitForInputResponse = initiateInputReponse;
                this.ScanPack(initiateInputReponse.TenantID,
                              "",
                              initiateInputRequest.SetPickingIndicator,
                              initiateInputRequest.IsDeliveryInput,
                              initiateInputReponse.Packs);
            }
        }
예제 #4
0
        private void StorageSystemSimulatorCore_InputResponseReceived(object sender, StockInputResponse inputResponse)
        {
            if (this.listViewScannedPackInformation.InvokeRequired)
            {
                this.listViewScannedPackInformation.BeginInvoke(new InputResponseReceivedEventHandler(StorageSystemSimulatorCore_InputResponseReceived),
                                                                new object[] { sender, inputResponse });
                return;
            }

            bool allowToLoad = true;

            this.listViewScannedPackInformation.Items.Clear();

            foreach (RobotPack pack in inputResponse.Packs)
            {
                ListViewItem newScannedPack = new ListViewItem("");
                newScannedPack.SubItems.Add(pack.RobotArticleCode);

                RobotArticle foundArticle = null;

                foreach (RobotArticle article in inputResponse.Articles)
                {
                    if (article.Code == pack.RobotArticleCode)
                    {
                        foundArticle = article;
                    }
                }

                if (foundArticle != null)
                {
                    newScannedPack.SubItems.Add(foundArticle.Name);
                    newScannedPack.SubItems.Add(foundArticle.DosageForm);
                    newScannedPack.SubItems.Add(foundArticle.PackagingUnit);
                    newScannedPack.SubItems.Add(foundArticle.MaxSubItemQuantity.ToString());
                }
                else
                {
                    newScannedPack.SubItems.Add("");
                    newScannedPack.SubItems.Add("");
                    newScannedPack.SubItems.Add("");
                    newScannedPack.SubItems.Add("");
                }

                newScannedPack.SubItems.Add(pack.BatchNumber);
                newScannedPack.SubItems.Add(pack.ExpiryDate.ToString("dd/MM/yyyy"));
                newScannedPack.SubItems.Add(pack.ExternalID);
                newScannedPack.SubItems.Add(pack.SubItemQuantity.ToString());
                newScannedPack.SubItems.Add(pack.StockLocationID);
                newScannedPack.SubItems.Add((inputResponse.Handlings[pack].Handling == StockInputHandlingType.AllowedForFridge).ToString());

                newScannedPack.SubItems.Add(inputResponse.Handlings[pack].Handling.ToString());
                newScannedPack.SubItems.Add(inputResponse.Handlings[pack].Description);

                this.listViewScannedPackInformation.Items.Add(newScannedPack);

                allowToLoad &= ((inputResponse.Handlings[pack].Handling == StockInputHandlingType.Allowed) ||
                                ((inputResponse.Handlings[pack].Handling == StockInputHandlingType.AllowedForFridge) &&
                                 (checkBoxAcceptFridge.Checked)));

                allowToLoad &= this.simulatorCore.SimulatorStockLocation.Contains(pack.StockLocationID);
            }

            if (checkBoxInputMessageAuto.Checked)
            {
                // send automaticaly message back.
                this.simulatorCore.InputCore.SendInputMessage(this.GetSelectedInputTenant(),
                                                              inputResponse, this.inputRequestPackList, allowToLoad);
                this.dataGridViewInputRequestPackList.Enabled = true;
            }
            else
            {
                // Enabled buttons to load the pack.
                this.inputInProgress = inputResponse;
                this.UpdateInputMessageButtons();
            }
        }