@ -22,6 +22,8 @@ namespace MediaBrowser.Api.Reports
public class ReportBuilder : ReportBuilderBase
{
#region [Constructors]
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportBuilder class. </summary>
/// <param name="libraryManager"> Manager for library. </param>
@ -30,22 +32,31 @@ namespace MediaBrowser.Api.Reports
{
}
private Func < bool , string > GetBoolString = s = > s = = true ? "x" : "" ;
# endregion
#region [Public Methods]
public ReportResult GetReportResult ( BaseItem [ ] items , ReportViewType reportRowType , BaseReportRequest request )
/// <summary> Gets report result. </summary>
/// <param name="items"> The items. </param>
/// <param name="request"> The request. </param>
/// <returns> The report result. </returns>
public ReportResult GetResult ( BaseItem [ ] items , IReportsQuery request )
{
List < HeaderMetadata > headersMetadata = this . GetFilteredReportHeaderMetadata ( reportRowType , request ) ;
ReportIncludeItemTypes reportRowType = ReportHelper . GetRowType ( request . IncludeItemTypes ) ;
List < ReportOptions < BaseItem > > options = this . GetReportOptions < BaseItem > ( request ,
( ) = > this . GetDefaultHeaderMetadata ( reportRowType ) ,
( hm ) = > this . GetOption ( hm ) ) . Where ( x = > x . Header . Visible = = true ) . ToList ( ) ;
var headers = GetReportHeaders ( reportRowType , headersMetadata ) ;
var rows = GetReportRows ( items , headersMetadata ) ;
var headers = GetHeaders < BaseItem > ( options ) ;
var rows = GetReportRows ( items , options ) ;
ReportResult result = new ReportResult { Headers = headers } ;
HeaderMetadata groupBy = ReportHelper . GetHeaderMetadataType ( request . GroupBy ) ;
int i = headers . FindIndex ( x = > x . FieldName = = groupBy ) ;
if ( groupBy ! = HeaderMetadata . None & & i > 0 )
if ( groupBy ! = HeaderMetadata . None & & i > = 0 )
{
var rowsGroup = rows . SelectMany ( x = > x . Columns [ i ] . Name . Split ( ';' ) , ( x , g ) = > new { G enre = g . Trim ( ) , Rows = x } )
. GroupBy ( x = > x . Genre )
var rowsGroup = rows . SelectMany ( x = > x . Columns [ i ] . Name . Split ( ';' ) , ( x , g ) = > new { G roup = g . Trim ( ) , Rows = x } )
. GroupBy ( x = > x . Group )
. OrderBy ( x = > x . Key )
. Select ( x = > new ReportGroup { Name = x . Key , Rows = x . Select ( r = > r . Rows ) . ToList ( ) } ) ;
@ -61,117 +72,33 @@ namespace MediaBrowser.Api.Reports
return result ;
}
public List < ReportHeader > GetReportHeaders ( ReportViewType reportRowType , BaseReportRequest request )
{
List < ReportHeader > headersMetadata = this . GetReportHeaders ( reportRowType ) ;
if ( request ! = null & & ! string . IsNullOrEmpty ( request . ReportColumns ) )
{
List < HeaderMetadata > headersMetadataFiltered = this . GetFilteredReportHeaderMetadata ( reportRowType , request ) ;
foreach ( ReportHeader reportHeader in headersMetadata )
{
if ( ! headersMetadataFiltered . Contains ( reportHeader . FieldName ) )
{
reportHeader . Visible = false ;
}
}
# endregion
}
return headersMetadata ;
}
public List < ReportHeader > GetReportHeaders ( ReportViewType reportRowType , List < HeaderMetadata > headersMetadata = null )
{
if ( headersMetadata = = null )
headersMetadata = this . GetDefaultReportHeaderMetadata ( reportRowType ) ;
List < ReportOptions < BaseItem > > options = new List < ReportOptions < BaseItem > > ( ) ;
foreach ( HeaderMetadata header in headersMetadata )
{
options . Add ( GetReportOption ( header ) ) ;
}
#region [Protected Internal Methods]
List < ReportHeader > headers = new List < ReportHeader > ( ) ;
foreach ( ReportOptions < BaseItem > option in options )
{
headers . Add ( option . Header ) ;
}
return headers ;
}
private List < ReportRow > GetReportRows ( IEnumerable < BaseItem > items , List < HeaderMetadata > headersMetadata )
{
List < ReportOptions < BaseItem > > options = new List < ReportOptions < BaseItem > > ( ) ;
foreach ( HeaderMetadata header in headersMetadata )
{
options . Add ( GetReportOption ( header ) ) ;
}
var rows = new List < ReportRow > ( ) ;
foreach ( BaseItem item in items )
{
ReportRow rRow = GetRow ( item ) ;
foreach ( ReportOptions < BaseItem > option in options )
/// <summary> Gets the headers. </summary>
/// <typeparam name="H"> Type of the header. </typeparam>
/// <param name="request"> The request. </param>
/// <returns> The headers. </returns>
/// <seealso cref="M:MediaBrowser.Api.Reports.ReportBuilderBase.GetHeaders{H}(H)"/>
protected internal override List < ReportHeader > GetHeaders < H > ( H request )
{
object itemColumn = option . Column ! = null ? option . Column ( item , rRow ) : "" ;
object itemId = option . ItemID ! = null ? option . ItemID ( item ) : "" ;
ReportItem rItem = new ReportItem
{
Name = ReportHelper . ConvertToString ( itemColumn , option . Header . HeaderFieldType ) ,
Id = ReportHelper . ConvertToString ( itemId , ReportFieldType . Object )
} ;
rRow . Columns . Add ( rItem ) ;
ReportIncludeItemTypes reportRowType = ReportHelper . GetRowType ( request . IncludeItemTypes ) ;
return this . GetHeaders < BaseItem > ( request , ( ) = > this . GetDefaultHeaderMetadata ( reportRowType ) , ( hm ) = > this . GetOption ( hm ) ) ;
}
rows . Add ( rRow ) ;
}
# endregion
return rows ;
}
#region [Private Methods]
/// <summary> Gets a row . </summary>
/// <param name="item"> The item . </param>
/// <returns> The row . </returns>
private ReportRow GetRow ( BaseItem item )
/// <summary> Gets default report header metadata. </summary>
/// <param name="reportIncludeItemTypes"> Type of the report row. </param>
/// <returns> The default report header metadata. </returns>
private List < HeaderMetadata > GetDefaultHeaderMetadata ( ReportIncludeItemTypes reportIncludeItemTypes )
{
var hasTrailers = item as IHasTrailers ;
var hasSpecialFeatures = item as IHasSpecialFeatures ;
var video = item as Video ;
ReportRow rRow = new ReportRow
switch ( reportIncludeItemTypes )
{
Id = item . Id . ToString ( "N" ) ,
HasLockData = item . IsLocked ,
IsUnidentified = item . IsUnidentified ,
HasLocalTrailer = hasTrailers ! = null ? hasTrailers . GetTrailerIds ( ) . Count ( ) > 0 : false ,
HasImageTagsPrimary = ( item . ImageInfos ! = null & & item . ImageInfos . Count ( n = > n . Type = = ImageType . Primary ) > 0 ) ,
HasImageTagsBackdrop = ( item . ImageInfos ! = null & & item . ImageInfos . Count ( n = > n . Type = = ImageType . Backdrop ) > 0 ) ,
HasImageTagsLogo = ( item . ImageInfos ! = null & & item . ImageInfos . Count ( n = > n . Type = = ImageType . Logo ) > 0 ) ,
HasSpecials = hasSpecialFeatures ! = null ? hasSpecialFeatures . SpecialFeatureIds . Count > 0 : false ,
HasSubtitles = video ! = null ? video . HasSubtitles : false ,
RowType = ReportHelper . GetRowType ( item . GetClientTypeName ( ) )
} ;
return rRow ;
}
public List < HeaderMetadata > GetFilteredReportHeaderMetadata ( ReportViewType reportRowType , BaseReportRequest request )
{
if ( request ! = null & & ! string . IsNullOrEmpty ( request . ReportColumns ) )
{
var s = request . ReportColumns . Split ( '|' ) . Select ( x = > ReportHelper . GetHeaderMetadataType ( x ) ) . Where ( x = > x ! = HeaderMetadata . None ) ;
return s . ToList ( ) ;
}
else
return this . GetDefaultReportHeaderMetadata ( reportRowType ) ;
}
public List < HeaderMetadata > GetDefaultReportHeaderMetadata ( ReportViewType reportRowType )
{
switch ( reportRowType )
{
case ReportViewType . Season :
case ReportIncludeItemTypes . Season :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -183,7 +110,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Genres
} ;
case ReportViewType . Series :
case ReportIncludeItemTypes . Series :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -199,7 +126,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Specials
} ;
case ReportViewType . MusicAlbum :
case ReportIncludeItemTypes . MusicAlbum :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -212,7 +139,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Genres
} ;
case ReportViewType . MusicArtist :
case ReportIncludeItemTypes . MusicArtist :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -223,7 +150,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Genres
} ;
case ReportViewType . Game :
case ReportIncludeItemTypes . Game :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -239,7 +166,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Trailers
} ;
case ReportViewType . Movie :
case ReportIncludeItemTypes . Movie :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -259,7 +186,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Specials
} ;
case ReportViewType . Book :
case ReportIncludeItemTypes . Book :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -272,7 +199,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . CommunityRating
} ;
case ReportViewType . BoxSet :
case ReportIncludeItemTypes . BoxSet :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -286,7 +213,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Trailers
} ;
case ReportViewType . Audio :
case ReportIncludeItemTypes . Audio :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -305,7 +232,7 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Audio
} ;
case ReportViewType . Episode :
case ReportIncludeItemTypes . Episode :
return new List < HeaderMetadata >
{
HeaderMetadata . StatusImage ,
@ -327,10 +254,10 @@ namespace MediaBrowser.Api.Reports
HeaderMetadata . Specials
} ;
case ReportViewType . Video :
case ReportViewType . MusicVideo :
case ReportViewType . Trailer :
case ReportViewType . BaseItem :
case ReportIncludeItemTypes . Video :
case ReportIncludeItemTypes . MusicVideo :
case ReportIncludeItemTypes . Trailer :
case ReportIncludeItemTypes . BaseItem :
default :
return new List < HeaderMetadata >
{
@ -359,231 +286,274 @@ namespace MediaBrowser.Api.Reports
/// <param name="header"> The header. </param>
/// <param name="sortField"> The sort field. </param>
/// <returns> The report option. </returns>
private ReportOptions < BaseItem > Ge tRepor tOption( HeaderMetadata header , string sortField = "" )
private ReportOptions < BaseItem > Ge tOption( HeaderMetadata header , string sortField = "" )
{
ReportHeader reportHeader = new ReportHeader
HeaderMetadata internalHeader = header ;
ReportOptions < BaseItem > option = new ReportOptions < BaseItem > ( )
{
Header = new ReportHeader
{
HeaderFieldType = ReportFieldType . String ,
SortField = sortField ,
Type = "" ,
ItemViewType = ItemViewType . None
}
} ;
Func < BaseItem , ReportRow , object > column = null ;
Func < BaseItem , object > itemId = null ;
HeaderMetadata internalHeader = header ;
switch ( header )
{
case HeaderMetadata . StatusImage :
report Header. ItemViewType = ItemViewType . StatusImage ;
option . Header . ItemViewType = ItemViewType . StatusImage ;
internalHeader = HeaderMetadata . Status ;
report Header. CanGroup = false ;
option . Header. CanGroup = false ;
break ;
case HeaderMetadata . Name :
c olumn = ( i , r ) = > i . Name ;
report Header. ItemViewType = ItemViewType . Detail ;
report Header. SortField = "SortName" ;
option . C olumn = ( i , r ) = > i . Name ;
option . Header. ItemViewType = ItemViewType . Detail ;
option . Header. SortField = "SortName" ;
break ;
case HeaderMetadata . DateAdded :
c olumn = ( i , r ) = > i . DateCreated ;
report Header. SortField = "DateCreated,SortName" ;
report Header. HeaderFieldType = ReportFieldType . DateTime ;
report Header. Type = "" ;
option . C olumn = ( i , r ) = > i . DateCreated ;
option . Header. SortField = "DateCreated,SortName" ;
option . Header. HeaderFieldType = ReportFieldType . DateTime ;
option . Header. Type = "" ;
break ;
case HeaderMetadata . PremiereDate :
case HeaderMetadata . ReleaseDate :
c olumn = ( i , r ) = > i . PremiereDate ;
report Header. HeaderFieldType = ReportFieldType . DateTime ;
report Header. SortField = "ProductionYear,PremiereDate,SortName" ;
option . C olumn = ( i , r ) = > i . PremiereDate ;
option . Header. HeaderFieldType = ReportFieldType . DateTime ;
option . Header. SortField = "ProductionYear,PremiereDate,SortName" ;
break ;
case HeaderMetadata . Runtime :
c olumn = ( i , r ) = > this . GetRuntimeDateTime ( i . RunTimeTicks ) ;
report Header. HeaderFieldType = ReportFieldType . Minutes ;
report Header. SortField = "Runtime,SortName" ;
option . C olumn = ( i , r ) = > this . GetRuntimeDateTime ( i . RunTimeTicks ) ;
option . Header. HeaderFieldType = ReportFieldType . Minutes ;
option . Header. SortField = "Runtime,SortName" ;
break ;
case HeaderMetadata . PlayCount :
report Header. HeaderFieldType = ReportFieldType . Int ;
option . Header. HeaderFieldType = ReportFieldType . Int ;
break ;
case HeaderMetadata . Season :
c olumn = ( i , r ) = > this . GetEpisode ( i ) ;
report Header. ItemViewType = ItemViewType . Detail ;
report Header. SortField = "SortName" ;
option . C olumn = ( i , r ) = > this . GetEpisode ( i ) ;
option . Header. ItemViewType = ItemViewType . Detail ;
option . Header. SortField = "SortName" ;
break ;
case HeaderMetadata . SeasonNumber :
c olumn = ( i , r ) = > this . GetObject < Season , string > ( i , ( x ) = > x . IndexNumber = = null ? "" : x . IndexNumber . ToString ( ) ) ;
report Header. SortField = "IndexNumber" ;
report Header. HeaderFieldType = ReportFieldType . Int ;
option . C olumn = ( i , r ) = > this . GetObject < Season , string > ( i , ( x ) = > x . IndexNumber = = null ? "" : x . IndexNumber . ToString ( ) ) ;
option . Header. SortField = "IndexNumber" ;
option . Header. HeaderFieldType = ReportFieldType . Int ;
break ;
case HeaderMetadata . Series :
c olumn = ( i , r ) = > this . GetObject < IHasSeries , string > ( i , ( x ) = > x . SeriesName ) ;
report Header. ItemViewType = ItemViewType . Detail ;
report Header. SortField = "SeriesSortName,SortName" ;
option . C olumn = ( i , r ) = > this . GetObject < IHasSeries , string > ( i , ( x ) = > x . SeriesName ) ;
option . Header. ItemViewType = ItemViewType . Detail ;
option . Header. SortField = "SeriesSortName,SortName" ;
break ;
case HeaderMetadata . EpisodeSeries :
c olumn = ( i , r ) = > this . GetObject < IHasSeries , string > ( i , ( x ) = > x . SeriesName ) ;
report Header. ItemViewType = ItemViewType . Detail ;
itemId = ( i ) = >
option . C olumn = ( i , r ) = > this . GetObject < IHasSeries , string > ( i , ( x ) = > x . SeriesName ) ;
option . Header. ItemViewType = ItemViewType . Detail ;
option . ItemID = ( i ) = >
{
Series series = this . GetObject < Episode , Series > ( i , ( x ) = > x . Series ) ;
if ( series = = null )
return string . Empty ;
return series . Id ;
} ;
report Header. SortField = "SeriesSortName,SortName" ;
option . Header. SortField = "SeriesSortName,SortName" ;
internalHeader = HeaderMetadata . Series ;
break ;
case HeaderMetadata . EpisodeSeason :
c olumn = ( i , r ) = > this . GetObject < IHasSeries , string > ( i , ( x ) = > x . SeriesName ) ;
report Header. ItemViewType = ItemViewType . Detail ;
itemId = ( i ) = >
option . C olumn = ( i , r ) = > this . GetObject < IHasSeries , string > ( i , ( x ) = > x . SeriesName ) ;
option . Header. ItemViewType = ItemViewType . Detail ;
option . ItemID = ( i ) = >
{
Season season = this . GetObject < Episode , Season > ( i , ( x ) = > x . Season ) ;
if ( season = = null )
return string . Empty ;
return season . Id ;
} ;
report Header. SortField = "SortName" ;
option . Header. SortField = "SortName" ;
internalHeader = HeaderMetadata . Season ;
break ;
case HeaderMetadata . Network :
c olumn = ( i , r ) = > this . GetListAsString ( i . Studios ) ;
itemId = ( i ) = > this . GetStudioID ( i . Studios . FirstOrDefault ( ) ) ;
report Header. ItemViewType = ItemViewType . ItemByNameDetails ;
report Header. SortField = "Studio,SortName" ;
option . C olumn = ( i , r ) = > this . GetListAsString ( i . Studios ) ;
option . ItemID = ( i ) = > this . GetStudioID ( i . Studios . FirstOrDefault ( ) ) ;
option . Header. ItemViewType = ItemViewType . ItemByNameDetails ;
option . Header. SortField = "Studio,SortName" ;
break ;
case HeaderMetadata . Year :
c olumn = ( i , r ) = > this . GetSeriesProductionYear ( i ) ;
report Header. SortField = "ProductionYear,PremiereDate,SortName" ;
option . C olumn = ( i , r ) = > this . GetSeriesProductionYear ( i ) ;
option . Header. SortField = "ProductionYear,PremiereDate,SortName" ;
break ;
case HeaderMetadata . ParentalRating :
c olumn = ( i , r ) = > i . OfficialRating ;
report Header. SortField = "OfficialRating,SortName" ;
option . C olumn = ( i , r ) = > i . OfficialRating ;
option . Header. SortField = "OfficialRating,SortName" ;
break ;
case HeaderMetadata . CommunityRating :
c olumn = ( i , r ) = > i . CommunityRating ;
report Header. SortField = "CommunityRating,SortName" ;
option . C olumn = ( i , r ) = > i . CommunityRating ;
option . Header. SortField = "CommunityRating,SortName" ;
break ;
case HeaderMetadata . Trailers :
c olumn = ( i , r ) = > this . GetBoolString ( r . HasLocalTrailer ) ;
report Header. ItemViewType = ItemViewType . TrailersImage ;
option . C olumn = ( i , r ) = > this . GetBoolString ( r . HasLocalTrailer ) ;
option . Header. ItemViewType = ItemViewType . TrailersImage ;
break ;
case HeaderMetadata . Specials :
c olumn = ( i , r ) = > this . GetBoolString ( r . HasSpecials ) ;
report Header. ItemViewType = ItemViewType . SpecialsImage ;
option . C olumn = ( i , r ) = > this . GetBoolString ( r . HasSpecials ) ;
option . Header. ItemViewType = ItemViewType . SpecialsImage ;
break ;
case HeaderMetadata . GameSystem :
c olumn = ( i , r ) = > this . GetObject < Game , string > ( i , ( x ) = > x . GameSystem ) ;
report Header. SortField = "GameSystem,SortName" ;
option . C olumn = ( i , r ) = > this . GetObject < Game , string > ( i , ( x ) = > x . GameSystem ) ;
option . Header. SortField = "GameSystem,SortName" ;
break ;
case HeaderMetadata . Players :
c olumn = ( i , r ) = > this . GetObject < Game , int? > ( i , ( x ) = > x . PlayersSupported ) ;
report Header. SortField = "Players,GameSystem,SortName" ;
option . C olumn = ( i , r ) = > this . GetObject < Game , int? > ( i , ( x ) = > x . PlayersSupported ) ;
option . Header. SortField = "Players,GameSystem,SortName" ;
break ;
case HeaderMetadata . AlbumArtist :
c olumn = ( i , r ) = > this . GetObject < MusicAlbum , string > ( i , ( x ) = > x . AlbumArtist ) ;
itemId = ( i ) = > this . GetPersonID ( this . GetObject < MusicAlbum , string > ( i , ( x ) = > x . AlbumArtist ) ) ;
report Header. ItemViewType = ItemViewType . Detail ;
report Header. SortField = "AlbumArtist,Album,SortName" ;
option . C olumn = ( i , r ) = > this . GetObject < MusicAlbum , string > ( i , ( x ) = > x . AlbumArtist ) ;
option . ItemID = ( i ) = > this . GetPersonID ( this . GetObject < MusicAlbum , string > ( i , ( x ) = > x . AlbumArtist ) ) ;
option . Header. ItemViewType = ItemViewType . Detail ;
option . Header. SortField = "AlbumArtist,Album,SortName" ;
break ;
case HeaderMetadata . MusicArtist :
c olumn = ( i , r ) = > this . GetObject < MusicArtist , string > ( i , ( x ) = > x . GetLookupInfo ( ) . Name ) ;
report Header. ItemViewType = ItemViewType . Detail ;
report Header. SortField = "AlbumArtist,Album,SortName" ;
option . C olumn = ( i , r ) = > this . GetObject < MusicArtist , string > ( i , ( x ) = > x . GetLookupInfo ( ) . Name ) ;
option . Header. ItemViewType = ItemViewType . Detail ;
option . Header. SortField = "AlbumArtist,Album,SortName" ;
internalHeader = HeaderMetadata . AlbumArtist ;
break ;
case HeaderMetadata . AudioAlbumArtist :
c olumn = ( i , r ) = > this . GetListAsString ( this . GetObject < Audio , List < string > > ( i , ( x ) = > x . AlbumArtists ) ) ;
report Header. SortField = "AlbumArtist,Album,SortName" ;
option . C olumn = ( i , r ) = > this . GetListAsString ( this . GetObject < Audio , List < string > > ( i , ( x ) = > x . AlbumArtists ) ) ;
option . Header. SortField = "AlbumArtist,Album,SortName" ;
internalHeader = HeaderMetadata . AlbumArtist ;
break ;
case HeaderMetadata . AudioAlbum :
c olumn = ( i , r ) = > this . GetObject < Audio , string > ( i , ( x ) = > x . Album ) ;
report Header. SortField = "Album,SortName" ;
option . C olumn = ( i , r ) = > this . GetObject < Audio , string > ( i , ( x ) = > x . Album ) ;
option . Header. SortField = "Album,SortName" ;
internalHeader = HeaderMetadata . Album ;
break ;
case HeaderMetadata . Countries :
c olumn = ( i , r ) = > this . GetListAsString ( this . GetObject < IHasProductionLocations , List < string > > ( i , ( x ) = > x . ProductionLocations ) ) ;
option . C olumn = ( i , r ) = > this . GetListAsString ( this . GetObject < IHasProductionLocations , List < string > > ( i , ( x ) = > x . ProductionLocations ) ) ;
break ;
case HeaderMetadata . Disc :
c olumn = ( i , r ) = > i . ParentIndexNumber ;
option . C olumn = ( i , r ) = > i . ParentIndexNumber ;
break ;
case HeaderMetadata . Track :
c olumn = ( i , r ) = > i . IndexNumber ;
option . C olumn = ( i , r ) = > i . IndexNumber ;
break ;
case HeaderMetadata . Tracks :
c olumn = ( i , r ) = > this . GetObject < MusicAlbum , List < Audio > > ( i , ( x ) = > x . Tracks . ToList ( ) , new List < Audio > ( ) ) . Count ( ) ;
option . C olumn = ( i , r ) = > this . GetObject < MusicAlbum , List < Audio > > ( i , ( x ) = > x . Tracks . ToList ( ) , new List < Audio > ( ) ) . Count ( ) ;
break ;
case HeaderMetadata . Audio :
c olumn = ( i , r ) = > this . GetAudioStream ( i ) ;
option . C olumn = ( i , r ) = > this . GetAudioStream ( i ) ;
break ;
case HeaderMetadata . EmbeddedImage :
break ;
case HeaderMetadata . Video :
c olumn = ( i , r ) = > this . GetVideoStream ( i ) ;
option . C olumn = ( i , r ) = > this . GetVideoStream ( i ) ;
break ;
case HeaderMetadata . Resolution :
c olumn = ( i , r ) = > this . GetVideoResolution ( i ) ;
option . C olumn = ( i , r ) = > this . GetVideoResolution ( i ) ;
break ;
case HeaderMetadata . Subtitles :
c olumn = ( i , r ) = > this . GetBoolString ( r . HasSubtitles ) ;
report Header. ItemViewType = ItemViewType . SubtitleImage ;
option . C olumn = ( i , r ) = > this . GetBoolString ( r . HasSubtitles ) ;
option . Header. ItemViewType = ItemViewType . SubtitleImage ;
break ;
case HeaderMetadata . Genres :
c olumn = ( i , r ) = > this . GetListAsString ( i . Genres ) ;
option . C olumn = ( i , r ) = > this . GetListAsString ( i . Genres ) ;
break ;
}
string headerName = "" ;
if ( internalHeader ! = HeaderMetadata . None )
option . Header . Name = GetLocalizedHeader ( internalHeader ) ;
option . Header . FieldName = header ;
return option ;
}
/// <summary> Gets report rows. </summary>
/// <param name="items"> The items. </param>
/// <param name="options"> Options for controlling the operation. </param>
/// <returns> The report rows. </returns>
private List < ReportRow > GetReportRows ( IEnumerable < BaseItem > items , List < ReportOptions < BaseItem > > options )
{
var rows = new List < ReportRow > ( ) ;
foreach ( BaseItem item in items )
{
ReportRow rRow = GetRow ( item ) ;
foreach ( ReportOptions < BaseItem > option in options )
{
object itemColumn = option . Column ! = null ? option . Column ( item , rRow ) : "" ;
object itemId = option . ItemID ! = null ? option . ItemID ( item ) : "" ;
ReportItem rItem = new ReportItem
{
string localHeader = "Header" + internalHeader . ToString ( ) ;
headerName = internalHeader ! = HeaderMetadata . None ? ReportHelper . GetJavaScriptLocalizedString ( localHeader ) : "" ;
if ( string . Compare ( localHeader , headerName , StringComparison . CurrentCultureIgnoreCase ) = = 0 )
headerName = ReportHelper . GetServerLocalizedString ( localHeader ) ;
Name = ReportHelper . ConvertToString ( itemColumn , option . Header . HeaderFieldType ) ,
Id = ReportHelper . ConvertToString ( itemId , ReportFieldType . Object )
} ;
rRow . Columns . Add ( rItem ) ;
}
reportHeader . Name = headerName ;
reportHeader . FieldName = header ;
ReportOptions < BaseItem > option = new ReportOptions < BaseItem > ( )
rows . Add ( rRow ) ;
}
return rows ;
}
/// <summary> Gets a row. </summary>
/// <param name="item"> The item. </param>
/// <returns> The row. </returns>
private ReportRow GetRow ( BaseItem item )
{
var hasTrailers = item as IHasTrailers ;
var hasSpecialFeatures = item as IHasSpecialFeatures ;
var video = item as Video ;
ReportRow rRow = new ReportRow
{
Header = reportHeader ,
Column = column ,
ItemID = itemId
Id = item . Id . ToString ( "N" ) ,
HasLockData = item . IsLocked ,
IsUnidentified = item . IsUnidentified ,
HasLocalTrailer = hasTrailers ! = null ? hasTrailers . GetTrailerIds ( ) . Count ( ) > 0 : false ,
HasImageTagsPrimary = ( item . ImageInfos ! = null & & item . ImageInfos . Count ( n = > n . Type = = ImageType . Primary ) > 0 ) ,
HasImageTagsBackdrop = ( item . ImageInfos ! = null & & item . ImageInfos . Count ( n = > n . Type = = ImageType . Backdrop ) > 0 ) ,
HasImageTagsLogo = ( item . ImageInfos ! = null & & item . ImageInfos . Count ( n = > n . Type = = ImageType . Logo ) > 0 ) ,
HasSpecials = hasSpecialFeatures ! = null ? hasSpecialFeatures . SpecialFeatureIds . Count > 0 : false ,
HasSubtitles = video ! = null ? video . HasSubtitles : false ,
RowType = ReportHelper . GetRowType ( item . GetClientTypeName ( ) )
} ;
return option ;
return rRow ;
}
# endregion
}
}