/// <summary>
        /// Downloads the campaign performance report.
        /// </summary>
        /// <param name="user">The user for which the report is run..</param>
        /// <param name="startDate">The start date in yyyyMMdd format.</param>
        /// <param name="endDate">The end date in yyyyMMdd format.</param>
        /// <returns>The campaign performance report, as a CSV file.</returns>
        private CsvFile DownloadCampaignPerformanceReport(AdWordsUser user, string startDate,
        string endDate)
        {
            string query = string.Format("Select {0} from CAMPAIGN_PERFORMANCE_REPORT DURING {1}, {2}",
              string.Join(", ", CAMPAIGN_PERFORMANCE_COLUMNS), startDate, endDate);

              AdWordsAppConfig appConfig = user.Config as AdWordsAppConfig;
              appConfig.SkipReportHeader = true;
              appConfig.SkipReportSummary = true;

              ReportUtilities reportUtilities = new ReportUtilities(user, query,
              DownloadFormat.CSV.ToString());

              using (ReportResponse response = reportUtilities.GetResponse()) {
            string reportContents = Encoding.UTF8.GetString(response.Download());
            CsvFile csvFile = new CsvFile();
            csvFile.ReadFromString(reportContents, true);
            return csvFile;
              }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load all error codes into memory.
        /// </summary>
        private static void LoadErrorCodes()
        {
            allCodes = new Dictionary<int, ErrorCode>();
              CsvFile reader = new CsvFile();
              reader.ReadFromString(CodeCsvs.ErrorCodes, true);
              List<ErrorCode> retVal = new List<ErrorCode>();

              foreach (string[] item in reader.Records) {
            allCodes.Add(int.Parse(item[0]), new ErrorCode(int.Parse(item[0]), item[1]));
              }
        }