diff --git a/MConnectSDK/Logging.cs b/MConnectSDK/Logging.cs index 93087ed..1d6d76d 100644 --- a/MConnectSDK/Logging.cs +++ b/MConnectSDK/Logging.cs @@ -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() diff --git a/MConnectSDK/MConnectClient.cs b/MConnectSDK/MConnectClient.cs index 07caaee..ae182f4 100644 --- a/MConnectSDK/MConnectClient.cs +++ b/MConnectSDK/MConnectClient.cs @@ -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 /// /// 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(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(rawResult); - } catch (Exception exc) { diff --git a/MConnectSDK/Utils.cs b/MConnectSDK/Utils.cs index 2e78c08..c3eaa21 100644 --- a/MConnectSDK/Utils.cs +++ b/MConnectSDK/Utils.cs @@ -100,7 +100,13 @@ namespace MConnectSDK /// public static async Task 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 /// public static async Task 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))) { diff --git a/Rilasci/MCC_1.1.1904.95_Debug.zip b/Rilasci/MCC_1.1.1904.97_Debug.zip similarity index 80% rename from Rilasci/MCC_1.1.1904.95_Debug.zip rename to Rilasci/MCC_1.1.1904.97_Debug.zip index f97071b..e8a6a09 100644 Binary files a/Rilasci/MCC_1.1.1904.95_Debug.zip and b/Rilasci/MCC_1.1.1904.97_Debug.zip differ diff --git a/Rilasci/MCC_1.1.1904.95_Release.zip b/Rilasci/MCC_1.1.1904.97_Release.zip similarity index 79% rename from Rilasci/MCC_1.1.1904.95_Release.zip rename to Rilasci/MCC_1.1.1904.97_Release.zip index c684820..150d1d9 100644 Binary files a/Rilasci/MCC_1.1.1904.95_Release.zip and b/Rilasci/MCC_1.1.1904.97_Release.zip differ diff --git a/SharedAssemblyInfo.cs b/SharedAssemblyInfo.cs index e2fa4b0..2e062e3 100644 --- a/SharedAssemblyInfo.cs +++ b/SharedAssemblyInfo.cs @@ -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")] diff --git a/TestClient/MainForm.cs b/TestClient/MainForm.cs index b539520..0bbdbc3 100644 --- a/TestClient/MainForm.cs +++ b/TestClient/MainForm.cs @@ -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 => {