From eb69a3cf12220869d267e04a0e5ea82ddcf6ec12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81=20=EA=B9=80?= Date: Wed, 8 May 2024 20:01:25 +0900 Subject: [PATCH] Modified --- .../Helper/FileExtensionDB.cs | 12 ++++-------- Catswords.DataType.Client/UserControl1.cs | 18 ++++++++---------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Catswords.DataType.Client/Helper/FileExtensionDB.cs b/Catswords.DataType.Client/Helper/FileExtensionDB.cs index efcba24..231e246 100644 --- a/Catswords.DataType.Client/Helper/FileExtensionDB.cs +++ b/Catswords.DataType.Client/Helper/FileExtensionDB.cs @@ -1,6 +1,8 @@ using Catswords.DataType.Client.Model; using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; using System.Net; using System.Net.Http; using System.Net.NetworkInformation; @@ -19,18 +21,12 @@ namespace Catswords.DataType.Client.Helper Indicators = new List(); } + public void Fetch(string q) { try { - bool isConnected = NetworkInterface.GetIsNetworkAvailable(); - if (isConnected == false) - { - MessageBox.Show("인터넷에 연결되어 있지 않습니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - // 원격 주소에서 XML 다운로드 + // 원격 주소에서 XML 다운로드 string url = Config.SEARCH_URL + q; WebClient client = new WebClient(); diff --git a/Catswords.DataType.Client/UserControl1.cs b/Catswords.DataType.Client/UserControl1.cs index b105123..8021fe6 100644 --- a/Catswords.DataType.Client/UserControl1.cs +++ b/Catswords.DataType.Client/UserControl1.cs @@ -85,7 +85,6 @@ namespace Catswords.DataType.Client bool IsInternetConnected() { const string NCSI_TEST_URL = "http://www.msftncsi.com/ncsi.txt"; - const string NCSI_TEST_RESULT = "Microsoft NCSI"; const string NCSI_DNS = "dns.msftncsi.com"; const string NCSI_DNS_IP_ADDRESS = "131.107.255.255"; @@ -94,7 +93,7 @@ namespace Catswords.DataType.Client // Check NCSI test link var webClient = new WebClient(); string result = webClient.DownloadString(NCSI_TEST_URL); - if (result != NCSI_TEST_RESULT) + if (result != "Microsoft NCSI") { return false; } @@ -118,18 +117,17 @@ namespace Catswords.DataType.Client private void FetchFromFileExtensionDB() { if (IsInternetConnected()) - { - var search = new FileExtensionDB(); - search.Fetch(fileExtension); - foreach (Indicator ind in search.Indicators) - { - listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt.ToString(), ind.Content }, 0)); - } + search.Fetch(fileExtension); + foreach (Indicator ind in search.Indicators) + { + listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt.ToString(), ind.Content }, 0)); + } } else { - MessageBox.Show("네트워크 상태 좋지 않습니다."); + MessageBox.Show("인터넷에 연결되어 있지 않습니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } }