Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var productList = ProductExcelImporter.ReadProductExcel(@"D:\fzone.xlsx");

            foreach (var p in productList.ToList())
            {
                Console.WriteLine("Type: " + p.GetType());
                Console.WriteLine(p.Code);
                Console.WriteLine(p.Title);
                Console.WriteLine(p.Retail);
                Console.WriteLine(p.Buy);
                Console.WriteLine(p.Sell);
                Console.WriteLine(p.Desc);
                Console.WriteLine(p.Sex);
                Console.WriteLine(p.Category);
                Console.WriteLine(p.ImgList);
                Console.WriteLine(p.SizeXS);
                Console.WriteLine(p.SizeS);
                Console.WriteLine(p.SizeM);
                Console.WriteLine(p.SizeL);
                Console.WriteLine(p.SizeXL);
                Console.WriteLine(p.SizeXXL);
                Console.WriteLine(p.OneSize);
                Console.WriteLine(p.Quantity);
            }
            ApplicationContext.Current.Products.ImportProducts(32, @"D:\fzone.xlsx");

            Console.Read();
        }
Ejemplo n.º 2
0
        public void ImportProducts(int CampaignId, string Path)
        {
            var     productList     = ProductExcelImporter.ReadProductExcel(Path);
            string  encryptedCampId = FashionZone.BL.Util.Encryption.Encrypt(CampaignId.ToString());
            PRODUCT product;

            // preparing categories
            List <CATEGORY> categoriesList = _categoryDAO.GetCategoryListByCampaign(CampaignId);

            int?categoryParentF = null, categoryParentM = null;

            CATEGORY cat, categoryParent = null;

            categoryParent = categoriesList.Where(o => o.NameEng.Contains("Woman")).FirstOrDefault();
            if (categoryParent != null)
            {
                cat = new CATEGORY()
                {
                    ID = categoryParent.ID
                };
                categoryParentF = categoryParent.ID;
            }

            categoryParent = categoriesList.Where(o => o.NameEng.Contains("Man")).FirstOrDefault();
            if (categoryParent != null)
            {
                cat = new CATEGORY()
                {
                    ID = categoryParent.ID
                };
                categoryParentM = categoryParent.ID;
            }
            var query = (from c in categoriesList
                         select new { c.ID, c.Name, c.NameEng, c.ParentID }).ToList();

            foreach (FZExcelProduct exProd in productList)
            {
                product      = new PRODUCT();
                product.Name = exProd.Title;
                product.Code = exProd.Code;
                decimal our, original, suppl = 0;
                if (Decimal.TryParse(exProd.Sell, out our))
                {
                    product.OurPrice = our;
                }
                if (Decimal.TryParse(exProd.Retail, out original))
                {
                    product.OriginalPrice = original;
                }

                if (Decimal.TryParse(exProd.Buy, out suppl))
                {
                    product.SupplierPrice = suppl;
                }

                product.Description = "Produkti <br /><br />" + exProd.Title + "<br /><br />" + exProd.Desc.Replace("\n", "<br />");

                setCategories(CampaignId, query, product, exProd.Category, exProd.Sex, categoryParentF, categoryParentM);

                // inserting the product entity, we are on a "transaction" so everything will
                // be rolled back in case the other statements aren't successful
                Insert(product);
                setAttributes(categoriesList, product, exProd);
                setImages(product, exProd, encryptedCampId);
            }
        }