/// <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> /// load article information to ArticleMasterSetRequest Small set /// </summary> /// <param name="request">ArticleMasterSetRequest to update.</param> /// <param name="currentArticleTree">Article tree to update</param> /// <param name="article">Article source information.</param> private void LoadPISArticleToRequestSmallSet(Interfaces.Messages.Stock.ArticleMasterSetRequest request, ArticleTree <PISArticle> currentArticleTree, Article article) { PISArticle currentPISArticle = currentArticleTree.GetArticle(); currentPISArticle.Code = article.Id != null?TextConverter.UnescapeInvalidXmlChars(article.Id) : string.Empty; currentPISArticle.Name = article.Name != null?TextConverter.UnescapeInvalidXmlChars(article.Name) : string.Empty; currentPISArticle.DosageForm = article.DosageForm != null?TextConverter.UnescapeInvalidXmlChars(article.DosageForm) : string.Empty; currentPISArticle.PackagingUnit = article.PackagingUnit != null?TextConverter.UnescapeInvalidXmlChars(article.PackagingUnit) : string.Empty; currentPISArticle.RobotArticleCode = article.Id != null?TextConverter.UnescapeInvalidXmlChars(article.Id) : string.Empty; // in wwks2, PIS code = robot article code. request.PISArticles.Add(currentPISArticle); // Load current article child Articles. foreach (var childArticle in article.ChildArticle) { ArticleTree <PISArticle> childArticleTree = new ArticleTree <PISArticle>(); LoadPISArticleToRequestSmallSet(request, childArticleTree, childArticle); currentArticleTree.AddChild(childArticleTree); } }