public IPluginContent GetChildContent(string id)
        {
            if (_contents.Count == 0)
            {
                _contents = (List <IPluginContent>)GetContent();
            }
            string[] ids = id.Split("_".ToCharArray(), 2);

            IPluginContent content = _contents.FirstOrDefault(c => c.Id.ToLower() == ids[0]);

            if (ids.Length == 1)
            {
                return(content);
            }
            if (content is EpgContentProvider)
            {
                return((content as EpgContentProvider).Children.FirstOrDefault(c => c.Id == id));
            }
            if (content is LocalFileContentProvider)
            {
                return((content as LocalFileContentProvider).GetChildContent(id));
            }
            if (content is YoutubeContentProvider)
            {
                return(_youtube.Children.FirstOrDefault(c => c.Id == id));
            }
            if (content is TorrentContentProvider)
            {
                return(_torrent.Children.FirstOrDefault(c => c.Id == id));
            }
            return(null);
        }
        public XElement GetXDocument(IPluginContent content, string plugin, bool root = false, string host = "")
        {
            if (content is IPluginContainer)
            {
                XElement xroot = new XElement("items");
                xroot.Add(new XAttribute("Id", content.Id ?? ""));
                xroot.Add(new XAttribute("Parent", content.Parent != null ? content.Parent.Id ?? "" : ""));
                xroot.Add(new XAttribute("Type", content.PluginMediaType));
                xroot.Add(new XAttribute("Title", content.Title));

                if (root)
                {
                    foreach (var child in (content as IPluginContainer).Children)
                    {
                        if (_device.Filter.Check(plugin).Check(child.Id).HasChild() || !_device.Filter.Check(plugin).Check(child.Id).Check())
                        {
                            xroot.Add(GetXDocument(child, plugin));
                        }
                    }
                }

                return(xroot);
            }
            XElement xe = new XElement("item");

            xe.Add(new XAttribute("Id", content.Id));
            xe.Add(new XAttribute("Parent", content.Parent != null ? content.Parent.Id ?? "" : ""));
            xe.Add(new XAttribute("Type", content.PluginMediaType));
            xe.Add(new XAttribute("Title", content.Title));
            xe.Add(new XAttribute("Url", content.GetUrl(host)));
            return(xe);
        }
 public static VirtualItem Copy(IPluginContent content)
 {
     return(new VirtualItem
     {
         Id = content.Id,
         Title = content.Title,
         PluginMediaType = content.PluginMediaType,
         Parent = content.Parent,
         Translation = content.Translation
     });
 }
Beispiel #4
0
        private Item GetItem(IPluginContent content, string host)
        {
            Item item;

            if (content is IPluginContainer)
            {
                item = new ItemContainer(null, _device)
                {
                    Title = "[" + content.Title + "]"
                };
            }
            else if (content.Translation == TranslationType.VoD)
            {
                item = new ItemVideo(null, _device)
                {
                    Title = content.Title
                };
                item.ContentUrl = host + "/" + _plugin.Id + "/play?id=" + content.Id;
            }
            else
            {
                item = new ItemStream(null, MediaType.Video, _device)
                {
                    Title      = content.Title,
                    ContentUrl =
                        string.IsNullOrEmpty(content.GetUrl(host))
                            ? string.Format("{0}/{1}/play?id={2}", host, Id, content.Id)
                            : content.GetUrl(host)
                };
            }


            item.ParentId = ParentId + "_" + Id;
            item.Id       = item.ParentId + "_" + content.Id;
            if (!string.IsNullOrEmpty(content.Parent.Id))
            {
                item.ParentId = item.ParentId + "_" + content.Parent.Id;
            }
            item.IconUrl = content.Icon;


            item.Type = MediaType.Video;
            return(item);
        }
