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

      // Create statement to select active placements.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("status = :status")
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .AddValue("status", InventoryStatus.ACTIVE.ToString());

      // Sets default for page.
      PlacementPage page = new PlacementPage();
      List<string> placementIds = new List<string>();

      try {
        do {
          // Get placements by statement.
          page = placementService.getPlacementsByStatement(statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (Placement placement in page.results) {
              Console.WriteLine("{0}) Placement with ID ='{1}', name ='{2}', and status ='{3}'" +
                  " will be deactivated.", i, placement.id, placement.name, placement.status);
              placementIds.Add(placement.id.ToString());
              i++;
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of placements to be deactivated: {0}", placementIds.Count);

        if (placementIds.Count > 0) {
          // Modify statement for action.
          statementBuilder.RemoveLimitAndOffset();

          // Create action.
          DeactivatePlacements action = new DeactivatePlacements();

          // Perform action.
          UpdateResult result = placementService.performPlacementAction(action,
              statementBuilder.ToStatement());

          // Display results.
          if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of placements deactivated: {0}", result.numChanges);
          } else {
            Console.WriteLine("No placements were deactivated.");
          }
        }
      } catch (Exception e) {
        Console.WriteLine("Failed to deactivate placements. Exception says \"{0}\"",
            e.Message);
      }
    }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the PlacementService.
      PlacementService placementService =
          (PlacementService) user.GetService(DfpService.v201502.PlacementService);

      // Create a statement to only select active placements.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("status = :status")
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .AddValue("status", InventoryStatus.ACTIVE.ToString());

      // Set default for page
      PlacementPage page = new PlacementPage();

      try {
        do {
          // Get placements by statement.
          page = placementService.getPlacementsByStatement(statementBuilder.ToStatement());

          // Display results.
          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (Placement placement in page.results) {
              Console.WriteLine("{0}) Placement with ID = '{1}', name ='{2}', and status = '{3}' " +
                "was found.", i, placement.id, placement.name, placement.status);
              i++;
            }
          }

          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 placement by statement. Exception says \"{0}\"",
            e.Message);
      }
    }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the PlacementService.
      PlacementService placementService =
          (PlacementService) user.GetService(DfpService.v201502.PlacementService);

      // Sets default for page.
      PlacementPage page = new PlacementPage();

      // Create a statement to get all placements.
      StatementBuilder statementBuilder = new StatementBuilder()
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

      try {
        do {
          // Get placements by statement.
          page = placementService.getPlacementsByStatement(statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (Placement placement in page.results) {
              Console.WriteLine("{0}) Placement with ID = '{1}' and name = '{2}' was found.",
                  i, placement.id, placement.name);
              i++;
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of results found: {0}" + page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get all placements. Exception says \"{0}\"",
            ex.Message);
      }
    }