diff --git a/unimarc/CLAUDE.md b/unimarc/CLAUDE.md index 50c3f96..de6683b 100644 --- a/unimarc/CLAUDE.md +++ b/unimarc/CLAUDE.md @@ -41,310 +41,4 @@ F:\(VHD) Program Files\Microsoft Visual Studio\2022\MSBuild\Current\Bin\msbuild.exe ## 프로젝트 파일명 -UniMarc.csproj - -## Webview2 Fixed Version 다운로드 주소 -https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/759b508a-00bb-4724-9b87-2703c8417737/Microsoft.WebView2.FixedVersionRuntime.139.0.3405.86.x86.cab - -## WebView2 Selenium 스타일 DOM 조작 가이드 - -### 🔧 기본 DOM 조작 메서드들 (NamguLibrarySearcher 기본 클래스에 구현됨) - -#### 1. 요소 대기 및 존재 확인 -```csharp -// DOM 요소가 준비될 때까지 대기 (Selenium의 WebDriverWait와 유사) -await WaitForElementReady("#clickAll", 10000); // 10초 타임아웃 -await WaitForElementReady("input[name='query']", 5000); // 5초 타임아웃 -``` - -#### 2. 요소 상태 확인 -```csharp -// 체크박스가 체크되어 있는지 확인 (Selenium의 element.IsSelected와 유사) -bool isChecked = await IsElementChecked("#clickAll"); -bool isLibMAChecked = await IsElementChecked("#libMA"); -``` - -#### 3. 요소 클릭 -```csharp -// 요소 클릭 (Selenium의 element.Click()와 유사) -await ClickElement("#clickAll"); // 전체 선택 클릭 -await ClickElement("#libMA"); // 문화정보도서관 클릭 -await ClickElement("button[type='submit']"); // 검색 버튼 클릭 -``` - -#### 4. 값 입력 및 설정 -```csharp -// 입력창에 값 설정 (Selenium의 element.SendKeys()와 유사) -await SetElementValue("input[name='query']", "검색어"); -await SetElementValue("#search_txt", "도서명"); -// 이벤트도 자동으로 발생시킴 (input, change 이벤트) -``` - -#### 5. 텍스트 가져오기 -```csharp -// 요소의 텍스트 내용 가져오기 (Selenium의 element.Text와 유사) -string resultText = await GetElementText(".search-result span"); -string bookCount = await GetElementText("span:contains('전체')"); -``` - -### 🚀 실제 사용 예제 - -#### 도서관 선택 (남구통합도서관 예제) -```csharp -protected override async Task SelectLibraryWebView2() -{ - try - { - // 1. DOM 요소 존재 확인 및 대기 - await WaitForElementReady("#clickAll"); - await WaitForElementReady("#libMA"); - - // 2. 전체 선택 해제 (단계별 실행) - bool isClickAllChecked = await IsElementChecked("#clickAll"); - if (isClickAllChecked) - { - await ClickElement("#clickAll"); - Console.WriteLine("전체 선택 해제됨"); - } - - // 3. 특정 도서관 선택 - bool libMAChecked = await ClickElement("#libMA"); - Console.WriteLine($"문화정보도서관 선택: {libMAChecked}"); - - return libMAChecked; - } - catch (Exception ex) - { - Console.WriteLine($"도서관 선택 오류: {ex.Message}"); - return false; - } -} -``` - -#### 검색 실행 (단계별) -```csharp -private async Task PerformSearchWebView2(string searchTerm) -{ - try - { - // 1. 검색창 찾기 및 대기 (여러 선택자 시도) - string[] searchSelectors = { - "input[name='query']", - "input[id='query']", - "input[type='text']" - }; - - string searchInputSelector = null; - foreach (var selector in searchSelectors) - { - try - { - await WaitForElementReady(selector, 3000); - searchInputSelector = selector; - break; - } - catch { continue; } - } - - // 2. 검색어 입력 - await SetElementValue(searchInputSelector, searchTerm); - - // 3. 검색 버튼 클릭 (여러 선택자 시도) - string[] buttonSelectors = { - "button[type='submit']", - "input[type='submit']", - ".search-btn", - ".btn-search" - }; - - bool searchExecuted = false; - foreach (var selector in buttonSelectors) - { - if (await ClickElement(selector)) - { - searchExecuted = true; - break; - } - } - - // 4. 검색 버튼이 없으면 Enter 키로 검색 - if (!searchExecuted) - { - string enterScript = $@" - const input = document.querySelector('{searchInputSelector}'); - if (input) {{ - input.dispatchEvent(new KeyboardEvent('keydown', {{ - key: 'Enter', keyCode: 13, bubbles: true - }})); - return true; - }} - return false; - "; - await _webView2.CoreWebView2.ExecuteScriptAsync(enterScript); - } - - Console.WriteLine("✅ 검색 실행 완료"); - } - catch (Exception ex) - { - Console.WriteLine($"❌ 검색 실행 오류: {ex.Message}"); - throw; - } -} -``` - -### 🎯 CSS 선택자 참고 - -#### 남구통합도서관 주요 선택자들 -```css -/* 도서관 선택 체크박스 */ -#clickAll /* 전체 선택 */ -#libMA /* 문화정보도서관 */ -#libMB /* 푸른길도서관 */ -#libMC /* 청소년도서관 */ -#libSW /* 효천어울림도서관 */ -#libSQ /* 스마트도서관 */ - -/* 검색 관련 */ -input[name='query'] /* 검색창 */ -button[type='submit'] /* 검색 버튼 */ - -/* 결과 관련 */ -.search-result /* 검색 결과 영역 */ -span:contains('전체') /* 검색 결과 수량 */ -``` - -### ⚠️ 주의사항 - -1. **페이지 로딩 대기**: 항상 `WaitForElementReady()`로 요소가 준비될 때까지 대기 -2. **에러 처리**: try-catch로 각 단계별 예외 처리 -3. **로깅**: `Console.WriteLine()`으로 상세한 실행 로그 남기기 -4. **타임아웃**: 적절한 타임아웃 설정 (기본 10초) -5. **다중 선택자**: 여러 CSS 선택자를 배열로 준비하여 순차적으로 시도 - -### 🔄 Selenium에서 WebView2로 이주 가이드 - -| Selenium 코드 | WebView2 대응 코드 | -|---------------|-------------------| -| `WebDriverWait.Until()` | `await WaitForElementReady()` | -| `element.Click()` | `await ClickElement()` | -| `element.SendKeys()` | `await SetElementValue()` | -| `element.Text` | `await GetElementText()` | -| `element.IsSelected` | `await IsElementChecked()` | -| `element.Clear()` | SetElementValue로 빈 문자열 설정 | - -### 💡 성능 및 안정성 팁 - -- **WebView2가 Selenium보다 빠름**: 네이티브 성능 -- **고정 버전 사용**: Chrome 버전 호환성 문제 없음 -- **단계별 실행**: 각 작업을 개별 메서드로 분리하여 디버깅 용이 -- **상세 로깅**: 각 단계마다 성공/실패 상태 출력 -- **단순한 JavaScript 사용**: 복잡한 JSON보다는 단순한 문자열 반환 권장 - -## 🚨 **WebView2 JavaScript 실행 시 주의사항 (중요 교훈)** - -### **문제: RuntimeBinderException과 null 반환** - -**❌ 피해야 할 패턴:** -```csharp -// 복잡한 JSON 반환 스크립트 - 불안정함 -string script = $@" - try {{ - const element = document.querySelector('{selector}'); - return JSON.stringify({{ success: true, isChecked: element.checked }}); - }} catch (e) {{ - return JSON.stringify({{ success: false, error: e.message }}); - }} -"; - -string result = await webView2.CoreWebView2.ExecuteScriptAsync(script); -dynamic resultObj = JsonConvert.DeserializeObject(result); // RuntimeBinderException 위험! - -if (resultObj.success == true) // null 참조 오류 발생 가능 -``` - -**✅ 권장하는 안전한 패턴:** -```csharp -// 단순한 문자열 반환 - 안정적임 -string result = await webView2.CoreWebView2.ExecuteScriptAsync($@" - try {{ - var element = document.querySelector('{selector}'); - if (element && element.checked) {{ - element.click(); - return element.checked ? 'failed' : 'success'; - }} - return element ? 'already_unchecked' : 'not_found'; - }} catch (e) {{ - return 'error: ' + e.message; - }} -"); - -// 안전한 문자열 비교 -if (result != null && result.Contains("success")) -{ - return true; -} -``` - -### **핵심 교훈:** - -1. **단순함이 최고**: WebView2에서는 복잡한 JSON.stringify()보다 단순한 문자열 반환이 훨씬 안정적 -2. **Dynamic 타입 위험**: `dynamic` 객체는 null 체크 없이 사용하면 RuntimeBinderException 발생 -3. **직접적인 JavaScript**: 중간 JSON 변환 없이 직접적인 DOM 조작이 더 확실함 -4. **단계별 진단**: 복잡한 로직은 여러 개의 간단한 스크립트로 분할하여 실행 - -### **권장 디버깅 패턴:** -```csharp -// 1단계: 기본 JavaScript 실행 확인 -string test1 = await webView2.ExecuteScriptAsync("1+1"); -Console.WriteLine($"기본 연산: {test1}"); - -// 2단계: DOM 접근 확인 -string test2 = await webView2.ExecuteScriptAsync("document.title"); -Console.WriteLine($"DOM 접근: {test2}"); - -// 3단계: 요소 존재 확인 -string test3 = await webView2.ExecuteScriptAsync($"document.querySelector('{selector}') !== null"); -Console.WriteLine($"요소 존재: {test3}"); - -// 4단계: 실제 작업 수행 -string result = await webView2.ExecuteScriptAsync($"document.querySelector('{selector}').click(); 'clicked'"); -Console.WriteLine($"작업 결과: {result}"); -``` - -**이 패턴을 사용하면 WebView2 JavaScript 실행에서 99%의 문제를 예방할 수 있습니다!** - -## 🧹 **WebView2 메모리 누수 방지 (중요!)** - -**문제**: WebView2는 메모리 누수로 인해 프로그램이 갑자기 종료될 수 있습니다. - -**해결책**: 검색 전후로 메모리 정리를 수행하세요. - -```csharp -// 검색 시작 전 -await CleanupWebView2Memory(); - -// 검색 작업 수행... - -// 검색 완료 후 (finally 블록에서) -finally { - await CleanupWebView2Memory(); -} - -private async Task CleanupWebView2Memory() -{ - try { - await _webView2.CoreWebView2.ExecuteScriptAsync(@" - if (window.gc) window.gc(); null; - "); - GC.Collect(); - GC.WaitForPendingFinalizers(); - } catch { /* 무시 */ } -} -``` - -**주의사항**: -- WebView2는 장시간 사용 시 메모리 누수 발생 가능 -- 각 검색 작업 후 반드시 정리 수행 -- Chrome WebDriver보다 메모리 관리가 까다로움 - +UniMarc.csproj \ No newline at end of file diff --git a/unimarc/unimarc/App.config b/unimarc/unimarc/App.config index c35a7d9..d97add1 100644 --- a/unimarc/unimarc/App.config +++ b/unimarc/unimarc/App.config @@ -26,7 +26,7 @@ - + @@ -44,6 +44,14 @@ + + + + + + + + diff --git a/unimarc/unimarc/CUtill.cs b/unimarc/unimarc/CUtill.cs deleted file mode 100644 index 69b7175..0000000 --- a/unimarc/unimarc/CUtill.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace UniMarc -{ - public static class CUtill - { - public static arUtil.Log mLog; - - public static void MsgI(string m) - { - //MessageWindow.VisibleAll(false); - MessageBox.Show(m, "CHECK", MessageBoxButtons.OK, MessageBoxIcon.Information); - //MessageWindow.VisibleAll(true); - } - public static void MsgE(string m) - { - //MessageWindow.VisibleAll(false); - MessageBox.Show(m, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); - //MessageWindow.VisibleAll(true); - } - public static DialogResult MsgQ(string m) - { - //MessageWindow.VisibleAll(false); - DialogResult dlg = MessageBox.Show(m, "CHECK", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - //MessageWindow.VisibleAll(true); - return dlg; - } - } -} diff --git a/unimarc/unimarc/Main.cs b/unimarc/unimarc/Main.cs index 711a9f0..818b056 100644 --- a/unimarc/unimarc/Main.cs +++ b/unimarc/unimarc/Main.cs @@ -41,26 +41,16 @@ namespace WindowsFormsApp1 public Main() { InitializeComponent(); - - + PUB.Init(); } public string User_Name { get; internal set; } private void Main_Load(object sender, EventArgs e) { - - - this.Visible = false; // 메인폼을 먼저 숨김 - #region "Log setting" - var logsubdir = "{yyyy|MM|dd}"; - string tPath = string.Format("{0}\\LOG", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); ; - CUtill.mLog = new arUtil.Log(tPath); - CUtill.mLog.SubDirectory = logsubdir; - CUtill.mLog.FileNameFormat = "{yyMMdd}"; - #endregion + login login = new login(); VersionText.Text = string.Format("UniMarc Ver.{0}", ip.VersionInfo()); @@ -1202,7 +1192,7 @@ namespace WindowsFormsApp1 { Mac_dLS_Copy = new DLS_Copy(this); Mac_dLS_Copy.MdiParent = this; - Mac_dLS_Copy.WindowState = FormWindowState.Maximized; + //Mac_dLS_Copy.WindowState = FormWindowState.Maximized; Mac_dLS_Copy.FormClosed += (o, ea) => Mac_dLS_Copy = null; Mac_dLS_Copy.Show(); } diff --git a/unimarc/unimarc/PUB.cs b/unimarc/unimarc/PUB.cs new file mode 100644 index 0000000..1968a39 --- /dev/null +++ b/unimarc/unimarc/PUB.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace UniMarc +{ + public static class PUB + { + public static arUtil.Log log; + + public static void Init() + { + #region "Log setting" + var logsubdir = "{yyyy|MM|dd}"; + string tPath = string.Format("{0}\\LOG", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); ; + PUB.log = new arUtil.Log(tPath); + PUB.log.SubDirectory = logsubdir; + PUB.log.FileNameFormat = "{yyMMdd}"; + #endregion + } + + } +} diff --git a/unimarc/unimarc/SearchModel/BookSearchService.cs b/unimarc/unimarc/SearchModel/BookSearchService.cs index 6debbb7..e833b33 100644 --- a/unimarc/unimarc/SearchModel/BookSearchService.cs +++ b/unimarc/unimarc/SearchModel/BookSearchService.cs @@ -26,20 +26,6 @@ namespace BokBonCheck }; } - public async Task> SearchBooksAsync(string searchTerm) - { - var results = new List(); - - foreach (var searcher in _searchers) - { - searcher.StartDriver(); - var result = await searcher.SearchAsync(searchTerm); - results.Add(result); - //searcher.StopDriver(); - } - - return results; - } /// /// Return Searcher diff --git a/unimarc/unimarc/SearchModel/ChromeDriverManager.cs b/unimarc/unimarc/SearchModel/ChromeDriverManager.cs index a864b52..6bb4f90 100644 --- a/unimarc/unimarc/SearchModel/ChromeDriverManager.cs +++ b/unimarc/unimarc/SearchModel/ChromeDriverManager.cs @@ -8,17 +8,60 @@ using System.Reflection; using System.Net.Http; using System.Threading; using System.IO.Compression; +using System.Linq; +using System.Security.Principal; +using OpenQA.Selenium; +using OpenQA.Selenium.Chrome; namespace BokBonCheck { public static class ChromeDriverManager { private static string _driverPath = null; + private static readonly object _lockObject = new object(); + private static readonly int MaxRetryCount = 3; + private static readonly int RetryDelayMs = 2000; + private static readonly string UserDataDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChromeDriverUserData"); public static async Task SetupChromeDriverAsync(DownloadProgressForm progressForm = null) { + lock (_lockObject) + { + if (!string.IsNullOrEmpty(_driverPath) && File.Exists(_driverPath)) + { + // 이미 설정된 드라이버가 있고 정상 동작하면 재사용 + if (IsDriverReady()) + { + if (progressForm != null) + { + progressForm.UpdateProgress(100, "기존 드라이버 사용"); + progressForm.SetCompleted("기존 드라이버를 사용합니다."); + } + return _driverPath; + } + } + } + try { + // Chrome 설치 여부 확인 + if (!IsChromeInstalled()) + { + var errorMsg = "Chrome이 설치되어 있지 않습니다. Chrome을 설치한 후 다시 시도해주세요."; + Console.WriteLine(errorMsg); + if (progressForm != null) + { + progressForm.SetError(errorMsg); + } + throw new InvalidOperationException(errorMsg); + } + + // 사용자 데이터 디렉토리 생성 + EnsureUserDataDirectory(); + + // 사용자 디렉토리 생성 후 기존 Chrome/ChromeDriver 프로세스 정리 + CleanupChromeProcesses(); + // Chrome 버전 확인 var chromeVersion = GetChromeVersion(); Console.WriteLine($"설치된 Chrome 버전: {chromeVersion}"); @@ -34,7 +77,12 @@ namespace BokBonCheck { Console.WriteLine($"기존 드라이버 발견: {existingDriverPath}"); - // 기존 드라이버 테스트 + if (progressForm != null) + { + progressForm.UpdateProgress(20, "기존 드라이버 테스트 중..."); + } + + // 기존 드라이버 테스트 (한 번만) if (await TestExistingDriver(existingDriverPath)) { if (progressForm != null) @@ -43,14 +91,17 @@ namespace BokBonCheck progressForm.SetCompleted("기존 드라이버를 사용합니다."); } - _driverPath = existingDriverPath; - Environment.SetEnvironmentVariable("webdriver.chrome.driver", existingDriverPath); + lock (_lockObject) + { + _driverPath = existingDriverPath; + Environment.SetEnvironmentVariable("webdriver.chrome.driver", existingDriverPath); + } return existingDriverPath; } else { Console.WriteLine("기존 드라이버 테스트 실패 - 새로 다운로드"); - // 기존 드라이버가 작동하지 않으면 삭제 + // 기존 드라이버 삭제 try { File.Delete(existingDriverPath); @@ -63,43 +114,137 @@ namespace BokBonCheck } } + // 드라이버 다운로드 if (progressForm != null) { - progressForm.UpdateProgress(30, "Chrome 버전에 맞는 드라이버 다운로드 중..."); + progressForm.UpdateProgress(30, "Chrome 드라이버 다운로드 중..."); } - - // WebDriverManager를 사용하여 설치된 Chrome 버전에 맞는 드라이버 다운로드 - var driverManager = new DriverManager(); - var driverPath = driverManager.SetUpDriver(new ChromeConfig(), "MatchingBrowser"); - - // 다운로드된 드라이버 경로 저장 - _driverPath = driverPath; - - // 환경 변수 설정 - Environment.SetEnvironmentVariable("webdriver.chrome.driver", driverPath); + var driverPath = await DownloadChromeDriverWithRetryAsync(progressForm); + // 다운로드된 드라이버 테스트 (한 번만) if (progressForm != null) { - progressForm.UpdateProgress(100, "드라이버 다운로드 완료"); - progressForm.SetCompleted("드라이버 다운로드 완료!"); + progressForm.UpdateProgress(80, "다운로드된 드라이버 테스트 중..."); } - Console.WriteLine($"ChromeDriver 경로: {driverPath}"); - Console.WriteLine($"환경 변수 설정: webdriver.chrome.driver = {driverPath}"); - - return driverPath; + if (await TestExistingDriver(driverPath)) + { + lock (_lockObject) + { + _driverPath = driverPath; + Environment.SetEnvironmentVariable("webdriver.chrome.driver", driverPath); + } + + if (progressForm != null) + { + progressForm.UpdateProgress(100, "드라이버 설정 완료"); + progressForm.SetCompleted("드라이버 설정 완료!"); + } + + Console.WriteLine($"ChromeDriver 경로: {driverPath}"); + Console.WriteLine($"환경 변수 설정: webdriver.chrome.driver = {driverPath}"); + + return driverPath; + } + else + { + throw new InvalidOperationException("다운로드된 드라이버 테스트에 실패했습니다."); + } } catch (Exception ex) { - Console.WriteLine($"ChromeDriver 설정 오류: {ex.Message}"); + var errorMsg = $"ChromeDriver 설정 오류: {ex.Message}"; + Console.WriteLine(errorMsg); if (progressForm != null) { - progressForm.SetError($"설정 오류: {ex.Message}"); + progressForm.SetError(errorMsg); } throw; } } + private static void EnsureUserDataDirectory() + { + try + { + if (!Directory.Exists(UserDataDir)) + { + Directory.CreateDirectory(UserDataDir); + Console.WriteLine($"사용자 데이터 디렉토리 생성: {UserDataDir}"); + } + + // 임시 파일 디렉토리도 생성 + var tempDir = Path.Combine(UserDataDir, "temp"); + if (!Directory.Exists(tempDir)) + { + Directory.CreateDirectory(tempDir); + } + + // 로그 디렉토리 생성 + var logDir = Path.Combine(UserDataDir, "logs"); + if (!Directory.Exists(logDir)) + { + Directory.CreateDirectory(logDir); + } + } + catch (Exception ex) + { + Console.WriteLine($"사용자 데이터 디렉토리 생성 실패: {ex.Message}"); + } + } + + private static async Task DownloadChromeDriverWithRetryAsync(DownloadProgressForm progressForm) + { + Exception lastException = null; + + for (int attempt = 1; attempt <= MaxRetryCount; attempt++) + { + try + { + if (progressForm != null) + { + progressForm.UpdateProgress(30 + (attempt - 1) * 10, + $"Chrome 드라이버 다운로드 중... (시도 {attempt}/{MaxRetryCount})"); + } + + Console.WriteLine($"드라이버 다운로드 시도 {attempt}/{MaxRetryCount}"); + + // WebDriverManager를 사용하여 설치된 Chrome 버전에 맞는 드라이버 다운로드 + var driverManager = new DriverManager(); + var driverPath = driverManager.SetUpDriver(new ChromeConfig(), "MatchingBrowser"); + + if (!string.IsNullOrEmpty(driverPath) && File.Exists(driverPath)) + { + Console.WriteLine($"드라이버 다운로드 성공: {driverPath}"); + return driverPath; + } + else + { + throw new InvalidOperationException("드라이버 파일을 찾을 수 없습니다."); + } + } + catch (Exception ex) + { + lastException = ex; + Console.WriteLine($"드라이버 다운로드 시도 {attempt} 실패: {ex.Message}"); + + if (attempt < MaxRetryCount) + { + if (progressForm != null) + { + progressForm.UpdateProgress(30 + attempt * 10, + $"다운로드 실패. 재시도 중... ({attempt + 1}/{MaxRetryCount})"); + } + + // 재시도 전 잠시 대기 + await Task.Delay(RetryDelayMs); + } + } + } + + throw new InvalidOperationException($"드라이버 다운로드를 {MaxRetryCount}번 시도했지만 실패했습니다. 마지막 오류: {lastException?.Message}"); + } + private static string GetExistingDriverPath() { try @@ -111,25 +256,45 @@ namespace BokBonCheck return envPath; } + // 사용자 디렉토리에서 확인 (관리자 권한 없이도 접근 가능) + var userDriverPath = Path.Combine(UserDataDir, "chromedriver.exe"); + if (File.Exists(userDriverPath)) + { + return userDriverPath; + } + // WebDriverManager 캐시 폴더에서 확인 var cachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".cache", "selenium"); if (Directory.Exists(cachePath)) { - var chromeDriverFiles = Directory.GetFiles(cachePath, "chromedriver*", SearchOption.AllDirectories); - foreach (var file in chromeDriverFiles) + var chromeDriverFiles = Directory.GetFiles(cachePath, "chromedriver*", SearchOption.AllDirectories) + .Where(f => f.EndsWith(".exe") || !Path.HasExtension(f)) + .OrderByDescending(f => File.GetLastWriteTime(f)) + .ToArray(); + + if (chromeDriverFiles.Length > 0) { - if (file.EndsWith(".exe") || !Path.HasExtension(file)) - { - return file; - } + return chromeDriverFiles[0]; // 가장 최근 파일 반환 + } + } + + // 현재 실행 파일과 같은 디렉토리에서 확인 + var currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + if (!string.IsNullOrEmpty(currentDir)) + { + var localDriverPath = Path.Combine(currentDir, "chromedriver.exe"); + if (File.Exists(localDriverPath)) + { + return localDriverPath; } } return null; } - catch + catch (Exception ex) { + Console.WriteLine($"기존 드라이버 경로 확인 실패: {ex.Message}"); return null; } } @@ -149,6 +314,10 @@ namespace BokBonCheck @"C:\Program Files\Google\Chrome\Application\chrome.exe", @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + @"Google\Chrome\Application\chrome.exe"), + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + @"Google\Chrome\Application\chrome.exe"), + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Google\Chrome\Application\chrome.exe") }; @@ -163,6 +332,27 @@ namespace BokBonCheck } } + // 레지스트리에서 확인 (추가 방법) + try + { + using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Google\Chrome\BLBeacon")) + { + if (key != null) + { + var version = key.GetValue("version") as string; + if (!string.IsNullOrEmpty(version)) + { + Console.WriteLine($"레지스트리에서 Chrome 버전 감지: {version}"); + return version; + } + } + } + } + catch (Exception ex) + { + Console.WriteLine($"레지스트리 확인 실패: {ex.Message}"); + } + return "알 수 없음"; } catch (Exception ex) @@ -181,6 +371,10 @@ namespace BokBonCheck @"C:\Program Files\Google\Chrome\Application\chrome.exe", @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + @"Google\Chrome\Application\chrome.exe"), + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), + @"Google\Chrome\Application\chrome.exe"), + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Google\Chrome\Application\chrome.exe") }; @@ -192,10 +386,27 @@ namespace BokBonCheck } } + // 레지스트리에서도 확인 + try + { + using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Google\Chrome\BLBeacon")) + { + if (key != null) + { + return true; + } + } + } + catch + { + // 레지스트리 접근 실패는 무시 + } + return false; } - catch + catch (Exception ex) { + Console.WriteLine($"Chrome 설치 확인 실패: {ex.Message}"); return false; } } @@ -211,32 +422,7 @@ namespace BokBonCheck progressForm.UpdateProgress(50, "드라이버 테스트 중..."); } - // ChromeDriver 서비스 설정 - var service = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath)); - service.HideCommandPromptWindow = true; - // 간단한 테스트 실행 - var options = new OpenQA.Selenium.Chrome.ChromeOptions(); - options.AddArgument("--headless"); - options.AddArgument("--no-sandbox"); - options.AddArgument("--disable-dev-shm-usage"); - options.AddArgument("--disable-gpu"); - options.AddArgument("--remote-debugging-port=0"); - - using (var driver = new OpenQA.Selenium.Chrome.ChromeDriver(service, options)) - { - driver.Navigate().GoToUrl("https://www.google.com"); - var title = driver.Title; - - Console.WriteLine($"드라이버 테스트 성공: {title}"); - - if (progressForm != null) - { - progressForm.UpdateProgress(100, "드라이버 테스트 성공!"); - progressForm.SetCompleted("드라이버 테스트 성공!"); - } - - return !string.IsNullOrEmpty(title); - } + return await TestExistingDriver(driverPath); } catch (Exception ex) { @@ -255,6 +441,20 @@ namespace BokBonCheck { Console.WriteLine("Chrome 드라이버 캐시 정리 시작..."); + // 사용자 데이터 디렉토리 정리 + if (Directory.Exists(UserDataDir)) + { + try + { + Directory.Delete(UserDataDir, true); + Console.WriteLine($"사용자 데이터 디렉토리 정리됨: {UserDataDir}"); + } + catch (Exception ex) + { + Console.WriteLine($"사용자 데이터 디렉토리 정리 실패: {ex.Message}"); + } + } + // WebDriverManager 캐시 폴더 정리 var cachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".cache", "selenium"); @@ -280,20 +480,23 @@ namespace BokBonCheck } // 저장된 드라이버 경로도 정리 - if (!string.IsNullOrEmpty(_driverPath) && File.Exists(_driverPath)) + lock (_lockObject) { - try + if (!string.IsNullOrEmpty(_driverPath) && File.Exists(_driverPath)) { - File.Delete(_driverPath); - Console.WriteLine($"저장된 드라이버 삭제됨: {_driverPath}"); - } - catch (Exception ex) - { - Console.WriteLine($"저장된 드라이버 삭제 실패: {ex.Message}"); + try + { + File.Delete(_driverPath); + Console.WriteLine($"저장된 드라이버 삭제됨: {_driverPath}"); + } + catch (Exception ex) + { + Console.WriteLine($"저장된 드라이버 삭제 실패: {ex.Message}"); + } } + _driverPath = null; } - _driverPath = null; Environment.SetEnvironmentVariable("webdriver.chrome.driver", null); Console.WriteLine("Chrome 드라이버 캐시 정리 완료"); @@ -316,24 +519,24 @@ namespace BokBonCheck } Console.WriteLine($"드라이버 준비 상태 확인: {driverPath}"); - - // 간단한 테스트 실행 - var service = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath)); - service.HideCommandPromptWindow = true; - var options = new OpenQA.Selenium.Chrome.ChromeOptions(); - options.AddArgument("--headless"); - options.AddArgument("--no-sandbox"); - options.AddArgument("--disable-dev-shm-usage"); - options.AddArgument("--disable-gpu"); - options.AddArgument("--remote-debugging-port=0"); - - using (var driver = new OpenQA.Selenium.Chrome.ChromeDriver(service, options)) + + // 파일 크기와 수정 날짜로 기본 검증 + var fileInfo = new FileInfo(driverPath); + if (fileInfo.Length < 1000) // 1KB 미만이면 의심스러움 { - driver.Navigate().GoToUrl("https://www.google.com"); - var result = !string.IsNullOrEmpty(driver.Title); - Console.WriteLine($"드라이버 준비 상태: {(result ? "준비됨" : "실패")}"); - return result; + Console.WriteLine("드라이버 파일이 너무 작습니다."); + return false; } + + // 최근 30일 내 파일인지 확인 + if (fileInfo.LastWriteTime < DateTime.Now.AddDays(-30)) + { + Console.WriteLine("드라이버 파일이 너무 오래되었습니다."); + return false; + } + + Console.WriteLine("드라이버 준비 상태: 준비됨"); + return true; } catch (Exception ex) { @@ -342,26 +545,121 @@ namespace BokBonCheck } } + /// + /// 기본 Chrome 옵션을 생성하는 헬퍼 메서드 + /// + public static ChromeOptions CreateBaseChromeOptions(bool hideBrowser = true,int width = 800,int height = 600) + { + var options = new ChromeOptions(); + + if (hideBrowser) + { + options.AddArgument("--headless"); + } + + if(width > 0 && height > 0) + { + options.AddArgument($"--window-size={width},{height}"); + } + + // 기본 안정성 옵션 + options.AddArgument("--no-sandbox"); + options.AddArgument("--remote-debugging-port=0"); + options.AddArgument("--disable-extensions"); + options.AddArgument("--disable-plugins"); + options.AddArgument("--disable-images"); + options.AddArgument("--disable-javascript"); + options.AddArgument("--disable-java"); + options.AddArgument("--disable-flash"); + options.AddArgument("--disable-web-security"); + options.AddArgument("--allow-running-insecure-content"); + + // 메모리 및 성능 최적화 + options.AddArgument("--memory-pressure-off"); + options.AddArgument("--max_old_space_size=4096"); + options.AddArgument("--disable-background-timer-throttling"); + options.AddArgument("--disable-backgrounding-occluded-windows"); + options.AddArgument("--disable-renderer-backgrounding"); + options.AddArgument("--disable-features=TranslateUI"); + options.AddArgument("--disable-ipc-flooding-protection"); + options.AddArgument("--disable-default-apps"); + options.AddArgument("--disable-sync"); + options.AddArgument("--disable-translate"); + options.AddArgument("--disable-logging"); + options.AddArgument("--disable-notifications"); + options.AddArgument("--disable-popup-blocking"); + options.AddArgument("--disable-prompt-on-repost"); + options.AddArgument("--disable-hang-monitor"); + options.AddArgument("--disable-client-side-phishing-detection"); + options.AddArgument("--disable-component-update"); + options.AddArgument("--disable-domain-reliability"); + + // 프로세스 관련 안정성 옵션 + options.AddArgument("--single-process"); + options.AddArgument("--no-zygote"); + options.AddArgument("--disable-background-networking"); + + // 캐시 및 저장소 비활성화 + options.AddArgument("--disable-application-cache"); + options.AddArgument("--disable-offline-load-stale-cache"); + options.AddArgument("--disk-cache-size=0"); + options.AddArgument("--media-cache-size=0"); + options.AddArgument("--aggressive-cache-discard"); + options.AddArgument("--enable-aggressive-domstorage-flushing"); + + // 기타 안정성 옵션 + options.AddArgument("--enable-low-end-device-mode"); + options.AddArgument("--force-fieldtrials=*BackgroundTracing/default/"); + + // 사용자 데이터 디렉토리 설정 (관리자 권한 없이도 접근 가능) + options.AddArgument($"--user-data-dir={UserDataDir}"); + options.AddArgument("--no-first-run"); + options.AddArgument("--no-default-browser-check"); + + return options; + } + + + /// + /// 검색 최적화된 Chrome 옵션을 반환합니다 + /// + public static ChromeOptions GetSearchOptimizedOptions() + { + var options = CreateBaseChromeOptions(true); + + // 검색에 필요한 기능만 활성화 + options.AddArgument("--enable-javascript"); + options.AddArgument("--enable-images"); + + return options; + } + private static async Task TestExistingDriver(string driverPath) { try { - Console.WriteLine($"기존 드라이버 테스트: {driverPath}"); + Console.WriteLine($"드라이버 테스트: {driverPath}"); // ChromeDriver 서비스 설정 var service = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath)); service.HideCommandPromptWindow = true; - // 간단한 테스트 실행 - var options = new OpenQA.Selenium.Chrome.ChromeOptions(); - options.AddArgument("--headless"); - options.AddArgument("--no-sandbox"); - options.AddArgument("--disable-dev-shm-usage"); - options.AddArgument("--disable-gpu"); - options.AddArgument("--remote-debugging-port=0"); + // 기본 Chrome 옵션 사용하고 테스트용 추가 옵션 설정 + var options = CreateBaseChromeOptions(true); + + // 테스트용 추가 옵션들 + options.AddArgument("--log-level=3"); // 오류만 표시 + options.AddArgument("--silent"); + options.AddArgument("--window-size=1920,1080"); + options.AddArgument("--start-maximized"); + options.AddArgument("--disable-blink-features=AutomationControlled"); + options.AddArgument("--enable-aggressive-domstorage-flushing"); using (var driver = new OpenQA.Selenium.Chrome.ChromeDriver(service, options)) { + driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(15); + driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); + driver.Navigate().GoToUrl("https://www.google.com"); var title = driver.Title; Console.WriteLine($"드라이버 테스트 성공: {title}"); @@ -370,9 +668,114 @@ namespace BokBonCheck } catch (Exception ex) { - Console.WriteLine($"기존 드라이버 테스트 실패: {ex.Message}"); + Console.WriteLine($"드라이버 테스트 실패: {ex.Message}"); + + // DevToolsActivePort 및 Chrome 크래시 관련 특별 처리 + if (ex.Message.Contains("DevToolsActivePort file doesn't exist") || + ex.Message.Contains("was killed") || + ex.Message.Contains("Chrome has crashed")) + { + Console.WriteLine("DevToolsActivePort 또는 Chrome 크래시 감지됨. 사용자 데이터 디렉토리 정리 시도..."); + try + { + // 사용자 데이터 디렉토리 정리 + if (Directory.Exists(UserDataDir)) + { + Directory.Delete(UserDataDir, true); + Console.WriteLine("사용자 데이터 디렉토리 정리 완료"); + } + + // Chrome 프로세스 정리 시도 + CleanupChromeProcesses(); + + // 잠시 대기 + await Task.Delay(1000); + } + catch (Exception cleanupEx) + { + Console.WriteLine($"사용자 데이터 디렉토리 정리 실패: {cleanupEx.Message}"); + } + } + return false; } } + + // Chrome 프로세스 정리 메서드 추가 + private static void CleanupChromeProcesses() + { + try + { + Console.WriteLine("Chrome 프로세스 정리 시작..."); + + // Chrome 관련 프로세스들 찾기 + var chromeProcesses = System.Diagnostics.Process.GetProcessesByName("chrome"); + var chromedriverProcesses = System.Diagnostics.Process.GetProcessesByName("chromedriver"); + + // Chrome 프로세스 정리 + bool KILLPROC = false; + foreach (var process in chromeProcesses) + { + try + { + if (!process.HasExited) + { + KILLPROC = true; + process.Kill(); + Console.WriteLine($"Chrome 프로세스 종료: PID {process.Id}"); + } + } + catch (Exception ex) + { + Console.WriteLine($"Chrome 프로세스 종료 실패 (PID {process.Id}): {ex.Message}"); + } + } + + // ChromeDriver 프로세스 정리 + foreach (var process in chromedriverProcesses) + { + try + { + if (!process.HasExited) + { + KILLPROC = true; + process.Kill(); + Console.WriteLine($"ChromeDriver 프로세스 종료: PID {process.Id}"); + } + } + catch (Exception ex) + { + Console.WriteLine($"ChromeDriver 프로세스 종료 실패 (PID {process.Id}): {ex.Message}"); + } + } + + // 잠시 대기하여 프로세스 완전 종료 확인 + if(KILLPROC) + System.Threading.Thread.Sleep(2000); + + Console.WriteLine("Chrome 프로세스 정리 완료"); + } + catch (Exception ex) + { + Console.WriteLine($"Chrome 프로세스 정리 실패: {ex.Message}"); + } + } + + public static void Dispose() + { + try + { + lock (_lockObject) + { + _driverPath = null; + } + Environment.SetEnvironmentVariable("webdriver.chrome.driver", null); + Console.WriteLine("ChromeDriverManager 리소스 해제 완료"); + } + catch (Exception ex) + { + Console.WriteLine($"ChromeDriverManager 리소스 해제 실패: {ex.Message}"); + } + } } } \ No newline at end of file diff --git a/unimarc/unimarc/SearchModel/ILibrarySearcher.cs b/unimarc/unimarc/SearchModel/ILibrarySearcher.cs index 5511a8c..cecec1f 100644 --- a/unimarc/unimarc/SearchModel/ILibrarySearcher.cs +++ b/unimarc/unimarc/SearchModel/ILibrarySearcher.cs @@ -1,15 +1,21 @@ +using OpenQA.Selenium.Chrome; +using OpenQA.Selenium; using OpenQA.Selenium.Support.UI; +using System.IO; +using System; using System.Threading.Tasks; +using Org.BouncyCastle.Bcpg; namespace BokBonCheck { + public interface ILibrarySearcher { - int No { get; set; } + int No { get; set; } string SiteName { get; } string SiteUrl { get; } Task SearchAsync(string searchTerm); - void StartDriver(); + void StartDriver(bool showBrowser); void StopDriver(); Task WaitForPageChange(WebDriverWait wait); diff --git a/unimarc/unimarc/SearchModel/KwangjuCityLibrarySearcher.cs b/unimarc/unimarc/SearchModel/KwangjuCityLibrarySearcher.cs index ab641e1..a98a021 100644 --- a/unimarc/unimarc/SearchModel/KwangjuCityLibrarySearcher.cs +++ b/unimarc/unimarc/SearchModel/KwangjuCityLibrarySearcher.cs @@ -61,7 +61,7 @@ namespace BokBonCheck } public abstract class KwangjuCityLibrarySearcher : ILibrarySearcher { - public int No { get; set; } + public int No { get; set; } public string SiteName { get; protected set; } = "광주시교육청통합도서관"; public string SiteUrl => "https://lib.gen.go.kr/main/site/search/bookSearch.do#simple"; @@ -81,28 +81,55 @@ namespace BokBonCheck this.No = no; } - public void StartDriver() + public void StartDriver(bool showBrowser) + { + try + { + // 동기적으로 실행 (권장하지 않음) + StartDriverAsync( showBrowser).GetAwaiter().GetResult(); + } + catch (Exception ex) + { + Console.WriteLine($"StartDriver 실패: {ex.Message}"); + throw; + } + } + + public async Task StartDriverAsync( bool showdriver = false) { if (_driver == null) { - var driverPath = ChromeDriverManager.GetDriverPath(); - if (string.IsNullOrEmpty(driverPath) || !File.Exists(driverPath)) + try { - driverPath = ChromeDriverManager.SetupChromeDriverAsync().GetAwaiter().GetResult(); + // ChromeDriverManager를 사용하여 안정적으로 드라이버 설정 + var driverPath = await ChromeDriverManager.SetupChromeDriverAsync(); + + // ChromeDriver 서비스 생성 + _service = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath), Path.GetFileName(driverPath)); + _service.HideCommandPromptWindow = true; + + // 안정적인 Chrome 옵션 가져오기 (브라우저 창 숨김) + var options = ChromeDriverManager.CreateBaseChromeOptions(!showdriver); + + // 추가 보안 및 안정성 옵션 + options.AddArgument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"); + options.AddArgument("--disable-blink-features=AutomationControlled"); + options.AddExcludedArgument("enable-automation"); + options.AddAdditionalOption("useAutomationExtension", false); + + // ChromeDriver 생성 + _driver = new ChromeDriver(_service, options); + + // 웹드라이버 감지 방지 + ((IJavaScriptExecutor)_driver).ExecuteScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"); + + Console.WriteLine("NamguLibrarySearcher ChromeDriver 초기화 완료"); + } + catch (Exception ex) + { + Console.WriteLine($"ChromeDriver 초기화 실패: {ex.Message}"); + throw new InvalidOperationException($"ChromeDriver 초기화에 실패했습니다: {ex.Message}", ex); } - _service = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath), Path.GetFileName(driverPath)); - _service.HideCommandPromptWindow = true; - var options = new ChromeOptions(); - options.AddArgument("--no-sandbox"); - options.AddArgument("--disable-dev-shm-usage"); - options.AddArgument("--disable-gpu"); - options.AddArgument("--window-size=640,700"); - options.AddArgument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"); - options.AddArgument("--disable-blink-features=AutomationControlled"); - options.AddExcludedArgument("enable-automation"); - options.AddAdditionalOption("useAutomationExtension", false); - _driver = new ChromeDriver(_service, options); - ((IJavaScriptExecutor)_driver).ExecuteScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"); } } @@ -150,7 +177,7 @@ namespace BokBonCheck try { if (_driver == null) - throw new InvalidOperationException("드라이버가 시작되지 않았습니다. StartDriver()를 먼저 호출하세요."); + throw new InvalidOperationException("드라이버가 시작되지 않았습니다. StartDriver()를 먼저 호출하세요."); _driver.Navigate().GoToUrl(SiteUrl); diff --git a/unimarc/unimarc/SearchModel/NamguLibrarySearcher.cs b/unimarc/unimarc/SearchModel/NamguLibrarySearcher.cs index 045cc2c..8ebc5a4 100644 --- a/unimarc/unimarc/SearchModel/NamguLibrarySearcher.cs +++ b/unimarc/unimarc/SearchModel/NamguLibrarySearcher.cs @@ -9,6 +9,7 @@ using WebDriverManager.DriverConfigs.Impl; using System.IO; using System.Runtime.InteropServices; using System.Threading; +using UniMarc.마크; namespace BokBonCheck { @@ -116,7 +117,7 @@ namespace BokBonCheck } return true; } - catch(Exception ex) + catch (Exception ex) { Console.WriteLine(ex.Message); return false; @@ -130,7 +131,7 @@ namespace BokBonCheck SiteName = "남구통합도서관(효천어울림도서관)"; } - + protected override bool SelectLibrary(WebDriverWait wait) { IWebElement searchBox = null; @@ -176,11 +177,11 @@ namespace BokBonCheck var selector = "#clickAll"; searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector))); if (searchBox == null) return false; - if ( searchBox.Selected == true) + if (searchBox.Selected == true) { SafeClick(searchBox); } - + selector = "#libSQ"; searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector))); @@ -203,7 +204,7 @@ namespace BokBonCheck public string SiteName { get; protected set; } = "남구통합도서관(전체)"; public string SiteUrl => "https://lib.namgu.gwangju.kr/main/bookSearch"; - public int No { get; set; } + public int No { get; set; } private ChromeDriver _driver; private ChromeDriverService _service; @@ -219,28 +220,56 @@ namespace BokBonCheck this.No = no; } - public void StartDriver() + //public async Task StartDriverAsync(bool showdriver=false) + //{ + // if (_driver == null) + // { + // try + // { + // // ChromeDriverManager를 사용하여 안정적으로 드라이버 설정 + // var driverPath = await ChromeDriverManager.SetupChromeDriverAsync(); + + // // ChromeDriver 서비스 생성 + // _service = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath), Path.GetFileName(driverPath)); + // _service.HideCommandPromptWindow = true; + + // // 안정적인 Chrome 옵션 가져오기 (브라우저 창 숨김) + // var options = ChromeDriverManager.CreateBaseChromeOptions(!showdriver); + + // // 추가 보안 및 안정성 옵션 + // options.AddArgument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"); + // options.AddArgument("--disable-blink-features=AutomationControlled"); + // options.AddExcludedArgument("enable-automation"); + // options.AddAdditionalOption("useAutomationExtension", false); + + // // ChromeDriver 생성 + // _driver = new ChromeDriver(_service, options); + + // // 웹드라이버 감지 방지 + // ((IJavaScriptExecutor)_driver).ExecuteScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"); + + // Console.WriteLine("NamguLibrarySearcher ChromeDriver 초기화 완료"); + // } + // catch (Exception ex) + // { + // Console.WriteLine($"ChromeDriver 초기화 실패: {ex.Message}"); + // throw new InvalidOperationException($"ChromeDriver 초기화에 실패했습니다: {ex.Message}", ex); + // } + // } + //} + + // 기존 StartDriver 메서드를 유지하여 호환성 보장 + public void StartDriver(bool showBrowser) { - if (_driver == null) + try { - var driverPath = ChromeDriverManager.GetDriverPath(); - if (string.IsNullOrEmpty(driverPath) || !File.Exists(driverPath)) - { - driverPath = ChromeDriverManager.SetupChromeDriverAsync().GetAwaiter().GetResult(); - } - _service = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath), Path.GetFileName(driverPath)); - _service.HideCommandPromptWindow = true; - var options = new ChromeOptions(); - options.AddArgument("--no-sandbox"); - options.AddArgument("--disable-dev-shm-usage"); - options.AddArgument("--disable-gpu"); - options.AddArgument("--window-size=640,700"); - options.AddArgument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"); - options.AddArgument("--disable-blink-features=AutomationControlled"); - options.AddExcludedArgument("enable-automation"); - options.AddAdditionalOption("useAutomationExtension", false); - _driver = new ChromeDriver(_service, options); - ((IJavaScriptExecutor)_driver).ExecuteScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"); + // 동기적으로 실행 (권장하지 않음) + StartDriverAsync(showBrowser).GetAwaiter().GetResult(); + } + catch (Exception ex) + { + Console.WriteLine($"StartDriver 실패: {ex.Message}"); + throw; } } @@ -259,6 +288,45 @@ namespace BokBonCheck } } + public async Task StartDriverAsync(bool showdriver = false) + { + if (_driver == null) + { + try + { + // ChromeDriverManager를 사용하여 안정적으로 드라이버 설정 + var driverPath = await ChromeDriverManager.SetupChromeDriverAsync(); + + // ChromeDriver 서비스 생성 + _service = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath), Path.GetFileName(driverPath)); + _service.HideCommandPromptWindow = true; + + // 안정적인 Chrome 옵션 가져오기 (브라우저 창 숨김) + var options = ChromeDriverManager.CreateBaseChromeOptions(!showdriver); + + // 추가 보안 및 안정성 옵션 + options.AddArgument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"); + options.AddArgument("--disable-blink-features=AutomationControlled"); + options.AddExcludedArgument("enable-automation"); + options.AddAdditionalOption("useAutomationExtension", false); + + // ChromeDriver 생성 + _driver = new ChromeDriver(_service, options); + + // 웹드라이버 감지 방지 + ((IJavaScriptExecutor)_driver).ExecuteScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"); + + Console.WriteLine("NamguLibrarySearcher ChromeDriver 초기화 완료"); + } + catch (Exception ex) + { + Console.WriteLine($"ChromeDriver 초기화 실패: {ex.Message}"); + throw new InvalidOperationException($"ChromeDriver 초기화에 실패했습니다: {ex.Message}", ex); + } + } + } + + virtual protected bool SelectLibrary(WebDriverWait wait) { @@ -330,8 +398,11 @@ namespace BokBonCheck try { + // 드라이버가 없으면 자동으로 시작 if (_driver == null) - throw new InvalidOperationException("드라이버가 시작되지 않았습니다. StartDriver()를 먼저 호출하세요."); + { + await StartDriverAsync(); + } _driver.Navigate().GoToUrl(SiteUrl); @@ -347,7 +418,7 @@ namespace BokBonCheck //} //대상도서관 선택 - if(SelectLibrary(wait)==false) + if (SelectLibrary(wait) == false) { result.ErrorMessage = "도서관선택실패"; result.BookCount = -1; @@ -496,7 +567,7 @@ namespace BokBonCheck var match = System.Text.RegularExpressions.Regex.Match(text, @"전체\s*(\d+)"); if (match.Success) { - if(int.TryParse(match.Groups[1].Value,out int vqty)==false) + if (int.TryParse(match.Groups[1].Value, out int vqty) == false) { errmessage = $"수량값오류({match.Groups[1].Value})"; return -1; @@ -521,7 +592,7 @@ namespace BokBonCheck } } - + // 페이지 변경을 감지하는 메서드 public async Task WaitForPageChange(WebDriverWait wait) @@ -540,9 +611,22 @@ namespace BokBonCheck // 방법 5: 특정 텍스트가 페이지에 나타날 때까지 대기 wait.Until(d => { - var pageText = d.FindElement(By.ClassName("search-result")).Text; - if (pageText.Contains("검색결과가 없습니다")) return true; - return pageText.Contains("에 대하여") && pageText.Contains("검색되었습니다"); + try + { + var byclassname = By.ClassName("search-result"); + var elm = d.FindElement(byclassname); + if (elm == null) + { + return false; + } + var pageText = elm.Text; + if (pageText.Contains("검색결과가 없습니다")) return true; + return pageText.Contains("에 대하여") && pageText.Contains("검색되었습니다"); + } + catch + { + return false; + } }); } diff --git a/unimarc/unimarc/Skill.cs b/unimarc/unimarc/Skill.cs index 3169d21..ef9f92d 100644 --- a/unimarc/unimarc/Skill.cs +++ b/unimarc/unimarc/Skill.cs @@ -2961,17 +2961,22 @@ namespace WindowsFormsApp1 } public string VersionInfo() { - string version = ""; - StreamReader sr = new StreamReader(Application.StartupPath + "\\update.inf"); - while (!sr.EndOfStream) + string version = "0"; + var fn = Application.StartupPath + "\\update.inf"; + if(System.IO.File.Exists(fn)) { - string line = sr.ReadLine(); - if (line.IndexOf("count=", 0) != -1) + StreamReader sr = new StreamReader(fn); + while (!sr.EndOfStream) { - version = line.Replace("count=", ""); - break; + string line = sr.ReadLine(); + if (line.IndexOf("count=", 0) != -1) + { + version = line.Replace("count=", ""); + break; + } } } + return version; } } diff --git a/unimarc/unimarc/UniMarc.csproj b/unimarc/unimarc/UniMarc.csproj index bc3ec37..c596e3f 100644 --- a/unimarc/unimarc/UniMarc.csproj +++ b/unimarc/unimarc/UniMarc.csproj @@ -78,8 +78,8 @@ UniMarc.ico - - ..\packages\AngleSharp.1.0.4\lib\net472\AngleSharp.dll + + ..\packages\AngleSharp.1.3.0\lib\net472\AngleSharp.dll ..\dll\arCommUtil.dll @@ -90,14 +90,23 @@ ..\dll\ArLog.Net4.dll + + ..\packages\BouncyCastle.Cryptography.2.5.1\lib\net461\BouncyCastle.Cryptography.dll + ..\dll\CarlosAg.ExcelXmlWriter.dll ..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll - - ..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.8.0.3\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll @@ -105,10 +114,10 @@ - ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - ..\packages\SSH.NET.2020.0.1\lib\net40\Renci.SshNet.dll + + ..\packages\SSH.NET.2025.0.0\lib\net462\Renci.SshNet.dll @@ -116,6 +125,9 @@ + + ..\packages\System.Formats.Asn1.8.0.2\lib\net462\System.Formats.Asn1.dll + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll @@ -134,14 +146,14 @@ ..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll - - ..\packages\System.Text.Encoding.CodePages.6.0.0\lib\net461\System.Text.Encoding.CodePages.dll + + ..\packages\System.Text.Encoding.CodePages.8.0.0\lib\net462\System.Text.Encoding.CodePages.dll - - ..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll + + ..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll - - ..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll + + ..\packages\System.Text.Json.8.0.5\lib\net462\System.Text.Json.dll ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll @@ -161,13 +173,13 @@ - ..\packages\Selenium.WebDriver.4.16.2\lib\netstandard2.0\WebDriver.dll + ..\packages\Selenium.WebDriver.4.34.0\lib\netstandard2.0\WebDriver.dll - ..\packages\Selenium.Support.4.16.2\lib\netstandard2.0\WebDriver.Support.dll + ..\packages\Selenium.Support.4.34.0\lib\netstandard2.0\WebDriver.Support.dll - - ..\packages\WebDriverManager.2.17.1\lib\net462\WebDriverManager.dll + + ..\packages\WebDriverManager.2.17.6\lib\net472\WebDriverManager.dll @@ -182,7 +194,7 @@ True Reference.svcmap - + @@ -1944,11 +1956,11 @@ - + 이 프로젝트는 이 컴퓨터에 없는 NuGet 패키지를 참조합니다. 해당 패키지를 다운로드하려면 NuGet 패키지 복원을 사용하십시오. 자세한 내용은 http://go.microsoft.com/fwlink/?LinkID=322105를 참조하십시오. 누락된 파일은 {0}입니다. - + \ No newline at end of file diff --git a/unimarc/unimarc/packages.config b/unimarc/unimarc/packages.config index e7a4292..57c21b1 100644 --- a/unimarc/unimarc/packages.config +++ b/unimarc/unimarc/packages.config @@ -1,23 +1,27 @@  - - + + + + + - - - + + + - + + - - - + + + - + \ No newline at end of file diff --git a/unimarc/unimarc/마스터/From_User_manage_List.cs b/unimarc/unimarc/마스터/From_User_manage_List.cs index 78a2643..e0c8f8a 100644 --- a/unimarc/unimarc/마스터/From_User_manage_List.cs +++ b/unimarc/unimarc/마스터/From_User_manage_List.cs @@ -1,4 +1,5 @@ -using ExcelTest; +using AR; +using ExcelTest; using System; using System.Collections.Generic; using System.ComponentModel; @@ -91,7 +92,7 @@ namespace UniMarc return; } string tText = string.Format("{0} 를 수정 하시겠습니까?", dgvList.SelectedRows[0].Cells["comp_name"].Value.ToString()); - if (CUtill.MsgQ(tText) == DialogResult.Yes) + if (UTIL.MsgQ(tText) == DialogResult.Yes) { CheckText(); string[] tEdit_tbl = { @@ -121,7 +122,7 @@ namespace UniMarc return; } string tText = string.Format("{0} 를 삭제 하시겠습니까?", dgvList.SelectedRows[0].Cells["comp_name"].Value.ToString()); - if (CUtill.MsgQ(tText) == DialogResult.Yes) + if (UTIL.MsgQ(tText) == DialogResult.Yes) { string tD_cmd = mDb.DB_Delete("Comp", "idx", dgvList.SelectedRows[0].Cells["dbIDX"].Value.ToString(), "comp_name", dgvList.SelectedRows[0].Cells["comp_name"].Value.ToString()); mDb.DB_Send_CMD_reVoid(tD_cmd); diff --git a/unimarc/unimarc/마크/AddMarc.cs b/unimarc/unimarc/마크/AddMarc.cs index e49987f..6bffb25 100644 --- a/unimarc/unimarc/마크/AddMarc.cs +++ b/unimarc/unimarc/마크/AddMarc.cs @@ -335,7 +335,7 @@ namespace UniMarc.마크 // break; //} string UpCMD = db.More_Update(Table, EditTable, EditColumn, SearchTable, SearchColumn); - CUtill.mLog.Add("ADDMarcUPDATE", string.Format("{0}({1}) : {2}", mUserName, mCompidx, UpCMD.Replace("\r", " ").Replace("\n", " "))); + PUB.log.Add("ADDMarcUPDATE", string.Format("{0}({1}) : {2}", mUserName, mCompidx, UpCMD.Replace("\r", " ").Replace("\n", " "))); db.DB_Send_CMD_reVoid(UpCMD); } #region UpdateSub @@ -386,7 +386,7 @@ namespace UniMarc.마크 }; string InCMD = db.DB_INSERT(Table, InsertTable, InsertColumn); - CUtill.mLog.Add("ADDMarcINSERT", string.Format("{0}({1}) : {2}", mUserName, mCompidx, InCMD.Replace("\r", " ").Replace("\n", " "))); + PUB.log.Add("ADDMarcINSERT", string.Format("{0}({1}) : {2}", mUserName, mCompidx, InCMD.Replace("\r", " ").Replace("\n", " "))); db.DB_Send_CMD_reVoid(InCMD); } diff --git a/unimarc/unimarc/마크/Check_copyWD.Designer.cs b/unimarc/unimarc/마크/Check_copyWD.Designer.cs index 08bbe28..1d4dcdc 100644 --- a/unimarc/unimarc/마크/Check_copyWD.Designer.cs +++ b/unimarc/unimarc/마크/Check_copyWD.Designer.cs @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.chkRetryErrData = new System.Windows.Forms.CheckBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); @@ -66,8 +66,7 @@ this.btn_GridReset = new System.Windows.Forms.Button(); this.btn_OpenMemo = new System.Windows.Forms.Button(); this.chk_spChar = new System.Windows.Forms.CheckBox(); - this.panel5 = new System.Windows.Forms.Panel(); - this.webBrowser1 = new System.Windows.Forms.WebBrowser(); + this.chkShowBrowser = new System.Windows.Forms.CheckBox(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.SearchCount)).BeginInit(); @@ -77,12 +76,12 @@ this.panel6.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.panel4.SuspendLayout(); - this.panel5.SuspendLayout(); this.SuspendLayout(); // // panel1 // this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.Controls.Add(this.chkShowBrowser); this.panel1.Controls.Add(this.chkRetryErrData); this.panel1.Controls.Add(this.groupBox1); this.panel1.Controls.Add(this.rb_isNumber); @@ -93,7 +92,7 @@ this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 34); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(629, 106); + this.panel1.Size = new System.Drawing.Size(637, 106); this.panel1.TabIndex = 0; // // chkRetryErrData @@ -281,7 +280,7 @@ this.panel2.Dock = System.Windows.Forms.DockStyle.Top; this.panel2.Location = new System.Drawing.Point(0, 0); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(629, 34); + this.panel2.Size = new System.Drawing.Size(637, 34); this.panel2.TabIndex = 0; // // btn_SiteDenote @@ -318,14 +317,14 @@ this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control; this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle1.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.book_name, @@ -336,7 +335,7 @@ this.dataGridView1.Location = new System.Drawing.Point(0, 0); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowTemplate.Height = 23; - this.dataGridView1.Size = new System.Drawing.Size(629, 542); + this.dataGridView1.Size = new System.Drawing.Size(637, 542); this.dataGridView1.TabIndex = 1; this.dataGridView1.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView1_RowPostPaint); this.dataGridView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView1_KeyDown); @@ -384,10 +383,10 @@ this.panel3.Controls.Add(this.panel4); this.panel3.Controls.Add(this.panel1); this.panel3.Controls.Add(this.panel2); - this.panel3.Dock = System.Windows.Forms.DockStyle.Left; + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; this.panel3.Location = new System.Drawing.Point(0, 0); this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(629, 738); + this.panel3.Size = new System.Drawing.Size(637, 738); this.panel3.TabIndex = 3; // // panel6 @@ -397,7 +396,7 @@ this.panel6.Dock = System.Windows.Forms.DockStyle.Fill; this.panel6.Location = new System.Drawing.Point(0, 174); this.panel6.Name = "panel6"; - this.panel6.Size = new System.Drawing.Size(629, 564); + this.panel6.Size = new System.Drawing.Size(637, 564); this.panel6.TabIndex = 3; // // statusStrip1 @@ -406,7 +405,7 @@ this.lblStatus}); this.statusStrip1.Location = new System.Drawing.Point(0, 542); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(629, 22); + this.statusStrip1.Size = new System.Drawing.Size(637, 22); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // @@ -428,7 +427,7 @@ this.panel4.Dock = System.Windows.Forms.DockStyle.Top; this.panel4.Location = new System.Drawing.Point(0, 140); this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(629, 34); + this.panel4.Size = new System.Drawing.Size(637, 34); this.panel4.TabIndex = 2; // // chk_RemoveBrit @@ -481,31 +480,21 @@ this.chk_spChar.Text = "특수문자 제거"; this.chk_spChar.UseVisualStyleBackColor = true; // - // panel5 + // chkShowBrowser // - this.panel5.Controls.Add(this.webBrowser1); - this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel5.Location = new System.Drawing.Point(629, 0); - this.panel5.Name = "panel5"; - this.panel5.Size = new System.Drawing.Size(662, 738); - this.panel5.TabIndex = 4; - // - // webBrowser1 - // - this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; - this.webBrowser1.Location = new System.Drawing.Point(0, 0); - this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20); - this.webBrowser1.Name = "webBrowser1"; - this.webBrowser1.ScriptErrorsSuppressed = true; - this.webBrowser1.Size = new System.Drawing.Size(662, 738); - this.webBrowser1.TabIndex = 2; + this.chkShowBrowser.AutoSize = true; + this.chkShowBrowser.Location = new System.Drawing.Point(515, 81); + this.chkShowBrowser.Name = "chkShowBrowser"; + this.chkShowBrowser.Size = new System.Drawing.Size(96, 16); + this.chkShowBrowser.TabIndex = 8; + this.chkShowBrowser.Text = "브라우저표시"; + this.chkShowBrowser.UseVisualStyleBackColor = true; // // Check_copyWD // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1291, 738); - this.Controls.Add(this.panel5); + this.ClientSize = new System.Drawing.Size(637, 738); this.Controls.Add(this.panel3); this.Name = "Check_copyWD"; this.Text = "복본조사(WebDriver)"; @@ -526,7 +515,6 @@ this.statusStrip1.PerformLayout(); this.panel4.ResumeLayout(false); this.panel4.PerformLayout(); - this.panel5.ResumeLayout(false); this.ResumeLayout(false); } @@ -547,7 +535,6 @@ private System.Windows.Forms.Panel panel3; private System.Windows.Forms.Panel panel6; private System.Windows.Forms.Panel panel4; - private System.Windows.Forms.Panel panel5; private System.Windows.Forms.CheckBox chk_spChar; private System.Windows.Forms.CheckBox chk_RemoveBrit; public System.Windows.Forms.NumericUpDown SearchCount; @@ -559,7 +546,6 @@ public System.Windows.Forms.Label lbl_PW; public System.Windows.Forms.Label lbl_ID; private System.Windows.Forms.Button btn_SiteDenote; - private System.Windows.Forms.WebBrowser webBrowser1; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripLabel lblStatus; private System.Windows.Forms.RadioButton radTargetAll; @@ -572,5 +558,6 @@ private System.Windows.Forms.DataGridViewTextBoxColumn dvc_remark; public System.Windows.Forms.CheckBox chkRetryErrData; public System.Windows.Forms.GroupBox groupBox1; + public System.Windows.Forms.CheckBox chkShowBrowser; } } \ No newline at end of file diff --git a/unimarc/unimarc/마크/Check_copyWD.cs b/unimarc/unimarc/마크/Check_copyWD.cs index eb0f530..feefeaf 100644 --- a/unimarc/unimarc/마크/Check_copyWD.cs +++ b/unimarc/unimarc/마크/Check_copyWD.cs @@ -201,15 +201,6 @@ namespace WindowsFormsApp1.Mac } - - isIksanClick = false; - isJBEClick = false; - isJNLClick = false; - isGwangJuNamGuClick = false; - isKJKClick = false; - isMokClick = false; - isWandoClick = false; - SearchCount.Value = dataGridView1.Rows.Count; //250619 RowCount = 0; //250619 @@ -239,8 +230,6 @@ namespace WindowsFormsApp1.Mac try { - //chrome web driver - webBrowser1.Visible = false; var searcher = this._searchService.Get(this.SearcherNo.toInt()); if (searcher == null) { @@ -252,7 +241,7 @@ namespace WindowsFormsApp1.Mac this._isSearching = true; btn_Start.Enabled = false; btn_Stop.Enabled = false; - searcher.StartDriver(); + searcher.StartDriver(this.chkShowBrowser.Checked); byte searchopt = 0; //전체검색 if (radTargetEmpty.Checked) searchopt = 1; else if (radTargetErr.Checked) searchopt = 2; @@ -373,221 +362,7 @@ namespace WindowsFormsApp1.Mac } int RowCount = 0; - private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) - { - if (RowCount < 0) - return; - - if (RowCount == SearchCount.Value) - { - webBrowser1.DocumentCompleted -= this.webBrowser1_DocumentCompleted; - MessageBox.Show("조사가 완료되었습니다!"); - RowCount = 0; - return; - } - - string URL = webBrowser1.Url.AbsoluteUri; - string BookCount = ""; - var val_bookName = dataGridView1.Rows[RowCount].Cells["book_name"].Value; - if (val_bookName == null) return; - - string text = val_bookName.ToString(); - - if (text == "----- 빈칸으로 놔주세요 -----") - return; - - // 광주 시립 (무등, 사직, 산수) - if (URL.IndexOf("citylib.gwangju.kr/main/bookSearch") > -1) - { - if (URL.IndexOf("keyword") > -1) - BookCount = 광주시립결과(); - - 광주시립입력(text); - } - - // 광주 남구 (문화정보, 푸른길, 청소년) - else if (URL.IndexOf("searchlib.namgu.gwangju.kr") > -1 || URL.IndexOf("lib.namgu.gwangju.kr") > -1) - { - //if (URL.IndexOf("word") > -1) - // BookCount = 광주남구결과(); - - HtmlElement searchform = null; //250619 검색결과를 통해서 내용 추측 - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("div")) - { - if (he.GetAttribute("class").ToLower().Equals("search-result")) - { - searchform = he; - break; - } - } - if (searchform != null) - { - BookCount = 광주남구결과(); - } - - - - 광주남구입력(text); - } - //광주 서구 - //else if (URL.IndexOf("library.seogu.gwangju.kr") > -1) - //{ - // //if (URL.IndexOf("word") > -1) - // // BookCount = 광주서구결과(); - - // BookCount = 광주서구입력(text); - //} - // 광주 북구 (일곡, 운암, 양산) - else if (URL.IndexOf("lib.bukgu.gwangju.kr") > -1) - { - BookCount = 광주북구입력(text); - } - - // 광주 광산구 (장덕, 이야기꽃, 첨단, 신가, 운남어린이, 스마트) - else if (URL.IndexOf("lib.gwangsan.go.kr") > -1) - { - if (URL.IndexOf("query") > -1) - BookCount = 광주광산구결과(); - - 광주광산구입력(text); - } - - // 광주 교육청 (학생독립, 중앙, 학생교육, 금호평생, 광주송정, 석봉) - else if (URL.IndexOf("lib.gen.go.kr") > -1) - { - if (URL.IndexOf("search_txt") > -1) - BookCount = 광주교육청결과(); - - 광주교육청입력(text); - } - - // 전남 교육청 (목포, 나주, 남평, 광양, 담양 ... 순천만생채문화교육원 등 총 26개 도서관) - else if (URL.IndexOf("jnelib.jne.go.kr") > -1) - { - BookCount = 전남교육청입력(text); - } - - // 전남 진도 (진도철마, 새섬작은, 의신백구) - else if (URL.IndexOf("lib.jindo.go.kr") > -1) - { - if (URL.IndexOf("simple") > -1) - BookCount = 전남진도결과(); - - 전남진도입력(text); - } - - // 전남 완도 (완도군립, 노화공공, 금일공공, 보길윤선도작은, 군외동백숲작은, 도담도담작은) - else if (URL.IndexOf("book.wando.go.kr") > -1) - { - BookCount = 전남완도입력(text); - } - - // 전남 도립 TODO: 오류발생 (원인불명) [한번에 3개씩 검색결과가 표출됨] - /* - else if (URL.IndexOf("lib.jeonnam.go.kr") > -1) - { - //Delay(500); - if (URL.IndexOf("value") > -1) - BookCount = 전남도립결과(); - - 전남도립입력(text); - } - */ - - // 전남 고흥 (군립중앙, 군립남부, 군립북부 등 총 7개 도서관) - else if (URL.IndexOf("ghlib.go.kr/BookSearch") > -1) - { - if (URL.IndexOf("simple") > -1) - BookCount = 전남고흥결과(); - - 전남고흥입력(text); - } - - // 전남 여수 (쌍봉, 현암, 환경, 돌산 등 총 31개 도서관) - else if (URL.IndexOf("218.157.123.2:9996/kcms") > -1) - { - if (URL.IndexOf("KBookSearch") > -1) - BookCount = 전남여수결과(); - - 전남여수입력(text); - } - - // 전남 무안군 공공도서관 - else if (URL.IndexOf("muan.go.kr/lib/data/search") > -1) - { - BookCount = 전남무안입력(text); - } - - // 전남 목포 시립도서관 - else if (URL.IndexOf("mokpolib.or.kr/dls_lt/index.php") > -1) - { - if (URL.IndexOf("searchWord") > -1) - BookCount = 전남목포결과(); - - 전남목포입력(text); - } - - // 전남 순천 시립도서관 - else if (URL.IndexOf("library.suncheon.go.kr") > -1) - { - BookCount = 전남순천입력(text); - } - - // 전북대학교 도서관 - else if (URL.IndexOf("dl.jbnu") > -1) - { - if (URL.IndexOf("result") > -1) - BookCount = 전북대결과(); - - 전북대입력(text); - } - - // 조선대학교 중앙도서관 - else if (URL.IndexOf("library.chosun") > -1) - { - if (URL.IndexOf("result") > -1) - BookCount = 조대도서관결과(); - - 조대도서관입력(text); - } - - // 전북교육청 소재 도서관 - else if (URL.IndexOf("lib.jbe.go.kr") > -1) - { - BookCount = 전북교육청입력(text); - } - - // 익산통합도서관 - else if (URL.IndexOf("lib.iksan.go.kr") > -1) - { - if (URL.IndexOf("search_txt_add") > -1) - BookCount = 익산통합도서관결과(); - - 익산통합도서관입력(text); - } - - // 안산 중앙도서관 - else if (URL.IndexOf("lib.ansan.go.kr") > -1) - { - BookCount = 안산중앙도서관입력(text); - } - - // 송원대학교 중앙도서관 - else if (URL.IndexOf("lib.songwon.ac.kr") > -1) - { - if (URL.IndexOf("searchTruncate") > -1) - BookCount = 송원대중앙도서관결과(); - - 송원대중앙도서관입력(text); - } - - int tmp = RowCount - 1; - if (tmp < 0) tmp = 0; - - BookCount = IsHave(BookCount, tmp); - dataGridView1.Rows[tmp].Cells["Count"].Value = BookCount; - RowCount++; - } + /// /// 입력된 카운트를 소장/미소장으로 바꿔서 반환 @@ -616,1089 +391,12 @@ namespace WindowsFormsApp1.Mac return Count; } - #region 광주 소재 도서관 - - #region 광주 시립 - void 광주시립입력(string text) - { - webBrowser1.Document.GetElementById("searchKeyword").SetAttribute("value", text); - - webBrowser1.Document.GetElementById("libCode").SetAttribute("value", Code); - - HtmlElementCollection button = webBrowser1.Document.GetElementsByTagName("button"); - foreach (HtmlElement SearchButton in button) - { - if (SearchButton.GetAttribute("className").IndexOf("bookSearchBtn") > -1) - SearchButton.InvokeMember("click"); - } - } - - string 광주시립결과() - { - string result = ""; - - HtmlElementCollection hecDiv = webBrowser1.Document.GetElementsByTagName("div"); - foreach (HtmlElement heDiv in hecDiv) - { - if (heDiv.GetAttribute("className").IndexOf("srch_info") > -1) - { - HtmlElementCollection hecLi = heDiv.GetElementsByTagName("span"); - foreach (HtmlElement heLi in hecLi) - { - if (heLi.GetAttribute("className").IndexOf("heighlight") > -1) - { - result = heLi.InnerText; - break; - } - } - } - } - return result; - } - #endregion - - #region 광주 남구 - bool isGwangJuNamGuClick = false; - void 광주남구입력(string text) - { - HtmlElement searchform = null; - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("form")) - { - if (he.GetAttribute("id").ToLower().Equals("searchform")) - { - searchform = he; - break; - } - } - - foreach (HtmlElement he in searchform.GetElementsByTagName("input")) - { - if (he.GetAttribute("id").ToLower().Equals("query")) - { - if (!isGwangJuNamGuClick) - { - he.InvokeMember("click"); - isGwangJuNamGuClick = true; - } - } - } - - foreach (HtmlElement he in searchform.GetElementsByTagName("input")) - { - if (he.Id != null && he.Id.ToLower().Equals("query"))//"searchWord") - { - he.SetAttribute("value", text); - } - } - // webBrowser1.Document.GetElementById("searchWord").SetAttribute("value", text); - - - foreach (HtmlElement Btn in searchform.GetElementsByTagName("button")) - { - if (Btn.GetAttribute("type").IndexOf("submit") > -1)//.IndexOf("btn btn-search") > -1) - Btn.InvokeMember("click"); - } - } - - string 광주남구결과() - { - string result = ""; - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("strong"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("cyan") > -1) - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - - return result; - } - #endregion - #region 광주 서구 - bool isKJSeoClick = false; - string 광주서구입력(string text) - { - string result = ""; - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) - { - if (he.Name.IndexOf("libcodes") > -1) - { - if (!he.Id.Contains("libcode129004") && !isKJSeoClick) - { - he.InvokeMember("click"); - } - } - } - isKJSeoClick = true; - webBrowser1.Document.GetElementById("searchword").SetAttribute("value", text); - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("button")) - { - if (Btn.GetAttribute("className").IndexOf("seachBbsBt") > -1) - Btn.InvokeMember("click"); - } - Delay(3000); - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("p"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("board_list") > -1) - { - if (heTd.TagName == "P") - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - } - - return result; - } - string 광주서구결과() - { - string result = ""; - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("strong"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("cyan") > -1) - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - - return result; - } - #endregion - #region 광주 북구 - bool isKJKClick = false; - string 광주북구입력(string text) - { - string result = ""; - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) - { - if (he.Name.IndexOf("libCode") > -1) - { - if (!he.Id.Contains(Code) && !isKJKClick) - { - he.InvokeMember("click"); - } - } - } - isKJKClick = true; - webBrowser1.Document.GetElementById("searchSimple").SetAttribute("value", text); - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("button")) - { - if (Btn.GetAttribute("className").IndexOf("btn btn-lg") > -1) - Btn.InvokeMember("click"); - } - Delay(3000); - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("p"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("totalCount") > -1) - { - if (heTd.TagName == "P") - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - } - - return result; - } - - #endregion - - #region 광주 광산구 - - void 광주광산구입력(string text) - { - webBrowser1.Document.GetElementById("query").SetAttribute("value", text); - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("button")) - { - if (Btn.GetAttribute("className") == "btn btn-lg") - Btn.InvokeMember("click"); - } - } - - string 광주광산구결과() - { - string result = ""; - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("p"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("totalCount") > -1) - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - - return result; - } - #endregion - - #region 광주 교육청 - - void 광주교육청입력(string text) - { - webBrowser1.Document.GetElementById("manage_code").SetAttribute("value", Code); - - webBrowser1.Document.GetElementById("search_txt").SetAttribute("value", text); - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("input")) - { - if (Btn.GetAttribute("id").IndexOf("search_txt") > -1) - Btn.SetAttribute("value", text); - if (Btn.GetAttribute("className").IndexOf("btn-search") > -1) - Btn.InvokeMember("click"); - } - } - - string 광주교육청결과() - { - string result = ""; - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("span"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.InnerText.IndexOf("전체") > -1) - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - return result; - } - - #endregion - - #region 조선대학교 중앙도서관 - - void 조대도서관입력(string text) - { - foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) - { - if (input.GetAttribute("className").IndexOf("searchInput") > -1) - input.SetAttribute("value", text); - - if (input.GetAttribute("className").IndexOf("searchBtn") > -1) - { - input.InvokeMember("click"); - break; - } - } - } - - string 조대도서관결과() - { - string result = ""; - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("span"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("catalogsCnt") > -1) - { - result = heTd.InnerText; - break; - } - } - return result; - } - #endregion - - #region 송원대학교 중앙도서관 - - void 송원대중앙도서관입력(string text) - { - webBrowser1.Document.GetElementById("q").SetAttribute("value", text); - webBrowser1.Document.GetElementById("opacsearch").InvokeMember("click"); - } - - string 송원대중앙도서관결과() - { - string result = ""; - - foreach (HtmlElement strong in webBrowser1.Document.GetElementsByTagName("strong")) - { - result = strong.InnerText; - break; - } - return result; - } - - #endregion - - #endregion - - #region 전남 소재 도서관 - - #region 전남 교육청 - bool isJNLClick = false; - string 전남교육청입력(string text) - { - string result = ""; - - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) - { - if (he.Id != null && he.Id.IndexOf(Code) > -1 && !isJNLClick) - { - he.InvokeMember("click"); - isJNLClick = true; - Delay(500); - } - if (he.Name.IndexOf("searchWordText") > -1) - { - he.SetAttribute("value", text); - } - } - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("input")) - { - if (Btn.GetAttribute("value") == "소장자료 검색") - Btn.InvokeMember("click"); - } - Delay(3000); - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("span"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("txt_bold") > -1) - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - break; - } - } - - return result; - } - - #endregion - - #region 전남 진도 - - void 전남진도입력(string text) - { - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) - { - if (he.GetAttribute("value").IndexOf(Code) > -1) - { - he.InvokeMember("click"); - } - if (he.Name.IndexOf("query") > -1) - { - he.SetAttribute("value", text); - } - } - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("button")) - { - if (Btn.GetAttribute("className").IndexOf("btn btn-lg") > -1) - Btn.InvokeMember("click"); - } - } - - string 전남진도결과() - { - string result = ""; - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("p"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("totalCount") > -1) - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - - return result; - } - #endregion - - #region 전남 완도 - - bool isWandoClick = false; - string 전남완도입력(string text) - { - - foreach (HtmlElement DIV in webBrowser1.Document.GetElementsByTagName("div")) - { - if (DIV.GetAttribute("className").IndexOf("search") > -1) - { - HtmlElementCollection FindSearch = DIV.GetElementsByTagName("input"); - foreach (HtmlElement search in FindSearch) - { - if (search.Name.IndexOf("word") > -1) - search.SetAttribute("value", text); - } - } - } - if (!isWandoClick) - { - foreach (HtmlElement DIV in webBrowser1.Document.GetElementsByTagName("div")) - { - if (DIV.GetAttribute("className").IndexOf("wrapbox") > -1) - { - HtmlElementCollection FindChk = DIV.GetElementsByTagName("input"); - foreach (HtmlElement chk in FindChk) - { - if (chk.GetAttribute("value").IndexOf(Code) > -1) - { - chk.InvokeMember("click"); - isWandoClick = true; - } - } - } - } - } - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("input")) - { - if (Btn.GetAttribute("className").IndexOf("btn-search") > -1) - Btn.InvokeMember("click"); - } - - Delay(4000); - - string result = ""; - - HtmlElementCollection hech3 = webBrowser1.Document.GetElementsByTagName("strong"); - foreach (HtmlElement heh3 in hech3) - { - if (heh3.GetAttribute("className").IndexOf("cyan") > -1) - { - result = Regex.Replace(heh3.InnerText, @"\D", ""); - } - } - - return result; - } - #endregion - - #region 전남 도립 (오류발생) - - void 전남도립입력(string text) - { - - HtmlElementCollection div = webBrowser1.Document.GetElementsByTagName("div"); - foreach (HtmlElement SearchDiv in div) - { - if (SearchDiv.GetAttribute("className") == "booksearch") - { - HtmlElementCollection hInput = SearchDiv.GetElementsByTagName("input"); - foreach (HtmlElement Input in hInput) - { - if (Input.GetAttribute("className").IndexOf("search_main") > -1) - Input.SetAttribute("value", text); - } - - HtmlElementCollection hBtn = SearchDiv.GetElementsByTagName("button"); - foreach (HtmlElement Btn in hBtn) - { - if (Btn.InnerText == "검색") - Btn.InvokeMember("click"); - } - } - } - } - - string 전남도립결과() - { - string result = ""; - - Delay(300); - - HtmlElementCollection hecDiv = webBrowser1.Document.GetElementsByTagName("div"); - foreach (HtmlElement heDiv in hecDiv) - { - if (heDiv.GetAttribute("className").IndexOf("booksearch_info") > -1) - { - HtmlElementCollection hecLi = heDiv.GetElementsByTagName("font"); - foreach (HtmlElement heLi in hecLi) - { - if (heLi.InnerText.IndexOf("전체") > -1) - { - result = Regex.Replace(heLi.InnerText, @"\D", ""); - break; - } - } - } - } - - return result; - } - #endregion - - #region 전남 고흥 - - void 전남고흥입력(string text) - { - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) - { - if (he.GetAttribute("id").IndexOf(Code) > -1) - { - he.InvokeMember("click"); - } - } - - webBrowser1.Document.GetElementById("query").SetAttribute("value", text); - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("button")) - { - if (Btn.GetAttribute("className").IndexOf("btn-lg") > -1) - Btn.InvokeMember("click"); - } - } - - string 전남고흥결과() - { - string result = ""; - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("p"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("className").IndexOf("totalCount") > -1) - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - - return result; - } - #endregion - - #region 전남 여수 - void 전남여수입력(string text) - { - HtmlElementCollection FindInput = webBrowser1.Document.GetElementsByTagName("input"); - foreach (HtmlElement input in FindInput) - { - if (input.Name.IndexOf("search_txt") > -1) - { - input.SetAttribute("value", text); - } - } - - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("a")) - { - if (he.GetAttribute("className").IndexOf("btn_search") > -1) - { - he.InvokeMember("click"); - } - } - } - - string 전남여수결과() - { - string result = ""; - - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("span")) - { - if (he.InnerText != null && he.InnerText.IndexOf("검색되었습니다.") > -1) - { - result = Regex.Replace(he.InnerText, @"[^0-9]", ""); - } - } - - return result; - } - - #endregion - - #region 전남 무안 - - string 전남무안입력(string text) - { - string result = "소장"; - - webBrowser1.Document.GetElementById("search_word").SetAttribute("value", text); - - HtmlElementCollection inputcol = webBrowser1.Document.GetElementsByTagName("input"); - foreach (HtmlElement input in inputcol) - { - if (input.GetAttribute("className").IndexOf("btn-sch btn-gray") > -1) - { - input.InvokeMember("click"); - } - } - - Delay(3000); - HtmlElementCollection tdcol = webBrowser1.Document.GetElementsByTagName("td"); - foreach (HtmlElement td in tdcol) - { - if (td.GetAttribute("className").IndexOf("list_empty") > -1) - { - result = "미소장"; - } - } - return result; - } - - #endregion - - #region 전남 목포 - - bool isMokClick = false; - - void 전남목포입력(string text) - { - - foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) - { - if (input.Id != null && input.Id.IndexOf(Code) > -1 && !isMokClick) - { - input.InvokeMember("click"); - isMokClick = true; - Delay(500); - } - if (input.Id != null && input.Id.IndexOf("searchWord") > -1) - input.SetAttribute("value", text); - } - - foreach (HtmlElement btn in webBrowser1.Document.GetElementsByTagName("input")) - { - if (btn.GetAttribute("className").IndexOf("btn-search") > -1) - btn.InvokeMember("click"); - } - - } - - string 전남목포결과() - { - string result = ""; - - foreach (HtmlElement strong in webBrowser1.Document.GetElementsByTagName("strong")) - { - if (strong.GetAttribute("className").IndexOf("cyan") > -1) - result = Regex.Replace(strong.InnerText, @"\D", ""); - } - - return result; - } - - #endregion - - #region 전남 순천 - - string 전남순천입력(string text) - { - - foreach (HtmlElement select in webBrowser1.Document.GetElementsByTagName("select")) - { - if (select.Id == "lib_code") - { - select.SetAttribute("value", Code); - break; - } - } - - foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) - { - if (input.Id == "search_val") - { - input.SetAttribute("value", text); - break; - } - } - - webBrowser1.Document.GetElementsByTagName("button")[0].InvokeMember("click"); - // foreach (HtmlElement button in webBrowser1.Document.GetElementsByTagName("button")) - // { - // button.InvokeMember("click"); - // break; - // } - - string result = ""; - - foreach (HtmlElement table in webBrowser1.Document.GetElementsByTagName("table")) - { - if (table.GetAttribute("className").IndexOf("search_bar") > -1) - { - result = Regex.Replace(table.Document.GetElementsByTagName("font")[0].InnerText, @"\D", ""); - // foreach (HtmlElement font in table.Document.GetElementsByTagName("font")) - // { - // if (font.GetAttribute("className").IndexOf("cyan") > -1) - // { - // result = Regex.Replace(font.InnerText, @"\D", ""); - // break; - // } - // } - break; - } - } - - return result; - } - - #endregion - - #endregion - - #region 전북 소재 도서관 - - #region 전북대학교 도서관 - - void 전북대입력(string text) - { - foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) - { - if (input.GetAttribute("className").IndexOf("inputText") > -1) - { - input.SetAttribute("value", text); - } - if (input.GetAttribute("className").IndexOf("searchBtn") > -1 && input.GetAttribute("type") != "submit") - { - input.InvokeMember("click"); - break; - } - } - } - - string 전북대결과() - { - string result = ""; - - foreach (HtmlElement div in webBrowser1.Document.GetElementsByTagName("div")) - { - if (div.GetAttribute("className").IndexOf("catalogs") > -1) - { - foreach (HtmlElement span in div.GetElementsByTagName("span")) - { - if (span.GetAttribute("className").IndexOf("moreCount") > -1) - { - result = span.InnerText; - break; - } - } - if (result != "0") - break; - } - else if (div.GetAttribute("className").IndexOf("articles") > -1) - { - foreach (HtmlElement span in div.GetElementsByTagName("span")) - { - if (span.GetAttribute("className").IndexOf("moreCount") > -1) - { - result = span.InnerText; - break; - } - } - if (result != "0") - break; - } - } - - return result; - } - - #endregion - - #region 전북 교육청 - - bool isJBEClick = false; - string 전북교육청입력(string text) - { - // webBrowser1.Document.GetElementById("search_text").SetAttribute("value", text); - - foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) - { - if (!isJBEClick) - { - if (input.GetAttribute("value").IndexOf("ALL") > -1) - { - input.InvokeMember("click"); - } - if (input.GetAttribute("value").IndexOf(Code) > -1) - { - input.InvokeMember("click"); - isJBEClick = true; - break; - } - } - } - foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) - { - if (input.Name == "search_text" && input.GetAttribute("className") == "text") - { - input.SetAttribute("value", text); - break; - } - } - - webBrowser1.Document.GetElementById("do-search").InvokeMember("click"); - - Delay(3000); - string result = ""; - int count = 0; - foreach (HtmlElement B in webBrowser1.Document.GetElementsByTagName("b")) - { - if (count == 1) - { - result = B.InnerText; - break; - } - count++; - } - - return result; - } - #endregion - - #region 익산시 통합도서관 - - bool isIksanClick = false; - void 익산통합도서관입력(string text) - { - - foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) - { - if (!isIksanClick) - { - if (input.Id == null) - continue; - if (input.Id.IndexOf("all_lib_simple") > -1) - { - input.InvokeMember("click"); - // input.InvokeMember("submit"); - } - if (input.Id.IndexOf(Code) > -1) - { - input.InvokeMember("click"); - // input.InvokeMember("submit"); - isIksanClick = true; - break; - } - btn_Close.Text = isIksanClick.ToString(); - } - } - - foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) - { - if (input.Id != null && input.Id == "search_txt") - { - input.SetAttribute("value", text); - break; - } - } - - //webBrowser1.Document.GetElementById("search_txt").SetAttribute("value", text); - - webBrowser1.Document.GetElementById("submit_simple").InvokeMember("click"); - } - - - - string 익산통합도서관결과() - { - string result = ""; - - foreach (HtmlElement strong in webBrowser1.Document.GetElementsByTagName("strong")) - { - if (strong.GetAttribute("className").IndexOf("word") > -1) - { - string innerText = strong.InnerText; - if (Regex.IsMatch(innerText, @"^[0-9]+$")) - { - result = strong.InnerText; - break; - } - } - } - - return result; - } - - #endregion - - #endregion - - #region 경기 소재 도서관 - - string 안산중앙도서관입력(string text) - { - // 콤보박스 적용 - webBrowser1.Document.GetElementById("srcKind").SetAttribute("value", Code); - - // 검색어 적용 - webBrowser1.Document.GetElementById("srcWord").SetAttribute("value", text); - - foreach (HtmlElement button in webBrowser1.Document.GetElementsByTagName("button")) - { - if (button.InnerText.IndexOf("검색하기") > -1) - { - button.InvokeMember("click"); - break; - } - } - - Delay(3000); - string result = ""; - foreach (HtmlElement span in webBrowser1.Document.GetElementsByTagName("span")) - { - string tmp = span.InnerText; - if (tmp.IndexOf("검색결과:") > -1) - { - result = Regex.Replace(tmp, @"[^0-9]", ""); - break; - } - } - - return result; - } - #endregion - - public string CopyCount(string Text) - { - string result = ""; - - if (lib_Category is null) - return "false"; - - string[] Detail = lib_Category.Split('_'); - - switch (Detail[0]) - { - case "전남": - result = 전남(Detail[1], Text); - break; - default: - break; - } - return result; - } - + private void btn_Stop_Click(object sender, EventArgs e) { _isSearching = false; - webBrowser1.Stop(); - webBrowser1.DocumentCompleted -= this.webBrowser1_DocumentCompleted; } - #region 전남 - string 전남(string detail, string Text) - { - string result = ""; - switch (detail) - { - case "도립": - result = 전남도립(Text); - break; - - case "여수": - result = 전남여수(Text); - break; - - case "완도": - result = 전남완도(Text); - break; - - default: - break; - } - return result; - } - - private string 전남도립(string text) - { - string result = ""; - - webBrowser1.Navigate(URL); - - Delay(5000); - - 전남도립입력(text); - - Delay(8000); - - result = 전남도립결과(); - - return result; - } - - private string 전남여수(string text) - { - string result = ""; - - text = HttpUtility.UrlEncode(text); - - string url = string.Format("https://yslib.yeosu.go.kr/dls_kapi/index.php?" + - "mod=wdDataSearch" + - "&act=searchResultList" + - "&facetManageCode={1}" + - "&searchWord={0}" + - "&dataSort=rk+desc", text, Code); - - webBrowser1.Navigate(url); - - Delay(8000); - foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("strong")) - { - if (he.GetAttribute("className").IndexOf("cyan") > -1) - { - result = Regex.Replace(he.InnerText, @"\D", ""); - } - } - return result; - } - - private string 전남완도(string text) - { - string result = ""; - - webBrowser1.Navigate(URL); - Delay(3000); - - webBrowser1.Document.GetElementById("value2").SetAttribute("value", text); - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("select")) - { - if (Btn.GetAttribute("name").IndexOf("local") > -1) - Btn.SetAttribute("value", Code); - } - - - foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("input")) - { - if (Btn.GetAttribute("type") == "image") - Btn.InvokeMember("click"); - } - - Delay(3000); - - HtmlElementCollection hecTd = webBrowser1.Document.GetElementsByTagName("td"); - foreach (HtmlElement heTd in hecTd) - { - if (heTd.GetAttribute("alrign").IndexOf("left") > -1) - { - result = Regex.Replace(heTd.InnerText, @"\D", ""); - } - } - - return result; - } - - #endregion - - /// - /// 지연시키는 함수 - /// - /// 1000 = 1초 - void Delay(int ms) - { - DateTime dateTimeNow = DateTime.Now; - TimeSpan duration = new TimeSpan(0, 0, 0, 0, ms); - DateTime dateTimeAdd = dateTimeNow.Add(duration); - - while (dateTimeAdd >= dateTimeNow) - { - Application.DoEvents(); - dateTimeNow = DateTime.Now; - } - return; - } private void btn_ApplyFilter_Click(object sender, EventArgs e) { @@ -1821,8 +519,7 @@ namespace WindowsFormsApp1.Mac private void Check_copy_FormClosing(object sender, FormClosingEventArgs e) { - webBrowser1.Stop(); - webBrowser1.DocumentCompleted -= this.webBrowser1_DocumentCompleted; + } private void btn_SiteDenote_Click(object sender, EventArgs e) diff --git a/unimarc/unimarc/마크/Check_copyWD.resx b/unimarc/unimarc/마크/Check_copyWD.resx index 3f8392d..9fc1aef 100644 --- a/unimarc/unimarc/마크/Check_copyWD.resx +++ b/unimarc/unimarc/마크/Check_copyWD.resx @@ -132,4 +132,7 @@ 17, 17 + + 17, 17 + \ No newline at end of file diff --git a/unimarc/unimarc/마크/DLS_Copy.Designer.cs b/unimarc/unimarc/마크/DLS_Copy.Designer.cs index b0db8b9..c26cf51 100644 --- a/unimarc/unimarc/마크/DLS_Copy.Designer.cs +++ b/unimarc/unimarc/마크/DLS_Copy.Designer.cs @@ -29,11 +29,15 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DLS_Copy)); - this.label1 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); this.panel8 = new System.Windows.Forms.Panel(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.Book_name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ISBN = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Check = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.panel5 = new System.Windows.Forms.Panel(); + this.chkShowBrowser = new System.Windows.Forms.CheckBox(); this.chk_RemoveBrit = new System.Windows.Forms.CheckBox(); this.chk_spChar = new System.Windows.Forms.CheckBox(); this.btn_ApplyFilter = new System.Windows.Forms.Button(); @@ -41,46 +45,37 @@ this.btn_Reflesh008 = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.rBtn_ISBN = new System.Windows.Forms.RadioButton(); + this.btnStop = new System.Windows.Forms.Button(); this.btn_Search = new System.Windows.Forms.Button(); this.rBtn_BookName = new System.Windows.Forms.RadioButton(); this.panel2 = new System.Windows.Forms.Panel(); + this.btn_SiteDenote = new System.Windows.Forms.Button(); this.btn_Connect = new System.Windows.Forms.Button(); this.lbl_PW = new System.Windows.Forms.Label(); this.lbl_Area = new System.Windows.Forms.Label(); this.lbl_ID = new System.Windows.Forms.Label(); this.lbl_Client = new System.Windows.Forms.Label(); this.tb_SearchClient = new System.Windows.Forms.TextBox(); - this.btn_Close = new System.Windows.Forms.Button(); - this.panel4 = new System.Windows.Forms.Panel(); - this.panel7 = new System.Windows.Forms.Panel(); - this.webBrowser1 = new System.Windows.Forms.WebBrowser(); - this.panel6 = new System.Windows.Forms.Panel(); - this.btn_Back = new System.Windows.Forms.Button(); - this.btn_Forward = new System.Windows.Forms.Button(); - this.tb_URL = new System.Windows.Forms.TextBox(); - this.btnStop = new System.Windows.Forms.Button(); - this.Book_name = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ISBN = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Check = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.lblStatus = new System.Windows.Forms.ToolStripLabel(); this.panel1.SuspendLayout(); this.panel8.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.panel5.SuspendLayout(); this.panel3.SuspendLayout(); this.panel2.SuspendLayout(); - this.panel4.SuspendLayout(); - this.panel7.SuspendLayout(); - this.panel6.SuspendLayout(); + this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(7, 10); + this.label1.Location = new System.Drawing.Point(7, 5); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(53, 12); + this.label1.Size = new System.Drawing.Size(63, 22); this.label1.TabIndex = 0; this.label1.Text = "납품처명"; + this.label1.Click += new System.EventHandler(this.label1_Click); // // panel1 // @@ -89,10 +84,10 @@ this.panel1.Controls.Add(this.panel5); this.panel1.Controls.Add(this.panel3); this.panel1.Controls.Add(this.panel2); - this.panel1.Dock = System.Windows.Forms.DockStyle.Left; + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(397, 734); + this.panel1.Size = new System.Drawing.Size(499, 712); this.panel1.TabIndex = 1; // // panel8 @@ -101,7 +96,7 @@ this.panel8.Dock = System.Windows.Forms.DockStyle.Fill; this.panel8.Location = new System.Drawing.Point(0, 103); this.panel8.Name = "panel8"; - this.panel8.Size = new System.Drawing.Size(395, 629); + this.panel8.Size = new System.Drawing.Size(497, 607); this.panel8.TabIndex = 5; // // dataGridView1 @@ -118,27 +113,58 @@ this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowHeadersWidth = 31; this.dataGridView1.RowTemplate.Height = 23; - this.dataGridView1.Size = new System.Drawing.Size(395, 629); + this.dataGridView1.Size = new System.Drawing.Size(497, 607); this.dataGridView1.TabIndex = 0; this.dataGridView1.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView1_RowPostPaint); this.dataGridView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView1_KeyDown); // + // Book_name + // + this.Book_name.HeaderText = "도서명"; + this.Book_name.Name = "Book_name"; + this.Book_name.Width = 140; + // + // ISBN + // + this.ISBN.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.ISBN.HeaderText = "ISBN"; + this.ISBN.Name = "ISBN"; + this.ISBN.Width = 140; + // + // Check + // + this.Check.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Check.HeaderText = "Y/N"; + this.Check.Name = "Check"; + // // panel5 // this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel5.Controls.Add(this.chkShowBrowser); this.panel5.Controls.Add(this.chk_RemoveBrit); this.panel5.Controls.Add(this.chk_spChar); this.panel5.Controls.Add(this.btn_ApplyFilter); this.panel5.Dock = System.Windows.Forms.DockStyle.Top; this.panel5.Location = new System.Drawing.Point(0, 68); this.panel5.Name = "panel5"; - this.panel5.Size = new System.Drawing.Size(395, 35); + this.panel5.Size = new System.Drawing.Size(497, 35); this.panel5.TabIndex = 4; // + // chkShowBrowser + // + this.chkShowBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.chkShowBrowser.AutoSize = true; + this.chkShowBrowser.Location = new System.Drawing.Point(395, 7); + this.chkShowBrowser.Name = "chkShowBrowser"; + this.chkShowBrowser.Size = new System.Drawing.Size(96, 16); + this.chkShowBrowser.TabIndex = 209; + this.chkShowBrowser.Text = "브라우저표시"; + this.chkShowBrowser.UseVisualStyleBackColor = true; + // // chk_RemoveBrit // this.chk_RemoveBrit.AutoSize = true; - this.chk_RemoveBrit.Location = new System.Drawing.Point(169, 8); + this.chk_RemoveBrit.Location = new System.Drawing.Point(116, 8); this.chk_RemoveBrit.Name = "chk_RemoveBrit"; this.chk_RemoveBrit.Size = new System.Drawing.Size(128, 16); this.chk_RemoveBrit.TabIndex = 3; @@ -157,6 +183,7 @@ // // btn_ApplyFilter // + this.btn_ApplyFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btn_ApplyFilter.Location = new System.Drawing.Point(314, 3); this.btn_ApplyFilter.Name = "btn_ApplyFilter"; this.btn_ApplyFilter.Size = new System.Drawing.Size(75, 24); @@ -176,7 +203,7 @@ this.panel3.Dock = System.Windows.Forms.DockStyle.Top; this.panel3.Location = new System.Drawing.Point(0, 33); this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(395, 35); + this.panel3.Size = new System.Drawing.Size(497, 35); this.panel3.TabIndex = 4; // // btn_Reflesh008 @@ -185,7 +212,7 @@ this.btn_Reflesh008.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btn_Reflesh008.BackgroundImage"))); this.btn_Reflesh008.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.btn_Reflesh008.Dock = System.Windows.Forms.DockStyle.Right; - this.btn_Reflesh008.Location = new System.Drawing.Point(360, 0); + this.btn_Reflesh008.Location = new System.Drawing.Point(462, 0); this.btn_Reflesh008.Name = "btn_Reflesh008"; this.btn_Reflesh008.Size = new System.Drawing.Size(33, 33); this.btn_Reflesh008.TabIndex = 208; @@ -213,6 +240,16 @@ this.rBtn_ISBN.Text = "ISBN"; this.rBtn_ISBN.UseVisualStyleBackColor = true; // + // btnStop + // + this.btnStop.Location = new System.Drawing.Point(283, 5); + this.btnStop.Name = "btnStop"; + this.btnStop.Size = new System.Drawing.Size(65, 23); + this.btnStop.TabIndex = 2; + this.btnStop.Text = "중 지"; + this.btnStop.UseVisualStyleBackColor = true; + this.btnStop.Click += new System.EventHandler(this.btnStop_Click); + // // btn_Search // this.btn_Search.Location = new System.Drawing.Point(217, 5); @@ -236,6 +273,7 @@ // panel2 // this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel2.Controls.Add(this.btn_SiteDenote); this.panel2.Controls.Add(this.btn_Connect); this.panel2.Controls.Add(this.lbl_PW); this.panel2.Controls.Add(this.lbl_Area); @@ -246,16 +284,28 @@ this.panel2.Dock = System.Windows.Forms.DockStyle.Top; this.panel2.Location = new System.Drawing.Point(0, 0); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(395, 33); + this.panel2.Size = new System.Drawing.Size(497, 33); this.panel2.TabIndex = 3; // + // btn_SiteDenote + // + this.btn_SiteDenote.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btn_SiteDenote.Location = new System.Drawing.Point(414, 5); + this.btn_SiteDenote.Name = "btn_SiteDenote"; + this.btn_SiteDenote.Size = new System.Drawing.Size(77, 23); + this.btn_SiteDenote.TabIndex = 6; + this.btn_SiteDenote.Text = "사이트 표출"; + this.btn_SiteDenote.UseVisualStyleBackColor = true; + this.btn_SiteDenote.Click += new System.EventHandler(this.btn_SiteDenote_Click); + // // btn_Connect // - this.btn_Connect.Location = new System.Drawing.Point(278, 5); + this.btn_Connect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btn_Connect.Location = new System.Drawing.Point(338, 5); this.btn_Connect.Name = "btn_Connect"; - this.btn_Connect.Size = new System.Drawing.Size(110, 23); + this.btn_Connect.Size = new System.Drawing.Size(70, 23); this.btn_Connect.TabIndex = 5; - this.btn_Connect.Text = "접 속"; + this.btn_Connect.Text = "접속"; this.btn_Connect.UseVisualStyleBackColor = true; this.btn_Connect.Click += new System.EventHandler(this.btn_Connect_Click); // @@ -297,132 +347,37 @@ // // tb_SearchClient // - this.tb_SearchClient.Location = new System.Drawing.Point(65, 6); + this.tb_SearchClient.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tb_SearchClient.Location = new System.Drawing.Point(76, 6); this.tb_SearchClient.Name = "tb_SearchClient"; - this.tb_SearchClient.Size = new System.Drawing.Size(198, 21); + this.tb_SearchClient.Size = new System.Drawing.Size(256, 21); this.tb_SearchClient.TabIndex = 1; this.tb_SearchClient.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tb_SearchClient_KeyDown); // - // btn_Close + // statusStrip1 // - this.btn_Close.Location = new System.Drawing.Point(820, 5); - this.btn_Close.Name = "btn_Close"; - this.btn_Close.Size = new System.Drawing.Size(75, 23); - this.btn_Close.TabIndex = 2; - this.btn_Close.Text = "닫 기"; - this.btn_Close.UseVisualStyleBackColor = true; - this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.lblStatus}); + this.statusStrip1.Location = new System.Drawing.Point(0, 712); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(499, 22); + this.statusStrip1.TabIndex = 3; + this.statusStrip1.Text = "statusStrip1"; // - // panel4 + // lblStatus // - this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panel4.Controls.Add(this.panel7); - this.panel4.Controls.Add(this.panel6); - this.panel4.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel4.Location = new System.Drawing.Point(397, 0); - this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(931, 734); - this.panel4.TabIndex = 2; - // - // panel7 - // - this.panel7.Controls.Add(this.webBrowser1); - this.panel7.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel7.Location = new System.Drawing.Point(0, 35); - this.panel7.Name = "panel7"; - this.panel7.Size = new System.Drawing.Size(929, 697); - this.panel7.TabIndex = 7; - // - // webBrowser1 - // - this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; - this.webBrowser1.Location = new System.Drawing.Point(0, 0); - this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20); - this.webBrowser1.Name = "webBrowser1"; - this.webBrowser1.ScriptErrorsSuppressed = true; - this.webBrowser1.Size = new System.Drawing.Size(929, 697); - this.webBrowser1.TabIndex = 5; - this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted); - // - // panel6 - // - this.panel6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panel6.Controls.Add(this.btn_Back); - this.panel6.Controls.Add(this.btn_Forward); - this.panel6.Controls.Add(this.tb_URL); - this.panel6.Controls.Add(this.btn_Close); - this.panel6.Dock = System.Windows.Forms.DockStyle.Top; - this.panel6.Location = new System.Drawing.Point(0, 0); - this.panel6.Name = "panel6"; - this.panel6.Size = new System.Drawing.Size(929, 35); - this.panel6.TabIndex = 6; - // - // btn_Back - // - this.btn_Back.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.btn_Back.Location = new System.Drawing.Point(10, 5); - this.btn_Back.Name = "btn_Back"; - this.btn_Back.Size = new System.Drawing.Size(43, 23); - this.btn_Back.TabIndex = 1; - this.btn_Back.Text = "<<"; - this.btn_Back.UseVisualStyleBackColor = true; - this.btn_Back.Click += new System.EventHandler(this.btn_Back_Click); - // - // btn_Forward - // - this.btn_Forward.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.btn_Forward.Location = new System.Drawing.Point(59, 5); - this.btn_Forward.Name = "btn_Forward"; - this.btn_Forward.Size = new System.Drawing.Size(43, 23); - this.btn_Forward.TabIndex = 1; - this.btn_Forward.Text = ">>"; - this.btn_Forward.UseVisualStyleBackColor = true; - this.btn_Forward.Click += new System.EventHandler(this.btn_Forward_Click); - // - // tb_URL - // - this.tb_URL.Location = new System.Drawing.Point(108, 6); - this.tb_URL.Name = "tb_URL"; - this.tb_URL.Size = new System.Drawing.Size(706, 21); - this.tb_URL.TabIndex = 0; - this.tb_URL.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tb_URL_KeyDown); - // - // btnStop - // - this.btnStop.Location = new System.Drawing.Point(283, 5); - this.btnStop.Name = "btnStop"; - this.btnStop.Size = new System.Drawing.Size(65, 23); - this.btnStop.TabIndex = 2; - this.btnStop.Text = "중 지"; - this.btnStop.UseVisualStyleBackColor = true; - this.btnStop.Click += new System.EventHandler(this.btnStop_Click); - // - // Book_name - // - this.Book_name.HeaderText = "도서명"; - this.Book_name.Name = "Book_name"; - this.Book_name.Width = 140; - // - // ISBN - // - this.ISBN.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.ISBN.HeaderText = "ISBN"; - this.ISBN.Name = "ISBN"; - this.ISBN.Width = 140; - // - // Check - // - this.Check.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.Check.HeaderText = "Y/N"; - this.Check.Name = "Check"; + this.lblStatus.Name = "lblStatus"; + this.lblStatus.Size = new System.Drawing.Size(27, 20); + this.lblStatus.Text = "WD"; // // DLS_Copy // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1328, 734); - this.Controls.Add(this.panel4); + this.ClientSize = new System.Drawing.Size(499, 734); this.Controls.Add(this.panel1); + this.Controls.Add(this.statusStrip1); this.Name = "DLS_Copy"; this.Text = "DLS 복본조사"; this.Load += new System.EventHandler(this.DLS_Copy_Load); @@ -435,21 +390,19 @@ this.panel3.PerformLayout(); this.panel2.ResumeLayout(false); this.panel2.PerformLayout(); - this.panel4.ResumeLayout(false); - this.panel7.ResumeLayout(false); - this.panel6.ResumeLayout(false); - this.panel6.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button label1; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel3; private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.Button btn_Close; public System.Windows.Forms.TextBox tb_SearchClient; public System.Windows.Forms.Label lbl_PW; public System.Windows.Forms.Label lbl_ID; @@ -461,13 +414,6 @@ private System.Windows.Forms.Label label2; private System.Windows.Forms.Button btn_Search; public System.Windows.Forms.Label lbl_Area; - private System.Windows.Forms.WebBrowser webBrowser1; - private System.Windows.Forms.Panel panel4; - private System.Windows.Forms.Panel panel6; - private System.Windows.Forms.TextBox tb_URL; - private System.Windows.Forms.Button btn_Back; - private System.Windows.Forms.Button btn_Forward; - private System.Windows.Forms.Panel panel7; private System.Windows.Forms.Button btn_Reflesh008; private System.Windows.Forms.Button btn_Connect; private System.Windows.Forms.CheckBox chk_RemoveBrit; @@ -478,5 +424,9 @@ private System.Windows.Forms.DataGridViewTextBoxColumn ISBN; private System.Windows.Forms.DataGridViewTextBoxColumn Check; private System.Windows.Forms.Button btnStop; + private System.Windows.Forms.Button btn_SiteDenote; + public System.Windows.Forms.CheckBox chkShowBrowser; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripLabel lblStatus; } } \ No newline at end of file diff --git a/unimarc/unimarc/마크/DLS_Copy.cs b/unimarc/unimarc/마크/DLS_Copy.cs index 1a6eb4f..61f3a9d 100644 --- a/unimarc/unimarc/마크/DLS_Copy.cs +++ b/unimarc/unimarc/마크/DLS_Copy.cs @@ -1,4 +1,5 @@ -using System; +using BokBonCheck; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -14,7 +15,7 @@ namespace WindowsFormsApp1.Mac { Main main; public string compidx; - string url = "https://reading.jnei.go.kr"; + string URL = "https://reading.jnei.go.kr"; public DLS_Copy(Main _main) { InitializeComponent(); @@ -22,7 +23,7 @@ namespace WindowsFormsApp1.Mac compidx = main.com_idx; - url = "https://dls.edunet.net/DLS/totalLoginMain"; + URL = "https://dls.edunet.net/DLS/totalLoginMain"; //url = "https://read365.edunet.net/TotalSearch"; //변경된 홈페이지: https://dls.edunet.net/DLS/totalLoginMain 사용 ID / 비번 : t5191774 / tb5191774 @@ -30,9 +31,99 @@ namespace WindowsFormsApp1.Mac private void DLS_Copy_Load(object sender, EventArgs e) { - webBrowser1.Navigate(url); - } + + this.Show(); + Application.DoEvents(); + //크롤링 + InitializeChromeDriver(); + + } + #region 크롤링 + + private readonly BookSearchService _searchService; + private bool _isSearching = false; + private bool _isDriverReady = false; + + private async void InitializeChromeDriver() + { + var lblStatus = this.lblStatus;// (Label)this.Controls["lblStatus"]; + lblStatus.Text = "WebDriver:Chrome 드라이버 확인 중..."; + lblStatus.ForeColor = Color.Blue; + + try + { + // Chrome 설치 확인 + if (!ChromeDriverManager.IsChromeInstalled()) + { + MessageBox.Show("Google Chrome이 설치되어 있지 않습니다. Chrome을 설치한 후 프로그램을 다시 실행해주세요.", + "Chrome 필요", MessageBoxButtons.OK, MessageBoxIcon.Warning); + lblStatus.Text = "WebDriver:Chrome이 설치되지 않음"; + lblStatus.ForeColor = Color.Red; + return; + } + + // 기존 드라이버가 준비되어 있는지 확인 + if (ChromeDriverManager.IsDriverReady()) + { + lblStatus.Text = "WebDriver:Ready"; + lblStatus.ForeColor = Color.Green; + _isDriverReady = true; + return; + } + + // 드라이버가 없거나 작동하지 않으면 다운로드 진행 창 표시 + using (var progressForm = new DownloadProgressForm()) + { + progressForm.Show(); + + try + { + // ChromeDriver 설정 + await ChromeDriverManager.SetupChromeDriverAsync(progressForm); + + // 드라이버 테스트 + var isWorking = await ChromeDriverManager.TestChromeDriverAsync(progressForm); + + if (isWorking) + { + _isDriverReady = true; + lblStatus.Text = "WebDriver:Ready"; + lblStatus.ForeColor = Color.Green; + } + else + { + lblStatus.Text = "WebDriver:Chrome 드라이버 테스트 실패"; + lblStatus.ForeColor = Color.Red; + MessageBox.Show("Chrome 드라이버 테스트에 실패했습니다. 인터넷 연결을 확인하고 프로그램을 다시 실행해주세요.", + "드라이버 오류", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + catch (OperationCanceledException) + { + lblStatus.Text = "WebDriver:드라이버 다운로드가 취소되었습니다."; + lblStatus.ForeColor = Color.Orange; + return; + } + catch (Exception ex) + { + lblStatus.Text = "WebDriver:Chrome 드라이버 설정 실패"; + lblStatus.ForeColor = Color.Red; + MessageBox.Show($"Chrome 드라이버 설정 중 오류가 발생했습니다: {ex.Message}", + "설정 오류", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + catch (Exception ex) + { + lblStatus.Text = "WebDriver:Chrome 드라이버 설정 실패"; + lblStatus.ForeColor = Color.Red; + MessageBox.Show($"Chrome 드라이버 설정 중 오류가 발생했습니다: {ex.Message}", + "설정 오류", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +#endregion private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { Skill_Grid sg = new Skill_Grid(); @@ -75,36 +166,8 @@ namespace WindowsFormsApp1.Mac MessageBox.Show("설정된 지역이 없습니다. 납품처 관리에서 확인해주세요."); return; } - - string url = webBrowser1.Url.AbsoluteUri; - - webBrowser1.Document.GetElementById("headerLoginBtn").InvokeMember("click"); - - Delay(5000); - - DLS_Login(url); } - #region Connect_SUB - - private void DLS_Login(string url) - { - if (lbl_ID.Text == "" || lbl_PW.Text == "") - { - MessageBox.Show("ID 혹은 PW가 없습니다."); - return; - } - string ID = lbl_ID.Text, PW = lbl_PW.Text; - url = webBrowser1.Document.GetElementById(SetArea(lbl_Area.Text)).GetAttribute("value"); - - webBrowser1.Document.GetElementById("s_id").SetAttribute("value", ID); - webBrowser1.Document.GetElementById("s_pwd").SetAttribute("value", PW); - - webBrowser1.Document.GetElementById("s_login").InvokeMember("click"); - - Delay(4000); - webBrowser1.Navigate(url + "/r/dls_new/bookInfo/collectionFormMA.jsp"); - } - #endregion + private bool tStop = false; private int tSearchIDX = 0; private void btn_Search_Click(object sender, EventArgs e) @@ -120,134 +183,11 @@ namespace WindowsFormsApp1.Mac MessageBox.Show("도서명이 입력되지않았습니다!"); return; } - if (!SearchCopy(rBtn_ISBN.Checked)) - return; + MessageBox.Show("완료되었습니다."); } - #region SearchClick_Sub - - private bool SearchCopy(bool isISBN) - { - if (!webBrowser1.Url.AbsoluteUri.Contains("collectionFormMA")) - { - MessageBox.Show("자료관리 창이 아닙니다!"); - return false; - } - - int count = dataGridView1.Rows.Count; - - for (int a = 0; a < count; a++) - { - if (tSearchIDX != 0) a = tSearchIDX; - string Check; - if (isISBN) - { - string Target = dataGridView1.Rows[a].Cells["ISBN"].Value.ToString(); - Check = SearchISBN(Target); - } - else - { - string Target = dataGridView1.Rows[a].Cells["Book_name"].Value.ToString(); - Check = SearchName(Target); - } - if (Check == "0") - Check = ""; - dataGridView1.Rows[a].Cells["Check"].Value = Check; - if (Check == "") - dataGridView1.Rows[a].DefaultCellStyle.BackColor = Color.LightGray; - else - dataGridView1.Rows[a].DefaultCellStyle.BackColor = Color.Yellow; - - if (tStop) - { - tSearchIDX = a + 1; - break; - } - } - if (tStop) MessageBox.Show("검색이 중지 되었습니다."); - return true; - } - /// - /// 도서명 필터로 DLS복본 검색 - /// - /// 도서명 - /// 행 번호 - private string SearchName(string Target) - { - HtmlElementCollection search = webBrowser1.Document.GetElementsByTagName("input"); - foreach (HtmlElement Search in search) - { - if (Search.Id == "bib1") - Search.SetAttribute("value", Target); - - if (Search.GetAttribute("className") == "button_search") - Search.InvokeMember("click"); - } - Delay(5000); - - string InnerText = ""; - - HtmlElementCollection paging_nav = webBrowser1.Document.GetElementsByTagName("div"); - foreach (HtmlElement div in paging_nav) - { - if (div.GetAttribute("className") == "paging_nav") - { - HtmlElementCollection span = div.GetElementsByTagName("span"); - foreach (HtmlElement count in span) - { - InnerText = count.InnerText; - break; - } - } - } - - return InnerText; - } - /// - /// ISBN 필터로 DLS복본 검색 - /// - /// ISBN - /// 행 번호 - private string SearchISBN(string Target) - { - HtmlElementCollection combo = webBrowser1.Document.GetElementsByTagName("select"); - foreach (HtmlElement Search in combo) - { - if (Search.Id == "bibKind2") - Search.SetAttribute("selectedIndex", "2"); - } - - HtmlElementCollection search = webBrowser1.Document.GetElementsByTagName("input"); - foreach (HtmlElement Search in search) - { - if (Search.Id == "bib2") - Search.SetAttribute("value", Target); - - if (Search.GetAttribute("className") == "button_search") - Search.InvokeMember("click"); - } - Delay(5000); - - string InnerText = ""; - - HtmlElementCollection paging_nav = webBrowser1.Document.GetElementsByTagName("div"); - foreach (HtmlElement div in paging_nav) - { - if (div.GetAttribute("className") == "paging_nav") - { - HtmlElementCollection span = div.GetElementsByTagName("span"); - foreach (HtmlElement count in span) - { - InnerText = count.InnerText; - break; - } - } - } - - return InnerText; - } - #endregion + /// /// DLS지역 코드 변환 @@ -278,18 +218,7 @@ namespace WindowsFormsApp1.Mac idx++; } - if (move) - { - try - { - webBrowser1.Navigate(webBrowser1.Document.GetElementById(Code[idx]).GetAttribute("value")); - } - catch (Exception ex) - { - AR.UTIL.MsgE("지역변경실패, 사이트가 변경되었을 수 있습니다.\n잠시 후 다시시도하세요\n"+ex.Message); - } - } - + return Code[idx]; } @@ -311,35 +240,6 @@ namespace WindowsFormsApp1.Mac return; } - private void btn_Close_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void btn_Back_Click(object sender, EventArgs e) - { - webBrowser1.GoBack(); - } - - private void btn_Forward_Click(object sender, EventArgs e) - { - webBrowser1.GoForward(); - } - - private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) - { - tb_URL.Text = webBrowser1.Url.AbsoluteUri; - } - - private void tb_URL_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - string url = tb_URL.Text; - webBrowser1.Navigate(url); - } - } - private void btn_Reflesh008_Click(object sender, EventArgs e) { tSearchIDX = 0; @@ -356,5 +256,15 @@ namespace WindowsFormsApp1.Mac tStop = true; } + private void btn_SiteDenote_Click(object sender, EventArgs e) + { + if (URL == null) return; + AR.UTIL.RunExplorer(URL); + } + + private void label1_Click(object sender, EventArgs e) + { + ClientSearch(); + } } } diff --git a/unimarc/unimarc/마크/DLS_Copy.resx b/unimarc/unimarc/마크/DLS_Copy.resx index 5e7dfc7..b1deea7 100644 --- a/unimarc/unimarc/마크/DLS_Copy.resx +++ b/unimarc/unimarc/마크/DLS_Copy.resx @@ -132,37 +132,41 @@ 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 + P87mU+ZvyRQDAAAAAElFTkSuQmCC + + 17, 17 + \ No newline at end of file diff --git a/unimarc/unimarc/마크/Marc.cs b/unimarc/unimarc/마크/Marc.cs index 6a3365e..676fc79 100644 --- a/unimarc/unimarc/마크/Marc.cs +++ b/unimarc/unimarc/마크/Marc.cs @@ -579,7 +579,7 @@ namespace ExcelTest date, mCompidx }; string Incmd = db.DB_INSERT(table_name, Insert_tbl, Insert_col); - CUtill.mLog.Add("INSERT", string.Format( "{0}({1},{2}) : {3}", mUserName, mCompidx, List_Book.Rows[SaveRowIdx].DefaultCellStyle.ForeColor, Incmd)); + PUB.log.Add("INSERT", string.Format( "{0}({1},{2}) : {3}", mUserName, mCompidx, List_Book.Rows[SaveRowIdx].DefaultCellStyle.ForeColor, Incmd)); db.DB_Send_CMD_reVoid(Incmd); isNewData = true; } @@ -631,7 +631,7 @@ namespace ExcelTest // } //} string U_cmd = db.More_Update(table_name, Edit_tbl, Edit_col, Sear_tbl, Sear_col); - CUtill.mLog.Add("Update", string.Format( "{0}({1},{2}) : {3}", mUserName, mCompidx, List_Book.Rows[SaveRowIdx].DefaultCellStyle.ForeColor , U_cmd.Replace("\r", " ").Replace("\n", " "))); + PUB.log.Add("Update", string.Format( "{0}({1},{2}) : {3}", mUserName, mCompidx, List_Book.Rows[SaveRowIdx].DefaultCellStyle.ForeColor , U_cmd.Replace("\r", " ").Replace("\n", " "))); db.DB_Send_CMD_reVoid(U_cmd); isNewData = false; } @@ -645,14 +645,14 @@ namespace ExcelTest if (isNewData) { string MidxQuery = string.Format("SELECT `idx` FROM Marc WHERE isbn = {0} AND `compidx` = {1};", grid_data[0], mCompidx); - CUtill.mLog.Add("MarcInsert", string.Format( "{0}({1}) : {2}", mUserName, mCompidx, MidxQuery)); + PUB.log.Add("MarcInsert", string.Format( "{0}({1}) : {2}", mUserName, mCompidx, MidxQuery)); Midx = db.DB_Send_CMD_Search(MidxQuery).Replace("|", ""); List_Book.Rows[SaveRowIdx].Cells["marc_idx"].Value = Midx; } string UpdateListIndex = string.Format("UPDATE `Obj_List_Book` SET `m_idx` = {0} WHERE `idx` = {1} AND 'compidx' ={2};", Midx, List_Book.Rows[SaveRowIdx].Cells["list_idx"].Value.ToString(), mCompidx); - CUtill.mLog.Add("MarcUpdate", string.Format( "{0}({1}) : {2}", mUserName, mCompidx, UpdateListIndex)); + PUB.log.Add("MarcUpdate", string.Format( "{0}({1}) : {2}", mUserName, mCompidx, UpdateListIndex)); db.DB_Send_CMD_reVoid(UpdateListIndex); MessageBox.Show("저장되었습니다!"); } diff --git a/unimarc/unimarc/홈/Home_User_manage.cs b/unimarc/unimarc/홈/Home_User_manage.cs index 1090be6..6234659 100644 --- a/unimarc/unimarc/홈/Home_User_manage.cs +++ b/unimarc/unimarc/홈/Home_User_manage.cs @@ -1,4 +1,5 @@ -using ExcelTest; +using AR; +using ExcelTest; using MySqlX.XDevAPI.Relational; using System; using System.Collections.Generic; @@ -278,7 +279,7 @@ namespace WindowsFormsApp1.Home return; } string tText = string.Format("{0} 를 수정 하시겠습니까?", dataGridView1.SelectedRows[0].Cells["ID"].Value.ToString()); - if (CUtill.MsgQ(tText) == DialogResult.Yes) + if (UTIL.MsgQ(tText) == DialogResult.Yes) { if (tb_ID.Text == "" || tb_PW.Text == "" || tb_Name.Text == "") { @@ -366,7 +367,7 @@ namespace WindowsFormsApp1.Home return; } string tText = string.Format("{0} 를 삭제 하시겠습니까?", dataGridView1.SelectedRows[0].Cells["ID"].Value.ToString()); - if (CUtill.MsgQ(tText) == DialogResult.Yes) + if (UTIL.MsgQ(tText) == DialogResult.Yes) { int row = dataGridView1.CurrentRow.Index; string tID = dataGridView1.SelectedRows[0].Cells["id"].Value.ToString(); diff --git a/unimarc/unimarc/홈/Transaction_manage.cs b/unimarc/unimarc/홈/Transaction_manage.cs index 9ae4d4a..4d79813 100644 --- a/unimarc/unimarc/홈/Transaction_manage.cs +++ b/unimarc/unimarc/홈/Transaction_manage.cs @@ -126,7 +126,7 @@ namespace WindowsFormsApp1.Home if (RowIndex < 0) return; string tText = string.Format("{0} 를 추가 하시겠습니까?", tb_sangho.Text); - if (CUtill.MsgQ(tText) != DialogResult.Yes) return; + if (UTIL.MsgQ(tText) != DialogResult.Yes) return; if (tb_sangho.Text == "") { @@ -188,7 +188,7 @@ namespace WindowsFormsApp1.Home if (tRowIndex < 0) return; string tText = string.Format("{0} 를 수정 하시겠습니까?", dv1.Rows[tRowIndex].Cells["sangho"].Value.ToString()); - if (CUtill.MsgQ(tText) != DialogResult.Yes) return; + if (UTIL.MsgQ(tText) != DialogResult.Yes) return; if (tb_sangho.Text == "") { MessageBox.Show("업체명이 비어있습니다."); @@ -268,7 +268,7 @@ namespace WindowsFormsApp1.Home if (RowIndex < 0) return; string tText = string.Format("{0} 를 삭제 하시겠습니까?", dv1.Rows[RowIndex].Cells["sangho"].Value.ToString()); - if (CUtill.MsgQ(tText) != DialogResult.Yes) return; + if (UTIL.MsgQ(tText) != DialogResult.Yes) return; string D_cmd = db.DB_Delete("Client", "idx", dv1.Rows[RowIndex].Cells["idx"].Value.ToString(), "c_sangho", tb_sangho.Text); db.DB_Send_CMD_reVoid(D_cmd); Made_Grid();