Beispiel #1
0
        public void DeleteTest()
        {
            var s = dp.GetFromSelect("select * from Feed where Id not in (select FeedId from article)").ToFeeds();

            foreach (var feed in s)
            {
                var             request  = (HttpWebRequest)WebRequest.Create(feed.Url);
                HttpWebResponse response = null;
                try
                {
                    response = (HttpWebResponse)request.GetResponse();
                    if (response.StatusCode == HttpStatusCode.NotFound)
                    {
                        FeedService.DeleteFeed(feed.Id);
                    }
                }
                catch (WebException we)
                {
                    if (we.Status == WebExceptionStatus.NameResolutionFailure || (we.Response != null && ((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.NotFound))
                    {
                        FeedService.DeleteFeed(feed.Id);
                    }
                }
                if (response != null)
                {
                    response.Close();
                }
            }
        }
Beispiel #2
0
        public ActionResult Feeds(int feedId, string action)
        {
            var feed = FeedService.GetFeed(feedId);

            switch (action)
            {
            case "reviewed": feed.Reviewed = true; break;

            case "public": feed.Public = true; break;
            }

            if (action == "delete")
            {
                FeedService.DeleteFeed(feedId);
            }
            else
            {
                FeedService.UpdateFeed(feed);
            }

            if (action == "public")
            {
                var articles = FeedService.GetArticles(feed.Id);
                foreach (var article in articles)
                {
                    article.Feed = feed;
                    article.Tags = FeedService.GetArticleTags(article.Id);
                    Redis.AddArticle(article);
                }
            }

            return(RedirectToAction("Feeds"));
        }