public IActionResult AddServerNode(string server)
 {
     if (!server.StartsWith("http://") || server.StartsWith("https://"))
     {
         return(Json(new { Success = false, Message = "ServerHost格式不正确" }));
     }
     ServerSvc.AddServerNode(server.TrimEnd('/'));
     return(Json(new { Success = true, Message = "添加成功!" }));
 }
        public IActionResult Index()
        {
            ClusterIndexModel cluster = new ClusterIndexModel()
            {
                Servers = ServerSvc.LoadServerNodes().ToList(),
                Topics  = TopicSvc.LoadValidTopics().ToList()
            };

            return(View(cluster));
        }
예제 #3
0
        private void RunMonitor()
        {
            ServerDTO  serverDTO = null;
            HttpClient client    = new HttpClient();

            client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["BASE_ADDRESS_API"]);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            IServerSvc _iSvc          = null;
            string     wcfHostAddress = System.Configuration.ConfigurationManager.AppSettings["BASE_ADDR_WCF"];

            while (true)
            {
                System.Threading.Thread.Sleep(1000);
                using (_iSvc = new ServerSvc())
                {
                    serverDTO = _iSvc.GetServerInformation();
                    serverDTO.WCFHostingURL = wcfHostAddress;
                    if (!string.IsNullOrEmpty(serverDTO.ServerIP) && !string.IsNullOrEmpty(serverDTO.ServerName))
                    {
                        var response = client.PostAsJsonAsync("api/server/sendDetail", serverDTO).Result;

                        if (response.IsSuccessStatusCode)
                        {
                            Console.WriteLine("Call status successful...");
                        }
                        else
                        {
                            Console.WriteLine("Call status error...");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Server IP or Server Name is not found");
                    }
                }
            }
        }
 public IActionResult RemoveServerNode(string server)
 {
     ServerSvc.RemoveServerNode(server);
     return(Json(new { Success = true, Message = "删除成功!" }));
 }