diff --git a/ISBN_Check/.vscode/settings.json b/ISBN_Check/.vscode/settings.json
new file mode 100644
index 0000000..013007b
--- /dev/null
+++ b/ISBN_Check/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "dotnet.preferCSharpExtension": true
+}
\ No newline at end of file
diff --git a/ISBN_Check/Main/.vscode/settings.json b/ISBN_Check/Main/.vscode/settings.json
new file mode 100644
index 0000000..013007b
--- /dev/null
+++ b/ISBN_Check/Main/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "dotnet.preferCSharpExtension": true
+}
\ No newline at end of file
diff --git a/ISBN_Check/Main/Form1.Designer.cs b/ISBN_Check/Main/Form1.Designer.cs
index 3149b4c..8c576e7 100644
--- a/ISBN_Check/Main/Form1.Designer.cs
+++ b/ISBN_Check/Main/Form1.Designer.cs
@@ -29,9 +29,9 @@ namespace ISBN_Check_test
///
private void InitializeComponent()
{
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
this.cb_filter = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
@@ -58,6 +58,7 @@ namespace ISBN_Check_test
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
+ this.button3 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
@@ -76,7 +77,7 @@ namespace ISBN_Check_test
//
// button1
//
- this.button1.Location = new System.Drawing.Point(416, 10);
+ this.button1.Location = new System.Drawing.Point(388, 9);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
@@ -86,14 +87,14 @@ namespace ISBN_Check_test
//
// dataGridView1
//
- dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle4.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
- dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
+ dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+ dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle7.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
+ dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.book_name,
this.author,
@@ -110,14 +111,14 @@ namespace ISBN_Check_test
this.dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnF2;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
- dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle6.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
- dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle6;
+ dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+ dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle9.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
+ dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.dataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle9;
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dataGridView1.Size = new System.Drawing.Size(1001, 471);
@@ -186,8 +187,8 @@ namespace ISBN_Check_test
//
// count
//
- dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.count.DefaultCellStyle = dataGridViewCellStyle5;
+ dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+ this.count.DefaultCellStyle = dataGridViewCellStyle8;
this.count.HeaderText = "검색갯수";
this.count.Name = "count";
this.count.Width = 80;
@@ -239,7 +240,7 @@ namespace ISBN_Check_test
//
// button2
//
- this.button2.Location = new System.Drawing.Point(503, 10);
+ this.button2.Location = new System.Drawing.Point(467, 9);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
@@ -267,7 +268,7 @@ namespace ISBN_Check_test
//
// btn_Yes24
//
- this.btn_Yes24.Location = new System.Drawing.Point(590, 10);
+ this.btn_Yes24.Location = new System.Drawing.Point(625, 9);
this.btn_Yes24.Name = "btn_Yes24";
this.btn_Yes24.Size = new System.Drawing.Size(75, 23);
this.btn_Yes24.TabIndex = 8;
@@ -277,6 +278,7 @@ namespace ISBN_Check_test
//
// panel1
//
+ this.panel1.Controls.Add(this.button3);
this.panel1.Controls.Add(this.cb_api);
this.panel1.Controls.Add(this.btn_Yes24);
this.panel1.Controls.Add(this.cb_filter);
@@ -311,6 +313,16 @@ namespace ISBN_Check_test
this.panel3.Size = new System.Drawing.Size(1001, 471);
this.panel3.TabIndex = 11;
//
+ // button3
+ //
+ this.button3.Location = new System.Drawing.Point(546, 9);
+ this.button3.Name = "button3";
+ this.button3.Size = new System.Drawing.Size(75, 23);
+ this.button3.TabIndex = 9;
+ this.button3.Text = "리셋(전체)";
+ this.button3.UseVisualStyleBackColor = true;
+ this.button3.Click += new System.EventHandler(this.button3_Click);
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -360,6 +372,7 @@ namespace ISBN_Check_test
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
+ private System.Windows.Forms.Button button3;
}
}
diff --git a/ISBN_Check/Main/Form1.cs b/ISBN_Check/Main/Form1.cs
index df842d4..6faaefc 100644
--- a/ISBN_Check/Main/Form1.cs
+++ b/ISBN_Check/Main/Form1.cs
@@ -159,11 +159,16 @@ namespace ISBN_Check_test
gridview.Rows[a ].DefaultCellStyle.BackColor = Color.Empty;
// string aladin = api.Aladin(query, "ISBN13", param);
- string aladin = api.Aladin(query, type, param);
+ var aladin = api.Aladin(query, type, param);
insert_By_Aladin(aladin, a);
try
{
- richTextBox1.Text = aladin;
+ var sb = new StringBuilder();
+ foreach(var item in aladin)
+ {
+ sb.AppendLine(string.Join("|", item));
+ }
+ richTextBox1.Text = sb.ToString();
}
catch { }
}
@@ -309,7 +314,7 @@ namespace ISBN_Check_test
{
progressBar1.PerformStep();
}
- void insert_By_Aladin(string data, int row)
+ void insert_By_Aladin(string[] insert, int row)
{
if (row >0)
{
@@ -317,9 +322,8 @@ namespace ISBN_Check_test
}
dataGridView1.Rows[row ].Selected = true;
- string[] insert = data.Split('|');
- if (data == "") { return; }
+ if (insert.Any() == false) { return; }
// pubDate형 보기편하게 DateTime형으로 재정리
string newstring = "";
@@ -328,7 +332,7 @@ namespace ISBN_Check_test
newstring = String.Format("{0:yyyy/MM/dd}",
DateTime.Parse(insert[5].Remove(insert[5].IndexOf(" G"))));
}
- catch (Exception ex) { MessageBox.Show(data); }
+ catch (Exception ex) { MessageBox.Show(string.Join("|",insert)); }
for (int a = 0; a < insert.Length; a++)
{
@@ -641,7 +645,8 @@ namespace ISBN_Check_test
{
if (System.Diagnostics.Debugger.IsAttached)
{
- string[] lst = { "9791193110584",
+ string[] lst = { "9788965427520",
+ "9791193110584",
"9791168672260",
"9788993858396",
"9791171200351",
@@ -658,5 +663,17 @@ namespace ISBN_Check_test
end_idx.Text = (this.dataGridView1.Rows.Count - 1).ToString();
}
}
+
+ private void button3_Click(object sender, EventArgs e)
+ {
+ for (int a = 0; a < dataGridView1.Rows.Count - 1; a++)
+ {
+ //if (dataGridView1.Rows[a].DefaultCellStyle.BackColor != Color.Yellow)
+ {
+ dataGridView1.Rows[a].Cells["Column1"].Value = "";
+ dataGridView1.Rows[a].DefaultCellStyle.BackColor = Color.Empty;
+ }
+ }
+ }
}
}
diff --git a/ISBN_Check/Main/Form1_Sub.cs b/ISBN_Check/Main/Form1_Sub.cs
index b35ccbd..d8e29c3 100644
--- a/ISBN_Check/Main/Form1_Sub.cs
+++ b/ISBN_Check/Main/Form1_Sub.cs
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
using System.Xml;
+using System.Xml.Linq;
namespace ISBN_Check_test
{
@@ -22,7 +23,7 @@ namespace ISBN_Check_test
///
///
///
- public string Aladin(string Query, string QueryType, string[] Param)
+ public string[] Aladin(string Query, string QueryType, string[] Param)
{
string result = string.Empty;
// 쿼리 생성
@@ -49,57 +50,40 @@ namespace ISBN_Check_test
// xml형식을 json형식으로 변환
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
- var json = JsonConvert.SerializeXmlNode(doc);
- // json형식 분석을 위해 JavaScriptSerializer 개체 생성
- JavaScriptSerializer js = new JavaScriptSerializer();
+ var xdoc = XDocument.Parse(xml);
+ var xroot = xdoc.Root;
- // 런타임에 개체를 확인하여 사용할수 있는 dynamic을 이용해 역직렬화
- dynamic dob = js.Deserialize(json);
+ // XML에서 직접 totalResults와 item 추출 (XDocument 사용)
+ XNamespace ns = "http://www.aladin.co.kr/ttb/apiguide.aspx";
- // "object"내에 있는것을 얻어오기 위해 다시 dynamic변수에 참조
- dynamic docs = "";
- try
+ // totalResults 추출
+ string totalResults = xdoc.Descendants(ns + "totalResults").FirstOrDefault()?.Value ?? "0";
+
+ // item들 추출
+ var itemElements = xdoc.Descendants(ns + "item");
+
+ if (!itemElements.Any())
{
- docs = dob["object"]["item"];
+ return new string[] { };
}
- catch
- {
- return "";
- }
- int length = 0;
+
+ int length = itemElements.Count();
int ID_length = Param.Length;
- // 검색 결과가 1개 이하일 경우, 오류가 발생하여 try/catch문 사용.
- try
+ // XML item들을 순회하면서 필요한 데이터 추출 (XDocument 사용)
+ List retval = new List();
+ foreach (var itemElement in itemElements)
{
- // docs는 요소 컬렉션으로 object로 변환.
- object[] buf = docs;
- length = buf.Length;
- }
- catch
- {
- object buf = docs;
- length = 1;
- }
- for (int a = 0; a < length; a++)
- {
- List tmp_data = new List();
+ string[] buffer = new string[ID_length];
for (int b = 0; b < ID_length; b++)
{
- if (length == 1)
- {
- tmp_data.Add(docs[Param[b]]);
- }
- else
- {
- tmp_data.Add(docs[a][Param[b]]);
- }
- result += tmp_data[b] + "|";
+ buffer[b] = itemElement.Element(ns + Param[b])?.Value ?? "";
}
- result += "\n";
+ //retval.Add(buffer);
+ return buffer;
}
- return result;
+ return new string[] { };
}
///
/// https://blog.aladin.co.kr/openapi 참고
@@ -194,7 +178,7 @@ namespace ISBN_Check_test
// url 생성
string url = "https://openapi.naver.com/v1/search/book_adv?";
- for(int a = 0; a < Query.Length; a++)
+ for (int a = 0; a < Query.Length; a++)
{
url += string.Format("{0}={1}&", QueryType[a], Query[a]);
}
@@ -278,7 +262,7 @@ namespace ISBN_Check_test
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
string json = reader.ReadToEnd();
stream.Close();
-
+
JavaScriptSerializer js = new JavaScriptSerializer();
dynamic dob = js.Deserialize(json);
dynamic docs = dob["documents"];
@@ -287,18 +271,20 @@ namespace ISBN_Check_test
int length = buf.Length;
int ID_length = Param.Length;
- for(int a = 0; a < length; a++)
+ for (int a = 0; a < length; a++)
{
List