Files
cms_thermo_active/Step/Controllers/WebApi/CmsConnectController.cs
T
Nicola Carminati bb45bdf9e5 Wip Wip Wip
2019-08-23 17:15:16 +02:00

55 lines
1.8 KiB
C#

using Step.CmsConnectGateway;
using Step.CmsConnectGateway.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
namespace Step.Controllers.WebApi
{
[RoutePrefix("api/cms_connect")]
public class CmsConnectController : ApiController
{
[Route("runConnectionTest"), HttpGet]
public IHttpActionResult RunConnectionTest()
{
using(GatewayAdapter Adp = new GatewayAdapter(Config.ServerConfig.CmsConnectConfig.Gateway.Address, Config.ServerConfig.CmsConnectConfig.Gateway.Username, Config.ServerConfig.CmsConnectConfig.Gateway.Password))
{
try
{
GatewayConnectionStatus sts = Adp.TestGatewayConnection(5);
return Ok(sts.ToString());
}
catch (GatewayException e)
{
return InternalServerError(e);
}
}
}
[Route("getGatewayNetworkSetup"), HttpGet]
public IHttpActionResult GetGatewayNetworkSetup()
{
using (GatewayAdapter Adp = new GatewayAdapter(Config.ServerConfig.CmsConnectConfig.Gateway.Address, Config.ServerConfig.CmsConnectConfig.Gateway.Username, Config.ServerConfig.CmsConnectConfig.Gateway.Password))
{
try
{
GatewayNetworkConfiguration config = Adp.ReadGatewayNetworkConfiguration();
return Ok(config);
}
catch (GatewayException e)
{
return InternalServerError(e);
}
}
}
}
}