mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Change the way data is uploaded to the server.
This commit is contained in:
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -1802,7 +1802,6 @@
|
||||
</e>
|
||||
</e>
|
||||
<e p="DiscImageChef.Server" t="IncludeRecursive">
|
||||
<e p="App.config" t="Include" />
|
||||
<e p="App_Start" t="Include">
|
||||
<e p="Ata.cs" t="Include" />
|
||||
<e p="RouteConfig.cs" t="Include" />
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Xml.Serialization;
|
||||
using DiscImageChef.CommonTypes.Metadata;
|
||||
@@ -126,22 +127,19 @@ namespace DiscImageChef.Core
|
||||
DiscImageChef.Console.DicConsole.DebugWriteLine("Submit stats", "Uploading device report");
|
||||
#endif
|
||||
|
||||
MemoryStream jsonStream = new MemoryStream();
|
||||
StreamWriter jsonSw = new StreamWriter(jsonStream);
|
||||
|
||||
jsonSw.Write(JsonConvert.SerializeObject(report, Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
}));
|
||||
jsonStream.Seek(0, SeekOrigin.Begin);
|
||||
WebRequest request = WebRequest.Create("http://discimagechef.claunia.com/api/uploadreportv2");
|
||||
string json = JsonConvert.SerializeObject(report, Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
byte[] jsonBytes = Encoding.UTF8.GetBytes(json);
|
||||
WebRequest request = WebRequest.Create("http://discimagechef.claunia.com/api/uploadreportv2");
|
||||
((HttpWebRequest)request).UserAgent = $"DiscImageChef {typeof(Version).Assembly.GetName().Version}";
|
||||
request.Method = "POST";
|
||||
request.ContentLength = jsonStream.Length;
|
||||
request.ContentLength = jsonBytes.Length;
|
||||
request.ContentType = "application/json";
|
||||
Stream reqStream = request.GetRequestStream();
|
||||
jsonStream.CopyTo(reqStream);
|
||||
reqStream.Write(jsonBytes, 0, jsonBytes.Length);
|
||||
reqStream.Close();
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
@@ -153,8 +151,6 @@ namespace DiscImageChef.Core
|
||||
reader.ReadToEnd();
|
||||
data.Close();
|
||||
response.Close();
|
||||
jsonSw.Close();
|
||||
jsonStream.Close();
|
||||
}
|
||||
catch(WebException)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Xml.Serialization;
|
||||
using DiscImageChef.CommonTypes.Interop;
|
||||
@@ -609,23 +610,21 @@ namespace DiscImageChef.Core
|
||||
DiscImageChef.Console.DicConsole.DebugWriteLine("Submit stats", "Uploading statistics");
|
||||
#endif
|
||||
|
||||
MemoryStream jsonStream = new MemoryStream();
|
||||
StreamWriter jsonSw = new StreamWriter(jsonStream);
|
||||
|
||||
jsonSw.Write(JsonConvert.SerializeObject(dto, Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
}));
|
||||
jsonStream.Seek(0, SeekOrigin.Begin);
|
||||
WebRequest request = WebRequest.Create("http://discimagechef.claunia.com/api/uploadstatsv2");
|
||||
string json = JsonConvert.SerializeObject(dto, Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
byte[] jsonBytes = Encoding.UTF8.GetBytes(json);
|
||||
WebRequest request = WebRequest.Create("http://discimagechef.claunia.com/api/uploadstatsv2");
|
||||
((HttpWebRequest)request).UserAgent =
|
||||
$"DiscImageChef {typeof(Version).Assembly.GetName().Version}";
|
||||
request.Method = "POST";
|
||||
request.ContentLength = jsonStream.Length;
|
||||
request.ContentLength = jsonBytes.Length;
|
||||
request.ContentType = "application/json";
|
||||
Stream reqStream = request.GetRequestStream();
|
||||
jsonStream.CopyTo(reqStream);
|
||||
reqStream.Write(jsonBytes, 0, jsonBytes.Length);
|
||||
//jsonStream.CopyTo(reqStream);
|
||||
reqStream.Close();
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
@@ -634,11 +633,11 @@ namespace DiscImageChef.Core
|
||||
Stream data = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(data ?? throw new InvalidOperationException());
|
||||
|
||||
reader.ReadToEnd();
|
||||
string result = reader.ReadToEnd();
|
||||
data.Close();
|
||||
response.Close();
|
||||
jsonSw.Close();
|
||||
jsonStream.Close();
|
||||
|
||||
if(result != "ok") return;
|
||||
|
||||
if(ctx.Commands.Any(c => !c.Synchronized))
|
||||
foreach(string nvs in ctx.Commands.Where(c => !c.Synchronized).Select(c => c.Name)
|
||||
|
||||
Reference in New Issue
Block a user