C# Class Nop.Services.Media.PictureService

Picture service
Inheritance: IPictureService
显示文件 Open project: jimmy00784/nopCommerce-Linux-Mysql

Public Methods

Method Description
DeletePicture ( Nop.Core.Domain.Media.Picture picture ) : void

Deletes a picture

GetDefaultPictureUrl ( int targetSize, PictureType defaultPictureType = PictureType.Entity, bool useSsl = null ) : string

Gets the default picture URL

GetPictureById ( int pictureId ) : Nop.Core.Domain.Media.Picture

Gets a picture

GetPictureLocalPath ( Nop.Core.Domain.Media.Picture picture, int targetSize, bool showDefaultPicture = true ) : string

Get a picture local path

GetPictureSeName ( string name ) : string

Get picture SEO friendly name

GetPictureUrl ( Nop.Core.Domain.Media.Picture picture, int targetSize, bool showDefaultPicture = true, bool useSsl = null ) : string

Get a picture URL

GetPictureUrl ( int pictureId, int targetSize, bool showDefaultPicture = true, bool useSsl = null ) : string

Get a picture URL

GetPictures ( int pageIndex, int pageSize ) : IPagedList

Gets a collection of pictures

GetPicturesByProductId ( int productId ) : IList

Gets pictures by product identifier

GetPicturesByProductId ( int productId, int recordsToReturn ) : IList

Gets pictures by product identifier

InsertPicture ( byte pictureBinary, string mimeType, string seoFilename, bool isNew ) : Nop.Core.Domain.Media.Picture

Inserts a picture

LoadPictureBinary ( Nop.Core.Domain.Media.Picture picture ) : byte[]

Gets the loaded picture binary depending on picture storage settings

LoadPictureBinary ( Nop.Core.Domain.Media.Picture picture, bool fromDb ) : byte[]

Gets the loaded picture binary depending on picture storage settings

LoadPictureFromFile ( int pictureId, string mimeType ) : byte[]

Loads a cpiture from file

PictureService ( IRepository pictureRepository, IRepository productPictureRepository, ISettingService settingService, IWebHelper webHelper, IEventPublisher eventPublisher, Nop.Core.Domain.Media.MediaSettings mediaSettings ) : System

Ctor

SetSeoFilename ( int pictureId, string seoFilename ) : Nop.Core.Domain.Media.Picture

Updates a SEO filename of a picture

UpdatePicture ( int pictureId, byte pictureBinary, string mimeType, string seoFilename, bool isNew ) : Nop.Core.Domain.Media.Picture

Updates the picture

ValidatePicture ( byte pictureBinary, string mimeType ) : byte[]

Validates input picture dimensions

Protected Methods

Method Description
CalculateDimensions ( Size originalSize, int targetSize ) : Size

Calculates picture dimensions whilst maintaining aspect

DeletePictureOnFileSystem ( Nop.Core.Domain.Media.Picture picture ) : void

Delete a picture on file system

DeletePictureThumbs ( Nop.Core.Domain.Media.Picture picture ) : void

Delete picture thumbs

GetFileExtensionFromMimeType ( string mimeType ) : string

Returns the file extension from mime type.

GetImageCodecInfoFromExtension ( string fileExt ) : ImageCodecInfo

Returns the first ImageCodecInfo instance with the specified extension.

GetImageCodecInfoFromMimeType ( string mimeType ) : ImageCodecInfo

Returns the first ImageCodecInfo instance with the specified mime type.

SavePictureInFile ( int pictureId, byte pictureBinary, string mimeType ) : void

Save picture on file system

Method Details

CalculateDimensions() protected method

Calculates picture dimensions whilst maintaining aspect
protected CalculateDimensions ( Size originalSize, int targetSize ) : Size
originalSize System.Drawing.Size The original picture size
targetSize int The target picture size (longest side)
return System.Drawing.Size

DeletePicture() public method

Deletes a picture
public DeletePicture ( Nop.Core.Domain.Media.Picture picture ) : void
picture Nop.Core.Domain.Media.Picture Picture
return void

DeletePictureOnFileSystem() protected method

Delete a picture on file system
protected DeletePictureOnFileSystem ( Nop.Core.Domain.Media.Picture picture ) : void
picture Nop.Core.Domain.Media.Picture Picture
return void

DeletePictureThumbs() protected method

Delete picture thumbs
protected DeletePictureThumbs ( Nop.Core.Domain.Media.Picture picture ) : void
picture Nop.Core.Domain.Media.Picture Picture
return void

GetDefaultPictureUrl() public method

Gets the default picture URL
public GetDefaultPictureUrl ( int targetSize, PictureType defaultPictureType = PictureType.Entity, bool useSsl = null ) : string
targetSize int The target picture size (longest side)
defaultPictureType PictureType Default picture type
useSsl bool Value indicating whether to get SSL protected picture URL; null to use the same value as the current page
return string

GetFileExtensionFromMimeType() protected method

Returns the file extension from mime type.
protected GetFileExtensionFromMimeType ( string mimeType ) : string
mimeType string Mime type
return string

GetImageCodecInfoFromExtension() protected method

Returns the first ImageCodecInfo instance with the specified extension.
protected GetImageCodecInfoFromExtension ( string fileExt ) : ImageCodecInfo
fileExt string File extension
return ImageCodecInfo

