Exemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            label.Text = "Statistiques pour " + Program.Username + endl;
            label.Text += "Dernière mise à jour le " + Program.LastUpdate.ToShortDateString() + endl;

            var flickr = new Flickr(Program.ApiKey, Program.SharedSecret, Program.AuthToken);
            string info = "Aujourd'hui :\n";
            try
            {
                var stats = flickr.StatsGetTotalViews();
                info += "Vues totales: " + stats.TotalViews + endl +
                    "Vues photos: " + stats.PhotoViews + endl +
                    "Vues albums: " + stats.PhotosetViews + endl +
                    "Vues galerie: " + stats.PhotostreamViews + endl +
                    "Vues expos: " + stats.CollectionViews;
                // MessageBox.Show(info, "Stats", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (FlickrException ex)
            {
                // MessageBox.Show(ex.ToString(), "Erreur",
                //   MessageBoxButtons.OK, MessageBoxIcon.Error);
                info += ex.Message;
            }

            label.Text += info;
        }
Exemplo n.º 2
0
 private void ButtonStats_Click(object sender, EventArgs e)
 {
     var flickr = new Flickr(Program.ApiKey, Program.SharedSecret, Program.AuthToken);
     // Statistiques générales
     var statfile = new System.IO.StreamWriter("stats.csv");
     DateTime day = DateTime.Today;
     statfile.WriteLine("Date;Photos;Albums;Flux;Expos");
     while (day > Program.LastUpdate)
     {
         try
         {
             var s = flickr.StatsGetTotalViews(day);
             statfile.WriteLine(day.ToShortDateString() + ";" + Utility.toCSV(s));
             StatusLabel.Text = "Chargement des stats " + day.ToShortDateString();
             Application.DoEvents();
             day -= TimeSpan.FromDays(1);
         }
         catch (FlickrApiException ex) {
             MessageBox.Show("Erreur lors du chargement des statistiques du "
                 + day.ToShortDateString() + " : " + ex.OriginalMessage,
                 "Erreur", MessageBoxButtons.OK);
             break;
         }
     }
     statfile.Close();
 }