복본검색 : 도서관이름 검색이 검색완료된 검색어가 다시 검색안되는 현상 수정

마지막 항목이 검색되지 않는 현상 수정
  사이트리뉴얼로 기존 코드로 분석이 쉽지 않음 변경이 필요 함
This commit is contained in:
2025-07-06 19:25:11 +09:00
committed by SeungHo Yang
parent 701f84d96a
commit 344659c1b9
2 changed files with 56 additions and 21 deletions

Binary file not shown.

View File

@@ -38,7 +38,7 @@ namespace WindowsFormsApp1.Mac
// if (Target == "") { MessageBox.Show("도서관명이 비어있습니다."); return; } // if (Target == "") { MessageBox.Show("도서관명이 비어있습니다."); return; }
string area = "`Province`, `Area`, `LibName`, `Code`, `URL`"; string area = "`Province`, `Area`, `LibName`, `Code`, `URL`";
string cmd = string.Format("SELECT {0} FROM `lib_CopyCheck` WHERE `LibName` LIKE '%{1}%';", area, Target); string cmd = string.Format("SELECT {0} FROM `lib_CopyCheck` WHERE CONCAT( province , '_' , AREA , '_' , libname) LIKE '%{1}%';", area, Target);
string data = db.self_Made_Cmd(cmd); string data = db.self_Made_Cmd(cmd);
string[] ary = data.Split('|'); string[] ary = data.Split('|');
Check_Copy_Sub_Search ccs = new Check_Copy_Sub_Search(this); Check_Copy_Sub_Search ccs = new Check_Copy_Sub_Search(this);
@@ -80,13 +80,17 @@ namespace WindowsFormsApp1.Mac
isMokClick = false; isMokClick = false;
isWandoClick = false; isWandoClick = false;
SearchCount.Value = dataGridView1.Rows.Count; //250619
RowCount = 0; //250619
dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[0]; dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[0];
webBrowser1.Navigate(""); webBrowser1.Navigate("");
int SCount = Convert.ToInt32(SearchCount.Value); int SCount = Convert.ToInt32(SearchCount.Value);
if (URL is null) { if (URL is null)
{
webBrowser1.DocumentCompleted -= this.webBrowser1_DocumentCompleted; webBrowser1.DocumentCompleted -= this.webBrowser1_DocumentCompleted;
return; return;
} }
@@ -130,7 +134,8 @@ namespace WindowsFormsApp1.Mac
dataGridView1.Rows[a].Cells["Count"].Value = BookSearchCount; dataGridView1.Rows[a].Cells["Count"].Value = BookSearchCount;
} }
} }
else { else
{
if (URL.IndexOf("218.157.123.2:9996/kcms/Main") > -1) if (URL.IndexOf("218.157.123.2:9996/kcms/Main") > -1)
webBrowser1.Navigate(URL + "/" + Code); webBrowser1.Navigate(URL + "/" + Code);
@@ -158,7 +163,10 @@ namespace WindowsFormsApp1.Mac
string URL = webBrowser1.Url.AbsoluteUri; string URL = webBrowser1.Url.AbsoluteUri;
string BookCount = ""; string BookCount = "";
string text = dataGridView1.Rows[RowCount].Cells["book_name"].Value.ToString(); var val_bookName = dataGridView1.Rows[RowCount].Cells["book_name"].Value;
if (val_bookName == null) return;
string text = val_bookName.ToString();
if (text == "----- 빈칸으로 놔주세요 -----") if (text == "----- 빈칸으로 놔주세요 -----")
return; return;
@@ -173,10 +181,26 @@ namespace WindowsFormsApp1.Mac
} }
// 광주 남구 (문화정보, 푸른길, 청소년) // 광주 남구 (문화정보, 푸른길, 청소년)
else if (URL.IndexOf("searchlib.namgu.gwangju.kr") > -1) else if (URL.IndexOf("searchlib.namgu.gwangju.kr") > -1 || URL.IndexOf("lib.namgu.gwangju.kr") > -1)
{ {
if (URL.IndexOf("word") > -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 = (); BookCount = ();
}
(text); (text);
} }
@@ -202,7 +226,7 @@ namespace WindowsFormsApp1.Mac
(text); (text);
} }
// 광주 교육청 (학생독립, 중앙, 학생교육, 금호평생, 광주송정, 석봉) // 광주 교육청 (학생독립, 중앙, 학생교육, 금호평생, 광주송정, 석봉)
else if (URL.IndexOf("lib.gen.go.kr") > -1) else if (URL.IndexOf("lib.gen.go.kr") > -1)
{ {
@@ -262,7 +286,7 @@ namespace WindowsFormsApp1.Mac
(text); (text);
} }
// 전남 무안군 공공도서관 // 전남 무안군 공공도서관
else if (URL.IndexOf("muan.go.kr/lib/data/search") > -1) else if (URL.IndexOf("muan.go.kr/lib/data/search") > -1)
{ {
@@ -412,9 +436,19 @@ namespace WindowsFormsApp1.Mac
bool isGwangJuNamGuClick = false; bool isGwangJuNamGuClick = false;
void (string text) void (string text)
{ {
foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) HtmlElement searchform = null;
foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("form"))
{ {
if (he.GetAttribute("id").IndexOf(Code) > -1) 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) if (!isGwangJuNamGuClick)
{ {
@@ -424,18 +458,19 @@ namespace WindowsFormsApp1.Mac
} }
} }
foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) foreach (HtmlElement he in searchform.GetElementsByTagName("input"))
{ {
if (he.Id != null && he.Id == "searchWord") if (he.Id != null && he.Id.ToLower().Equals("query"))//"searchWord")
{ {
he.SetAttribute("value", text); he.SetAttribute("value", text);
} }
} }
// webBrowser1.Document.GetElementById("searchWord").SetAttribute("value", text); // webBrowser1.Document.GetElementById("searchWord").SetAttribute("value", text);
foreach (HtmlElement Btn in webBrowser1.Document.GetElementsByTagName("input"))
foreach (HtmlElement Btn in searchform.GetElementsByTagName("button"))
{ {
if (Btn.GetAttribute("className").IndexOf("btn btn-search") > -1) if (Btn.GetAttribute("type").IndexOf("submit") >-1)//.IndexOf("btn btn-search") > -1)
Btn.InvokeMember("click"); Btn.InvokeMember("click");
} }
} }
@@ -682,7 +717,7 @@ namespace WindowsFormsApp1.Mac
string (string text) string (string text)
{ {
string result = ""; string result = "";
foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input")) foreach (HtmlElement he in webBrowser1.Document.GetElementsByTagName("input"))
{ {
if (he.Id != null && he.Id.IndexOf(Code) > -1 && !isJNLClick) if (he.Id != null && he.Id.IndexOf(Code) > -1 && !isJNLClick)
@@ -1053,7 +1088,7 @@ namespace WindowsFormsApp1.Mac
// } // }
string result = ""; string result = "";
foreach (HtmlElement table in webBrowser1.Document.GetElementsByTagName("table")) foreach (HtmlElement table in webBrowser1.Document.GetElementsByTagName("table"))
{ {
if (table.GetAttribute("className").IndexOf("search_bar") > -1) if (table.GetAttribute("className").IndexOf("search_bar") > -1)
@@ -1070,7 +1105,7 @@ namespace WindowsFormsApp1.Mac
break; break;
} }
} }
return result; return result;
} }
@@ -1218,7 +1253,7 @@ namespace WindowsFormsApp1.Mac
foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input")) foreach (HtmlElement input in webBrowser1.Document.GetElementsByTagName("input"))
{ {
if (input.Id !=null && input.Id == "search_txt") if (input.Id != null && input.Id == "search_txt")
{ {
input.SetAttribute("value", text); input.SetAttribute("value", text);
break; break;
@@ -1469,7 +1504,7 @@ namespace WindowsFormsApp1.Mac
// Target = Target.Replace(",", "").Replace(".", "").Replace(";", "").Replace(":", ""); // Target = Target.Replace(",", "").Replace(".", "").Replace(";", "").Replace(":", "");
string res = Regex.Replace(Target, @"[^a-zA-Z0-9가-힣_\s()]", "", RegexOptions.Singleline); string res = Regex.Replace(Target, @"[^a-zA-Z0-9가-힣_\s()]", "", RegexOptions.Singleline);
dataGridView1.Rows[a].Cells["book_name"].Value = res.Trim(); dataGridView1.Rows[a].Cells["book_name"].Value = res.Trim();
} }
} }
@@ -1578,9 +1613,9 @@ namespace WindowsFormsApp1.Mac
} }
catch catch
{ {
} }
} }
} }
} }