/// <summary> /// Run the code example. /// </summary> public void Run(AdManagerUser user) { using (AdjustmentService adjustmentService = user.GetService <AdjustmentService>()) { // Set the ID of the adjustment to update. long adjustmentId = long.Parse(_T("INSERT_ADJUSTMENT_ID_HERE")); // Create a statement to select adjustments. StatementBuilder statementBuilder = new StatementBuilder() .Where("id = :id") .OrderBy("id ASC") .Limit(1) .AddValue("id", adjustmentId); ForecastAdjustmentPage page = adjustmentService .getForecastAdjustmentsByStatement(statementBuilder.ToStatement()); ForecastAdjustment adjustment = page.results[0]; adjustment.name += " (updated)"; ForecastAdjustment[] adjustments = adjustmentService.updateForecastAdjustments( new ForecastAdjustment[] { adjustment }); foreach (ForecastAdjustment updatedAdjustment in adjustments) { Console.WriteLine("Forecast adjustment with ID {0} and name '{1}' was found.", updatedAdjustment.id, updatedAdjustment.name); } } }
/// <summary> /// Run the code example. /// </summary> public void Run(AdManagerUser user, long trafficForecastSegmentId) { using (AdjustmentService adjustmentService = user.GetService <AdjustmentService>()) { // Create a statement to select adjustments. int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT; StatementBuilder statementBuilder = new StatementBuilder() .Where("trafficForecastSegmentId = :trafficForecastSegmentId") .OrderBy("id ASC") .Limit(pageSize) .AddValue("trafficForecastSegmentId", trafficForecastSegmentId); // Retrieve a small amount of adjustments at a time, paging through until all // adjustments have been retrieved. int totalResultSetSize = 0; do { ForecastAdjustmentPage page = adjustmentService.getForecastAdjustmentsByStatement( statementBuilder.ToStatement()); // Print out some information for each adjustment. if (page.results != null) { totalResultSetSize = page.totalResultSetSize; int i = page.startIndex; foreach (ForecastAdjustment adjustment in page.results) { Console.WriteLine("Forecast adjustment with ID {0} and name '{1}' " + "was found.", adjustment.id, adjustment.name); } } statementBuilder.IncreaseOffsetBy(pageSize); } while (statementBuilder.GetOffset() < totalResultSetSize); Console.WriteLine("Number of results found: {0}", totalResultSetSize); } }