Exemple #1
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user, long trafficForecastSegmentId)
        {
            using (AdjustmentService adjustmentService = user.GetService <AdjustmentService>())
            {
                ForecastAdjustment forecastAdjustment = new ForecastAdjustment()
                {
                    name = "Forecast Adjustment #" + new Random().Next(int.MaxValue),
                    trafficForecastSegmentId = trafficForecastSegmentId,
                    status = ForecastAdjustmentStatus.ACTIVE,
                    // Adjust next year's New Year's Day values
                    dateRange = new DateRange()
                    {
                        startDate = new Date()
                        {
                            year  = System.DateTime.Now.Year + 1,
                            month = 1,
                            day   = 1
                        },
                        endDate = new Date()
                        {
                            year  = System.DateTime.Now.Year + 1,
                            month = 1,
                            day   = 1
                        }
                    },
                    volumeType = ForecastAdjustmentVolumeType.HISTORICAL_BASIS_VOLUME,
                    historicalBasisVolumeSettings = new HistoricalBasisVolumeSettings()
                    {
                        useParentTrafficForecastSegmentTargeting = true,
                        // Base the adjustment on this year's New Years's Day values
                        historicalDateRange = new DateRange()
                        {
                            startDate = new Date()
                            {
                                year  = System.DateTime.Now.Year,
                                month = 1,
                                day   = 1
                            },
                            endDate = new Date()
                            {
                                year  = System.DateTime.Now.Year,
                                month = 1,
                                day   = 1
                            }
                        },
                        multiplierMilliPercent = 110_000L
                    }
                };

                ForecastAdjustment[] adjustments = adjustmentService.createForecastAdjustments(
                    new ForecastAdjustment[] { forecastAdjustment });

                foreach (ForecastAdjustment createdAdjustment in adjustments)
                {
                    Console.WriteLine("Adjustment with ID {0} and name '{1}' was created.",
                                      createdAdjustment.id,
                                      createdAdjustment.name);
                }
            }
        }