/// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            ReportService reportService = (ReportService) user.GetService(
              DfpService.v201302.ReportService);

              // Set the id of the completed report.
              long reportJobId = long.Parse(_T("INSERT_REPORT_JOB_ID_HERE"));
              ExportFormat exportFormat = (ExportFormat) Enum.Parse(typeof(ExportFormat),
              _T("INSERT_EXPORT_FORMAT_HERE"));

              // Set the format of the report (e.g., CSV_DUMP) and download without
              // compression so we can print it.
              ReportDownloadOptions reportDownloadOptions = new ReportDownloadOptions();
              reportDownloadOptions.exportFormat = exportFormat;
              reportDownloadOptions.useGzipCompression = false;

              try {
            // Download report data.
            string downloadUrl = reportService.getReportDownloadUrlWithOptions(reportJobId,
            reportDownloadOptions);
            byte[] rawReport = MediaUtilities.GetAssetDataFromUrl(downloadUrl);
            string reportContents = Encoding.UTF8.GetString(rawReport);

            // Display results.
            Console.WriteLine("Data for report job with id '{0}\':\n{1}", reportJobId, reportContents);
              } catch (Exception ex) {
            Console.WriteLine("Failed to download report. Exception says \"{0}\"", ex.Message);
              }
        }
Exemplo n.º 2
0
 public string getReportDownloadUrlWithOptions(long reportJobId, ReportDownloadOptions reportDownloadOptions)
 {
     object[] results = this.Invoke("getReportDownloadUrlWithOptions", new object[] { reportJobId, reportDownloadOptions });
       return ((string) (results[0]));
 }