コード例 #1
0
ファイル: WordController.cs プロジェクト: aml630/FactFlux
        private static void AddNewResourcesFromYouTube(ref string updateResults, FactFluxEntities db, RSSFeed feed, ref int articlesAdded)
        {
            var youTubeLogic = new Logic.YouTubeLogic();

            var videoList = youTubeLogic.GetVidsForFeed(feed.FeedLink);

            var vidListResult = videoList.Result.Where(x => x.Id.VideoId != null).ToList();

            foreach (var item in vidListResult)
            {
                var text = item.Snippet.Title;

                if (OnlyAddUniqueArticle(text))
                {
                    try
                    {
                        if (item.Snippet.PublishedAt == null)
                        {
                            item.Snippet.PublishedAt = DateTime.UtcNow;
                        }

                        ArticleLink newArticleLinke = CreateNewArticleLink(db, feed, item.Snippet.Title, item.Id.VideoId, item.Snippet.PublishedAt.Value);

                        articlesAdded += 1;
                    }
                    catch (Exception ex)
                    {
                        updateResults += ex.Message;
                    }
                }
            }
        }
コード例 #2
0
 public override IDocEntity SaveChanges(bool ignoreCache, DocConstantPermission permission)
 {
     ArticleId   = ArticleId?.TrimAndPruneSpaces();
     ArticleLink = ArticleLink?.TrimAndPruneSpaces();
     SearchLink  = SearchLink?.TrimAndPruneSpaces();
     return(base.SaveChanges(ignoreCache, permission));
 }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            ArticleLink articleLink = db.ArticleLinks.Find(id);

            db.ArticleLinks.Remove(articleLink);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "id,ArticleId,Link")] ArticleLink articleLink)
 {
     if (ModelState.IsValid)
     {
         db.Entry(articleLink).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ArticleId = new SelectList(db.articles, "id", "title", articleLink.ArticleId);
     return(View(articleLink));
 }
コード例 #5
0
        public ActionResult Create([Bind(Include = "id,ArticleId,Link")] ArticleLink articleLink)
        {
            if (ModelState.IsValid)
            {
                db.ArticleLinks.Add(articleLink);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ArticleId = new SelectList(db.articles, "id", "title", articleLink.ArticleId);
            return(View(articleLink));
        }
コード例 #6
0
        // GET: ArticleLink/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleLink articleLink = db.ArticleLinks.Find(id);

            if (articleLink == null)
            {
                return(HttpNotFound());
            }
            return(View(articleLink));
        }
コード例 #7
0
        // GET: ArticleLink/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleLink articleLink = db.ArticleLinks.Find(id);

            if (articleLink == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ArticleId = new SelectList(db.articles, "id", "title", articleLink.ArticleId);
            return(View(articleLink));
        }
コード例 #8
0
ファイル: WordController.cs プロジェクト: aml630/FactFlux
        private static string CutArticleIntoWords(FactFluxEntities db, ArticleLink newArticleLinke)
        {
            string responseText = "Chopping: " + newArticleLinke.ArticleLinkTitle;
            //divide article title into words
            var punctuation = newArticleLinke.ArticleLinkTitle.Where(Char.IsPunctuation).Distinct().ToArray();
            var words       = newArticleLinke.ArticleLinkTitle.Split().Select(x => x.Trim(punctuation));

            var oneWordLogPerArticle = new List <string>();

            foreach (var singleWord in words)
            {
                //for each word, check if we store a word or phrase that contains it
                var doesExistList = db.Words.Where
                                        (x => x.Word1.ToLower() == singleWord.ToLower() ||
                                        (x.Word1.Contains(" ") && x.Word1.ToLower().Contains(singleWord.ToLower())
                                        )).OrderByDescending(x => x.Word1.Length).ToList();

                // if we dont haveit, make it
                if (doesExistList == null || doesExistList.Count == 0 || !doesExistList.Any(x => x.Word1.ToLower() == singleWord.ToLower()) && singleWord != "")
                {
                    responseText += "--Creating: " + singleWord;
                    var newWord = CreateNewWord(db, newArticleLinke.DatePublished, singleWord);
                }

                //if we do have it, lets loop through them
                foreach (var doesExist in doesExistList)
                {
                    //words or phrases should only be logged once per article
                    var alreadyLogged = oneWordLogPerArticle.Any(x => x.Contains(newArticleLinke.ArticleLinkId.ToString() + doesExist.WordId));
                    //if the word isn't banned, and the entire word or phrase is contained in the article, lets log it
                    if (doesExist.Banned == false && newArticleLinke.ArticleLinkTitle.ToLower().Contains(doesExist.Word1.ToLower()) && alreadyLogged == false)
                    {
                        responseText += "--logging: " + singleWord;

                        oneWordLogPerArticle.Add(newArticleLinke.ArticleLinkId.ToString() + doesExist.WordId);

                        CreateWordLog(db, newArticleLinke.DatePublished, newArticleLinke.ArticleLinkId, doesExist.WordId, doesExist.Slug);
                    }
                }

                db.SaveChanges();
            }
            return(responseText);
        }
コード例 #9
0
ファイル: WordController.cs プロジェクト: aml630/FactFlux
        private static int AddNewResourcesFromRSS(ref string updateResults, FactFluxEntities db, RSSFeed feed)
        {
            var r      = XmlReader.Create(feed.FeedLink);
            var albums = SyndicationFeed.Load(r);

            int articlesAdded = 0;

            var currentRSSArticeList = new List <string>();

            //for each article in the feed
            foreach (var item in albums.Items)
            {
                var text = item.Title.Text;

                var isArticleRepeatInFeedList = currentRSSArticeList.FirstOrDefault(stringToCheck => stringToCheck.Contains(text));

                if (OnlyAddUniqueArticle(text) && isArticleRepeatInFeedList == null)
                {
                    try
                    {
                        currentRSSArticeList.Add(text);

                        if (string.IsNullOrEmpty(item.Title.Text) || string.IsNullOrEmpty(item.Links[0].Uri.AbsoluteUri) || item.PublishDate.UtcDateTime == null)
                        {
                            break;
                        }

                        ArticleLink newArticleLinke = CreateNewArticleLink(db, feed, item.Title.Text, item.Links[0].Uri.AbsoluteUri, item.PublishDate.UtcDateTime);

                        articlesAdded += 1;
                    }
                    catch (DbEntityValidationException ex)
                    {
                        updateResults += ex.Message;
                    }
                }
            }
            r.Close();
            return(articlesAdded);
        }
コード例 #10
0
ファイル: WordController.cs プロジェクト: aml630/FactFlux
        public static void PullDownAllLinksFromFeeds(RSSFeed rssFeed)
        {
            if (rssFeed.FeedLink != null)
            {
                var r      = XmlReader.Create(rssFeed.FeedLink);
                var albums = SyndicationFeed.Load(r);

                foreach (var item in albums.Items)
                {
                    var text = item.Title.Text;

                    if (OnlyAddUniqueArticle(text))
                    {
                        using (FactFluxEntities db = new FactFluxEntities())
                        {
                            try
                            {
                                var newArticleLinke = new ArticleLink();

                                newArticleLinke.ArticleLinkTitle = item.Title.Text;
                                newArticleLinke.ArticleLinkUrl   = item.Links[0].Uri.AbsoluteUri;
                                newArticleLinke.DatePublished    = item.PublishDate.UtcDateTime;
                                newArticleLinke.DateAdded        = DateTime.UtcNow;
                                newArticleLinke.FeedId           = rssFeed.FeedId;

                                db.ArticleLinks.Add(newArticleLinke);

                                db.SaveChanges();
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }

                r.Close();
            }
        }
コード例 #11
0
ファイル: Article.cs プロジェクト: victorvilella/libvw
        public ArticleLinkModel(RacLib.RacMsg msgs, ArticleLink n)
        {
            Type        = (int)n.type;
            TypeName    = "";
            Link        = n.link;
            Description = n.description;

            switch (n.type)
            {
            case ArticleLink.LinkType.ExternalLink:
                TypeName = msgs.Get(RacLib.RacMsg.Id.ExternalLink);
                break;

            case ArticleLink.LinkType.Image:
                TypeName = msgs.Get(RacLib.RacMsg.Id.Image);
                break;

            case ArticleLink.LinkType.Video:
                TypeName = msgs.Get(RacLib.RacMsg.Id.Video);
                break;
            }
        }
コード例 #12
0
ファイル: WordController.cs プロジェクト: aml630/FactFlux
        private static ArticleLink CreateNewArticleLink(FactFluxEntities db, RSSFeed feed, string Title, string Url, DateTime publishDate)
        {
            var newArticleLinke = new ArticleLink();

            if (Title.Contains("&#8216;"))
            {
                Title = Title.Replace("&#8216;", "");
            }
            if (Title.Contains("&#8217;"))
            {
                Title = Title.Replace("&#8217;", "");
            }

            newArticleLinke.ArticleLinkTitle = Title;
            newArticleLinke.ArticleLinkUrl   = Url;
            newArticleLinke.DatePublished    = publishDate;
            newArticleLinke.DateAdded        = DateTime.UtcNow;
            newArticleLinke.FeedId           = feed.FeedId;

            db.ArticleLinks.Add(newArticleLinke);

            db.SaveChanges();
            return(newArticleLinke);
        }