My favorites
▼
|
Sign in
google-api-adwords-dotnet
AdWords API DotNet Client Library
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
branches
/
v13.0
/
examples
/
csharp
/
v201109
/
DownloadAdhocReport.cs
‹r181
r234
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright 2011, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Author: api.anash@gmail.com (Anash P. Oommen)
using Google.Api.Ads.AdWords.Lib;
using Google.Api.Ads.AdWords.Util.Reports;
using Google.Api.Ads.AdWords.v201109;
using Google.Api.Ads.Common.Lib;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Google.Api.Ads.AdWords.Examples.CSharp.v201109 {
/// <summary>
/// This code example gets and downloads an Ad Hoc report from a XML report
/// definition.
/// </summary>
class DownloadAdhocReport : SampleBase {
/// <summary>
/// Returns a description about the code example.
/// </summary>
public override string Description {
get {
return "This code example gets and downloads an Ad Hoc report from a XML report " +
"definition.";
}
}
/// <summary>
/// Main method, to run this code example as a standalone application.
/// </summary>
/// <param name="args">The command line arguments.</param>
public static void Main(string[] args) {
SampleBase codeExample = new DownloadAdhocReport();
Console.WriteLine(codeExample.Description);
codeExample.Run(new AdWordsUser());
}
/// <summary>
/// Run the code example.
/// </summary>
/// <param name="user">The AdWords user object running the code example.
/// </param>
public override void Run(AdWordsUser user) {
string fileName = _T("INSERT_OUTPUT_FILE_NAME_HERE");
ReportDefinition definition = new ReportDefinition();
definition.reportName = "Last 7 days ADGROUP_PERFORMANCE_REPORT";
definition.reportType = ReportDefinitionReportType.ADGROUP_PERFORMANCE_REPORT;
definition.downloadFormat = DownloadFormat.CSV;
definition.dateRangeType = ReportDefinitionDateRangeType.LAST_7_DAYS;
Selector selector = new Selector();
selector.fields = new string[] {"CampaignId", "Id", "Impressions", "Clicks", "Cost"};
Predicate predicate = new Predicate();
predicate.field = "Status";
predicate.@operator = PredicateOperator.IN;
predicate.values = new string[] {"ENABLED", "PAUSED"};
selector.predicates = new Predicate[] {predicate};
definition.selector = selector;
definition.includeZeroImpressions = true;
string path = GetHomeDir() + Path.DirectorySeparatorChar + fileName;
try {
// If you know that your report is small enough to fit in memory, then
// you can instead use
// ClientReport report = new ReportUtilities().DownloadClientReport(
// new AdWordsAppConfig(), definition);
//
// // Binary report file (e.g. zip format)
// byte[] reportBytes = report.Contents;
//
// // Text report file (e.g. xml format)
// string reportText = report.Text;
new ReportUtilities(user).DownloadClientReport(definition, path);
Console.WriteLine("Report was downloaded to '{0}'.", path);
} catch (Exception ex) {
Console.WriteLine("Failed to download report. Exception says \"{0}\"", ex.Message);
}
}
}
}
Show details
Hide details
Change log
r183
by api.anash on Oct 24, 2011
Diff
Final updates for v13.0
Go to:
...cs/google-api-adwords-dotnet.chm
...p/AdWords.Examples.CSharp.csproj
...csharp/oauth/DownloadReport.aspx
.../DownloadReport.aspx.designer.cs
...sharp/oauth/GetAllCampaigns.aspx
...rp/oauth/GetAllCampaigns.aspx.cs
...GetAllCampaigns.aspx.designer.cs
.../AddCampaignTargetingCriteria.cs
...p/v201109/DownloadAdhocReport.cs
...csharp/v201109/GetAllCarriers.cs
...sharp/v201109/GetAllLanguages.cs
...p/v201109/GetLocationCriteria.cs
...p/v201109/GetTrafficEstimates.cs
...harp/v201109/PerformMutateJob.cs
...p/v201109/SetCampaignCriteria.cs
...es/vb/AdWords.Examples.VB.vbproj
.../AddCampaignTargetingCriteria.vb
...b/v201109/DownloadAdhocReport.vb
...les/vb/v201109/GetAllCarriers.vb
...es/vb/v201109/GetAllLanguages.vb
...b/v201109/GetLocationCriteria.vb
...b/v201109/GetTrafficEstimates.vb
...s/vb/v201109/PerformMutateJob.vb
...b/v201109/SetCampaignCriteria.vb
Project members,
sign in
to write a code review
Older revisions
r181
by api.anash on Oct 17, 2011
Diff
Committing initial version to svn.
All revisions of this file
File info
Size: 3798 bytes, 100 lines
View raw file
Powered by
Google Project Hosting