internal LatestsCollection GetArgusRecordings() { UpdateSheduledTVRecordings(); LatestsCollection latests = new LatestsCollection(); LatestsCollection resultTmp = new LatestsCollection(); try { // parent.CurrentFacade.Facade = Utils.GetLatestsFacade(parent.CurrentFacade.ControlID); if (parent.CurrentFacade.Facade != null) { Utils.ClearFacade(ref parent.CurrentFacade.Facade); } if (facadeCollection != null) { facadeCollection.Clear(); } if (Proxies.IsInitialized) { List <RecordingSummary> recordings = null; DateTime _time = DateTime.Now; List <Channel> channels = new List <Channel>(); channels = Proxies.SchedulerService.GetAllChannels(ChannelType.Television).Result; List <Guid> chids = new List <Guid>(); foreach (Channel ch in channels) { chids.Add(ch.ChannelId); } IEnumerable <Guid> iechids = chids; List <List <RecordingSummary> > rr = new List <List <RecordingSummary> >(); rr = Proxies.ControlService.GetRecordingsOnChannels(iechids).Result; recordings = rr.SelectMany(z => z).ToList(); recordings.Sort(new RecordingsComparer()); if (recordings != null) { foreach (RecordingSummary rec in recordings) { logger.Debug("Recording: " + rec.ChannelId + " " + rec.RecordingStartTime.ToLocalTime() + " " + rec.Title); if (latests.Count > Utils.FacadeMaxNum) { break; } if (rec.ChannelType == ChannelType.Television) { Recording recording = Proxies.ControlService.GetRecordingById(rec.RecordingId).Result; string _summary = string.Empty; if (recording != null) { _summary = recording.Description; } string thumbNail = rec.ThumbnailFileName; if (!File.Exists(thumbNail)) { thumbNail = "defaultTVBig.png"; } if (Utils.LatestTVRecordingsWatched) { if (!rec.LastWatchedTime.HasValue) { latests.Add(new Latest(rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), thumbNail, null, rec.Title, rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), null, null, rec.Category, null, null, null, null, null, null, null, null, rec, null, _summary, null)); } } else { latests.Add(new Latest(rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), thumbNail, null, rec.Title, rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), null, null, rec.Category, null, null, null, null, null, null, null, null, rec, null, _summary, null)); } } Utils.ThreadToSleep(); } } int x = 0; int i0 = 1; if (latests != null && latests.Count > 0) { // latests.Sort(new LatestAddedComparerDesc()); Utils.SortLatests(ref latests, parent.CurrentFacade.Type, parent.CurrentFacade.LeftToRight); latestArgusRecordings = new Hashtable(); for (int x0 = 0; x0 < latests.Count; x0++) { //latests[x0].DateAdded = latests[x0].DateAdded.Substring(0, 10); try { DateTime dTmp = DateTime.Parse(latests[x0].DateAdded); latests[x0].DateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp); } catch { } latests[x0].Directory = Utils.GetGetDirectoryName(((RecordingSummary)latests[x0].Playable).RecordingFileName); latests[x0].Fanart = (Utils.FanartHandler ? UtilsFanartHandler.GetFanartForLatest(latests[x0].Title) : string.Empty); resultTmp.Add(latests[x0]); if (result == null || result.Count == 0) { result = resultTmp; } latestArgusRecordings.Add(i0, latests[x].Playable); //if (facade != null) //{ AddToFilmstrip(parent.CurrentFacade.Facade, latests[x], i0); //} x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } } } Utils.UpdateFacade(ref parent.CurrentFacade.Facade, parent.CurrentFacade); if (latests != null) { latests.Clear(); } latests = null; } catch { if (latests != null) { latests.Clear(); } latests = null; } result = resultTmp; return(result); }
internal LatestsCollection GetTVRecordings() { UpdateSheduledTVRecordings(); if (TVHome.Connected) { LatestMediaHandler.LatestsCollection resultTmp = new LatestMediaHandler.LatestsCollection(); LatestsCollection latests = new LatestsCollection(); try { IList <TvDatabase.Recording> recordings = TvDatabase.Recording.ListAll(); int x = 0; int i0 = 1; foreach (TvDatabase.Recording rec in recordings) { if (!Utils.LatestTVRecordingsUnfinished && IsRecordingActual(rec)) { continue; } if (Utils.LatestTVRecordingsWatched && (rec.TimesWatched > 0)) { continue; } latests.Add(new Latest(rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), "defaultTVBig.png", null, rec.Title, rec.EndTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), null, null, rec.Genre, null, null, null, null, null, null, rec.EpisodeNum, rec.EpisodeName, rec, null, rec.Description, rec.SeriesNum)); Utils.ThreadToSleep(); } // parent.CurrentFacade.Facade = Utils.GetLatestsFacade(parent.CurrentFacade.ControlID); if (parent.CurrentFacade.Facade != null) { Utils.ClearFacade(ref parent.CurrentFacade.Facade); } if (facadeCollection != null) { facadeCollection.Clear(); } // latests.Sort(new LatestAddedComparerDesc()); Utils.SortLatests(ref latests, parent.CurrentFacade.Type, parent.CurrentFacade.LeftToRight); latestTVRecordings = new Hashtable(); for (int x0 = 0; x0 < latests.Count; x0++) { //latests[x0].DateAdded = latests[x0].DateAdded.Substring(0, 10); try { DateTime dTmp = DateTime.Parse(latests[x0].DateAdded); latests[x0].DateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp); } catch { } string _filename = ((Recording)latests[x0].Playable).FileName; string thumbNail = string.Empty; if (LatestMediaHandlerSetup.MpVersion.CompareTo("1.03") > 0) { // MP 1.4 logger.Debug("GetTVRecordings [" + LatestMediaHandlerSetup.MpVersion + "] Thumbs method: 1.4 and above ..."); thumbNail = TVRecordingsThumbnailHandler.GetThumb(_filename); } else { // MP 1.3 or older logger.Debug("GetTVRecordings [" + LatestMediaHandlerSetup.MpVersion + "] Thumbs method: 1.3 or older ..."); thumbNail = string.Format(CultureInfo.CurrentCulture, "{0}\\{1}{2}", Thumbs.TVRecorded, Path.ChangeExtension(MediaPortal.Util.Utils.SplitFilename(_filename), null), MediaPortal.Util.Utils.GetThumbExtension()); if (File.Exists(thumbNail)) { string tmpThumbNail = MediaPortal.Util.Utils.ConvertToLargeCoverArt(thumbNail); if (File.Exists(tmpThumbNail)) { thumbNail = tmpThumbNail; } } if (!File.Exists(thumbNail)) { thumbNail = string.Format(CultureInfo.CurrentCulture, "{0}{1}", Path.ChangeExtension(_filename, null), MediaPortal.Util.Utils.GetThumbExtension()); } if (!File.Exists(thumbNail)) { thumbNail = "defaultTVBig.png"; } } latests[x0].Fanart = (Utils.FanartHandler ? UtilsFanartHandler.GetFanartForLatest(latests[x0].Title) : string.Empty); latests[x0].Directory = Utils.GetGetDirectoryName(TVUtil.GetFileNameForRecording(((Recording)latests[x0].Playable))); latests[x0].Thumb = thumbNail; resultTmp.Add(latests[x0]); if (result == null || result.Count == 0) { result = resultTmp; } latestTVRecordings.Add(i0, latests[x].Playable); AddToFilmstrip(parent.CurrentFacade.Facade, latests[x], i0); x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } Utils.UpdateFacade(ref parent.CurrentFacade.Facade, parent.CurrentFacade); if (latests != null) { latests.Clear(); } latests = null; } catch (FileNotFoundException) { //do nothing } catch (MissingMethodException) { //do nothing } catch (Exception ex) { if (latests != null) { latests.Clear(); } latests = null; logger.Error("GetTVRecordings: " + ex.ToString()); } result = resultTmp; } return(result); }