示例#1
0
        public void Init()
        {
            if (_inited)
            {
                return;
            }
            var types = BoxTypeCache.Instance.Items.Values;
            var plats = PlatformUtils.FormatVodPlatform();
            var list  = new Dictionary <VideoNodeKey, int>(types.Count * plats.Count + 1);
            var fb    = new Dictionary <VideoNodeKey, bool>(plats.Count);
            int i     = 0;

            foreach (var f in plats)
            {
                var key = new VideoNodeKey(f.PlatformName, 0, f.Licence);
                fb.Add(key, f.IsForbiddenSupport);
                list.Add(key, ++i);
                foreach (var type in types)
                {
                    list.Add(new VideoNodeKey(f.PlatformName, type.TypeID, f.Licence), ++i);
                }
            }
            list.Add(new VideoNodeKey(AuthNode.NoPlatFormName, 0, AuthNode.NoPlatFormLicence), ++i);
            _list      = list;
            _forbidden = fb;
            _inited    = true;
        }
示例#2
0
        private void LoadChannel(Dictionary <int, TreeNode> dic, TreeNode node, IEnumerable <TreeNodeChannelRelInfo> rels)
        {
            var cc = PlatformUtils.FormatVodPlatform().Count;

            node.Channels    = new Dictionary <VideoNodeKey, List <int> >(cc);
            node.AllChannels = new Dictionary <VideoNodeKey, List <int> >(cc);
            var count = rels.Count();

            foreach (var rel in rels)
            {
                VideoNode v;
                if (ListCache.Instance.Dictionary.TryGetValue(rel.ChannelID, out v))
                {
                    foreach (var plat in v.PlatForms)
                    {
                        var key = VideoNodeKeyArray.Instance.FindKey(plat.PlatformName, v.Type, plat.Licence); //new VideoNodeKey(plat.PlatformName, v.Type, plat.Licence);
                        if (!node.Channels.ContainsKey(key))
                        {
                            node.Channels[key] = new List <int>(count);
                        }
                        node.Channels[key].Add(v.Main.ChannelID);
                        ParentLoadChannel(dic, node, key, count, v.Main.ChannelID);
                    }
                }
            }
        }
示例#3
0
        public override void RefreshCache()
        {
            string hql    = "from RecommandInfo r";
            var    res    = RecommandInfo.Execute(new HqlReadQuery <RecommandInfo>(hql)) as IList <RecommandInfo>;
            var    gquery = from re in res group re by re.Mode;
            var    dic    = new Dictionary <int, List <RecommandNode> >(gquery.Count());
            var    all    = new Dictionary <int, RecommandNode>(res.Count);

            foreach (var g in gquery)
            {
                dic[g.Key] = new List <RecommandNode>(g.Count());
                var relquery = from re in g
                               orderby re.Rank
                               join rel in ChannelRecomRelCache.Instance.Items
                               on re.ID equals rel.RecommandID
                               into rels
                               select new
                {
                    Node = new RecommandNode()
                    {
                        Id       = re.ID,
                        PicLink  = re.PicLink,
                        Language = SimpleLanguageHandler.ProcessLang(re.Name, re.NameEng),
                        Channels = new Dictionary <VideoNodeKey, List <int> >(PlatformUtils.FormatVodPlatform().Count)
                    },
                    Rels = rels.OrderBy(r => r.Rank)
                };
                foreach (var rel in relquery)
                {
                    var result = false;
                    var rcount = rel.Rels.Count();
                    foreach (var r in rel.Rels)
                    {
                        VideoNode v;
                        if (ListCache.Instance.Dictionary.TryGetValue(r.ChannelID, out v))
                        {
                            foreach (var plat in v.PlatForms)
                            {
                                var vk = VideoNodeKeyArray.Instance.FindKey(plat.PlatformName, 0, plat.Licence);
                                if (!rel.Node.Channels.ContainsKey(vk))
                                {
                                    rel.Node.Channels.Add(vk, new List <int>(rcount));
                                }
                                rel.Node.Channels[vk].Add(v.Main.ChannelID);
                                result = true;
                            }
                        }
                    }
                    if (result)
                    {
                        dic[g.Key].Add(rel.Node);
                        all[rel.Node.Id] = rel.Node;
                    }
                }
            }
            _cache = dic;
            _all   = all;
        }