GetImageCodecInfoFromMimeType() protected method

Returns the first ImageCodecInfo instance with the specified mime type.
protected GetImageCodecInfoFromMimeType ( string mimeType ) : ImageCodecInfo
mimeType string Mime type
return ImageCodecInfo

GetPictureById() public method

Gets a picture
public GetPictureById ( int pictureId ) : Nop.Core.Domain.Media.Picture
pictureId int Picture identifier
return Nop.Core.Domain.Media.Picture

GetPictureLocalPath() public method

Get a picture local path
public GetPictureLocalPath ( Nop.Core.Domain.Media.Picture picture, int targetSize, bool showDefaultPicture = true ) : string
picture Nop.Core.Domain.Media.Picture Picture instance
targetSize int The target picture size (longest side)
showDefaultPicture bool A value indicating whether the default picture is shown
return string

GetPictureSeName() public method

Get picture SEO friendly name
public GetPictureSeName ( string name ) : string
name string Name
return string

GetPictureUrl() public method

Get a picture URL
public GetPictureUrl ( Nop.Core.Domain.Media.Picture picture, int targetSize, bool showDefaultPicture = true, bool useSsl = null ) : string
picture Nop.Core.Domain.Media.Picture Picture instance
targetSize int The target picture size (longest side)
showDefaultPicture bool A value indicating whether the default picture is shown
useSsl bool Value indicating whether to get SSL protected picture URL; null to use the same value as the current page
return string

GetPictureUrl() public method

Get a picture URL
public GetPictureUrl ( int pictureId, int targetSize, bool showDefaultPicture = true, bool useSsl = null ) : string
pictureId int Picture identifier
targetSize int The target picture size (longest side)
showDefaultPicture bool A value indicating whether the default picture is shown
useSsl bool Value indicating whether to get SSL protected picture URL; null to use the same value as the current page
return string

GetPictures() public method

Gets a collection of pictures
public GetPictures ( int pageIndex, int pageSize ) : IPagedList
pageIndex int Current page
pageSize int Items on each page
return IPagedList

GetPicturesByProductId() public method

Gets pictures by product identifier
public GetPicturesByProductId ( int productId ) : IList
productId int Product identifier
return IList

GetPicturesByProductId() public method

Gets pictures by product identifier
public GetPicturesByProductId ( int productId, int recordsToReturn ) : IList
productId int Product identifier
recordsToReturn int Number of records to return. 0 if you want to get all items
return IList

InsertPicture() public method

Inserts a picture
public InsertPicture ( byte pictureBinary, string mimeType, string seoFilename, bool isNew ) : Nop.Core.Domain.Media.Picture
pictureBinary byte The picture binary
mimeType string The picture MIME type
seoFilename string The SEO filename
isNew bool A value indicating whether the picture is new
return Nop.Core.Domain.Media.Picture

LoadPictureBinary() public method

Gets the loaded picture binary depending on picture storage settings
public LoadPictureBinary ( Nop.Core.Domain.Media.Picture picture ) : byte[]
picture Nop.Core.Domain.Media.Picture Picture
return byte[]

LoadPictureBinary() public method

Gets the loaded picture binary depending on picture storage settings
public LoadPictureBinary ( Nop.Core.Domain.Media.Picture picture, bool fromDb ) : byte[]
picture Nop.Core.Domain.Media.Picture Picture
fromDb bool Load from database; otherwise, from file system
return byte[]

LoadPictureFromFile() public method

Loads a cpiture from file
public LoadPictureFromFile ( int pictureId, string mimeType ) : byte[]
pictureId int Picture identifier
mimeType string MIME type
return byte[]

PictureService() public method

Ctor
public PictureService ( IRepository pictureRepository, IRepository productPictureRepository, ISettingService settingService, IWebHelper webHelper, IEventPublisher eventPublisher, Nop.Core.Domain.Media.MediaSettings mediaSettings ) : System
pictureRepository IRepository Picture repository
productPictureRepository IRepository Product picture repository
settingService ISettingService Setting service
webHelper IWebHelper Web helper
eventPublisher IEventPublisher Event publisher
mediaSettings Nop.Core.Domain.Media.MediaSettings Media settings
return System

SavePictureInFile() protected method

Save picture on file system
protected SavePictureInFile ( int pictureId, byte pictureBinary, string mimeType ) : void
pictureId int Picture identifier
pictureBinary byte Picture binary
mimeType string MIME type
return void

SetSeoFilename() public method

Updates a SEO filename of a picture
public SetSeoFilename ( int pictureId, string seoFilename ) : Nop.Core.Domain.Media.Picture
pictureId int The picture identifier
seoFilename string The SEO filename
return Nop.Core.Domain.Media.Picture

UpdatePicture() public method

Updates the picture
public UpdatePicture ( int pictureId, byte pictureBinary, string mimeType, string seoFilename, bool isNew ) : Nop.Core.Domain.Media.Picture
pictureId int The picture identifier
pictureBinary byte The picture binary
mimeType string The picture MIME type
seoFilename string The SEO filename
isNew bool A value indicating whether the picture is new
return Nop.Core.Domain.Media.Picture

ValidatePicture() public method

Validates input picture dimensions
public ValidatePicture ( byte pictureBinary, string mimeType ) : byte[]
pictureBinary byte Picture binary
mimeType string MIME type
return byte[]