Пример #1
0
 /// <summary>
 /// LuceneNet建立索引
 /// </summary>
 private void LuceneInitIndex(Dictionary <int, LiveVideoNode> videos)
 {
     if (bool.Parse(AppSettingCache.Instance["LiveSearchAct"]))
     {
         //ThreadPool.QueueUserWorkItem(state =>
         //{
         if (!_indexlock.TryEnter())
         {
             return;
         }
         try
         {
             _log.Info("LiveListCache开始建立LuceneNet索引");
             var dic = LiveEpgLuceneNet.Instance.Init();
             foreach (var video in videos.Values)
             {
                 LiveEpgIndex.AddVideo(video, dic);
             }
             LiveEpgLuceneNet.Instance.CompleteIndex(dic);
             _log.Info("LiveListCache索引建立完成");
         }
         catch (Exception ex)
         {
             _log.Error(ex);
         }
         finally
         {
             _indexlock.Exit();
         }
         //});
     }
 }
Пример #2
0
 public void Execute(JobExecutionContext context)
 {
     if (!_lock.TryEnter())
     {
         return;
     }
     try
     {
         LiveChannelCache.Instance.Init();
         var source  = LiveListCache.Instance.Dictionary.Values.Where(l => l.HiddenFlag == 0).Select(l => l.Main.ChannelID).ToPerfectList();
         var compare = LiveChannelCache.Instance.Items.Select(l => l.ChannelID).ToPerfectList();
         var hiddens = source.Except(compare).ToPerfectList();
         var shows   = compare.Except(source).ToPerfectList();
         if (hiddens.Count > 0)
         {
             if (hiddens.Count < AppSettingCache.LiveHiddenMaxCount)
             {
                 foreach (var hidden in hiddens)
                 {
                     if (LiveListCache.Instance.Dictionary.ContainsKey(hidden))
                     {
                         var video = LiveListCache.Instance.Dictionary[hidden];
                         video.HiddenFlag = 1;
                         LiveEpgIndex.DeleteVideo(video, LiveEpgLuceneNet.Instance.IndexDic);
                         _logger.Info(string.Format("频道{0}已下线", hidden));
                     }
                 }
             }
             else
             {
                 _logger.Info(string.Format("下线个数超过最大阀值,当前下线个数为{0}", hiddens.Count));
             }
         }
         if (shows.Count > 0)
         {
             foreach (var show in shows)
             {
                 if (LiveListCache.Instance.Dictionary.ContainsKey(show))
                 {
                     var video = LiveListCache.Instance.Dictionary[show];
                     video.HiddenFlag = 0;
                     LiveEpgIndex.InsertVideo(video, LiveEpgLuceneNet.Instance.IndexDic);
                     _logger.Info(string.Format("频道{0}已上线", show));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
     }
     finally
     {
         _lock.Exit();
     }
 }