/// <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 CreativeFieldRemoteService instance. CreativeFieldRemoteService service = (CreativeFieldRemoteService)user.GetService( DfaService.v1_20.CreativeFieldRemoteService); long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE")); string creativeFieldName = _T("INSERT_CREATIVE_FIELD_NAME_HERE"); // Create creative field structure. CreativeField creativeField = new CreativeField(); creativeField.id = -1; creativeField.name = creativeFieldName; creativeField.advertiserId = advertiserId; try { // Create creative field. CreativeFieldSaveResult creativeFieldSaveResult = service.saveCreativeField(creativeField); // Display creative field id. Console.WriteLine("Creative field with id \"{0}\" was created.", creativeFieldSaveResult.id); } catch (Exception ex) { Console.WriteLine("Failed to add creative field. 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 PlacementStrategyRemoteService instance. PlacementStrategyRemoteService service = (PlacementStrategyRemoteService)user.GetService( DfaService.v1_19.PlacementStrategyRemoteService); String placementStrategyName = _T("INSERT_PLACEMENT_STRATEGY_NAME_HERE"); // Create placement strategy structure. PlacementStrategy placementStrategy = new PlacementStrategy(); placementStrategy.id = 0; placementStrategy.name = placementStrategyName; try { // Create placement strategy. PlacementStrategySaveResult placementStrategySaveResult = service.savePlacementStrategy(placementStrategy); if (placementStrategySaveResult != null) { // Display placement strategy id. Console.WriteLine("Placement Strategy with id \"{0}\" was created.", placementStrategySaveResult.id); } } catch (Exception e) { Console.WriteLine("Failed to create placement strategy. Exception says \"{0}\"", e.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 SizeRemoteService instance. SizeRemoteService service = (SizeRemoteService)user.GetService( DfaService.v1_20.SizeRemoteService); int width = int.Parse(_T("INSERT_WIDTH_HERE")); int height = int.Parse(_T("INSERT_HEIGHT_HERE")); SizeSearchCriteria criteria = new SizeSearchCriteria(); criteria.width = width; criteria.height = height; try { // Get size. SizeRecordSet sizeRecords = service.getSizes(criteria); if (sizeRecords.records != null) { foreach (Size size in sizeRecords.records) { // Display size id. Console.WriteLine("Size id for \"{0}\" width and \"{1}\" height is \"{2}\".", size.width, size.height, size.id); } } } catch (Exception ex) { Console.WriteLine("Failed to retrieve size. 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 UserRoleRemoteService instance. UserRoleRemoteService service = (UserRoleRemoteService)user.GetService( DfaService.v1_20.UserRoleRemoteService); long subnetworkId = long.Parse(_T("INSERT_SUBNETWORK_ID_HERE")); try { // Get available permissions. Permission[] permissions = service.getAvailablePermissions(subnetworkId); // Display permission name and its id. if (permissions != null) { foreach (Permission permission in permissions) { Console.WriteLine("Permission with name \"{0}\" and id \"{1}\" was found.", permission.name, permission.id); } } } catch (Exception e) { Console.WriteLine("Failed to get permission. Exception says \"{0}\"", e.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 CreativeRemoteService instance. ContentCategoryRemoteService service = (ContentCategoryRemoteService) user.GetService( DfaService.v1_20.ContentCategoryRemoteService); String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Create content category search criteria structure. ContentCategorySearchCriteria searchCriteria = new ContentCategorySearchCriteria(); searchCriteria.pageSize = 10; searchCriteria.searchString = searchString; try { // Get content category record set. ContentCategoryRecordSet contentCategoryRecordSet = service.getContentCategories(searchCriteria); // Display content category names, ids and descriptions. if (contentCategoryRecordSet != null && contentCategoryRecordSet.records != null) { foreach (ContentCategory contentCategory in contentCategoryRecordSet.records) { Console.WriteLine("Content category with name \"{0}\" and id \"{1}\" was found.", contentCategory.name, contentCategory.id); } } else { Console.WriteLine("No content categories found for your search criteria."); } } catch (Exception e) { Console.WriteLine("Failed to get content categories. Exception says \"{0}\"", e.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); String searchString = _T("INSERT_SEARCH_STRING_HERE"); // Set placement search criteria. PlacementSearchCriteria searchCriteria = new PlacementSearchCriteria(); searchCriteria.pageSize = 10; searchCriteria.searchString = searchString; try { // Get placements. PlacementRecordSet placements = service.getPlacementsByCriteria(searchCriteria); // Display placment names and ids. if (placements.records != null) { foreach (Placement result in placements.records) { Console.WriteLine("Placment with name \"{0}\" and id \"{1}\" was found.", result.name, result.id); } } else { Console.WriteLine("No placements found for your criteria"); } } catch (Exception ex) { Console.WriteLine("Failed to retrieve placements. 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 AdvertiserGroupRemoteService instance. AdvertiserGroupRemoteService service = (AdvertiserGroupRemoteService)user.GetService( DfaService.v1_20.AdvertiserGroupRemoteService); string advertiserGroupName = _T("INSERT_ADVERTISER_GROUP_NAME_HERE"); // Create advertiser group structure. AdvertiserGroup advertiserGroup = new AdvertiserGroup(); advertiserGroup.id = 0; advertiserGroup.name = advertiserGroupName; try { // Create advertiser group. AdvertiserGroupSaveResult advertiserGroupSaveResult = service.saveAdvertiserGroup(advertiserGroup); // Display advertiser group id. Console.WriteLine("Advertiser Group with id \"{0}\" was created.", advertiserGroupSaveResult.id); } catch (Exception ex) { Console.WriteLine("Failed to create advertiser group. 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 CampaignRemoteService instance. CampaignRemoteService service = (CampaignRemoteService)user.GetService( DfaService.v1_19.CampaignRemoteService); String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Create campaign search criteria structure. CampaignSearchCriteria searchCriteria = new CampaignSearchCriteria(); searchCriteria.pageSize = 10; searchCriteria.searchString = searchString; try { // Get the campaigns. CampaignRecordSet recordSet = service.getCampaignsByCriteria(searchCriteria); // Display campaign names and ids. if (recordSet.records != null) { foreach (Campaign result in recordSet.records) { Console.WriteLine("Campaign with name \"{0}\" and id \"{1}\" was found.", result.name, result.id); } } else { Console.WriteLine("No campaigns found for your search criteria."); } } catch (Exception ex) { Console.WriteLine("Failed to retrieve campaigns. 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 SubnetworkRemoteService instance. SubnetworkRemoteService service = (SubnetworkRemoteService)user.GetService( DfaService.v1_19.SubnetworkRemoteService); long networkId = long.Parse(_T("INSERT_NETWORK_ID_HERE")); String subnetworkName = _T("INSERT_SUBNETWORK_NAME_HERE"); long permission1 = long.Parse(_T("INSERT_FIRST_PERMISSION_ID_HERE")); long permission2 = long.Parse(_T("INSERT_SECOND_PERMISSION_ID_HERE")); // Create subnetwork structure. Subnetwork subnetwork = new Subnetwork(); subnetwork.id = 0; subnetwork.name = subnetworkName; subnetwork.networkId = networkId; // Create an array of all permissions assigned to this subnetwork and add // it to the subnetwork structure. To get list of available permissions, // run GetAvailablePermissions.cs. subnetwork.availablePermissions = new long[] { permission1, permission2 }; try { // Create subnetwork. SubnetworkSaveResult subnetworkSaveResult = service.saveSubnetwork(subnetwork); // Display subnetwork id. Console.WriteLine("Subnetwork with id \"{0}\" was created.", subnetworkSaveResult.id); } catch (Exception e) { Console.WriteLine("Failed to create subnetwork. Exception says \"{0}\"", e.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 SpotlightRemoteService instance. SpotlightRemoteService service = (SpotlightRemoteService)user.GetService( DfaService.v1_20.SpotlightRemoteService); // Set search criteria. CountrySearchCriteria countrySearchCriteria = new CountrySearchCriteria(); countrySearchCriteria.secure = false; try { // Get countries. Country[] countries = service.getCountriesByCriteria(countrySearchCriteria); // Display country names, codes and secure server support information. if (countries != null) { foreach (Country result in countries) { Console.WriteLine("Country name \"{0}\", country code \"{1}\", supports a secure " + "server? \"{2}\".", result.name, result.id, result.secure); } } } catch (Exception e) { Console.WriteLine("Failed to retrieve countries. Exception says \"{0}\"", e.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 UserRemoteService instance. UserRemoteService service = (UserRemoteService)user.GetService( DfaService.v1_19.UserRemoteService); try { // Get user filter criteria types. UserFilterCriteriaType[] userFilterCriteriaTypes = service.getAvailableUserFilterCriteriaTypes(); // Display user filter criteria types. if (userFilterCriteriaTypes != null) { foreach (UserFilterCriteriaType userFilterCriteriaType in userFilterCriteriaTypes) { Console.WriteLine("User Filter Criteria type with name \"{0}\" and id \"{1}\" " + "was found.", userFilterCriteriaType.name, userFilterCriteriaType.id); } } } catch (Exception ex) { Console.WriteLine("Failed to retrieve user filter and criteria types. 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 ReportRemoteService instance. ReportRemoteService service = (ReportRemoteService)user.GetService( DfaService.v1_19.ReportRemoteService); long queryId = long.Parse(_T("INSERT_QUERY_ID_HERE")); // Create report search criteria object. ReportSearchCriteria reportSearchCriteria = new ReportSearchCriteria(); reportSearchCriteria.queryId = queryId; try { // Get report information. ReportInfoRecordSet reportInfoRecordSet = service.getReportsByCriteria(reportSearchCriteria); // Display information on reports. if (reportInfoRecordSet.records != null && reportInfoRecordSet.records.Length > 0) { foreach (ReportInfo report in reportInfoRecordSet.records) { Console.WriteLine("Report with ID '{0}', status of '{1}' and URL of '{2}' was found.", report.reportId, report.status, report.url); } } else { Console.WriteLine("No reports found for your query ID."); } } catch (Exception ex) { Console.WriteLine("Failed to retrieve all reports. 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 CreativeRemoteService instance. CreativeRemoteService service = (CreativeRemoteService)user.GetService( DfaService.v1_20.CreativeRemoteService); long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE")); // Set up creative search criteria structure. CreativeSearchCriteria creativeSearchCriteria = new CreativeSearchCriteria(); creativeSearchCriteria.pageSize = 10; creativeSearchCriteria.advertiserId = advertiserId; try { // Get creatives for the selected criteria. CreativeRecordSet creatives = service.getCreatives(creativeSearchCriteria); // Display creative name and its id. if (creatives != null && creatives.records != null) { foreach (CreativeBase result in creatives.records) { Console.WriteLine("Creative with name \"{0}\" and id \"{1}\" was found.", result.name, result.id); } } else { Console.WriteLine("No creatives found for your criteria"); } } catch (Exception e) { Console.WriteLine("Failed to retrieve creatives. Exception says \"{0}\"", e.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 AdvertiserRemoteService instance. AdvertiserRemoteService service = (AdvertiserRemoteService)user.GetService( DfaService.v1_20.AdvertiserRemoteService); String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Create advertiser search criteria structure. AdvertiserSearchCriteria advSearchCriteria = new AdvertiserSearchCriteria(); advSearchCriteria.pageSize = 10; advSearchCriteria.searchString = searchString; try { // Get advertiser record set. AdvertiserRecordSet recordSet = service.getAdvertisers(advSearchCriteria); // Display advertiser names, ids and spotlight configuration ids. if (recordSet.records != null) { foreach (Advertiser result in recordSet.records) { Console.WriteLine("Advertiser with name \"{0}\", id \"{1}\", and spotlight " + "configuration id \"{2}\" was found.", result.name, result.id, result.spotId); } } else { Console.WriteLine("No advertisers found for your criteria."); } } catch (Exception ex) { Console.WriteLine("Failed to retrieve advertisers. 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 SpotlightRemoteService instance. SpotlightRemoteService service = (SpotlightRemoteService)user.GetService( DfaService.v1_20.SpotlightRemoteService); long spotlightConfigurationId = long.Parse(_T("INSERT_SPOTLIGHT_CONFIGURATION_ID_HERE")); int activityType = int.Parse(_T("INSERT_ACTIVITY_TYPE_HERE")); string groupName = _T("INSERT_GROUP_NAME_HERE"); // Set spotlight activity group structure. SpotlightActivityGroup spotlightActivityGroup = new SpotlightActivityGroup(); spotlightActivityGroup.id = 0; spotlightActivityGroup.spotlightConfigurationId = spotlightConfigurationId; spotlightActivityGroup.groupType = activityType; spotlightActivityGroup.name = groupName; try { // Create the activity group. SpotlightActivityGroupSaveResult result = service.saveSpotlightActivityGroup( spotlightActivityGroup); // Display activity group id. if (result != null) { Console.WriteLine("Activity group with id \"{0}\" was created.", result.id); } } catch (Exception ex) { Console.WriteLine("Failed to create spotlight activity group. 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 ContentCategoryRemoteService instance. ContentCategoryRemoteService service = (ContentCategoryRemoteService)user.GetService( DfaService.v1_20.ContentCategoryRemoteService); string contentCategoryName = _T("INSERT_CONTENT_CATEGORY_NAME_HERE"); // Create content category structure. ContentCategory contentCategory = new ContentCategory(); contentCategory.id = 0; contentCategory.name = contentCategoryName; try { // Create content category. ContentCategorySaveResult contentCategorySaveResult = service.saveContentCategory(contentCategory); // Display content category id. Console.WriteLine("Content category with id \"{0}\" was created.", contentCategorySaveResult.id); } catch (Exception e) { Console.WriteLine("Failed to add content category. Exception says \"{0}\"", e.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 CreativeFieldRemoteService instance. CreativeFieldRemoteService service = (CreativeFieldRemoteService)user.GetService( DfaService.v1_19.CreativeFieldRemoteService); long creativeFieldId = long.Parse(_T("INSERT_CREATIVE_FIELD_ID_HERE")); String creativeFieldValueName = _T("INSERT_CREATIVE_FIELD_VALUE_NAME_HERE"); // Create creative field value structure. CreativeFieldValue creativeFieldValue = new CreativeFieldValue(); creativeFieldValue.id = -1; creativeFieldValue.name = creativeFieldValueName; creativeFieldValue.creativeFieldId = creativeFieldId; try { // Create creative field value. CreativeFieldValueSaveResult creativeFieldValueSaveResult = service.saveCreativeFieldValue(creativeFieldValue); // Display creative field value id. Console.WriteLine("Creative field value with id \"{0}\" was created.", creativeFieldValueSaveResult.id); } catch (Exception ex) { Console.WriteLine("Failed to add creative field value. 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 AdvertiserRemoteService instance. AdvertiserRemoteService service = (AdvertiserRemoteService)user.GetService( DfaService.v1_19.AdvertiserRemoteService); long networkId = long.Parse(_T("INSERT_NETWORK_ID_HERE")); string advertiserName = _T("INSERT_ADVERTISER_NAME_HERE"); // Create advertiser structure. Advertiser advertiser = new Advertiser(); advertiser.name = advertiserName; advertiser.networkId = networkId; advertiser.id = 0; advertiser.advertiserGroupId = 0; advertiser.approved = true; try { // Create advertiser. AdvertiserSaveResult result = service.saveAdvertiser(advertiser); if (result != null) { // Display advertiser id. Console.WriteLine("Advertiser with id \"{0}\" was created.", result.id); } else { Console.WriteLine("Could not create advertiser for the specified network id."); } } catch (Exception e) { Console.WriteLine("Failed to create advertiser. Exception says \"{0}\"", e.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 CreativeRemoteService instance. CreativeRemoteService service = (CreativeRemoteService)user.GetService( DfaService.v1_19.CreativeRemoteService); long creativeId = long.Parse(_T("INSERT_CREATIVE_ID")); long placementId = long.Parse(_T("INSERT_PLACEMENT_ID")); // Create creative placement assignment structure. CreativePlacementAssignment creativePlacementAssignment = new CreativePlacementAssignment(); creativePlacementAssignment.creativeId = creativeId; creativePlacementAssignment.placementId = placementId; creativePlacementAssignment.placementIds = new long[] { placementId }; try { // Assign creatives to placements. CreativePlacementAssignmentResult[] results = service.assignCreativesToPlacements( new CreativePlacementAssignment[] { creativePlacementAssignment }); // Display new ads that resulted from the assignment. foreach (CreativePlacementAssignmentResult result in results) { Console.WriteLine("Ad with name \"{0}\" and id \"{1}\" was created.", result.adName, result.adId); } } catch (Exception e) { Console.WriteLine("Failed to create ad. Exception says \"{0}\"", e.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 CreateRemoteService instance. CreativeRemoteService service = (CreativeRemoteService)user.GetService( DfaService.v1_19.CreativeRemoteService); long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE")); string assetName = _T("INSERT_MOBILE_ASSET_NAME_HERE"); string pathToFile = _T("INSERT_PATH_TO_MOBILE_ASSET_HERE"); // Set mobile asset structure. CreativeAsset mobileAsset = new CreativeAsset(); mobileAsset.forHTMLCreatives = true; mobileAsset.advertiserId = advertiserId; mobileAsset.content = MediaUtilities.GetAssetDataFromUrl(new Uri(pathToFile)); mobileAsset.name = assetName; try { // Create mobile asset. CreativeAssetSaveResult result = service.saveCreativeAsset(mobileAsset); // Display asset file name. Console.WriteLine("Asset was saved with file name of \"{0}\".", result.savedFilename); } catch (Exception ex) { Console.WriteLine("Failed to create mobile asset. 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 SubnetworkRemoteService instance. SubnetworkRemoteService service = (SubnetworkRemoteService)user.GetService( DfaService.v1_19.SubnetworkRemoteService); String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Set subnetwork search criteria. SubnetworkSearchCriteria searchCriteria = new SubnetworkSearchCriteria(); searchCriteria.pageSize = 10; searchCriteria.searchString = searchString; try { // Get subnetworks. SubnetworkRecordSet subnetworks = service.getSubnetworks(searchCriteria); // Display subnetwork names, ids, and subnetwork ids. if (subnetworks != null && subnetworks.records != null) { foreach (Subnetwork subNetwork in subnetworks.records) { Console.WriteLine("Subnetwork with name \"{0}\", id \"{1}\", and Subnetwork id " + "\"{2}\" was found.", subNetwork.name, subNetwork.id, subNetwork.networkId); } } else { Console.WriteLine("No subnetworks found for your criteria."); } } catch (Exception e) { Console.WriteLine("Failed to retrieve subnetworks. Exception says \"{0}\"", e.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 CreativeGroupRemoteService instance. CreativeGroupRemoteService service = (CreativeGroupRemoteService)user.GetService( DfaService.v1_20.CreativeGroupRemoteService); long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE")); int groupNumber = int.Parse(_T("INSERT_GROUP_NUMBER_HERE")); string creativeGroupName = _T("INSERT_CREATIVE_GROUP_NAME_HERE"); // Create creative group structure. CreativeGroup creativeGroup = new CreativeGroup(); creativeGroup.id = -1; creativeGroup.name = creativeGroupName; creativeGroup.groupNumber = groupNumber; creativeGroup.advertiserId = advertiserId; try { // Create creative group. CreativeGroupSaveResult creativeGroupSaveResult = service.saveCreativeGroup(creativeGroup); // Display new creative group id. Console.WriteLine("Creative group with id \"{0}\" was created.", creativeGroupSaveResult.id); } catch (Exception e) { Console.WriteLine("Failed to create creative group. Exception says \"{0}\"", e.Message); } }
/// <summary> /// Gets the ad types. /// </summary> /// <returns></returns> internal AdType[] GetAdTypes() { // Create AdRemoteService instance. AdRemoteService service = (AdRemoteService)user.GetService( DfaService.v1_20.AdRemoteService); // Get ad types. return(service.getAdTypes()); }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Request the creative service from the service client factory. CreativeRemoteService creativeService = (CreativeRemoteService)user.GetService( DfaService.v1_19.CreativeRemoteService); long creativeId = long.Parse(_T("INSERT_IN_STREAM_VIDEO_CREATIVE_ID_HERE")); try { // Fetch the In-Stream video creative which contains the asset to modify. CreativeBase rawCreative = creativeService.getCreative(creativeId); if (!(rawCreative is InStreamVideoCreative)) { Console.WriteLine("Unable to update creative with ID \"{0}\": not an In-Stream video " + "creative.", creativeId); } else { InStreamVideoCreative inStreamVideoCreative = (InStreamVideoCreative)rawCreative; // Modify the media files, companion ads, and/or non-linear ads. if (inStreamVideoCreative.mediaFiles != null) { foreach (InStreamMediaFile mediaFile in inStreamVideoCreative.mediaFiles) { mediaFile.pickedToServe = !mediaFile.pickedToServe; } } if (inStreamVideoCreative.companionAds != null) { foreach (InStreamCompanionAd companionAd in inStreamVideoCreative.companionAds) { companionAd.altText = companionAd.altText + " Updated."; } } if (inStreamVideoCreative.nonLinearAds != null) { foreach (InStreamNonLinearAd nonLinearAd in inStreamVideoCreative.nonLinearAds) { nonLinearAd.scalable = !nonLinearAd.scalable; } } CreativeSaveResult creativeSaveResult = creativeService.saveCreative(inStreamVideoCreative, 0); Console.WriteLine("Updated the In-Stream assets of In-Stream video creative with ID " + "\"{0}\".", creativeSaveResult.id); } } catch (Exception ex) { Console.WriteLine("Failed to update in-stream assets of in-stream video creative. " + "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); 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 CreativeRemoteService instance. CreativeRemoteService service = (CreativeRemoteService)user.GetService( DfaService.v1_19.CreativeRemoteService); long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE")); String creativeName = _T("INSERT_CREATIVE_NAME_HERE"); String swfAssetFileName = _T("INSERT_SWF_ASSET_FILE_NAME_HERE"); String imgAssetFileName = _T("INSERT_IMG_ASSET_FILE_NAME_HERE"); long sizeId = long.Parse(_T("INSERT_SIZE_ID_HERE")); long typeId = long.Parse(_T("INSERT_TYPE_ID_HERE")); // Create flash inpage structure. FlashInpageCreative flashInpage = new FlashInpageCreative(); flashInpage.typeId = typeId; flashInpage.id = 0; flashInpage.name = creativeName; flashInpage.advertiserId = advertiserId; flashInpage.active = true; flashInpage.codeLocked = true; flashInpage.sizeId = sizeId; // Set parent flash asset structure. HTMLCreativeFlashAsset parentFlashAsset = new HTMLCreativeFlashAsset(); parentFlashAsset.assetFilename = swfAssetFileName; flashInpage.parentFlashAsset = parentFlashAsset; flashInpage.wmode = "opaque"; // Set backup image asset. HTMLCreativeAsset backupImageAsset = new HTMLCreativeAsset(); backupImageAsset.assetFilename = imgAssetFileName; flashInpage.backupImageAsset = backupImageAsset; // Set target window for backup image. TargetWindow backupImageTargetWindow = new TargetWindow(); backupImageTargetWindow.option = "_blank"; flashInpage.backupImageTargetWindow = backupImageTargetWindow; try { // Create flash inpage creative. CreativeSaveResult result = service.saveCreative(flashInpage, 0); // Display new creative id. Console.WriteLine("Flash inpage creative with id \"{0}\" was created.", result.id); } catch (Exception e) { Console.WriteLine("Failed to create advertiser. Exception says \"{0}\"", e.Message); } }
/// <summary> /// Handles the Click event of the btnAdTypes control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="eventArgs">The <see cref="System.EventArgs"/> instance containing /// the event data.</param> protected void OnGetAdTypesButtonClick(object sender, EventArgs eventArgs) { ConfigureUserForOAuth(); try { // Set the username. This is required for the LoginService to work // correctly when authenticating using OAuth2. (user.Config as DfaAppConfig).DfaUserName = txtUserName.Text; // Create AdRemoteService instance. AdRemoteService service = (AdRemoteService)user.GetService( DfaService.v1_20.AdRemoteService); // Get ad types. AdType[] adTypes = service.getAdTypes(); // Display ad type and its id. foreach (AdType result in adTypes) { Console.WriteLine("Ad type with name \"{0}\" and id \"{1}\" was found.", result.name, result.id); } // Display ad types. if (adTypes != null && adTypes.Length > 0) { DataTable dataTable = new DataTable(); dataTable.Columns.AddRange(new DataColumn[] { new DataColumn("Serial No.", typeof(int)), new DataColumn("Id", typeof(long)), new DataColumn("Ad Type", typeof(string)), }); for (int i = 0; i < adTypes.Length; i++) { AdType result = adTypes[i]; DataRow dataRow = dataTable.NewRow(); dataRow.ItemArray = new object[] { i + 1, result.id, result.name }; dataTable.Rows.Add(dataRow); } AdTypeGrid.DataSource = dataTable; AdTypeGrid.DataBind(); } else { Response.Write("No ad types were found."); } } catch (Exception e) { Response.Write(string.Format("Failed to get ad types. Exception says \"{0}\"", e.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 UserRemoteService instance. UserRemoteService service = (UserRemoteService)user.GetService( DfaService.v1_20.UserRemoteService); long userId = long.Parse(_T("INSERT_USER_ID_HERE")); long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE")); // Create and configure a user filter. UserFilter filterToAdd = new UserFilter(); // The following field has been filled in to make a filter that allows a // user to access only the assigned objects. This value was determined // using GetUserFilterTypes.cs. filterToAdd.userFilterCriteriaId = 2; // Because this filter used the criteria type "Assigned" it is necessary // to specify what advertisers this user has access to. This next step // would be skipped for the criteria types "All" and "None". // Create an object filter to represent each object the user has access // to. Since this is an advertiser filter, an object filter represents an // advertiser. The total of object filter objects will need to match the // total of advertisers the user is assigned. ObjectFilter allowedObject = new ObjectFilter(); // Insert the advertiser id of an advertiser assigned to this user. allowedObject.id = advertiserId; // Create any additional object filters that are needed, then add these // settings to the user filter filterToAdd.objectFilters = new ObjectFilter[] { allowedObject }; try { // Retrieve the user who is to be modified. User userToModify = service.getUser(userId); // Add the filter to the user. The following method is specific to // advertiser filters. See the User class documentation for the names of // methods for other filters. userToModify.advertiserUserFilter = filterToAdd; // Save the changes made and display a success message. UserSaveResult userSaveResult = service.saveUser(userToModify); Console.WriteLine("User with id \"{0}\" was modified.", userSaveResult.id); } catch (Exception ex) { Console.WriteLine("Failed to add advertiser user filter. 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 UserRoleRemoteService instance. UserRoleRemoteService service = (UserRoleRemoteService)user.GetService( DfaService.v1_19.UserRoleRemoteService); String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Set user role search criteria. UserRoleSearchCriteria userRoleSearchCriteria = new UserRoleSearchCriteria(); userRoleSearchCriteria.pageSize = 10; userRoleSearchCriteria.searchString = searchString; try { // Get user roles that match the search criteria. UserRoleRecordSet result = service.getUserRoles(userRoleSearchCriteria); // Display user role names, ids, subnetwork ids, number of assigned users, // and assigned permissions. if (result != null && result.userRoles != null) { foreach (UserRole userRole in result.userRoles) { Console.WriteLine("User role with name \"{0}\", id \"{1}\", subnetwork id \"{2}\", " + "and assigned to \"{3}\" users was found.", userRole.name, userRole.id, userRole.subnetworkId, userRole.totalAssignedUsers); if (userRole.permissions != null && userRole.permissions.Length != 0) { Console.WriteLine(" The above user role has the following permissions:"); foreach (Permission permission in userRole.permissions) { Console.WriteLine(" Permission with name \"{0}\" and id \"{1}\".", permission.name, permission.id); } } else { Console.WriteLine(" The above user role has no permissions assigned."); } } } else { Console.WriteLine("No user roles found for your criteria."); } } catch (Exception ex) { Console.WriteLine("Failed to retrieve user roles. Exception says \"{0}\"", ex.Message); } }
/// <summary> /// Main method, to run this code example as a standalone application. /// </summary> /// <param name="args">The command line arguments.</param> public static void Main(string[] args) { if (args.Length != 4) { Console.WriteLine("This program requires 4 command line arguments:"); Console.WriteLine("\t1. DFA username\n\t2. DFA password\n" + "\t3. Query ID number\n\t4. Output filename."); Console.WriteLine("Example usage: RCReport.exe username@dfa password456 " + "12345 report.zip"); } RCReport codeExample = new RCReport(); Console.WriteLine(codeExample.Description); DfaUser user = new DfaUser(); ReportRemoteService reportService = (ReportRemoteService)user.GetService( DfaService.v1_19.ReportRemoteService); LoginRemoteService loginService = (LoginRemoteService)user.GetService( DfaService.v1_19.LoginRemoteService); codeExample.ScheduleAndDownloadReport(loginService, reportService, args[0], args[1], long.Parse(args[2]), args[3]); }