public WebFeed getWebFeed(FuenteWEB fuente, string filtrado) { /* * WebClient wc = new WebClient(); * string var = String.Format("{0:ddMMyyyyHHmmss}", DateTime.Now); * string tmpFile = "tmpfile" + var + ".dll"; * wc.DownloadFile(fuente.UrlDll, tmpFile); * AssemblyName an = AssemblyName.GetAssemblyName(tmpFile); */ WebFeed webfeed = null; byte[] bytes = GetBytesFromUrl(fuente.UrlDll); Assembly a = Assembly.Load(bytes); try { foreach (Type type in a.GetTypes()) { if (type.IsClass == true) { ConstructorInfo ci = type.GetConstructor(Type.EmptyTypes); object responder = ci.Invoke(null); MethodInfo mi = type.GetMethod("getWebFeed"); return((WebFeed)mi.Invoke(null, new object[] { fuente.Url, filtrado })); } } } catch (TargetInvocationException) { } return(null); }
// OBSOLETA // Devuelve Feeds filtrados segun categoria tematica para origenes de fuentes de datos del Movimiento de la convocatoria public List <WebFeed> GetFeedsConvocatoria(int idConvocatoria) { Console.WriteLine("Obtener Feeds convocatoria con ID" + idConvocatoria); Convocatoria conv = GetConvocatoriaById(idConvocatoria); List <WebFeed> lwf = new List <WebFeed>(); //LINQ TO Entities var fuentes = from f in conv.Movimiento.FuentesWEB select f; foreach (var f in fuentes) { WebFeed wffiltrado = WebFeedReader.ReadFeedFiltrado(f.Url, f.Tipo, conv.CategoriaTematica.Nombre); if (wffiltrado.Nodes.Count > 0) { lwf.Add(wffiltrado); } } return(lwf); }
public static WebFeed ReadFeedFiltrado(string url, string tipo, string tematica) { try { if (!url.StartsWith("http://") && !url.StartsWith("https://")) { url = string.Format("http://{0}", url); } SyndicationFeedFormatter formatter = null; if (tipo.Equals("RSS")) { formatter = new Rss20FeedFormatter(); } else if (tipo.Equals("ATOM")) { formatter = new Atom10FeedFormatter(); } using (XmlReader reader = XmlReader.Create(url)) { // le decimos al formateador que analice el XML del feed. formatter.ReadFrom(reader); } WebFeed webFeed = new WebFeed { Title = formatter.Feed.Title.Text, Description = formatter.Feed.Description.Text, Language = formatter.Feed.Language, LastUpdatedTime = formatter.Feed.LastUpdatedTime.DateTime, Copyright = formatter.Feed.Copyright.Text, Nodes = new List <WebFeedNode>() }; foreach (SyndicationItem item in formatter.Feed.Items) { if (itemRelacionado(item, tematica)) { webFeed.Nodes.Add(new WebFeedNode { Title = item.Title.Text, PublishDate = item.PublishDate.DateTime, LastUpdateTime = item.LastUpdatedTime.DateTime, Summary = item.Summary.Text, Link = item.Links.First().Uri.ToString() }); } } return(webFeed); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public List <WebFeed> CargarYLeerFeeds(FuenteWEB[] fweb, string filtrado) { List <WebFeed> listaWF = new List <WebFeed>(); WebFeed wf = null; foreach (FuenteWEB fuente in fweb) { wf = getWebFeed(fuente, filtrado); if (wf != null) { listaWF.Add(wf); } } return(listaWF); }
public static WebFeed ReadFeedYT(string url, string tematica) { YouTubeRequestSettings settings = new YouTubeRequestSettings("IndignadoFramework", clave); YouTubeRequest request = new YouTubeRequest(settings); //YouTubeQuery query = new YouTubeQuery(url); YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); //order results by the number of views (most viewed first) query.OrderBy = "relevance"; // search for puppies and include restricted content in the search results // query.SafeSearch could also be set to YouTubeQuery.SafeSearchValues.Moderate query.Query = tematica; query.SafeSearch = YouTubeQuery.SafeSearchValues.None; Feed <Video> videoFeed = request.Get <Video>(query); WebFeed wf = new WebFeed { Title = "You Tube", Tipo = WebFeed.TipoFuente.VIDEO, Nodes = new List <WebFeedNode>() }; foreach (Video video in videoFeed.Entries) { wf.Nodes.Add(new WebFeedNode() { Link = video.WatchPage.ToString(), ThumbnailUrl = video.Thumbnails.First().Url.ToString(), Updated = video.Updated.ToString(), Title = video.Title }); } return(wf); }
protected void Page_Init(object sender, EventArgs e) { AuthenticationMode eAuthenticationMode = AuthenticationMode.None; string strSid = ""; AuthenticationSection objAuthenticationSection = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection; if ( objAuthenticationSection != null ) { eAuthenticationMode = objAuthenticationSection.Mode; } if ( eAuthenticationMode == AuthenticationMode.Forms ) { if ( HttpContext.Current.User.Identity.IsAuthenticated == false ) { Uri baseUrl = new Uri(Request.Url, Request.FilePath + "/.."); Response.Redirect(baseUrl.ToString() + "default.aspx?ReturnUrl=../WebFeed.aspx"); } TSFormAuthTicketInfo objTSFormAuthTicketInfo = new TSFormAuthTicketInfo(HttpContext.Current); strSid = objTSFormAuthTicketInfo.UserSid; // // TODO: Need to correctly call this // //Response.Write("\nshowWorkspaceNotification();"); } HttpContext.Current.Response.AppendHeader("Vary", "Accept"); FeedXmlVersion xmlVersion; string contentType; ContentNegotiationHelper.GetPreferredXmlVersion(out xmlVersion, out contentType); // downlevel requests cannot specify a folder if (xmlVersion == FeedXmlVersion.Win7 && Request.PathInfo.Length != 0) { Response.StatusCode = 404; Response.End(); } HttpContext.Current.Response.ContentType = contentType; string rdpRenderMode = HttpContext.Current.Request.Params.Get("rdpRender"); bool rdpEmbed = !String.IsNullOrEmpty(rdpRenderMode) && rdpRenderMode.Trim().ToLower(CultureInfo.InvariantCulture).Equals("inline"); try { WebFeed tswf = new WebFeed(rdpEmbed ? RdpType.Both : RdpType.Link); oXML = tswf.GenerateFeed(strSid, xmlVersion, Request.PathInfo, true); } catch (WorkspaceUnknownFolderException) { Response.StatusCode = 404; Response.End(); } catch (WorkspaceUnavailableException wue) { // This exception is raised when we cannot contact the appropriate sources to obtain the workspace information. // This is an edge case that can ocurr e.g. if the cpub server we're pointing to is down. Response.StatusCode = 503; // Write a simple text error string to the body, so that if an administrator happens to be accessing the feed via a browser, we can point them in the right direction // We need to wrap this in some sort of tags, otherwise IE does not display the message (since it expects an XML content-type) Response.Write("<Error>" + wue.Message + "</Error>"); Response.End(); } }
public static WebFeed ReadFeedRA(string url, SyndicationFeedFormatter formatter, string tematica, bool filtrar, bool RSS) { try { if (!url.StartsWith("http://") && !url.StartsWith("https://")) { url = string.Format("http://{0}", url); } using (XmlReader reader = XmlReader.Create(url)) { // le decimos al formateador que analice el XML del feed. formatter.ReadFrom(reader); } WebFeed webFeed = new WebFeed { Title = formatter.Feed.Title.Text, Description = formatter.Feed.Description.Text, Language = formatter.Feed.Language, LastUpdatedTime = formatter.Feed.LastUpdatedTime.DateTime, Nodes = new List <WebFeedNode>() }; if (RSS) { webFeed.Tipo = WebFeed.TipoFuente.RSS; } else { webFeed.Tipo = WebFeed.TipoFuente.ATOM; } if (formatter.Feed.Copyright != null) { webFeed.Copyright = formatter.Feed.Copyright.Text; } foreach (SyndicationItem item in formatter.Feed.Items) { if (itemRelacionado(item, tematica) || !filtrar) { webFeed.Nodes.Add(new WebFeedNode { Title = item.Title.Text, PublishDate = item.PublishDate.DateTime, LastUpdateTime = item.LastUpdatedTime.DateTime, Summary = item.Summary.Text, Link = item.Links.First().Uri.ToString() }); } } return(webFeed); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
protected void Page_Init(object sender, EventArgs e) { AuthenticationMode eAuthenticationMode = AuthenticationMode.None; string strSid = ""; AuthenticationSection objAuthenticationSection = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection; if (objAuthenticationSection != null) { eAuthenticationMode = objAuthenticationSection.Mode; } if (eAuthenticationMode == AuthenticationMode.Forms) { if (HttpContext.Current.User.Identity.IsAuthenticated == false) { Uri baseUrl = new Uri(Request.Url, Request.FilePath + "/.."); Response.Redirect(baseUrl.ToString() + "default.aspx?ReturnUrl=../WebFeed.aspx"); } TSFormAuthTicketInfo objTSFormAuthTicketInfo = new TSFormAuthTicketInfo(HttpContext.Current); strSid = objTSFormAuthTicketInfo.UserSid; // // TODO: Need to correctly call this // //Response.Write("\nshowWorkspaceNotification();"); } HttpContext.Current.Response.AppendHeader("Vary", "Accept"); FeedXmlVersion xmlVersion; string contentType; ContentNegotiationHelper.GetPreferredXmlVersion(out xmlVersion, out contentType); // downlevel requests cannot specify a folder if (xmlVersion == FeedXmlVersion.Win7 && Request.PathInfo.Length != 0) { Response.StatusCode = 404; Response.End(); } HttpContext.Current.Response.ContentType = contentType; string rdpRenderMode = HttpContext.Current.Request.Params.Get("rdpRender"); bool rdpEmbed = !String.IsNullOrEmpty(rdpRenderMode) && rdpRenderMode.Trim().ToLower(CultureInfo.InvariantCulture).Equals("inline"); try { WebFeed tswf = new WebFeed(rdpEmbed ? RdpType.Both : RdpType.Link); oXML = tswf.GenerateFeed(strSid, xmlVersion, Request.PathInfo, true); } catch (WorkspaceUnknownFolderException) { Response.StatusCode = 404; Response.End(); } catch (WorkspaceUnavailableException wue) { // This exception is raised when we cannot contact the appropriate sources to obtain the workspace information. // This is an edge case that can ocurr e.g. if the cpub server we're pointing to is down. Response.StatusCode = 503; // Write a simple text error string to the body, so that if an administrator happens to be accessing the feed via a browser, we can point them in the right direction // We need to wrap this in some sort of tags, otherwise IE does not display the message (since it expects an XML content-type) Response.Write("<Error>" + wue.Message + "</Error>"); Response.End(); } }
public static WebFeed ReadFeed(string url, string tipo) { try { if (!url.StartsWith("http://") && !url.StartsWith("https://")) { url = string.Format("http://{0}", url); } SyndicationFeedFormatter formatter = null; if (tipo.Equals("RSS")) { formatter = new Rss20FeedFormatter(); } else if (tipo.Equals("ATOM")) { formatter = new Atom10FeedFormatter(); } using (XmlReader reader = XmlReader.Create(url)) { // le decimos al formateador que analice el XML del feed. formatter.ReadFrom(reader); } WebFeed webFeed = new WebFeed { Title = formatter.Feed.Title.Text, Description = formatter.Feed.Description.Text, Language = formatter.Feed.Language, LastUpdatedTime = formatter.Feed.LastUpdatedTime.DateTime, Nodes = new List <WebFeedNode>() }; //if (formatter.Feed.Copyright != null) // webFeed.Copyright = formatter.Feed.Copyright.Text; foreach (SyndicationItem item in formatter.Feed.Items) { StringBuilder text = new StringBuilder().AppendFormat(item.Summary.Text); string summary = text.ToString(); if (summary.Length > 256) { summary = summary.Remove(256); } webFeed.Nodes.Add(new WebFeedNode { Title = item.Title.Text, PublishDate = item.PublishDate.DateTime, LastUpdateTime = item.LastUpdatedTime.DateTime, Summary = summary, Link = item.Links.First().Uri.ToString() }); } return(webFeed); } catch (Exception ex) { Console.WriteLine(ex.Message); return(new WebFeed { Nodes = new List <WebFeedNode>() }); } }