Beispiel #5
0
        static void Main(string[] para)
        {
            try
            {
                Application.ThreadException += Application_ThreadException;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                //当从服务登陆的时候,从命令行中获取的登录信息
                if (para != null && para.Length > 0)
                {
                    string value = para[0];
                    int    index = value.IndexOf("://");
                    if (index != -1)
                    {
                        string needWord = value.Substring(index + 3);
                        if (needWord.EndsWith("/"))
                        {
                            needWord = needWord.Trim(new char[] { '/' });
                        }
                        string[] arrayStrs = needWord.Split(new char[] { ' ' });
                        if (arrayStrs.Length > 1)
                        {
                            string userName = arrayStrs[0];
                            string passWord = arrayStrs[1];
                            Core.ServiceLocator.ServiceLocatorFactory.ServiceLocator.SetInstance <string>(userName, Core.ServiceLocator.ServiceLocatorKeys.LoginUserID);
                            Core.ServiceLocator.ServiceLocatorFactory.ServiceLocator.SetInstance <string>(passWord, Core.ServiceLocator.ServiceLocatorKeys.LoginPassWord);
                        }
                    }
                }

                //SystemStart systemstart = new SystemStart();
                //PlotBuild build = new PlotBuild();
                //IPluginContent content = systemstart.ShowDialog(build);
                //if (content == null)
                //    return;
                IApplicationContext pContext = ContextRegistry.GetContext();


                IOpenProjectLogic open = pContext.GetObject("IOpenProjectLogic") as IOpenProjectLogic;
                if (!open.ProjectExit() && !open.OpenAccess())
                {
                    return;
                }

                IPlotBuild     plotbuild = pContext.GetObject("IPlotBuild") as IPlotBuild;
                IPluginContent content   = plotbuild.Build();
                if (content == null)
                {
                    return;
                }
                if (content.PluginMainForm is RibbonDevWorkPlantForm)
                {
                    (content.PluginMainForm as RibbonDevWorkPlantForm).SetWorkspace(content);
                }
                Application.Run(content.PluginMainForm as Form);
            }
            catch (Exception e)
            {
                if (e is Core.SysRegist.SysRegistException)
                {
                    ForeStar.SysReg.SysRegistForm from = new SysReg.SysRegistForm();
                    DialogResult dr = from.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        Application.Restart();
                    }
                    else
                    {
                        Application.Exit();
                    }
                }

                try
                {
                    ILog adviceLogger = LogManager.GetLogger(AppDomain.CurrentDomain.Id.ToString());
                    adviceLogger.Error(e.Message, e);
                }
                catch { }
            }
        }
 public static VirtualItem Copy(IPluginContent content)
 {
     return new VirtualItem
     {
         Id = content.Id,
         Title = content.Title,
         PluginMediaType = content.PluginMediaType,
         Parent = content.Parent,
         Translation = content.Translation
     };
 }
        public XElement GetXDocument(IPluginContent content, string plugin, bool root = false, string host="")
        {
            if (content is IPluginContainer)
            {
                XElement xroot = new XElement("items");
                xroot.Add(new XAttribute("Id", content.Id ?? ""));
                xroot.Add(new XAttribute("Parent", content.Parent != null ? content.Parent.Id ?? "" : ""));
                xroot.Add(new XAttribute("Type", content.PluginMediaType));
                xroot.Add(new XAttribute("Title", content.Title));

                if (root)
                    foreach (var child in (content as IPluginContainer).Children)
                    {
                        if (_device.Filter.Check(plugin).Check(child.Id).HasChild() || !_device.Filter.Check(plugin).Check(child.Id).Check())
                        xroot.Add(GetXDocument(child, plugin));
                    }

                return xroot;
            }
            XElement xe = new XElement("item");
            xe.Add(new XAttribute("Id", content.Id));
            xe.Add(new XAttribute("Parent", content.Parent != null ? content.Parent.Id ?? "" : ""));
            xe.Add(new XAttribute("Type", content.PluginMediaType));
            xe.Add(new XAttribute("Title", content.Title));
            xe.Add(new XAttribute("Url", content.GetUrl(host)));
            return xe;
        }
Beispiel #8
0
        private Item GetItem(IPluginContent content, string host)
        {
            Item item;
            if (content is IPluginContainer)
            {
                item = new ItemContainer(null, _device) {Title = "[" + content.Title + "]"};
            }
            else if (content.Translation == TranslationType.VoD)
            {
                item = new ItemVideo(null, _device) {Title = content.Title};
                item.ContentUrl = host + "/" + _plugin.Id + "/play?id=" + content.Id;
            }
            else
            {
                item = new ItemStream(null, MediaType.Video, _device)
                {
                    Title = content.Title,
                    ContentUrl =
                        string.IsNullOrEmpty(content.GetUrl(host))
                            ? string.Format("{0}/{1}/play?id={2}", host, Id, content.Id)
                            : content.GetUrl(host)
                };
            }


            item.ParentId = ParentId + "_" + Id;
            item.Id = item.ParentId + "_" + content.Id;
            if (!string.IsNullOrEmpty(content.Parent.Id))
                item.ParentId = item.ParentId + "_" + content.Parent.Id;
            item.IconUrl = content.Icon;
            
            
            item.Type = MediaType.Video;
            return item;

        }