예제 #1
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");
                    }
                }
            }
        }
예제 #2
0
 public ServerApiController(IServerSvc serverSvc)
 {
     _serverSvc = serverSvc;
 }