Example #1
0
 /// <summary>
 /// Initializes a new instance of the ReportOptions class.
 /// </summary>
 /// <param name="header"></param>
 /// <param name="column"></param>
 /// <param name="itemID"></param>
 public ReportOptions(ReportHeader header, Func <I, ReportRow, object> column, Func <I, object> itemID)
 {
     Header = header;
     Column = column;
     ItemID = itemID;
 }
Example #2
0
        /// <summary> Gets report option. </summary>
        /// <param name="header"> The header. </param>
        /// <param name="sortField"> The sort field. </param>
        /// <returns> The report option. </returns>
        private ReportOptions <BaseItem> GetReportOption(HeaderMetadata header, string sortField = "")
        {
            ReportHeader reportHeader = 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:
                reportHeader.ItemViewType = ItemViewType.StatusImage;
                internalHeader            = HeaderMetadata.Status;
                reportHeader.CanGroup     = false;
                break;

            case HeaderMetadata.Name:
                column = (i, r) => i.Name;
                reportHeader.ItemViewType = ItemViewType.Detail;
                reportHeader.SortField    = "SortName";
                break;

            case HeaderMetadata.DateAdded:
                column = (i, r) => i.DateCreated;
                reportHeader.SortField       = "DateCreated,SortName";
                reportHeader.HeaderFieldType = ReportFieldType.DateTime;
                reportHeader.Type            = "";
                break;

            case HeaderMetadata.PremiereDate:
            case HeaderMetadata.ReleaseDate:
                column = (i, r) => i.PremiereDate;
                reportHeader.HeaderFieldType = ReportFieldType.DateTime;
                reportHeader.SortField       = "ProductionYear,PremiereDate,SortName";
                break;

            case HeaderMetadata.Runtime:
                column = (i, r) => this.GetRuntimeDateTime(i.RunTimeTicks);
                reportHeader.HeaderFieldType = ReportFieldType.Minutes;
                reportHeader.SortField       = "Runtime,SortName";
                break;

            case HeaderMetadata.PlayCount:
                reportHeader.HeaderFieldType = ReportFieldType.Int;
                break;

            case HeaderMetadata.Season:
                column = (i, r) => this.GetEpisode(i);
                reportHeader.ItemViewType = ItemViewType.Detail;
                reportHeader.SortField    = "SortName";
                break;

            case HeaderMetadata.SeasonNumber:
                column = (i, r) => this.GetObject <Season, string>(i, (x) => x.IndexNumber == null ? "" : x.IndexNumber.ToString());
                reportHeader.SortField       = "IndexNumber";
                reportHeader.HeaderFieldType = ReportFieldType.Int;
                break;

            case HeaderMetadata.Series:
                column = (i, r) => this.GetObject <IHasSeries, string>(i, (x) => x.SeriesName);
                reportHeader.ItemViewType = ItemViewType.Detail;
                reportHeader.SortField    = "SeriesSortName,SortName";
                break;

            case HeaderMetadata.EpisodeSeries:
                column = (i, r) => this.GetObject <IHasSeries, string>(i, (x) => x.SeriesName);
                reportHeader.ItemViewType = ItemViewType.Detail;
                itemId = (i) =>
                {
                    Series series = this.GetObject <Episode, Series>(i, (x) => x.Series);
                    if (series == null)
                    {
                        return(string.Empty);
                    }
                    return(series.Id);
                };
                reportHeader.SortField = "SeriesSortName,SortName";
                internalHeader         = HeaderMetadata.Series;
                break;

            case HeaderMetadata.EpisodeSeason:
                column = (i, r) => this.GetObject <IHasSeries, string>(i, (x) => x.SeriesName);
                reportHeader.ItemViewType = ItemViewType.Detail;
                itemId = (i) =>
                {
                    Season season = this.GetObject <Episode, Season>(i, (x) => x.Season);
                    if (season == null)
                    {
                        return(string.Empty);
                    }
                    return(season.Id);
                };
                reportHeader.SortField = "SortName";
                internalHeader         = HeaderMetadata.Season;
                break;

            case HeaderMetadata.Network:
                column = (i, r) => this.GetListAsString(i.Studios);
                itemId = (i) => this.GetStudioID(i.Studios.FirstOrDefault());
                reportHeader.ItemViewType = ItemViewType.ItemByNameDetails;
                reportHeader.SortField    = "Studio,SortName";
                break;

            case HeaderMetadata.Year:
                column = (i, r) => this.GetSeriesProductionYear(i);
                reportHeader.SortField = "ProductionYear,PremiereDate,SortName";
                break;

            case HeaderMetadata.ParentalRating:
                column = (i, r) => i.OfficialRating;
                reportHeader.SortField = "OfficialRating,SortName";
                break;

            case HeaderMetadata.CommunityRating:
                column = (i, r) => i.CommunityRating;
                reportHeader.SortField = "CommunityRating,SortName";
                break;

            case HeaderMetadata.Trailers:
                column = (i, r) => this.GetBoolString(r.HasLocalTrailer);
                reportHeader.ItemViewType = ItemViewType.TrailersImage;
                break;

            case HeaderMetadata.Specials:
                column = (i, r) => this.GetBoolString(r.HasSpecials);
                reportHeader.ItemViewType = ItemViewType.SpecialsImage;
                break;

            case HeaderMetadata.GameSystem:
                column = (i, r) => this.GetObject <Game, string>(i, (x) => x.GameSystem);
                reportHeader.SortField = "GameSystem,SortName";
                break;

            case HeaderMetadata.Players:
                column = (i, r) => this.GetObject <Game, int?>(i, (x) => x.PlayersSupported);
                reportHeader.SortField = "Players,GameSystem,SortName";
                break;

            case HeaderMetadata.AlbumArtist:
                column = (i, r) => this.GetObject <MusicAlbum, string>(i, (x) => x.AlbumArtist);
                itemId = (i) => this.GetPersonID(this.GetObject <MusicAlbum, string>(i, (x) => x.AlbumArtist));
                reportHeader.ItemViewType = ItemViewType.Detail;
                reportHeader.SortField    = "AlbumArtist,Album,SortName";

                break;

            case HeaderMetadata.MusicArtist:
                column = (i, r) => this.GetObject <MusicArtist, string>(i, (x) => x.GetLookupInfo().Name);
                reportHeader.ItemViewType = ItemViewType.Detail;
                reportHeader.SortField    = "AlbumArtist,Album,SortName";
                internalHeader            = HeaderMetadata.AlbumArtist;
                break;

            case HeaderMetadata.AudioAlbumArtist:
                column = (i, r) => this.GetListAsString(this.GetObject <Audio, List <string> >(i, (x) => x.AlbumArtists));
                reportHeader.SortField = "AlbumArtist,Album,SortName";
                internalHeader         = HeaderMetadata.AlbumArtist;
                break;

            case HeaderMetadata.AudioAlbum:
                column = (i, r) => this.GetObject <Audio, string>(i, (x) => x.Album);
                reportHeader.SortField = "Album,SortName";
                internalHeader         = HeaderMetadata.Album;
                break;

            case HeaderMetadata.Countries:
                column = (i, r) => this.GetListAsString(this.GetObject <IHasProductionLocations, List <string> >(i, (x) => x.ProductionLocations));
                break;

            case HeaderMetadata.Disc:
                column = (i, r) => i.ParentIndexNumber;
                break;

            case HeaderMetadata.Track:
                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();
                break;

            case HeaderMetadata.Audio:
                column = (i, r) => this.GetAudioStream(i);
                break;

            case HeaderMetadata.EmbeddedImage:
                break;

            case HeaderMetadata.Video:
                column = (i, r) => this.GetVideoStream(i);
                break;

            case HeaderMetadata.Resolution:
                column = (i, r) => this.GetVideoResolution(i);
                break;

            case HeaderMetadata.Subtitles:
                column = (i, r) => this.GetBoolString(r.HasSubtitles);
                reportHeader.ItemViewType = ItemViewType.SubtitleImage;
                break;

            case HeaderMetadata.Genres:
                column = (i, r) => this.GetListAsString(i.Genres);
                break;
            }

            string headerName = "";

            if (internalHeader != HeaderMetadata.None)
            {
                string localHeader = "Header" + internalHeader.ToString();
                headerName = internalHeader != HeaderMetadata.None ? ReportHelper.GetJavaScriptLocalizedString(localHeader) : "";
                if (string.Compare(localHeader, headerName, StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    headerName = ReportHelper.GetServerLocalizedString(localHeader);
                }
            }

            reportHeader.Name      = headerName;
            reportHeader.FieldName = header;
            ReportOptions <BaseItem> option = new ReportOptions <BaseItem>()
            {
                Header = reportHeader,
                Column = column,
                ItemID = itemId
            };

            return(option);
        }
