ServiceManager.cs
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Common;
using DeviceLib.WebApi;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLib.BLL
{
public class ServiceManager
{
static HttpService httpService;
public async static void Start()
{
try
{
int port = AppConfigSetting.GetIntVal(Setting_Str.WebApiPort, 8088);
httpService = new HttpService(port);
await httpService.StartHttpServer();
}
catch (Exception ex)
{
LogUtil.Error("打开WebApi服务失败", ex);
}
}
public async static void Stop()
{
try
{
await httpService.CloseHttpServer();
httpService.Dispose();
}
catch (Exception ex)
{
LogUtil.Error("关闭WebApi服务失败", ex);
}
}
}
}