public List <RssFeed> GetFeeds() { using (var ctx = new RssContext()) { return(ctx.Feeds.Include(f => f.Posts).Include(f => f.MatchCriteria).ToList()); } }
public UnitOfWork(RssContext rssContext) { _rssContext = rssContext; NewsPostRepository = new NewsPostRepository(rssContext); FeedList = new FeedRepository(rssContext); ItemListRepository = new ItemListRepository(rssContext); }
public List <RssPost> Search(int?feedId, string keyword, DateTime?startDate, DateTime?endDate) { using (var ctx = new RssContext()) { var query = (IQueryable <RssPost>)ctx.Posts; if (feedId != null) { query = query.Where(p => p.FeedId == feedId); } if (keyword != null) { query = query.Where( p => p.Title.Contains(keyword) || p.Description.Contains(keyword) || p.Content.Contains(keyword)); } if (startDate != null) { query = query.Where(p => p.PostDate >= startDate); } if (endDate != null) { query = query.Where(p => p.PostDate <= endDate); } return(query.ToList()); } }
public void Fetch() { RssContext context = new RssContext(); var rss = context.RssItem.ToList(); Clients.All.addMessage(rss); }
public MainWindow() { db = new RssContext(); InitializeComponent(); FindNoticeByID(); FindNoticeByChannelID(); }
public static void Write() { GetLinks(); using (var db = new RssContext()) { var test = db.RssChannel.FirstOrDefault(); int counter = 1; foreach (var item in XmlLinks)//Exception { try { reader.Url = item; reader.GetFeed(); noticeItems = reader.RssItems; // checking db existing counter++; RssChannel channel = new RssChannel(); if (test == null) { channel.ChannelName = "Channel" + counter; channel.ChannelLink = item; db.RssChannel.Add(channel); db.SaveChanges(); } else { channel = db.RssChannel.Where(x => x.ChannelID == counter).First(); } for (int i = 0; i < noticeItems.Count; i++) { Notice notice = new Notice(); notice.PageLink = noticeItems[i].Link; notice.PublishDate = noticeItems[i].Date; notice.Title = noticeItems[i].Title; notice.Channel_Id = channel.ChannelID; if (db.Notice.Where(x => x.Title == notice.Title).FirstOrDefault() == null) { db.Notice.Add(notice); } } //db.RssChannel.Add(channel); db.SaveChanges(); } catch (Exception ex) { } } } }
public void SavePost(RssPost post) { using (var ctx = new RssContext()) { AddOrUpdate(post, ctx); ctx.SaveChanges(); } }
public void SaveFeed(RssFeed feed) { using (var ctx = new RssContext()) { AddOrUpdate(feed, ctx); ctx.SaveChanges(); } }
public void SaveMatchCirterion(RssFeedMatchCriterion criterion) { using (var ctx = new RssContext()) { AddOrUpdate(criterion, ctx); ctx.SaveChanges(); } }
public void SavePosts(List <RssPost> newPosts) { using (var ctx = new RssContext()) { foreach (var newPost in newPosts) { AddOrUpdate(newPost, ctx); } ctx.SaveChanges(); } }
public void DeleteRss(RssEntry rssEntry) { using (var db = new RssContext()) { var item = db.RssEntries.Find(rssEntry.Id); if (item == null) { return; } db.RssEntries.Remove(item); db.SaveChanges(); _feeds.Remove(rssEntry); } }
public ServiceCore() { RssContext db = new RssContext(); _timer = new Timer(30000) { AutoReset = true }; _timer.Elapsed += (sender, eventArgs) => DbWriter.Write(); Console.WriteLine("Database write successes !!!"); Console.ReadKey(); }
public void FireDatabaseEvents() { RssContext context = new RssContext(); var rss = context.RssItem.ToList(); BlockingCollection <string> mailList = new BlockingCollection <string>(); context.Customer.Select(s => s.Email).ToList().ForEach(f => mailList.Add(f)); foreach (RssItem item in rss) { var mailer = new Mailer.Mailer(mailList, item); mailer.StartEmailRun(); } BroadcastToClients(rss); }
public static void Write() { // write test GetLinks(); // write test using (var db = new RssContext()) { foreach (var item in XmlLinks) { //int count = 1; RssChannel channel = new RssChannel(); channel.ChannelName = item; //channel.ChannelLink = item; try { reader.Url = item; reader.GetFeed(); noticeItems = reader.RssItems; for (int i = 0; i < noticeItems.Count; i++) { Notice notice = new Notice(); notice.PageLink = item; notice.PublishDate = noticeItems[i].Date; notice.Title = noticeItems[i].Title; notice.Channel_Id = channel.ChannelID; notice.PageText = ""; db.Notice.Add(notice); } db.RssChannel.Add(channel); db.SaveChanges(); } catch (Exception ex) { } } } }
public RssEntriesViewModel(IEventAggregator aggregator) { Feeds = CollectionViewSource.GetDefaultView(_feeds); _aggregator = aggregator; DisplayName = "RSS Entries"; using (var db = new RssContext()) { _feeds.AddRange(db.RssEntries.ToArray()); } aggregator.Subscribe(this); Feeds.SortDescriptions.Add(new SortDescription("PublishedDate", ListSortDirection.Descending)); PropertyChanged += (sender, args) => { if (args.PropertyName != nameof(FilterText)) { return; } if (string.IsNullOrWhiteSpace(FilterText)) { Feeds.Filter = o => true; } else if (FilterText.Length < 3) { Feeds.Filter = o => false; } else { Feeds.Filter = o => o is RssEntry item && (item.PublishedDate.ToString(CultureInfo.InvariantCulture).Contains(FilterText) || item.Title.ToLower().Contains(FilterText.ToLower()) || item.Url.ToLower().Contains(FilterText.ToLower())); } }; }
public RssRepository() { context = RssContext.Create(); }
public RepositoryFeed(RssContext context) : base(context) { }
public RssServicesController(RssContext _rssContext) { rssContext = _rssContext; rssService = new RSSData.services.RssService(rssContext); }
public Repository(RssContext context) { this.context = context; DbSet = context.Set <T>(); }
private static void AddOrUpdate(IEntity entity, RssContext ctx) { ctx.Entry(entity).State = entity.Id != null ? EntityState.Modified : EntityState.Added; }
public RepositoryItem(RssContext context) : base(context) { }
public RssUnitOfWork(string connectionString) { this._db = new RssContext(connectionString); this.News = new NewsRepository(this._db); this.Sources = new SourceRepository(this._db); }
public RssService(RssContext rssContext) { rSSContext = rssContext; }
public NewsRepository(RssContext dbContext) { this._db = dbContext; }
public SourceRepository(RssContext dbContext) { this._db = dbContext; }
public BaseRepository() { Context = new RssContext(); }