示例#1
0
        /// <summary>
        /// Get image Url, try create base64 URI. If the size is too big, resize until its gonna be OK.
        /// </summary>
        /// <param name="item">Items.</param>
        /// <returns>Image url.</returns>
        public async Task <string> GetImageUrl(PimItem item)
        {
            string base64string = await _pictureRepository.GetPictureUrlByPictureDocumentId(item.Picture_Document_ID);

            if (base64string == null)
            {
                return(null);
            }

            try
            {
                while (!Uri.TryCreate(base64string, UriKind.RelativeOrAbsolute, out Uri uri))
                {
                    var image        = Base64ToImage(base64string);
                    var comprimImage = ResizeImage(image, image.Width / 4, image.Height / 4);

                    MemoryStream ms = new MemoryStream();
                    comprimImage.Save(ms, ImageFormat.Png);
                    byte[] byteImage = ms.ToArray();
                    base64string = "data:image/png;base64," + Convert.ToBase64String(byteImage);
                }

                return(base64string);
            }
            catch (Exception)
            {
                return(null);
            }
        }
示例#2
0
        private PimItem MapPimItem(IDictionary <string, object> item)
        {
            var pimItem = new PimItem
            {
                No                       = (string)item["No"],
                Description              = (string)item["Description"],
                Systemstatus             = (string)item["Systemstatus"],
                Assembly_BOM             = (bool)item["Assembly_BOM"],
                Base_Unit_of_Measure     = (string)item["Base_Unit_of_Measure"],
                Shelf_No                 = (string)item["Shelf_No"],
                Costing_Method           = (string)item["Costing_Method"],
                Standard_Cost            = (decimal)item["Standard_Cost"],
                Unit_Cost                = (decimal)item["Unit_Cost"],
                Last_Direct_Cost         = (decimal)item["Last_Direct_Cost"],
                Price_Profit_Calculation = (string)item["Price_Profit_Calculation"],
                Profit_Percent           = (decimal)item["Profit_Percent"],
                Unit_Price               = (decimal)item["Unit_Price"],
                Inventory_Posting_Group  = (string)item["Inventory_Posting_Group"],
                Gen_Prod_Posting_Group   = (string)item["Gen_Prod_Posting_Group"],
                VAT_Prod_Posting_Group   = (string)item["VAT_Prod_Posting_Group"],
                Vendor_No                = (string)item["Vendor_No"],
                Vendor_Item_No           = (string)item["Vendor_Item_No"],
                Tariff_No                = (string)item["Tariff_No"],
                Search_Description       = (string)item["Search_Description"],
                Durability               = (string)item["Durability"],
                Picture_Document_ID      = (string)item["Picture_Document_ID"],
                Standardartikelgruppe    = (string)item["Standardartikelgruppe"],
                Base_Class_No            = (string)item["Base_Class_No"],
                Item_Category_Code       = (string)item["Item_Category_Code"],
                Product_Group_Code       = (string)item["Product_Group_Code"],
                ETag                     = (string)item["ETag"],
            };

            return(pimItem);
        }
