CRVM-redis-6/RestApi/RestHandler.cs
2025-11-07 02:02:31 +08:00

52 lines
1.3 KiB
C#

using System;
using System.ServiceModel.Web;
namespace RestApi
{
public class RestHandler
{
WebServiceHost _serviceHost;
RollMillGetService _service = new RollMillGetService();
string _ip = "0.0.0.0";
int _port = 5122;
string _uri = "http://0.0.0.0:5122/";
public RestHandler(int port = 5122, string ip = "0.0.0.0")
{
this._port = port;
this._ip = ip;
this._uri = "http://" + this._ip + ":" + this._port.ToString() + "/";
}
public void Start()
{
try
{
_serviceHost = new WebServiceHost(_service, new Uri(this._uri));
_serviceHost.Open();
}
catch (Exception ex)
{
Console.WriteLine(DateTime.Now.ToString()+"|RestHandler|" + ex.Message);
throw new Exception("|RestHandler|Start()|ERROR| " + ex.Message + "StackTrace:" + ex.StackTrace);
}
}
public RollMillData Roll_mill_data
{
get { return _service.Roll_mill_data; }
set { _service.Roll_mill_data = value; }
}
public CZState cZState { set { _service.czState = value; } get { return _service.czState; } }
public void Stop()
{
_serviceHost.Close();
}
}
}