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


C# Lib.DfpUser类代码示例

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


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

示例1: Run

    /// <summary>
    /// Run the sample code.
    /// </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.v201405.InventoryService);

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

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

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

        AdUnit adUnit = page.results[0];
        adUnit.inheritedAdSenseSettings.value.adSenseEnabled = true;

        // Update the ad units on the server.
        AdUnit[] updatedAdUnits = inventoryService.updateAdUnits(new AdUnit[] { adUnit });

        foreach (AdUnit updatedAdUnit in updatedAdUnits) {
          Console.WriteLine("Ad unit with ID \"{0}\", name \"{1}\", and is AdSense enabled " +
              "\"{2}\" was updated.", updatedAdUnit.id, updatedAdUnit.name,
              updatedAdUnit.inheritedAdSenseSettings.value.adSenseEnabled);
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to update ad units. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:klimenkor,项目名称:googleads-dotnet-lib,代码行数:38,代码来源:UpdateAdUnits.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 PlacementService.
      PlacementService placementService =
          (PlacementService) user.GetService(DfpService.v201211.PlacementService);

      // Create a Statement to only select active placements.
      Statement statement = new StatementBuilder("WHERE status = :status LIMIT 500").AddValue(
          "status", InventoryStatus.ACTIVE.ToString()).ToStatement();

      try {
        // Get placements by Statement.
        PlacementPage page = placementService.getPlacementsByStatement(statement);

        // Display results.
        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}' " +
              "was found.", i, placement.id, placement.name, placement.status);
            i++;
          }
        }

        Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get placement by Statement. Exception says \"{0}\"",
            ex.Message);
      }
    }
开发者ID:hoodapecan,项目名称:googleads-dotnet-lib,代码行数:33,代码来源:GetPlacementsByStatement.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 UserService.
              UserService userService = (UserService) user.GetService(DfpService.v201211.UserService);

              // Sets defaults for page and Statement.
              UserPage page = new UserPage();
              Statement statement = new Statement();
              int offset = 0;

              try {
            do {
              // Create a Statement to get all users.
              statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);

              // Get users by Statement.
              page = userService.getUsersByStatement(statement);

              if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (User usr in page.results) {
              Console.WriteLine("{0}) User with ID = '{1}', email = '{2}', and role = '{3}'" +
                  " was found.", i, usr.id, usr.email, usr.roleName);
              i++;
            }
              }
              offset += 500;
            } while (offset < page.totalResultSetSize);

            Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
              } catch (Exception ex) {
            Console.WriteLine("Failed to get all users. Exception says \"{0}\"",
            ex.Message);
              }
        }
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:39,代码来源:GetAllUsers.cs

