コード例 #1
0
ファイル: LuceneNetUtils.cs プロジェクト: uvbs/MyProjects
 /// <summary>
 /// 添加索引
 /// </summary>
 public static void AddIndex(IndexNode node, List<IndexBase> indexs)
 {
     var doc = CreateDoucment(node);
     foreach (var index in indexs)
     {
         index.AddIndex(doc);
     }
 }
コード例 #2
0
ファイル: LiveEpgIndex.cs プロジェクト: uvbs/MyProjects
        /// <summary>
        /// 建立以节目预告名称为索引的字典
        /// </summary>
        private static List<IndexNode> CreateNewNode(LiveVideoNode video, string builder)
        {
            var flag = video.Flags.FormatListToStr(SplitArray.Line, 16);
            var list = new List<IndexNode>(video.Items.Count + 1);
            list.Add(AddNameVideo(video, builder, flag));
            foreach (var parade in video.Items)
            {
                IndexNode node = new IndexNode();
                var indexnames = new List<KeyValuePair<string, string>>(5);
                var paradename = new KeyValuePair<string, string>(LiveEpgNode.ParadeName, parade.Language[CustomArray.LanguageArray[0]].Title);
                var paradecnname = new KeyValuePair<string, string>(LiveEpgNode.ParadeCnName, string.Format("{0}{1}", parade.Language[CustomArray.LanguageArray[0]].Title, SplitArray.IndexCnName));
                var flags = new KeyValuePair<string, string>(LiveEpgNode.Flags, flag);
                var pindex = new KeyValuePair<string, string>(LiveEpgNode.PlatformIndex, string.Format("{0}{1}", builder, SplitArray.IndexFlag));
                var fbcode = new KeyValuePair<string, string>(LiveEpgNode.ForbiddenCode, string.Format("{0},{1}", string.Join(",", ForbiddenAreaCache.Instance.ForbiddenNames.Except(video.ForbiddenAreas).ToArray()), SplitArray.IndexFlag));
                indexnames.Add(paradename);
                indexnames.Add(paradecnname);
                indexnames.Add(flags);
                indexnames.Add(pindex);
                indexnames.Add(fbcode);

                List<KeyValuePair<string, string>> indexvalues = new List<KeyValuePair<string, string>>(5);
                KeyValuePair<string, string> vid = new KeyValuePair<string, string>(LiveEpgNode.IndexValue, parade.ID.ToString());
                KeyValuePair<string, string> paradeid = new KeyValuePair<string, string>(LiveEpgNode.ParadeId, parade.ID.ToString());
                KeyValuePair<string, string> vipflag = new KeyValuePair<string, string>(LiveEpgNode.VipFlag, video.Main.VipFlag.ToString());
                var tabletype = new KeyValuePair<string, string>(LiveEpgNode.TableType, video.Main.TableType.ToString());
                var group = new KeyValuePair<string, string>(LiveEpgNode.IsGroup, video.IsGroup ? "1" : "0");
                indexvalues.Add(vid);
                indexvalues.Add(paradeid);
                indexvalues.Add(vipflag);
                indexvalues.Add(tabletype);
                indexvalues.Add(group);

                List<KeyValuePair<string, int>> indexnumerices = new List<KeyValuePair<string, int>>(3);
                KeyValuePair<string, int> bitrate = new KeyValuePair<string, int>(LiveEpgNode.BitrateRange, video.Main.BitRate);
                KeyValuePair<string, int> hight = new KeyValuePair<string, int>(LiveEpgNode.HightRange, video.Main.VideoHeight);
                KeyValuePair<string, int> width = new KeyValuePair<string, int>(LiveEpgNode.WidthRange, video.Main.VideoWidth);
                KeyValuePair<string, int> paradebegintime = new KeyValuePair<string, int>(LiveEpgNode.ParadeBeginTime, video.Main.VideoWidth);
                indexnumerices.Add(bitrate);
                indexnumerices.Add(hight);
                indexnumerices.Add(width);

                var indexlongs = new List<KeyValuePair<string, long>>(1);
                KeyValuePair<string, long> begintime = new KeyValuePair<string, long>(LiveEpgNode.ParadeBeginTime, parade.StartTime.Ticks);
                indexlongs.Add(begintime);

                node.IndexNames = indexnames;
                node.IndexValues = indexvalues;
                node.IndexNumerices = indexnumerices;
                node.IndexLongs = indexlongs;
                list.Add(node);
            }
            return list;
        }