示例#3
0
        /// <summary>
        /// Get item groups by No.
        /// </summary>
        /// <param name="item">Item.</param>
        /// <returns>Task.</returns>
        public async Task GetItemGroupsByNo(PimItem item)
        {
            throw new System.NotImplementedException();

            //            var allGroups = await _categoryRepository.GetAllItemGroup();
            //
            //            var pimItemGroups = new List<PimItemGroup>();
            //            var client = ODataClientSingleton.Get();
            //
            //            var groups = await client
            //                .For(Constants.Company).Key(Constants.CompanyName)
            //                .NavigateTo(Constants.ItemGroupLinks)
            //                .Filter($"Number%20eq%20%27{item.No}%27")
            //                .FindEntriesAsync();
            //
            //            foreach (var group in groups)
            //            {
            //                var pimItemGroup = new PimItemGroup();
            //                pimItemGroup.Code = (string)group["Code"];
            //                var description = allGroups.Where(i => i.Code == (string) group["Code"]).Select(i => i.Description).First();
            //                pimItemGroup.Description = description;
            //                pimItemGroups.Add(pimItemGroup);
            //            }
            //
            //         item.PimItemGroups = pimItemGroups;
        }
        private Attachment CreateAdaptiveCardDetailUsingSdk(PimItem item, List <PimFeature> features, string pictureUrl)
        {
            var card = new AdaptiveCard();

            if (pictureUrl != null)
            {
                card.Body.Add(new AdaptiveImage()
                {
                    Type                = "Image",
                    UrlString           = pictureUrl,
                    HorizontalAlignment = AdaptiveHorizontalAlignment.Center,
                    Size                = AdaptiveImageSize.Large,
                });
            }

            card.Body.Add(new AdaptiveTextBlock()
            {
                Text   = $"**{Messages.No}**: {item.No}",
                Size   = AdaptiveTextSize.Medium,
                Weight = AdaptiveTextWeight.Bolder,
            });

            card.Body.Add(new AdaptiveTextBlock()
            {
                Text   = $"**{Messages.Description}**: {item.Description}",
                Size   = AdaptiveTextSize.Medium,
                Weight = AdaptiveTextWeight.Bolder,
            });

            card.Body.Add(new AdaptiveTextBlock()
            {
                Text   = $"**{Messages.Price}**: {item.Unit_Price}/{item.Base_Unit_of_Measure}",
                Size   = AdaptiveTextSize.Medium,
                Weight = AdaptiveTextWeight.Bolder,
            });

            foreach (var feature in features)
            {
                card.Body.Add(new AdaptiveTextBlock()
                {
                    Text   = $"{feature.Description}: {feature.Value} {feature.Unit_Shorthand_Description}",
                    Size   = AdaptiveTextSize.Medium,
                    Weight = AdaptiveTextWeight.Bolder,
                });
            }

            card.Actions.Add(new AdaptiveSubmitAction()
            {
                Title = Messages.FindItemAddToCartButton, Data = $"add {item.No}"
            });

            return(new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content = card,
            });
        }
示例#5
0
        /// <summary>
        /// Is item cointains keywords.
        /// </summary>
        /// <param name="item">Item.</param>
        /// <param name="key">Key.</param>
        /// <param name="keywordsByItem">KeywordsByItem.</param>
        /// <returns>If items cointains keyword.</returns>
        private bool IsItemContainsKeyword(PimItem item, string key, Dictionary <string, List <PimKeyword> > keywordsByItem)
        {
            if (!keywordsByItem.ContainsKey(item.No))
            {
                return(false);
            }

            var keywords = keywordsByItem[item.No];

            foreach (var keyword in keywords)
            {
                if (CommonUtil.ContainsIgnoreCase(keyword.Keyword, key) || CommonUtil.ContainsIgnoreCase(key, keyword.Keyword))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#6
0
        public static IEnumerable <PimItem> CreateDummyItems()
        {
            var items = new List <PimItem>();
            var item1 = new PimItem();

            item1.PimItemGroups = new List <PimItemGroup>();
            var itemCategory1 = new PimItemGroup();

            itemCategory1.Code        = "1000";
            itemCategory1.Description = "Roma benches";
            item1.PimItemGroups.Add(itemCategory1);

            item1.No                  = "1000";
            item1.Description         = "Chair Camilla";
            item1.Unit_Price          = 500;
            item1.Picture_Document_ID = "PicID1";
            items.Add(item1);

            var item2 = new PimItem();

            item2.No                  = "1001";
            item2.Description         = "Chair Roma";
            item2.Unit_Price          = 700;
            item2.Picture_Document_ID = "PicID1";
            items.Add(item2);

            var item3 = new PimItem();

            item3.No                  = "1002";
            item3.Description         = "Chair Milada";
            item3.Unit_Price          = 1000;
            item3.Picture_Document_ID = "PicID1";
            items.Add(item3);

            var item4 = new PimItem();

            item4.No          = "1003";
            item4.Description = "Table";
            item4.Unit_Price  = 2000;
            items.Add(item4);

            return(items);
        }