Nextrek
Diff Revisions
751
vs
752
for /Android/SmartCharging/SmartCharging_WP/SmartCharging/Net/Net.cs
|
@@ -80,7 +80,7 @@ |
80 |
80 |
|
} |
81 |
81 |
|
|
82 |
82 |
|
|
83 |
|
- |
public async Task<string> PostRequest(Uri url, byte[] byteData, string paramName, string paramValue, string type) |
|
83 |
+ |
public async Task<string> PostRequest(Uri url, byte[] byteData, Dictionary<string,string> parameters, string type) |
84 |
84 |
|
{ |
85 |
85 |
|
string result = ""; |
86 |
86 |
|
using (var httpClient = new HttpClient()) |
|
@@ -88,7 +88,23 @@ |
88 |
88 |
|
MultipartFormDataContent form = new MultipartFormDataContent(); |
89 |
89 |
|
HttpContent content = new ByteArrayContent(byteData); |
90 |
90 |
|
content.Headers.ContentType = MediaTypeHeaderValue.Parse(type); |
91 |
|
- |
form.Add(content, paramName, paramValue); |
|
91 |
+ |
|
|
92 |
+ |
List<KeyValuePair<string, string>> pairs = parameters.ToList<KeyValuePair<string, string>>(); |
|
93 |
+ |
KeyValuePair<string, string> pair = pairs[0]; |
|
94 |
+ |
|
|
95 |
+ |
form.Add(content, pair.Key, pair.Value); |
|
96 |
+ |
pairs.Remove(pairs[0]); |
|
97 |
+ |
|
|
98 |
+ |
|
|
99 |
+ |
for (int i = 0; i < pairs.Count; i++) |
|
100 |
+ |
{ |
|
101 |
+ |
|
|
102 |
+ |
HttpContent formContent = new StringContent(pairs[i].Value); |
|
103 |
+ |
form.Add(formContent,pairs[i].Key); |
|
104 |
+ |
} |
|
105 |
+ |
|
|
106 |
+ |
|
|
107 |
+ |
|
92 |
108 |
|
|
93 |
109 |
|
HttpResponseMessage response = await httpClient.PostAsync(url, form); |
94 |
110 |
|
result = await response.Content.ReadAsStringAsync(); |