OK servizio auto approvazione da PROG
This commit is contained in:
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// Init generico
|
||||
/// </summary>
|
||||
/// <param name="FileArchDService"></param>
|
||||
public FileChangeController(FileArchDataService FileArchDService)
|
||||
{
|
||||
FADService = FileArchDService;
|
||||
Log.Info("Avviata classe FileChangeController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica Health servizi FileChange
|
||||
/// GET api/FileChange
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public ActionResult<string> Get()
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue controllo + approvazione modifiche x directory
|
||||
/// GET api/FileChange/anagkeyval/[id]?[CodApp]
|
||||
/// </summary>
|
||||
/// <param name="id">Directory / IdxMacchina | 0/ALL = tutte</param>
|
||||
/// <param name="numDayPrev">Verifica file modificati da numDayPrev gg</param>
|
||||
/// <returns>Elenco dei file approvati</returns>
|
||||
[HttpGet("approve/{id}")]
|
||||
public async Task<List<string>> approve(string id, int numDayPrev)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
// verifico se una o tutte le macchine
|
||||
List<string> listDir = new List<string>();
|
||||
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<string> listAppr = await ForceApproveMod(currDir, numDayPrev);
|
||||
result.AddRange(listAppr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua approvazione file modificati, restituendo elenco
|
||||
/// </summary>
|
||||
/// <param name="currDir"></param>
|
||||
/// <param name="numDayPrev"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<string>> ForceApproveMod(string currDir, int numDayPrev)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
// 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
|
||||
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
protected FileArchDataService FADService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Classe per logging
|
||||
/// </summary>
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// Init generico
|
||||
/// </summary>
|
||||
/// <param name="FileArchDService"></param>
|
||||
public HealthController(FileArchDataService FileArchDService)
|
||||
{
|
||||
FADService = FileArchDService;
|
||||
Log.Info("Avviata classe HealthController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica Health servizi app
|
||||
/// GET api/health
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public ActionResult<string> Get()
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
protected FileArchDataService FADService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Classe per logging
|
||||
/// </summary>
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>MP.Prog</RootNamespace>
|
||||
<Version>6.16.2410.2219</Version>
|
||||
<Version>6.16.2410.2311</Version>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -27,6 +28,9 @@
|
||||
<PackageReference Include="NLog" Version="5.3.3" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.12" />
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.8.12" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.9.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.9.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.9.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -6,9 +6,15 @@
|
||||
<div class="px-0">
|
||||
<h4>Elenco Programmi</h4>
|
||||
<div class="form-group mb-0">
|
||||
<button id="btnForceCheck" class="btn btn-warning btn-sm" @onclick="() => ForceCheck(30)" title="Analisi Modifiche ultimi 30gg">
|
||||
<button class="btn btn-warning btn-sm" @onclick="() => ForceCheck(30)" title="Analisi Modifiche ultimi 30gg">
|
||||
<i class="fas fa-sync-alt"></i> Update (30gg) <i class="far fa-folder-open"></i>
|
||||
</button>
|
||||
@if (OnlyMod && totalCount >= 0)
|
||||
{
|
||||
<button class="btn btn-success btn-sm ms-1" @onclick="MassAppr" title="Approva tutte le modifiche visualizzate">
|
||||
<i class="fas fa-sync-alt"></i> Approva Mod. vis. <i class="fa-solid fa-clipboard-check"></i>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-0 text-end">
|
||||
|
||||
@@ -230,6 +230,19 @@ namespace MP.Prog.Pages
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua approvazione di ttute le modifiche visualizzate
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task MassAppr()
|
||||
{
|
||||
ResetData();
|
||||
await ResetFilter();
|
||||
await Task.Delay(1);
|
||||
await ReloadData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
{
|
||||
FDService.rollBackEdit(currRecord);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo gestione Programmi MAPO</i>
|
||||
<h4>Versione: 6.16.2410.2219</h4>
|
||||
<h4>Versione: 6.16.2410.2311</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2410.2219
|
||||
6.16.2410.2311
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2410.2219</version>
|
||||
<version>6.16.2410.2311</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
+30
-2
@@ -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<string>("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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user