FixTaskMan module
- LAND - STATS
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Stats.Data;
|
||||
using MP.TaskMan.Models;
|
||||
using MP.TaskMan.Services;
|
||||
using NLog;
|
||||
using NLog.Fluent;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -16,7 +14,9 @@ namespace MP.Stats.Controllers
|
||||
[ApiController]
|
||||
public class TaskController : ControllerBase
|
||||
{
|
||||
public TaskController(IConfiguration configuration, MpStatsService DataService)
|
||||
#region Public Constructors
|
||||
|
||||
public TaskController(IConfiguration configuration, TaskService DataService)
|
||||
{
|
||||
Log.Trace("Starting TaskController");
|
||||
_configuration = configuration;
|
||||
@@ -24,16 +24,9 @@ namespace MP.Stats.Controllers
|
||||
Log.Trace("Avviato TaskController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of available task and last execution data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetList")]
|
||||
public async Task<List<TaskListModel>> GetList()
|
||||
{
|
||||
List<TaskListModel> answ = await DService.TaskListAll(MP.Data.Objects.Enums.Task2ExeType.ND, "");
|
||||
return answ;
|
||||
}
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Call for execution of due task and report state
|
||||
@@ -43,26 +36,47 @@ namespace MP.Stats.Controllers
|
||||
public async Task<List<TaskResultModel>> ExecuteAndReturnGet()
|
||||
{
|
||||
List<TaskResultModel> answ = new List<TaskResultModel>();
|
||||
List<TaskListModel> listTask = await DService.TaskListAll(MP.Data.Objects.Enums.Task2ExeType.ND, "");
|
||||
List<TaskListModel> listTask = await DService.TaskListAll(TaskMan.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, true);
|
||||
TaskResultModel result = await DService.ExecuteTask(taskRec, true);
|
||||
answ.Add(result);
|
||||
}
|
||||
// resituisco
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of available task and last execution data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetList")]
|
||||
public async Task<List<TaskListModel>> GetList()
|
||||
{
|
||||
List<TaskListModel> answ = await DService.TaskListAll(TaskMan.Objects.Enums.Task2ExeType.ND, "");
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
protected TaskService DService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
protected MpStatsService DService { get; set; }
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user