diff --git a/Core/DTO/ReleaseReqDTO.cs b/Core/DTO/ReleaseReqDTO.cs new file mode 100644 index 0000000..9e8a64d --- /dev/null +++ b/Core/DTO/ReleaseReqDTO.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DTO +{ + + // + // This is here so CodeMaid doesn't reorganize this document + // + public class ReleaseReqDTO + { + /// + /// CodApp Richiesta + /// + public string CodApp { get; set; } = ""; + + /// + /// Master Key + /// + public string MastKey { get; set; } = ""; + + /// + /// Codice Impiego istanza SubLic + /// + public string CodImp { get; set; } = ""; + + /// + /// Chiave SubLic + /// + public string AppKey { get; set; } = ""; + + /// + /// Versione minima richiesta + /// + public string VersMin { get; set; } = ""; + + /// + /// Versione MAX richiesta + /// + public string VersMax { get; set; } = ""; + + /// + /// Verifica complessiva validità richiesta: + /// CodApp presente + /// - MainKey oppure CodImp + AppKey presenti + /// + [NotMapped] + public bool IsValid + { + get => !string.IsNullOrEmpty(CodApp) && (!string.IsNullOrEmpty(MastKey) || (!string.IsNullOrEmpty(CodImp) && !string.IsNullOrEmpty(AppKey))); + } + } +} diff --git a/Core/DTO/TicketDTO.cs b/Core/DTO/TicketDTO.cs index 64d2291..d23252d 100644 --- a/Core/DTO/TicketDTO.cs +++ b/Core/DTO/TicketDTO.cs @@ -3,6 +3,9 @@ using static Core.Enum; namespace Core.DTO { + // + // This is here so CodeMaid doesn't reorganize this document + // public class TicketDTO { #region Public Properties diff --git a/EgwControlCenter.App/BlazorForm.cs b/EgwControlCenter.App/BlazorForm.cs index f62df93..977d194 100644 --- a/EgwControlCenter.App/BlazorForm.cs +++ b/EgwControlCenter.App/BlazorForm.cs @@ -36,7 +36,7 @@ namespace EgwControlCenter.App private bool forceClose = false; - private Size minSize = new Size(636, 409); + private Size minSize = new Size(676, 409); private bool showReduced = false; /// diff --git a/EgwControlCenter.App/Components/Compo/ApplicationCheck.razor b/EgwControlCenter.App/Components/Compo/ApplicationCheck.razor index 12b0a39..9eb5c5f 100644 --- a/EgwControlCenter.App/Components/Compo/ApplicationCheck.razor +++ b/EgwControlCenter.App/Components/Compo/ApplicationCheck.razor @@ -5,18 +5,18 @@
App Control Center
-
-
- +
+
+ - +
- +
diff --git a/EgwControlCenter.App/Components/Compo/TargetSetup.razor b/EgwControlCenter.App/Components/Compo/TargetSetup.razor index 9e1aa5a..a59861e 100644 --- a/EgwControlCenter.App/Components/Compo/TargetSetup.razor +++ b/EgwControlCenter.App/Components/Compo/TargetSetup.razor @@ -10,16 +10,16 @@ @if (PwdOk) {
- - - - + + + +
} else {
- +
}
diff --git a/EgwControlCenter.App/EgwControlCenter.App.csproj b/EgwControlCenter.App/EgwControlCenter.App.csproj index a32ec4a..72d35f5 100644 --- a/EgwControlCenter.App/EgwControlCenter.App.csproj +++ b/EgwControlCenter.App/EgwControlCenter.App.csproj @@ -5,7 +5,7 @@ enable true enable - 1.1.2409.2611 + 1.1.2409.2615 Debug;Release;DEBUG_Local diff --git a/EgwControlCenter.App/Properties/PublishProfiles/ClickOnceProfile.pubxml b/EgwControlCenter.App/Properties/PublishProfiles/ClickOnceProfile.pubxml index e546788..53b134b 100644 --- a/EgwControlCenter.App/Properties/PublishProfiles/ClickOnceProfile.pubxml +++ b/EgwControlCenter.App/Properties/PublishProfiles/ClickOnceProfile.pubxml @@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - 2611 - 1.1.2409.2611 + 2615 + 1.1.2409.2615 True Release True diff --git a/EgwControlCenter.Core/DTO/ReleaseReqDTO.cs b/EgwControlCenter.Core/DTO/ReleaseReqDTO.cs new file mode 100644 index 0000000..50399c7 --- /dev/null +++ b/EgwControlCenter.Core/DTO/ReleaseReqDTO.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EgwControlCenter.Core.DTO +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + public class ReleaseReqDTO + { + /// + /// CodApp Richiesta + /// + public string CodApp { get; set; } = ""; + + /// + /// Master Key + /// + public string MastKey { get; set; } = ""; + + /// + /// Codice Impiego istanza SubLic + /// + public string CodImp { get; set; } = ""; + + /// + /// Chiave SubLic + /// + public string AppKey { get; set; } = ""; + + /// + /// Versione minima richiesta + /// + public string VersMin { get; set; } = ""; + + /// + /// Versione MAX richiesta + /// + public string VersMax { get; set; } = ""; + + /// + /// Verifica complessiva validità richiesta: + /// CodApp presente + /// - MainKey oppure CodImp + AppKey presenti + /// + [NotMapped] + public bool IsValid + { + get => !string.IsNullOrEmpty(CodApp) && (!string.IsNullOrEmpty(MastKey) || (!string.IsNullOrEmpty(CodImp) && !string.IsNullOrEmpty(AppKey))); + } + + } +} diff --git a/EgwControlCenter.Core/ReleaseChecker.cs b/EgwControlCenter.Core/ReleaseChecker.cs index 5a8bda3..75f332e 100644 --- a/EgwControlCenter.Core/ReleaseChecker.cs +++ b/EgwControlCenter.Core/ReleaseChecker.cs @@ -465,30 +465,65 @@ namespace EgwControlCenter.Core return answ; } + /// + /// Indica se usare la chaive appKey x i metodi di recupero informazioni 8elenco versioni...) + /// + private bool useAppKey = true; - private static List GetRemoteRel(string CodApp, string CurrVers) + private List GetRemoteRel(string CodApp, string CurrVers) { List answ = new List(); try { // client chiamate rest var client = new RestClient(Const.apiUrl); - // Chiamo il metodo! - var checkRel = new RestRequest($"/api/Release/filt/{CodApp}?VersMin={CurrVers}", Method.Get); - // effettuo vera chiamata - var pUpd = Task.Run(async () => + // provo cmq ad inizializzare la richiesta + ReleaseReqDTO reqDto = new ReleaseReqDTO() { - var currResp = await client.GetAsync(checkRel); - if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null) + CodApp = CodApp, + CodImp = CurrPatrolCont.CodImpiego, + AppKey = CurrPatrolCont.AppKey, + VersMin = CurrVers + }; + // Chiamo il metodo! + if (useAppKey && reqDto.IsValid) + { + var actReq = new RestRequest($"/api/release/getfilt", Method.Post); + string payload = JsonConvert.SerializeObject(reqDto); + actReq.AddJsonBody(payload); + // effettuo vera chiamata + var pUpd = Task.Run(async () => { - var currList = JsonConvert.DeserializeObject>(currResp.Content); - if (currList != null) + var currResp = await client.PostAsync(actReq); + if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null) { - answ = currList; + var currList = JsonConvert.DeserializeObject>(currResp.Content); + if (currList != null) + { + answ = currList; + } } - } - }); - pUpd.Wait(); + }); + pUpd.Wait(); + } + else + { + var checkRel = new RestRequest($"/api/release/filt/{CodApp}?VersMin={CurrVers}", Method.Get); + // effettuo vera chiamata + var pUpd = Task.Run(async () => + { + var currResp = await client.GetAsync(checkRel); + if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null) + { + var currList = JsonConvert.DeserializeObject>(currResp.Content); + if (currList != null) + { + answ = currList; + } + } + }); + pUpd.Wait(); + } } catch (Exception exc) { diff --git a/LiMan.Api/Controllers/ReleaseController.cs b/LiMan.Api/Controllers/ReleaseController.cs index fea97e2..2cd27c4 100644 --- a/LiMan.Api/Controllers/ReleaseController.cs +++ b/LiMan.Api/Controllers/ReleaseController.cs @@ -10,6 +10,8 @@ using System.Threading.Tasks; using System.Linq; using LiMan.DB.DBModels; using Microsoft.Extensions.Configuration; +using Org.BouncyCastle.Asn1.Crmf; +using System; namespace LiMan.APi.Controllers { @@ -37,8 +39,7 @@ namespace LiMan.APi.Controllers #region Public Methods /// - /// Recupera elenco dati licenza Applicativi (completo) - /// GET api/Release/EgtBW + /// Recupera elenco dati Release (rilasciate) GET api/release/EgtBW /// /// Codice Applicazione /// @@ -46,13 +47,12 @@ namespace LiMan.APi.Controllers public async Task> Get(string id) { var result = await dataService.ReleaseGetByApp(id); - await dataService.recordCall(id, id, $"GET:api/Release/{id}"); + await dataService.recordCall(id, id, $"GET:api/release/{id}"); return result; } /// - /// Recupera elenco dati licenza Applicativi data versione minima - /// GET api/Release/EgtBW + /// Recupera elenco dati Release (rilasciate) data versione minima GET api/release/EgtBW /// /// Codice Applicazione /// Versione minima richiesta (attuale) @@ -61,13 +61,13 @@ namespace LiMan.APi.Controllers public async Task> GetFilt(string id, string VersMin) { var result = await dataService.ReleaseGetByAppVers(id, VersMin); - await dataService.recordCall(id, id, $"GET:api/Release/filt/{id}"); + await dataService.recordCall(id, id, $"GET:api/release/filt/{id}"); return result; } /// - /// Recupera elenco dati licenza Applicativi data versione minima + vers limite - /// GET api/Release/EgtBW + /// Recupera elenco dati Release (rilasciate) data versione minima e massima + /// GET api/release/EgtBW /// /// Codice Applicazione /// Versione minima richiesta (attuale) @@ -77,13 +77,66 @@ namespace LiMan.APi.Controllers public async Task> GetFiltLimit(string id, string VersMin, string VersMax) { var result = await dataService.ReleaseGetByAppVersLimit(id, VersMin, VersMax); - await dataService.recordCall(id, id, $"GET:api/Release/filtLimit/{id}"); + await dataService.recordCall(id, id, $"GET:api/release/filtLimit/{id}"); return result; } /// - /// Richiesta di registrazione di una nuova Release applicativa - /// POST api/release/save + /// Recupera elenco dati Release (rilasciate) + /// POST api/release/getall + /// + /// Obj ReleaseReqDTO con chiavi (master o app) + [HttpPost("getall")] + public async Task> GetReleases([FromBody] ReleaseReqDTO CurrRequest) + { + List result = new List(); + // verifica validità richiesta... + if (CheckReqKeys(CurrRequest)) + { + result = await dataService.ReleaseGetByApp(CurrRequest.CodApp); + await dataService.recordCall(CurrRequest.CodApp, CurrRequest.CodApp, $"POST:api/release/getall/ | {CurrRequest.MastKey} | {CurrRequest.CodImp} | {CurrRequest.CodApp}"); + } + return result; + } + + /// + /// Recupera elenco dati Release (rilasciate) data versione minima + /// POST api/release/getfilt + /// + /// Obj ReleaseReqDTO con chiavi (master o app) + [HttpPost("getfilt")] + public async Task> GetReleasesFilt([FromBody] ReleaseReqDTO CurrRequest) + { + List result = new List(); + // verifica validità richiesta... + if (CheckReqKeys(CurrRequest)) + { + result = await dataService.ReleaseGetByAppVers(CurrRequest.CodApp, CurrRequest.VersMin); + await dataService.recordCall(CurrRequest.CodApp, CurrRequest.CodApp, $"POST:api/release/getfilt/ | {CurrRequest.MastKey} | {CurrRequest.CodImp} | {CurrRequest.CodApp}"); + } + return result; + } + + /// + /// Recupera elenco dati Release (rilasciate) data versione minima e massima + /// POST api/release/getlimit + /// + /// Obj ReleaseReqDTO con chiavi (master o app) + [HttpPost("getlimit")] + public async Task> GetReleasesLimit([FromBody] ReleaseReqDTO CurrRequest) + { + List result = new List(); + // verifica validità richiesta... + if (CheckReqKeys(CurrRequest)) + { + result = await dataService.ReleaseGetByAppVersLimit(CurrRequest.CodApp, CurrRequest.VersMin, CurrRequest.VersMax); + await dataService.recordCall(CurrRequest.CodApp, CurrRequest.CodApp, $"POST:api/release/getlimit/ | {CurrRequest.MastKey} | {CurrRequest.CodImp} | {CurrRequest.CodApp}"); + } + return result; + } + + /// + /// Salva una nuova release dell'applicativo (eventualmente sovrascrivendo) POST api/release/save /// /// Obj Richiesta [HttpPost("save")] @@ -104,7 +157,6 @@ namespace LiMan.APi.Controllers var licUploader = await dataService.LicenzeSearch(CurrRequest.CodInst, CurrRequest.UplAppID, CurrRequest.MasterKey, false); if (licUploader != null && licUploader.Count > 0) { - // in primis cerco app... var appList = await dataService.ApplicativiGetAll(); ApplicativoModel recApp = new ApplicativoModel(); @@ -176,5 +228,26 @@ namespace LiMan.APi.Controllers private static Logger Log = LogManager.GetCurrentClassLogger(); #endregion Private Fields + + #region Private Methods + + /// + /// Verifica validità richiesta + /// - dati presenti in chiamata + /// - combinazioni CodApp + chiavi valide/attive + /// + /// + /// + private bool CheckReqKeys(ReleaseReqDTO currReq) + { + bool answ = currReq.IsValid; + if (answ) + { + // verifica validità chiavi... TBD!!! + } + return answ; + } + + #endregion Private Methods } } \ No newline at end of file