This commit is contained in:
준영 김 2024-05-08 20:01:25 +09:00
parent 723858ec9b
commit eb69a3cf12
2 changed files with 12 additions and 18 deletions

View File

@ -1,6 +1,8 @@
using Catswords.DataType.Client.Model; using Catswords.DataType.Client.Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
@ -19,18 +21,12 @@ namespace Catswords.DataType.Client.Helper
Indicators = new List<Indicator>(); Indicators = new List<Indicator>();
} }
public void Fetch(string q) public void Fetch(string q)
{ {
try try
{ {
bool isConnected = NetworkInterface.GetIsNetworkAvailable(); // 원격 주소에서 XML 다운로드
if (isConnected == false)
{
MessageBox.Show("인터넷에 연결되어 있지 않습니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// 원격 주소에서 XML 다운로드
string url = Config.SEARCH_URL + q; string url = Config.SEARCH_URL + q;
WebClient client = new WebClient(); WebClient client = new WebClient();

View File

@ -85,7 +85,6 @@ namespace Catswords.DataType.Client
bool IsInternetConnected() bool IsInternetConnected()
{ {
const string NCSI_TEST_URL = "http://www.msftncsi.com/ncsi.txt"; 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 = "dns.msftncsi.com";
const string NCSI_DNS_IP_ADDRESS = "131.107.255.255"; const string NCSI_DNS_IP_ADDRESS = "131.107.255.255";
@ -94,7 +93,7 @@ namespace Catswords.DataType.Client
// Check NCSI test link // Check NCSI test link
var webClient = new WebClient(); var webClient = new WebClient();
string result = webClient.DownloadString(NCSI_TEST_URL); string result = webClient.DownloadString(NCSI_TEST_URL);
if (result != NCSI_TEST_RESULT) if (result != "Microsoft NCSI")
{ {
return false; return false;
} }
@ -118,18 +117,17 @@ namespace Catswords.DataType.Client
private void FetchFromFileExtensionDB() private void FetchFromFileExtensionDB()
{ {
if (IsInternetConnected()) if (IsInternetConnected())
{ {
var search = new FileExtensionDB(); var search = new FileExtensionDB();
search.Fetch(fileExtension); search.Fetch(fileExtension);
foreach (Indicator ind in search.Indicators) foreach (Indicator ind in search.Indicators)
{ {
listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt.ToString(), ind.Content }, 0)); listView1.Items.Add(new ListViewItem(new string[] { ind.CreatedAt.ToString(), ind.Content }, 0));
} }
} else } else
{ {
MessageBox.Show("네트워크 상태 좋지 않습니다."); MessageBox.Show("인터넷에 연결되어 있지 않습니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
} }
} }