/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> public void Run(AdWordsUser user) { // Get the CustomerSyncService. CustomerSyncService customerSyncService = (CustomerSyncService) user.GetService(AdWordsService.v201409. CustomerSyncService); // The date time string should be of the form yyyyMMdd HHmmss zzz string minDateTime = DateTime.Now.AddDays(-1).ToUniversalTime().ToString( "yyyyMMdd HHmmss") + " UTC"; string maxDateTime = DateTime.Now.ToUniversalTime().ToString("yyyyMMdd HHmmss") + " UTC"; // Create date time range. DateTimeRange dateTimeRange = new DateTimeRange(); dateTimeRange.min = minDateTime; dateTimeRange.max = maxDateTime; try { // Create the selector. CustomerSyncSelector selector = new CustomerSyncSelector(); selector.dateTimeRange = dateTimeRange; selector.campaignIds = GetAllCampaignIds(user); // Get all account changes for campaign. CustomerChangeData accountChanges = customerSyncService.get(selector); // Display the changes. if (accountChanges != null && accountChanges.changedCampaigns != null) { Console.WriteLine("Displaying changes up to: {0}", accountChanges.lastChangeTimestamp); foreach (CampaignChangeData campaignChanges in accountChanges.changedCampaigns) { Console.WriteLine("Campaign with id \"{0}\" was changed:", campaignChanges.campaignId); Console.WriteLine(" Campaign changed status: {0}", campaignChanges.campaignChangeStatus); if (campaignChanges.campaignChangeStatus != ChangeStatus.NEW) { Console.WriteLine(" Added ad extensions: {0}", GetFormattedList( campaignChanges.addedAdExtensions)); Console.WriteLine(" Added campaign criteria: {0}", GetFormattedList(campaignChanges.addedCampaignCriteria)); Console.WriteLine(" Added campaign targeting: {0}", campaignChanges.campaignTargetingChanged? "yes" : "no"); Console.WriteLine(" Removed ad extensions: {0}", GetFormattedList(campaignChanges.removedAdExtensions)); Console.WriteLine(" Removed campaign criteria: {0}", GetFormattedList(campaignChanges.removedAdExtensions)); if (campaignChanges.changedAdGroups != null) { foreach (AdGroupChangeData adGroupChanges in campaignChanges.changedAdGroups) { Console.WriteLine(" Ad group with id \"{0}\" was changed:", adGroupChanges.adGroupId); Console.WriteLine(" Ad group changed status: {0}", adGroupChanges.adGroupChangeStatus); if (adGroupChanges.adGroupChangeStatus != ChangeStatus.NEW) { Console.WriteLine(" Ads changed: {0}", GetFormattedList(adGroupChanges.changedAds)); Console.WriteLine(" Criteria changed: {0}", GetFormattedList(adGroupChanges.changedCriteria)); Console.WriteLine(" Criteria removed: {0}", GetFormattedList(adGroupChanges.removedCriteria)); } } } } Console.WriteLine(); } } else { Console.WriteLine("No account changes were found.");; } } catch (Exception ex) { throw new System.ApplicationException("Failed to get account changes.", ex); } }
public virtual CustomerChangeData get(CustomerSyncSelector selector) { object[] results = this.Invoke("get", new object[] { selector }); return ((CustomerChangeData) (results[0])); }