コード例 #3
0
ファイル: TagIndex.cs プロジェクト: uvbs/MyProjects
        public static void AddTag(TagNode tag, string dimension, IndexBase index)
        {
            var builder = new StringBuilder();
            //Dictionary<int, string[]> fbcodes = new Dictionary<int, string[]>(tag.Channels.Keys.Count);
            foreach (var plat in tag.Channels.Keys)
            {
                var indexx = VideoNodeKeyArray.Instance.Items[VideoNodeKeyArray.Instance.FindKey(plat.PlatForm, 0, plat.Auth)];
                builder.Append(indexx);
                builder.Append(SplitArray.DH);
                //IEnumerable<string> fbcode = null;
                //var query = tag.Channels[plat].Select(v => ListCache.Instance.Dictionary[v].ForbiddenAreas);
                //foreach (var q in query)
                //{
                //    if (fbcode == null)
                //        fbcode = q;
                //    else
                //        fbcode = fbcode.Intersect(q);
                //}
                //fbcodes[indexx] = fbcode.ToArray();
            }
            if (builder.Length < 2)
                return;
            var node = new IndexNode();
            var indexnames = new List<KeyValuePair<string, string>>(3);
            var name = new KeyValuePair<string, string>(EpgIndexNode.Name, tag.Language[CustomArray.LanguageArray[0]].Title);
            var cnname = new KeyValuePair<string, string>(EpgIndexNode.CnName, string.Format("{0}{1}", tag.Language[CustomArray.LanguageArray[0]].Title, SplitArray.IndexCnName));
            var pindex = new KeyValuePair<string, string>(EpgIndexNode.PlatformIndex, string.Format("{0}{1}", builder.Remove(builder.Length - 1, 1), SplitArray.IndexFlag));
            //foreach (var fbcode in fbcodes)
            //{
            //    var fb = new KeyValuePair<string, string>(string.Format("{0}{1}", EpgIndexNode.ForbiddenCode, fbcode.Key), string.Format("{0},{1}", string.Join(",", ForbiddenAreaCache.Instance.ForbiddenNames.Except(fbcode.Value).ToArray()), SplitArray.IndexFlag));
            //    indexnames.Add(fb);
            //}
            indexnames.Add(name);
            indexnames.Add(cnname);
            indexnames.Add(pindex);

            var indexvalues = new List<KeyValuePair<string, string>>(2);
            var vid = new KeyValuePair<string, string>(EpgIndexNode.IndexValue, tag.Language[CustomArray.LanguageArray[0]].Title);
            var dimen = new KeyValuePair<string, string>(EpgIndexNode.Flags, dimension);
            indexvalues.Add(vid);
            indexvalues.Add(dimen);

            node.IndexNames = indexnames;
            node.IndexValues = indexvalues;

            LuceneNetUtils.AddIndex(node, index);
        }
コード例 #4
0
ファイル: LuceneNetUtils.cs プロジェクト: uvbs/MyProjects
 /// <summary>
 /// 创建Document
 /// </summary>
 public static Document CreateDoucment(IndexNode node)
 {
     Document doc = new Document();
     foreach (KeyValuePair<string, string> name in node.IndexNames)
     {
         var field = new Field(name.Key, name.Value, Field.Store.YES, Field.Index.ANALYZED);
         var boost = SettingCache.Boost;
         switch (name.Key)
         { 
             case "name":
                 break;
             case "catalog":
                 boost = boost - 4; break;
             case "act":
                 boost = boost - 8; break;
             case "area":
                 boost = boost - 16; break;
         }
         field.SetBoost(boost);
         doc.Add(field);
     }
     foreach (KeyValuePair<string, string> value in node.IndexValues)
     {
         doc.Add(new Field(value.Key, value.Value, Field.Store.YES, Field.Index.NOT_ANALYZED));
     }
     if (node.IndexNumerices != null)
     {
         foreach (KeyValuePair<string, int> numeric in node.IndexNumerices)
         {
             doc.Add(new NumericField(numeric.Key, Field.Store.YES, true).SetIntValue(numeric.Value));
         }
     }
     if (node.IndexLongs != null)
     {
         foreach (var numeric in node.IndexLongs)
         {
             doc.Add(new NumericField(numeric.Key, Field.Store.YES, true).SetLongValue(numeric.Value));
         }
     }
     return doc;
 }
コード例 #5
0
ファイル: EpgIndex.cs プロジェクト: uvbs/MyProjects
        public static void AddVideo(VideoNode video, IndexBase indexBase)
        {
            var builder = new StringBuilder();
            foreach (var authnode in video.PlatForms)
            {
                if (authnode.SearchTypeIndexList.Contains(video.Type))
                {
                    builder.Append(VideoNodeKeyArray.Instance.Items[VideoNodeKeyArray.Instance.FindKey(authnode.PlatformName, 0, authnode.Licence)]);
                    builder.Append(SplitArray.DH);
                }
            }
            if (builder.Length < 2)
                return;
            
            var node = new IndexNode();
            var indexnames = new List<KeyValuePair<string, string>>(10);
            var name = new KeyValuePair<string, string>(EpgIndexNode.Name, video.Language[CustomArray.LanguageArray[0]].ChannelName);
            var cnname = new KeyValuePair<string, string>(EpgIndexNode.CnName, string.Format("{0}{1}", video.Language[CustomArray.LanguageArray[0]].ChannelName, SplitArray.IndexCnName));
            var flag = video.Flags.FormatListToStr(SplitArray.Line, 16);
            var catalog = new KeyValuePair<string, string>(EpgIndexNode.Catalog, string.Format("{0}{1}", video.Language[CustomArray.LanguageArray[0]].CatalogTags, SplitArray.IndexFlag));
            var area = new KeyValuePair<string, string>(EpgIndexNode.Area, string.Format("{0}{1}", video.Language[CustomArray.LanguageArray[0]].AreaTags, SplitArray.IndexFlag));
            var year = new KeyValuePair<string, string>(EpgIndexNode.Year, string.Format("{0}{1}", video.YearTags, SplitArray.IndexFlag));
            var act = new KeyValuePair<string, string>(EpgIndexNode.Act, string.Format("{0}{1}", video.BKInfo.Actors, SplitArray.IndexFlag));
            var director = new KeyValuePair<string, string>(EpgIndexNode.Director, string.Format("{0}{1}", video.BKInfo.Directors, SplitArray.IndexFlag));
            var flags = new KeyValuePair<string, string>(EpgIndexNode.Flags, flag);
            var pindex = new KeyValuePair<string, string>(EpgIndexNode.PlatformIndex, string.Format("{0}{1}", builder.Remove(builder.Length - 1, 1), SplitArray.IndexFlag));
            var fbcode = new KeyValuePair<string, string>(EpgIndexNode.ForbiddenCode, string.Format("{0},{1}", string.Join(",", ForbiddenAreaCache.Instance.ForbiddenNames.Except(video.ForbiddenAreas).ToArray()), SplitArray.IndexFlag));
            indexnames.Add(name);
            indexnames.Add(cnname);
            indexnames.Add(catalog);
            indexnames.Add(area);
            indexnames.Add(year);
            indexnames.Add(act);
            indexnames.Add(director);
            indexnames.Add(flags);
            indexnames.Add(pindex);
            indexnames.Add(fbcode);

            var indexvalues = new List<KeyValuePair<string, string>>(6);
            var vid = new KeyValuePair<string, string>(EpgIndexNode.IndexValue, video.Main.ChannelID.ToString());
            var vipflag = new KeyValuePair<string, string>(EpgIndexNode.VipFlag, video.Main.VipFlag.ToString());
            var tabletype = new KeyValuePair<string, string>(EpgIndexNode.TableType, video.Main.TableType.ToString());
            var screen = new KeyValuePair<string, string>(EpgIndexNode.Screen, video.Main.TableType == 1 ? "1" : "0");
            var group = new KeyValuePair<string, string>(EpgIndexNode.IsGroup, video.IsGroup ? "1" : "0");
            var type = new KeyValuePair<string, string>(EpgIndexNode.Type, video.Type.ToString());
            indexvalues.Add(vid);
            indexvalues.Add(vipflag);
            indexvalues.Add(tabletype);
            indexvalues.Add(screen);
            indexvalues.Add(group);
            indexvalues.Add(type);

            var indexnumerices = new List<KeyValuePair<string, int>>(3);
            var bitrate = new KeyValuePair<string, int>(EpgIndexNode.BitrateRange, video.Main.BitRate);
            var hight = new KeyValuePair<string, int>(EpgIndexNode.HightRange, video.Main.VideoHeight);
            var width = new KeyValuePair<string, int>(EpgIndexNode.WidthRange, video.Main.VideoWidth);
            indexnumerices.Add(bitrate);
            indexnumerices.Add(hight);
            indexnumerices.Add(width);

            node.IndexNames = indexnames;
            node.IndexValues = indexvalues;
            node.IndexNumerices = indexnumerices;

            LuceneNetUtils.AddIndex(node, indexBase);
        }
