/// <returns>Item1 = todayVisitors, Item2 = monthVisitors</returns> private Tuple <int, int> GetAnalyticsData(string profileID, DateTime firstOfMonth) { int todayVisitors = 0; int monthVisitors = 0; var ga = new GoogleAnalytics(); ga.Init(DateTime.UtcNow, GaCertThumb, profileID); var todayAnalytics = ga.FetchByCountry(DateTime.Today, LastChanged); var monthToDateAnalytics = ga.FetchByCountry(firstOfMonth, LastChanged); if (todayAnalytics.ContainsKey("United Kingdom")) { todayVisitors = todayAnalytics["United Kingdom"].Users; } if (monthToDateAnalytics.ContainsKey("United Kingdom")) { monthVisitors = monthToDateAnalytics["United Kingdom"].Users; } return(new Tuple <int, int>(todayVisitors, monthVisitors)); }
} // ReportDateStr private void UpdateCurrentReportDate() { Log.Debug("UpdateCurrentReportDate('{0}') started...", ReportDateStr); SortedDictionary <string, CountryData> oRawByCountry = m_oApp.FetchByCountry(m_oReportDate, m_oReportDate); SortedDictionary <PageID, int> oRawByPage = m_oApp.FetchByPage(); var oStats = new SortedDictionary <string, int>(); m_oApp.ProcessByCountry(oRawByCountry, oStats); m_oApp.ProcessByPage(oRawByPage, oStats); SaveStats(oStats, "by country and by page"); SaveStats(m_oApp.FetchBySource(), "by source"); SaveStats(m_oApp.FetchByLandingPage(), "by landing page"); Log.Debug("UpdateCurrentReportDate('{0}') complete.", ReportDateStr); } // UpdateCurrentReportDate
private static void Run(GoogleAnalytics app) { Log.Debug("Program.Run started..."); var oRawByCountry = app.FetchByCountry(m_oReportDate, m_oReportDate); var oRawByPage = app.FetchByPage(); var oStats = new SortedDictionary <string, int>(); app.ProcessByCountry(oRawByCountry, oStats); app.ProcessByPage(oRawByPage, oStats); SaveStats(oStats); var sourceStats = app.FetchBySource(); SaveStats(sourceStats); var landingPageStats = app.FetchByLandingPage(); SaveStats(landingPageStats); Log.Debug("Program.Run complete."); } // Run