/// <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.v201511.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 e) {
        Console.WriteLine("Failed to get proposal line items. Exception says \"{0}\"",
            e.Message);
      }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(DfpUser user)
        {
            using (ProposalLineItemService proposalLineItemService =
                       (ProposalLineItemService)user.GetService(
                           DfpService.v201802.ProposalLineItemService))
            {
                // Set the ID of the proposal line item.
                long proposalLineItemId = long.Parse(_T("INSERT_PROPOSAL_LINE_ITEM_ID_HERE"));

                // Create a statement to get the proposal line item.
                StatementBuilder statementBuilder = new StatementBuilder()
                                                    .Where("id = :proposalLineItemId").OrderBy("id ASC").Limit(1)
                                                    .AddValue("proposalLineItemId", proposalLineItemId);

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

                    ProposalLineItem proposalLineItem = page.results[0];

                    // Update proposal line item notes.
                    proposalLineItem.internalNotes = "Proposal line item ready for submission";

                    // Update the proposal line item on the server.
                    ProposalLineItem[] proposalLineItems =
                        proposalLineItemService.updateProposalLineItems(new ProposalLineItem[]
                    {
                        proposalLineItem
                    });

                    if (proposalLineItems != null)
                    {
                        foreach (ProposalLineItem updatedProposalLineItem in proposalLineItems)
                        {
                            Console.WriteLine(
                                "A proposal line item with ID = '{0}' and name '{1}' was updated.",
                                updatedProposalLineItem.id, updatedProposalLineItem.name);
                        }
                    }
                    else
                    {
                        Console.WriteLine("No proposal line items updated.");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(
                        "Failed to update proposal line items. Exception says \"{0}\"", e.Message);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public void Run(DfpUser user, long proposalId)
        {
            ProposalLineItemService proposalLineItemService =
                (ProposalLineItemService)user.GetService(DfpService.v201608.ProposalLineItemService);

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

            // Retrieve a small amount of proposal line items at a time, paging through
            // until all proposal line items have been retrieved.
            ProposalLineItemPage page = new ProposalLineItemPage();

            try {
                do
                {
                    page = proposalLineItemService.getProposalLineItemsByStatement(
                        statementBuilder.ToStatement());

                    if (page.results != null)
                    {
                        // Print out some information for each proposal line item.
                        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 items. Exception says \"{0}\"",
                                  e.Message);
            }
        }
Ejemplo n.º 4
0
        /// <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.v201602.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);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public void Run(DfpUser dfpUser, long proposalId)
        {
            ProposalLineItemService proposalLineItemService =
                (ProposalLineItemService)dfpUser.GetService(DfpService.v201608.ProposalLineItemService);

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

            // Retrieve a small amount of proposal line items at a time, paging through until all
            // proposal line items have been retrieved.
            int totalResultSetSize = 0;

            do
            {
                ProposalLineItemPage page = proposalLineItemService.getProposalLineItemsByStatement(
                    statementBuilder.ToStatement());

                // Print out some information for each proposal line item.
                if (page.results != null)
                {
                    totalResultSetSize = page.totalResultSetSize;
                    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(pageSize);
            } while (statementBuilder.GetOffset() < totalResultSetSize);

            Console.WriteLine("Number of results found: {0}", totalResultSetSize);
        }
Ejemplo n.º 6
0
        /// <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.v201411.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 e) {
                Console.WriteLine("Failed to get proposal line items. 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.v201511.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);
      }
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(DfpUser user)
        {
            using (ProposalLineItemService proposalLineItemService =
                       (ProposalLineItemService)user.GetService(DfpService.v201802.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)
                        {
                            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.v201802.ArchiveProposalLineItems action =
                            new Google.Api.Ads.Dfp.v201802.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);
                }
            }
        }
    /// <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.v201511.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.v201511.ArchiveProposalLineItems action =
              new Google.Api.Ads.Dfp.v201511.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);
      }
    }