/// <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_20.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); } }
/// <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_20.PlacementRemoteService); long campaignId = long.Parse(_T("INSERT_CAMPAIGN_ID_HERE")); long placementId = long.Parse(_T("INSERT_PLACEMENT_ID_HERE")); // Set placement tag search criteria. PlacementTagCriteria placementTagCriteria = new PlacementTagCriteria(); placementTagCriteria.id = placementId; try { // Get placement tag options. PlacementTagOption[] placementTagOptions = service.getRegularPlacementTagOptions(); long[] tagOptionIds = new long[placementTagOptions.Length]; // Add all types of tags to the tag option structure. for (int i = 0; i < placementTagOptions.Length; i++) { tagOptionIds[i] = placementTagOptions[i].id; } placementTagCriteria.tagOptionIds = tagOptionIds; // Get HTML tags for the placements. PlacementTagData placementTagData = service.getPlacementTagData(campaignId, new PlacementTagCriteria[] { placementTagCriteria }); // Display tags for the placement id used as criteria. PlacementTagInfo temp = placementTagData.placementTagInfos[0]; Console.WriteLine("Placement name : {0}\nIframe/JavaScript tag : {1}\nStandard tag : {2}" + "\nInternal Redirect tag : {3}", temp.placement.name, temp.iframeJavaScriptTag, temp.javaScriptTag, temp.internalRedirectTag); } catch (Exception ex) { Console.WriteLine("Failed to download tags. Exception says \"{0}\"", ex.Message); } }