/// <summary>
        /// 添加产品图片
        /// </summary>
        /// <param name="picture"></param>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static DataActionStatus Create(ProductPicture picture, Stream stream)
        {
            DataActionStatus status;

            picture = ShopDataProvider.Instance.CreateUpdatePicture(picture, DataProviderAction.Create, out status);
            if (status == DataActionStatus.Success)
            {
                FileStorageProvider fs = new FileStorageProvider(FileStoreKey);
                fs.AddUpdateFile(MakePath(picture.ProductID), picture.PictureFile, stream);

                HHCache.Instance.Remove(CacheKeyManager.GetPictureKey(picture.PictureID));
                HHCache.Instance.Remove(CacheKeyManager.GetPictureKeyByProductID(picture.ProductID));
            }
            return(status);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新行业信息
        /// </summary>
        /// <param name="industry"></param>
        /// <param name="contentStream"></param>
        public static DataActionStatus Update(ProductIndustry industry, Stream contentStream)
        {
            DataActionStatus status;

            ShopDataProvider.Instance.CreateUpdateIndustry(industry, DataProviderAction.Update, out status);
            if (status == DataActionStatus.Success)
            {
                if (contentStream != null && contentStream.Length > 0)
                {
                    FileStorageProvider fs = new FileStorageProvider(FileStoreKey);
                    fs.AddUpdateFile(MakePath(industry.IndustryID), industry.IndustryLogo, contentStream);
                }
                HHCache.Instance.RemoveByPattern(CacheKeyManager.ProductIndustryXpath);
                OnUpdated(industry.IndustryID);
            }
            return(status);
        }
Esempio n. 3
0
        public IStorageFile GetResizedFileUrl(string fileStoreKey, string path, string fileName, int width, int height)
        {
            string resizedFileName = fileName + "-" + width.ToString() + "x" + height.ToString() + ".";
            string resizedPath     = Path.Combine(path, "ResizeImages");

            System.Drawing.Imaging.ImageFormat format;
            string extension = GlobalSettings.GetExtension(fileName).ToLower();

            if (extension == "png" || extension == "gif")
            {
                format           = System.Drawing.Imaging.ImageFormat.Png;
                resizedFileName += "png";
            }
            else
            {
                format           = System.Drawing.Imaging.ImageFormat.Jpeg;
                resizedFileName += "jpg";
            }
            FileStorageProvider fileProvider = new FileStorageProvider(fileStoreKey);
            IStorageFile        file         = fileProvider.GetFile(resizedPath, resizedFileName);

            if (file == null)
            {
                IStorageFile originalFile = null;

                if (fileProvider != null)
                {
                    originalFile = fileProvider.GetFile(path, fileName);
                }

                if (originalFile != null)
                {
                    using (Stream sourceStream = originalFile.OpenReadStream())
                    {
                        using (Stream imageStream = GlobalSettings.ResizeImage(sourceStream, height, width, format))
                        {
                            file = fileProvider.AddUpdateFile(resizedPath, resizedFileName, imageStream);
                            imageStream.Close();
                        }
                        sourceStream.Close();
                    }
                }
            }
            return(file);
        }
        /// <summary>
        /// 添加品牌信息
        /// </summary>
        /// <param name="brand"></param>
        /// <param name="contentStream"></param>
        public static DataActionStatus Create(ProductBrand brand, Stream contentStream)
        {
            DataActionStatus status;

            brand = ShopDataProvider.Instance.CreateUpdateBrand(brand, DataProviderAction.Create, out status);
            if (status == DataActionStatus.Success)
            {
                if (contentStream != null && contentStream.Length > 0)
                {
                    FileStorageProvider fs = new FileStorageProvider(FileStoreKey);
                    fs.AddUpdateFile(MakePath(brand.BrandID), brand.BrandLogo, contentStream);
                }
                HHCache.Instance.RemoveByPattern(CacheKeyManager.ProductBrandXpath);
                OnUpdated(brand.BrandID);
                //HHCache.Instance.Remove(CacheKeyManager.ProductBrandKey);
            }
            return(status);
        }