コード例 #1
0
    /// <summary>
    /// Gets the platform restrictions for sitelinks in a campaign.
    /// </summary>
    /// <param name="campaignFeed">The campaign feed.</param>
    /// <returns>The platform restrictions.</returns>
    private ExtensionSettingPlatform GetPlatformRestrictionsForCampaign(
          CampaignFeed campaignFeed) {
      string platformRestrictions = "NONE";

      if (campaignFeed.matchingFunction.@operator == FunctionOperator.AND) {
        foreach (FunctionArgumentOperand argument in campaignFeed.matchingFunction.lhsOperand) {
          // Check if matchingFunction is of the form EQUALS(CONTEXT.DEVICE, 'Mobile').
          if (argument is FunctionOperand) {
            FunctionOperand operand = (argument as FunctionOperand);
            if (operand.value.@operator == FunctionOperator.EQUALS) {
              RequestContextOperand requestContextOperand = operand.value.lhsOperand[0] as
                  RequestContextOperand;
              if (requestContextOperand != null && requestContextOperand.contextType ==
                  RequestContextOperandContextType.DEVICE_PLATFORM) {
                platformRestrictions = (operand.value.rhsOperand[0] as ConstantOperand)
                      .stringValue;
              }
            }
          }
        }
      }

      return (ExtensionSettingPlatform) Enum.Parse(typeof(ExtensionSettingPlatform),
              platformRestrictions, true);
    }
コード例 #2
0
    /// <summary>
    /// Gets the list of feed items that are used by a campaign through a given
    /// campaign feed.
    /// </summary>
    /// <param name="campaignFeed">The campaign feed.</param>
    /// <returns>The list of feed items.</returns>
    private List<long> GetFeedItemsForCampaign(CampaignFeed campaignFeed) {
      List<long> feedItems = new List<long>();

      switch (campaignFeed.matchingFunction.@operator) {
        case FunctionOperator.IN:
          // Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
          // Extract feedItems if applicable.
          feedItems.AddRange(GetFeedItemsFromArgument(campaignFeed.matchingFunction));

          break;

        case FunctionOperator.AND:
          // Check each condition.

          foreach (FunctionArgumentOperand argument in campaignFeed.matchingFunction.lhsOperand) {
            // Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
            // Extract feedItems if applicable.
            if (argument is FunctionOperand) {
              FunctionOperand operand = (argument as FunctionOperand);
              if (operand.value.@operator == FunctionOperator.IN) {
                feedItems.AddRange(GetFeedItemsFromArgument(operand.value));
              }
            }
          }
          break;

        default:
          // There are no other matching functions involving feeditem ids.
          break;
      }

      return feedItems;
    }
コード例 #3
0
    /// <summary>
    /// Deletes a campaign feed.
    /// </summary>
    /// <param name="user">The user.</param>
    /// <param name="campaignFeed">The campaign feed.</param>
    /// <returns></returns>
    private CampaignFeed DeleteCampaignFeed(AdWordsUser user, CampaignFeed campaignFeed) {
      CampaignFeedService campaignFeedService = (CampaignFeedService) user.GetService(
          AdWordsService.v201409.CampaignFeedService);

      CampaignFeedOperation operation = new CampaignFeedOperation() {
        operand = campaignFeed,
        @operator = Operator.REMOVE
      };

      return campaignFeedService.mutate(new CampaignFeedOperation[] { operation }).value[0];
    }