private object[,] SetHeaders(Query query) { object[,] headers = new object[1, query.GetDimensionsAndMetricsCount()]; int columnIndex = 0; foreach (string item in query.Dimensions.Keys) { headers[0, columnIndex] = item; columnIndex++; } foreach (string item in query.Metrics.Keys) { headers[0, columnIndex] = item; columnIndex++; } return(headers); }
public Report GetReport(Query query, string authToken, int profileCounter) { authenticationToken = authToken; NotifySubscribers(10, "Requesting report", null); Report report = new Report(); int originalStartIndex = query.StartIndex; CreateRequest(query, profileCounter); if (!RequestData(request)) { return(report); } int dimensionsAndMetrics = query.GetDimensionsAndMetricsCount(); if (xDoc != null) { NotifySubscribers(50, "Extract data", null); report.Data = ExtractDataFromXml(xDoc, dimensionsAndMetrics); report.Query = query.ToString(); report.SiteURI = query.Ids[profileCounter].Value; } report.Headers = SetHeaders(query); // Checks if paging is neccessary. while (totalHitResult > upperLimitBound && upperLimitBound > 10000) { query.StartIndex = query.StartIndex + 10000; query.MaxResults = upperLimitBound = query.MaxResults + 10000; CreateRequest(query, profileCounter); if (!RequestData(request)) { return(report); } NotifySubscribers(50, "Extract data", null); report.Data = ExtractDataFromXml(xDoc, dimensionsAndMetrics); if (upperLimitBound <= query.MaxResults) { break; } } query.StartIndex = originalStartIndex; return(report); }
public Report GetReport(Query query, string authToken, int profileCounter) { authenticationToken = authToken; NotifySubscribers(10 , "Requesting report" , null); Report report = new Report(); int originalStartIndex = query.StartIndex; CreateRequest(query, profileCounter); if (!RequestData(request)) return report; int dimensionsAndMetrics = query.GetDimensionsAndMetricsCount(); if (xDoc != null) { NotifySubscribers(50, "Extract data", null); report.Data = ExtractDataFromXml(xDoc, dimensionsAndMetrics); report.Query = query.ToString(); report.SiteURI = query.Ids[profileCounter].Value; } report.Headers = SetHeaders(query); // Checks if paging is neccessary. while (totalHitResult > upperLimitBound && upperLimitBound > 10000) { query.StartIndex = query.StartIndex + 10000; query.MaxResults = upperLimitBound = query.MaxResults + 10000; CreateRequest(query, profileCounter); if (!RequestData(request)) return report; NotifySubscribers(50, "Extract data", null); report.Data = ExtractDataFromXml(xDoc, dimensionsAndMetrics); if (upperLimitBound <= query.MaxResults) break; } query.StartIndex = originalStartIndex; return report; }
private static object[] GetQueryInformation(Query query, Report report, int profileCounter) { string timePeriod = ""; if (!query.SelectDates) { timePeriod += query.TimePeriod.ToString(); } else { timePeriod = "PeriodNotSpecified"; } object[] queryInformation = new object[] { report.SiteURI + " [ " + query.StartDate.ToShortDateString() + " -> " + query.EndDate.ToShortDateString() + " ]\n" + string.Format( "{0}queryString={1};rows={2};columns={3};timePeriod={4}]", queryInfoIdentifier, query.ToString(profileCounter), report.Hits, query.GetDimensionsAndMetricsCount(), timePeriod)}; return queryInformation; }
private object[,] SetHeaders(Query query) { object[,] headers = new object[1, query.GetDimensionsAndMetricsCount()]; int columnIndex = 0; foreach (string item in query.Dimensions.Keys) { headers[0, columnIndex] = item; columnIndex++; } foreach (string item in query.Metrics.Keys) { headers[0, columnIndex] = item; columnIndex++; } return headers; }