Example #3
0
 /// <summary> Initializes a new instance of the ReportOptions class. </summary>
 /// <param name="header"> . </param>
 /// <param name="row"> . </param>
 public ReportOptions(ReportHeader header, Func <I, ReportRow, object> column)
 {
     Header = header;
     Column = column;
 }
Example #4
0
		/// <summary> Gets report option. </summary>
		/// <param name="header"> The header. </param>
		/// <param name="sortField"> The sort field. </param>
		/// <returns> The report option. </returns>
		private ReportOptions<BaseItem> GetReportOption(HeaderMetadata header, string sortField = "")
		{
			ReportHeader reportHeader = 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:
					reportHeader.ItemViewType = ItemViewType.StatusImage;
					internalHeader = HeaderMetadata.Status;
					reportHeader.CanGroup = false;
					break;

				case HeaderMetadata.Name:
					column = (i, r) => i.Name;
					reportHeader.ItemViewType = ItemViewType.Detail;
					reportHeader.SortField = "SortName";
					break;

				case HeaderMetadata.DateAdded:
					column = (i, r) => i.DateCreated;
					reportHeader.SortField = "DateCreated,SortName";
					reportHeader.HeaderFieldType = ReportFieldType.DateTime;
					reportHeader.Type = "";
					break;

				case HeaderMetadata.PremiereDate:
				case HeaderMetadata.ReleaseDate:
					column = (i, r) => i.PremiereDate;
					reportHeader.HeaderFieldType = ReportFieldType.DateTime;
					reportHeader.SortField = "ProductionYear,PremiereDate,SortName";
					break;

				case HeaderMetadata.Runtime:
					column = (i, r) => this.GetRuntimeDateTime(i.RunTimeTicks);
					reportHeader.HeaderFieldType = ReportFieldType.Minutes;
					reportHeader.SortField = "Runtime,SortName";
					break;

				case HeaderMetadata.PlayCount:
					reportHeader.HeaderFieldType = ReportFieldType.Int;
					break;

				case HeaderMetadata.Season:
					column = (i, r) => this.GetEpisode(i);
					reportHeader.ItemViewType = ItemViewType.Detail;
					reportHeader.SortField = "SortName";
					break;

				case HeaderMetadata.SeasonNumber:
					column = (i, r) => this.GetObject<Season, string>(i, (x) => x.IndexNumber == null ? "" : x.IndexNumber.ToString());
					reportHeader.SortField = "IndexNumber";
					reportHeader.HeaderFieldType = ReportFieldType.Int;
					break;

				case HeaderMetadata.Series:
					column = (i, r) => this.GetObject<IHasSeries, string>(i, (x) => x.SeriesName);
					reportHeader.ItemViewType = ItemViewType.Detail;
					reportHeader.SortField = "SeriesSortName,SortName";
					break;

				case HeaderMetadata.EpisodeSeries:
					column = (i, r) => this.GetObject<IHasSeries, string>(i, (x) => x.SeriesName);
					reportHeader.ItemViewType = ItemViewType.Detail;
					itemId = (i) =>
					{
						Series series = this.GetObject<Episode, Series>(i, (x) => x.Series);
						if (series == null)
							return string.Empty;
						return series.Id;
					};
					reportHeader.SortField = "SeriesSortName,SortName";
					internalHeader = HeaderMetadata.Series;
					break;

				case HeaderMetadata.EpisodeSeason:
					column = (i, r) => this.GetObject<IHasSeries, string>(i, (x) => x.SeriesName);
					reportHeader.ItemViewType = ItemViewType.Detail;
					itemId = (i) =>
					{
						Season season = this.GetObject<Episode, Season>(i, (x) => x.Season);
						if (season == null)
							return string.Empty;
						return season.Id;
					};
					reportHeader.SortField = "SortName";
					internalHeader = HeaderMetadata.Season;
					break;

				case HeaderMetadata.Network:
					column = (i, r) => this.GetListAsString(i.Studios);
					itemId = (i) => this.GetStudioID(i.Studios.FirstOrDefault());
					reportHeader.ItemViewType = ItemViewType.ItemByNameDetails;
					reportHeader.SortField = "Studio,SortName";
					break;

				case HeaderMetadata.Year:
					column = (i, r) => this.GetSeriesProductionYear(i);
					reportHeader.SortField = "ProductionYear,PremiereDate,SortName";
					break;

				case HeaderMetadata.ParentalRating:
					column = (i, r) => i.OfficialRating;
					reportHeader.SortField = "OfficialRating,SortName";
					break;

				case HeaderMetadata.CommunityRating:
					column = (i, r) => i.CommunityRating;
					reportHeader.SortField = "CommunityRating,SortName";
					break;

				case HeaderMetadata.Trailers:
					column = (i, r) => this.GetBoolString(r.HasLocalTrailer);
					reportHeader.ItemViewType = ItemViewType.TrailersImage;
					break;

				case HeaderMetadata.Specials:
					column = (i, r) => this.GetBoolString(r.HasSpecials);
					reportHeader.ItemViewType = ItemViewType.SpecialsImage;
					break;

				case HeaderMetadata.GameSystem:
					column = (i, r) => this.GetObject<Game, string>(i, (x) => x.GameSystem);
					reportHeader.SortField = "GameSystem,SortName";
					break;

				case HeaderMetadata.Players:
					column = (i, r) => this.GetObject<Game, int?>(i, (x) => x.PlayersSupported);
					reportHeader.SortField = "Players,GameSystem,SortName";
					break;

				case HeaderMetadata.AlbumArtist:
					column = (i, r) => this.GetObject<MusicAlbum, string>(i, (x) => x.AlbumArtist);
					itemId = (i) => this.GetPersonID(this.GetObject<MusicAlbum, string>(i, (x) => x.AlbumArtist));
					reportHeader.ItemViewType = ItemViewType.Detail;
					reportHeader.SortField = "AlbumArtist,Album,SortName";

					break;
				case HeaderMetadata.MusicArtist:
					column = (i, r) => this.GetObject<MusicArtist, string>(i, (x) => x.GetLookupInfo().Name);
					reportHeader.ItemViewType = ItemViewType.Detail;
					reportHeader.SortField = "AlbumArtist,Album,SortName";
					internalHeader = HeaderMetadata.AlbumArtist;
					break;
				case HeaderMetadata.AudioAlbumArtist:
					column = (i, r) => this.GetListAsString(this.GetObject<Audio, List<string>>(i, (x) => x.AlbumArtists));
					reportHeader.SortField = "AlbumArtist,Album,SortName";
					internalHeader = HeaderMetadata.AlbumArtist;
					break;

				case HeaderMetadata.AudioAlbum:
					column = (i, r) => this.GetObject<Audio, string>(i, (x) => x.Album);
					reportHeader.SortField = "Album,SortName";
					internalHeader = HeaderMetadata.Album;
					break;

				case HeaderMetadata.Countries:
					column = (i, r) => this.GetListAsString(this.GetObject<IHasProductionLocations, List<string>>(i, (x) => x.ProductionLocations));
					break;

				case HeaderMetadata.Disc:
					column = (i, r) => i.ParentIndexNumber;
					break;

				case HeaderMetadata.Track:
					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();
					break;

				case HeaderMetadata.Audio:
					column = (i, r) => this.GetAudioStream(i);
					break;

				case HeaderMetadata.EmbeddedImage:
					break;

				case HeaderMetadata.Video:
					column = (i, r) => this.GetVideoStream(i);
					break;

				case HeaderMetadata.Resolution:
					column = (i, r) => this.GetVideoResolution(i);
					break;

				case HeaderMetadata.Subtitles:
					column = (i, r) => this.GetBoolString(r.HasSubtitles);
					reportHeader.ItemViewType = ItemViewType.SubtitleImage;
					break;

				case HeaderMetadata.Genres:
					column = (i, r) => this.GetListAsString(i.Genres);
					break;

			}

			string headerName = "";
			if (internalHeader != HeaderMetadata.None)
			{
				string localHeader = "Header" + internalHeader.ToString();
				headerName = internalHeader != HeaderMetadata.None ? ReportHelper.GetJavaScriptLocalizedString(localHeader) : "";
				if (string.Compare(localHeader, headerName, StringComparison.CurrentCultureIgnoreCase) == 0)
					headerName = ReportHelper.GetServerLocalizedString(localHeader);
			}

			reportHeader.Name = headerName;
			reportHeader.FieldName = header;
			ReportOptions<BaseItem> option = new ReportOptions<BaseItem>()
			{
				Header = reportHeader,
				Column = column,
				ItemID = itemId
			};
			return option;
		}