Example #1
0
        static void GetArticles(string channelUrl, string category)
        {
            var lstArticles = _spider.GetArticles(channelUrl);

            lstArticles.ForEach(item =>
            {
                InsertArticle(_appDbContext.Users.FirstOrDefault(x => x.Username.Equals("spider"))?.Username, item, category);
            });
        }
Example #2
0
        static void GetArticles(string channelUrl, int channelId)
        {
            var lstArticles = spider.GetArticles(channelUrl, channelId);

            foreach (var article in lstArticles)
            {
                if (article.excerpt.Length > 999)
                {
                    article.excerpt = article.excerpt.Substring(0, 999);
                }
                var insertedID = sqlhelperBackend.AddToGetInsertID("[Article]", new Dictionary <string, string> {
                    { "ChannelId", channelId.ToString() },
                    { "Title", article.title },
                    { "Thumbnail", article.lead_image_url },
                    { "Headlines", article.excerpt },
                    { "Content", article.content },
                    { "Keyword", "" },
                    { "Source", article.domain },
                    { "SourceUrl", article.url },
                    { "SourceType", "16" },
                    { "FriendlyTitle", VietCMS.Framework.Core.Common.WebControl.ToFriendlyString(article.title) },
                    { "TypeId", "1" },
                    { "AuthorAlias", article.author },
                    { "Status", "2" },
                    { "CreatedAt", DateTime.Now.ToString() },
                    { "CreatedBy", System.Configuration.ConfigurationManager.AppSettings.Get("User_ID") },
                    { "LastModifiedBy", System.Configuration.ConfigurationManager.AppSettings.Get("User_ID") },
                    { "LastModifiedAt", DateTime.Now.ToString() }
                }, "INSERTED.ArticleId");
                sqlhelperBackend.Add("[ArticleRoyalty]", new Dictionary <string, string> {
                    { "ArticleId", insertedID.ToString() },
                    { "RoyaltyStepId", "16" },
                    { "CreatedBy", System.Configuration.ConfigurationManager.AppSettings.Get("User_ID") },
                    { "CreatedAt", DateTime.Now.ToString() },
                    { "LastModifiedBy", System.Configuration.ConfigurationManager.AppSettings.Get("User_ID") },
                    { "LastModifiedAt", DateTime.Now.ToString() }
                });
            }
        }