/// <summary> /// Run the code example. /// </summary> public void Run(DfpUser dfpUser, long masterCreativeId) { CreativeSetService creativeSetService = (CreativeSetService)dfpUser.GetService(DfpService.v201611.CreativeSetService); // Create a statement to select creative sets. int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT; StatementBuilder statementBuilder = new StatementBuilder() .Where("masterCreativeId = :masterCreativeId") .OrderBy("id ASC") .Limit(pageSize) .AddValue("masterCreativeId", masterCreativeId); // Retrieve a small amount of creative sets at a time, paging through until all // creative sets have been retrieved. int totalResultSetSize = 0; do { CreativeSetPage page = creativeSetService.getCreativeSetsByStatement( statementBuilder.ToStatement()); // Print out some information for each creative set. if (page.results != null) { totalResultSetSize = page.totalResultSetSize; int i = page.startIndex; foreach (CreativeSet creativeSet in page.results) { Console.WriteLine( "{0}) Creative set with ID {1} and name \"{2}\" was found.", i++, creativeSet.id, creativeSet.name ); } } 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 user, long masterCreativeId) { CreativeSetService creativeSetService = (CreativeSetService)user.GetService(DfpService.v201605.CreativeSetService); // Create a statement to select creative sets. StatementBuilder statementBuilder = new StatementBuilder() .Where("masterCreativeId = :masterCreativeId") .OrderBy("id ASC") .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT) .AddValue("masterCreativeId", masterCreativeId); // Retrieve a small amount of creative sets at a time, paging through // until all creative sets have been retrieved. CreativeSetPage page = new CreativeSetPage(); try { do { page = creativeSetService.getCreativeSetsByStatement(statementBuilder.ToStatement()); if (page.results != null) { // Print out some information for each creative set. int i = page.startIndex; foreach (CreativeSet creativeSet in page.results) { Console.WriteLine("{0}) Creative set with ID \"{1}\" and name \"{2}\" was found.", i++, creativeSet.id, creativeSet.name); } } statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT); } while (statementBuilder.GetOffset() < page.totalResultSetSize); Console.WriteLine("Number of results found: {0}", page.totalResultSetSize); } catch (Exception e) { Console.WriteLine("Failed to get creative sets. Exception says \"{0}\"", e.Message); } }