60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Serilog;
|
|
using LCU.Library.Internal.FileOperationsModels.Models;
|
|
using LCU.Library.Internal.FileOperationsModels.Shared;
|
|
|
|
namespace LCU.Api.Internal.FileOperations.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class DynamicFileController : ControllerBase
|
|
{
|
|
/// <summary>Gets a list of files based on regex substitution.</summary>
|
|
/// <remarks>
|
|
/// Example:
|
|
/// POST /api/BuildDynamicFileList
|
|
/// {
|
|
/// "path": "\\\\172.16.13.17\\Reports\\",
|
|
/// "filename": "Action_IndirectVehicleLoanSales_date_time.csv",
|
|
/// "dynamicFileSettings": {
|
|
/// "regexSettings": [
|
|
/// {
|
|
/// "tag": "date",
|
|
/// "regex": "\\d+_\\d+_\\d+"
|
|
/// },
|
|
/// {
|
|
/// "tag": "time",
|
|
/// "regex": "\\d+"
|
|
/// }],
|
|
/// "daysFromToday": 0
|
|
/// }
|
|
/// }
|
|
/// </remarks>
|
|
/// <param name="dynamicFileListRequest"></param>
|
|
/// <returns></returns>
|
|
// POST api/BuildDynamicFileList
|
|
[HttpPost("BuildDynamicFileList")]
|
|
[ProducesResponseType(201)]
|
|
[ProducesResponseType(typeof(List<string>), 400)]
|
|
[ProducesResponseType(500)]
|
|
public IActionResult BuildDynamicFileList([FromBody] DynamicFileListRequest dynamicFileListRequest)
|
|
{
|
|
try
|
|
{
|
|
var fileNames = RegexNameHandler.BuildFileList(dynamicFileListRequest.Path,
|
|
dynamicFileListRequest.Filename,
|
|
dynamicFileListRequest.DynamicFileSettings);
|
|
return Ok(fileNames);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error(ex, "Failure Build Dynamic File List");
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
}
|
|
}
|