12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using Abp.Dependency;
- using Microsoft.AspNetCore.Hosting;
- using System.IO;
- using Yunda.ISAS.DataMonitoringServer.DataCenter;
- namespace Yunda.ISAS.DataMonitoringServer.WebApi
- {
- public class WebApiServer : ISingletonDependency
- {
- private IWebHost _host;
- private WebApiConfigModel _configModel;
- public static CameraDataCenter _cameraDataCenter;
- public static RunningDataCache _runningDataCache;
- public WebApiServer(WebApiConfigModel webApiConfig,
- RunningDataCache runningDataCache,
- CameraDataCenter cameraDataCenter)
- {
- _configModel = webApiConfig;
- _cameraDataCenter = cameraDataCenter;
- _runningDataCache = runningDataCache;
- }
- public async void RunServerAsync(int port)
- {
- if (_host == null)
- {
- if (_configModel == null)
- _configModel = new WebApiConfigModel();
- string url = "http://*:" + port;
- _host = new WebHostBuilder()
- .UseKestrel()
- .UseContentRoot(Directory.GetCurrentDirectory())
- .UseUrls(url)
- .UseStartup<WebApiStartup>()
- .Build();
- await _host.RunAsync();
- }
- }
- public void ShutdownServer()
- {
- if (_host != null)
- _host.Dispose();
- //await _host.WaitForShutdownAsync();
- }
- }
- }
|