81 lines
2.5 KiB
C#
81 lines
2.5 KiB
C#
using CMS_CORE_Library.Models;
|
|
using Step.Database.Controllers;
|
|
using Step.Model.ConfigModels;
|
|
using Step.Model.DatabaseModels;
|
|
using Step.Model.DTOModels;
|
|
using Step.Model.DTOModels.AlarmModels;
|
|
using Step.NC;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Policy;
|
|
using System.Web.Http;
|
|
using static Step.Config.ServerConfig;
|
|
|
|
namespace Step.Controllers.WebApi
|
|
{
|
|
[RoutePrefix("api/ext_software")]
|
|
public class ApiExternalSoftwareController : ApiController
|
|
{
|
|
[Route(""), HttpGet]
|
|
public IHttpActionResult GetSoftware()
|
|
{
|
|
List<DTOExternalSoftwareModel> dto = ExtSoftwaresConfig.Select(x => new DTOExternalSoftwareModel()
|
|
{
|
|
Id = x.Id,
|
|
Arguments = x.Arguments,
|
|
InMainMenuBar = x.InMainMenuBar,
|
|
LongName = x.LongName,
|
|
Path = x.Path,
|
|
ShortName = x.ShortName,
|
|
IconBase64 = x.IconBase64,
|
|
IsCms = true
|
|
})
|
|
.ToList();
|
|
|
|
ExternalSoftwareController controller = new ExternalSoftwareController();
|
|
var dbSoftware = controller.GetSoftware().Select(x => new DTOExternalSoftwareModel()
|
|
{
|
|
Id = x.Id.ToString(),
|
|
IsCms = false,
|
|
InMainMenuBar = x.InMainMenuBar,
|
|
Arguments = "",
|
|
Path = x.Path.Trim()
|
|
}).ToList();
|
|
|
|
return Ok(dto.Concat(dbSoftware));
|
|
}
|
|
|
|
[Route(""), HttpPost]
|
|
public IHttpActionResult AddExternalSoftware([FromBody] ExternalProgramModel software)
|
|
{
|
|
ExternalSoftwareController controller = new ExternalSoftwareController();
|
|
|
|
software = controller.Add(software.Path);
|
|
|
|
return Ok(software);
|
|
}
|
|
|
|
[Route("{id:int}"), HttpDelete]
|
|
public IHttpActionResult DeleteExternalSoftware(int id)
|
|
{
|
|
ExternalSoftwareController controller = new ExternalSoftwareController();
|
|
|
|
var software = controller.Delete(id);
|
|
if (software == null)
|
|
return NotFound();
|
|
|
|
return Ok(software);
|
|
}
|
|
|
|
[Route("move/{id:int}"), HttpPut]
|
|
public IHttpActionResult MoveExternalSoftware(int id, ExternalProgramModel software)
|
|
{
|
|
ExternalSoftwareController controller = new ExternalSoftwareController();
|
|
|
|
var ext = controller.Move(id, software.InMainMenuBar);
|
|
|
|
return Ok(ext);
|
|
}
|
|
}
|
|
}
|