Example #1
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)
        {
            ProposalService proposalService =
                (ProposalService)user.GetService(DfpService.v201608.ProposalService);

            // Create a statement to select Marketplace comments.
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .Where("proposalId = :proposalId")
                                                .AddValue("proposalId", proposalId);

            // Retrieve a small amount of Marketplace comments at a time, paging through
            // until all Marketplace comments have been retrieved.
            MarketplaceCommentPage page = new MarketplaceCommentPage();

            try {
                do
                {
                    page = proposalService.getMarketplaceCommentsByStatement(statementBuilder.ToStatement());

                    if (page.results != null)
                    {
                        // Print out some information for each proposal.
                        int i = page.startIndex;
                        foreach (MarketplaceComment marketplaceComment in page.results)
                        {
                            Google.Api.Ads.Dfp.v201608.DateTime creationTime = marketplaceComment.creationTime;
                            string isoTimestamp = new System.DateTime(
                                day: creationTime.date.day,
                                month: creationTime.date.month,
                                year: creationTime.date.year,
                                hour: creationTime.hour,
                                minute: creationTime.minute,
                                second: creationTime.second
                                ).ToString("s");
                            Console.WriteLine("{0}) Marketplace comment with creation time \"{1}\" "
                                              + "and comment \"{2}\" was found.",
                                              i++,
                                              isoTimestamp,
                                              marketplaceComment.comment);
                        }
                    }

                    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 Marketplace comments. Exception says \"{0}\"",
                                  e.Message);
            }
        }
Example #2
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)
        {
            ProposalService proposalService =
                (ProposalService)dfpUser.GetService(DfpService.v201608.ProposalService);

            // Create a statement to select Marketplace comments.
            int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .Where("proposalId = :proposalId")
                                                .AddValue("proposalId", proposalId);

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

            do
            {
                MarketplaceCommentPage page = proposalService.getMarketplaceCommentsByStatement(
                    statementBuilder.ToStatement());

                // Print out some information for each Marketplace comment.
                if (page.results != null)
                {
                    totalResultSetSize = page.totalResultSetSize;
                    int i = page.startIndex;
                    foreach (MarketplaceComment marketplaceComment in page.results)
                    {
                        String creationTimeString = new System.DateTime(
                            day: marketplaceComment.creationTime.date.day,
                            month: marketplaceComment.creationTime.date.month,
                            year: marketplaceComment.creationTime.date.year,
                            hour: marketplaceComment.creationTime.hour,
                            minute: marketplaceComment.creationTime.minute,
                            second: marketplaceComment.creationTime.second
                            ).ToString("s");
                        Console.WriteLine(
                            "{0}) Marketplace comment with creation time \"{1}\" " +
                            "and comment \"{2}\" was found.",
                            i++,
                            creationTimeString,
                            marketplaceComment.comment
                            );
                    }
                }

                statementBuilder.IncreaseOffsetBy(pageSize);
            } while (statementBuilder.GetOffset() < totalResultSetSize);

            Console.WriteLine("Number of results found: {0}", totalResultSetSize);
        }
        /// <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)
        {
            ProposalService proposalService =
                (ProposalService)dfpUser.GetService(DfpService.v201702.ProposalService);

            // Create a statement to select Marketplace comments.
            int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
            StatementBuilder statementBuilder = new StatementBuilder()
                                                .Where("proposalId = :proposalId")
                                                .AddValue("proposalId", proposalId);

            MarketplaceCommentPage page = proposalService.getMarketplaceCommentsByStatement(
                statementBuilder.ToStatement());

            // Print out some information for each Marketplace comment.
            if (page.results != null)
            {
                int i = page.startIndex;
                foreach (MarketplaceComment marketplaceComment in page.results)
                {
                    String creationTimeString = new System.DateTime(
                        day: marketplaceComment.creationTime.date.day,
                        month: marketplaceComment.creationTime.date.month,
                        year: marketplaceComment.creationTime.date.year,
                        hour: marketplaceComment.creationTime.hour,
                        minute: marketplaceComment.creationTime.minute,
                        second: marketplaceComment.creationTime.second
                        ).ToString("s");
                    Console.WriteLine(
                        "{0}) Marketplace comment with creation time \"{1}\" " +
                        "and comment \"{2}\" was found.",
                        i++,
                        creationTimeString,
                        marketplaceComment.comment
                        );
                }
            }
            else
            {
                Console.WriteLine("No Marketplace comments found.");
            }
        }