Example #1
0
        public object Get(GetTwitterNewsFeeds request)
        {
            var            context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            List <WebNews> result  = new List <WebNews>();

            try{
                context.Open();
                context.LogInfo(this, string.Format("/news/twitter/feeds GET"));

                var twitterCollection          = TwitterNews.LoadTwitterCollection(context);
                var twitters                   = twitterCollection.GetFeeds(new System.Collections.Specialized.NameValueCollection());
                List <TwitterNews> tweetsfeeds = new List <TwitterNews>();
                tweetsfeeds.AddRange(TwitterNews.FromFeeds(context, twitters));
                foreach (TwitterNews tweetfeed in tweetsfeeds)
                {
                    result.Add(new WebNews(tweetfeed));
                }

                context.Close();
            }catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(result);
        }
Example #2
0
        public object Get(GetAllNewsFeeds request)
        {
            List <WebNews> result = new List <WebNews>();

            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);

            try {
                context.Open();
                context.LogInfo(this, string.Format("/news/feeds GET"));

                //get internal news
                //try{
                //    EntityList<Article> news = new EntityList<Article>(context);
                //    news.Load();
                //    foreach(Terradue.Portal.Article f in news){
                //        if(f.GetType() == typeof(Article))
                //            result.Add(new WebNews(f));
                //    }
                //}catch(Exception){}

                //get twitter news
                try {
                    var twitterCollection          = TwitterNews.LoadTwitterCollection(context);
                    var twitters                   = twitterCollection.GetFeeds(new System.Collections.Specialized.NameValueCollection());
                    List <TwitterNews> tweetsfeeds = new List <TwitterNews>();
                    tweetsfeeds.AddRange(TwitterNews.FromFeeds(context, twitters));
                } catch (Exception) { }

                //get rss news
                try{
                    EntityList <RssNews> rsss = new EntityList <RssNews>(context);
                    rsss.Load();
                    List <RssNews> rssfeeds = new List <RssNews>();
                    foreach (RssNews rss in rsss)
                    {
                        rssfeeds.AddRange(rss.GetFeeds());
                    }
                    foreach (RssNews rssfeed in rssfeeds)
                    {
                        result.Add(new WebNews(rssfeed));
                    }
                }catch (Exception) {}

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result.OrderByDescending(r => r.Date));
        }