Пример #1
0
 private void ButtonPhoto_Click(object sender, EventArgs e)
 {
     var flickr = new Flickr(Program.ApiKey, Program.SharedSecret, Program.AuthToken);
     // Referrers
     DateTime day = DateTime.Today;
     var statfile = new System.IO.StreamWriter("stats_dom.csv");
     var reffile = new System.IO.StreamWriter("stats_referrers.csv");
     while (day > Program.LastUpdate)
     {
         try
         {
             var s = flickr.StatsGetPhotoDomains(day, 1, 100);
             day -= TimeSpan.FromDays(1);
             StatusLabel.Text = "Chargement des domaines " + day.ToShortDateString();
             Application.DoEvents();
             statfile.Write(Utility.toCSV(s, day.ToShortDateString()));
             foreach (StatDomain dom in s)
             {
                 var r = flickr.StatsGetPhotoReferrers(day, dom.Name, 1, 100);
                 reffile.Write(Utility.toCSV(r, day.ToShortDateString() + ";" + dom.Name));
             }
         }
         catch (FlickrApiException ex)
         {
             MessageBox.Show("Erreur lors du chargement des domaines référents du "
                 + day.ToShortDateString() + " : " + ex.OriginalMessage,
                 "Erreur", MessageBoxButtons.OK);
             break;
         }
     }
     statfile.Close();
 }