Esempio n. 1
0
        public IActionResult Index()
        {
            var html = @"http://ami.lnu.edu.ua/news";

            HtmlWeb web = new HtmlWeb();

            var htmlDoc = web.Load(html);

            var node = htmlDoc.DocumentNode.SelectSingleNode("//head/title");

            Console.WriteLine("Node Name: " + node.Name + "\n" + node.OuterHtml);

            var htmlNodes = htmlDoc.DocumentNode.SelectNodes("//article//div[@class='excerpt']//a[@class='read-more']").First();

            /*
             * var html = @"http://bioweb.lnu.edu.ua/department/biophysics-and-bioinformatics";
             *
             * var test_res = ArticleDepartmentCriteria.ExtractArticles(htmlDoc.DocumentNode,"//body//div[@class='content news']");
             * var test_res = ArticleDepartmentCriteria.ExtractArticles(htmlDoc.DocumentNode, "//body//div//div//section");
             */


            ArticleCriteria test = new ArticleCriteria(null, 0, "");

            test.MainFunction(DateTime.Parse("01.01.2019", CultureInfo.CreateSpecificCulture("fr-FR")));

            return(View());
        }
Esempio n. 2
0
        public string GetArticles(int page = 1, int n = 1, int lastId = 0, int userId = 0, string type = "")
        {
            if (page < 1)
            {
                return("");
            }
            var cr = new ArticleCriteria()
            {
                StartFrom = page * NumberOfItemsOnPage, UserId = 0, Count = n * NumberOfItemsOnPage, LastId = lastId
            };

            if (User.Identity.IsAuthenticated)
            {
                var userIdentityId = User.Identity.GetUserId <int>();
                if (type == "tags")
                {
                    cr.UserId = userIdentityId;
                    var currentUser = userRepo.GetById(userIdentityId);
                    var tags        = currentUser.Tags;
                    return(JsonConvert.SerializeObject(repo.GetArticleByTags(tags, cr)));
                }
                if (type == "my")
                {
                    cr.UserId = userIdentityId;
                }
            }
            var lst = repo.GetDemoList(cr);

            return(JsonConvert.SerializeObject(lst));
        }
Esempio n. 3
0
        public string GetArticles(int page = 1, int n = 1, int lastId = 0, int userId = 0)
        {
            if (page < 1)
            {
                return("");
            }
            var cr = new ArticleCriteria()
            {
                StartFrom = page * NumberOfItemsOnPage, UserId = userId, Count = n * NumberOfItemsOnPage, LastId = lastId
            };
            var lst = repo.GetDemoList(cr);// as IList<DemoArticle>;

            return(JsonConvert.SerializeObject(lst));
        }
 public IList <DemoArticle> GetArticleList(ArticleCriteria cr)
 {
     throw new NotImplementedException();
 }