コード例 #1
0
ファイル: FeedAggregator.cs プロジェクト: gekola/BSUIR-labs
 private void CategorizeEntry(FeedEntry entry,
                          IEnumerable<string> categories)
 {
     ThreadPool.QueueUserWorkItem((dynamic obj) => {
     foreach (string cat in obj.categories) {
       obj.entry.Category = cat;
       notify_callback(obj.entry.Clone());
     }
       }, new {entry = entry, categories = categories});
 }
コード例 #2
0
ファイル: MainWin.xaml.cs プロジェクト: gekola/BSUIR-labs
 private void OnNewFeedEntry(FeedEntry entry)
 {
     lock(entries) {
     entries.Add(entry);
     lock(Categories)
       this.Dispatcher.BeginInvoke((Action)(()=> {
     if (CurrentCategory != null &&
         CurrentCategory.Content as string == entry.Category)
       feeds.Items.Add(entry);
     if (!Categories.Select(x=>x.Content).Contains(entry.Category)) {
       System.Console.WriteLine("==> {0}", entry.Category);
       Categories.Add(new ComboBoxItem(){ Content = entry.Category});
     }
       }));
       }
 }
コード例 #3
0
ファイル: MainWin.xaml.cs プロジェクト: gekola/BSUIR-labs
 private void OnNewFeedEntry(FeedEntry entry)
 {
     this.Dispatcher.BeginInvoke((Action)(()=>feeds.Items.Add(entry)));
 }
コード例 #4
0
ファイル: FeedAggregator.cs プロジェクト: gekola/BSUIR-labs
        private void SendEmail(FeedEntry entry,
                           IEnumerable<string> categories)
        {
            ThreadPool.QueueUserWorkItem((dynamic obj) => {
            try {
              SmtpClient client = new SmtpClient();
              client.Port = 587;
              client.Host = "smtp.gmail.com";
              client.EnableSsl = true;
              client.Timeout = 200000;
              client.DeliveryMethod = SmtpDeliveryMethod.Network;
              client.UseDefaultCredentials = false;
              client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "password");

              MailMessage mm = new MailMessage();
              mm.To.Add("*****@*****.**");
              mm.From = new MailAddress("*****@*****.**");
              var subj = new StringBuilder();
              foreach(var cat in obj.categories) {
            subj.Append(cat);
            subj.Append(", ");
              }
              subj.Append("rss");
              mm.Subject = subj.ToString();
              mm.Body = entry.Content;
              mm.BodyEncoding = UTF8Encoding.UTF8;
              mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

              client.Send(mm);
            } catch (Exception e) {
              Console.WriteLine("Could not send e-mail. Exception caught: " + e);
            }

              }, new {entry = entry, categories = categories});
        }