Aggiunto file di conf YAML + NuGet package
This commit is contained in:
@@ -318,28 +318,28 @@ namespace MConnectSDK
|
||||
{
|
||||
// init in stato ND...
|
||||
isHmiEnrolled = false,
|
||||
cloudStatus = false,
|
||||
localStatus = false,
|
||||
source = Source.offline,
|
||||
callResult = false
|
||||
CloudStatusOk = false,
|
||||
LocalStatusOk = false,
|
||||
Source = SourceType.OFFLINE,
|
||||
CallResultOk = false
|
||||
};
|
||||
// verifico REDIS in primis
|
||||
answ.localStatus = checkRedisAlive();
|
||||
if (answ.localStatus)
|
||||
answ.LocalStatusOk = checkRedisAlive();
|
||||
if (answ.LocalStatusOk)
|
||||
{
|
||||
// cerco i TOKEN in REDIS...
|
||||
answ.isAuth = !string.IsNullOrEmpty(refresh_token);
|
||||
answ.isHmiEnrolled = enrollDate < DateTime.Now;
|
||||
answ.source = Source.local;
|
||||
answ.Source = SourceType.LOCAL;
|
||||
}
|
||||
|
||||
// verifico chiamata server...
|
||||
if (_currParam.testMode)
|
||||
{
|
||||
// Fingo che tutto vada bene e di conseguenza setto risposta...
|
||||
answ.cloudStatus = true;
|
||||
answ.source = Source.cloud;
|
||||
answ.callResult = true;
|
||||
answ.CloudStatusOk = true;
|
||||
answ.Source = SourceType.CLOUD;
|
||||
answ.CallResultOk = true;
|
||||
// attesa random...
|
||||
Random r = new Random();
|
||||
Thread.Sleep(100 + r.Next(0, 100));
|
||||
@@ -484,18 +484,23 @@ namespace MConnectSDK
|
||||
}
|
||||
/// <summary>
|
||||
/// Metodo di INIT della classe di comunicazione
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
/// <param name="token"></param>
|
||||
/// <param name="progress"></param>
|
||||
/// <returns></returns>
|
||||
public Result initSDKAsync()
|
||||
public async Task<Result> initSDKAsync(CancellationToken token, IProgress<Result> progress)
|
||||
{
|
||||
// svuoto TUTTI i dati x INIT...
|
||||
//ML.redFlushDB(_currParam.defaultDb);
|
||||
ML.redFlushKey("MCC*", _currParam.defaultDb);
|
||||
enrollDate = DateTime.Now.AddYears(100);
|
||||
// iniziod a watchdog...
|
||||
setWatchdog();
|
||||
// init output
|
||||
reqStatus = preCheckStatus();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// svuoto TUTTI i dati x INIT...
|
||||
//ML.redFlushDB(_currParam.defaultDb);
|
||||
ML.redFlushKey("MCC*", _currParam.defaultDb);
|
||||
enrollDate = DateTime.Now.AddYears(100);
|
||||
// iniziod a watchdog...
|
||||
setWatchdog();
|
||||
// init output
|
||||
reqStatus = preCheckStatus();
|
||||
});
|
||||
return reqStatus;
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Pipelines.Sockets.Unofficial.1.0.9\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
|
||||
<HintPath>..\packages\Pipelines.Sockets.Unofficial.1.1.14\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\StackExchange.Redis.2.0.519\lib\net461\StackExchange.Redis.dll</HintPath>
|
||||
@@ -81,6 +81,9 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\YamlDotNet.5.4.0\lib\net45\YamlDotNet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SharedAssemblyInfo.cs">
|
||||
|
||||
+24
-22
@@ -165,47 +165,48 @@
|
||||
/// <summary>
|
||||
/// Indica lo stato di disponibilità del CLOUD (= connesso)
|
||||
/// </summary>
|
||||
public bool cloudStatus = false;
|
||||
public bool CloudStatusOk = false;
|
||||
/// <summary>
|
||||
/// Indica la disponibilità dello storage LOCALE (= connesso)
|
||||
/// </summary>
|
||||
public bool localStatus = false;
|
||||
public bool LocalStatusOk = false;
|
||||
/// <summary>
|
||||
/// Sorgente da cui deriva l'esito dell'operazione
|
||||
/// </summary>
|
||||
public Source source;
|
||||
public SourceType Source;
|
||||
/// <summary>
|
||||
/// Indica se la chiamata sia andata a buon fine (success) oppure ci siano stati errori/problemi
|
||||
/// </summary>
|
||||
public bool callResult = false;
|
||||
public bool CallResultOk = false;
|
||||
/// <summary>
|
||||
/// Property class associata ad eventuale errore riscontrato
|
||||
/// </summary>
|
||||
public Error error;
|
||||
public ErrorResult error;
|
||||
/// <summary>
|
||||
/// Payload associato alla chiamata
|
||||
/// </summary>
|
||||
public PayLoad payLoad;
|
||||
public PayLoadResult payLoad;
|
||||
}
|
||||
/// <summary>
|
||||
/// Enum delle sorgenti di comunicazione
|
||||
/// </summary>
|
||||
public enum Source
|
||||
public enum SourceType
|
||||
{
|
||||
/// <summary>
|
||||
/// Piattaforma Cloud MaestroConnect
|
||||
/// </summary>
|
||||
cloud = 0,
|
||||
CLOUD = 0,
|
||||
/// <summary>
|
||||
/// Storage cache locale
|
||||
/// </summary>
|
||||
local,
|
||||
LOCAL,
|
||||
/// <summary>
|
||||
/// Offline
|
||||
/// </summary>
|
||||
offline
|
||||
OFFLINE
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Enum per status
|
||||
/// </summary>
|
||||
@@ -213,25 +214,26 @@
|
||||
{
|
||||
KO = 0,
|
||||
OK = 1
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Enum per causali errori
|
||||
/// </summary>
|
||||
public enum Reason
|
||||
{
|
||||
NotFound = 0,
|
||||
PwdMismatch
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Classe errore chiamata
|
||||
/// </summary>
|
||||
public class Error
|
||||
public class ErrorResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum per causali errori
|
||||
/// </summary>
|
||||
public enum Reason
|
||||
{
|
||||
NotFound = 0,
|
||||
PwdMismatch
|
||||
}
|
||||
/// <summary>
|
||||
/// Classe causale errore
|
||||
/// </summary>
|
||||
public Reason reason;
|
||||
public Reason Reason;
|
||||
/// <summary>
|
||||
/// Messaggio di dettaglio errore
|
||||
/// </summary>
|
||||
@@ -241,7 +243,7 @@
|
||||
/// <summary>
|
||||
/// Classe base per ritnro dati chiamate
|
||||
/// </summary>
|
||||
public class PayLoad
|
||||
public class PayLoadResult
|
||||
{
|
||||
|
||||
}
|
||||
@@ -250,7 +252,7 @@
|
||||
/// Classe che contiene PayLoad x fare auth iniziale,
|
||||
/// contentente i dati x user auth da mostrare con HMI
|
||||
/// </summary>
|
||||
public class userAuthData : PayLoad
|
||||
public class userAuthData : PayLoadResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Codice device
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
|
||||
<package id="NLog" version="4.5.11" targetFramework="net462" />
|
||||
<package id="Pipelines.Sockets.Unofficial" version="1.0.9" targetFramework="net462" />
|
||||
<package id="Pipelines.Sockets.Unofficial" version="1.1.14" targetFramework="net462" />
|
||||
<package id="StackExchange.Redis" version="2.0.519" targetFramework="net462" />
|
||||
<package id="System.Buffers" version="4.5.0" targetFramework="net462" />
|
||||
<package id="System.Diagnostics.PerformanceCounter" version="4.5.0" targetFramework="net462" />
|
||||
@@ -12,4 +12,5 @@
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net462" />
|
||||
<package id="System.Threading.Channels" version="4.5.0" targetFramework="net462" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net462" />
|
||||
<package id="YamlDotNet" version="5.4.0" targetFramework="net462" />
|
||||
</packages>
|
||||
+25
-4
@@ -119,9 +119,9 @@ namespace TestClient
|
||||
sb.AppendLine("-------------------------");
|
||||
sb.AppendLine("isAuth: " + reqStatus.isAuth);
|
||||
sb.AppendLine("isHmiEnrolled: " + reqStatus.isHmiEnrolled);
|
||||
sb.AppendLine("cloudConnection: " + reqStatus.cloudStatus);
|
||||
sb.AppendLine("localConnection: " + reqStatus.localStatus);
|
||||
sb.AppendLine("callSuccess: " + reqStatus.callResult);
|
||||
sb.AppendLine("cloudConnection: " + reqStatus.CloudStatusOk);
|
||||
sb.AppendLine("localConnection: " + reqStatus.LocalStatusOk);
|
||||
sb.AppendLine("callSuccess: " + reqStatus.CallResultOk);
|
||||
sb.AppendLine("-------------------------");
|
||||
lblReqStatus.Text = sb.ToString();
|
||||
sb.AppendLine("");
|
||||
@@ -219,7 +219,28 @@ namespace TestClient
|
||||
await Task.Run(() =>
|
||||
{
|
||||
MCC = new MConnectClient(txtMConnectID.Text.Trim(), txtClientID.Text.Trim(), param);
|
||||
reqStatus = MCC.initSDKAsync();
|
||||
|
||||
// elimino eventuali cancel presenti...
|
||||
if (_cts.IsCancellationRequested)
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
}
|
||||
CancellationToken token = _cts.Token;
|
||||
// gestione progress...
|
||||
var progressHandler = new Progress<Result>(value =>
|
||||
{
|
||||
#if false
|
||||
// mostro i dati SPECIFICI x AUTH...
|
||||
updateAuthData(value);
|
||||
#endif
|
||||
});
|
||||
var progress = progressHandler as IProgress<Result>;
|
||||
|
||||
var taskResult = MCC.initSDKAsync(token, progress);
|
||||
|
||||
#if false
|
||||
reqStatus = MCC.initSDKAsync(token, progress);
|
||||
#endif
|
||||
|
||||
// sistemo retVal
|
||||
saveTokenResp();
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#File di conf per MConnectClientSDK
|
||||
conf:
|
||||
clientId: “UTE_TEST”
|
||||
machineId: “ABCD000231234”
|
||||
memoryLayer:
|
||||
redis:
|
||||
connectionString: “127.0.0.1,abortConnect=false,ssl=false“
|
||||
dbIndex: 1
|
||||
module: “MCC”
|
||||
Reference in New Issue
Block a user