/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public void Run(DfpUser dfpUser) { // [START reconciliation_guide_include_1] MOE:strip_line ReconciliationReportService reconciliationReportService = (ReconciliationReportService)dfpUser .GetService(DfpService.v201608.ReconciliationReportService); // Create a statement to select reconciliation reports. int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT; StatementBuilder statementBuilder = new StatementBuilder() .Where("startDate = :startDate") .OrderBy("id ASC") .Limit(pageSize) .AddValue("startDate", DateTimeUtilities.FromDateTime( new System.DateTime(System.DateTime.Today.Year, System.DateTime.Today.Month - 1, 1), "America/New_York").date ); // [END reconciliation_guide_include_1] MOE:strip_line // Retrieve a small amount of reconciliation reports at a time, paging through until all // reconciliation reports have been retrieved. int totalResultSetSize = 0; do { // [START reconciliation_guide_include_2] MOE:strip_line ReconciliationReportPage page = reconciliationReportService.getReconciliationReportsByStatement( statementBuilder.ToStatement()); // [END reconciliation_guide_include_2] MOE:strip_line // Print out some information for each reconciliation report. if (page.results != null) { totalResultSetSize = page.totalResultSetSize; int i = page.startIndex; foreach (ReconciliationReport reconciliationReport in page.results) { String startDateString = new System.DateTime( day: reconciliationReport.startDate.day, month: reconciliationReport.startDate.month, year: reconciliationReport.startDate.year ).ToString("d"); Console.WriteLine( "{0}) Reconciliation report with ID {1} and start date \"{2}\" was found.", i++, reconciliationReport.id, startDateString ); } } statementBuilder.IncreaseOffsetBy(pageSize); } while (statementBuilder.GetOffset() < totalResultSetSize); Console.WriteLine("Number of results found: {0}", totalResultSetSize); }
/// <summary> /// Run the code example. /// </summary> public void Run(DfpUser dfpUser) { using (ReconciliationReportService reconciliationReportService = (ReconciliationReportService)dfpUser.GetService( DfpService.v201711.ReconciliationReportService)) { // Create a statement to select reconciliation reports. int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT; StatementBuilder statementBuilder = new StatementBuilder() .OrderBy("id ASC") .Limit(pageSize); // Retrieve a small amount of reconciliation reports at a time, paging through until all // reconciliation reports have been retrieved. int totalResultSetSize = 0; do { ReconciliationReportPage page = reconciliationReportService.getReconciliationReportsByStatement( statementBuilder.ToStatement()); // Print out some information for each reconciliation report. if (page.results != null) { totalResultSetSize = page.totalResultSetSize; int i = page.startIndex; foreach (ReconciliationReport reconciliationReport in page.results) { String startDateString = new System.DateTime( day: reconciliationReport.startDate.day, month: reconciliationReport.startDate.month, year: reconciliationReport.startDate.year ).ToString("d"); Console.WriteLine( "{0}) Reconciliation report with ID {1} and start date \"{2}\" was found.", i++, reconciliationReport.id, startDateString ); } } statementBuilder.IncreaseOffsetBy(pageSize); } while (statementBuilder.GetOffset() < totalResultSetSize); Console.WriteLine("Number of results found: {0}", totalResultSetSize); } }