Beispiel #1
0
 public HtmlScraper(Substring substring, DataEntryModel dataEntryModel,
                    DAL.EntityFramework.SQL.NewsEntry efmodel, Logger logger, DataService ds)
 {
     _ss              = substring;
     _DEM             = dataEntryModel;
     EFnewsentryModel = efmodel;
     //_DE = dataEntry;
     _logger     = logger;
     dataService = ds;
 }
Beispiel #2
0
        public void Execute(NewsEntry NewsEntryModel)
        {
            var DeObj = new DAL.EntityFramework.SQL.NewsEntry();

            //var dbObj = (from entry in dc.NewsEntries where entry.Headline.StartsWith(DEM.Headline.Remove(10, DEM.Headline.Length - 10)) select entry).FirstOrDefault();
            var DBitem = context.FindHeadline(NewsEntryModel.Headline);

            if (DBitem == null)
            {
                DeObj.Headline    = NewsEntryModel.Headline;
                DeObj.HeadlineUrl = NewsEntryModel.HeadlineUrl;
                DeObj.NewsSource  = NewsEntryModel.NewsSource;
                DeObj.TimeAdded   = DateTime.UtcNow;
                DeObj.Article     = NewsEntryModel.Article;
                DeObj.Imagepath   = NewsEntryModel.Imagepath;
                DeObj.Category    = NewsEntryModel.Category;

                context.Insert(DeObj);
                context.Commit();

                _logger.Log($"Added to database", ConsoleColor.Red);
            }
        }