示例4: GetAllAdUnits

    /// <summary>
    /// Gets all ad units for this user.
    /// </summary>
    /// <param name="user">The DfpUser to get the ad units for.</param>
    /// <returns>All ad units for this user.</returns>
    private static AdUnit[] GetAllAdUnits(DfpUser user) {
      // Create list to hold all ad units.
      List<AdUnit> adUnits = new List<AdUnit>();

      // Get InventoryService.
      InventoryService inventoryService =
          (InventoryService) user.GetService(DfpService.v201311.InventoryService);

      // Sets defaults for page and Statement.
      AdUnitPage page = new AdUnitPage();
      Statement statement = new Statement();
      int offset = 0;

      do {
        // Create a Statement to get all ad units.
        statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);

        // Get ad units by Statement.
        page = inventoryService.getAdUnitsByStatement(statement);

        if (page.results != null && page.results.Length > 0) {
          adUnits.AddRange(page.results);
        }
        offset += 500;
      } while (page.results != null && page.results.Length == 500);
      return adUnits.ToArray();
    }
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:32,代码来源:GetInventoryTree.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 ForecastService.
      ForecastService forecastService =
          (ForecastService) user.GetService(DfpService.v201502.ForecastService);

      // Set the line item to get a forecast for.
      long lineItemId = long.Parse(_T("INSERT_LINE_ITEM_ID_HERE"));

      try {
        // Get forecast for line item.
        AvailabilityForecastOptions options = new AvailabilityForecastOptions();
        options.includeContendingLineItems = true;
        options.includeTargetingCriteriaBreakdown = true;
        AvailabilityForecast forecast =
            forecastService.getAvailabilityForecastById(lineItemId, options);

        // Display results.
        long matched = forecast.matchedUnits;
        double availablePercent = (double) (forecast.availableUnits / (matched * 1.0)) * 100;
        String unitType = forecast.unitType.ToString().ToLower();

        Console.WriteLine("{0} {1} matched.\n{2} % {3} available.", matched, unitType,
            availablePercent, unitType);
        if (forecast.possibleUnitsSpecified) {
          double possiblePercent = (double) (forecast.possibleUnits / (matched * 1.0)) * 100;
          Console.WriteLine(possiblePercent + "% " + unitType + " possible.\n");
        }
        Console.WriteLine("{0} contending line items.", (forecast.contendingLineItems != null)?
            forecast.contendingLineItems.Length : 0);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get forecast by id. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:37,代码来源:GetAvailabilityForecastById.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 ActivityService.
      ActivityService activityService =
          (ActivityService) user.GetService(DfpService.v201502.ActivityService);

      int totalResultsCounter = 0;

      try {
        StatementBuilder statementBuilder = new StatementBuilder()
            .OrderBy("id ASC")
            .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

        ActivityPage page = new ActivityPage();

        do {
          // Get activities by statement.
          page = activityService.getActivitiesByStatement(statementBuilder.ToStatement());

          // Display results.
          if (page.results != null) {
            foreach (Activity activity in page.results) {
              Console.WriteLine("{0}) Activity with ID \"{1}\", name \"{2}\" and type \"{3}\" " +
                  "was found.\n", totalResultsCounter, activity.id, activity.name,
                  activity.type);
              totalResultsCounter++;
            }
          }
          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);
        Console.WriteLine("Number of results found: {0}.", totalResultsCounter);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get contacts. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:38,代码来源:GetAllActivities.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 InventoryService.
      InventoryService inventoryService =
          (InventoryService) user.GetService(DfpService.v201408.InventoryService);

      // Create a Statement to get all ad units.
      StatementBuilder statementBuilder = new StatementBuilder()
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

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

      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}' " +
                  "was found.", i, adUnit.id, adUnit.name, adUnit.status);
              i++;
            }
          }
          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get ad unit. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:psmacchia,项目名称:googleads-dotnet-lib,代码行数:38,代码来源:GetAllAdUnits.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 ContentService.
              ContentService contentService =
              (ContentService) user.GetService(DfpService.v201403.ContentService);

              // Set defaults for page and filterStatement.
              ContentPage page = new ContentPage();
              Statement filterStatement = new Statement();
              int offset = 0;

              try {
            do {
              // Create a statement to get all content.
              filterStatement.query = "LIMIT 500 OFFSET " + offset.ToString();

              // Get content by statement.
              page = contentService.getContentByStatement(filterStatement);

              if (page.results != null) {
            int i = page.startIndex;
            foreach (Content content in page.results) {
              Console.WriteLine("{0}) Content with ID \"{1}\", name \"{2}\", and status \"{3}\" " +
                  "was found.", i, content.id, content.name, content.status);
              i++;
            }
              }
              offset += 500;
            } while (offset < page.totalResultSetSize);

            Console.WriteLine("Number of results found: " + page.totalResultSetSize);
              } catch (Exception ex) {
            Console.WriteLine("Failed to get all content. Exception says \"{0}\"", ex.Message);
              }
        }
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:39,代码来源:GetAllContent.cs

示例9: Run

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

              // Set the IDs of the user and team to get the association for.
              long userId = long.Parse(_T("INSERT_USER_ID_HERE"));
              long teamId = long.Parse(_T("INSERT_TEAM_ID_HERE"));

              try {
            // Get the user team association.
            UserTeamAssociation userTeamAssociation = userTeamAssociationService.getUserTeamAssociation(
            teamId, userId);

            if (userTeamAssociation != null) {
              Console.WriteLine("User team association between user with ID \"{0}\" and team with " +
              "ID \"{1}\" was found.", userTeamAssociation.userId, userTeamAssociation.teamId);
            } else {
              Console.WriteLine("No user team association found.");
            }
              } catch (Exception ex) {
            Console.WriteLine("Failed to get user team associations. Exception says \"{0}\"",
            ex.Message);
              }
        }
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:31,代码来源:GetUserTeamAssociation.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) {
      // Create the CreativeWrapperService.
      CreativeWrapperService creativeWrapperService = (CreativeWrapperService) user.GetService(
          DfpService.v201502.CreativeWrapperService);

      long creativeWrapperId = long.Parse(_T("INSERT_CREATIVE_WRAPPER_ID_HERE"));

      try {
        StatementBuilder statementBuilder = new StatementBuilder()
            .Where("id = :id")
            .OrderBy("id ASC")
            .Limit(1)
            .AddValue("id", creativeWrapperId);
        CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(
            statementBuilder.ToStatement());
        CreativeWrapper wrapper = page.results[0];

        wrapper.ordering = CreativeWrapperOrdering.OUTER;
        // Update the creative wrappers on the server.
        CreativeWrapper[] creativeWrappers = creativeWrapperService.updateCreativeWrappers(
            new CreativeWrapper[] {wrapper});

        // Display results.
        foreach (CreativeWrapper createdCreativeWrapper in creativeWrappers) {
          Console.WriteLine("Creative wrapper with ID '{0}' and wrapping order '{1}' was " +
              "updated.", createdCreativeWrapper.id, createdCreativeWrapper.ordering);
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to update creative wrappers. Exception says \"{0}\"",
            ex.Message);
      }
    }
