Esempio n. 1
0
        private string GetFileName(Nop190_Picture picture)
        {
            string extension = GetExtension(picture);
            //string fileName = string.IsNullOrWhiteSpace(picture.SeoFilename)
            //    ? picture.Id.ToString()
            //    : picture.SeoFilename;
            //return string.Concat(fileName, extension);

            // GM: SeoFilename is new field
            string fileName = picture.PictureID.ToString();

            return(string.Concat(fileName, extension));
        }
Esempio n. 2
0
        private static string GetExtension(Nop190_Picture picture)
        {
            switch (picture.MimeType)
            {
            case "image/png":
                return(".png");

            case "image/gif":
                return(".gif");

            case "image/pjpeg":
                return(".jpg");

            default:
                return(".jpeg");
            }
        }
Esempio n. 3
0
        private Stream GetData(Nop190_Picture picture, PictureInfo pictureInfo)
        {
            string fileName = picture.PictureID.ToString().PadLeft(7, '0') + "_0" + GetExtension(picture);

            switch (pictureInfo.PictureLocation)
            {
            case PictureLocation.OnDisc:
                string discFolderLocation = GetOnDiscFolderLocation(pictureInfo.LocationData);
                return(File.OpenRead(discFolderLocation + fileName));

            case PictureLocation.Url:
                string webFolder = GetWebFolderLocation(pictureInfo.LocationData);
                return(WebRequest.Create(webFolder + fileName).GetResponse().GetResponseStream());

            case PictureLocation.Database:
                return(new MemoryStream(picture.PictureBinary.ToArray()));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }