/// <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 ProposalLineItemService.
      ProposalLineItemService proposalLineItemService =
          (ProposalLineItemService) user.GetService(DfpService.v201505.ProposalLineItemService);

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

      // Sets default for page.
      ProposalLineItemPage page = new ProposalLineItemPage();
      try {
        do {
          // Get proposal line items by statement.
          page = proposalLineItemService
              .getProposalLineItemsByStatement(statementBuilder.ToStatement());

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

          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 proposal line items. Exception says \"{0}\"",
            ex.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 ProposalLineItemService.
      ProposalLineItemService proposalLineItemService =
          (ProposalLineItemService) user.GetService(DfpService.v201505.ProposalLineItemService);

      // Set the ID of the proposal to get proposal line items from.
      long proposalId = long.Parse(_T("INSERT_PROPOSAL_ID_HERE"));

      // Create a statement to only select proposal line items from a given proposal.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("proposalId = :proposalId")
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .AddValue("proposalId", proposalId);

      // Set default for page.
      ProposalLineItemPage page = new ProposalLineItemPage();

      try {
        do {
          // Get proposal line items by statement.
          page = proposalLineItemService
              .getProposalLineItemsByStatement(statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (ProposalLineItem proposalLineItem in page.results) {
              Console.WriteLine("{0}) Proposal line item with ID ='{1}' and name '{2}' was found.",
                  i++, proposalLineItem.id, proposalLineItem.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 proposal line item 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 ProposalLineItemService.
      ProposalLineItemService proposalLineItemService =
          (ProposalLineItemService) user.GetService(DfpService.v201505.ProposalLineItemService);

      // Set the ID of the proposal line item to archive.
      long proposalLineItemId = long.Parse(_T("INSERT_PROPOSAL_LINE_ITEM_ID_HERE"));

      // Create statement to select a proposal line item by ID.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("id = :id")
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .AddValue("id", proposalLineItemId);

      // Set default for page.
      ProposalLineItemPage page = new ProposalLineItemPage();
      List<string> proposalLineItemIds = new List<string>();

      try {
        do {
          // Get proposal line items by statement.
          page = proposalLineItemService.getProposalLineItemsByStatement(
              statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (ProposalLineItem proposalLineItem in page.results) {
              Console.WriteLine("{0}) Proposal line item with ID ='{1}' will be archived.",
                  i++, proposalLineItem.id);
              proposalLineItemIds.Add(proposalLineItem.id.ToString());
            }
          }

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

        Console.WriteLine("Number of proposal line items to be archived: {0}",
            proposalLineItemIds.Count);

        if (proposalLineItemIds.Count > 0) {
          // Modify statement.
          statementBuilder.RemoveLimitAndOffset();

          // Create action.
          Google.Api.Ads.Dfp.v201505.ArchiveProposalLineItems action =
              new Google.Api.Ads.Dfp.v201505.ArchiveProposalLineItems();

          // Perform action.
          UpdateResult result = proposalLineItemService.performProposalLineItemAction(action,
              statementBuilder.ToStatement());

          // Display results.
          if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of proposal line items archived: {0}", result.numChanges);
          } else {
            Console.WriteLine("No proposal line items were archived.");
          }
        }
      } catch (Exception e) {
        Console.WriteLine("Failed to archive proposal line items. Exception says \"{0}\"",
            e.Message);
      }
    }