} // FetchByCountry public SortedDictionary <PageID, int> FetchByPage() { Log.Debug("Fetching by page started..."); var oFetcher = new GoogleDataFetcher( m_oService, m_oReportDate, m_oReportDate, profileID, new GoogleReportDimensions[] { GoogleReportDimensions.pagePath, }, new GoogleReportMetrics[] { GoogleReportMetrics.users }, null /*GoogleDataFetcher.GAString(GoogleReportDimensions.hostname) + "==ezbob.com"*/, Log ); List <GoogleDataItem> oFetchResult = oFetcher.Fetch(); var oByPage = new SortedDictionary <PageID, int>(); foreach (GoogleDataItem oItem in oFetchResult) { string sPagePath = oItem[GoogleReportDimensions.pagePath]; PageID nPageID = GetPageID(sPagePath); if (nPageID == PageID.Other) { continue; } int nUsers = oItem[GoogleReportMetrics.users]; if (oByPage.ContainsKey(nPageID)) { oByPage[nPageID] += nUsers; } else { oByPage[nPageID] = nUsers; } } // for each item Log.Debug("By page - begin"); foreach (KeyValuePair <PageID, int> pair in oByPage) { Log.Debug("{1} to {0}", pair.Key, pair.Value); } Log.Debug("By page - end"); Log.Debug("Fetching by page complete."); return(oByPage); } // FetchByPage
} // FetchByPage public List <StatsModel> FetchBySource() { Log.Debug("Fetching by source started..."); var oFetcher = new GoogleDataFetcher( m_oService, m_oReportDate, m_oReportDate, profileID, new GoogleReportDimensions[] { GoogleReportDimensions.sourceMedium, GoogleReportDimensions.country, }, new GoogleReportMetrics[] { GoogleReportMetrics.users, GoogleReportMetrics.newUsers }, null /*GoogleDataFetcher.GAString(GoogleReportDimensions.hostname) + "==ezbob.com"*/, Log ); var model = new List <StatsModel>(); List <GoogleDataItem> oFetchResult = oFetcher.Fetch(); foreach (GoogleDataItem oItem in oFetchResult) { string country = oItem[GoogleReportDimensions.country]; if (country != GoogleDataFetcher.UK) { continue; } string source = oItem[GoogleReportDimensions.sourceMedium]; int nUsers = oItem[GoogleReportMetrics.users]; int nNewUsers = oItem[GoogleReportMetrics.newUsers]; model.Add(new StatsModel { CodeName = DbConsts.SourceUsers, Source = source, Value = nUsers }); model.Add(new StatsModel { CodeName = DbConsts.SourceNewUsers, Source = source, Value = nNewUsers }); Log.Debug("source: {0}, Users: {1}, new Users: {2}", source, nUsers, nNewUsers); } // for each item Log.Debug("Fetching by source complete."); return(model); } // FetchByPage
} // NewUsers public SortedDictionary <string, CountryData> FetchByCountry(DateTime startDate, DateTime endDate) { Log.Debug("Fetching by country started..."); var oFetcher = new GoogleDataFetcher( m_oService, startDate, endDate, profileID, new GoogleReportDimensions[] { GoogleReportDimensions.country, }, new GoogleReportMetrics[] { GoogleReportMetrics.users, GoogleReportMetrics.newUsers }, null /*GoogleDataFetcher.GAString(GoogleReportDimensions.hostname) + "==ezbob.com"*/, Log ); List <GoogleDataItem> oFetchResult = oFetcher.Fetch(); var oByCountry = new SortedDictionary <string, CountryData>(); foreach (GoogleDataItem oItem in oFetchResult) { string sCountry = oItem[GoogleReportDimensions.country]; int nUsers = oItem[GoogleReportMetrics.users]; int nNewUsers = oItem[GoogleReportMetrics.newUsers]; if (oByCountry.ContainsKey(sCountry)) { oByCountry[sCountry].Add(nUsers, nNewUsers); } else { oByCountry[sCountry] = new CountryData(nUsers, nNewUsers); } } // for each item Log.Debug("Fetched by country - begin"); foreach (KeyValuePair <string, CountryData> pair in oByCountry) { Log.Debug("{0}: {1}", pair.Key, pair.Value); } Log.Debug("Fetched by country - end"); Log.Debug("Fetching by country complete."); return(oByCountry); } // FetchByCountry
} // FetchByPage public List <StatsModel> FetchByLandingPage() { Log.Debug("Fetching by source started..."); var oFetcher = new GoogleDataFetcher( m_oService, m_oReportDate, m_oReportDate, profileID, new GoogleReportDimensions[] { GoogleReportDimensions.landingPagePath }, new GoogleReportMetrics[] { GoogleReportMetrics.users, GoogleReportMetrics.newUsers }, null, Log ); var model = new List <StatsModel>(); List <GoogleDataItem> oFetchResult = oFetcher.Fetch(); foreach (GoogleDataItem oItem in oFetchResult) { string landingPagePath = oItem[GoogleReportDimensions.landingPagePath]; int nUsers = oItem[GoogleReportMetrics.users]; int nNewUsers = oItem[GoogleReportMetrics.newUsers]; model.Add(new StatsModel { CodeName = DbConsts.LandingPageUsers, Source = landingPagePath, Value = nUsers }); model.Add(new StatsModel { CodeName = DbConsts.LandingPageNewUsers, Source = landingPagePath, Value = nNewUsers }); Log.Debug("landingPagePath: {0}, Users: {1}, new Users: {2}", landingPagePath, nUsers, nNewUsers); } // for each item Log.Debug("Fetching by source complete."); return(model); } // FetchByPage