diff --git a/MP.Prog/Controllers/FileChangeController.cs b/MP.Prog/Controllers/FileChangeController.cs new file mode 100644 index 00000000..9ece29c0 --- /dev/null +++ b/MP.Prog/Controllers/FileChangeController.cs @@ -0,0 +1,130 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using MP.FileData.Controllers; +using MP.Prog.Data; +using NLog; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MP.Prog.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class FileChangeController : ControllerBase + { + #region Public Constructors + + /// + /// Init generico + /// + /// + public FileChangeController(FileArchDataService FileArchDService) + { + FADService = FileArchDService; + Log.Info("Avviata classe FileChangeController"); + } + + #endregion Public Constructors + + #region Public Methods + + /// + /// Verifica Health servizi FileChange + /// GET api/FileChange + /// + /// + [HttpGet] + public ActionResult Get() + { + return "OK"; + } + + /// + /// Esegue controllo + approvazione modifiche x directory + /// GET api/FileChange/anagkeyval/[id]?[CodApp] + /// + /// Directory / IdxMacchina | 0/ALL = tutte + /// Verifica file modificati da numDayPrev gg + /// Elenco dei file approvati + [HttpGet("approve/{id}")] + public async Task> approve(string id, int numDayPrev) + { + List result = new List(); + // verifico se una o tutte le macchine + List listDir = new List(); + if (id == "ALL" || id == "0") + { + var machList = await FADService.ArchMaccGetAll(); + listDir = machList + .Where(x => !string.IsNullOrEmpty(x.BasePath)) + .Select(x => x.IdxMacchina).ToList(); + } + else + { + listDir.Add(id); + } + // ciclo su tutte le macchine e faccio approvazione... + foreach (var currDir in listDir) + { + // eseguo singolo controllo, utente = "" (è auto-approvazione) + await FADService.UpdateMachineArchive(currDir, numDayPrev, false, false, ""); + List listAppr = await ForceApproveMod(currDir, numDayPrev); + result.AddRange(listAppr); + } + return result; + } + + /// + /// Effettua approvazione file modificati, restituendo elenco + /// + /// + /// + /// + private async Task> ForceApproveMod(string currDir, int numDayPrev) + { + List answ = new List(); + // preparo filtro + SelectData currFilt = new SelectData() + { + IdxMacchina = currDir, + OnlyActive = true, + OnlyMod = true + }; + // recupero elenco files modificati x cartella + var listChanged = await FADService.FileGetFilt(currFilt); + // ciclo ogni file modificato + foreach (var cFile in listChanged) + { + // approvo il file modificato con utente anonimo (auto-approve) + bool fatto = await FADService.FileApprove(cFile, ""); + if (fatto) + { + answ.Add(cFile.Path); + } + } + return answ; + } + + #endregion Public Methods + + #region Protected Properties + + /// + /// Dataservice x accesso DB + /// + protected FileArchDataService FADService { get; set; } + + #endregion Protected Properties + + #region Private Fields + + /// + /// Classe per logging + /// + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/MP.Prog/Controllers/HealthController.cs b/MP.Prog/Controllers/HealthController.cs new file mode 100644 index 00000000..eb7e4144 --- /dev/null +++ b/MP.Prog/Controllers/HealthController.cs @@ -0,0 +1,61 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using MP.FileData.Controllers; +using MP.Prog.Data; +using NLog; +using System.Threading.Tasks; + +namespace MP.Prog.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class HealthController : ControllerBase + { + #region Public Constructors + + /// + /// Init generico + /// + /// + public HealthController(FileArchDataService FileArchDService) + { + FADService = FileArchDService; + Log.Info("Avviata classe HealthController"); + } + + #endregion Public Constructors + + #region Public Methods + + /// + /// Verifica Health servizi app + /// GET api/health + /// + /// + [HttpGet] + public ActionResult Get() + { + return "OK"; + } + + #endregion Public Methods + + #region Protected Properties + + /// + /// Dataservice x accesso DB + /// + protected FileArchDataService FADService { get; set; } + + #endregion Protected Properties + + #region Private Fields + + /// + /// Classe per logging + /// + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/MP.Prog/MP.Prog.csproj b/MP.Prog/MP.Prog.csproj index 89755597..18a4c859 100644 --- a/MP.Prog/MP.Prog.csproj +++ b/MP.Prog/MP.Prog.csproj @@ -3,7 +3,8 @@ net6.0 MP.Prog - 6.16.2410.2219 + 6.16.2410.2311 + True @@ -27,6 +28,9 @@ + + + diff --git a/MP.Prog/Pages/Archive.razor b/MP.Prog/Pages/Archive.razor index 967f76db..873233f3 100644 --- a/MP.Prog/Pages/Archive.razor +++ b/MP.Prog/Pages/Archive.razor @@ -6,9 +6,15 @@

Elenco Programmi

- + @if (OnlyMod && totalCount >= 0) + { + + }
diff --git a/MP.Prog/Pages/Archive.razor.cs b/MP.Prog/Pages/Archive.razor.cs index 20e47c48..af50582a 100644 --- a/MP.Prog/Pages/Archive.razor.cs +++ b/MP.Prog/Pages/Archive.razor.cs @@ -230,6 +230,19 @@ namespace MP.Prog.Pages await Task.Delay(1); } + /// + /// effettua approvazione di ttute le modifiche visualizzate + /// + /// + protected async Task MassAppr() + { + ResetData(); + await ResetFilter(); + await Task.Delay(1); + await ReloadData(); + isLoading = false; + } + protected void ResetData() { FDService.rollBackEdit(currRecord); diff --git a/MP.Prog/Resources/ChangeLog.html b/MP.Prog/Resources/ChangeLog.html index a3ed871e..c017c782 100644 --- a/MP.Prog/Resources/ChangeLog.html +++ b/MP.Prog/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

