コード例 #1
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user)
        {
            using (AdjustmentService adjustmentService = user.GetService <AdjustmentService>())
            {
                // Create a statement to select traffic forecast segments.
                int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
                StatementBuilder statementBuilder =
                    new StatementBuilder().OrderBy("id ASC").Limit(pageSize);

                // Retrieve a small amount of segments at a time, paging through until all
                // adjustments have been retrieved.
                int totalResultSetSize = 0;
                do
                {
                    TrafficForecastSegmentPage page =
                        adjustmentService.getTrafficForecastSegmentsByStatement(
                            statementBuilder.ToStatement());

                    // Print out some information for each traffic forecast segment.
                    if (page.results != null)
                    {
                        totalResultSetSize = page.totalResultSetSize;
                        int i = page.startIndex;
                        foreach (TrafficForecastSegment trafficForecastSegment in page.results)
                        {
                            Console.WriteLine("Traffic forecast segment with ID {0} and name '{1}' "
                                              + "was found.",
                                              trafficForecastSegment.id,
                                              trafficForecastSegment.name);
                        }
                    }

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

                Console.WriteLine("Number of results found: {0}", totalResultSetSize);
            }
        }