Update con logging, estensione timeout, maggiore dim file inviato...
This commit is contained in:
@@ -4,7 +4,7 @@ using NLog.Targets;
|
||||
|
||||
namespace MConnectSDK
|
||||
{
|
||||
internal static class Log
|
||||
public static class Log
|
||||
{
|
||||
public static Logger Instance { get; private set; }
|
||||
static Log()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -449,7 +450,7 @@ namespace MConnectSDK
|
||||
}
|
||||
|
||||
// ORA verifica STATO sistema A VALLE...
|
||||
if(checkConnStatus())
|
||||
if (checkConnStatus())
|
||||
{
|
||||
answ.CloudStatusOk = true;
|
||||
answ.Source = SourceType.CLOUD;
|
||||
@@ -465,7 +466,7 @@ namespace MConnectSDK
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected bool checkConnStatus()
|
||||
{
|
||||
{
|
||||
// STEP 1: PING a server (locale/remoto)
|
||||
pingOk = false;
|
||||
cloudOk = false;
|
||||
@@ -480,7 +481,7 @@ namespace MConnectSDK
|
||||
var pageRes = Utils.getPageAsync(AliveTarget);
|
||||
pageRes.Wait();
|
||||
if (pageRes.Result.IndexOf("HELLO") >= 0)
|
||||
{
|
||||
{
|
||||
cloudOk = true;
|
||||
}
|
||||
else
|
||||
@@ -1543,7 +1544,7 @@ namespace MConnectSDK
|
||||
{
|
||||
var respErr = JsonConvert.DeserializeObject<userLoginFailedResponse>(callResult);
|
||||
string msgErr = "Username not found";
|
||||
if(respErr!=null)
|
||||
if (respErr != null)
|
||||
{
|
||||
msgErr = "Username not found | " + respErr.message + " | " + respErr.result.error;
|
||||
}
|
||||
@@ -1800,14 +1801,19 @@ namespace MConnectSDK
|
||||
|
||||
try
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Restart();
|
||||
byte[] fileBytes = File.ReadAllBytes(fileName);
|
||||
double fileSize = ((double)fileBytes.Length) / 1024 / 1024;
|
||||
Log.Instance.Info($"Inizio TryUpLoadFile, effettuata lettura del file {fileName} per {fileSize:N3}Mb");
|
||||
// effettuo call EFFETTIVA
|
||||
var taskRes = Task.Run(() => Utils.uploadAsync(UploadUrl, uploadName, fileBytes));
|
||||
taskRes.Wait();
|
||||
var rawResult = taskRes.Result;
|
||||
double velMbps = fileSize / (stopwatch.ElapsedMilliseconds / 1000);
|
||||
Log.Instance.Info($"Completato invio del file, vel media upload: {velMbps:N3} Mb/sec, risultato json: {rawResult}");
|
||||
// leggo la risposta in var temporanea...
|
||||
resp = JsonConvert.DeserializeObject<GatewayPayload>(rawResult);
|
||||
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
+10
-2
@@ -100,7 +100,13 @@ namespace MConnectSDK
|
||||
/// <param name="doLog"></param>
|
||||
public static async Task<string> getPageAsync(string pageURL)
|
||||
{
|
||||
Log.Instance.Info($"[getPageAsync]: Calling URL: {pageURL}");
|
||||
string currUrl = pageURL;
|
||||
if(currUrl.IndexOf("token")>=0)
|
||||
{
|
||||
currUrl = currUrl.Substring(0, currUrl.IndexOf("token"));
|
||||
}
|
||||
// se contiene token --> TRIMMO...
|
||||
Log.Instance.Info($"[getPageAsync]: Calling URL: {currUrl}");
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
@@ -125,7 +131,8 @@ namespace MConnectSDK
|
||||
/// <param name="pageURL"></param>
|
||||
public static async Task<string> getPageAsync(string pageURL, string oauthToken)
|
||||
{
|
||||
Log.Instance.Info($"[getPageAsync]: Calling URL: {pageURL} | OAuth Token: {oauthToken}");
|
||||
Log.Instance.Info($"[getPageAsync]: Calling URL: {pageURL} | OAuth Token: OMISSIS");
|
||||
//Log.Instance.Info($"[getPageAsync]: Calling URL: {pageURL} | OAuth Token: {oauthToken}");
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
@@ -255,6 +262,7 @@ namespace MConnectSDK
|
||||
// imposto a 15 minutiupload timeout!
|
||||
TimeSpan ts = new TimeSpan(0, 15, 0);
|
||||
client.Timeout = ts;
|
||||
client.MaxResponseContentBufferSize = fileContent.Length + 1024;
|
||||
using (var content =
|
||||
new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture)))
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -8,5 +8,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © Steamware 2019")]
|
||||
[assembly: AssemblyTrademark("_")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("1.1.1904.97")]
|
||||
[assembly: AssemblyFileVersion("1.1.1904.97")]
|
||||
[assembly: AssemblyVersion("1.1.1904.99")]
|
||||
[assembly: AssemblyFileVersion("1.1.1904.99")]
|
||||
|
||||
+10
-2
@@ -851,8 +851,16 @@ namespace TestClient
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var taskResult = MCC.TryUpLoadFile(token, progress, txtUploadFile.Text.Trim());
|
||||
// salvo il risultato restituito...
|
||||
reqStatus = taskResult.Result;
|
||||
|
||||
try
|
||||
{
|
||||
// salvo il risultato restituito...
|
||||
reqStatus = taskResult.Result;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
MConnectSDK.Log.Instance.Error(exc, "Eccezione in btnUploadFile_Click");
|
||||
}
|
||||
|
||||
synchronizationContext.Post(new SendOrPostCallback(o =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user