Ejemplo n.º 1
0
 public void SetArticlesReadForUser(int id_article, string user)
 {
     try
     {
         using (BD.AtomicRssDatabaseContainer context = new BD.AtomicRssDatabaseContainer())
         {
             BD.Users    u       = (from el in context.UsersSet where el.Email == user select el).FirstOrDefault();
             BD.Articles article = (from el in context.ArticlesSet where el.Id == id_article select el).FirstOrDefault();
             if (u != null && article != null)
             {
                 article.Users.Add(u);
             }
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }
Ejemplo n.º 2
0
 public void LoadArticles()
 {
     try
     {
         using (BD.AtomicRssDatabaseContainer context = new BD.AtomicRssDatabaseContainer())
         {
             foreach (BD.Channels chan in context.ChannelsSet)
             {
                 XmlReader       read  = XmlReader.Create(chan.Link);
                 SyndicationFeed feeds = SyndicationFeed.Load(read);
                 read.Close();
                 Debug.WriteLine("LoadArticles : " + chan.Link);
                 foreach (SyndicationItem article in feeds.Items)
                 {
                     BD.Articles a = new BD.Articles();
                     a.Date        = article.PublishDate.DateTime;
                     a.Title       = article.Title.Text;
                     a.Description = article.Summary.Text;
                     a.GUID        = "0000";
                     a.Link        = article.Id;
                     BD.Articles exist = (from el in chan.Articles where el.Link == a.Link select el).FirstOrDefault();
                     if (exist != null)
                     {
                         Debug.WriteLine("Test : " + a.Link + " exist : " + exist.Link);
                     }
                     if (exist == null)
                     {
                         Debug.WriteLine("Adding new article : " + a.Title);
                         chan.Articles.Add(a);
                         context.ArticlesSet.AddObject(a);
                     }
                 }
             }
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }