Пример #1
0
        // Leave this code here, because it will need to use the SubQuery logic in its selection
        public ISelector <T> BuildSelector(IIncludeJoin[] joins, QueryStatistics stats, SelectManyQuery subQuery, IIncludeJoin[] includeJoins)
        {
            var selector = _innerSelector = SelectorParser.ChooseSelector <T>("d.data", _schema, _mapping, Model, subQuery, joins);

            if (stats != null)
            {
                selector = new StatsSelector <T>(selector);
            }

            if (joins.Any())
            {
                selector = new IncludeSelector <T>(_schema, selector, joins);
            }

            return(selector);
        }
Пример #2
0
        // Leave this code here, because it will need to use the SubQuery logic in its selection
        public ISelector <T> BuildSelector(IIncludeJoin[] joins, QueryStatistics stats, SelectManyQuery subQuery)
        {
            var selector =
                _innerSelector = SelectorParser.ChooseSelector <T>("d.data", _store.Tenancy.Default, _mapping, Model, subQuery, _store.Serializer, joins);

            if (stats != null)
            {
                selector = new StatsSelector <T>(selector);
            }

            if (joins.Any())
            {
                selector = new IncludeSelector <T>(_store.Storage, selector, joins);
            }

            return(selector);
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="campaignId">The campaign ID.</param>
        public void Run(AdWordsUser user, long campaignId)
        {
            // Get the VideoCampaignService.
            VideoCampaignService videoCampaignService = (VideoCampaignService)user.GetService(
                AdWordsService.v201402.VideoCampaignService);

            // The dates will be interpreted using the account's timezone.
            String minDateTime = DateTime.Now.Year.ToString() + "0101";
            String maxDateTime = DateTime.Now.ToString("yyyyMMdd");

            // Create selector.
            StatsSelector statsSelector = new StatsSelector();
            DateRange     dateRange     = new DateRange();

            dateRange.min = minDateTime;
            dateRange.max = maxDateTime;

            statsSelector.dateRange = dateRange;
            statsSelector.segmentationDimensions = new SegmentationDimension[] {
                SegmentationDimension.DATE_MONTH
            };
            statsSelector.metrics      = new Metric[] { Metric.VIEWS, Metric.COST, Metric.AVERAGE_CPV };
            statsSelector.summaryTypes = new VideoEntityStatsSummaryType[] {
                VideoEntityStatsSummaryType.ALL
            };
            statsSelector.segmentedSummaryType = VideoEntityStatsSummaryType.ALL;

            try {
                // Create selector.
                VideoCampaignSelector selector = new VideoCampaignSelector();
                selector.statsSelector = statsSelector;
                selector.ids           = new long[] { campaignId };

                selector.paging = new Paging();

                VideoCampaignPage page = videoCampaignService.get(selector);

                if (page != null)
                {
                    if (page.entries != null && page.entries.Length > 0)
                    {
                        VideoCampaign videoCampaign = page.entries[0];

                        Console.WriteLine("Campaign ID {0}, name '{1}' and status '{2}'", videoCampaign.id,
                                          videoCampaign.name, videoCampaign.status);
                        if (videoCampaign.stats != null)
                        {
                            Console.WriteLine("\tCampaign stats:");
                            Console.WriteLine("\t\t" + FormatStats(videoCampaign.stats));
                        }
                        if (videoCampaign.segmentedStats != null)
                        {
                            foreach (VideoEntityStats segment in videoCampaign.segmentedStats)
                            {
                                Console.WriteLine("\tCampaign segmented stats for month of " +
                                                  ((DateKey)segment.segmentKey.Item).date);
                                Console.WriteLine("\t\t" + FormatStats(segment));
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("No campaigns were found.");
                    }
                    if (page.summaryStats != null)
                    {
                        foreach (VideoEntityStats summary in page.summaryStats)
                        {
                            Console.WriteLine("\tSummary of type " + summary.summaryType);
                            Console.WriteLine("\t\t" + FormatStats(summary));
                        }
                    }
                    else
                    {
                        Console.WriteLine("No summary stats found.");
                    }
                }
                else
                {
                    Console.WriteLine("No campaigns were found.");
                }
            } catch (Exception ex) {
                throw new System.ApplicationException("Failed to get campaigns.", ex);
            }
        }