本文整理汇总了C#中Google.Api.Ads.Dfa.Lib.DfaUser.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# DfaUser.GetService方法的具体用法?C# DfaUser.GetService怎么用?C# DfaUser.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.Api.Ads.Dfa.Lib.DfaUser
的用法示例。
在下文中一共展示了DfaUser.GetService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <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 mobileAssetFileName = _T("INSERT_MOBILE_ASSET_FILE_NAME_HERE");
long typeId = long.Parse(_T("INSERT_TYPE_ID_HERE"));
// Set mobile display creative structure.
MobileDisplayCreative mobileDisplayCreative = new MobileDisplayCreative();
mobileDisplayCreative.advertiserId = advertiserId;
mobileDisplayCreative.name = creativeName;
mobileDisplayCreative.typeId = typeId;
mobileDisplayCreative.archived = false;
// Set mobile creative asset.
HTMLCreativeAsset htmlCreativeAsset = new MobileDisplayCreativeAsset();
htmlCreativeAsset.assetFilename = mobileAssetFileName;
mobileDisplayCreative.creativeAssets = new HTMLCreativeAsset[] {htmlCreativeAsset};
try {
// Create mobile display creative.
CreativeSaveResult creativeSaveResult = service.saveCreative(mobileDisplayCreative, 0);
// Display new creative id.
Console.WriteLine("Mobile display creative with id \"{0}\" was created.",
creativeSaveResult.id);
} catch (Exception ex) {
Console.WriteLine("Failed to create display creative. Exception says \"{0}\"",
ex.Message);
}
}
示例2: Run
/// <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"));
string assetName = _T("INSERT_SWF_ASSET_NAME_HERE");
string pathToFile = _T("INSERT_PATH_TO_SWF_FILE_HERE");
// Set HTML asset Structure.
CreativeAsset swfAsset = new CreativeAsset();
// Set it to true if this asset is being used for HTML creative.
swfAsset.forHTMLCreatives = true;
swfAsset.advertiserId = advertiserId;
swfAsset.content = MediaUtilities.GetAssetDataFromUrl(new Uri(pathToFile));
swfAsset.name = assetName;
try {
//Create asset.
CreativeAssetSaveResult result = service.saveCreativeAsset(swfAsset);
// Display asset file name.
Console.WriteLine("Asset was saved with file name of \"{0}\".", result.savedFilename);
} catch (Exception ex) {
Console.WriteLine("Failed to create html asset. Exception says \"{0}\"",
ex.Message);
}
}
示例3: Run
/// <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);
}
}
示例4: Run
/// <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_19.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);
}
}
示例5: Run
/// <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_19.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 ex) {
Console.WriteLine("Failed to get content categories. Exception says \"{0}\"",
ex.Message);
}
}
示例6: Run
/// <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 activityGroupId = long.Parse(_T("INSERT_ACTIVITY_GROUP_ID_HERE"));
long activityTypeId = long.Parse(_T("INSERT_ACTIVITY_TYPE_ID_HERE"));
long tagMethodTypeId = long.Parse(_T("INSERT_TAG_METHOD_TYPE_ID_HERE"));
long countryId = long.Parse(_T("INSERT_COUNTRY_ID_HERE"));
string url = _T("INSERT_EXPECTED_URL_HERE");
string activityName = _T("INSERT_ACTIVITY_NAME_HERE");
// Set spotlight activity structure.
SpotlightActivity spotActivity = new SpotlightActivity();
spotActivity.id = 0;
spotActivity.activityGroupId = activityGroupId;
spotActivity.activityTypeId = activityTypeId;
spotActivity.tagMethodTypeId = tagMethodTypeId;
spotActivity.name = activityName;
spotActivity.expectedUrl = url;
spotActivity.countryId = countryId;
try {
// Create the spotlight tag activity.
SpotlightActivitySaveResult result = service.saveSpotlightActivity(spotActivity);
// Display new spotlight activity id.
if (result != null) {
Console.WriteLine("Spotlight activity with id \"{0}\" was created.", result.id);
}
} catch (Exception ex) {
Console.WriteLine("Failed to create spotlight activity. Exception says \"{0}\"",
ex.Message);
}
}
示例7: Run
/// <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);
}
}
示例8: Run
/// <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 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 e) {
Console.WriteLine("Failed to retrieve placements. Exception says \"{0}\"", e.Message);
}
}
示例9: Run
/// <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);
}
}
示例10: Run
/// <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);
}
}
示例11: Run
/// <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);
}
}
示例12: Run
/// <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 advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
// Set activity group search criteria structure and
// use advertiser id as search criteria.
SpotlightActivityGroupSearchCriteria activityGroupSearchCriteria =
new SpotlightActivityGroupSearchCriteria();
activityGroupSearchCriteria.advertiserId = advertiserId;
try {
// Get activity group.
SpotlightActivityGroupRecordSet recordSet =
service.getSpotlightActivityGroups(activityGroupSearchCriteria);
// Display activity group names and ids.
if (recordSet.records != null) {
foreach (SpotlightActivityGroup result in recordSet.records) {
Console.WriteLine("Activity group with name \"{0}\" and id \"{1}\" was found.",
result.name, result.id);
}
} else {
Console.WriteLine("No activity groups found for your criteria.");
}
} catch (Exception ex) {
Console.WriteLine("Failed to retrieve activity groups. Exception says \"{0}\"",
ex.Message);
}
}
示例13: Run
/// <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 SiteRemoteService instance.
SiteRemoteService service = (SiteRemoteService) user.GetService(
DfaService.v1_19.SiteRemoteService);
String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");
// Create DFA site search criteria structure.
DfaSiteSearchCriteria searchCriteria = new DfaSiteSearchCriteria();
searchCriteria.pageSize = 10;
searchCriteria.searchString = searchString;
try {
// Get the sites.
DfaSiteRecordSet dfaSiteRecordSet = service.getDfaSites(searchCriteria);
// Display DFA site names and ids.
if (dfaSiteRecordSet != null && dfaSiteRecordSet.records != null) {
foreach (DfaSite dfaSite in dfaSiteRecordSet.records) {
Console.WriteLine("DFA site with name \"{0}\" and id \"{1}\" was found.",
dfaSite.name, dfaSite.id);
}
} else {
Console.WriteLine("No DFA sites found for your search criteria.");
}
} catch (Exception ex) {
Console.WriteLine("Failed to retrieve DFA sites. Exception says \"{0}\"",
ex.Message);
}
}
示例14: Run
/// <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 searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");
// Create placement strategy search criteria structure.
PlacementStrategySearchCriteria placementStrategySearchCriteria =
new PlacementStrategySearchCriteria();
placementStrategySearchCriteria.pageSize = 10;
placementStrategySearchCriteria.searchString = searchString;
try {
// Get placement strategy record set.
PlacementStrategyRecordSet placementStrategyRecordSet =
service.getPlacementStrategiesByCriteria(placementStrategySearchCriteria);
// Display placement strategy names, ids and descriptions.
if (placementStrategyRecordSet != null && placementStrategyRecordSet.records != null) {
foreach (PlacementStrategy strategy in placementStrategyRecordSet.records) {
Console.WriteLine("Placement Strategy with name \"{0}\" and id \"{1}\" was found.",
strategy.name, strategy.id);
}
} else {
Console.WriteLine("No placement strategies found for your criteria.");
}
} catch (Exception e) {
Console.WriteLine("Failed to retrieve placement strategies. Exception says \"{0}\"",
e.Message);
}
}
示例15: Run
/// <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);
String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE");
// Set up creative field search criteria structure.
CreativeFieldSearchCriteria creativeFieldSearchCriteria = new CreativeFieldSearchCriteria();
creativeFieldSearchCriteria.pageSize = 10;
creativeFieldSearchCriteria.searchString = searchString;
try {
// Get creative fields for the selected criteria.
CreativeFieldRecordSet creativeFields =
service.getCreativeFields(creativeFieldSearchCriteria);
// Display creative field names, ids, advertiser ids, and number of values.
if (creativeFields != null && creativeFields.records != null) {
foreach (CreativeField creativeField in creativeFields.records) {
Console.WriteLine("Creative field with name \"{0}\", id \"{1}\", Advertiser id " +
"\"{2}\", and containing \"{3}\" values was found.", creativeField.name,
creativeField.id, creativeField.advertiserId, creativeField.totalNumberOfValues);
}
} else {
Console.WriteLine("No creative fields found for your search criteria");
}
} catch (Exception ex) {
Console.WriteLine("Failed to retrieve creative fields. Exception says \"{0}\"",
ex.Message);
}
}