本文整理汇总了C#中Google.Api.Ads.Dfp.v201208.Statement类的典型用法代码示例。如果您正苦于以下问题:C# Statement类的具体用法?C# Statement怎么用?C# Statement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Statement类属于Google.Api.Ads.Dfp.v201208命名空间,在下文中一共展示了Statement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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) {
// Get the AudienceSegmentService.
AudienceSegmentService audienceSegmentService =
(AudienceSegmentService) user.GetService(DfpService.v201208.AudienceSegmentService);
// Set defaults for page and Statement.
AudienceSegmentPage page = new AudienceSegmentPage();
Statement statement = new Statement();
int offset = 0;
try {
do {
// Create a Statement to get all creatives.
statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);
// Get audience segment by Statement.
page = audienceSegmentService.getAudienceSegmentsByStatement(statement);
// Display results.
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (AudienceSegment segment in page.results) {
Console.WriteLine("{0}) 'Audience segment with id \"{1}\" and name \"{2}\" was " +
"found.", i, segment.id, segment.name);
i++;
}
}
offset += 500;
} while (offset < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get audience segment. Exception says \"{0}\"", ex.Message);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:39,代码来源:GetAllAudienceSegments.cs
示例2: TestAllStatementBuilderPartialFunctions
public void TestAllStatementBuilderPartialFunctions()
{
StatementBuilder statementBuilder = new StatementBuilder()
.Select("Name, Id")
.From("Geo_Target")
.Where("Targetable = :targetable")
.OrderBy("Id DESC")
.Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.Offset(0)
.AddValue("targetable", true)
.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.RemoveLimitAndOffset();
Assert.AreEqual(null, statementBuilder.GetOffset());
Statement expectedStatement = new Statement();
expectedStatement.query = "SELECT Name, Id FROM Geo_Target"
+ " WHERE Targetable = :targetable ORDER BY Id DESC";
String_ValueMapEntry targetableEntry = new String_ValueMapEntry();
targetableEntry.key = "targetable";
BooleanValue targetableValue = new BooleanValue();
targetableValue.value = true;
targetableEntry.value = targetableValue;
expectedStatement.values = new String_ValueMapEntry[] {targetableEntry};
Assert.True(StatementsAreEqual(expectedStatement, statementBuilder.ToStatement()));
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:25,代码来源:StatementBuilderTests.cs
示例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 CompanyService.
CompanyService companyService =
(CompanyService) user.GetService(DfpService.v201208.CompanyService);
// Set defaults for page and Statement.
CompanyPage page = new CompanyPage();
Statement statement = new Statement();
int offset = 0;
try {
do {
// Create a Statement to get all companies.
statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);
// Get companies by Statement.
page = companyService.getCompaniesByStatement(statement);
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++;
}
}
offset += 500;
} while (offset < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get companies. Exception says \"{0}\"", ex.Message);
}
}
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:39,代码来源:GetAllCompanies.cs
示例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 ContentService.
ContentService contentService =
(ContentService) user.GetService(DfpService.v201208.ContentService);
// Set defaults for page and filterStatement.
ContentPage page = new ContentPage();
Statement filterStatement = new Statement();
int offset = 0;
try {
do {
// Create a statement to get all content.
filterStatement.query = "LIMIT 500 OFFSET " + offset.ToString();
// Get content by statement.
page = contentService.getContentByStatement(filterStatement);
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++;
}
}
offset += 500;
} while (offset < 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);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:38,代码来源:GetAllContent.cs
示例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 SuggestedAdUnitService.
SuggestedAdUnitService suggestedAdUnitService = (SuggestedAdUnitService) user.GetService(
DfpService.v201208.SuggestedAdUnitService);
// Set defaults for page and filterStatement.
SuggestedAdUnitPage page = new SuggestedAdUnitPage();
Statement filterStatement = new Statement();
int offset = 0;
try {
do {
// Create a statement to get all suggested ad units.
filterStatement.query = "LIMIT 500 OFFSET " + offset;
// Get suggested ad units by statement.
page = suggestedAdUnitService.getSuggestedAdUnitsByStatement(filterStatement);
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);
i++;
}
}
offset += 500;
} while (offset < 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);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:39,代码来源:GetAllSuggestedAdUnits.cs
示例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 InventoryService.
InventoryService inventoryService =
(InventoryService) user.GetService(DfpService.v201208.InventoryService);
// Sets defaults for page and statement.
AdUnitPage page = new AdUnitPage();
Statement statement = new Statement();
int offset = 0;
try {
do {
// Create a Statement to get all ad units.
statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);
// Get ad units by Statement.
page = inventoryService.getAdUnitsByStatement(statement);
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++;
}
}
offset += 500;
} while (offset < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get ad unit. Exception says \"{0}\"", ex.Message);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:38,代码来源:GetAllAdUnits.cs
示例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 ThirdpartySlotService.
ThirdPartySlotService thirdPartySlotService =
(ThirdPartySlotService) user.GetService(DfpService.v201208.ThirdPartySlotService);
// Sets defaults for page and filterStatement.
ThirdPartySlotPage page = new ThirdPartySlotPage();
Statement filterStatement = new Statement();
int offset = 0;
try {
do {
// Create a statement to get third party slots.
filterStatement.query = "LIMIT 500 OFFSET " + offset.ToString();
// Get third party slots by statement.
page = thirdPartySlotService.getThirdPartySlotsByStatement(filterStatement);
if (page.results != null) {
int i = page.startIndex;
foreach (ThirdPartySlot slot in page.results) {
Console.WriteLine("{0}) Third party slot with ID \"{1}\" was found.", i, slot.id);
i++;
}
}
offset += 500;
} while (offset < page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get all third party slots. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:37,代码来源:GetAllThirdPartySlots.cs
示例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 OrderService.
OrderService orderService = (OrderService) user.GetService(DfpService.v201208.OrderService);
// Sets defaults for page and Statement.
OrderPage page = new OrderPage();
Statement statement = new Statement();
int offset = 0;
try {
do {
// Create a Statement to get all orders.
statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);
// Get orders by Statement.
page = orderService.getOrdersByStatement(statement);
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++;
}
}
offset += 500;
} while (page.results != null && page.results.Length == 500);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get all orders. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:hoodapecan,项目名称:googleads-dotnet-lib,代码行数:39,代码来源:GetAllOrders.cs
示例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 TeamService.
TeamService teamService = (TeamService) user.GetService(DfpService.v201208.TeamService);
// Set defaults for page and filterStatement.
TeamPage page = new TeamPage();
Statement filterStatement = new Statement();
int offset = 0;
try {
do {
// Create a statement to get all teams.
filterStatement.query = "LIMIT 500 OFFSET " + offset;
// Get teams by statement.
page = teamService.getTeamsByStatement(filterStatement);
if (page.results != null) {
int i = page.startIndex;
foreach (Team team in page.results) {
Console.WriteLine("{0}) Team with ID \"{1}\", name \"{2}\" was found.",
i, team.id, team.name);
i++;
}
}
offset += 500;
} while (offset < page.totalResultSetSize);
Console.WriteLine("Number of results found: " + page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get all teams. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:39,代码来源:GetAllTeams.cs
示例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 UserService.
UserService userService = (UserService) user.GetService(DfpService.v201208.UserService);
// Sets defaults for page and Statement.
UserPage page = new UserPage();
Statement statement = new Statement();
int offset = 0;
try {
do {
// Create a Statement to get all users.
statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);
// Get users by Statement.
page = userService.getUsersByStatement(statement);
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (User usr in page.results) {
Console.WriteLine("{0}) User with ID = '{1}', email = '{2}', and role = '{3}'" +
" was found.", i, usr.id, usr.email, usr.roleName);
i++;
}
}
offset += 500;
} while (offset < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get all users. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:39,代码来源:GetAllUsers.cs
示例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 UserService.
UserService userService = (UserService) user.GetService(DfpService.v201208.UserService);
// Create a Statement to get all users sorted by name.
Statement statement = new Statement();
statement.query = "ORDER BY name LIMIT 500";
try {
// Get users by Statement.
UserPage page = userService.getUsersByStatement(statement);
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (User usr in page.results) {
Console.WriteLine("{0}) User with ID = '{1}', email = '{2}', and role = '{3}'" +
" was found.", i, usr.id, usr.email, usr.roleName);
}
}
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get user by ID. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:30,代码来源:GetUsersByStatement.cs
示例12: TestStatementBuilderBasicStatement
public void TestStatementBuilderBasicStatement()
{
StatementBuilder statementBuilder = new StatementBuilder()
.Where("ID = 1");
Statement expectedStatement = new Statement();
expectedStatement.query = "WHERE ID = 1";
expectedStatement.values = new String_ValueMapEntry[0];
Assert.True(StatementsAreEqual(expectedStatement,
statementBuilder.ToStatement()));
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:12,代码来源:StatementBuilderTests.cs
示例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 CustomFieldService.
CustomFieldService customFieldService = (CustomFieldService) user.GetService(
DfpService.v201208.CustomFieldService);
// Sets defaults for page and filter.
CustomFieldPage page = new CustomFieldPage();
Statement filterStatement = new Statement();
int offset = 0;
try {
do {
// Create a statement to get all custom fields.
filterStatement.query = "LIMIT 500 OFFSET " + offset;
// Get custom fields by statement.
page = customFieldService.getCustomFieldsByStatement(filterStatement);
if (page.results != null) {
int i = page.startIndex;
foreach (CustomField customField in page.results) {
if (customField is DropDownCustomField) {
List<String> dropDownCustomFieldStrings = new List<String>();
DropDownCustomField dropDownCustomField = (DropDownCustomField) customField;
if (dropDownCustomField.options != null) {
foreach (CustomFieldOption customFieldOption in dropDownCustomField.options) {
dropDownCustomFieldStrings.Add(customFieldOption.displayName);
}
}
Console.WriteLine("{0}) Drop-down custom field with ID \"{1}\", name \"{2}\", " +
"and options {{{3}}} was found.", i, customField.id, customField.name,
string.Join(", ", dropDownCustomFieldStrings.ToArray()));
} else {
Console.WriteLine("{0}) Custom field with ID \"{1}\" and name \"{2}\" was found.",
i, customField.id, customField.name);
}
i++;
}
}
offset += 500;
} while (page.results != null && page.results.Length == 500);
Console.WriteLine("Number of results found: " + page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get all custom fields. Exception says \"{0}\"", ex.Message);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:53,代码来源:GetAllCustomFields.cs
示例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 PlacementService.
PlacementService placementService =
(PlacementService) user.GetService(DfpService.v201208.PlacementService);
// Get the InventoryService.
InventoryService inventoryService =
(InventoryService) user.GetService(DfpService.v201208.InventoryService);
// Create a statement to select first 500 placements.
Statement filterStatement = new Statement();
filterStatement.query = "LIMIT 500";
try {
// Get placements by statement.
PlacementPage page = placementService.getPlacementsByStatement(filterStatement);
if (page.results != null) {
Placement[] placements = page.results;
// Update each local placement object by enabling AdSense targeting.
foreach (Placement placement in placements) {
placement.targetingDescription = (string.IsNullOrEmpty(placement.description))?
"Generic description" : placement.description;
placement.targetingAdLocation = "All images on sports pages.";
placement.targetingSiteName = "http://code.google.com";
placement.isAdSenseTargetingEnabled = true;
}
// Update the placements on the server.
placements = placementService.updatePlacements(placements);
// Display results.
if (placements != null) {
foreach (Placement placement in placements) {
Console.WriteLine("A placement with ID \"{0}\", name \"{1}\", and AdSense targeting" +
" enabled \"{2}\" was updated.", placement.id, placement.name,
placement.isAdSenseTargetingEnabled);
}
} else {
Console.WriteLine("No placements updated.");
}
}
} catch (Exception ex) {
Console.WriteLine("Failed to update placements. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:53,代码来源:UpdatePlacements.cs
示例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 CreativeService.
CustomTargetingService customTargetingService =
(CustomTargetingService) user.GetService(DfpService.v201208.CustomTargetingService);
// Create a statement to get all custom targeting keys.
Statement filterStatement = new Statement();
filterStatement.query = "LIMIT 500";
try {
// Get custom targeting keys by statement.
CustomTargetingKeyPage page =
customTargetingService.getCustomTargetingKeysByStatement(filterStatement);
if (page.results != null) {
CustomTargetingKey[] customTargetingKeys = page.results;
// Update each local custom targeting key object by changing its display
// name.
foreach (CustomTargetingKey customTargetingKey in customTargetingKeys) {
if (customTargetingKey.displayName == null) {
customTargetingKey.displayName = customTargetingKey.name;
}
customTargetingKey.displayName = customTargetingKey.displayName + " (Deprecated)";
}
// Update the custom targeting keys on the server.
customTargetingKeys =
customTargetingService.updateCustomTargetingKeys(customTargetingKeys);
if (customTargetingKeys != null) {
foreach (CustomTargetingKey customTargetingKey in customTargetingKeys) {
Console.WriteLine("Custom targeting key with ID \"{0}\", name \"{1}\", and " +
"display name \"{2}\" was updated.", customTargetingKey.id,
customTargetingKey.name, customTargetingKey.displayName);
}
} else {
Console.WriteLine("No custom targeting keys updated.");
}
} else {
Console.WriteLine("No custom targeting keys found to update.");
}
} catch (Exception ex) {
Console.WriteLine("Failed to update display name of custom targeting keys. Exception " +
"says \"{0}\"", ex.Message);
}
}
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:52,代码来源:UpdateCustomTargetingKeys.cs
示例16: OnGetUsersButtonClick
/// <summary>
/// Handles the Click event of the btnGetUsers control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing
/// the event data.</param>
protected void OnGetUsersButtonClick(object sender, EventArgs e) {
ConfigureUserForOAuth();
try {
// Get the UserService.
UserService userService = (UserService)user.GetService(DfpService.v201208.UserService);
// Sets defaults for page and Statement.
UserPage page = new UserPage();
Statement statement = new Statement();
int offset = 0;
DataTable dataTable = new DataTable();
dataTable.Columns.AddRange(new DataColumn[] {
new DataColumn("Serial No.", typeof(int)),
new DataColumn("User Id", typeof(long)),
new DataColumn("Email", typeof(string)),
new DataColumn("Role", typeof(string))
});
do {
// Create a Statement to get all users.
statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);
// Get users by Statement.
page = userService.getUsersByStatement(statement);
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (User usr in page.results) {
DataRow dataRow = dataTable.NewRow();
dataRow.ItemArray = new object[] {i + 1, usr.id, usr.email, usr.roleName};
dataTable.Rows.Add(dataRow);
i++;
}
}
offset += 500;
} while (offset < page.totalResultSetSize);
if (dataTable.Rows.Count > 0) {
UserGrid.DataSource = dataTable;
UserGrid.DataBind();
} else {
Response.Write("No users were found.");
}
} catch (Exception ex) {
Response.Write(string.Format("Failed to get users. Exception says \"{0}\"",
ex.Message));
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:54,代码来源:Default.aspx.cs
示例17: Main
/// <summary>
/// The main method.
/// </summary>
/// <param name="args">Command line arguments.</param>
static void Main(string[] args) {
DfpUser user = new DfpUser();
DfpAppConfig config = (user.Config as DfpAppConfig);
if (config.AuthorizationMethod == DfpAuthorizationMethod.OAuth2) {
if (config.OAuth2Mode == OAuth2Flow.APPLICATION &&
string.IsNullOrEmpty(config.OAuth2RefreshToken)) {
DoAuth2Authorization(user);
}
} else {
throw new Exception("Authorization mode is not OAuth.");
}
// Get the UserService.
UserService userService = (UserService)user.GetService(DfpService.v201208.UserService);
// Sets defaults for page and Statement.
UserPage page = new UserPage();
Statement statement = new Statement();
int offset = 0;
try {
do {
// Create a Statement to get all users.
statement.query = string.Format("LIMIT 500 OFFSET {0}", offset);
// Get users by Statement.
page = userService.getUsersByStatement(statement);
if (page.results != null && page.results.Length > 0) {
int i = page.startIndex;
foreach (User usr in page.results) {
Console.WriteLine("{0}) User with ID = '{1}', email = '{2}', and role = '{3}'" +
" was found.", i, usr.id, usr.email, usr.roleName);
i++;
}
}
offset += 500;
} while (offset < page.totalResultSetSize);
Console.WriteLine("Number of results found: {0}", page.totalResultSetSize);
} catch (Exception ex) {
Console.WriteLine("Failed to get all users. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:hoodapecan,项目名称:googleads-dotnet-lib,代码行数:49,代码来源:ConsoleExample.cs
示例18: 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.v201208.OrderService);
// Create a Statement to get all orders.
Statement statement = new Statement();
statement.query = "LIMIT 500";
try {
// Get orders by Statement.
OrderPage page = orderService.getOrdersByStatement(statement);
if (page.results != null && page.results.Length > 0) {
Order[] orders = page.results;
List<Order> ordersToUpdate = new List<Order>();
// Update each local order object by changing its notes.
foreach (Order order in orders) {
if (!order.isArchived) {
order.notes = "Spoke to advertiser. All is well.";
ordersToUpdate.Add(order);
}
}
// Update the orders on the server.
orders = orderService.updateOrders(ordersToUpdate.ToArray());
if (orders != null) {
foreach (Order order in orders) {
Console.WriteLine("Order with ID = '{0}', name = '{1}', advertiser ID = '{2}', " +
"and notes = '{3}' was updated.", order.id, order.name, order.advertiserId,
order.notes);
}
} else {
Console.WriteLine("No orders updated.");
}
} else {
Console.WriteLine("No orders found to update.");
}
} catch (Exception ex) {
Console.WriteLine("Failed to update orders. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:49,代码来源:UpdateOrders.cs
示例19: 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 LineItemCreativeAssociationService.
LineItemCreativeAssociationService licaService = (LineItemCreativeAssociationService)
user.GetService(DfpService.v201208.LineItemCreativeAssociationService);
// Create a Statement to get all LICAs.
Statement statement = new Statement();
statement.query = "LIMIT 500";
try {
// Get LICAs by Statement.
LineItemCreativeAssociationPage page =
licaService.getLineItemCreativeAssociationsByStatement(statement);
if (page.results != null && page.results.Length > 0) {
LineItemCreativeAssociation[] licas = page.results;
// Update each local LICA object by changing its destination URL.
foreach (LineItemCreativeAssociation lica in licas) {
lica.destinationUrl = "http://news.google.com";
}
// Update the LICAs on the server.
licas = licaService.updateLineItemCreativeAssociations(licas);
if (licas != null) {
foreach (LineItemCreativeAssociation lica in licas) {
Console.WriteLine("LICA with line item ID = '{0}, creative ID ='{1}' and " +
"destination URL '{2}' was updated.", lica.lineItemId, lica.creativeId,
lica.destinationUrl);
}
} else {
Console.WriteLine("No LICAs updated.");
}
} else {
Console.WriteLine("No LICAs found to update.");
}
} catch (Exception ex) {
Console.WriteLine("Failed to update LICAs. Exception says \"{0}\"", ex.Message);
}
}
开发者ID:hassanasd,项目名称:googleads-dfp-dotnet-lib,代码行数:46,代码来源:UpdateLicas.cs
示例20: Run
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="dfpUser">The DFP user object running the code example.</param>
public override void Run(DfpUser dfpUser)
{
// Get the UserService.
UserService userService = (UserService) dfpUser.GetService(DfpService.v201208.UserService);
// Create a Statement to get all users.
Statement statement = new Statement();
statement.query = "LIMIT 500";
try {
// Get users by Statement.
UserPage page = userService.getUsersByStatement(statement);
if (page.results != null && page.results.Length > 0) {
User[] users = page.results;
// Update each local users object by changing its name.
foreach (User user in users) {
user.name = user.name + " Sr.";
}
// Update the users on the server.
users = userService.updateUsers(users);
if (users != null) {
foreach (User user in users) {
Console.WriteLine("A user with ID = '{0}', name ='{1}', and role = '{2}'" +
" was updated.", user.id, user.name, user.roleName);
}
} else {
Console.WriteLine("No users updated.");
}
} else {
Console.WriteLine("No users found to update.");
}
} catch (Exception ex) {
Console.WriteLine("Failed to get user by ID. Exception says \"{0}\"",
ex.Message);
}
}
开发者ID:GerryT01,项目名称:googleads-dotnet-lib,代码行数:44,代码来源:UpdateUsers.cs
注:本文中的Google.Api.Ads.Dfp.v201208.Statement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论