diff --git a/unimarc/unimarc/SearchModel/ChromeDriverManager.cs b/unimarc/unimarc/SearchModel/ChromeDriverManager.cs
index 4010728..caacefd 100644
--- a/unimarc/unimarc/SearchModel/ChromeDriverManager.cs
+++ b/unimarc/unimarc/SearchModel/ChromeDriverManager.cs
@@ -566,57 +566,7 @@ namespace BokBonCheck
options.AddArgument("--no-sandbox");
options.AddArgument("--disable-dev-shm-usage");
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;
}
diff --git a/unimarc/unimarc/SearchModel/NamguLibrarySearcher.cs b/unimarc/unimarc/SearchModel/NamguLibrarySearcher.cs
index 8ebc5a4..af4aaf6 100644
--- a/unimarc/unimarc/SearchModel/NamguLibrarySearcher.cs
+++ b/unimarc/unimarc/SearchModel/NamguLibrarySearcher.cs
@@ -220,44 +220,6 @@ namespace BokBonCheck
this.No = no;
}
- //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)
{
diff --git a/unimarc/unimarc/SearchModel/SeleniumHelper.cs b/unimarc/unimarc/SearchModel/SeleniumHelper.cs
new file mode 100644
index 0000000..ef230f0
--- /dev/null
+++ b/unimarc/unimarc/SearchModel/SeleniumHelper.cs
@@ -0,0 +1,330 @@
+using OpenQA.Selenium;
+using OpenQA.Selenium.Chrome;
+using OpenQA.Selenium.Chromium;
+using OpenQA.Selenium.Edge;
+using OpenQA.Selenium.Interactions;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using WebDriverManager;
+using WebDriverManager.DriverConfigs;
+using WebDriverManager.DriverConfigs.Impl;
+
+namespace UniMarc.SearchModel
+{
+ public static class SeleniumHelper
+ {
+ static ChromiumDriver _driver;
+ static string pathname_userdata = "WebDriverUserData";
+ public enum eBrowserType
+ {
+ edge,
+ chrome
+ }
+ public static eBrowserType Browser = eBrowserType.edge;
+
+ ///
+ /// 드라이버파일을 다운로드 하고 완료된 경우 드라이버 실행파일 명을 반환합니다.
+ ///
+ /// MatchingBrowser,Latest
+ ///
+ public static string Download(string versiontype = "MatchingBrowser")
+ {
+ var dnpath = new System.IO.DirectoryInfo("WebDriver\\Download");
+ if (dnpath.Exists == false) dnpath.Create();
+ var drv = new DriverManager(dnpath.FullName);
+
+ IDriverConfig config = null;
+ if (Browser == eBrowserType.edge) config = new EdgeConfig();
+ else if (Browser == eBrowserType.chrome) config = new ChromeConfig();
+
+ return drv.SetUpDriver(config, versiontype);
+ }
+ static string MakeUserDataPath()
+ {
+ string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss_fff");
+ string randomId = Guid.NewGuid().ToString("N").Substring(0, 8);
+ var userDataDir = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"WebDriver", $"Edge_{timestamp}_{randomId}");
+
+ var userpath = new System.IO.DirectoryInfo(userDataDir);
+ if (userpath.Exists == false) userpath.Create();
+ return userpath.FullName;
+ }
+ public static ChromiumDriver MakeDriver()
+ {
+ ChromiumDriver driver = nul;
+ var options = MakeBaseOption();
+ if (Browser == eBrowserType.edge)
+ {
+ driver = new EdgeDriver((EdgeOptions)options); // Edge 드라이버 초기화
+ }
+ else if (Browser == eBrowserType.chrome)
+ {
+ driver = new ChromeDriver((ChromeOptions)options); // Edge 드라이버 초기화
+ }
+
+ if( driver != null)
+ {
+ // 웹드라이버 감지 방지
+ ((IJavaScriptExecutor)_driver).ExecuteScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})");
+ }
+
+ return driver;
+ }
+ static ChromiumOptions MakeBaseOption()
+ {
+ EdgeOptions options = nul;
+ if (Browser == eBrowserType.edge)
+ {
+ options = new EdgeOptions();
+ //options.AddArgument($"--user-data-dir={userDataDir}");
+ options.AddArgument("--no-first-run");
+ options.AddArgument("--no-default-browser-check");
+ options.AddArgument("--disable-default-apps");
+ options.AddArgument("--disable-popup-blocking");
+ options.AddArgument("--disable-translate");
+ options.AddArgument("--disable-background-timer-throttling");
+ options.AddArgument("--disable-renderer-backgrounding");
+ options.AddArgument("--disable-backgrounding-occluded-windows");
+ options.AddArgument("--disable-client-side-phishing-detection");
+ options.AddArgument("--disable-sync");
+ options.AddArgument("--disable-extensions");
+ options.AddArgument("--disable-component-extensions-with-background-pages");
+ options.AddArgument("--disable-background-networking");
+ options.AddArgument("--disable-background-mode");
+ options.AddArgument("--no-sandbox");
+ options.AddArgument("--disable-dev-shm-usage");
+ options.AddArgument("--disable-blink-features=AutomationControlled");
+ options.AddArgument("--remote-debugging-port=0"); // 랜덤 포트 사용
+
+ }
+ else if (Browser == eBrowserType.chrome)
+ {
+ options = new ChromeOptions();
+ //options.AddArgument($"--user-data-dir={userDataDir}");
+ options.AddArgument("--no-first-run");
+ options.AddArgument("--no-default-browser-check");
+ options.AddArgument("--disable-default-apps");
+ options.AddArgument("--disable-popup-blocking");
+ options.AddArgument("--disable-translate");
+ options.AddArgument("--disable-background-timer-throttling");
+ options.AddArgument("--disable-renderer-backgrounding");
+ options.AddArgument("--disable-backgrounding-occluded-windows");
+ options.AddArgument("--disable-client-side-phishing-detection");
+ options.AddArgument("--disable-sync");
+ options.AddArgument("--disable-extensions");
+ options.AddArgument("--disable-component-extensions-with-background-pages");
+ options.AddArgument("--disable-background-networking");
+ options.AddArgument("--disable-background-mode");
+ options.AddArgument("--no-sandbox");
+ options.AddArgument("--disable-dev-shm-usage");
+ options.AddArgument("--disable-blink-features=AutomationControlled");
+ options.AddArgument("--remote-debugging-port=0"); // 랜덤 포트 사용
+
+
+ }
+ options.AddArgument("--window-size=1920,1080");
+ return options;
+ }
+ public static void KillExistingDrivers()
+ {
+ string[] processNames = { };
+ if (Browser == eBrowserType.chrome)
+ processNames = new string[] { "chromedriver", "chrome" };
+ else if (Browser == eBrowserType.edge)
+ processNames = new string[] { "msedgedriver", "msedge", "MicrosoftEdge" };
+
+ try
+ {
+ foreach (string processName in processNames)
+ {
+ Process[] processes = Process.GetProcessesByName(processName);
+ if (processes.Length > 0)
+ {
+ Console.WriteLine($"기존 {processName} 프로세스 {processes.Length}개를 종료하는 중...");
+ foreach (Process process in processes)
+ {
+ try
+ {
+ process.Kill();
+ process.WaitForExit(3000);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"{processName} 종료 중 오류: {ex.Message}");
+ }
+ }
+ }
+ }
+
+ // 임시 WebDriver 사용자 데이터 폴더들 정리
+ CleanupTempUserDataDirectories();
+
+ // 프로세스가 완전히 종료될 때까지 대기
+ Thread.Sleep(2000);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"기존 프로세스 종료 중 오류: {ex.Message}");
+ }
+
+ }
+
+
+ static void CleanupTempUserDataDirectories()
+ {
+ try
+ {
+ var tempPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, pathname_userdata, $"{Browser}");
+ string[] directories = System.IO.Directory.GetDirectories(tempPath);
+
+ if (directories.Length > 0)
+ {
+ Console.WriteLine($"기존 임시 사용자 데이터 폴더 {directories.Length}개를 정리하는 중...");
+ foreach (string dir in directories)
+ {
+ try
+ {
+ System.IO.Directory.Delete(dir, true);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"폴더 삭제 중 오류: {ex.Message}");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"임시 폴더 정리 중 오류: {ex.Message}");
+ }
+ }
+
+ ///
+ /// 현재 설치된 브라우저 버전을 확인합니다.
+ ///
+ /// 브라우저 버전 문자열
+ public static string GetBrowserVersion()
+ {
+ try
+ {
+ if (Browser == eBrowserType.chrome)
+ {
+ return GetChromeVersion();
+ }
+ else if (Browser == eBrowserType.edge)
+ {
+ return GetEdgeVersion();
+ }
+ return "Unknown Browser";
+ }
+ catch (Exception ex)
+ {
+ return $"Version check failed: {ex.Message}";
+ }
+ }
+
+ ///
+ /// Chrome 브라우저 버전을 확인합니다.
+ ///
+ /// Chrome 버전
+ static string GetChromeVersion()
+ {
+ try
+ {
+ // 레지스트리에서 Chrome 버전 확인
+ using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Google\Chrome\BLBeacon"))
+ {
+ if (key != null)
+ {
+ var version = key.GetValue("version")?.ToString();
+ if (!string.IsNullOrEmpty(version))
+ return $"Chrome {version}";
+ }
+ }
+
+ // HKLM에서 시도
+ using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Google\Chrome\BLBeacon"))
+ {
+ if (key != null)
+ {
+ var version = key.GetValue("version")?.ToString();
+ if (!string.IsNullOrEmpty(version))
+ return $"Chrome {version}";
+ }
+ }
+
+ // WOW6432Node에서 시도 (32비트 앱이 64비트 시스템에서 실행될 때)
+ using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Google\Chrome\BLBeacon"))
+ {
+ if (key != null)
+ {
+ var version = key.GetValue("version")?.ToString();
+ if (!string.IsNullOrEmpty(version))
+ return $"Chrome {version}";
+ }
+ }
+
+ return "Chrome version not found";
+ }
+ catch (Exception ex)
+ {
+ return $"Chrome version check failed: {ex.Message}";
+ }
+ }
+
+ ///
+ /// Edge 브라우저 버전을 확인합니다.
+ ///
+ /// Edge 버전
+ static string GetEdgeVersion()
+ {
+ try
+ {
+ // 레지스트리에서 Edge 버전 확인
+ using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Edge\BLBeacon"))
+ {
+ if (key != null)
+ {
+ var version = key.GetValue("version")?.ToString();
+ if (!string.IsNullOrEmpty(version))
+ return $"Edge {version}";
+ }
+ }
+
+ // HKLM에서 시도
+ using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Edge\BLBeacon"))
+ {
+ if (key != null)
+ {
+ var version = key.GetValue("version")?.ToString();
+ if (!string.IsNullOrEmpty(version))
+ return $"Edge {version}";
+ }
+ }
+
+ // WOW6432Node에서 시도
+ using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Edge\BLBeacon"))
+ {
+ if (key != null)
+ {
+ var version = key.GetValue("version")?.ToString();
+ if (!string.IsNullOrEmpty(version))
+ return $"Edge {version}";
+ }
+ }
+
+ return "Edge version not found";
+ }
+ catch (Exception ex)
+ {
+ return $"Edge version check failed: {ex.Message}";
+ }
+ }
+ }
+}
diff --git a/unimarc/unimarc/UniMarc.csproj b/unimarc/unimarc/UniMarc.csproj
index c596e3f..e12bf8c 100644
--- a/unimarc/unimarc/UniMarc.csproj
+++ b/unimarc/unimarc/UniMarc.csproj
@@ -45,6 +45,7 @@
prompt
4
false
+ IDE0090,IDE1006
AnyCPU
@@ -96,9 +97,21 @@
..\dll\CarlosAg.ExcelXmlWriter.dll
+
+ ..\packages\Google.Protobuf.3.30.0\lib\net45\Google.Protobuf.dll
+
..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll
+
+ ..\packages\K4os.Compression.LZ4.1.3.8\lib\net462\K4os.Compression.LZ4.dll
+
+
+ ..\packages\K4os.Compression.LZ4.Streams.1.3.8\lib\net462\K4os.Compression.LZ4.Streams.dll
+
+
+ ..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll
+
..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
@@ -112,7 +125,9 @@
..\packages\Microsoft.Win32.Registry.5.0.0\lib\net461\Microsoft.Win32.Registry.dll
-
+
+ ..\packages\MySql.Data.9.4.0\lib\net462\MySql.Data.dll
+
..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
@@ -123,11 +138,22 @@
..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
+
+ ..\packages\System.Configuration.ConfigurationManager.8.0.0\lib\net462\System.Configuration.ConfigurationManager.dll
+
+
+ ..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll
+
..\packages\System.Formats.Asn1.8.0.2\lib\net462\System.Formats.Asn1.dll
+
+ ..\packages\System.IO.Pipelines.5.0.2\lib\net461\System.IO.Pipelines.dll
+
+
..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll
@@ -158,6 +184,7 @@
..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
@@ -181,6 +208,9 @@
..\packages\WebDriverManager.2.17.6\lib\net472\WebDriverManager.dll
+
+ ..\packages\ZstdSharp.Port.0.8.5\lib\net462\ZstdSharp.dll
+
@@ -203,6 +233,7 @@
+
Form
diff --git a/unimarc/unimarc/packages.config b/unimarc/unimarc/packages.config
index 57c21b1..3710adb 100644
--- a/unimarc/unimarc/packages.config
+++ b/unimarc/unimarc/packages.config
@@ -2,17 +2,25 @@
+
+
+
+
+
+
+
+
@@ -24,4 +32,5 @@
+
\ No newline at end of file
diff --git a/unimarc/unimarc/납품관리/Commodity_registration.cs b/unimarc/unimarc/납품관리/Commodity_registration.cs
index 6945357..2561a89 100644
--- a/unimarc/unimarc/납품관리/Commodity_registration.cs
+++ b/unimarc/unimarc/납품관리/Commodity_registration.cs
@@ -1,5 +1,4 @@
-using MySqlX.XDevAPI.Relational;
-using System;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
diff --git a/unimarc/unimarc/마크/Marc_Plan.cs b/unimarc/unimarc/마크/Marc_Plan.cs
index d9d3621..e65b88e 100644
--- a/unimarc/unimarc/마크/Marc_Plan.cs
+++ b/unimarc/unimarc/마크/Marc_Plan.cs
@@ -1,5 +1,4 @@
using ExcelTest;
-using MySqlX.XDevAPI.Relational;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -259,7 +258,7 @@ namespace WindowsFormsApp1.Mac
}
#region SearchTag_KeyDown_Sub
- List BackUpTag = new List();
+ readonly List BackUpTag = new List();
private void Search_Tag()
{
BackUpTag.Clear();
diff --git a/unimarc/unimarc/홈/Home_User_manage.cs b/unimarc/unimarc/홈/Home_User_manage.cs
index 6234659..d648c02 100644
--- a/unimarc/unimarc/홈/Home_User_manage.cs
+++ b/unimarc/unimarc/홈/Home_User_manage.cs
@@ -1,6 +1,5 @@
using AR;
using ExcelTest;
-using MySqlX.XDevAPI.Relational;
using System;
using System.Collections.Generic;
using System.ComponentModel;