当前位置: 首页>>代码示例>>C#>>正文


C# StatementBuilder.RemoveLimitAndOffset方法代码示例

本文整理汇总了C#中Google.Api.Ads.Dfp.Util.v201411.StatementBuilder.RemoveLimitAndOffset方法的典型用法代码示例。如果您正苦于以下问题:C# StatementBuilder.RemoveLimitAndOffset方法的具体用法?C# StatementBuilder.RemoveLimitAndOffset怎么用?C# StatementBuilder.RemoveLimitAndOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Google.Api.Ads.Dfp.Util.v201411.StatementBuilder的用法示例。


在下文中一共展示了StatementBuilder.RemoveLimitAndOffset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the ContentMetadataKeyHierarchy service.
      ContentMetadataKeyHierarchyService contentMetadataKeyHierarchyService =
          (ContentMetadataKeyHierarchyService) user.GetService(
          DfpService.v201411.ContentMetadataKeyHierarchyService);

      // Set the ID of the content metadata key hierarchy to delete.
      long contentMetadataKeyHierarchyId = 
          long.Parse(_T("INSERT_CONTENT_METADATA_KEY_HIERARCHY_ID_HERE"));

      // Create a statement to select a content metadata key hierarchy.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("WHERE id = :id")
          .OrderBy("id ASC")
          .Limit(1)
          .AddValue("id", contentMetadataKeyHierarchyId);

      try {
        // Get content metadata key hierarchies by statement.
        ContentMetadataKeyHierarchyPage page = contentMetadataKeyHierarchyService
            .getContentMetadataKeyHierarchiesByStatement(statementBuilder.ToStatement());

        ContentMetadataKeyHierarchy contentMetadataKeyHierarchy = page.results[0];

        Console.WriteLine("Content metadata key hierarchy with ID \"{0}\" will be deleted.",
            contentMetadataKeyHierarchy.id);

        statementBuilder.RemoveLimitAndOffset();

        // Create action.
        Google.Api.Ads.Dfp.v201411.DeleteContentMetadataKeyHierarchies action =
          new Google.Api.Ads.Dfp.v201411.DeleteContentMetadataKeyHierarchies();

        // Perform action.
        UpdateResult result = contentMetadataKeyHierarchyService
          .performContentMetadataKeyHierarchyAction(action, statementBuilder.ToStatement());

        Console.WriteLine("Number of content metadata key hierarchies deleted: {0}",
            result.numChanges);
      } catch (Exception ex) {
        Console.WriteLine("Failed to delete content metadata key hierarchies. " +
            "Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:48,代码来源:DeleteContentMetadataKeyHierarchies.cs

示例2: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the LineItemService.
      LineItemService lineItemService =
          (LineItemService) user.GetService(DfpService.v201411.LineItemService);

      // Set the ID of the order to get line items from.
      long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));

      // Create statement to select approved line items from a given order.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("orderId = :orderId and status = :status")
          .AddValue("orderId", orderId)
          .AddValue("status", ComputedStatus.INACTIVE.ToString());

      // Set default for page.
      LineItemPage page = new LineItemPage();
      List<string> lineItemIds = new List<string>();

      try {
        do {
          // Get line items by statement.
          page = lineItemService.getLineItemsByStatement(statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (LineItemSummary lineItem in page.results) {
              // Archived line items cannot be activated.
              if (!lineItem.isArchived) {
                Console.WriteLine("{0}) Line item with ID ='{1}', belonging to order ID ='{2}' " +
                    "and name ='{2}' will be activated.", i, lineItem.id, lineItem.orderId,
                    lineItem.name);
                lineItemIds.Add(lineItem.id.ToString());
                i++;
              }
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);


        Console.WriteLine("Number of line items to be activated: {0}", lineItemIds.Count);

        if (lineItemIds.Count > 0) {
          // Modify statement.
          statementBuilder.RemoveLimitAndOffset();

          // Create action.
          ActivateLineItems action = new ActivateLineItems();

          // Perform action.
          UpdateResult result = lineItemService.performLineItemAction(action,
              statementBuilder.ToStatement());

          // Display results.
          if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of line items activated: {0}", result.numChanges);
          } else {
            Console.WriteLine("No line items were activated.");
          }
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to activate line items. Exception says \"{0}\"",
            ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:70,代码来源:ActivateLineItem.cs

示例3: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the PlacementService.
              PlacementService placementService =
              (PlacementService) user.GetService(DfpService.v201411.PlacementService);

              // Create statement to select active placements.
              StatementBuilder statementBuilder = new StatementBuilder()
              .Where("status = :status")
              .OrderBy("id ASC")
              .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
              .AddValue("status", InventoryStatus.ACTIVE.ToString());

              // Sets default for page.
              PlacementPage page = new PlacementPage();
              List<string> placementIds = new List<string>();

              try {
            do {
              // Get placements by statement.
              page = placementService.getPlacementsByStatement(statementBuilder.ToStatement());

              if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (Placement placement in page.results) {
              Console.WriteLine("{0}) Placement with ID ='{1}', name ='{2}', and status ='{3}'" +
                  " will be deactivated.", i, placement.id, placement.name, placement.status);
              placementIds.Add(placement.id.ToString());
              i++;
            }
              }

              statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
            } while (statementBuilder.GetOffset() < page.totalResultSetSize);

            Console.WriteLine("Number of placements to be deactivated: {0}", placementIds.Count);

            if (placementIds.Count > 0) {
              // Modify statement for action.
              statementBuilder.RemoveLimitAndOffset();

              // Create action.
              DeactivatePlacements action = new DeactivatePlacements();

              // Perform action.
              UpdateResult result = placementService.performPlacementAction(action,
              statementBuilder.ToStatement());

              // Display results.
              if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of placements deactivated: {0}", result.numChanges);
              } else {
            Console.WriteLine("No placements were deactivated.");
              }
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to deactivate placements. Exception says \"{0}\"",
            e.Message);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:64,代码来源:DeactivatePlacement.cs

示例4: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the InventoryService.
      InventoryService inventoryService =
          (InventoryService) user.GetService(DfpService.v201411.InventoryService);

      // Set the ID of the ad unit to deactivate.
      int adUnitId = int.Parse(_T("INSERT_AD_UNIT_ID_HERE"));

      // Create a statement to select the ad unit.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("id = :id")
          .OrderBy("id ASC")
          .Limit(1)
          .AddValue("id", adUnitId);

      // Set default for page.
      AdUnitPage page = new AdUnitPage();
      List<string> adUnitIds = new List<string>();

      try {
        do {
          // Get ad units by statement.
          page = inventoryService.getAdUnitsByStatement(statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (AdUnit adUnit in page.results) {
              Console.WriteLine("{0}) Ad unit with ID ='{1}', name = {2} and status = {3} will" +
                  " be deactivated.", i, adUnit.id, adUnit.name, adUnit.status);
              adUnitIds.Add(adUnit.id);
              i++;
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of ad units to be deactivated: {0}", adUnitIds.Count);

        // Modify statement for action.
        statementBuilder.RemoveLimitAndOffset();

        // Create action.
        DeactivateAdUnits action = new DeactivateAdUnits();

        // Perform action.
        UpdateResult result = inventoryService.performAdUnitAction(action,
            statementBuilder.ToStatement());

        // Display results.
        if (result != null && result.numChanges > 0) {
          Console.WriteLine("Number of ad units deactivated: {0}", result.numChanges);
        } else {
          Console.WriteLine("No ad units were deactivated.");
        }

      } catch (Exception ex) {
        Console.WriteLine("Failed to deactivate ad units. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:64,代码来源:DeActivateAdUnits.cs

示例5: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the ProductTemplateService.
              ProductTemplateService productTemplateService =
              (ProductTemplateService) user.GetService(DfpService.v201411.ProductTemplateService);

              // Set the ID of the product template to activate.
              long productTemplateId = long.Parse(_T("INSERT_PRODUCT_TEMPLATE_ID_HERE"));

              // Create statement to select a product template by ID.
              StatementBuilder statementBuilder = new StatementBuilder()
              .Where("id = :id")
              .OrderBy("id ASC")
              .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
              .AddValue("id", productTemplateId);

              // Set default for page.
              ProductTemplatePage page = new ProductTemplatePage();
              List<string> productTemplateIds = new List<string>();

              try {
            do {
              // Get product templates by statement.
              page = productTemplateService.getProductTemplatesByStatement(
              statementBuilder.ToStatement());

              if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (ProductTemplate productTemplate in page.results) {
              Console.WriteLine("{0}) Product template with ID ='{1}' will be activated.",
                  i++, productTemplate.id);
              productTemplateIds.Add(productTemplate.id.ToString());
            }
              }

              statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
            } while (statementBuilder.GetOffset() < page.totalResultSetSize);

            Console.WriteLine("Number of product templates to be activated: {0}",
            productTemplateIds.Count);

            if (productTemplateIds.Count > 0) {
              // Modify statement.
              statementBuilder.RemoveLimitAndOffset();

              // Create action.
              Google.Api.Ads.Dfp.v201411.ActivateProductTemplates action =
              new Google.Api.Ads.Dfp.v201411.ActivateProductTemplates();

              // Perform action.
              UpdateResult result = productTemplateService.performProductTemplateAction(action,
              statementBuilder.ToStatement());

              // Display results.
              if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of product templates activated: {0}", result.numChanges);
              } else {
            Console.WriteLine("No product templates were activated.");
              }
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to activate product templates. Exception says \"{0}\"",
            e.Message);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:69,代码来源:ActivateProductTemplates.cs

示例6: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the ProposalService.
      ProposalService proposalService =
          (ProposalService) user.GetService(DfpService.v201411.ProposalService);

      // Set the ID of the proposal.
      long proposalId = long.Parse(_T("INSERT_PROPOSAL_ID_HERE"));

      // Create statement to select the proposal.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("id = :id")
          .OrderBy("id ASC")
          .Limit(1)
          .AddValue("id", proposalId);

      // Set default for page.
      ProposalPage page = new ProposalPage();
      List<string> proposalIds = new List<string>();
      int i = 0;

      try {
        do {
          // Get proposals by statement.
          page = proposalService.getProposalsByStatement(statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            foreach (Proposal proposal in page.results) {
              Console.WriteLine("{0}) Proposal with ID = '{1}', name = '{2}', and status ='{3}' " +
                  "will be approved.", i++, proposal.id, proposal.name, proposal.status);
              proposalIds.Add(proposal.id.ToString());
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of proposals to be approved: {0}", proposalIds.Count);

        if (proposalIds.Count > 0) {
          // Modify statement for action.
          statementBuilder.RemoveLimitAndOffset();

          // Create action.
          Dfp.v201411.SubmitProposalsForApproval action =
              new Dfp.v201411.SubmitProposalsForApproval();

          // Perform action.
          UpdateResult result = proposalService.performProposalAction(action,
              statementBuilder.ToStatement());

          // Display results.
          if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of proposals approved: {0}", result.numChanges);
          } else {
            Console.WriteLine("No proposals were approved.");
          }
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to approve proposals. Exception says \"{0}\"",
            ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:66,代码来源:SubmitProposalsForApproval.cs

示例7: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the LineItemService.
              LineItemService lineItemService =
              (LineItemService) user.GetService(DfpService.v201411.LineItemService);
              // Get the ReportService.
              ReportService reportService =
              (ReportService) user.GetService(DfpService.v201411.ReportService);

              try {
            // Set the ID of the order to get line items from.
            long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));

            // Sets default for page.
            LineItemPage page = new LineItemPage();

            // Create a statement to only select line items from a given order.
            StatementBuilder statementBuilder = new StatementBuilder()
            .Where("orderId = :orderId")
            .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
            .AddValue("orderId", orderId);

            // Collect all line item custom field IDs for an order.
            List<long> customFieldIds = new List<long>();
            do {
              // Get line items by statement.
              page = lineItemService.getLineItemsByStatement(statementBuilder.ToStatement());

              // Get custom field IDs from the line items of an order.
              if (page.results != null) {
            foreach (LineItem lineItem in page.results) {
              if (lineItem.customFieldValues != null) {
                foreach (BaseCustomFieldValue customFieldValue in lineItem.customFieldValues) {
                  if (!customFieldIds.Contains(customFieldValue.customFieldId)) {
                    customFieldIds.Add(customFieldValue.customFieldId);
                  }
                }
              }
            }
              }

              statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
            } while (statementBuilder.GetOffset() < page.totalResultSetSize);

            // Create statement to filter for an order.
            statementBuilder.RemoveLimitAndOffset();

            // Create report job.
            ReportJob reportJob = new ReportJob();

            // Create report query.
            ReportQuery reportQuery = new ReportQuery();
            reportQuery.dateRangeType = DateRangeType.LAST_MONTH;
            reportQuery.dimensions = new Dimension[] {Dimension.LINE_ITEM_ID, Dimension.LINE_ITEM_NAME};
            reportQuery.statement = statementBuilder.ToStatement();
            reportQuery.customFieldIds = customFieldIds.ToArray();
            reportQuery.columns = new Column[] {Column.AD_SERVER_IMPRESSIONS};
            reportJob.reportQuery = reportQuery;

            // Run report job.
            reportJob = reportService.runReportJob(reportJob);

            do {
              Console.WriteLine("Report with ID '{0}' is still running.", reportJob.id);
              Thread.Sleep(30000);
              // Get report job.
              reportJob = reportService.getReportJob(reportJob.id);
            } while (reportJob.reportJobStatus == ReportJobStatus.IN_PROGRESS);

            if (reportJob.reportJobStatus == ReportJobStatus.FAILED) {
              Console.WriteLine("Report job with ID '{0}' failed to finish successfully.",
              reportJob.id);
            } else {
              Console.WriteLine("Report job with ID '{0}' completed successfully.", reportJob.id);
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to run cusom fields report. Exception says \"{0}\"",
            e.Message);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:84,代码来源:RunReportWithCustomFields.cs

示例8: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the OrderService.
      OrderService orderService =
          (OrderService) user.GetService(DfpService.v201411.OrderService);

      // Set the ID of the order.
      long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));

      // Create statement to select the order.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("id = :id")
          .OrderBy("id ASC")
          .Limit(1)
          .AddValue("id", orderId);

      // Set default for page.
      OrderPage page = new OrderPage();
      List<string> orderIds = new List<string>();
      int i = 0;

      try {
        do {
          // Get orders by statement.
          page = orderService.getOrdersByStatement(statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            foreach (Order order in page.results) {
              Console.WriteLine("{0}) Order with ID = '{1}', name = '{2}', and status ='{3}' " +
                  "will be approved.", i, order.id, order.name, order.status);
              orderIds.Add(order.id.ToString());
              i++;
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of orders to be approved: {0}", orderIds.Count);

        if (orderIds.Count > 0) {
          // Modify statement for action.
          statementBuilder.RemoveLimitAndOffset();

          // Create action.
          ApproveAndOverbookOrders action = new ApproveAndOverbookOrders();

          // Perform action.
          UpdateResult result = orderService.performOrderAction(action,
              statementBuilder.ToStatement());

          // Display results.
          if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of orders approved: {0}", result.numChanges);
          } else {
            Console.WriteLine("No orders were approved.");
          }
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to approve orders. Exception says \"{0}\"",
            ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:66,代码来源:ApproveOrder.cs

示例9: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the UserService.
      UserService userService = (UserService) user.GetService(DfpService.v201411.UserService);

      // Set the ID of the user to deactivate
      long userId = long.Parse(_T("INSERT_USER_ID_HERE"));

      // Create statement text to select user by id.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("id = :userId")
          .OrderBy("id ASC")
          .Limit(1)
          .AddValue("userId", userId);

      // Sets default for page.
      UserPage page = new UserPage();
      List<string> userIds = new List<string>();

      try {
        do {
          // Get users by statement.
          page = userService.getUsersByStatement(statementBuilder.ToStatement());

          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (User userResult in page.results) {
              Console.WriteLine("{0}) User with ID = '{1}', email = '{2}', and status = '{3}'" +
                 " will be deactivated.", i, userResult.id, userResult.email,
                 userResult.isActive ? "ACTIVE" : "INACTIVE");
              userIds.Add(userResult.id.ToString());
              i++;
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of users to be deactivated: {0}", page.totalResultSetSize);

        if (userIds.Count > 0) {
          // Modify statement for action.
          statementBuilder.RemoveLimitAndOffset();

          // Create action.
          DeactivateUsers action = new DeactivateUsers();

          // Perform action.
          UpdateResult result = userService.performUserAction(action,
              statementBuilder.ToStatement());

          // Display results.
          if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of users deactivated: {0}" + result.numChanges);
          } else {
            Console.WriteLine("No users were deactivated.");
          }
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to deactivate users. Exception says \"{0}\"",
            ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:66,代码来源:DeactivateUser.cs

示例10: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the LabelService.
      LabelService labelService =
          (LabelService) user.GetService(DfpService.v201411.LabelService);

      // Set the ID of the label to deactivate.
      int labelId = int.Parse(_T("INSERT_LABEL_ID_HERE"));

      // Create statement text to select the label.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("id = :id")
          .OrderBy("id ASC")
          .Limit(1)
          .AddValue("id", labelId);

      // Set default for page.
      LabelPage page = new LabelPage();

      try {
        do {
          // Get labels by statement.
          page = labelService.getLabelsByStatement(statementBuilder.ToStatement());

          if (page.results != null) {
            int i = page.startIndex;
            foreach (Label label in page.results) {
              Console.WriteLine("{0}) Label with ID '{1}', name '{2}' will be deactivated.",
                  i, label.id, label.name);
              i++;
            }
          }
          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of labels to be deactivated: " + page.totalResultSetSize);

        // Modify statement for action.
        statementBuilder.RemoveLimitAndOffset();

        // Create action.
        DeactivateLabels action = new DeactivateLabels();

        // Perform action.
        UpdateResult result = labelService.performLabelAction(action,
            statementBuilder.ToStatement());

        // Display results.
        if (result != null && result.numChanges > 0) {
          Console.WriteLine("Number of labels deactivated: " + result.numChanges);
        } else {
          Console.WriteLine("No labels were deactivated.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to deactivate labels. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:60,代码来源:DeactivateActiveLabels.cs

示例11: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the LineItemCreativeAssociationService.
              LineItemCreativeAssociationService licaService = (LineItemCreativeAssociationService)
              user.GetService(DfpService.v201411.LineItemCreativeAssociationService);

              // Set the line item to get LICAs by.
              long lineItemId = long.Parse(_T("INSERT_LINE_ITEM_ID_HERE"));

              // Create a statement to page through active LICAs.
              StatementBuilder statementBuilder = new StatementBuilder()
              .Where("lineItemId = :lineItemId")
              .OrderBy("lineItemId ASC, creativeId ASC")
              .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
              .AddValue("lineItemId", lineItemId);

              // Set default for page.
              LineItemCreativeAssociationPage page = new LineItemCreativeAssociationPage();
              List<string> creativeIds = new List<string>();

              try {
            do {
              // Get LICAs by statement.
              page = licaService.getLineItemCreativeAssociationsByStatement(
              statementBuilder.ToStatement());

              if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (LineItemCreativeAssociation lica in page.results) {
              Console.WriteLine("{0}) LICA with line item ID = '{1}', creative ID ='{2}' and " +
                  "status ='{3}' will be deactivated.", i, lica.lineItemId, lica.creativeId,
                  lica.status);
              i++;
              creativeIds.Add(lica.creativeId.ToString());
            }
              }

              statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
            } while (statementBuilder.GetOffset() < page.totalResultSetSize);

            Console.WriteLine("Number of LICAs to be deactivated: {0}", creativeIds.Count);

            if (creativeIds.Count > 0) {
              // Modify statement for action.
              statementBuilder.RemoveLimitAndOffset();

              // Create action.
              DeactivateLineItemCreativeAssociations action =
              new DeactivateLineItemCreativeAssociations();

              // Perform action.
              UpdateResult result = licaService.performLineItemCreativeAssociationAction(action,
              statementBuilder.ToStatement());

              // Display results.
              if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of LICAs deactivated: {0}", result.numChanges);
              } else {
            Console.WriteLine("No LICAs were deactivated.");
              }
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to deactivate LICAs. Exception says \"{0}\"", e.Message);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:69,代码来源:DeactivateLicas.cs

示例12: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the WorkflowRequestService.
              WorkflowRequestService proposalLineItemService =
              (WorkflowRequestService) user.GetService(DfpService.v201411.WorkflowRequestService);

              // Set the ID of the proposal to trigger workflow external conditions for.c
              long proposalId = long.Parse(_T("INSERT_PROPOSAL_ID_HERE"));

              // Create a statement to select workflow external condition requests for a proposal.
              StatementBuilder statementBuilder = new StatementBuilder()
              .Where("entityId = :entityId and entityType = :entityType and type = :type")
              .OrderBy("id ASC")
              .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
              .AddValue("entityId", proposalId)
              .AddValue("entityType", WorkflowEntityType.PROPOSAL.ToString())
              .AddValue("type", WorkflowRequestType.WORKFLOW_EXTERNAL_CONDITION_REQUEST.ToString());

              // Set default for page.
              WorkflowRequestPage page = new WorkflowRequestPage();
              List<long> workflowRequestIds = new List<long>();

              try {
            do {
              // Get workflow requests by statement.
              page = proposalLineItemService.getWorkflowRequestsByStatement(
              statementBuilder.ToStatement());

              if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (WorkflowRequest workflowRequest in page.results) {
              Console.WriteLine("{0}) Workflow external condition request with ID '{1}'" +
                  " for {2} with ID '{3}' will be triggered.", i++, workflowRequest.id,
                  workflowRequest.entityType.ToString(), workflowRequest.entityId);
              workflowRequestIds.Add(workflowRequest.id);
            }
              }

              statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
            } while (statementBuilder.GetOffset() < page.totalResultSetSize);

            Console.WriteLine("Number of workflow external condition requests to be triggered: {0}",
            workflowRequestIds.Count);

            if (workflowRequestIds.Count > 0) {
              // Modify statement.
              statementBuilder.RemoveLimitAndOffset();

              // Create action.
              Google.Api.Ads.Dfp.v201411.TriggerWorkflowExternalConditionRequests action =
              new Google.Api.Ads.Dfp.v201411.TriggerWorkflowExternalConditionRequests();

              // Perform action.
              UpdateResult result = proposalLineItemService.performWorkflowRequestAction(action,
              statementBuilder.ToStatement());

              // Display results.
              if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of workflow external condition requests triggered: {0}",
                result.numChanges);
              } else {
            Console.WriteLine("No workflow external condition requests were triggered.");
              }
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to tirgger workflow external condition requests. Exception " +
            "says \"{0}\"", e.Message);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:73,代码来源:TriggerWorkflowExternalConditionRequests.cs

示例13: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the CustomFieldService.
              CustomFieldService customFieldService = (CustomFieldService) user.GetService(
              DfpService.v201411.CustomFieldService);

              // Set the ID of the custom field to update.
              int customFieldId = int.Parse(_T("INSERT_CUSTOM_FIELD_ID_HERE"));

              // Create statement to select only active custom fields that apply to
              // line items.
              StatementBuilder statementBuilder = new StatementBuilder()
              .Where("id = :id")
              .OrderBy("id ASC")
              .Limit(1)
              .AddValue("id", customFieldId);

              // Set default for page.
              CustomFieldPage page = new CustomFieldPage();
              int i = 0;
              List<string> customFieldIds = new List<string>();

              try {
            do {
              // Get custom fields by statement.
              page = customFieldService.getCustomFieldsByStatement(statementBuilder.ToStatement());

              if (page.results != null) {
            foreach (CustomField customField in page.results) {
              Console.WriteLine("{0}) Custom field with ID \"{1}\" and name \"{2}\" will be " +
                  "deactivated.", i, customField.id, customField.name);
              customFieldIds.Add(customField.id.ToString());
              i++;
            }
              }
              statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
            } while (statementBuilder.GetOffset() < page.totalResultSetSize);

            Console.WriteLine("Number of custom fields to be deactivated: " + customFieldIds.Count);

            if (customFieldIds.Count > 0) {
              // Remove limit and offset from statement.
              statementBuilder.RemoveLimitAndOffset();

              // Create action.
              Google.Api.Ads.Dfp.v201411.DeactivateCustomFields action =
              new Google.Api.Ads.Dfp.v201411.DeactivateCustomFields();

              // Perform action.
              UpdateResult result = customFieldService.performCustomFieldAction(action,
              statementBuilder.ToStatement());

              // Display results.
              if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of custom fields deactivated: " + result.numChanges);
              } else {
            Console.WriteLine("No custom fields were deactivated.");
              }
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to deactivate custom fields. Exception says \"{0}\"", e.Message);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:67,代码来源:DeactivateCustomFields.cs

示例14: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Create the CreativeWrapperService.
              CreativeWrapperService creativeWrapperService = (CreativeWrapperService) user.GetService(
              DfpService.v201411.CreativeWrapperService);

              long labelId = long.Parse(_T("INSERT_CREATIVE_WRAPPER_LABEL_ID_HERE"));

              try {
            // Create a query to select the active creative wrapper for the given
            // label.
            StatementBuilder statementBuilder = new StatementBuilder()
            .Where ("labelId = :labelId AND status = :status")
            .OrderBy("id ASC")
            .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
            .AddValue("status", CreativeWrapperStatus.ACTIVE.ToString())
            .AddValue("labelId", labelId);

            // Set default for page.
            CreativeWrapperPage page = new CreativeWrapperPage();

            do {
              page =
              creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.ToStatement());
              CreativeWrapper[] creativeWrappers = page.results;
              if (creativeWrappers != null) {
            foreach (CreativeWrapper wrapper in creativeWrappers) {
              Console.WriteLine("Creative wrapper with ID \'{0}\' applying to label \'{1}\' with " +
                  "status \'{2}\' will be deactivated.", wrapper.id, wrapper.labelId,
                   wrapper.status);
            }
              }
              statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
            } while (statementBuilder.GetOffset() < page.totalResultSetSize);

            Console.WriteLine("Number of creative wrappers to be deactivated: {0}",
            page.totalResultSetSize);

            // Modify statement for action.
            statementBuilder.RemoveLimitAndOffset();

            // Perform action.
            CreativeWrapperAction action = new DeactivateCreativeWrappers();
            UpdateResult result = creativeWrapperService.performCreativeWrapperAction(action,
            statementBuilder.ToStatement());

            // Display results.
            if (result.numChanges > 0) {
              Console.WriteLine("Number of creative wrappers deactivated: {0}", result.numChanges);
            } else {
              Console.WriteLine("No creative wrappers were deactivated.");
            }

              } catch (Exception e) {
            Console.WriteLine("Failed to create creative wrappers. Exception says \"{0}\"", e.Message);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:61,代码来源:DeactivateCreativeWrappers.cs

示例15: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="dfpUser">The DFP user object running the code example.</param>
        public override void Run(DfpUser dfpUser)
        {
            // Get the UserTeamAssociationService.
              UserTeamAssociationService userTeamAssociationService = (UserTeamAssociationService)
              dfpUser.GetService(DfpService.v201411.UserTeamAssociationService);

              // Set the user to remove from its teams.
              long userId = long.Parse(_T("INSERT_USER_ID_HERE"));

              // Create filter text to select user team associations by the user ID.
              StatementBuilder statementBuilder = new StatementBuilder()
              .Where("userId = :userId")
              .OrderBy("userId ASC, teamId ASC")
              .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
              .AddValue("userId", userId);

              // Set default for page.
              UserTeamAssociationPage page = new UserTeamAssociationPage();

              try {
            do {
              // Get user team associations by statement.
              page = userTeamAssociationService.getUserTeamAssociationsByStatement(
              statementBuilder.ToStatement());

              if (page.results != null) {
            int i = page.startIndex;
            foreach (UserTeamAssociation userTeamAssociation in page.results) {
              Console.WriteLine("{0}) User team association between user with ID \"{1}\" and " +
                  "team with ID \"{2}\" will be deleted.", i, userTeamAssociation.userId,
                  userTeamAssociation.teamId);
              i++;
            }
              }

              statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
            } while (statementBuilder.GetOffset() < page.totalResultSetSize);

            Console.WriteLine("Number of teams that the user will be removed from: "
            + page.totalResultSetSize);

            if (page.totalResultSetSize > 0) {
              // Modify statement for action.
              statementBuilder.RemoveLimitAndOffset();

              // Create action.
              DeleteUserTeamAssociations action = new DeleteUserTeamAssociations();

              // Perform action.
              UpdateResult result = userTeamAssociationService.performUserTeamAssociationAction(action,
              statementBuilder.ToStatement());

              // Display results.
              if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of teams that the user was removed from: "
                + result.numChanges);
              } else {
            Console.WriteLine("No user team associations were deleted.");
              }
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to delete user team associations. Exception says \"{0}\"",
            e.Message);
              }
        }
开发者ID:nathanlowy,项目名称:googleads-dotnet-lib,代码行数:69,代码来源:DeleteUserTeamAssociations.cs


注:本文中的Google.Api.Ads.Dfp.Util.v201411.StatementBuilder.RemoveLimitAndOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。