• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# v201506.Selector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Google.Api.Ads.AdWords.v201506.Selector的典型用法代码示例。如果您正苦于以下问题:C# Selector类的具体用法?C# Selector怎么用?C# Selector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Selector类属于Google.Api.Ads.AdWords.v201506命名空间,在下文中一共展示了Selector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Run

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    public void Run(AdWordsUser user) {
      // Get the ManagedCustomerService.
      ManagedCustomerService managedCustomerService = (ManagedCustomerService) user.GetService(
          AdWordsService.v201506.ManagedCustomerService);

      // Create selector.
      Selector selector = new Selector();
      selector.fields = new String[] {
        ManagedCustomer.Fields.CustomerId, ManagedCustomer.Fields.Name
      };

      try {
        // Get results.
        ManagedCustomerPage page = managedCustomerService.get(selector);

        // Display serviced account graph.
        if (page.entries != null) {
          // Create map from customerId to customer node.
          Dictionary<long, ManagedCustomerTreeNode> customerIdToCustomerNode =
              new Dictionary<long, ManagedCustomerTreeNode>();

          // Create account tree nodes for each customer.
          foreach (ManagedCustomer customer in page.entries) {
            ManagedCustomerTreeNode node = new ManagedCustomerTreeNode();
            node.Account = customer;
            customerIdToCustomerNode.Add(customer.customerId, node);
          }

          // For each link, connect nodes in tree.
          if (page.links != null) {
            foreach (ManagedCustomerLink link in page.links) {
              ManagedCustomerTreeNode managerNode =
                  customerIdToCustomerNode[link.managerCustomerId];
              ManagedCustomerTreeNode childNode = customerIdToCustomerNode[link.clientCustomerId];
              childNode.ParentNode = managerNode;
              if (managerNode != null) {
                managerNode.ChildAccounts.Add(childNode);
              }
            }
          }

          // Find the root account node in the tree.
          ManagedCustomerTreeNode rootNode = null;
          foreach (ManagedCustomer account in page.entries) {
            if (customerIdToCustomerNode[account.customerId].ParentNode == null) {
              rootNode = customerIdToCustomerNode[account.customerId];
              break;
            }
          }

          // Display account tree.
          Console.WriteLine("CustomerId, Name");
          Console.WriteLine(rootNode.ToTreeString(0, new StringBuilder()));
        } else {
          Console.WriteLine("No serviced accounts were found.");
        }
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to create ad groups.", e);
      }
    }
开发者ID:markgmarkg,项目名称:googleads-dotnet-lib,代码行数:64,代码来源:GetAccountHierarchy.cs