示例#4
0
        public void ForbiddenInit()
        {
            var plats = PlatformUtils.FormatVodPlatform();
            var fb    = new Dictionary <VideoNodeKey, bool>(plats.Count);

            foreach (var f in plats)
            {
                var key = new VideoNodeKey(f.PlatformName, 0, f.Licence);
                fb.Add(key, f.IsForbiddenSupport);
            }
            _forbidden = fb;
        }
示例#5
0
        public VodContainer()
        {
            _plats = PlatformUtils.FormatVodPlatform();
            VideoNodeKeyArray.Instance.Init();
            var dic = new Dictionary <VideoNodeKey, VodContent>(VideoNodeKeyArray.Instance.Items.Count);

            foreach (var v in VideoNodeKeyArray.Instance.Items.Keys)
            {
                dic[v] = new VodContent();
            }
            _dic = dic;
        }
示例#6
0
        public override void RefreshCache()
        {
            var livetypes = LiveTypeCache.Instance.Items;
            var list      = new List <LiveTypeNode>(livetypes.Count);
            var types     = from livetype in livetypes
                            join rel in ChannelLiveRelCache.Instance.Items
                            on livetype.ID equals rel.LiveTypeID
                            into rels
                            select new
            {
                Type = livetype,
                Rels = rels.OrderBy(r => r.Rank)
            };

            foreach (var type in types)
            {
                var count = type.Rels.Count();
                if (count <= 0)
                {
                    continue;
                }
                var node = new LiveTypeNode()
                {
                    Language = SimpleLanguageHandler.ProcessLang(type.Type.TypeName, type.Type.TypeNameEng),
                    PicLink  = type.Type.PicLink,
                    ID       = type.Type.ID,
                    Channels = new Dictionary <VideoNodeKey, List <int> >(PlatformUtils.FormatVodPlatform().Count)
                };
                foreach (var rel in type.Rels)
                {
                    LiveVideoNode v;
                    if (LiveListCache.Instance.Dictionary.TryGetValue(rel.ChannelID, out v))
                    {
                        foreach (var plat in v.PlatForms)
                        {
                            var vk = new VideoNodeKey(plat.PlatformName, 0, plat.Licence);
                            if (!node.Channels.ContainsKey(vk))
                            {
                                node.Channels.Add(vk, new List <int>(count));
                            }
                            node.Channels[vk].Add(v.Main.ChannelID);
                        }
                    }
                }
                list.Add(node);
            }
            _cache = list;
        }
示例#7
0
        public override void RefreshCache()
        {
            var dic          = new Dictionary <TagNodeKey, List <TagNode> >(TagTypeCache.Instance.Dictionary.Count);
            var tagtypes     = TagTypeCache.Instance.Dictionary.Values;
            var pcount       = PlatformUtils.FormatVodPlatform().Count;
            var tagtypequery = from tagtype in tagtypes
                               join boxtag in BoxTagCache.Instance.Dictionary.Values
                               on tagtype.TagTypeID equals boxtag.TagType
                               into boxtags
                               select new
            {
                TagType = tagtype,
                BoxTags = boxtags.OrderBy(v => v.TagRank)
            };

            foreach (var tag in tagtypequery)
            {
                var key = new TagNodeKey()
                {
                    Dimension = tag.TagType.TagTypeLimitName, Type = tag.TagType.BoxTypeID
                };
                //dic[key] = new List<TagNode>(tag.BoxTags.Count());
                LoadTagCount(dic, key, tag.BoxTags.Count());
                var relquery = from boxtag in tag.BoxTags
                               join rel in ChannelTagRelCache.Instance.Items     //加载频道
                               on boxtag.ID equals rel.TagID
                               into rels
                               select new
                {
                    Node = new TagNode()
                    {
                        Language = SimpleLanguageHandler.ProcessLang(boxtag.TagName, boxtag.TagNameEng),
                        Channels = new Dictionary <VideoNodeKey, List <int> >(pcount)
                    },
                    Rels = rels.OrderByDescending(r => r.Rank)               //OrderBy(r => r.Rank)
                };
                foreach (var rel in relquery)
                {
                    var result = false;
                    var rcount = rel.Rels.Count();
                    foreach (var r in rel.Rels)
                    {
                        VideoNode v;
                        if (ListCache.Instance.Dictionary.TryGetValue(r.ChannelID, out v))
                        {
                            foreach (var plat in v.PlatForms)
                            {
                                var vk = VideoNodeKeyArray.Instance.FindKey(plat.PlatformName, v.Type, plat.Licence); //new VideoNodeKey(plat.PlatformName, v.Type, plat.Licence);
                                if (!rel.Node.Channels.ContainsKey(vk))
                                {
                                    rel.Node.Channels.Add(vk, new List <int>(rcount));
                                }
                                rel.Node.Channels[vk].Add(v.Main.ChannelID);
                                result = true;
                            }
                        }
                    }
                    if (result)
                    {
                        dic[key].Add(rel.Node);
                    }
                }
            }
            if (bool.Parse(AppSettingCache.Instance["ActDirectorTag"]))
            {
                LoadActorDirector(dic);
            }
            _cache = dic;
            LuceneInitIndex(dic);
            GC.Collect();
        }
