diff --git a/GW2EIDPSReport/DPSReportController.cs b/GW2EIDPSReport/DPSReportController.cs
index db3db583f3..d294685ab5 100644
--- a/GW2EIDPSReport/DPSReportController.cs
+++ b/GW2EIDPSReport/DPSReportController.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Drawing;
using System.IO;
using System.Net;
using System.Net.Http;
@@ -13,6 +12,9 @@
[assembly: System.CLSCompliant(false)]
namespace GW2EIDPSReport
{
+ ///
+ /// https://dps.report/api
+ ///
public static class DPSReportController
{
@@ -26,6 +28,8 @@ private static bool IsUserTokenValid(string userToken)
NamingStrategy = new CamelCaseNamingStrategy()
};
+ private static readonly HttpClient HTTPClient = new HttpClient();
+
private class DPSReportUserTokenResponse
{
public string UserToken { get; set; }
@@ -93,7 +97,25 @@ private static string GetGetUploadsURL(GetUploadsParameters parameters, string u
///////////////// APIs
public static DPSReportUploadObject UploadUsingEI(FileInfo fi, List traces, string userToken, bool anonymous = false, bool detailedWvW = false)
{
- return UploadToDPSR(fi, GetUploadContentURL(BaseUploadContentURL, userToken, anonymous, detailedWvW) + "&generator=ei", traces);
+ string fileName = fi.Name;
+ byte[] fileContents = File.ReadAllBytes(fi.FullName);
+ Func contentCreator = () =>
+ {
+ var multiPartContent = new MultipartFormDataContent("----MyGreatBoundary");
+ var byteArrayContent = new ByteArrayContent(fileContents);
+ byteArrayContent.Headers.Add("Content-Type", "application/octet-stream");
+ multiPartContent.Add(byteArrayContent, "file", fileName);
+ return multiPartContent;
+ };
+
+ DPSReportUploadObject response = GetDPSReportResponse("UploadUsingEI", GetUploadContentURL(BaseUploadContentURL, userToken, anonymous, detailedWvW) + " & generator=ei", traces, contentCreator);
+ if (response != null && response.Error != null)
+ {
+ traces.Add("DPSReport: UploadUsingEI failed - " + response.Error);
+ return null;
+ }
+ return response;
+
}
public static DPSReportGetUploadsObject GetUploads(List traces, string userToken, GetUploadsParameters parameters)
@@ -143,78 +165,23 @@ public static T GetJsonWithPermalink(string permalink, List traces)
return GetDPSReportResponse("GetJsonWithPermalink", BaseGetJsonURL + "permalink=" + permalink, traces);
}
///////////////// Response Utilities
- private static T GetDPSReportResponse(string requestName, string URI, List traces)
+ private static T GetDPSReportResponse(string requestName, string URI, List traces, Func content = null)
{
const int tentatives = 5;
for (int i = 0; i < tentatives; i++)
{
- traces.Add(requestName + " tentative");
+ traces.Add("DPSReport: " + requestName + " tentative");
var webService = new Uri(@URI);
var requestMessage = new HttpRequestMessage(HttpMethod.Post, webService);
requestMessage.Headers.ExpectContinue = false;
- var httpClient = new HttpClient();
- try
- {
- Task httpRequest = httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, CancellationToken.None);
- HttpResponseMessage httpResponse = httpRequest.Result;
- HttpStatusCode statusCode = httpResponse.StatusCode;
- HttpContent responseContent = httpResponse.Content;
-
- if (statusCode != HttpStatusCode.OK)
- {
- throw new HttpRequestException(statusCode.ToString());
- }
-
- if (responseContent != null)
- {
- Task stringContentsTask = responseContent.ReadAsStringAsync();
- string stringContents = stringContentsTask.Result;
- T item = JsonConvert.DeserializeObject(stringContents, new JsonSerializerSettings
- {
- NullValueHandling = NullValueHandling.Ignore,
- ContractResolver = DefaultJsonContractResolver,
- StringEscapeHandling = StringEscapeHandling.EscapeHtml
- });
- traces.Add(requestName + " tentative successful");
- return item;
- }
- }
- catch (Exception e)
- {
- traces.Add(requestName + " tentative failed: " + e.Message);
- }
- finally
+ if (content != null)
{
- httpClient.Dispose();
- requestMessage.Dispose();
+ requestMessage.Content = content();
}
- }
- return default;
- }
- private static DPSReportUploadObject UploadToDPSR(FileInfo fi, string URI, List traces)
- {
- string fileName = fi.Name;
- byte[] fileContents = File.ReadAllBytes(fi.FullName);
- const int tentatives = 5;
- for (int i = 0; i < tentatives; i++)
- {
- traces.Add("Upload tentative");
- var webService = new Uri(@URI);
- var requestMessage = new HttpRequestMessage(HttpMethod.Post, webService);
- requestMessage.Headers.ExpectContinue = false;
-
- var multiPartContent = new MultipartFormDataContent("----MyGreatBoundary");
- var byteArrayContent = new ByteArrayContent(fileContents);
- byteArrayContent.Headers.Add("Content-Type", "application/octet-stream");
- multiPartContent.Add(byteArrayContent, "file", fileName);
- //multiPartContent.Add(new StringContent("generator=ei"), "gen", "ei");
- requestMessage.Content = multiPartContent;
-
- var httpClient = new HttpClient();
try
{
- Task httpRequest = httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, CancellationToken.None);
+ Task httpRequest = HTTPClient.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, CancellationToken.None);
HttpResponseMessage httpResponse = httpRequest.Result;
HttpStatusCode statusCode = httpResponse.StatusCode;
HttpContent responseContent = httpResponse.Content;
@@ -228,32 +195,26 @@ private static DPSReportUploadObject UploadToDPSR(FileInfo fi, string URI, List<
{
Task stringContentsTask = responseContent.ReadAsStringAsync();
string stringContents = stringContentsTask.Result;
- DPSReportUploadObject item = JsonConvert.DeserializeObject(stringContents, new JsonSerializerSettings
+ T item = JsonConvert.DeserializeObject(stringContents, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = DefaultJsonContractResolver,
StringEscapeHandling = StringEscapeHandling.EscapeHtml
});
- if (item.Error != null)
- {
- throw new InvalidOperationException(item.Error);
- }
- traces.Add("Upload tentative successful");
+ traces.Add("DPSReport: " + requestName + " tentative successful");
return item;
}
}
catch (Exception e)
{
- traces.Add("Upload tentative failed: " + e.Message);
+ traces.Add("DPSReport: " + requestName + " tentative failed - " + e.Message);
}
finally
{
- byteArrayContent.Dispose();
- httpClient.Dispose();
requestMessage.Dispose();
}
}
- return null;
+ return default;
}
}
diff --git a/GW2EIDPSReport/GW2EIDPSReport.csproj b/GW2EIDPSReport/GW2EIDPSReport.csproj
index 8966d17332..8de76d1c2b 100644
--- a/GW2EIDPSReport/GW2EIDPSReport.csproj
+++ b/GW2EIDPSReport/GW2EIDPSReport.csproj
@@ -15,7 +15,7 @@
AllEnabledByDefault
- 4.0.0
+ 4.1.0
EliphasNUIT
GW2 Elite Insights
GW2 Elite Insights
@@ -23,7 +23,7 @@
-
+
diff --git a/GW2EIDiscord/GW2EIDiscord.csproj b/GW2EIDiscord/GW2EIDiscord.csproj
index 3629838987..2921460933 100644
--- a/GW2EIDiscord/GW2EIDiscord.csproj
+++ b/GW2EIDiscord/GW2EIDiscord.csproj
@@ -15,7 +15,7 @@
AllEnabledByDefault
- 3.1.1
+ 3.2.0
GW2 Elite Insights
GW2 Elite Insights
EliphasNUIT
@@ -24,7 +24,7 @@
-
+
diff --git a/GW2EIGW2API/GW2EIGW2API.csproj b/GW2EIGW2API/GW2EIGW2API.csproj
index f499599738..668cb9a585 100644
--- a/GW2EIGW2API/GW2EIGW2API.csproj
+++ b/GW2EIGW2API/GW2EIGW2API.csproj
@@ -3,7 +3,7 @@
netstandard2.0
GW2EIGW2API
- 2.2.2
+ 2.3.0
Debug;Release;NoRewards
@@ -24,7 +24,7 @@
-
+
diff --git a/GW2EIParser.tst/GW2EIParser.tst.csproj b/GW2EIParser.tst/GW2EIParser.tst.csproj
index bfedcab9fa..1548334738 100644
--- a/GW2EIParser.tst/GW2EIParser.tst.csproj
+++ b/GW2EIParser.tst/GW2EIParser.tst.csproj
@@ -35,9 +35,9 @@
-
-
-
+
+
+
diff --git a/GW2EIParser.tst/TestHelper.cs b/GW2EIParser.tst/TestHelper.cs
index 465aca780a..840d18339b 100644
--- a/GW2EIParser.tst/TestHelper.cs
+++ b/GW2EIParser.tst/TestHelper.cs
@@ -20,7 +20,7 @@ public static class TestHelper
NamingStrategy = new CamelCaseNamingStrategy()
};
private static readonly Version Version = new Version(1, 0);
- private static readonly EvtcParserSettings parserSettings = new EvtcParserSettings(false, true, true, true, true, 2200, true);
+ private static readonly EvtcParserSettings parserSettings = new EvtcParserSettings(false, false, true, true, true, 2200, true);
private static readonly HTMLSettings htmlSettings = new HTMLSettings(false, false);
private static readonly RawFormatSettings rawSettings = new RawFormatSettings(true);
private static readonly CSVSettings csvSettings = new CSVSettings(",");