public void Run(AdWordsUser user, long campaignId)
{
// Get the CampaignService.
CampaignService campaignService =
(CampaignService)user.GetService(AdWordsService.v201306.CampaignService);
// Create the campaign.
Campaign campaign = new Campaign();
campaign.id = campaignId;
campaign.status = CampaignStatus.PAUSED;
// Create the operation.
CampaignOperation operation = new CampaignOperation();
operation.@operator = Operator.SET;
operation.operand = campaign;
try {
// Update the campaign.
CampaignReturnValue retVal = campaignService.mutate((new CampaignOperation[] {operation}));
// Display the results.
if (retVal != null && retVal.value != null && retVal.value.Length > 0) {
Campaign updatedCampaign = retVal.value[0];
Console.WriteLine("Campaign with name = '{0}' and id = '{1}' was updated.",
updatedCampaign.name, updatedCampaign.id);
} else {
Console.WriteLine("No campaigns were updated.");
}
} catch (Exception ex) {
throw new System.ApplicationException("Failed to update campaign.", ex);
}
}