示例#8
0
        public override void RefreshCache()
        {
            string hql = "from CoverNavInfo c ";
            var    res = CoverNavInfo.Execute(new HqlReadQuery <CoverNavInfo>(hql)) as IList <CoverNavInfo>;

            res.Add(new CoverNavInfo()
            {
                ID = 0, Mode = -1
            });
            var gquery = from re in res group re by re.Mode;
            var dic    = new Dictionary <int, List <CoverNavNode> >(gquery.Count());
            var all    = new Dictionary <int, CoverNavNode>(res.Count);

            foreach (var g in gquery)
            {
                dic[g.Key] = new List <CoverNavNode>(g.Count());
                var relquery = from re in g
                               orderby re.Rank
                               join rel in CoverImageCache.Instance.Items.Values
                               on re.ID equals rel.NavId
                               into rels
                               select new
                {
                    Node = new CoverNavNode()
                    {
                        Id       = re.ID,
                        PicLink  = re.PicLink,
                        Language = SimpleLanguageHandler.ProcessLang(re.Name, re.NameEng),
                        Images   = new Dictionary <VideoNodeKey, List <int> >(PlatformUtils.FormatVodPlatform().Count)
                    },
                    Rels = rels               //.OrderBy(r => r.Rank)
                };
                foreach (var rel in relquery)
                {
                    var result = false;
                    var rcount = rel.Rels.Count();
                    foreach (var r in rel.Rels)
                    {
                        VideoNode     vod;
                        LiveVideoNode live;
                        if (r.ChannelType == 3)
                        {
                            if (ListCache.Instance.Dictionary.TryGetValue(r.ChannelId, out vod))
                            {
                                foreach (var plat in vod.PlatForms)
                                {
                                    var vk = VideoNodeKeyArray.Instance.FindKey(plat.PlatformName, 0, plat.Licence);
                                    if (!rel.Node.Images.ContainsKey(vk))
                                    {
                                        rel.Node.Images.Add(vk, new List <int>(rcount));
                                    }
                                    rel.Node.Images[vk].Add(r.ImageId);
                                    result = true;
                                }
                            }
                        }
                        else if (r.ChannelType == 0)
                        {
                            if (LiveListCache.Instance.Dictionary.TryGetValue(r.ChannelId, out live))
                            {
                                foreach (var plat in live.PlatForms)
                                {
                                    var vk = VideoNodeKeyArray.Instance.FindKey(plat.PlatformName, 0, plat.Licence);
                                    if (!rel.Node.Images.ContainsKey(vk))
                                    {
                                        rel.Node.Images.Add(vk, new List <int>(rcount));
                                    }
                                    rel.Node.Images[vk].Add(r.ImageId);
                                    result = true;
                                }
                            }
                        }
                    }
                    if (result)
                    {
                        dic[g.Key].Add(rel.Node);
                        all[rel.Node.Id] = rel.Node;
                    }
                }
            }
            _cache = dic;
            _all   = all;
        }