예제 #1
0
        private void setImages(PRODUCT product, FZExcelProduct exProd, string encryptedCampId)
        {

            string startFolder = Configuration.ImagesUploadPath + "\\" + encryptedCampId;

            // Take a snapshot of the file system.
            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(startFolder);
            IEnumerable<System.IO.FileInfo> fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories);

            //Create the query
            IEnumerable<System.IO.FileInfo> fileQuery =
                from file in fileList
                where file.Name.ToLower().Contains(exProd.Code.ToLower())
                orderby file.Name
                select file;

            //Execute the query
            PROD_IMAGES img;
            int count = 0;
            foreach (System.IO.FileInfo fi in fileQuery)
            {
                img = new PROD_IMAGES()
                {
                    ProductID = product.ID,
                    Image = "MED" + fi.Name,
                    LargeImage = fi.Name,
                    Thumbnail = "SMALL" + fi.Name,
                    Principal = false
                };

                if (count == 0)
                {
                    img.Principal = true;
                }
                fi.CopyTo(System.IO.Path.Combine(Configuration.ImagesUploadPath + fi.Name));
                // physical saving of all image versions
                GraphicsUtil.SaveProductImages(fi.Name, img.Principal.Value);

                InsertImage(img);
                Console.WriteLine(fi.FullName);
                count++;
            }
        }
예제 #2
0
        private void setAttributes(List<CATEGORY> categoriesList, PRODUCT product, FZExcelProduct exProd)
        {
            // TODO when different attributes used, this should be changed to be dynamic!
            int? sizeAttribute = categoriesList.FirstOrDefault().AttributeID;

            List<D_ATTRIBUTE_VALUE> attrValueList = _attributeDAO.GetAttributeValues(sizeAttribute.Value);
            PRODUCT_ATTRIBUTE prodAttr;
            int availability = 0;
            int attrValId = 0;

            // TODO this should be generalized for other attributes

            // XS size
            if (int.TryParse(exProd.SizeXS, out availability) && availability != 0)
            {
                attrValId = attrValueList.Where(a => a.Value.Equals("XS")).FirstOrDefault().ID;
                prodAttr = new PRODUCT_ATTRIBUTE()
                {
                    AttributeValueID = attrValId,
                    ProductID = product.ID,
                    Availability = availability,
                    Quantity = availability,
                };
                AddProductAttribute(prodAttr);
            }

            // S size
            if (int.TryParse(exProd.SizeS, out availability) && availability != 0)
            {
                attrValId = attrValueList.Where(a => a.Value.Equals("S")).FirstOrDefault().ID;
                prodAttr = new PRODUCT_ATTRIBUTE()
                {
                    AttributeValueID = attrValId,
                    ProductID = product.ID,
                    Availability = availability,
                    Quantity = availability,
                };
                AddProductAttribute(prodAttr);
            }

            // M size
            if (int.TryParse(exProd.SizeM, out availability) && availability != 0)
            {
                attrValId = attrValueList.Where(a => a.Value.Equals("M")).FirstOrDefault().ID;
                prodAttr = new PRODUCT_ATTRIBUTE()
                {
                    AttributeValueID = attrValId,
                    ProductID = product.ID,
                    Availability = availability,
                    Quantity = availability,
                };
                AddProductAttribute(prodAttr);
            }

            // L size
            if (int.TryParse(exProd.SizeL, out availability) && availability != 0)
            {
                attrValId = attrValueList.Where(a => a.Value.Equals("L")).FirstOrDefault().ID;
                prodAttr = new PRODUCT_ATTRIBUTE()
                {
                    AttributeValueID = attrValId,
                    ProductID = product.ID,
                    Availability = availability,
                    Quantity = availability,
                };
                AddProductAttribute(prodAttr);
            }

            // XL size
            if (int.TryParse(exProd.SizeXL, out availability) && availability != 0)
            {
                attrValId = attrValueList.Where(a => a.Value.Equals("XL")).FirstOrDefault().ID;
                prodAttr = new PRODUCT_ATTRIBUTE()
                {
                    AttributeValueID = attrValId,
                    ProductID = product.ID,
                    Availability = availability,
                    Quantity = availability,
                };
                AddProductAttribute(prodAttr);
            }

            // XXL size
            if (int.TryParse(exProd.SizeXXL, out availability) && availability != 0)
            {
                attrValId = attrValueList.Where(a => a.Value.Equals("XXL")).FirstOrDefault().ID;
                prodAttr = new PRODUCT_ATTRIBUTE()
                {
                    AttributeValueID = attrValId,
                    ProductID = product.ID,
                    Availability = availability,
                    Quantity = availability,
                };
                AddProductAttribute(prodAttr);
            }
        }