Example #1
0
 private string GetCachedJSON()
 {
     if (ProxyAsync.IsUrlInCache(Cache, this.Url))
     {
         var cachedRSS = new ProxyAsync().GetRss(this.Url, this.Count, 10);            
         string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cachedRSS);
         return json;
     }
     else
         return null;
 }
Example #2
0
 private string LoadPictures()
 {
     string cachedXml = new ProxyAsync().GetXml(GetPhotoUrl(), 5); // was 10
     return cachedXml;
 }
Example #3
0
    private void ShowFeeds()
    {
        string url = State.Element("url").Value;
        int count = State.Element("count") == null ? 3 : int.Parse( State.Element("count").Value );
        
        /*
        var feed = Cache[url] as XElement;
        if( feed == null )
        {
            if( Cache[url] == string.Empty ) return;
            try
            {
                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
                
                request.Timeout = 15000;
                using( WebResponse response = request.GetResponse() )
                {
                    XmlTextReader reader = new XmlTextReader( response.GetResponseStream() );

                    feed = XElement.Load(reader);

                    if( feed == null ) return;

                    Cache.Insert(url, feed, null, DateTime.MaxValue, TimeSpan.FromMinutes(15));
                }
           
            }
            catch
            {
                Cache[url] = string.Empty;
                return;
            }
        }

        XNamespace ns = "http://www.w3.org/2005/Atom";
        
        // see if RSS or Atom
        if( feed.Element("channel" ) != null )
            FeedList.DataSource = (from item in feed.Element("channel").Elements("item")
                              select new 
                              { 
                                  title = item.Element("title").Value, 
                                  link = item.Element("link").Value,
                                  description = item.Element("description").Value
                              }).Take(this.Count);
            
        else if( feed.Element(ns + "entry") != null )
            FeedList.DataSource = (from item in feed.Elements(ns + "entry")
                              select new 
                              { 
                                  title = item.Element(ns + "title").Value, 
                                  link = item.Element(ns + "link").Attribute("href").Value,
                                  description = item.Element(ns + "content").Value
                              }).Take(this.Count);

        */

        using (var proxy = new Dropthings.Web.Framework.ProxyAsync())
        {
            var items = proxy.GetRss(url, count, 10);
            FeedList.DataSource = items;
        }

        FeedList.DataBind();

        //Cache[url] = feed;
    }
 private string GetCachedJSON()
 {
     if (ProxyAsync.IsUrlInCache(Cache, this.GetPhotoUrl()))
     {
         var cachedString = new ProxyAsync().GetString(this.GetPhotoUrl(), 10);
         string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cachedString);
         return json;
     }
     else
         return null;
 }