Compare commits
27 Commits
v_1.3.2011.220
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 17835abb6e | |||
| ebeedf2bc2 | |||
| f2a7ce8478 | |||
| 72d3eaa088 | |||
| ac8ba8c05e | |||
| 2a7611150d | |||
| 1e0b47fdb4 | |||
| 076d7fc031 | |||
| 4a7eb2de75 | |||
| 62a17e38c4 | |||
| 2967fb3fc6 | |||
| 97409fac7e | |||
| 81b5b208e4 | |||
| 88b2ab5e58 | |||
| 7f6281457b | |||
| 002f747ca3 | |||
| 394bb0d406 | |||
| 3ceed9ff80 | |||
| 2d0852866a | |||
| 720198b4d4 | |||
| bd10dde7a2 | |||
| 9b5ea0a842 | |||
| 58a68e1282 | |||
| 9e5f178e12 | |||
| dfad3f70f6 | |||
| b6614de3fa | |||
| 0f7c2f4f00 |
+151
@@ -0,0 +1,151 @@
|
||||
variables:
|
||||
NUGET_PATH: 'C:\Tools\nuget.exe'
|
||||
MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe'
|
||||
ASPNET_MERGE_PATH: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools'
|
||||
NEXUS_PATH: 'SCM/MConnectSDK'
|
||||
APP_NAME: 'MConnectSDK'
|
||||
SOL_NAME: 'MConnect'
|
||||
VERS_MAIN: '2.0'
|
||||
NEW_REL: ''
|
||||
OUTPUT_DIR: ''
|
||||
|
||||
# helper x fix pacchetti nuget da repo locale nexus.steamware.net
|
||||
.nuget-fix: &nuget-fix
|
||||
- |
|
||||
$hasSource = C:\Tools\nuget.exe sources list | find "`"Steamware Nexus`"" /C
|
||||
if ($hasSource -eq 0) {
|
||||
C:\Tools\nuget.exe sources Add -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"$NEXUS_PASSWD`""
|
||||
} else {
|
||||
C:\Tools\nuget.exe sources Update -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"$NEXUS_PASSWD`""
|
||||
}
|
||||
echo $hasSource
|
||||
|
||||
# $env:NEW_REL = $env:VERS_MAIN+"."+(get-date –format yyMM)+"."+$CI_PIPELINE_IID
|
||||
# helper x fix version number
|
||||
.version-fix: &version-fix
|
||||
- |
|
||||
$env:NEW_REL = $env:VERS_MAIN+"."+(get-date –format yyMM)+"."+(get-date –format dHH)
|
||||
$contenuto = Get-Content -path 'SharedAssemblyInfo.cs' -Raw
|
||||
$newContenuto = $contenuto -replace '1.0.0.0', $env:NEW_REL
|
||||
$newContenuto | Set-Content -Path 'SharedAssemblyInfo.cs'
|
||||
echo "Set vers: $env:NEW_REL"
|
||||
|
||||
# helper pulizia files zip
|
||||
.cleanup-zip: &cleanup-zip
|
||||
- |
|
||||
$env:OUTPUT_DIR = "Releases\" + $CI_COMMIT_BRANCH + "\*"
|
||||
if ((Test-Path $env:OUTPUT_DIR))
|
||||
{
|
||||
Remove-Item $env:OUTPUT_DIR -Force -Recurse -ErrorAction Ignore
|
||||
}
|
||||
echo "Clening ZIP dir: $env:OUTPUT_DIR"
|
||||
|
||||
# helper creazione files zip
|
||||
.zipper: &zipper
|
||||
- |
|
||||
$7zipPath = $env:ProgramFiles+"\7-Zip\7z.exe"
|
||||
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
|
||||
throw "7 zip file '$7zipPath' not found"
|
||||
}
|
||||
Set-Alias 7zip $7zipPath
|
||||
$Target = "Releases\" + $CI_COMMIT_BRANCH + "\" + $env:APP_NAME + ".zip"
|
||||
$Source = "$env:APP_NAME\bin\*"
|
||||
7zip a -tzip $Target $Source
|
||||
echo "called ZIP $Source --> $Target"
|
||||
|
||||
# helper creazione hash files
|
||||
.hashBuild: &hashBuild
|
||||
- |
|
||||
$Target = "Releases\" + $CI_COMMIT_BRANCH + "\" + $env:APP_NAME + ".zip"
|
||||
$MD5 = Get-FileHash $Target -Algorithm MD5
|
||||
$SHA1 = Get-FileHash $Target -Algorithm SHA1
|
||||
New-Item $Target".md5"
|
||||
New-Item $Target".sha1"
|
||||
$MD5.Hash | Set-Content -Path $Target".md5"
|
||||
$SHA1.Hash | Set-Content -Path $Target".sha1"
|
||||
|
||||
echo "Created HASH files for $Target"
|
||||
|
||||
# helper x send su NEXUS
|
||||
.nexusUpload: &nexusUpload
|
||||
- |
|
||||
Set-Alias mCurl C:\Windows\system32\curl.exe
|
||||
$currentDate = get-date -format yyMM;
|
||||
$currentTime = get-date -format ddHH;
|
||||
$VersNumb = $env:NEW_REL
|
||||
echo "Curr Version: $VersNumb"
|
||||
$FileManIn="VersGen\manifest.xml"
|
||||
$FileManOut=$env:APP_NAME +"\Resources\manifest.xml"
|
||||
$FileCLogIn="VersGen\ChangeLog.html"
|
||||
$FileCLogOut=$env:APP_NAME +"\Resources\ChangeLog.html"
|
||||
echo "Manifest path: $FileManOut"
|
||||
echo "ChangeLog path: $FileCLogOut"
|
||||
|
||||
if($CI_COMMIT_BRANCH -eq "master")
|
||||
{
|
||||
$version = "stable"
|
||||
}
|
||||
else
|
||||
{
|
||||
$version = "unstable"
|
||||
}
|
||||
$manData = Get-Content $FileManIn
|
||||
$manData = $manData -replace "1.0.0.0", $VersNumb
|
||||
$manData = $manData -replace "{{DIRNAME}}", $env:NEXUS_PATH
|
||||
$manData = $manData -replace "{{BRANCHNAME}}", "$version/LAST"
|
||||
$manData = $manData -replace "{{PACKNAME}}", $env:APP_NAME
|
||||
Set-Content -Path $FileManOut -Value $manData
|
||||
$clogData = Get-Content $FileCLogIn
|
||||
$clogData = $clogData -replace "{{CURRENT-REL}}", $VersNumb
|
||||
Set-Content -Path $FileCLogOut -Value $clogData
|
||||
$File2Send = Get-ChildItem("Releases\$CI_COMMIT_BRANCH\*")
|
||||
ForEach ($File in $File2Send) {
|
||||
$FileName = Split-Path $File -leaf
|
||||
echo "mCurl -s -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/$FileName"
|
||||
mCurl -s -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/$FileName
|
||||
echo "mCurl -s -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/ARCHIVE/$VersNumb/$FileName"
|
||||
mCurl -s -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/ARCHIVE/$VersNumb/$FileName
|
||||
}
|
||||
echo "mCurl -s -u GitLab:$NEXUS_PASSWD --upload-file $FileManOut https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/manifest.xml"
|
||||
mCurl -s -u GitLab:$NEXUS_PASSWD --upload-file $FileManOut https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/manifest.xml
|
||||
echo "mCurl -s -u GitLab:$NEXUS_PASSWD --upload-file $FileCLogOut https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/ChangeLog.html"
|
||||
mCurl -s -u GitLab:$NEXUS_PASSWD --upload-file $FileCLogOut https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/ChangeLog.html
|
||||
|
||||
stages:
|
||||
- build
|
||||
- release
|
||||
|
||||
SDK:Build:
|
||||
stage: build
|
||||
tags:
|
||||
- win
|
||||
# only:
|
||||
# refs:
|
||||
# - develop
|
||||
before_script:
|
||||
- *nuget-fix
|
||||
- '& "$env:NUGET_PATH" restore "$env:SOL_NAME.sln"' # path alla solution corrente
|
||||
- *version-fix
|
||||
script:
|
||||
- '& "$env:MSBUILD_PATH" $env:APP_NAME\$env:APP_NAME.csproj -target:Build /p:Configuration=Debug /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
|
||||
|
||||
SDK:Release:
|
||||
stage: release
|
||||
tags:
|
||||
- win
|
||||
only:
|
||||
refs:
|
||||
- develop
|
||||
- main
|
||||
- master
|
||||
before_script:
|
||||
- *nuget-fix
|
||||
- '& "$env:NUGET_PATH" restore "$env:SOL_NAME.sln"' # path alla solution corrente
|
||||
- *version-fix
|
||||
- *cleanup-zip
|
||||
script:
|
||||
- '& "$env:MSBUILD_PATH" $env:APP_NAME\$env:APP_NAME.csproj -target:Build /p:Configuration=Release /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
|
||||
- *zipper
|
||||
- *hashBuild
|
||||
- *nexusUpload
|
||||
needs: ["SDK:Build"]
|
||||
Vendored
+4
-4
@@ -10,10 +10,10 @@ pipeline {
|
||||
|
||||
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
|
||||
script {
|
||||
withEnv(['NEXT_BUILD_NUMBER=220']) {
|
||||
// env.versionNumber = VersionNumber(versionNumberString : '1.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
||||
env.versionNumber = VersionNumber(versionNumberString : '1.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
env.versionNumberBeta = VersionNumber(versionNumberString : '1.3.${BUILD_DATE_FORMATTED, "yyMM"}-beta.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
withEnv(['NEXT_BUILD_NUMBER=225']) {
|
||||
// env.versionNumber = VersionNumber(versionNumberString : '2.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
||||
env.versionNumber = VersionNumber(versionNumberString : '2.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
env.versionNumberBeta = VersionNumber(versionNumberString : '2.0.${BUILD_DATE_FORMATTED, "yyMM"}-beta.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
env.APP_NAME = 'MConnectSDK'
|
||||
}
|
||||
}
|
||||
+16
-16
@@ -6,28 +6,28 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MConnectSDK
|
||||
{
|
||||
public enum ActStatus
|
||||
public enum ACTIVITY_STATUS
|
||||
{
|
||||
Defined = 0,
|
||||
ToDo,
|
||||
Assigned,
|
||||
Done
|
||||
DEFINED = 0,
|
||||
TO_DO,
|
||||
ASSIGNED,
|
||||
DONE
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum tipologie di manutenzione gestite
|
||||
/// </summary>
|
||||
public enum CMS_MAINTENANCE_TYPE
|
||||
public enum MAINTENANCE_TYPE
|
||||
{
|
||||
EXP_DATE = 0,
|
||||
MACHINE_INTERVAL = 1,
|
||||
TIME_INTERVAL = 2
|
||||
MACHINE_INTERVAL = 1, //ACTIVE_TIME
|
||||
TIME_INTERVAL = 2 //HOUR
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum unità di misura gestite
|
||||
/// </summary>
|
||||
public enum CMS_MAINTENANCE_UNIT_OF_MEASURE
|
||||
public enum MAINTENANCE_UNIT_OF_MEASURE
|
||||
{
|
||||
mm = 0,
|
||||
D = 1,
|
||||
@@ -35,19 +35,19 @@ namespace MConnectSDK
|
||||
M = 3
|
||||
}
|
||||
|
||||
public enum OpStatus
|
||||
public enum OP_STATUS
|
||||
{
|
||||
ToDo = 0,
|
||||
Done
|
||||
TO_DO = 0,
|
||||
DONE
|
||||
}
|
||||
|
||||
public enum OpType
|
||||
public enum OP_TYPE
|
||||
{
|
||||
Ordinary = 0,
|
||||
Scheduled
|
||||
ORDINARY = 0,
|
||||
SCHEDULED
|
||||
}
|
||||
|
||||
public enum SdkErrors
|
||||
public enum SDK_REPLY
|
||||
{
|
||||
NO_ERROR = 0,
|
||||
ERR_CLOUD_NOT_FOUND,
|
||||
|
||||
+226
-54
@@ -34,7 +34,7 @@ namespace MConnectSDK
|
||||
/// <summary>
|
||||
/// URL BASE per le chiamate
|
||||
/// <summary>
|
||||
protected string BaseUrl = @"https://stg.api.maestroconnect.scmgroup.com/";
|
||||
protected string BaseUrl = @"https://stg.api.maestroconnect.scmgroup.com/clients";
|
||||
|
||||
/// <summary>
|
||||
/// ID applicativo/client per piattaforma MaestroConnect (differente per UTE)
|
||||
@@ -61,6 +61,11 @@ namespace MConnectSDK
|
||||
/// <summary>
|
||||
protected memLayer ML;
|
||||
|
||||
/// <summary>
|
||||
/// URL BASE per le chiamate OAuth
|
||||
/// <summary>
|
||||
protected string OAuthUrl = @"https://stg.api.maestroconnect.scmgroup.com/api";
|
||||
|
||||
/// <summary>
|
||||
/// Semaforo ping PRELIMINARE
|
||||
/// </summary>
|
||||
@@ -90,6 +95,11 @@ namespace MConnectSDK
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Versione delle API
|
||||
/// <summary>
|
||||
public string ApiVersion;
|
||||
|
||||
/// <summary>
|
||||
/// ID univoco dell'HMI per piattaforma MaestroConnect
|
||||
/// <summary>
|
||||
@@ -252,6 +262,41 @@ namespace MConnectSDK
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL pagina per ENROLL/ATTIVAZIONE (parametrico)
|
||||
/// <summary>
|
||||
protected string pageUrlActivation
|
||||
{
|
||||
get
|
||||
{
|
||||
string activationUrl = $"{BaseUrl}/{organizationCode}/machines/{MachineID}/activation";
|
||||
return activationUrl;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL pagina per ASSEGNAZIONE (parametrica)
|
||||
/// <summary>
|
||||
protected string pageUrlAssignment
|
||||
{
|
||||
get
|
||||
{
|
||||
string assignmentUrl = "";
|
||||
// definizione in base alla ApiVersion
|
||||
if (ApiVersion == "v1")
|
||||
{
|
||||
assignmentUrl = $"{BaseUrl}/{organizationCode}/machines/{MachineID}/assignment";
|
||||
}
|
||||
else if (ApiVersion == "v2")
|
||||
{
|
||||
assignmentUrl = $"{BaseUrl}-v2/{organizationCode}/machines/{MachineID}/assignment";
|
||||
}
|
||||
return assignmentUrl;
|
||||
}
|
||||
}
|
||||
|
||||
// LEGACY to remove after v2 release
|
||||
#if false
|
||||
/// <summary>
|
||||
/// URL pagina per check enroll (parametrico)
|
||||
/// <summary>
|
||||
@@ -260,12 +305,18 @@ namespace MConnectSDK
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
//string shortBaseUrl = BaseUrl.Replace("/api", "");
|
||||
string shortBaseUrl = RemoveFromEnd(BaseUrl, "/api");
|
||||
answ = $"{shortBaseUrl}/clients/{organizationCode}/machines/{MachineID}";
|
||||
if (ApiVersion == "v1")
|
||||
{
|
||||
answ = $"{BaseUrl}/{organizationCode}/machines/{MachineID}";
|
||||
}
|
||||
else if (ApiVersion == "v2")
|
||||
{
|
||||
answ = $"{BaseUrl}-v2/{organizationCode}/machines/{MachineID}";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// URL pagina per Download Immagini ( https://firebasestorage.googleapis.com/v0/b/scm-mconnect.appspot.com/o/ )
|
||||
@@ -594,7 +645,7 @@ namespace MConnectSDK
|
||||
private void doTokenStep()
|
||||
{
|
||||
// parametri chiamata
|
||||
Uri callUri = new Uri(BaseUrl + "/oauth2/token");
|
||||
Uri callUri = new Uri(OAuthUrl + "/oauth2/token");
|
||||
// encapsulo clientID
|
||||
var payload = "{\"client_id\": \"" + ClientID + "\"}";
|
||||
HttpContent callCont = new StringContent(payload, Encoding.UTF8, "application/json");
|
||||
@@ -628,7 +679,7 @@ namespace MConnectSDK
|
||||
if (pingOk && cloudOk)
|
||||
{
|
||||
// parametri chiamata
|
||||
Uri callUri = new Uri(BaseUrl + "/oauth2/verification");
|
||||
Uri callUri = new Uri(OAuthUrl + "/oauth2/verification");
|
||||
// !!! FARE fix hard coded !!!
|
||||
var payload = "{\"client_id\": \"" + ClientID + "\", \"device_code\": \"" + tokResp.device_code + "\"}";
|
||||
HttpContent callCont = new StringContent(payload, Encoding.UTF8, "application/json");
|
||||
@@ -665,46 +716,6 @@ namespace MConnectSDK
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ottiene i dati licenza da MaestroConnect
|
||||
/// <summary>
|
||||
/// <returns>Dati licenza<returns>
|
||||
private LicenseData GetLicenseMConnect()
|
||||
{
|
||||
LicenseData result = null;
|
||||
|
||||
// controllo preliminare ping/cloud..
|
||||
if (pingOk && cloudOk)
|
||||
{
|
||||
//controllo con la chiamata della clientInfo...
|
||||
var taskCliInfo = Task.Run(() => GetClientStatusAsync());
|
||||
taskCliInfo.Wait();
|
||||
|
||||
// parametri chiamata
|
||||
string shortBaseUrl = BaseUrl.Replace(".com/api", ".com/clients");
|
||||
|
||||
string pageUrl = $"{shortBaseUrl}/{organizationCode}/machines/{MachineID}/license";
|
||||
// effettuo call
|
||||
Console.WriteLine("-> " + verifResp.access_token);
|
||||
var taskRes = Task.Run(() => Utils.getPageAsync(pageUrl, verifResp.access_token));
|
||||
taskRes.Wait();
|
||||
try
|
||||
{
|
||||
var resp = JsonConvert.DeserializeObject<LicenseResponse>(taskRes.Result);
|
||||
result = resp.result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.WriteLine(taskRes.Result.ToString());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parsing file di configurazione
|
||||
/// <summary>
|
||||
@@ -726,9 +737,11 @@ namespace MConnectSDK
|
||||
var config = mapping.Children["conf"];
|
||||
|
||||
// imposto val da file YAML...
|
||||
ApiVersion = config["ApiVersion"].ToString();
|
||||
MachineID = config["MachineID"].ToString();
|
||||
ClientID = config["Client_ID"].ToString();
|
||||
// URL base x le chiamate REALI
|
||||
OAuthUrl = config["OAuthUrl"].ToString();
|
||||
BaseUrl = config["BaseUrl"].ToString();
|
||||
WebAppUrl = config["WebAppUrl"].ToString();
|
||||
UploadUrl = config["UploadUrl"].ToString();
|
||||
@@ -791,8 +804,10 @@ namespace MConnectSDK
|
||||
answ.Source = SourceType.CLOUD;
|
||||
}
|
||||
answ.CallResultOk = (answ.CloudStatusOk || answ.LocalStatusOk);
|
||||
// x capire SE sia enrolled --> faccio chiamata di verifica...
|
||||
|
||||
// x capire SE sia enrolled --> faccio chiamata di verifica... (prima activation, ora licenza)
|
||||
answ.IsHmiEnrolled = checkEnroll();
|
||||
|
||||
// rispondo!
|
||||
return answ;
|
||||
}
|
||||
@@ -803,7 +818,7 @@ namespace MConnectSDK
|
||||
private void refreshAuthToken()
|
||||
{
|
||||
// parametri chiamata
|
||||
Uri callUri = new Uri(BaseUrl + "/oauth2/refresh");
|
||||
Uri callUri = new Uri(OAuthUrl + "/oauth2/refresh");
|
||||
var payload = "{\"refresh_token\": \"" + verifResp.refresh_token + "\"}";
|
||||
HttpContent callCont = new StringContent(payload, Encoding.UTF8, "application/json");
|
||||
|
||||
@@ -1069,6 +1084,8 @@ namespace MConnectSDK
|
||||
// controllo preliminare ping/cloud..
|
||||
if (pingOk && cloudOk)
|
||||
{
|
||||
// LEGACY to remove after v2 release
|
||||
#if false
|
||||
// controllo con la chiamata della clientInfo...
|
||||
var taskCliInfo = Task.Run(() => GetClientStatusAsync());
|
||||
taskCliInfo.Wait();
|
||||
@@ -1084,7 +1101,7 @@ namespace MConnectSDK
|
||||
var currStatus = reqStatus;
|
||||
if (resp.statusCode != 404)
|
||||
{
|
||||
if (resp.result != null && (resp.result.OrganizationCode.ToUpper() == organizationCode.ToUpper()))
|
||||
if (resp.result != null && (resp.result.OrganizationCode.Equals(organizationCode, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
// registro che è OK x AUTH
|
||||
currStatus.IsHmiEnrolled = true;
|
||||
@@ -1097,6 +1114,19 @@ namespace MConnectSDK
|
||||
Log.Instance.Error($"Errore in fase di checkEnroll: {Environment.NewLine}{taskRes.Result}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// verifica licenza da cui so che è enrolled
|
||||
var currStatus = reqStatus;
|
||||
var currLicense = GetLicenseMConnect();
|
||||
// se fosse 404 --> null quindi NO buono
|
||||
if (currLicense != null)
|
||||
{
|
||||
// verifico attiva licenza = enrolled
|
||||
currStatus.IsHmiEnrolled = currLicense.IsActive;
|
||||
answ = true;
|
||||
reqStatus = currStatus;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -1133,6 +1163,60 @@ namespace MConnectSDK
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Get list of all operation for current machine
|
||||
/// </summary>
|
||||
/// <param name="OperationsList"></param>
|
||||
/// <returns></returns>
|
||||
public static SDK_REPLY Download(out List<Maintenance.Operation> OperationsList)
|
||||
{
|
||||
SDK_REPLY currError = SDK_REPLY.NO_ERROR;
|
||||
OperationsList = new List<Maintenance.Operation>();
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get operation full details
|
||||
/// </summary>
|
||||
/// <param name="OperationId"></param>
|
||||
/// <param name="SingleOperation"></param>
|
||||
/// <returns></returns>
|
||||
public static SDK_REPLY GetSingle(string OperationId, out Maintenance.Operation SingleOperation)
|
||||
{
|
||||
SDK_REPLY currError = SDK_REPLY.NO_ERROR;
|
||||
SingleOperation = new Maintenance.Operation();
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update single operation
|
||||
/// </summary>
|
||||
/// <param name="OperationId"></param>
|
||||
/// <param name="progressPercent"></param>
|
||||
/// <param name="dueUntilDays"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public static SDK_REPLY Update(string OperationId, int progressPercent, int dueUntilDays, string userId)
|
||||
{
|
||||
SDK_REPLY currError = SDK_REPLY.NO_ERROR;
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload list of operations
|
||||
/// </summary>
|
||||
/// <param name="OperationsList"></param>
|
||||
/// <returns></returns>
|
||||
public static SDK_REPLY Upload(List<Maintenance.Operation> OperationsList)
|
||||
{
|
||||
SDK_REPLY currError = SDK_REPLY.NO_ERROR;
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vera chiamata enroll
|
||||
/// <summary>
|
||||
@@ -1140,18 +1224,41 @@ namespace MConnectSDK
|
||||
/// <returns>{ext}<returns>
|
||||
public string doEnroll()
|
||||
{
|
||||
string answ = "";
|
||||
// LEGACY to remove after v2 release
|
||||
#if false
|
||||
// effettuo call DI ENROLL
|
||||
Uri callUri = new Uri(pageUrlCheckEnroll);
|
||||
#endif
|
||||
string answ = "";
|
||||
// predispongo le URI di chiamata
|
||||
Uri callUriAssig = new Uri(pageUrlAssignment);
|
||||
Uri callUriActiv = new Uri(pageUrlActivation);
|
||||
var payload = "";
|
||||
HttpContent callCont = new StringContent(payload, Encoding.UTF8, "application/json");
|
||||
|
||||
// controllo preliminare ping/cloud..
|
||||
if (pingOk && cloudOk)
|
||||
{
|
||||
// LEGACY to remove after v2 release
|
||||
#if false
|
||||
// attivazione/assegnazione legacy
|
||||
var taskRes = Task.Run(() => Utils.putAsync(callUri, callCont, verifResp.access_token));
|
||||
taskRes.Wait();
|
||||
answ = taskRes.Result;
|
||||
#endif
|
||||
|
||||
// V2: nuova procedura in 2 step assegnazione / attivazione
|
||||
var taskResAssign = Task.Run(() => Utils.postUriAsync(callUriAssig, callCont, verifResp.access_token));
|
||||
taskResAssign.Wait();
|
||||
answ = taskResAssign.Result;
|
||||
// se ha creato
|
||||
if (answ == "201")
|
||||
{
|
||||
// step 2: ATTIVAZIONE
|
||||
var taskResActiv = Task.Run(() => Utils.postUriAsync(callUriActiv, callCont, verifResp.access_token));
|
||||
taskResActiv.Wait();
|
||||
answ = taskResActiv.Result;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -1227,6 +1334,20 @@ namespace MConnectSDK
|
||||
ML.redFlushKey(_currParam.module + "*", _currParam.defaultDb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of activities for specific operation<
|
||||
/// </summary>
|
||||
/// <param name="OperationId"></param>
|
||||
/// <param name="ActivitiesList"></param>
|
||||
/// <returns></returns>
|
||||
public SDK_REPLY GetActivities(string OperationId, out List<Maintenance.Activity> ActivitiesList)
|
||||
{
|
||||
SDK_REPLY currError = SDK_REPLY.NO_ERROR;
|
||||
ActivitiesList = new List<Maintenance.Activity>();
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera status del client
|
||||
/// <summary>
|
||||
@@ -1251,7 +1372,7 @@ namespace MConnectSDK
|
||||
if (pingOk && cloudOk)
|
||||
{
|
||||
// provo a chiamare clientInfo...
|
||||
string pageUrl = $"{BaseUrl}/oauth2/clientinfo?access_token={verifResp.access_token}";
|
||||
string pageUrl = $"{OAuthUrl}/oauth2/clientinfo?access_token={verifResp.access_token}";
|
||||
|
||||
var taskRes = Task.Run(() => Utils.getPageAsync(pageUrl));
|
||||
taskRes.Wait();
|
||||
@@ -1309,7 +1430,7 @@ namespace MConnectSDK
|
||||
if (pingOk && cloudOk)
|
||||
{
|
||||
// provo a chiamare clientInfo...
|
||||
string pageUrl = $"{BaseUrl}/oauth2/clientinfo?access_token={verifResp.access_token}";
|
||||
string pageUrl = $"{OAuthUrl}/oauth2/clientinfo?access_token={verifResp.access_token}";
|
||||
|
||||
var taskRes = Task.Run(() => Utils.getPageAsync(pageUrl));
|
||||
taskRes.Wait();
|
||||
@@ -1351,6 +1472,47 @@ namespace MConnectSDK
|
||||
return _currStatus;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ottiene i dati licenza da MaestroConnect
|
||||
/// <summary>
|
||||
/// <returns>Dati licenza<returns>
|
||||
public LicenseData GetLicenseMConnect()
|
||||
{
|
||||
LicenseData result = null;
|
||||
|
||||
// controllo preliminare ping/cloud..
|
||||
if (pingOk && cloudOk)
|
||||
{
|
||||
// controllo con la chiamata della clientInfo...
|
||||
var taskCliInfo = Task.Run(() => GetClientStatusAsync());
|
||||
taskCliInfo.Wait();
|
||||
|
||||
// parametri chiamata
|
||||
string shortBaseUrl = BaseUrl.Replace(".com/api", ".com/clients");
|
||||
|
||||
string pageUrl = $"{shortBaseUrl}/{organizationCode}/machines/{MachineID}/license";
|
||||
// effettuo call
|
||||
Console.WriteLine("-> " + verifResp.access_token);
|
||||
var taskRes = Task.Run(() => Utils.getPageAsync(pageUrl, verifResp.access_token));
|
||||
taskRes.Wait();
|
||||
try
|
||||
{
|
||||
var resp = JsonConvert.DeserializeObject<LicenseResponse>(taskRes.Result);
|
||||
result = resp.result;
|
||||
checkFixToken(taskRes.Result);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.WriteLine(taskRes.Result.ToString());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera elenco user di Maestro connect registrati come ELIMINATI (erano importati ma NON SONO PIU' su MConnect)
|
||||
/// <summary>
|
||||
@@ -1469,6 +1631,12 @@ namespace MConnectSDK
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rimozione suffisso da stringa
|
||||
/// </summary>
|
||||
/// <param name="fullString"></param>
|
||||
/// <param name="suffix"></param>
|
||||
/// <returns></returns>
|
||||
public string RemoveFromEnd(string fullString, string suffix)
|
||||
{
|
||||
string answ = fullString;
|
||||
@@ -1693,7 +1861,7 @@ namespace MConnectSDK
|
||||
// controllo SE sia stato autorizzato
|
||||
if (enrollResp != null && enrollResp.statusCode == 200)
|
||||
{
|
||||
if (enrollResp.result.OrganizationCode.ToUpper() == organizationCode.ToUpper())
|
||||
if (enrollResp.result.OrganizationCode.Equals(organizationCode, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
sb.AppendLine("--------------------------------------------------");
|
||||
sb.AppendLine(string.Format("{0:HH.mm.ss.fff} | ENROLL DONE", DateTime.Now));
|
||||
@@ -2012,7 +2180,11 @@ namespace MConnectSDK
|
||||
string msgErr = "Username not found";
|
||||
if (respErr != null)
|
||||
{
|
||||
msgErr = "Username not found | " + respErr.message + " | " + respErr.result.error;
|
||||
msgErr = $"Username not found | {respErr.message}";
|
||||
if (respErr.result != null)
|
||||
{
|
||||
msgErr += $" | {respErr.result.error}";
|
||||
}
|
||||
}
|
||||
errore = new LoginErrorResult
|
||||
{
|
||||
|
||||
+108
-53
@@ -6,24 +6,30 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MConnectSDK
|
||||
{
|
||||
public class Maintenance
|
||||
public static class Maintenance
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public static double ConvertInMinutes(double number, CMS_MAINTENANCE_UNIT_OF_MEASURE unit)
|
||||
/// <summary>
|
||||
/// COnverto from UoM to minutes
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <returns></returns>
|
||||
public static double ConvertInMinutes(double number, MAINTENANCE_UNIT_OF_MEASURE unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case CMS_MAINTENANCE_UNIT_OF_MEASURE.mm:
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.mm:
|
||||
return number;
|
||||
|
||||
case CMS_MAINTENANCE_UNIT_OF_MEASURE.H:
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.H:
|
||||
return number * 60;
|
||||
|
||||
case CMS_MAINTENANCE_UNIT_OF_MEASURE.D:
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.D:
|
||||
return number * (24 * 60);
|
||||
|
||||
case CMS_MAINTENANCE_UNIT_OF_MEASURE.M:
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.M:
|
||||
return (30 * number) * (24 * 60);
|
||||
|
||||
default:
|
||||
@@ -31,20 +37,26 @@ namespace MConnectSDK
|
||||
}
|
||||
}
|
||||
|
||||
public static double ConvertInUmeas(double number, CMS_MAINTENANCE_UNIT_OF_MEASURE unit)
|
||||
/// <summary>
|
||||
/// Convert from minutes to desider UoM
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <returns></returns>
|
||||
public static double ConvertInUmeas(double number, MAINTENANCE_UNIT_OF_MEASURE unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case CMS_MAINTENANCE_UNIT_OF_MEASURE.mm:
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.mm:
|
||||
return number;
|
||||
|
||||
case CMS_MAINTENANCE_UNIT_OF_MEASURE.H:
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.H:
|
||||
return number / 60;
|
||||
|
||||
case CMS_MAINTENANCE_UNIT_OF_MEASURE.D:
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.D:
|
||||
return number / (24 / 60);
|
||||
|
||||
case CMS_MAINTENANCE_UNIT_OF_MEASURE.M:
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.M:
|
||||
return (30 / number) / (24 / 60);
|
||||
|
||||
default:
|
||||
@@ -52,44 +64,6 @@ namespace MConnectSDK
|
||||
}
|
||||
}
|
||||
|
||||
public SdkErrors DownloadOperations(out List<Operation> OperationsList)
|
||||
{
|
||||
SdkErrors currError = SdkErrors.NO_ERROR;
|
||||
OperationsList = new List<Operation>();
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
public SdkErrors GetActivity(out List<Activity> ActivitiesList)
|
||||
{
|
||||
SdkErrors currError = SdkErrors.NO_ERROR;
|
||||
ActivitiesList = new List<Activity>();
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
public SdkErrors GetOperation(string OperationId, out Operation SingleOperation)
|
||||
{
|
||||
SdkErrors currError = SdkErrors.NO_ERROR;
|
||||
SingleOperation = new Operation();
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
public SdkErrors UpdateOperationStatus(string OperationId, int progressPercent, int dueUntilDays, string userId)
|
||||
{
|
||||
SdkErrors currError = SdkErrors.NO_ERROR;
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
public SdkErrors UploadOperations(List<Operation> OperationsList)
|
||||
{
|
||||
SdkErrors currError = SdkErrors.NO_ERROR;
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Public Classes
|
||||
@@ -101,11 +75,44 @@ namespace MConnectSDK
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Unique key (generated byMConnect)
|
||||
/// </summary>
|
||||
public string ActivityId { get; set; } = "";
|
||||
public string ParentOperationId { get; set; } = "";
|
||||
public ActStatus Status { get; set; } = ActStatus.Defined;
|
||||
|
||||
/// <summary>
|
||||
/// Parent Operation key
|
||||
/// </summary>
|
||||
public string OperationId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Status of activity
|
||||
/// </summary>
|
||||
public ACTIVITY_STATUS Status { get; set; } = ACTIVITY_STATUS.DEFINED;
|
||||
|
||||
/// <summary>
|
||||
/// User that made activity
|
||||
/// </summary>
|
||||
public string User { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// List of current (pending) activity for the amchine
|
||||
/// </summary>
|
||||
/// <param name="ActivitiesList"></param>
|
||||
/// <returns></returns>
|
||||
public SDK_REPLY GetCurrent(out List<Activity> ActivitiesList)
|
||||
{
|
||||
SDK_REPLY currError = SDK_REPLY.NO_ERROR;
|
||||
ActivitiesList = new List<Activity>();
|
||||
|
||||
return currError;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -115,14 +122,62 @@ namespace MConnectSDK
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Description of operation (optional)
|
||||
/// </summary>
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
public string GroupId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Key for localization inside machine (optional)
|
||||
/// </summary>
|
||||
public string LocationKey { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// MachineId (MConnect after enroll)
|
||||
/// </summary>
|
||||
public string MachineId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Unique Code for indicating Maintenance (mandatory, created by HMI)
|
||||
/// </summary>
|
||||
public string MaintenanceCode { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Model (optional)
|
||||
/// </summary>
|
||||
public string Model { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Name of operation (optional)
|
||||
/// </summary>
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Unique Code (create by HMI)
|
||||
/// </summary>
|
||||
public string OperationCode { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Unique key (generated byMConnect)
|
||||
/// </summary>
|
||||
public string OperationId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Priority
|
||||
/// </summary>
|
||||
public double priority { get; set; } = 0;
|
||||
public OpStatus Status { get; set; } = OpStatus.ToDo;
|
||||
public OpType Type { get; set; } = OpType.Ordinary;
|
||||
|
||||
/// <summary>
|
||||
/// Operation status
|
||||
/// </summary>
|
||||
public OP_STATUS Status { get; set; } = OP_STATUS.TO_DO;
|
||||
|
||||
/// <summary>
|
||||
/// Operation type
|
||||
/// </summary>
|
||||
public OP_TYPE Type { get; set; } = OP_TYPE.ORDINARY;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
+35
-1
@@ -1108,11 +1108,45 @@ namespace MConnectSDK
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Instance.Error($"EXC in getImageAsync: {Environment.NewLine}{exc}");
|
||||
Log.Instance.Error($"EXC in postUriAsync: {Environment.NewLine}{exc}");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST asyncrona + token
|
||||
/// </summary>
|
||||
/// <param name="reqUri">URI della chiamata</param>
|
||||
/// <param name="callCont">contenuto della chiamata</param>
|
||||
/// <param name="oauthToken">token da passare come bearer</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> postUriAsync(Uri reqUri, HttpContent callCont, string oauthToken)
|
||||
{
|
||||
Log.Instance.Info($"[postUriAsync]: Calling reqUri: {reqUri} | callCont Token: {oauthToken} | callCont: {callCont}");
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
// ... Use HttpClient.
|
||||
using (HttpClient client = new HttpClient() { Timeout = TimeSpan.FromMinutes(2) })
|
||||
{
|
||||
if (oauthToken != "")
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + oauthToken);
|
||||
}
|
||||
using (HttpResponseMessage response = await client.PostAsync(reqUri, callCont).ConfigureAwait(false))
|
||||
{
|
||||
// converto s stringa
|
||||
answ = $"{(int)response.StatusCode}";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Instance.Error($"EXC in postUriAsync + token: {Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua PUT async della REST API indicata
|
||||
/// </summary>
|
||||
|
||||
Generated
+538
-484
File diff suppressed because it is too large
Load Diff
+986
-868
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,16 @@
|
||||
#File di conf per MConnectClientSDK
|
||||
conf:
|
||||
Client_ID: "test"
|
||||
MachineID: "cjpjwuas400cb0slxs5zfj4yh"
|
||||
PingTarget: "stg.api.maestroconnect.scmgroup.com"
|
||||
AliveTarget: "https://stg.api.maestroconnect.scmgroup.com/health"
|
||||
BaseUrl: "https://stg.api.maestroconnect.scmgroup.com/api"
|
||||
UploadUrl: "https://stg.api.maestroconnect.scmgroup.com/storage-api/backups"
|
||||
WebAppUrl: "https://stg.maestroconnect.scmgroup.com/settings/machine-activation?user_code={0}&machine_id={1}"
|
||||
Client_ID: "test"
|
||||
MachineID: "ckk2ornjz224s0g4amp935fm2"
|
||||
PingTarget: "tst.api.maestroconnect.scmgroup.com"
|
||||
AliveTarget: "https://tst.api.maestroconnect.scmgroup.com/health"
|
||||
ApiVersion: "v2"
|
||||
OAuthUrl: "https://tst.api.maestroconnect.scmgroup.com/api"
|
||||
BaseUrl: "https://tst.api.maestroconnect.scmgroup.com/clients"
|
||||
UploadUrl: "https://tst.api.maestroconnect.scmgroup.com/storage-api/backups"
|
||||
WebAppUrl: "https://tst.maestroconnect.scmgroup.com/settings/machine-activation?user_code={0}&machine_id={1}"
|
||||
MemoryLayer:
|
||||
Redis:
|
||||
ConnectionString: "127.0.0.1,abortConnect=false,ssl=false"
|
||||
DbIndex: 1
|
||||
Module: "MCC"
|
||||
Module: "MCC"
|
||||
@@ -0,0 +1,14 @@
|
||||
#File di conf per MConnectClientSDK
|
||||
conf:
|
||||
Client_ID: "test"
|
||||
MachineID: "cjpjwuas400cb0slxs5zfj4yh"
|
||||
PingTarget: "stg.api.maestroconnect.scmgroup.com"
|
||||
AliveTarget: "https://stg.api.maestroconnect.scmgroup.com/health"
|
||||
BaseUrl: "https://stg.api.maestroconnect.scmgroup.com/api"
|
||||
UploadUrl: "https://stg.api.maestroconnect.scmgroup.com/storage-api/backups"
|
||||
WebAppUrl: "https://stg.maestroconnect.scmgroup.com/settings/machine-activation?user_code={0}&machine_id={1}"
|
||||
MemoryLayer:
|
||||
Redis:
|
||||
ConnectionString: "127.0.0.1,abortConnect=false,ssl=false"
|
||||
DbIndex: 1
|
||||
Module: "MCC"
|
||||
Reference in New Issue
Block a user