开发者ID:everlive,项目名称:googleads-dotnet-lib,代码行数:36,代码来源:UpdateCreativeWrappers.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 TeamService.
      TeamService teamService = (TeamService) user.GetService(DfpService.v201208.TeamService);

      // Create a statement to order teams by name.
      Statement filterStatement = new StatementBuilder("ORDER BY name LIMIT 500").ToStatement();

      try {
      // Get teams by statement.
      TeamPage page = teamService.getTeamsByStatement(filterStatement);

      // Display results.
      if (page.results != null) {
        int i = page.startIndex;
        foreach (Team team in page.results) {
          Console.WriteLine("{0}) Team with ID \"{1}\" and name \"{2}\" was found.",
              i, team.id, team.name);
          i++;
        }
      }

      Console.WriteLine("Number of results found: " + page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get teams by statement. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:hoodapecan,项目名称:googleads-dotnet-lib,代码行数:30,代码来源:GetTeamsByStatement.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 AudienceSegmentService.
      AudienceSegmentService audienceSegmentService =
          (AudienceSegmentService) user.GetService(DfpService.v201306.AudienceSegmentService);

      // Set defaults for page and Statement.
      AudienceSegmentPage page = new AudienceSegmentPage();
      Statement statement = new Statement();
      int offset = 0;

      try {
        do {
          // Create a Statement to get all creatives.
          statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);

          // Get audience segment by Statement.
          page = audienceSegmentService.getAudienceSegmentsByStatement(statement);

          // Display results.
          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (AudienceSegment segment in page.results) {
              Console.WriteLine("{0}) 'Audience segment with id \"{1}\" and name \"{2}\" was " +
                  "found.", i, segment.id, segment.name);
              i++;
            }
          }

          offset += 500;
        } while (offset < page.totalResultSetSize);
        Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get audience segment. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:39,代码来源:GetAllAudienceSegments.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 UserService.
      UserService userService = (UserService) user.GetService(DfpService.v201403.UserService);

      // Create a Statement to get all active users sorted by name.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("status = :status")
          .OrderBy("name ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .AddValue("status", "ACTIVE");

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

      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 usr in page.results) {
              Console.WriteLine("{0}) User with ID = '{1}', email = '{2}', and role = '{3}'" +
                " was found.", i, usr.id, usr.email, usr.roleName);
            }
          }
          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);
        Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get user by ID. Exception says \"{0}\"",
            ex.Message);
      }
    }
开发者ID:hoodapecan,项目名称:googleads-dotnet-lib,代码行数:38,代码来源:GetUsersByStatement.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) {
      // Get the LineItemService.
      LineItemService lineItemService =
          (LineItemService) user.GetService(DfpService.v201311.LineItemService);

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

      // Create a statement to only select line items that need creatives from a
      // given order.
      Statement filterStatement =
          new StatementBuilder("WHERE orderId = :orderId AND status = :status LIMIT 500")
              .AddValue("orderId", orderId)
              .AddValue("status", ComputedStatus.NEEDS_CREATIVES.ToString())
              .ToStatement();

      try {
        // Get line items by Statement.
        LineItemPage page = lineItemService.getLineItemsByStatement(filterStatement);

        if (page.results != null && page.results.Length > 0) {
          int i = page.startIndex;
          foreach (LineItem lineItem in page.results) {
            Console.WriteLine("{0}) Line item with ID ='{1}', belonging to order ID = '{2}' and " +
                 "named '{3}' was found.", i, lineItem.id, lineItem.orderId, lineItem.name);
            i++;
          }
        }
        Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get line item by Statement. Exception says \"{0}\"",
            ex.Message);
      }
    }
开发者ID:hoodapecan,项目名称:googleads-dotnet-lib,代码行数:38,代码来源:GetLineItemsByStatement.cs

示例15: 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 CreativeService.
      CreativeService creativeService =
          (CreativeService) user.GetService(DfpService.v201211.CreativeService);

      // Set defaults for page and Statement.
      CreativePage page = new CreativePage();
      Statement statement = new Statement();
      int offset = 0;

      try {
        do {
          // Create a Statement to get all creatives.
          statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);

          // Get creatives by Statement.
          page = creativeService.getCreativesByStatement(statement);

          if (page.results != null && page.results.Length > 0) {
            int i = page.startIndex;
            foreach (Creative creative in page.results) {
              Console.WriteLine("{0}) Creative with ID ='{1}', name ='{2}' and type ='{3}' " +
                  "was found.", i, creative.id, creative.name, creative.CreativeType);
              i++;
            }
          }

          offset += 500;
        } while (offset < page.totalResultSetSize);

        Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get all creatives. Exception says \"{0}\"", ex.Message);
      }
    }
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:39,代码来源:GetAllCreatives.cs


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