/// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The Dfa user object running the code example.
    /// </param>
    public override void Run(DfaUser user) {
      // Create PlacementRemoteService instance.
      PlacementRemoteService service = (PlacementRemoteService) user.GetService(
          DfaService.v1_19.PlacementRemoteService);
      string placementName = _T("INSERT_PLACEMENT_NAME_HERE");
      long dfaSiteId = long.Parse(_T("INSERT_DFA_SITE_ID_HERE"));
      long campaignId = long.Parse(_T("INSERT_CAMPAIGN_ID_HERE"));
      int pricingType = int.Parse(_T("INSERT_PRICING_TYPE_HERE"));
      int placementType = int.Parse(_T("INSERT_PLACEMENT_TYPE_HERE"));
      long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE"));

      // Create placement structure.
      Placement placement = new Placement();
      placement.id = 0;
      placement.name = placementName;
      placement.campaignId = campaignId;
      placement.dfaSiteId = dfaSiteId;
      placement.sizeId = sizeId;

      // Set pricing schedule for placement.
      PricingSchedule pricingSchedule = new PricingSchedule();
      pricingSchedule.startDate = DateTime.Now;
      pricingSchedule.endDate = DateTime.Now.AddMonths(1);
      pricingSchedule.pricingType = pricingType;
      placement.pricingSchedule = pricingSchedule;

      // Set placement type.
      placement.placementType = placementType;

      try {
        // Set placement tag settings.
        TagSettings tagSettings = new TagSettings();
        PlacementTagOption[] placementTagOptions = service.getRegularPlacementTagOptions();
        int[] tagTypes = new int[placementTagOptions.Length];

        for (int i = 0; i < placementTagOptions.Length; i++) {
          tagTypes[i] = (int) placementTagOptions[i].id;
        }

        tagSettings.tagTypes = tagTypes;
        placement.tagSettings = tagSettings;

        // Create the placement.
        PlacementSaveResult placementSaveResult = service.savePlacement(placement);

        // Display new placment id.
        Console.WriteLine("Placment with id \"{0}\" was created.", placementSaveResult.id);
      } catch (Exception ex) {
        Console.WriteLine("Failed to create placement. Exception says \"{0}\"", ex.Message);
      }
    }
Esempio n. 2
0
 public PlacementSaveResult savePlacement(Placement placement) {
   object[] results = this.Invoke("savePlacement", new object[] {placement});
   return ((PlacementSaveResult) (results[0]));
 }