示例2: Main

    /// <summary>
    /// The main method.
    /// </summary>
    /// <param name="args">Command line arguments.</param>
    static void Main(string[] args) {
      AdWordsUser user = new AdWordsUser();

      // This code example shows how to run an AdWords API web application
      // while incorporating the OAuth2 installed application flow into your
      // application. If your application uses a single MCC login to make calls
      // to all your accounts, you shouldn't use this code example. Instead, you
      // should run OAuthTokenGenerator.exe to generate a refresh
      // token and use that configuration in your application's App.config.
      AdWordsAppConfig config = user.Config as AdWordsAppConfig;
      if (user.Config.OAuth2Mode == OAuth2Flow.APPLICATION &&
            string.IsNullOrEmpty(config.OAuth2RefreshToken)) {
         DoAuth2Authorization(user);
      }

      Console.Write("Enter the customer id: ");
      string customerId = Console.ReadLine();
      config.ClientCustomerId = customerId;

      // Get the CampaignService.
      CampaignService campaignService =
          (CampaignService) user.GetService(AdWordsService.v201506.CampaignService);

      // Create the selector.
      Selector selector = new Selector();
      selector.fields = new string[] {"Id", "Name", "Status"};

      // Set the selector paging.
      selector.paging = new Paging();

      int offset = 0;
      int pageSize = 500;

      CampaignPage page = new CampaignPage();

      try {
        do {
          selector.paging.startIndex = offset;
          selector.paging.numberResults = pageSize;

          // Get the campaigns.
          page = campaignService.get(selector);

          // Display the results.
          if (page != null && page.entries != null) {
            int i = offset;
            foreach (Campaign campaign in page.entries) {
              Console.WriteLine("{0}) Campaign with id = '{1}', name = '{2}' and status = '{3}'" +
                " was found.", i + 1, campaign.id, campaign.name, campaign.status);
              i++;
            }
          }
          offset += pageSize;
        } while (offset < page.totalNumEntries);
        Console.WriteLine("Number of campaigns found: {0}", page.totalNumEntries);
      } catch (Exception ex) {
        throw new System.ApplicationException("Failed to retrieve campaigns", ex);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:63,代码来源:ConsoleExample.cs


示例3: Run

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    public void Run(AdWordsUser user) {
      // Get the MediaService.
      MediaService mediaService = (MediaService) user.GetService(
          AdWordsService.v201506.MediaService);

      // Create a selector.
      Selector selector = new Selector();
      selector.fields = new string[] {"MediaId", "Width", "Height", "MimeType"};

      // Set the filter.
      Predicate predicate = new Predicate();
      [email protected] = PredicateOperator.IN;
      predicate.field = "Type";
      predicate.values = new string[] {MediaMediaType.VIDEO.ToString(),
          MediaMediaType.IMAGE.ToString()};

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

      // Set selector paging.
      selector.paging = new Paging();

      int offset = 0;
      int pageSize = 500;

      MediaPage page = new MediaPage();

      try {
        do {
          selector.paging.startIndex = offset;
          selector.paging.numberResults = pageSize;

          page = mediaService.get(selector);

          if (page != null && page.entries != null) {
            int i = offset;

            foreach (Media media in page.entries) {
              if (media is Video) {
                Video video = (Video) media;
                Console.WriteLine("{0}) Video with id \"{1}\" and name \"{2}\" was found.",
                    i, video.mediaId, video.name);
              } else if (media is Image) {
                Image image = (Image) media;
                Dictionary<MediaSize, Dimensions> dimensions =
                    CreateMediaDimensionMap(image.dimensions);
                Console.WriteLine("{0}) Image with id '{1}', dimensions '{2}x{3}', and MIME type " +
                    "'{4}' was found.", i, image.mediaId, dimensions[MediaSize.FULL].width,
                    dimensions[MediaSize.FULL].height, image.mimeType);
              }
              i++;
            }
          }
          offset += pageSize;
        } while (offset < page.totalNumEntries);
        Console.WriteLine("Number of images and videos found: {0}", page.totalNumEntries);
      } catch (Exception ex) {
        throw new System.ApplicationException("Failed to get images and videos.", ex);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:63,代码来源:GetAllVideosAndImages.cs


示例4: Run

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="campaignId">Id of the campaign for which disapproved ads
        /// are retrieved.</param>
        public void Run(AdWordsUser user, long campaignId)
        {
            // Get the AdGroupAdService.
              AdGroupAdService service =
              (AdGroupAdService) user.GetService(AdWordsService.v201506.AdGroupAdService);

              // Create the selector.
              Selector selector = new Selector();
              selector.fields = new string[] {"Id", "AdGroupCreativeApprovalStatus",
              "AdGroupAdDisapprovalReasons"};

              // Create the filter.
              Predicate campaignPredicate = new Predicate();
              [email protected] = PredicateOperator.EQUALS;
              campaignPredicate.field = "CampaignId";
              campaignPredicate.values = new string[] {campaignId.ToString()};

              Predicate approvalPredicate = new Predicate();
              [email protected] = PredicateOperator.EQUALS;
              approvalPredicate.field = "AdGroupCreativeApprovalStatus";
              approvalPredicate.values = new string[] {AdGroupAdApprovalStatus.DISAPPROVED.ToString()};

              selector.predicates = new Predicate[] {campaignPredicate, approvalPredicate};

              // Set the selector paging.
              selector.paging = new Paging();

              int offset = 0;
              int pageSize = 500;

              AdGroupAdPage page = new AdGroupAdPage();

              try {
            do {
              selector.paging.startIndex = offset;
              selector.paging.numberResults = pageSize;

              // Get the disapproved ads.
              page = service.get(selector);

              // Display the results.
              if (page != null && page.entries != null) {
            int i = offset;
            foreach (AdGroupAd adGroupAd in page.entries) {
              Console.WriteLine("{0}) Ad id {1} has been disapproved for the following " +
                  "reason(s):", i, adGroupAd.ad.id);
              foreach (string reason in adGroupAd.disapprovalReasons) {
                Console.WriteLine("    {0}", reason);
              }
              i++;
            }
              }
              offset += pageSize;
            } while (offset < page.totalNumEntries);
            Console.WriteLine("Number of disapproved ads found: {0}", page.totalNumEntries);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to get disapproved ads.", e);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:65,代码来源:GetAllDisapprovedAds.cs


示例5: Run

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    public void Run(AdWordsUser user) {
      // Get the AdGroupCriterionService.
      AdGroupCriterionService adGroupCriterionService =
          (AdGroupCriterionService) user.GetService(
              AdWordsService.v201506.AdGroupCriterionService);

      // Create a selector.
      Selector selector = new Selector() {
        fields = new string[] {
          Criterion.Fields.Id, AdGroupCriterion.Fields.AdGroupId, Placement.Fields.PlacementUrl
        },
        predicates = new Predicate[] {
          // Select only placements.
          Predicate.Equals(Criterion.Fields.CriteriaType, "PLACEMENT")
        },
        paging = Paging.Default
      };

      AdGroupCriterionPage page = new AdGroupCriterionPage();

      try {
        do {
          // Get the keywords.
          page = adGroupCriterionService.get(selector);

          // Display the results.
          if (page != null && page.entries != null) {
            int i = selector.paging.startIndex;

            foreach (AdGroupCriterion adGroupCriterion in page.entries) {
              bool isNegative = (adGroupCriterion is NegativeAdGroupCriterion);

              // If you are retrieving multiple type of criteria, then you may
              // need to check for
              //
              // if (adGroupCriterion is Placement) { ... }
              //
              // to identify the criterion type.
              Placement placement = (Placement) adGroupCriterion.criterion;
              if (isNegative) {
                Console.WriteLine("{0}) Negative placement with ad group ID = '{1}', placement " +
                    "ID = '{2}', and url = '{3}' was found.", i + 1, adGroupCriterion.adGroupId,
                    placement.id, placement.url);
              } else {
                Console.WriteLine("{0}) Placement with ad group ID = '{1}', placement ID = " +
                    "'{2}' and url = '{3}' was found.", i + 1, adGroupCriterion.adGroupId,
                    placement.id, placement.url);
              }
              i++;
            }
          }
          selector.paging.IncreaseOffset();
        } while (selector.paging.startIndex < page.totalNumEntries);
        Console.WriteLine("Number of placements found: {0}", page.totalNumEntries);
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to retrieve placements.", e);
      }
    }
开发者ID:markgmarkg,项目名称:googleads-dotnet-lib,代码行数:62,代码来源:GetPlacements.cs


示例6: Run

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="labelName">ID of the label.</param>
        public void Run(AdWordsUser user, long labelId)
        {
            // Get the CampaignService.
              CampaignService campaignService =
              (CampaignService) user.GetService(AdWordsService.v201506.CampaignService);

              // Create the selector.
              Selector selector = new Selector();
              selector.fields = new string[] { "Id", "Name", "Labels" };

              // Labels filtering is performed by ID. You can use CONTAINS_ANY to
              // select campaigns with any of the label IDs, CONTAINS_ALL to select
              // campaigns with all of the label IDs, or CONTAINS_NONE to select
              // campaigns with none of the label IDs.
              Predicate predicate = new Predicate();
              [email protected] = PredicateOperator.CONTAINS_ANY;
              predicate.field = "Labels";
              predicate.values = new string[] { labelId.ToString() };
              selector.predicates = new Predicate[] { predicate };

              // Set the selector paging.
              selector.paging = new Paging();

              int offset = 0;
              int pageSize = 500;

              CampaignPage page = new CampaignPage();

              try {
            do {
              selector.paging.startIndex = offset;
              selector.paging.numberResults = pageSize;

              // Get the campaigns.
              page = campaignService.get(selector);

              // Display the results.
              if (page != null && page.entries != null) {
            int i = offset;
            foreach (Campaign campaign in page.entries) {
              List<string> labelNames = new List<string>();
              foreach (Label label in campaign.labels) {
                labelNames.Add(label.name);
              }

              Console.WriteLine("{0}) Campaign with id = '{1}', name = '{2}' and labels = '{3}'" +
                  " was found.", i + 1, campaign.id, campaign.name,
                  string.Join(", ", labelNames.ToArray()));
              i++;
            }
              }
              offset += pageSize;
            } while (offset < page.totalNumEntries);
            Console.WriteLine("Number of campaigns found: {0}", page.totalNumEntries);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to retrieve campaigns by label", e);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:63,代码来源:GetCampaignsByLabel.cs


示例7: Run

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="campaignId">Id of the campaign from which targeting
        /// criteria are retrieved.</param>
        public void Run(AdWordsUser user, long campaignId)
        {
            // Get the CampaignCriterionService.
              CampaignCriterionService campaignCriterionService =
              (CampaignCriterionService) user.GetService(
              AdWordsService.v201506.CampaignCriterionService);

              // Create the selector.
              Selector selector = new Selector();
              selector.fields = new string[] {"Id", "CriteriaType", "PlacementUrl"};

              // Set the filters.
              Predicate campaignPredicate = new Predicate();
              campaignPredicate.field = "CampaignId";
              [email protected] = PredicateOperator.EQUALS;
              campaignPredicate.values = new string[] {campaignId.ToString()};

              Predicate placementPredicate = new Predicate();
              placementPredicate.field = "CriteriaType";
              [email protected] = PredicateOperator.EQUALS;
              placementPredicate.values = new string[] {"PLACEMENT"};

              selector.predicates = new Predicate[] {campaignPredicate, placementPredicate};

              // Set the selector paging.
              selector.paging = new Paging();

              int offset = 0;
              int pageSize = 500;

              CampaignCriterionPage page = new CampaignCriterionPage();

              try {
            do {
              selector.paging.startIndex = offset;
              selector.paging.numberResults = pageSize;

              // Get all campaign targets.
              page = campaignCriterionService.get(selector);

              // Display the results.
              if (page != null && page.entries != null) {
            int i = offset;
            foreach (CampaignCriterion campaignCriterion in page.entries) {
              Placement placement = campaignCriterion.criterion as Placement;

              Console.WriteLine("{0}) Placement with ID {1} and url {2} was found.", i,
                  placement.id, placement.url);
              i++;
            }
              }
              offset += pageSize;
            } while (offset < page.totalNumEntries);
            Console.WriteLine("Number of placements found: {0}", page.totalNumEntries);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to get campaign targeting criteria.", e);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:64,代码来源:GetCampaignTargetingCriteria.cs


示例8: Run

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="adGroupId">Id of the ad group for which keyword bid
    /// simulations are retrieved.</param>
    /// <param name="keywordId">Id of the keyword for which bid simulations are
    /// retrieved.</param>
    public void Run(AdWordsUser user, long adGroupId, long keywordId) {
      // Get the DataService.
      DataService dataService = (DataService) user.GetService(AdWordsService.v201506.DataService);

      // Create the selector.
      Selector selector = new Selector() {
        fields = new string[] {
          CriterionBidLandscape.Fields.AdGroupId, CriterionBidLandscape.Fields.CriterionId,
          CriterionBidLandscape.Fields.StartDate, CriterionBidLandscape.Fields.EndDate, 
          BidLandscapeLandscapePoint.Fields.Bid, BidLandscapeLandscapePoint.Fields.LocalClicks,
          BidLandscapeLandscapePoint.Fields.LocalCost,
          BidLandscapeLandscapePoint.Fields.LocalImpressions
        },
        predicates = new Predicate[] {
          Predicate.Equals(CriterionBidLandscape.Fields.AdGroupId, adGroupId),
          Predicate.Equals(CriterionBidLandscape.Fields.CriterionId, keywordId)
        },
        paging = Paging.Default
      };

      CriterionBidLandscapePage page = new CriterionBidLandscapePage();
      int bidLandscapeCount = 0;
      int landscapePointsInLastResponse = 0;

      try {
        do {
          // Get bid landscape for keywords.
          page = dataService.getCriterionBidLandscape(selector);
          landscapePointsInLastResponse = 0;

          // Display bid landscapes.
          if (page != null && page.entries != null) {
            foreach (CriterionBidLandscape bidLandscape in page.entries) {
              Console.WriteLine("{0}) Found criterion bid landscape with ad group id '{1}', " +
                  "keyword id '{2}', start date '{3}', end date '{4}', and landscape points:",
                  bidLandscapeCount + 1, bidLandscape.adGroupId, bidLandscape.criterionId,
                  bidLandscape.startDate, bidLandscape.endDate);
              foreach (BidLandscapeLandscapePoint bidLandscapePoint in
                  bidLandscape.landscapePoints) {
                Console.WriteLine("- bid: {0} => clicks: {1}, cost: {2}, impressions: {3}\n",
                    bidLandscapePoint.bid.microAmount, bidLandscapePoint.clicks,
                    bidLandscapePoint.cost.microAmount, bidLandscapePoint.impressions);
                landscapePointsInLastResponse++;
              }
              bidLandscapeCount++;
            }
          }
          // Offset by the number of landscape points, NOT the number
          // of entries (bid landscapes) in the last response.
          selector.paging.IncreaseOffsetBy(landscapePointsInLastResponse);
        } while (landscapePointsInLastResponse > 0 &&
            landscapePointsInLastResponse < selector.paging.numberResults);
        Console.WriteLine("Number of keyword bid landscapes found: {0}", bidLandscapeCount);
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to retrieve keyword bid landscapes.", e);
      }
    }
开发者ID:madhvanimitesh,项目名称:googleads-dotnet-lib,代码行数:65,代码来源:GetKeywordBidSimulations.cs


示例9: Main

    /// <summary>
    /// The main method.
    /// </summary>
    /// <param name="args">Command line arguments.</param>
    static void Main(string[] args) {
      AdWordsUser user = new AdWordsUser();

      // This code example shows how to run an AdWords API web application
      // while incorporating the OAuth2 installed application flow into your
      // application. If your application uses a single AdWords manager account
      // login to make calls to all your accounts, you shouldn't use this code
      // example. Instead, you should run OAuthTokenGenerator.exe to generate a
      // refresh token and use that configuration in your application's
      // App.config.
      AdWordsAppConfig config = user.Config as AdWordsAppConfig;
      if (user.Config.OAuth2Mode == OAuth2Flow.APPLICATION &&
            string.IsNullOrEmpty(config.OAuth2RefreshToken)) {
         DoAuth2Authorization(user);
      }

      Console.Write("Enter the customer id: ");
      string customerId = Console.ReadLine();
      config.ClientCustomerId = customerId;

      // Get the CampaignService.
      CampaignService campaignService =
          (CampaignService) user.GetService(AdWordsService.v201506.CampaignService);

      Selector selector = new Selector() {
        fields = new string[] { Campaign.Fields.Id, Campaign.Fields.Name, Campaign.Fields.Status },
        ordering = new OrderBy[] { OrderBy.Asc(Campaign.Fields.Name) },
        paging = Paging.Default
      };

      // Set the selector paging.
      selector.paging = new Paging();

      CampaignPage page = new CampaignPage();

      try {
        do {
          // Get the campaigns.
          page = campaignService.get(selector);

          // Display the results.
          if (page != null && page.entries != null) {
            int i = selector.paging.startIndex;
            foreach (Campaign campaign in page.entries) {
              Console.WriteLine("{0}) Campaign with id = '{1}', name = '{2}' and status = '{3}'" +
                " was found.", i + 1, campaign.id, campaign.name, campaign.status);
              i++;
            }
          }
          selector.paging.IncreaseOffset();
        } while (selector.paging.startIndex < page.totalNumEntries);
        Console.WriteLine("Number of campaigns found: {0}", page.totalNumEntries);
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to retrieve campaigns", e);
      }
    }
开发者ID:markgmarkg,项目名称:googleads-dotnet-lib,代码行数:60,代码来源:ConsoleExample.cs


示例10: Run

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="adGroupId">Id of the ad group to which ads are added.
    /// </param>
    public void Run(AdWordsUser user, long campaignId) {
      // Get the AdGroupAdService.
      AdGroupBidModifierService adGroupBidModifierService =
          (AdGroupBidModifierService) user.GetService(
              AdWordsService.v201506.AdGroupBidModifierService);

      const int PAGE_SIZE = 500;

      // Get all ad group bid modifiers for the campaign.
      Selector selector = new Selector();
      selector.fields = new String[] {"CampaignId", "AdGroupId", "BidModifier", "BidModifierSource",
        "CriteriaType", "Id"};

      Predicate predicate = new Predicate();
      predicate.field = "CampaignId";
      [email protected] = PredicateOperator.EQUALS;
      predicate.values = new string[] {campaignId.ToString()};
      selector.predicates = new Predicate[] {predicate};

      // Set the selector paging.
      selector.paging = new Paging();

      int offset = 0;
      int pageSize = PAGE_SIZE;

      AdGroupBidModifierPage page = new AdGroupBidModifierPage();

      try {
        do {
          selector.paging.startIndex = offset;
          selector.paging.numberResults = pageSize;

          // Get the campaigns.
          page = adGroupBidModifierService.get(selector);

          // Display the results.
          if (page != null && page.entries != null) {
            int i = offset;
            foreach (AdGroupBidModifier adGroupBidModifier in page.entries) {
              string bidModifier = (adGroupBidModifier.bidModifierSpecified)?
                  adGroupBidModifier.bidModifier.ToString() : "UNSET";
              Console.WriteLine("{0}) Campaign ID {1}, AdGroup ID {2}, Criterion ID {3} has " +
                  "ad group level modifier: {4} and source = {5}.",
                  i + 1, adGroupBidModifier.campaignId,
                  adGroupBidModifier.adGroupId, adGroupBidModifier.criterion.id, bidModifier,
                  adGroupBidModifier.bidModifierSource);
              i++;
            }
          }
          offset += pageSize;
        } while (offset < page.totalNumEntries);
        Console.WriteLine("Number of adgroup bid modifiers found: {0}", page.totalNumEntries);
      } catch (Exception ex) {
        throw new System.ApplicationException("Failed to retrieve adgroup bid modifiers.", ex);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:62,代码来源:GetAdGroupBidModifiers.cs


示例11: Run

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Get the ConstantDataService.
              ConstantDataService constantDataService = (ConstantDataService) user.GetService(
              AdWordsService.v201506.ConstantDataService);

              Selector selector = new Selector();
              Predicate predicate = new Predicate();
              predicate.field = "Country";
              [email protected] = PredicateOperator.IN;
              predicate.values = new string[] { "US" };

              try {
            ProductBiddingCategoryData[] results =
            constantDataService.getProductBiddingCategoryData(selector);

            Dictionary<long, ProductCategory> biddingCategories =
            new Dictionary<long, ProductCategory>();
            List<ProductCategory> rootCategories = new List<ProductCategory>();

            foreach (ProductBiddingCategoryData productBiddingCategory in results) {
              long id = productBiddingCategory.dimensionValue.value;
              long parentId = 0;
              string name = productBiddingCategory.displayValue[0].value;

              if (productBiddingCategory.parentDimensionValue != null) {
            parentId = productBiddingCategory.parentDimensionValue.value;
              }

              if (biddingCategories.ContainsKey(id)) {
            biddingCategories.Add(id, new ProductCategory());
              }

              ProductCategory category = biddingCategories[id];

              if (parentId != 0) {
            if (biddingCategories.ContainsKey(parentId)) {
              biddingCategories.Add(parentId, new ProductCategory());
            }
            ProductCategory parent = biddingCategories[parentId];
            parent.Children.Add(category);
              } else {
            rootCategories.Add(category);
              }

              category.Id = id;
              category.Name = name;
            }

            DisplayProductCategories(rootCategories, "");
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to set shopping product category.", e);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:58,代码来源:GetProductCategoryTaxonomy.cs


示例12: Run

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Get the ExpressBusinessService.
              ExpressBusinessService businessService = (ExpressBusinessService)
              user.GetService(AdWordsService.v201506.ExpressBusinessService);

              Selector selector = new Selector();
              selector.fields = new String[] { "Id", "Name", "Website", "Address", "GeoPoint", "Status" };

              // To get all express businesses owned by the current customer,
              // simply skip the call to selector.setPredicates below.
              Predicate predicate = new Predicate();
              predicate.field = "Status";
              [email protected] = PredicateOperator.EQUALS;
              predicate.values = new string[] { "ACTIVE" };

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

              // Set the selector paging.
              selector.paging = new Paging();

              int offset = 0;
              int pageSize = 500;

              ExpressBusinessPage page = null;
              try {
            do {
              selector.paging.startIndex = offset;
              selector.paging.numberResults = pageSize;

              // Get all businesses.
              page = businessService.get(selector);

              // Display the results.
              if (page != null && page.entries != null) {
            int i = offset;
            foreach (ExpressBusiness business in page.entries) {
              Console.WriteLine("{0}) Express business found with name '{1}', id = {2}, " +
                  "website = {3} and status = {4}.\n", i + 1, business.name, business.id,
                  business.website, business.status);
              Console.WriteLine("Address");
              Console.WriteLine("=======");
              Console.WriteLine(FormatAddress(business.address));
              Console.WriteLine("Co-ordinates: {0}\n", FormatGeopoint(business.geoPoint));
              i++;
            }
              }
              offset += pageSize;
            } while (offset < page.totalNumEntries);
            Console.WriteLine("Number of businesses found: {0}", page.totalNumEntries);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to retrieve express business.", e);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:58,代码来源:GetExpressBusinesses.cs


示例13: Run

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="campaignId">Id of the campaign from which targeting
        /// criteria are retrieved.</param>
        public void Run(AdWordsUser user, long campaignId)
        {
            // Get the CampaignCriterionService.
              CampaignCriterionService campaignCriterionService =
              (CampaignCriterionService) user.GetService(
              AdWordsService.v201506.CampaignCriterionService);

              // Create the selector.
              Selector selector = new Selector();
              selector.fields = new string[] {"Id", "CriteriaType", "CampaignId"};

              // Set the filters.
              Predicate predicate = new Predicate();
              predicate.field = "CampaignId";
              [email protected] = PredicateOperator.EQUALS;
              predicate.values = new string[] {campaignId.ToString()};

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

              // Set the selector paging.
              selector.paging = new Paging();

              int offset = 0;
              int pageSize = 500;

              CampaignCriterionPage page = new CampaignCriterionPage();

              try {
            do {
              selector.paging.startIndex = offset;
              selector.paging.numberResults = pageSize;

              // Get all campaign targets.
              page = campaignCriterionService.get(selector);

              // Display the results.
              if (page != null && page.entries != null) {
            int i = offset;
            foreach (CampaignCriterion campaignCriterion in page.entries) {
              string negative = (campaignCriterion is NegativeCampaignCriterion) ? "Negative " : "";
              Console.WriteLine("{0}) {1}Campaign criterion with id = '{2}' and Type = {3} was " +
                  " found for campaign id '{4}'", i, negative, campaignCriterion.criterion.id,
                  campaignCriterion.criterion.type, campaignCriterion.campaignId);
              i++;
            }
              }
              offset += pageSize;
            } while (offset < page.totalNumEntries);
            Console.WriteLine("Number of campaign targeting criteria found: {0}", page.totalNumEntries);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to get campaign targeting criteria.", e);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:59,代码来源:GetCampaignTargetingCriteria.cs


示例14: Run

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="productServiceSuggestion">The product/service suggestion.
        /// </param>
        /// <param name="localeText">The locale text.</param>
        public void Run(AdWordsUser user, string productServiceSuggestion, string localeText)
        {
            // Get the service, which loads the required classes.
              ProductServiceService productServiceService = (ProductServiceService) user.GetService(
              AdWordsService.v201506.ProductServiceService);

              // Create selector.
              Selector selector = new Selector();
              selector.fields = new string[] {"ProductServiceText"};

              // Create predicates.
              Predicate textPredicate = new Predicate();
              textPredicate.field = "ProductServiceText";
              [email protected] = PredicateOperator.EQUALS;
              textPredicate.values = new string[] {productServiceSuggestion};

              Predicate localePredicate = new Predicate();
              localePredicate.field = "Locale";
              [email protected] = PredicateOperator.EQUALS;
              localePredicate.values = new string[]{localeText};

              selector.predicates = new Predicate[] {textPredicate, localePredicate};

              // Set the selector paging.
              selector.paging = new Paging();

              int offset = 0;
              int pageSize = 500;

              ProductServicePage page = null;
              try {
            do {
              selector.paging.startIndex = offset;
              selector.paging.numberResults = pageSize;

              // Make the get request.
              page = productServiceService.get(selector);

              // Display the results.
              if (page != null && page.entries != null) {
            int i = offset;
            foreach (ProductService productService in page.entries) {
              Console.WriteLine("Product/service with text '{0}' found", productService.text);
              i++;
            }
              }
              offset += pageSize;
            } while (offset < page.totalNumEntries);
            Console.WriteLine("Number of products/services found: {0}", page.totalNumEntries);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to retrieve products/services.", e);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:60,代码来源:GetProductServices.cs


示例15: Run

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    public void Run(AdWordsUser user) {
      // Get the MediaService.
      MediaService mediaService = (MediaService) user.GetService(
          AdWordsService.v201506.MediaService);

      // Create a selector.
      Selector selector = new Selector() {
        fields = new string[] {
          Media.Fields.MediaId, Dimensions.Fields.Width,
          Dimensions.Fields.Height,  Media.Fields.MimeType
        },
        predicates = new Predicate[] {
          Predicate.In(Media.Fields.Type, new string[] {
              MediaMediaType.VIDEO.ToString(),
              MediaMediaType.IMAGE.ToString()
          })
        },
        paging = Paging.Default
      };
      MediaPage page = new MediaPage();

      try {
        do {
          page = mediaService.get(selector);

          if (page != null && page.entries != null) {
            int i = selector.paging.startIndex;

            foreach (Media media in page.entries) {
              if (media is Video) {
                Video video = (Video) media;
                Console.WriteLine("{0}) Video with id '{1}' and name '{2}' was found.",
                    i + 1, video.mediaId, video.name);
              } else if (media is Image) {
                Image image = (Image) media;
                Dictionary<MediaSize, Dimensions> dimensions =
                    CreateMediaDimensionMap(image.dimensions);
                Console.WriteLine("{0}) Image with id '{1}', dimensions '{2}x{3}', and MIME " +
                    "type '{4}' was found.", i + 1, image.mediaId,
                    dimensions[MediaSize.FULL].width, dimensions[MediaSize.FULL].height,
                    image.mimeType);
              }
              i++;
            }
          }
          selector.paging.IncreaseOffset();
        } while (selector.paging.startIndex < page.totalNumEntries);
        Console.WriteLine("Number of images and videos found: {0}", page.totalNumEntries);
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to get images and videos.", e);
      }
    }
开发者ID:markgmarkg,项目名称:googleads-dotnet-lib,代码行数:56,代码来源:GetAllVideosAndImages.cs


示例16: Run

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    public void Run(AdWordsUser user) {
      // Get the LocationCriterionService.
      LocationCriterionService locationCriterionService =
          (LocationCriterionService) user.GetService(AdWordsService.v201506.
              LocationCriterionService);

      string[] locationNames = new string[] {"Paris", "Quebec", "Spain", "Deutschland"};

      Selector selector = new Selector();
      selector.fields = new string[] {"Id", "LocationName", "CanonicalName", "DisplayType",
          "ParentLocations", "Reach", "TargetingStatus"};

      // Location names must match exactly, only EQUALS and IN are supported.
      Predicate predicate1 = new Predicate();
      predicate1.field = "LocationName";
      [email protected] = PredicateOperator.IN;
      predicate1.values = locationNames;

      // Set the locale of the returned location names.
      Predicate predicate2 = new Predicate();
      predicate2.field = "Locale";
      [email protected] = PredicateOperator.EQUALS;
      predicate2.values = new string[] {"en"};

      selector.predicates = new Predicate[] {predicate1, predicate2};

      try {
        // Make the get request.
        LocationCriterion[] locationCriteria = locationCriterionService.get(selector);

        // Display the resulting location criteria.
        foreach (LocationCriterion locationCriterion in locationCriteria) {
          string parentLocations = "";
          if (locationCriterion.location != null &&
              locationCriterion.location.parentLocations != null) {
            foreach (Locati 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Lib.DfaUser类代码示例发布时间:2022-05-26
下一篇:
C# v201502.Selector类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap