diff --git a/MP.Stats/Controllers/TaskController.cs b/MP.Stats/Controllers/TaskController.cs
new file mode 100644
index 00000000..f5346a13
--- /dev/null
+++ b/MP.Stats/Controllers/TaskController.cs
@@ -0,0 +1,68 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using MP.Data.DatabaseModels;
+using MP.Stats.Data;
+using NLog;
+using NLog.Fluent;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MP.Stats.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class TaskController : ControllerBase
+ {
+ public TaskController(IConfiguration configuration, MpStatsService DataService)
+ {
+ Log.Trace("Starting TaskController");
+ _configuration = configuration;
+ DService = DataService;
+ Log.Trace("Avviato TaskController");
+ }
+
+ ///
+ /// List of available task and last execution data
+ ///
+ ///
+ [HttpGet("GetList")]
+ public async Task> GetList()
+ {
+ List answ = await DService.TaskListAll(MP.Data.Objects.Enums.Task2ExeType.ND, "");
+ return answ;
+ }
+
+ ///
+ /// Call for execution of due task and report state
+ ///
+ ///
+ [HttpGet]
+ public async Task> ExecuteAndReturnGet()
+ {
+ List answ = new List();
+ List listTask = await DService.TaskListAll(MP.Data.Objects.Enums.Task2ExeType.ND, "");
+ // verifico SE ci siano task in scadenza...
+ DateTime adesso = DateTime.Now;
+ var task2exe = listTask.Where(x => x.DtNextExec <= adesso).ToList();
+ foreach (var taskRec in task2exe)
+ {
+ TaskResultModel result = await DService.ExecuteTask(taskRec.TaskId);
+ answ.Add(result);
+ }
+ // resituisco
+ return answ;
+ }
+
+
+ private static IConfiguration _configuration = null!;
+
+ private static Logger Log = LogManager.GetCurrentClassLogger();
+ ///
+ /// Dataservice x accesso DB
+ ///
+ protected MpStatsService DService { get; set; }
+ }
+}
diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj
index aaab9c87..ddefe7ea 100644
--- a/MP.Stats/MP.Stats.csproj
+++ b/MP.Stats/MP.Stats.csproj
@@ -6,6 +6,8 @@
826e877c-ba70-4253-84cb-d0b1cafd4440
6.16.2404.0312
6.16.2404.0312
+ true
+ $(NoWarn);1591
@@ -192,6 +194,7 @@
+
diff --git a/MP.Stats/Startup.cs b/MP.Stats/Startup.cs
index 608c3a67..8c3393dc 100644
--- a/MP.Stats/Startup.cs
+++ b/MP.Stats/Startup.cs
@@ -5,9 +5,13 @@ using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
+using Microsoft.OpenApi.Models;
using MP.Stats.Data;
using StackExchange.Redis;
+using System;
using System.Globalization;
+using System.IO;
+using System.Reflection;
namespace MP.Stats
{
@@ -65,8 +69,17 @@ namespace MP.Stats
app.UseRouting();
+ // aggiunta swagger, alla pagina /swagger/index.html
+ if (env.IsDevelopment() || env.IsStaging())
+ {
+ app.UseSwagger();
+ app.UseSwaggerUI();
+ }
+
+ // Configure the HTTP request pipeline.
app.UseEndpoints(endpoints =>
{
+ endpoints.MapControllers();
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
@@ -76,6 +89,34 @@ namespace MP.Stats
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
+ services.AddControllers();
+ // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+ services.AddEndpointsApiExplorer();
+ services.AddSwaggerGen(options =>
+ {
+ options.SwaggerDoc("v1", new OpenApiInfo
+ {
+ Version = "v1",
+ Title = "MP-STATS API",
+ Description = "ASP.NET Core Web API for managing MP-STATS items",
+ TermsOfService = new Uri("https://www.egalware.com/mp-stats-api-terms"),
+ //Contact = new OpenApiContact
+ //{
+ // Name = "Example Contact",
+ // Url = new Uri("https://example.com/contact")
+ //},
+ //License = new OpenApiLicense
+ //{
+ // Name = "Example License",
+ // Url = new Uri("https://example.com/license")
+ //}
+ });
+
+ // using System.Reflection;
+ var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
+ options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
+ });
+
// Elmah
services.AddElmah();
//string elmaConn = "Data Source=SQL2016DEV;Initial Catalog=Elmah;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=SHERPA.BBM;";