/// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Retreiving the raw values of enum-type fields instead of display values
            (user.Config as AdWordsAppConfig).UseRawEnumValues = true;

            // Create the query.
            String query = "SELECT Id, AdNetworkType1, Impressions FROM CRITERIA_PERFORMANCE_REPORT " +
                           "WHERE Status IN [ENABLED, PAUSED] DURING LAST_7_DAYS";

            ReportUtilities reportUtilities = new ReportUtilities(user, "v201609", query,
                                                                  DownloadFormat.GZIPPED_XML.ToString());

            try {
                using (ReportResponse response = reportUtilities.GetResponse()) {
                    using (GZipStream gzipStream =
                               new GZipStream(response.Stream,
                                              CompressionMode.Decompress)) {
                        // Create the report object using the stream.
                        using (var report = new AwReport <CriteriaReportRow>(
                                   new AwXmlTextReader(gzipStream), "Example")) {
                            // Print the contents of each row object.
                            foreach (var record in report.Rows)
                            {
                                Console.WriteLine(record);
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                throw new System.ApplicationException("Failed to download and parse report.", e);
            }
        }
Example #2
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Retreiving the raw values of enum-type fields instead of display values
            (user.Config as AdWordsAppConfig).UseRawEnumValues = true;

            // Create the query.
            String query = "SELECT AccountCurrencyCode, AccountDescriptiveName FROM FINAL_URL_REPORT " +
                           "DURING LAST_7_DAYS";

            ReportUtilities reportUtilities = new ReportUtilities(user, "v201710", query,
                                                                  DownloadFormat.GZIPPED_XML.ToString());

            try {
                using (ReportResponse response = reportUtilities.GetResponse()) {
                    using (GZipStream gzipStream =
                               new GZipStream(response.Stream,
                                              CompressionMode.Decompress)) {
                        // Create the report object using the stream.
                        using (var report = new AwReport <FinalUrlReportReportRow>(
                                   new AwXmlTextReader(gzipStream), "Example")) {
                            // Print the contents of each row object.
                            while (report.MoveNext())
                            {
                                Console.WriteLine(report.Current.accountCurrencyCode
                                                  + " " + report.Current.accountDescriptiveName);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                throw new System.ApplicationException("Failed to download and parse report.", e);
            }
        }
 public void getFaultyRowsTest()
 {
     TestUtils.testActionWithXmlTextReader(reader => {
         var report = new AwReport <TestRow>(reader, "test");
         report.GetRows();
     }, faultyTestXml);
 }
Example #4
0
 public void getFaultyRowsTest()
 {
     Assert.Throws <AdWordsReportsException>(() => TestUtils.testActionWithXmlTextReader(
                                                 reader =>
     {
         var report = new AwReport <TestRow>(reader, "test");
         report.GetRows();
     }, faultyTestXml));
 }
Example #5
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Create the query.
            ReportQuery query = new ReportQueryBuilder()
                                .Select("Id", "AdNetworkType1", "Impressions")
                                .From(ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT)
                                .Where("Status").In("ENABLED", "PAUSED")
                                .During(ReportDefinitionDateRangeType.LAST_7_DAYS)
                                .Build();

            ReportUtilities reportUtilities = new ReportUtilities(user, "v201809", query,
                                                                  DownloadFormat.GZIPPED_XML.ToString());

            try
            {
                using (ReportResponse response = reportUtilities.GetResponse())
                {
                    using (GZipStream gzipStream =
                               new GZipStream(response.Stream, CompressionMode.Decompress))
                    {
                        // Deserialize the report into a list of CriteriaReportRow.
                        // You can also deserialize the list into your own POCOs as follows.
                        // 1. Annotate your class properties with ReportRow annotation.
                        //
                        //  public class MyCriteriaReportRow {
                        //
                        //    [ReportColumn]
                        //    public long KeywordID { get; set; }
                        //
                        //    [ReportColumn]
                        //    public long Impressions { get; set; }
                        //  }
                        //
                        // 2. Deserialize into your own report rows.
                        //
                        // var report = new AwReport<MyCriteriaReportRow>(
                        //                new AwXmlTextReader(gzipStream), "Example");
                        using (var report =
                                   new AwReport <CriteriaReportRow>(new AwXmlTextReader(gzipStream),
                                                                    "Example"))
                        {
                            // Print the contents of each row object.
                            foreach (var record in report.Rows)
                            {
                                Console.WriteLine(record);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new System.ApplicationException("Failed to download and parse report.", e);
            }
        }
Example #6
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Create the query.
            string query =
                "SELECT Id, AdNetworkType1, Impressions FROM CRITERIA_PERFORMANCE_REPORT " +
                "WHERE Status IN [ENABLED, PAUSED] DURING LAST_7_DAYS";

            ReportUtilities reportUtilities = new ReportUtilities(user, "v201806", query,
                                                                  DownloadFormat.GZIPPED_XML.ToString());

            try
            {
                using (ReportResponse response = reportUtilities.GetResponse())
                {
                    using (GZipStream gzipStream =
                               new GZipStream(response.Stream, CompressionMode.Decompress))
                    {
                        // Deserialize the report into a list of CriteriaReportRow.
                        // You can also deserialize the list into your own POCOs as follows.
                        // 1. Annotate your class properties with ReportRow annotation.
                        //
                        //  public class MyCriteriaReportRow {
                        //
                        //    [ReportColumn]
                        //    public long KeywordID { get; set; }
                        //
                        //    [ReportColumn]
                        //    public long Impressions { get; set; }
                        //  }
                        //
                        // 2. Deserialize into your own report rows.
                        //
                        // var report = new AwReport<MyCriteriaReportRow>(
                        //                new AwXmlTextReader(gzipStream), "Example");
                        using (var report =
                                   new AwReport <CriteriaReportRow>(new AwXmlTextReader(gzipStream),
                                                                    "Example"))
                        {
                            // Print the contents of each row object.
                            foreach (var record in report.Rows)
                            {
                                Console.WriteLine(record);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new System.ApplicationException("Failed to download and parse report.", e);
            }
        }