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


C# DfareportingService类代码示例

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


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

示例1: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
      long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      string pathToImageAssetFile = _T("INSERT_PATH_TO_IMAGE_ASSET_FILE_HERE");

      Creative creative = new Creative();
      creative.AdvertiserId = advertiserId;
      creative.Name = "Test image creative";
      creative.Size = new Size() { Id = sizeId };
      creative.Type = "IMAGE";

      // Upload the image asset.
      CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
      CreativeAssetId imageAssetId = assetUtils.uploadAsset(pathToImageAssetFile, "IMAGE");

      CreativeAsset imageAsset = new CreativeAsset();
      imageAsset.AssetIdentifier = imageAssetId;
      imageAsset.Role = "PRIMARY";

      // Add the creative assets.
      creative.CreativeAssets = new List<CreativeAsset>() { imageAsset };

      Creative result = service.Creatives.Insert(creative, profileId).Execute();

      // Display the new creative ID.
      Console.WriteLine("Image creative with ID {0} was created.", result.Id);
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:34,代码来源:CreateImageCreative.cs

示例2: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_PROFILE_ID_HERE"));

              // Limit the fields returned.
              String fields = "nextPageToken,changeLogs(action,fieldName,oldValue,newValue)";

              ChangeLogsListResponse changeLogs;
              String nextPageToken = null;

              do {
            // Create and execute the change logs list request
            ChangeLogsResource.ListRequest request = service.ChangeLogs.List(profileId);
            request.ObjectIds = advertiserId.ToString();
            request.ObjectType = ChangeLogsResource.ListRequest.ObjectTypeEnum.OBJECTADVERTISER;
            request.Fields = fields;
            request.PageToken = nextPageToken;
            changeLogs = request.Execute();

            foreach (ChangeLog changeLog in changeLogs.ChangeLogs) {
              Console.WriteLine("{0}: Field \"{1}\" from \"{2}\" to \"{3}\".",
              changeLog.Action, changeLog.FieldName, changeLog.OldValue,
              changeLog.NewValue);
            }

            // Update the next page token.
            nextPageToken = changeLogs.NextPageToken;
              } while (changeLogs.ChangeLogs.Any() && !String.IsNullOrEmpty(nextPageToken));
        }
开发者ID:Gereltuya,项目名称:googleads-dfa-reporting-samples,代码行数:35,代码来源:GetChangeLogsForAdvertiser.cs

