ServiceManager.cs 1.0 KB
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);
            }
        }
    }
}