Versione: 6.16.2410.2219

+

Versione: 6.16.2410.2311


Note di rilascio:
    diff --git a/MP.Prog/Resources/VersNum.txt b/MP.Prog/Resources/VersNum.txt index 3cfca690..d39e7196 100644 --- a/MP.Prog/Resources/VersNum.txt +++ b/MP.Prog/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2410.2219 +6.16.2410.2311 diff --git a/MP.Prog/Resources/manifest.xml b/MP.Prog/Resources/manifest.xml index af79ea5d..d2730839 100644 --- a/MP.Prog/Resources/manifest.xml +++ b/MP.Prog/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2410.2219 + 6.16.2410.2311 https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html false diff --git a/MP.Prog/Startup.cs b/MP.Prog/Startup.cs index fc459f4f..3f68ea0d 100644 --- a/MP.Prog/Startup.cs +++ b/MP.Prog/Startup.cs @@ -8,13 +8,17 @@ using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; using MP.Prog.Data; using NLog; using StackExchange.Redis; using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; +using System.Reflection; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace MP.Prog @@ -41,10 +45,24 @@ namespace MP.Prog // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - // aggiunt base URL x routing corretto app.UsePathBase(Configuration.GetValue("ServerConf:BaseUrl")); + if (env.IsDevelopment() || env.IsStaging()) + { + app.UseDeveloperExceptionPage(); + + // valido solo in sviluppo + app.UseSwagger(c => + { + c.RouteTemplate = "/swagger/{documentName}/swagger.json"; + }); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("v1/swagger.json", "MP-PROG.Api"); + }); + } + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); @@ -91,7 +109,7 @@ namespace MP.Prog app.UseEndpoints(endpoints => { - //endpoints.MapControllers(); + endpoints.MapControllers(); endpoints.MapBlazorHub(); //endpoints.MapHealthChecksUI(); //endpoints.MapHealthChecks("/health", new HealthCheckOptions @@ -107,6 +125,14 @@ namespace MP.Prog // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { + services.AddControllers(); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "MP-PROG.Api", Version = "v1" }); + // Set the comments path for the Swagger JSON and UI. + var xmlPath = Path.Combine(AppContext.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"); + c.IncludeXmlComments(xmlPath); + }); // Aggiunta auth windows services.AddAuthentication(NegotiateDefaults.AuthenticationScheme) .AddNegotiate(); @@ -147,6 +173,8 @@ namespace MP.Prog // avvio oggetto shared x redis... var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis); + services.AddControllers() + .AddJsonOptions(c => c.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve); services.AddLocalization();