示例3: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long campaignId = long.Parse(_T("ENTER_CAMPAIGN_ID_HERE"));
      long placementId = long.Parse(_T("ENTER_PLACEMENT_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      // Generate the placement activity tags.
      PlacementsResource.GeneratetagsRequest request =
          service.Placements.Generatetags(profileId);
      request.CampaignId = campaignId;
      request.TagFormats =
          PlacementsResource.GeneratetagsRequest.TagFormatsEnum.PLACEMENTTAGSTANDARD;
      request.PlacementIds = placementId.ToString();

      PlacementsGenerateTagsResponse response = request.Execute();

      // Display the placement activity tags.
      foreach (PlacementTag tag in response.PlacementTags) {
        foreach (TagData tagData in tag.TagDatas) {
          Console.WriteLine("{0}:\n", tagData.Format);

          if (tagData.ImpressionTag != null) {
            Console.WriteLine(tagData.ImpressionTag);
          }

          if (tagData.ClickTag != null) {
            Console.WriteLine(tagData.ClickTag);
          }

          Console.WriteLine();
        }
      }
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:37,代码来源:DownloadPlacementTags.cs

示例4: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      // Limit the fields returned.
      String fields = "nextPageToken,placementStrategies(id,name)";

      PlacementStrategiesListResponse strategies;
      String nextPageToken = null;

      do {
        // Create and execute the placement strategies list request
        PlacementStrategiesResource.ListRequest request =
            service.PlacementStrategies.List(profileId);
        request.Fields = fields;
        request.PageToken = nextPageToken;
        strategies = request.Execute();

        foreach (PlacementStrategy strategy in strategies.PlacementStrategies) {
          Console.WriteLine("Found placement strategy with ID {0} and name \"{1}\".",
              strategy.Id, strategy.Name);
        }

        // Update the next page token
        nextPageToken = strategies.NextPageToken;
      } while (strategies.PlacementStrategies.Any() && !String.IsNullOrEmpty(nextPageToken));
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:31,代码来源:GetPlacementStrategies.cs

示例5: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long profileId = long.Parse(_T("INSERT_PROFILE_ID_HERE"));

      // Limit the fields returned.
      String fields = "nextPageToken,campaigns(id,name)";

      CampaignsListResponse campaigns;
      String nextPageToken = null;

      do {
        // Create and execute the campaigns list request.
        CampaignsResource.ListRequest request =  service.Campaigns.List(profileId);
        request.Fields = fields;
        request.PageToken = nextPageToken;
        campaigns = request.Execute();

        foreach (Campaign campaign in campaigns.Campaigns) {
          Console.WriteLine("Campaign with ID {0} and name \"{1}\" was found.",
              campaign.Id, campaign.Name);
        }

        // Update the next page token.
        nextPageToken = campaigns.NextPageToken;
      } while (campaigns.Campaigns.Any() && !String.IsNullOrEmpty(nextPageToken));
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:30,代码来源:GetCampaigns.cs

示例6: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long profileId = long.Parse(_T("INSERT_PROFILE_ID_HERE"));

      // Limit the fields returned.
      String fields = "nextPageToken,userRoles(accountId,id,name,subaccountId)";

      UserRolesListResponse roles;
      String nextPageToken = null;

      do {
        // Create and execute the user roles list request.
        UserRolesResource.ListRequest request = service.UserRoles.List(profileId);
        request.Fields = fields;
        request.PageToken = nextPageToken;

        roles = request.Execute();

        foreach (UserRole role in roles.UserRoles) {
          Console.WriteLine("User role with ID {0} and name \"{1}\" was found.", role.Id,
              role.Name);
        }

        // Update the next page token.
        nextPageToken = roles.NextPageToken;
      } while (roles.UserRoles.Any() && !String.IsNullOrEmpty(nextPageToken));
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:31,代码来源:GetUserRoles.cs

示例7: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long parentUserRoleId = long.Parse(_T("INSERT_PARENT_USER_ROLE_ID_HERE"));
      long permission1Id = long.Parse(_T("INSERT_FIRST_PERMISSION_ID_HERE"));
      long permission2Id = long.Parse(_T("INSERT_SECOND_PERMISSIONS_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_PROFILE_ID_HERE"));
      long subaccountId = long.Parse(_T("INSERT_SUBACCOUNT_ID_HERE"));

      String userRoleName = _T("INSERT_USER_ROLE_NAME_HERE");

      // Create user role structure.
      UserRole userRole = new UserRole();
      userRole.Name = userRoleName;
      userRole.SubaccountId = subaccountId;
      userRole.ParentUserRoleId = parentUserRoleId;

      // Create a permission object to represent each permission this user role
      // has.
      UserRolePermission permission1 = new UserRolePermission();
      permission1.Id = permission1Id;
      UserRolePermission permission2 = new UserRolePermission();
      permission2.Id = permission2Id;
      List<UserRolePermission> permissions =
          new List<UserRolePermission> { permission1, permission2 };

      // Add the permissions to the user role.
      userRole.Permissions = permissions;

      // Create user role.
      UserRole result = service.UserRoles.Insert(userRole, profileId).Execute();

      // Display user role ID.
      Console.WriteLine("User role with ID {0} was created.", result.Id);
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:38,代码来源:CreateUserRole.cs

示例8: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string videoAssetName = _T("INSERT_VIDEO_ASSET_NAME_HERE");
              string pathToVideoAssetFile = _T("INSERT_PATH_TO_VIDEO_ASSET_FILE_HERE");

              Creative creative = new Creative();
              creative.AdvertiserId = advertiserId;
              creative.Name = "Test in-stream video creative";
              creative.Type = "INSTREAM_VIDEO";

              // Upload the video asset.
              CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
              CreativeAssetId videoAssetId = assetUtils.uploadAsset(pathToVideoAssetFile, "VIDEO");

              CreativeAsset videoAsset = new CreativeAsset();
              videoAsset.AssetIdentifier = videoAssetId;
              videoAsset.Role = "PARENT_VIDEO";

              // Add the creative assets.
              creative.CreativeAssets = new List<CreativeAsset>() { videoAsset };

              Creative result = service.Creatives.Insert(creative, profileId).Execute();

              // Display the new creative ID.
              Console.WriteLine("In-stream video creative with ID {0} was created.", result.Id);
        }
开发者ID:Gereltuya,项目名称:googleads-dfa-reporting-samples,代码行数:34,代码来源:CreateInstreamVideoCreative.cs

示例9: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long reportId = long.Parse(_T("ENTER_REPORT_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      // Retrieve the specified report.
      Report report = service.Reports.Get(profileId, reportId).Execute();

      // Look up the compatible fields for the report.
      CompatibleFields fields =
          service.Reports.CompatibleFields.Query(report, profileId).Execute();

      // Display the compatible fields, assuming this is a standard report.
      ReportCompatibleFields reportFields = fields.ReportCompatibleFields;

      Console.WriteLine("Compatible dimensions:\n");
      printDimensionNames(reportFields.Dimensions);

      Console.WriteLine("\nCompatible metrics:\n");
      printMetricNames(reportFields.Metrics);

      Console.WriteLine("\nCompatible dimension filters:\n");
      printDimensionNames(reportFields.DimensionFilters);

      Console.WriteLine("\nCompatible pivoted activity metrics:\n");
      printMetricNames(reportFields.PivotedActivityMetrics);
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:31,代码来源:GetCompatibleFields.cs

示例10: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long campaignId = long.Parse(_T("INSERT_CAMPAIGN_ID_HERE"));
              long dfaSiteId = long.Parse(_T("INSERT_SITE_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              string placementGroupName = _T("INSERT_PLACEMENT_GROUP_NAME_HERE");

              // Retrieve the campaign.
              Campaign campaign = service.Campaigns.Get(profileId, campaignId).Execute();

              // Create a pricing schedule.
              PricingSchedule pricingSchedule = new PricingSchedule();
              pricingSchedule.EndDate = campaign.EndDate;
              pricingSchedule.PricingType = "PRICING_TYPE_CPM";
              pricingSchedule.StartDate = campaign.StartDate;

              // Create the placement group.
              PlacementGroup placementGroup = new PlacementGroup();
              placementGroup.CampaignId = campaignId;
              placementGroup.Name = placementGroupName;
              placementGroup.PlacementGroupType = "PLACEMENT_PACKAGE";
              placementGroup.PricingSchedule = pricingSchedule;
              placementGroup.SiteId = dfaSiteId;

              // Insert the placement.
              PlacementGroup result =
              service.PlacementGroups.Insert(placementGroup, profileId).Execute();

              // Display the new placement ID.
              Console.WriteLine("Placement group with ID {0} was created.", result.Id);
        }
开发者ID:tsidell,项目名称:googleads-dfa-reporting-samples,代码行数:37,代码来源:CreatePlacementGroup.cs

示例11: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long reportId = long.Parse(_T("INSERT_REPORT_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      // Limit the fields returned.
      String fields = "nextPageToken,items(fileName,id,status)";

      FileList files;
      String nextPageToken = null;

      do {
        // Create and execute the report files list request.
        ReportsResource.FilesResource.ListRequest request =
            service.Reports.Files.List(profileId, reportId);
        request.Fields = fields;
        request.PageToken = nextPageToken;
        files = request.Execute();

        foreach (File file in files.Items) {
          Console.WriteLine("Report file with ID {0} and file name \"{1}\" has status \"{2}\".",
              file.Id, file.FileName, file.Status);
        }

        // Update the next page token.
        nextPageToken = files.NextPageToken;
      } while (files.Items.Any() && !String.IsNullOrEmpty(nextPageToken));
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:32,代码来源:GetReportFiles.cs

示例12: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
              long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              String campaignName = _T("INSERT_CAMPAIGN_NAME_HERE");
              String landingPageName = _T("INSERT_LANDING_PAGE_NAME_HERE");
              String url = _T("INSERT_LANDING_PAGE_URL_HERE");

              // Create the campaign structure.
              Campaign campaign = new Campaign();
              campaign.Name = campaignName;
              campaign.AdvertiserId = advertiserId;
              campaign.Archived = false;

              // Set the campaign start date. This example uses today's date.
              campaign.StartDate =
              DfaReportingDateConverterUtil.convertToDateString(DateTime.Now);

              // Set the campaign end date. This example uses one month from today's date.
              campaign.EndDate =
              DfaReportingDateConverterUtil.convertToDateString(DateTime.Now.AddMonths(1));

              // Insert the campaign.
              Campaign result =
              service.Campaigns.Insert(campaign, profileId, landingPageName, url).Execute();

              // Display the new campaign ID.
              Console.WriteLine("Campaign with ID {0} was created.", result.Id);
        }
开发者ID:tsidell,项目名称:googleads-dfa-reporting-samples,代码行数:35,代码来源:CreateCampaign.cs

示例13: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long profileId = long.Parse(_T("INSERT_PROFILE_ID_HERE"));

      // Limit the fields returned.
      String fields = "nextPageToken,advertisers(id,floodlightConfigurationId,name)";

      AdvertisersListResponse result;
      String nextPageToken = null;

      do {
        // Create and execute the advertiser list request.
        AdvertisersResource.ListRequest request = service.Advertisers.List(profileId);
        request.Fields = fields;
        request.PageToken = nextPageToken;
        result = request.Execute();

        foreach (Advertiser advertiser in result.Advertisers) {
          Console.WriteLine("Advertiser with ID {0}, name \"{1}\", and" +
              " floodlight configuration ID {2} was found.", advertiser.Id,
              advertiser.Name, advertiser.FloodlightConfigurationId);
        }

        // Update the next page token.
        nextPageToken = result.NextPageToken;
      } while (result.Advertisers.Any() && !String.IsNullOrEmpty(nextPageToken));
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:31,代码来源:GetAdvertisers.cs

示例14: Run

    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long advertiserId = long.Parse(_T("ENTER_ADVERTISER_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_PROFILE_ID_HERE"));

      // Limit the fields returned.
      String fields = "nextPageToken,creatives(id,name,type)";

      CreativesListResponse creatives;
      String nextPageToken = null;

      do {
        // Create and execute the campaigns list request.
        CreativesResource.ListRequest request = service.Creatives.List(profileId);
        request.Active = true;
        request.AdvertiserId = advertiserId;
        request.Fields = fields;
        request.PageToken = nextPageToken;
        creatives = request.Execute();

        foreach (Creative creative in creatives.Creatives) {
          Console.WriteLine("Found {0} creative with ID {1} and name \"{2}\".",
              creative.Type, creative.Id, creative.Name);
        }

        // Update the next page token.
        nextPageToken = creatives.NextPageToken;
      } while (creatives.Creatives.Any() && !String.IsNullOrEmpty(nextPageToken));
    }
开发者ID:bigTdiablo,项目名称:googleads-dfa-reporting-samples,代码行数:33,代码来源:GetCreatives.cs

示例15: Run

        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

              // Limit the fields returned.
              String fields = "nextPageToken,placements(campaignId,id,name)";

              PlacementsListResponse placements;
              String nextPageToken = null;

              do {
            // Create and execute the placements list request
            PlacementsResource.ListRequest request = service.Placements.List(profileId);
            request.Fields = fields;
            request.PageToken = nextPageToken;
            placements = request.Execute();

            foreach (Placement placement in placements.Placements) {
              Console.WriteLine(
              "Placement with ID {0} and name \"{1}\" is associated with campaign ID {2}.",
              placement.Id, placement.Name, placement.CampaignId);
            }

            // Update the next page token
            nextPageToken = placements.NextPageToken;
              } while (placements.Placements.Any() && !String.IsNullOrEmpty(nextPageToken));
        }
开发者ID:Gereltuya,项目名称:googleads-dfa-reporting-samples,代码行数:32,代码来源:GetPlacements.cs


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