Ejemplo n.º 1
0
        public IActionResult GetServerConfig()
        {
            var bll = new ServerConfigBll();
            var rst = bll.GetServerConfig();

            return(Json(rst));
        }
Ejemplo n.º 2
0
        public IActionResult GetList(ServerConfig model)
        {
            var bll = new ServerConfigBll();
            var rst = bll.GetList(model);

            return(Json(rst));
        }
Ejemplo n.º 3
0
        public IActionResult Delete(ServerConfig model)
        {
            var bll = new ServerConfigBll();
            var rst = bll.Delete(model);

            return(Json(rst));
        }
Ejemplo n.º 4
0
        public static void StartAllServer()
        {
            try
            {
                var bll        = new ServerConfigBll();
                var serverList = bll.GetList("").Data ?? new List <ServerConfig>();
                if (serverList.Any())
                {
                    foreach (var item in serverList)
                    {
                        switch (item.protocol)
                        {
                        case "http":
                        case "https":
                            StartHttpsServer(item);
                            break;

                        case "tcp":
                        case "udp":
                            StartTcpServer(item);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error($"启动服务失败:{ex}");
            }
        }
Ejemplo n.º 5
0
        public IActionResult GetOne(ServerConfig model)
        {
            if (model.id == 0)
            {
                var defalut = new ApiResult <ServerConfig>()
                {
                    Result = true,
                    Data   = new ServerConfig()
                };
                return(Json(defalut));
            }
            var bll = new ServerConfigBll();
            var rst = bll.GetOne(model);

            return(Json(rst));
        }
Ejemplo n.º 6
0
        public IActionResult Add(ServerConfig model)
        {
            var rst = new ReturnResult <bool>();

            using var bll = new ServerConfigBll();
            if (model.id == 0)
            {
                rst = bll.Add(model);
            }
            else
            {
                rst = bll.Update(model);
            }

            return(Json(rst));
        }
Ejemplo n.º 7
0
        public void StartAllServer()
        {
            try
            {
                using var bll = new ServerConfigBll();
                var serverList = bll.GetList("").Data ?? new List <Common.Models.ServerConfig>();
                if (serverList.Any())
                {
                    foreach (var item in serverList)
                    {
                        switch (item.protocol)
                        {
                        case "http":
                        case "https":
                            Task.Run(() =>
                            {
                                StartWebServer(item);
                            });
                            break;

                        case "tcp":
                        case "udp":
                            Task.Run(() =>
                            {
                                StartTcpServer(item);
                            });
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                HandleLog.WriteLine($"启动服务失败:{ex}");
            }
        }