private void DoInputResponseReceived(StockInputResponse inputResponse) { if (this.InputResponseReceived != null) { this.InputResponseReceived(this, inputResponse); } }
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); } }
private void buttonInputMessageNotLoad_Click(object sender, EventArgs e) { this.simulatorCore.InputCore.SendInputMessage(this.GetSelectedInputTenant(), this.inputInProgress, this.inputRequestPackList, false); this.inputInProgress = null; this.dataGridViewInputRequestPackList.Enabled = true; this.UpdateInputMessageButtons(); }
public void SendInputMessage(string tenantId, StockInputResponse inputResponse, List <RobotPack> inputRequestPackList, bool isLoaded) { if (isLoaded) { this.stock.LoadInput(inputResponse); } var inputRequestPackListIsEmpty = inputRequestPackList == null || inputRequestPackList.Count == 0; foreach (IConverterStream stream in this.converterStreamList) { if (tenantId != stream.TenantID) { continue; } StockInputMessage inputMessage = new StockInputMessage(stream) { IsNewDelivery = inputResponse.IsDeliveryInput }; inputMessage.AdoptHeader(inputResponse); inputMessage.Articles.AddRange(inputResponse.Articles.ToArray()); inputMessage.Packs.AddRange(inputResponse.Packs.ToArray()); for (int i = 0; i < inputMessage.Packs.Count; i++) { inputMessage.Packs[i].Depth = 60; inputMessage.Packs[i].Width = 60; inputMessage.Packs[i].Height = 60; if (!inputRequestPackListIsEmpty) { inputMessage.Packs[i].Shape = inputRequestPackList[i].Shape; //IT cannot define the shape. inputMessage.Packs[i].MachineLocation = inputRequestPackList[i].MachineLocation; //IT cannot define the Machine location. inputMessage.Packs[i].TenantID = inputRequestPackList[i].TenantID; //IT cannot define the tenant. } inputMessage.Handlings.Add(inputMessage.Packs[i], isLoaded ? StockInputHandlingType.Completed : StockInputHandlingType.Aborted); } stream.Write(inputMessage); } }
/// <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); } }
/// <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) { StockInputResponse response = new StockInputResponse(converterStream); response.ID = this.Id; response.Source = this.Source; response.Destination = this.Destination; response.IsDeliveryInput = TypeConverter.ConvertBool(this.IsNewDelivery); if (this.Article.Count > 0) { foreach (var article in this.Article) { ArticleTree <RobotArticle> currentArticleTree = new ArticleTree <RobotArticle>(); response.ArticleTrees.Add(currentArticleTree); LoadArticleToReponse(response, currentArticleTree, article); } } return(response); }
public void LoadInput(StockInputResponse inputResponse) { // 1 add Item to the stock. for (int i = 0; i < inputResponse.Packs.Count; i++) { StockProduct currentStockProduct = this.GetStockProduct(inputResponse.Packs[i].RobotArticleCode); inputResponse.Packs[i].ID = this.GetNextPackID(); currentStockProduct.AddItem(inputResponse.Packs[i]); } // 2 update Article Information for (int i = 0; i < inputResponse.Articles.Count; i++) { StorageSystemArticleInformation currentArticleInformation = this.articleInformationList.GetArticleInformation(inputResponse.Articles[i].Code, true); currentArticleInformation.Name = inputResponse.Articles[i].Name; currentArticleInformation.DosageForm = inputResponse.Articles[i].DosageForm; currentArticleInformation.PackagingUnit = inputResponse.Articles[i].PackagingUnit; currentArticleInformation.MaxSubItemQuantity = inputResponse.Articles[i].MaxSubItemQuantity; } // 3 forward stock update Event. this.DoStockUpdated(); }
/// <summary> /// Initializes a new instance of the <see cref="InputResponse"/> class. /// </summary> /// <param name="message">The message to use for initialization.</param> public InputResponse(MosaicMessage message) { StockInputResponse response = (StockInputResponse)message; this.Id = response.ID; this.Source = response.Source; this.Destination = response.Destination; this.IsNewDelivery = response.IsDeliveryInput.ToString(); if ((response.ArticleTrees != null) && (response.ArticleTrees.Count != 0)) { throw new System.Exception("public InputResponse(MosaicMessage message), using ArticleTree not supported."); } else { if (response.Articles.Count > 0) { this.Article = new List <Article>(response.Articles.Count); foreach (var article in response.Articles) { var a = new Article(); a.DosageForm = TextConverter.EscapeInvalidXmlChars(article.DosageForm); a.Id = TextConverter.EscapeInvalidXmlChars(article.Code); a.Name = TextConverter.EscapeInvalidXmlChars(article.Name); a.PackagingUnit = TextConverter.EscapeInvalidXmlChars(article.PackagingUnit); a.MaxSubItemQuantity = article.MaxSubItemQuantity.ToString(); a.Pack = new List <Types.Pack>(); a.RequiresFridge = article.RequiresFridge.ToString(); for (int i = 0; i < response.Packs.Count; ++i) { if (response.Packs[i].RobotArticleCode != article.Code) { continue; } a.Pack.Add(new Types.Pack() { Index = i.ToString(), Id = ((ulong)response.Packs[i].ID).ToString(), ScanCode = TextConverter.EscapeInvalidXmlChars(response.Packs[i].ScanCode), DeliveryNumber = TextConverter.EscapeInvalidXmlChars(response.Packs[i].DeliveryNumber), BatchNumber = TextConverter.EscapeInvalidXmlChars(response.Packs[i].BatchNumber), ExternalId = TextConverter.EscapeInvalidXmlChars(response.Packs[i].ExternalID), ExpiryDate = TypeConverter.ConvertDateNull(response.Packs[i].ExpiryDate), SubItemQuantity = response.Packs[i].SubItemQuantity.ToString(), StockLocationId = TextConverter.EscapeInvalidXmlChars(response.Packs[i].StockLocationID), Handling = new Handling() { Input = response.Handlings[response.Packs[i]].Handling, Text = TextConverter.EscapeInvalidXmlChars(response.Handlings[response.Packs[i]].Description) } }); } this.Article.Add(a); } } } }
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(); } }