Google.Api.Ads.AdWords.Examples.CSharp.v201306.GetAdGroupBidSimulations.Run C# (CSharp) Méthode

Run() public méthode

Runs the specified user.
public Run ( Google.Api.Ads.AdWords.Lib.AdWordsUser user, long adGroupId ) : void
user Google.Api.Ads.AdWords.Lib.AdWordsUser The user.
adGroupId long Id of the ad group for which bid simulations are /// retrieved.
Résultat void
        public void Run(AdWordsUser user, long adGroupId)
        {
            // Get the DataService.
              DataService dataService = (DataService) user.GetService(AdWordsService.v201306.DataService);

              // Create the selector.
              Selector selector = new Selector();
              selector.fields = new string[] {"AdGroupId", "LandscapeType", "LandscapeCurrent", "StartDate",
              "EndDate", "Bid", "LocalClicks", "LocalCost", "MarginalCpc", "LocalImpressions"};

              // Set the filters.
              Predicate adGroupPredicate = new Predicate();
              adGroupPredicate.field = "AdGroupId";
              adGroupPredicate.@operator = PredicateOperator.IN;
              adGroupPredicate.values = new string[] {adGroupId.ToString()};

              selector.predicates = new Predicate[] {adGroupPredicate};

              try {
            // Get bid landscape for ad group.
            AdGroupBidLandscapePage page = dataService.getAdGroupBidLandscape(selector);
            if (page != null && page.entries != null && page.entries.Length > 0) {
              foreach (AdGroupBidLandscape bidLandscape in page.entries) {
            Console.WriteLine("Found ad group bid landscape with ad group id '{0}', type '{1}', " +
                "current: '{2}', start date '{3}', end date '{4}', and landscape points",
                bidLandscape.adGroupId, bidLandscape.type, bidLandscape.landscapeCurrent,
                bidLandscape.startDate, bidLandscape.endDate);
            foreach (BidLandscapeLandscapePoint point in bidLandscape.landscapePoints) {
              Console.WriteLine("- bid: {0} => clicks: {1}, cost: {2}, marginalCpc: {3}, " +
                  "impressions: {4}", point.bid.microAmount, point.bid.microAmount,
                  point.clicks, point.cost.microAmount, point.marginalCpc.microAmount,
                  point.impressions);
            }
              }
            } else {
              Console.WriteLine("No ad group bid landscapes were found.");
            }
              } catch (Exception ex) {
            throw new System.ApplicationException("Failed to get ad group bid landscapes.", ex);
              }
        }

Usage Example

 /// <summary>
 /// Main method, to run this code example as a standalone application.
 /// </summary>
 /// <param name="args">The command line arguments.</param>
 public static void Main(string[] args)
 {
     GetAdGroupBidSimulations codeExample = new GetAdGroupBidSimulations();
       Console.WriteLine(codeExample.Description);
       try {
     long adGroupId = long.Parse("INSERT_ADGROUP_ID_HERE");
     codeExample.Run(new AdWordsUser(), adGroupId);
       } catch (Exception ex) {
     Console.WriteLine("An exception occurred while running this code example. {0}",
     ExampleUtilities.FormatException(ex));
       }
 }
GetAdGroupBidSimulations