本文整理汇总了C#中Google.Api.Ads.Dfp.Util.v201505.StatementBuilder.ToStatement方法的典型用法代码示例。如果您正苦于以下问题:C# StatementBuilder.ToStatement方法的具体用法?C# StatementBuilder.ToStatement怎么用?C# StatementBuilder.ToStatement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.Api.Ads.Dfp.Util.v201505.StatementBuilder
的用法示例。
在下文中一共展示了StatementBuilder.ToStatement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Create the CreativeWrapperService.
CreativeWrapperService creativeWrapperService = (CreativeWrapperService) user.GetService(
DfpService.v201505.CreativeWrapperService);
long creativeWrapperId = long.Parse(_T("INSERT_CREATIVE_WRAPPER_ID_HERE"));
try {
StatementBuilder statementBuilder = new StatementBuilder()
.Where("id = :id")
.OrderBy("id ASC")
.Limit(1)
.AddValue("id", creativeWrapperId);
CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(
statementBuilder.ToStatement());
CreativeWrapper wrapper = page.results[0];
wrapper.ordering = CreativeWrapperOrdering.OUTER;
// Update the creative wrappers on the server.
CreativeWrapper[] creativeWrappers = creativeWrapperService.updateCreativeWrappers(
new CreativeWrapper[] {wrapper});
// Display results.
foreach (CreativeWrapper createdCreativeWrapper in creativeWrappers) {
Console.WriteLine("Creative wrapper with ID '{0}' and wrapping order '{1}' was " +
"updated.", createdCreativeWrapper.id, createdCreativeWrapper.ordering);
}
} catch (Exception e) {
Console.WriteLine("Failed to update creative wrappers. Exception says \"{0}\"",
e.Message);
}
}
示例2: Run
/// <summary>
/// Run the sample code.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the InventoryService.
InventoryService inventoryService =
(InventoryService) user.GetService(DfpService.v201505.InventoryService);
// Set the ID of the ad unit to update.
int adUnitId = int.Parse(_T("INSERT_AD_UNIT_ID_HERE"));
// Create a statement to get the ad unit.
StatementBuilder statementBuilder = new StatementBuilder()
.Where("id = :id")
.OrderBy("id ASC")
.Limit(1)
.AddValue("id", adUnitId);
try {
// Get ad units by statement.
AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.ToStatement());
AdUnit adUnit = page.results[0];
adUnit.inheritedAdSenseSettings.value.adSenseEnabled = true;
// Update the ad units on the server.
AdUnit[] updatedAdUnits = inventoryService.updateAdUnits(new AdUnit[] {adUnit});
foreach (AdUnit updatedAdUnit in updatedAdUnits) {
Console.WriteLine("Ad unit with ID \"{0}\", name \"{1}\", and is AdSense enabled " +
"\"{2}\" was updated.", updatedAdUnit.id, updatedAdUnit.name,
updatedAdUnit.inheritedAdSenseSettings.value.adSenseEnabled);
}
} catch (Exception ex) {
Console.WriteLine("Failed to update ad units. Exception says \"{0}\"", ex.Message);
}
}
示例3: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the ContactService.
ContactService contactService =
(ContactService) user.GetService(DfpService.v201505.ContactService);
// Set the ID of the contact to update.
long contactId = long.Parse(_T("INSERT_CONTACT_ID_HERE"));
try {
StatementBuilder statementBuilder = new StatementBuilder()
.Where("id = :id")
.OrderBy("id ASC")
.Limit(1)
.AddValue("id", contactId);
// Get the contact.
ContactPage page = contactService.getContactsByStatement(statementBuilder.ToStatement());
Contact contact = page.results[0];
// Update the address of the contact.
contact.address = "123 New Street, New York, NY, 10011";
// Update the contact on the server.
Contact[] contacts = contactService.updateContacts(new Contact[] {contact});
// Display results.
foreach (Contact updatedContact in contacts) {
Console.WriteLine("Contact with ID \"{0}\", name \"{1}\", and comment \"{2}\" was " +
"updated.", updatedContact.id, updatedContact.name, updatedContact.comment);
}
} catch (Exception ex) {
Console.WriteLine("Failed to update contacts. Exception says \"{0}\"", ex.Message);
}
}
示例4: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the OrderService.
OrderService orderService = (OrderService) user.GetService(DfpService.v201505.OrderService);
// Create a statement to get all orders.
StatementBuilder statementBuilder = new StatementBuilder()
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Set default for page.
OrderPage page = new OrderPage();
try {
do {
// Get orders by statement.
page = orderService.getOrdersByStatement(statementBuilder.ToStatement());
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (Order order in page.results) {
Console.WriteLine("{0}) Order with ID = '{1}', name = '{2}', and advertiser " +
"ID = '{3}' was found.", i, order.id, order.name, order.advertiserId);
i++;
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get all orders. Exception says \"{0}\"",
ex.Message);
}
}
示例5: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the RateCardService.
RateCardService rateCardService =
(RateCardService) user.GetService(DfpService.v201505.RateCardService);
// Create a statement to get all rate cards using USD as currency.
StatementBuilder statementBuilder = new StatementBuilder()
.Where("currencyCode = :currencyCode")
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.AddValue("currencyCode", "USD");
// Set default for page.
RateCardPage page = new RateCardPage();
try {
do {
// Get rate cards by statement.
page = rateCardService.getRateCardsByStatement(statementBuilder.ToStatement());
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (RateCard rateCard in page.results) {
Console.WriteLine("{0}) Rate card with ID ='{1}', name '{2}', and currency '{3}' " +
"was found.", i++, rateCard.id, rateCard.name, rateCard.currencyCode);
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get rate cards by statement. Exception says \"{0}\"",
ex.Message);
}
}
示例6: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the ActivityService.
ActivityService activityService =
(ActivityService) user.GetService(DfpService.v201505.ActivityService);
// Set the ID of the activity to update.
int activityId = int.Parse(_T("INSERT_ACTIVITY_ID_HERE"));
try {
// Get the activity.
StatementBuilder statemetnBuilder = new StatementBuilder()
.Where("id = :id")
.OrderBy("id ASC")
.Limit(1)
.AddValue("id", activityId);
ActivityPage page = activityService.getActivitiesByStatement(
statemetnBuilder.ToStatement());
Activity activity = page.results[0];
// Update the expected URL.
activity.expectedURL = "https://www.google.com";
// Update the activity on the server.
Activity[] activities = activityService.updateActivities(new Activity[] {activity});
foreach (Activity updatedActivity in activities) {
Console.WriteLine("Activity with ID \"{0}\" and name \"{1}\" was updated.",
updatedActivity.id, updatedActivity.name);
}
} catch (Exception e) {
Console.WriteLine("Failed to update activities. Exception says \"{0}\"", e.Message);
}
}
示例7: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the PackageService.
PackageService packageService =
(PackageService) user.GetService(DfpService.v201505.PackageService);
// Create a statement to only select packages that are in progress.
StatementBuilder statementBuilder = new StatementBuilder()
.Where("status = :status")
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.AddValue("status", PackageStatus.IN_PROGRESS.ToString());
// Set default for page.
PackagePage page = new PackagePage();
try {
do {
// Get packages by statement.
page = packageService.getPackagesByStatement(statementBuilder.ToStatement());
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (Package package in page.results) {
Console.WriteLine("{0}) Package with ID = \"{1}\", name = \"{2}\" for proposal ID " +
"\"{3}\" was found.", i++, package.id, package.name, package.proposalId);
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while(statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: " + page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get packages. Exception says \"{0}\"",
ex.Message);
}
}
示例8: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the ProposalLineItemService.
ProposalLineItemService proposalLineItemService =
(ProposalLineItemService) user.GetService(DfpService.v201505.ProposalLineItemService);
// Create a statement to get all proposal line items.
StatementBuilder statementBuilder = new StatementBuilder()
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Sets default for page.
ProposalLineItemPage page = new ProposalLineItemPage();
try {
do {
// Get proposal line items by statement.
page = proposalLineItemService
.getProposalLineItemsByStatement(statementBuilder.ToStatement());
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (ProposalLineItem proposalLineItem in page.results) {
Console.WriteLine("{0}) Proposal line item with ID = '{1}' and name '{2}' was" +
" found.", i++, proposalLineItem.id, proposalLineItem.name);
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get proposal line items. Exception says \"{0}\"",
ex.Message);
}
}
示例9: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the InventoryService.
InventoryService inventoryService =
(InventoryService) user.GetService(DfpService.v201505.InventoryService);
// Create a statement to get all ad units.
StatementBuilder statementBuilder = new StatementBuilder()
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Set default for page.
AdUnitPage page = new AdUnitPage();
try {
do {
// Get ad units by statement.
page = inventoryService.getAdUnitsByStatement(statementBuilder.ToStatement());
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (AdUnit adUnit in page.results) {
Console.WriteLine("{0}) Ad unit with ID = '{1}', name = '{2}' and status = '{3}' " +
"was found.", i, adUnit.id, adUnit.name, adUnit.status);
i++;
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception e) {
Console.WriteLine("Failed to get ad unit. Exception says \"{0}\"", e.Message);
}
}
示例10: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the CompanyService.
CompanyService companyService =
(CompanyService) user.GetService(DfpService.v201505.CompanyService);
// Create a statement to only select companies that are advertisers sorted
// by name.
StatementBuilder statementBuilder = new StatementBuilder()
.Where("type = :advertiser")
.OrderBy("name ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.AddValue("advertiser", CompanyType.ADVERTISER.ToString());
CompanyPage page = new CompanyPage();
try {
do {
// Get companies by statement.
page = companyService.getCompaniesByStatement(statementBuilder.ToStatement());
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (Company company in page.results) {
Console.WriteLine("{0}) Company with ID = {1}, name = {2} and type = {3} was found",
i, company.id, company.name, company.type);
i++;
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception e) {
Console.WriteLine("Failed to get companies. Exception says \"{0}\"", e.Message);
}
}
示例11: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the ContentService.
ContentService contentService =
(ContentService) user.GetService(DfpService.v201505.ContentService);
// Create a statement to get all content.
StatementBuilder statementBuilder = new StatementBuilder()
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Set default for page.
ContentPage page = new ContentPage();
try {
do {
// Get content by statement.
page = contentService.getContentByStatement(statementBuilder.ToStatement());
if (page.results != null) {
int i = page.startIndex;
foreach (Content content in page.results) {
Console.WriteLine("{0}) Content with ID \"{1}\", name \"{2}\", and status \"{3}\" " +
"was found.", i, content.id, content.name, content.status);
i++;
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: " + page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get all content. Exception says \"{0}\"", ex.Message);
}
}
示例12: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the SuggestedAdUnitService.
SuggestedAdUnitService suggestedAdUnitService = (SuggestedAdUnitService) user.GetService(
DfpService.v201505.SuggestedAdUnitService);
// Set default for page.
SuggestedAdUnitPage page = new SuggestedAdUnitPage();
// Create a statement to get all suggested ad units.
StatementBuilder statementBuilder = new StatementBuilder()
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
try {
do {
// Get suggested ad units by statement.
page = suggestedAdUnitService.getSuggestedAdUnitsByStatement(
statementBuilder.ToStatement());
if (page.results != null) {
int i = page.startIndex;
foreach (SuggestedAdUnit suggestedAdUnit in page.results) {
Console.WriteLine("{0}) Suggested ad unit with ID \"{1}\", and number of requests " +
"\"{2}\" was found.", i++, suggestedAdUnit.id, suggestedAdUnit.numRequests);
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: " + page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get suggested ad units. Exception says \"{0}\"",
ex.Message);
}
}
示例13: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the ProposalService.
ProposalService proposalService =
(ProposalService) user.GetService(DfpService.v201505.ProposalService);
// Create a statement to only select proposals that are pending approval.
StatementBuilder statementBuilder = new StatementBuilder()
.Where("status = :status")
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.AddValue("status", ProposalStatus.PENDING_APPROVAL.ToString());
// Set default for page.
ProposalPage page = new ProposalPage();
try {
do {
// Get proposals by statement.
page = proposalService.getProposalsByStatement(statementBuilder.ToStatement());
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (Proposal proposal in page.results) {
Console.WriteLine("{0}) Proposal with ID = '{1}', name = '{2}' was found.",
i++, proposal.id, proposal.name);
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while(statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: " + page.totalResultSetSize);
} catch (Exception e) {
Console.WriteLine("Failed to get proposals. Exception says \"{0}\"",
e.Message);
}
}
示例14: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the ProductPackageService.
ProductPackageService productPackageService =
(ProductPackageService) user.GetService(DfpService.v201505.ProductPackageService);
// Create a statement to select all product packages.
StatementBuilder statementBuilder = new StatementBuilder()
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Set default for page.
ProductPackagePage page = new ProductPackagePage();
try {
do {
// Get product packages by statement.
page =
productPackageService.getProductPackagesByStatement(statementBuilder.ToStatement());
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (ProductPackage productPackage in page.results) {
Console.WriteLine("{0}) Product package with ID = \"{1}\" and name = \"{2}\" was " +
"found.", i++, productPackage.id, productPackage.name);
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: " + page.totalResultSetSize);
} catch (Exception e) {
Console.WriteLine("Failed to get product packages. Exception says \"{0}\"",
e.Message);
}
}
示例15: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The DFP user object running the code example.</param>
public override void Run(DfpUser user) {
// Get the ActivityGroupService.
ActivityGroupService activityGroupService =
(ActivityGroupService) user.GetService(DfpService.v201505.ActivityGroupService);
StatementBuilder statementBuilder = new StatementBuilder()
.Where("status = :status")
.OrderBy("id ASC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.AddValue("status", ActivityGroupStatus.ACTIVE.ToString());
// Set default for page.
ActivityGroupPage page;
try {
do {
// Get contacts by statement.
page = activityGroupService.getActivityGroupsByStatement(statementBuilder.ToStatement());
if (page.results != null) {
int i = page.startIndex;
foreach (ActivityGroup activityGroup in page.results) {
Console.WriteLine("{0}) Activity group with ID \"{1}\" and name \"{2}\" was found.",
i, activityGroup.id, activityGroup.name);
i++;
}
}
statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.GetOffset() < page.totalResultSetSize);
Console.WriteLine("Number of results found: " + page.totalResultSetSize);
} catch (Exception e) {
Console.WriteLine("Failed to get activity groups. Exception says \"{0}\"", e.Message);
}
}