Beispiel #1
0
 public string LiveParadeSearchEx(LiveSearchFilter filter)
 {
     try
     {
         return CreateParadeSmarkPageList(LuceneNetUtil.LiveSearchEx(filter, LiveEpgNode.ParadeFields, Searcher.SegmentKeyWord(filter.k), true), filter, true);
     }
     catch (KeyNotFoundException)
     {
         return NoPlatForm();
     }
     catch (Exception ex)
     {
         return BoxUtils.FormatErrorMsg(ex);
     }
 }
Beispiel #2
0
 public string LiveSearchCh(LiveSearchFilter filter)
 {
     try
     {
         return CreateSmarkPageList(LuceneNetUtil.LiveSearch(filter, LiveEpgNode.CnNameField, Searcher.SegmentChWord(filter.k), false), filter, false);
     }
     catch (KeyNotFoundException)
     {
         return NoPlatForm();
     }
     catch (Exception ex)
     {
         return BoxUtils.FormatErrorMsg(ex);
     }
 }
Beispiel #3
0
 /// <summary>
 /// LuceneNet节目预告分页输出
 /// </summary>
 private string CreateParadeSmarkPageList(LuceneResultNode result, LiveSearchFilter filter, bool isEx)
 {
     var vkey = new VideoNodeKey(filter.platform, 0, filter.auth);
     var parades = from parade in result.Result select ChannelLiveItemsCache.Instance.Items[int.Parse(parade)];
     var query = from parade in parades group parade by parade.ChannelID;
     var list = query.ToList();
     //var groupquery = query.Skip(filter.c * (filter.s - 1)).Take(filter.c);
     //var count = groupquery.Count();
     var index = (filter.s - 1) * filter.c;
     var max = index + filter.c;
     if (max > list.Count)
         max = list.Count;
     var count = max - index;
     var xml = new XElement("vlist");
     xml.Add(new XElement("count", count));
     xml.Add(new XElement("page_count", PageUtils.PageCount(count, filter.c)));
     xml.Add(new XElement("countInPage", filter.c));
     xml.Add(new XElement("page", filter.s));
     for (var i = index; i < max; i++)
     {
         var group = list[i];
         var v = VideoResponseUtils.CustomLiveListRes(LiveListCache.Instance.Dictionary[group.Key], filter, 0, isEx);
         var paraderoot = new XElement("parade_list");
         foreach (var key in group)
         {
             paraderoot.Add(VideoResponseUtils.LiveListSearchParade(key, filter));
         }
         v.Add(paraderoot);
         xml.Add(v);
     }
     return xml.ToString(SaveOptions.DisableFormatting);
 }
Beispiel #4
0
 /// <summary>
 /// LuceneNet分页输出
 /// </summary>
 private string CreateSmarkPageList(LuceneResultNode result, LiveSearchFilter filter, bool isEx)
 {
     var key = new VideoNodeKey(filter.platform, 0, filter.auth);
     var xml = new XElement("vlist");
     xml.Add(new XElement("count", result.AllCount));
     xml.Add(new XElement("page_count", PageUtils.PageCount(result.AllCount, filter.c)));
     xml.Add(new XElement("countInPage", filter.c));
     xml.Add(new XElement("page", filter.s));
     xml.Add(from v in result.Result select VideoResponseUtils.CustomLiveListRes(LiveListCache.Instance.Dictionary[int.Parse(v)], filter, 0, isEx));
     return xml.ToString(SaveOptions.DisableFormatting);
 }
Beispiel #5
0
 /// <summary>
 /// 直播搜索请求参数处理
 /// </summary>
 public static VideoPars FormatLiveSearchVideoPars(LiveSearchFilter filter)
 {
     var vp = new VideoPars();
     if (!string.IsNullOrEmpty(filter.flag))
     {
         vp.Flags = filter.flag.FormatStrToArray(SplitArray.LineArray);
     }
     if (filter.forbidden)
     {
         filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[new VideoNodeKey(filter.platform, 0, filter.auth)];
         if (filter.forbidden)
         {
             if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode))
             {
                 vp.ForbiddenName = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName;
             }
             else
             {
                 filter.forbidden = false;
             }
         }
     }
     return vp;
 }
Beispiel #6
0
 /// <summary>
 /// 直播搜索节目预告输出
 /// </summary>
 public static XElement LiveListSearchParade(ChannelLiveItemsNode parade, LiveSearchFilter filter)
 {
     return new XElement("parade",
         new XAttribute("date", parade.StartTime.Date.ToString("yyyy-MM-dd")),
         new XAttribute("begin_time", parade.StartTime.TimeOfDay.ToString()),
         parade.Language[filter.lang].Title
         );
 }
Beispiel #7
0
 /// <summary>
 /// 直播扩展搜索
 /// </summary>
 public static LuceneResultNode LiveSearchEx(LiveSearchFilter filter, string[] searchFields, string query, bool isNoPaging)
 {
     var fkey = new VideoNodeKey(filter.platform, 0, filter.auth);
     var containfilters = new List<ContainFilterNode>();
     var fbname = string.Empty;
     if (filter.forbidden)
     {
         filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey];
         if (filter.forbidden)
         {
             if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode))
             {
                 fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName;
             }
             else
             {
                 filter.forbidden = false;
             }
         }
     }
     if (filter.forbidden)
     {
         containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.ForbiddenCode, Text = fbname.ToLower() });
     }
     var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString();
     containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.PlatformIndex, Text = pindx });
     if (!string.IsNullOrEmpty(filter.flag))
     {
         containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.Flags, Text = VideoParsUtils.OrderAscFlags(filter.flag) });
     }
     if (filter.ver <= 1)
     {
         containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.TableType, Text = "0" });
     }
     else
     {
         containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.IsGroup, Text = "0" });
     }
     if (filter.forbidvip == 1)
     {
         containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.VipFlag, Text = "0" });
     }
     List<LongRangeNode> longs = new List<LongRangeNode>();
     if (filter.lastday != 0)
     {
         longs.Add(new LongRangeNode() { FieldName = LiveEpgNode.ParadeBeginTime, MinValue = 0, MaxValue = filter.lastday });
     }
     List<NumberRangeNode> rangenodes = new List<NumberRangeNode>();
     if (filter.bitratemin != 0 || filter.bitratemax != 0)
     {
         if (filter.bitratemax == 0) filter.bitratemax = int.MaxValue;
         rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.BitrateRange, MinValue = filter.bitratemin, MaxValue = filter.bitratemax });
     }
     if (filter.hmin != 0 || filter.hmax != 0)
     {
         if (filter.hmax == 0) filter.hmax = int.MaxValue;
         rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.HightRange, MinValue = filter.hmin, MaxValue = filter.hmax });
     }
     if (filter.wmin != 0 || filter.wmax != 0)
     {
         if (filter.wmax == 0) filter.wmax = int.MaxValue;
         rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.WidthRange, MinValue = filter.wmin, MaxValue = filter.wmax });
     }
     SearchNode node = new SearchNode();
     node.Key = filter.k;
     node.Pindex = pindx;
     node.Queries = query;//Searcher.SegmentKeyWord(filter.k);
     node.Fields = searchFields;
     node.Occurs = LiveEpgNode.Occurs;
     node.LongRnageFilters = longs;
     node.ContainFilters = containfilters;
     node.NumberRangeFiters = rangenodes;
     node.Start = filter.s;
     node.Limit = filter.c;
     node.IsNoPaging = isNoPaging;
     node.IndexValue = LiveEpgNode.IndexValue;
     return Searcher.SearchEx(LiveEpgLuceneNet.Instance.IndexDic, node);
 }