public override bool GetPrograms(string title, DateTime from, DateTime to, out IList <IProgram> programs) { programs = _tvBusiness.SearchPrograms(title).Where(p => p.StartTime >= from && p.StartTime <= to || p.EndTime >= from && p.EndTime <= to) .Select(tvProgram => tvProgram.ToProgram(true)) .Distinct(ProgramComparer.Instance) .ToList(); return(programs.Count > 0); }
public override async Task <AsyncResult <IList <IProgram> > > GetProgramsAsync(string title, DateTime from, DateTime to) { await _initComplete.Task; var programs = _tvBusiness.SearchPrograms(title).Where(p => p.StartTime >= from && p.StartTime <= to || p.EndTime >= from && p.EndTime <= to) .Select(tvProgram => GetProgram(tvProgram, true)) .Distinct(ProgramComparer.Instance) .ToList(); var success = programs.Count > 0; return(new AsyncResult <IList <IProgram> >(success, programs)); }
public bool GetPrograms(string title, DateTime from, DateTime to, out IList <IProgram> programs) { #if TVE3 programs = _tvBusiness.SearchPrograms(title).Where(p => p.StartTime >= from && p.StartTime <= to || p.EndTime >= from && p.EndTime <= to) #else IProgramService programService = GlobalServiceProvider.Instance.Get <IProgramService>(); programs = programService.GetProgramsByTitleAndStartEndTimes(title, from, to) #endif .Select(tvProgram => tvProgram.ToProgram(true)) .Distinct(ProgramComparer.Instance) .ToList(); return(programs.Count > 0); }
private void Search() { Log.Info("newsearch Search:{0} {1}", _searchKeyword, SearchFor); GUIControl.ClearControl(GetID, listResults.GetID); TvBusinessLayer layer = new TvBusinessLayer(); IList <Program> listPrograms = null; switch (SearchFor) { case SearchType.Genres: listPrograms = layer.SearchProgramsPerGenre("%" + _searchKeyword + "%", ""); break; case SearchType.KeyWord: listPrograms = layer.SearchProgramsByDescription("%" + _searchKeyword); break; case SearchType.Title: listPrograms = layer.SearchPrograms("%" + _searchKeyword); break; } if (listPrograms == null) { return; } if (listPrograms.Count == 0) { return; } Log.Info("newsearch found:{0} progs", listPrograms.Count); foreach (Program program in listPrograms) { GUIListItem item = new GUIListItem(); item.Label = TVUtil.GetDisplayTitle(program); string logo = Utils.GetCoverArt(Thumbs.TVChannel, program.ReferencedChannel().DisplayName); if (string.IsNullOrEmpty(logo)) { logo = "defaultVideoBig.png"; } item.ThumbnailImage = logo; item.IconImageBig = logo; item.IconImage = logo; item.TVTag = program; listResults.Add(item); } }
public IList <WebTVSearchResult> Search(string text, WebTVSearchResultType?type = null) { if (String.IsNullOrWhiteSpace(text)) { return(new List <WebTVSearchResult>()); } text = text.ToLower(); IEnumerable <WebTVSearchResult> result = new List <WebTVSearchResult>(); if (type == null || type == WebTVSearchResultType.TVChannel || type == WebTVSearchResultType.RadioChannel) { result = result.Concat(Channel.ListAll() .Where(channel => channel.DisplayName.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(channel => new WebTVSearchResult() { Id = channel.IdChannel.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / channel.DisplayName.Length * 50), Title = channel.DisplayName, Type = channel.IsTv ? WebTVSearchResultType.TVChannel : WebTVSearchResultType.RadioChannel }) .Where(r => type == null || r.Type == type)); } if (type == null || type == WebTVSearchResultType.TVGroup) { result = result.Concat(ChannelGroup.ListAll() .Where(group => group.GroupName.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(group => new WebTVSearchResult() { Id = group.IdGroup.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / group.GroupName.Length * 50), Title = group.GroupName, Type = WebTVSearchResultType.TVGroup, })); } if (type == null || type == WebTVSearchResultType.RadioGroup) { result = result.Concat(RadioChannelGroup.ListAll() .Where(group => group.GroupName.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(group => new WebTVSearchResult() { Id = group.IdGroup.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / group.GroupName.Length * 50), Title = group.GroupName, Type = WebTVSearchResultType.RadioGroup })); } if (type == null || type == WebTVSearchResultType.Recording) { result = result.Concat(Recording.ListAll() .Where(rec => rec.Title.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(rec => new WebTVSearchResult() { Id = rec.IdRecording.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / rec.Title.Length * 50), Title = rec.Title, Type = WebTVSearchResultType.Recording, StartTime = rec.StartTime, EndTime = rec.EndTime, ChannelName = GetChannelDisplayName(rec.IdChannel) })); } if (type == null || type == WebTVSearchResultType.Schedule) { result = result.Concat(Schedule.ListAll() .Where(schedule => schedule.ProgramName.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(schedule => new WebTVSearchResult() { Id = schedule.IdSchedule.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / schedule.ProgramName.Length * 50), Title = schedule.ProgramName, Type = WebTVSearchResultType.Schedule, ChannelName = GetChannelDisplayName(schedule.IdChannel) })); } if (type == null || type == WebTVSearchResultType.Program) { result = result.Concat(_tvBusiness.SearchPrograms("%" + text + "%") .Select(program => new WebTVSearchResult() { Id = program.IdProgram.ToString(), Score = (int)Math.Round(((decimal)text.Length / program.Title.Length * 50) - Math.Abs((decimal)(program.StartTime - DateTime.Now).TotalDays)), Title = program.Title, Type = WebTVSearchResultType.Program, StartTime = program.StartTime, EndTime = program.EndTime, ChannelName = GetChannelDisplayName(program.IdChannel) })); } return(result.OrderByDescending(x => x.Score).ToList()); }