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