コード例 #6
0
ファイル: LiveEpgIndex.cs プロジェクト: uvbs/MyProjects
        /// <summary>
        /// 建立以频道名称为索引的字典
        /// </summary>
        private static IndexNode AddNameVideo(LiveVideoNode video, string builder, string flag)
        {
            IndexNode node = new IndexNode();
            var indexnames = new List<KeyValuePair<string, string>>(5);
            var name = new KeyValuePair<string, string>(LiveEpgNode.Name, video.ChannelName);
            var cnname = new KeyValuePair<string, string>(LiveEpgNode.CnName, string.Format("{0}{1}", video.ChannelName, SplitArray.IndexCnName));
            var flags = new KeyValuePair<string, string>(LiveEpgNode.Flags, flag);
            var pindex = new KeyValuePair<string, string>(LiveEpgNode.PlatformIndex, string.Format("{0}{1}", builder, SplitArray.IndexFlag));
            var fbcode = new KeyValuePair<string, string>(LiveEpgNode.ForbiddenCode, string.Format("{0},{1}", string.Join(",", ForbiddenAreaCache.Instance.ForbiddenNames.Except(video.ForbiddenAreas).ToArray()), SplitArray.IndexFlag));
            indexnames.Add(name);
            indexnames.Add(cnname);
            indexnames.Add(flags);
            indexnames.Add(pindex);
            indexnames.Add(fbcode);

            List<KeyValuePair<string, string>> indexvalues = new List<KeyValuePair<string, string>>(5);
            KeyValuePair<string, string> vid = new KeyValuePair<string, string>(LiveEpgNode.IndexValue, video.Main.ChannelID.ToString());
            KeyValuePair<string, string> channelid = new KeyValuePair<string, string>(LiveEpgNode.ChannelId, video.Main.ChannelID.ToString());
            KeyValuePair<string, string> vipflag = new KeyValuePair<string, string>(LiveEpgNode.VipFlag, video.Main.VipFlag.ToString());
            var tabletype = new KeyValuePair<string, string>(LiveEpgNode.TableType, video.Main.TableType.ToString());
            var group = new KeyValuePair<string, string>(LiveEpgNode.IsGroup, video.IsGroup ? "1" : "0");
            indexvalues.Add(vid);
            indexvalues.Add(channelid);
            indexvalues.Add(vipflag);
            indexvalues.Add(tabletype);
            indexvalues.Add(group);

            List<KeyValuePair<string, int>> indexnumerices = new List<KeyValuePair<string, int>>(3);
            KeyValuePair<string, int> bitrate = new KeyValuePair<string, int>(LiveEpgNode.BitrateRange, video.Main.BitRate);
            KeyValuePair<string, int> hight = new KeyValuePair<string, int>(LiveEpgNode.HightRange, video.Main.VideoHeight);
            KeyValuePair<string, int> width = new KeyValuePair<string, int>(LiveEpgNode.WidthRange, video.Main.VideoWidth);
            indexnumerices.Add(bitrate);
            indexnumerices.Add(hight);
            indexnumerices.Add(width);

            node.IndexNames = indexnames;
            node.IndexValues = indexvalues;
            node.IndexNumerices = indexnumerices;
            return node;
        }
コード例 #7
0
ファイル: LuceneNetUtils.cs プロジェクト: uvbs/MyProjects
 /// <summary>
 /// 添加索引
 /// </summary>
 public static void AddIndex(IndexNode node, IndexBase index)
 {
     index.AddIndex(CreateDoucment(node));
 }
コード例 #8
0
ファイル: IndexBase.cs プロジェクト: uvbs/MyProjects
 /// <summary>
 /// 添加索引
 /// </summary>
 public virtual void AddIndex(IndexNode node)
 {
     _write.AddDocument(CreateDoucment(node));
 }
コード例 #9
0
ファイル: IndexBase.cs プロジェクト: uvbs/MyProjects
 /// <summary>
 /// 更新索引
 /// </summary>
 public void UpdateDocument(string field, string value, IndexNode node)
 {
     _updatewrite.UpdateDocument(new Term(field, value), CreateDoucment(node));
 }