Helpのサンプルコード(VB.NET) †
ここで紹介しているコードはこちらのプロキシクラスを使用しています。
ここで紹介しているコードはこちらのC#のコードをVB.NETに変換したものです。
ECSで使用できるオペレーションやResponseGroupの情報を表示するサンプルです。
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
| | <%@ Page Language="VB" %>
<%@ Import Namespace="Amazon.jp.v20060913" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As EventArgs)
Dim req As New HelpRequest()
If HelpTypeList.SelectedValue = "Operation" Then
req.HelpType = HelpRequestHelpType.Operation
Else
If HelpTypeList.SelectedValue = "ResponseGroup" Then
req.HelpType = HelpRequestHelpType.ResponseGroup
End If
End If
req.HelpTypeSpecified = True
req.About = AboutList.SelectedValue
Dim hlp As New Help()
hlp.AWSAccessKeyId = "(あなたのAccessKeyID)"
hlp.AssociateTag = "dobonnet-22"
hlp.Request = New HelpRequest() {req}
Dim aws As New AWSECommerceService()
Dim res As HelpResponse
Try
res = aws.Help(hlp)
Catch ex As Exception
Label1.Text = "エラー:" + ex.Message
Return
End Try
If res Is Nothing OrElse res.Information Is Nothing Then
Label1.Text = "結果を取得できませんでした。"
Return
End If
If Not (res.Information(0).Request.Errors Is Nothing) Then
Label1.Text = "エラー:" + _
res.Information(0).Request.Errors(0).Message
Return
End If
Label1.Text = ""
Dim info As Amazon.jp.v20060913.Information = res.Information(0)
If Not (info.OperationInformation Is Nothing) Then
Label1.Text = "<ul>" + vbLf
Dim i As OperationInformation
For Each i In info.OperationInformation
Label1.Text += "<li><b>" + i.Name + "</b>" + vbLf
Label1.Text += "<li>説明 : " + i.Description + vbLf
Label1.Text += "<li>必須パラメーター :" + vbLf
Label1.Text += "<ul>" + vbLf
Dim s As String
For Each s In i.RequiredParameters
Label1.Text += "<li>" + s + vbLf
Next s
Label1.Text += "</ul>" + vbLf
Label1.Text += "<li>オプションパラメーター :" + vbLf
Label1.Text += "<ul>" + vbLf
For Each s In i.AvailableParameters
Label1.Text += "<li>" + s + vbLf
Next s
Label1.Text += "</ul>" + vbLf
Label1.Text += "<li>デフォルトのResponseGroup :" + vbLf
Label1.Text += "<ul>" + vbLf
For Each s In i.DefaultResponseGroups
Label1.Text += "<li>" + s + vbLf
Next s
Label1.Text += "</ul>" + vbLf
Label1.Text += "<li>指定可能なResponseGroup :" + vbLf
Label1.Text += "<ul>" + vbLf
For Each s In i.AvailableResponseGroups
Label1.Text += "<li>" + s + vbLf
Next s
Label1.Text += "</ul>" + vbLf
Next i
Label1.Text += "</ul>" + vbLf
Else
If Not (info.ResponseGroupInformation Is Nothing) Then
Label1.Text = "<ul>" + vbLf
Dim i As ResponseGroupInformation
For Each i In info.ResponseGroupInformation
Label1.Text += "<li><b>" + i.Name + "</b>" + vbLf
Label1.Text += "<li>作成日 : " + i.CreationDate + vbLf
Label1.Text += "<li>Operation :" + vbLf
Label1.Text += "<ul>" + vbLf
Dim s As String
For Each s In i.ValidOperations
Label1.Text += "<li>" + s + vbLf
Next s
Label1.Text += "</ul>" + vbLf
Label1.Text += "<li>Element :" + vbLf
Label1.Text += "<ul>" + vbLf
For Each s In i.Elements
Label1.Text += "<li>" + s + vbLf
Next s
Label1.Text += "</ul>" + vbLf
Next i
Label1.Text += "</ul>" + vbLf
Else
Label1.Text += "表示する内容がありません。"
End If
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
SetAboutList()
End If
End Sub
Protected Sub HelpTypeList_SelectedIndexChanged( _
ByVal sender As Object, ByVal e As EventArgs)
SetAboutList()
End Sub
Protected Sub SetAboutList()
AboutList.Items.Clear()
If HelpTypeList.SelectedValue = "Operation" Then
AboutList.Items.Add("CartAdd")
AboutList.Items.Add("CartClear")
AboutList.Items.Add("CartCreate")
AboutList.Items.Add("CartModify")
AboutList.Items.Add("CustomerContentLookup")
AboutList.Items.Add("CustomerContentSearch")
AboutList.Items.Add("Help")
AboutList.Items.Add("ItemLookup")
AboutList.Items.Add("ItemSearch")
AboutList.Items.Add("ListLookup")
AboutList.Items.Add("ListSearch")
AboutList.Items.Add("SellerListingLookup")
AboutList.Items.Add("SellerListingSearch")
AboutList.Items.Add("SellerLookup")
AboutList.Items.Add("SimilarityLookup")
AboutList.Items.Add("TransactionLookup")
Else
If HelpTypeList.SelectedValue = "ResponseGroup" Then
AboutList.Items.Add("Accessories")
AboutList.Items.Add("BrowseNodes")
AboutList.Items.Add("Cart")
AboutList.Items.Add("CartSimilarities")
AboutList.Items.Add("CustomerFull")
AboutList.Items.Add("CustomerInfo")
AboutList.Items.Add("CustomerLists")
AboutList.Items.Add("CustomerReviews")
AboutList.Items.Add("EditorialReview")
AboutList.Items.Add("Help")
AboutList.Items.Add("Images")
AboutList.Items.Add("ItemAttributes")
AboutList.Items.Add("ItemIds")
AboutList.Items.Add("Large")
AboutList.Items.Add("ListFull")
AboutList.Items.Add("ListInfo")
AboutList.Items.Add("ListItems")
AboutList.Items.Add("ListMinimum")
AboutList.Items.Add("ListmaniaLists")
AboutList.Items.Add("Medium")
AboutList.Items.Add("OfferFull")
AboutList.Items.Add("OfferSummary")
AboutList.Items.Add("Offers")
AboutList.Items.Add("Request")
AboutList.Items.Add("Reviews")
AboutList.Items.Add("Salesrank")
AboutList.Items.Add("Seller")
AboutList.Items.Add("SellerListing")
AboutList.Items.Add("Similarities")
AboutList.Items.Add("Small")
AboutList.Items.Add("Tracks")
AboutList.Items.Add("TransactionDetails")
AboutList.Items.Add("VariationMinimum")
AboutList.Items.Add("VariationSummary")
AboutList.Items.Add("Variations")
End If
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Helpのサンプル</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="HelpTypeList" runat="server"
OnSelectedIndexChanged="HelpTypeList_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem>Operation</asp:ListItem>
<asp:ListItem>ResponseGroup</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="AboutList" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="送信" />
<br />
</div>
</form>
<br />
<asp:Label ID="Label1" runat="server" EnableViewState="False">
</asp:Label>
</body>
</html>
|