diff --git a/MConnectSDK/Logging.cs b/MConnectSDK/Logging.cs
new file mode 100644
index 0000000..f7af2e4
--- /dev/null
+++ b/MConnectSDK/Logging.cs
@@ -0,0 +1,40 @@
+using NLog;
+using NLog.Config;
+using NLog.Targets;
+
+namespace MConnectSDK
+{
+ internal static class Log
+ {
+ public static Logger Instance { get; private set; }
+ static Log()
+ {
+#if DEBUG
+ // Setup the logging view for Sentinel - http://sentinel.codeplex.com
+ var sentinalTarget = new NLogViewerTarget()
+ {
+ Name = "sentinal",
+ Address = "udp://127.0.0.1:9999",
+ IncludeNLogData = false
+ };
+ var sentinalRule = new LoggingRule("*", LogLevel.Trace, sentinalTarget);
+ LogManager.Configuration.AddTarget("sentinal", sentinalTarget);
+ LogManager.Configuration.LoggingRules.Add(sentinalRule);
+
+ // Setup the logging view for Harvester - http://harvester.codeplex.com
+ var harvesterTarget = new OutputDebugStringTarget()
+ {
+ Name = "harvester",
+ Layout = "${log4jxmlevent:includeNLogData=false}"
+ };
+ var harvesterRule = new LoggingRule("*", LogLevel.Trace, harvesterTarget);
+ LogManager.Configuration.AddTarget("harvester", harvesterTarget);
+ LogManager.Configuration.LoggingRules.Add(harvesterRule);
+#endif
+
+ LogManager.ReconfigExistingLoggers();
+
+ Instance = LogManager.GetCurrentClassLogger();
+ }
+ }
+}
diff --git a/MConnectSDK/MConnectClient.cs b/MConnectSDK/MConnectClient.cs
index 391cd88..a45184c 100644
--- a/MConnectSDK/MConnectClient.cs
+++ b/MConnectSDK/MConnectClient.cs
@@ -834,7 +834,10 @@ namespace MConnectSDK
// riporto in risposta i dati...
answ.DeviceCode = tokResp.device_code;
answ.UserCode = tokResp.user_code;
- answ.QrCode = string.Format(WebAppUrl, tokResp.user_code, MachineID);
+
+
+ string userCode = (tokResp != null && tokResp.user_code != null) ? tokResp.user_code : "";
+ answ.QrCode = string.Format(WebAppUrl, userCode, MachineID);
sb.AppendLine("--------------------------------------------------");
sb.AppendLine(string.Format("{0:HH.mm.ss.fff} | Try OAuth process", DateTime.Now));
sb.AppendLine("--------------------------------------------------");
@@ -1150,10 +1153,10 @@ namespace MConnectSDK
if (obj.LoginStatus != UserStatus.IMPORTED)
{
// elimino ANCHE da cache pwd (se c'era)
- if (userPwdLocalCache.Exists(x => x.user_id == obj.UserId))
+ if (userPwdLocalCache.Exists(x => x.Username == obj.Username))
{
var tmpData = userPwdLocalCache;
- tmpData.RemoveAll(x => x.user_id == obj.UserId);
+ tmpData.RemoveAll(x => x.Username == obj.Username);
userPwdLocalCache = tmpData;
}
// elimino...
@@ -1198,6 +1201,11 @@ namespace MConnectSDK
var taskCliInfo = Task.Run(() => GetClientStatusAsync());
taskCliInfo.Wait();
_currStatus = taskCliInfo.Result;
+#if false1
+ // SOLO SE E' tutot ok come connessione procedo...
+ if (_currStatus.CloudStatusOk)
+ {
+#endif
// parto pessimista...
bool userOk = false;
// variabili accessorie
@@ -1229,15 +1237,23 @@ namespace MConnectSDK
if (resp.status == "Ok" || resp.statusCode == 200)
{
userData item = resp.result.user;
- // creo obj userData...
- var imgRes = Task.Run(() => Utils.getImageAsync(pageUrlImgDownload, item.Image_Url));
- imgRes.Wait();
+
Image userImg = null;
- if (imgRes.Result != null)
+ try
{
- //userImg = imgRes.Result;
- userImg = imgRes.Result;
+ // creo obj userData... SE HO immagine...
+ if (item.Image_Url != "")
+ {
+ var imgRes = Task.Run(() => Utils.getImageAsync(pageUrlImgDownload, item.Image_Url));
+ imgRes.Wait();
+ if (imgRes.Result != null)
+ {
+ userImg = imgRes.Result;
+ }
+ }
}
+ catch (Exception ex)
+ { }
userFound = new UserData()
{
UserId = item.Id,
@@ -1282,7 +1298,7 @@ namespace MConnectSDK
string pwdCyph = GenerateSaltedHash(password, salt.ToString());
// cerco nelle pwd salvate: se lo trovo e NON HO una pwd --> accetto questa e salvo!
var _usrPwdList = userPwdLocalCache;
- var usrId_Found = _usrPwdList.Find(x => x.user_id == userFound.UserId);
+ var usrId_Found = _usrPwdList.Find(x => x.Username == userFound.Username);
if (usrId_Found != null)
{
// verifico la pwd locale...
@@ -1307,7 +1323,7 @@ namespace MConnectSDK
{
var _userPwd = new userPwdData()
{
- user_id = userFound.UserId,
+ Username = userFound.Username,
passwordCyph = pwdCyph
};
_usrPwdList.Add(_userPwd);
@@ -1342,18 +1358,6 @@ namespace MConnectSDK
_currStatus.Payload = userList;
_currStatus.Error = errore;
}
- //else
- //{
- // if (userFound != null && errore.Reason != Reason.AllOk)
- // {
- // errore = new ErrorResult
- // {
- // Reason = Reason.UserNotFound,
- // message = "Username not found"
- // };
- // _currStatus.Error = errore;
- // }
- //}
}
else
{
@@ -1375,6 +1379,13 @@ namespace MConnectSDK
}
_currStatus.Error = errore;
}
+#if false
+ }
+ else
+ {
+ _currStatus.Payload.Message = "Errore: manca connessione a cloud";
+ }
+#endif
reqStatus = _currStatus;
});
return _currStatus;
diff --git a/MConnectSDK/MConnectSDK.csproj b/MConnectSDK/MConnectSDK.csproj
index 4da0161..0c7e530 100644
--- a/MConnectSDK/MConnectSDK.csproj
+++ b/MConnectSDK/MConnectSDK.csproj
@@ -35,7 +35,7 @@
..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll
- ..\packages\NLog.4.6.0\lib\net45\NLog.dll
+ ..\packages\NLog.4.6.1\lib\net45\NLog.dll
..\packages\Pipelines.Sockets.Unofficial.2.0.11\lib\net461\Pipelines.Sockets.Unofficial.dll
@@ -90,6 +90,7 @@
SharedAssemblyInfo.cs
+
diff --git a/MConnectSDK/Utils.cs b/MConnectSDK/Utils.cs
index 9dc6432..863db71 100644
--- a/MConnectSDK/Utils.cs
+++ b/MConnectSDK/Utils.cs
@@ -80,10 +80,12 @@ namespace MConnectSDK
}
///
/// Effettua download async della pagina indicata
- ///
+ ///
///
+ ///
public static async Task getPageAsync(string pageURL)
{
+ Log.Instance.Info($"[getPageAsync]: Calling URL: {pageURL}");
string answ = "";
// ... Use HttpClient.
using (HttpClient client = new HttpClient())
@@ -101,6 +103,7 @@ namespace MConnectSDK
///
public static async Task getPageAsync(string pageURL, string oauthToken)
{
+ Log.Instance.Info($"[getPageAsync]: Calling URL: {pageURL} | OAuth Token: {oauthToken}");
string answ = "";
//var authToken = new AuthenticationHeaderValue("Bearer", oauthToken);
// ... Use HttpClient.
@@ -124,6 +127,7 @@ namespace MConnectSDK
/// token da passare come bearer
public static async Task putAsync(Uri reqUri, HttpContent callCont, string oauthToken)
{
+ Log.Instance.Info($"[putAsync]: Calling reqUri: {reqUri} | callCont Token: {oauthToken} | callCont: {callCont}");
string answ = "";
// ... Use HttpClient.
using (HttpClient client = new HttpClient())
@@ -152,6 +156,7 @@ namespace MConnectSDK
/// path immagine (cui applicare encode) e a cui appendere alt=media...
public static async Task getImageAsync(string pageURL, string imagePath)
{
+ Log.Instance.Info($"[getImageAsync]: Calling URL: {pageURL} | imagePath: {imagePath}");
Image answ = null;
string imgEncoded = Uri.EscapeDataString(imagePath);
string fullImgPath = pageURL + imgEncoded + "?alt=media";
@@ -175,6 +180,7 @@ namespace MConnectSDK
///
public static async Task postUriAsync(Uri reqUri, HttpContent callCont)
{
+ Log.Instance.Info($"[postUriAsync]: Calling reqUri: {reqUri} | callCont: {callCont}");
var response = string.Empty;
using (var client = new HttpClient())
{
@@ -195,6 +201,7 @@ namespace MConnectSDK
///
public static async Task uploadAsync(string pageUrl, string fileName, byte[] fileContent)
{
+ Log.Instance.Info($"[uploadAsync]: Calling pageUrl: {pageUrl} | fileName: {fileName}");
string answ = "";
using (var client = new HttpClient())
{
@@ -696,9 +703,9 @@ namespace MConnectSDK
public class userPwdData
{
///
- /// Codice utente (es asfd.0002)
+ /// UserName
///
- public string user_id = "";
+ public string Username = "";
///
/// Password (in formato cifrato)
///
@@ -712,7 +719,7 @@ namespace MConnectSDK
{
var base64 = (string)reader.Value;
Image answ = null;
- if(reader.Value != null && (string)reader.Value != "")
+ if (reader.Value != null && (string)reader.Value != "")
{
answ = Image.FromStream(new MemoryStream(Convert.FromBase64String(base64)));
}
diff --git a/MConnectSDK/packages.config b/MConnectSDK/packages.config
index ba937b5..47a6897 100644
--- a/MConnectSDK/packages.config
+++ b/MConnectSDK/packages.config
@@ -1,7 +1,7 @@
-
+
diff --git a/SharedAssemblyInfo.cs b/SharedAssemblyInfo.cs
index 393e97b..1d86704 100644
--- a/SharedAssemblyInfo.cs
+++ b/SharedAssemblyInfo.cs
@@ -8,7 +8,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © Steamware 2019")]
[assembly: AssemblyTrademark("_")]
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("1.1.1904.57")]
-[assembly: AssemblyFileVersion("1.1.1904.57")]
-
-
+[assembly: AssemblyVersion("1.1.1904.61")]
+[assembly: AssemblyFileVersion("1.1.1904.61")]
diff --git a/TestClient/NLog.config b/TestClient/NLog.config
index 2ecfef7..47b21c9 100644
--- a/TestClient/NLog.config
+++ b/TestClient/NLog.config
@@ -18,39 +18,14 @@
-->
-
-
-
+ />
-
-
\ No newline at end of file
diff --git a/TestClient/mconnect.conf.yaml b/TestClient/mconnect.conf.yaml
index d7e94c8..1b228df 100644
--- a/TestClient/mconnect.conf.yaml
+++ b/TestClient/mconnect.conf.yaml
@@ -5,7 +5,7 @@ conf:
PingTarget: "stg.api.maestroconnect.scmgroup.com"
AliveTarget: "https://stg.api.maestroconnect.scmgroup.com/health"
BaseUrl: "https://stg.api.maestroconnect.scmgroup.com/api"
- WebAppUrl: "https://smart.maestroconnect.com/deviceauth?user_code={0}&machineID={1}"
+ WebAppUrl: "https://stg.maestroconnect.scmgroup.com/scm/settings/machine-settings/?nav=activation&user_code={0}&machineID={1}"
MemoryLayer:
Redis:
ConnectionString: "127.0.0.1,abortConnect=false,ssl=false"