From 994e0168a8eaac6a8f1749d9870ef531e595a1f2 Mon Sep 17 00:00:00 2001 From: mjjo Date: Sun, 5 Feb 2017 16:55:15 +0900 Subject: [PATCH] =?UTF-8?q?-=20DartAPI=20=EC=9A=94=EC=B2=AD=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95=20-=208092=20=EC=A2=85=EB=AA=A9?= =?UTF-8?q?=EB=AA=85=20=EC=B0=BE=EA=B8=B0=20=EC=88=98=EC=A0=95=20-=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8=ED=95=9C=20=EC=A2=85=EB=AA=A9=EB=AA=85=20?= =?UTF-8?q?=EB=B0=B0=EA=B2=BD=EC=83=89=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config.cs | 2 +- Crawler.cs | 9 +++++---- NewsForm.cs | 34 ++++++++++++---------------------- Util.cs | 4 +++- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/Config.cs b/Config.cs index b15b373..d1b7fdf 100644 --- a/Config.cs +++ b/Config.cs @@ -221,7 +221,7 @@ namespace NewsCrawler public static bool CheckRightsIssue() { - return (bool)m_Data["ann-ann-rights-issue"]; + return (bool)m_Data["ann-rights-issue"]; } public static bool CheckPatent() diff --git a/Crawler.cs b/Crawler.cs index c265b8d..2deadb2 100644 --- a/Crawler.cs +++ b/Crawler.cs @@ -692,7 +692,8 @@ namespace NewsCrawler return; } - foreach(var data in jObj["list"]) + var List = jObj["list"]; + foreach(var data in List) { string strTime = "00:00"; string strTitle = data["rpt_nm"]; @@ -728,8 +729,8 @@ namespace NewsCrawler public void ReadDartAPI(bool bInitial = false) { - if (Util.IsDebugging() == true) - return; + //if (Util.IsDebugging() == true) + // return; if(m_iDartAPIRetry <= 0) return; @@ -737,7 +738,7 @@ namespace NewsCrawler try { string strAuthKey = Config.GetDartAPIKey(); - string strURL = "http://dart.fss.or.kr/api/search.json?auth="+strAuthKey+"&end_dt="+m_Today.ToString("yyyyMMdd"); + string strURL = "http://dart.fss.or.kr/api/search.json?auth="+strAuthKey+"&end_dt="+m_Today.ToString("yyyyMMdd")+"&sort=date&series=desc&page_set=100"; HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest; HttpReq.Credentials = CredentialCache.DefaultCredentials; HttpReq.Timeout = 2000; diff --git a/NewsForm.cs b/NewsForm.cs index 381a120..25770de 100644 --- a/NewsForm.cs +++ b/NewsForm.cs @@ -475,27 +475,18 @@ namespace NewsCrawler int iID = lvList.Items.Count+1; - CodeList.CODE_VALUE Code = null; - if(bInitial == false) - { - if(strCode == "") - Code = m_CodeList.SearchCode(strTitle); - else - Code = m_CodeList.GetCode(strCode); + CodeList.CODE_VALUE Code = m_CodeList.SearchCode(strTitle); + if(bInitial == false && Code != null) + ProcessSearchAndBuy(new NEWS_ITEM(iID, strTitle, strCode, Code, time, ResTime, strRef, strURL, (float)dElapseT)); - if(Code != null) - ProcessSearchAndBuy(new NEWS_ITEM(iID, strTitle, strCode, Code, time, ResTime, strRef, strURL, (float)dElapseT)); - } - - - lvList.Items.Add(new ListViewItem(new string[] { + var AddedItem = lvList.Items.Add(new ListViewItem(new string[] { iID.ToString(), time.ToString("HH:mm:ss"), ResTime.ToString("HH:mm:ss:fff"), string.Format("{0:n3} ms", dElapseT), strRef, strTitle, - (Code != null) ? Code.m_strName : "", + (Code != null) ? Code.m_strName : strName, "", "", "", @@ -503,13 +494,14 @@ namespace NewsCrawler "", strURL })); - if(lvList.Items.Count == 0) + AddedItem.UseItemStyleForSubItems = false; + if(Code == null && strCode != "") + AddedItem.SubItems[chCodeName.Index].BackColor = Color.Gray; + + if(lvList.Items.Count < 2) { - foreach (ColumnHeader col in lvList.Columns) - { - if (!(col == chPriceS || col == chPriceLow || col == chPriceHigh)) - col.Width = -2; - } + foreach(ColumnHeader col in lvList.Columns) + col.Width = -2; } lock(m_URLs) @@ -597,7 +589,6 @@ namespace NewsCrawler ListViewItem item = lvList.Items.Cast().FirstOrDefault(s => s.SubItems[chId.Index].Text == Data.m_iID.ToString()); item.SubItems[chPriceLow.Index].Text = string.Format("{0:n0}", Data.m_iPriceLow); float fLowRate = (Data.m_iPriceLow-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart; - item.UseItemStyleForSubItems = false; item.SubItems[chPriceLowP.Index].Text = string.Format("{0:n}", fLowRate); if(fLowRate > 0) item.SubItems[chPriceLowP.Index].ForeColor = Color.Red; @@ -621,7 +612,6 @@ namespace NewsCrawler item.SubItems[chPriceLow.Index].Text = string.Format("{0:n0}", Data.m_iPriceLow); float fLowRate = (Data.m_iPriceLow-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart; item.SubItems[chPriceLowP.Index].Text = string.Format("{0:n}", fLowRate); - item.UseItemStyleForSubItems = false; if(fLowRate > 0) item.SubItems[chPriceLowP.Index].ForeColor = Color.Red; else if(fLowRate < 0) diff --git a/Util.cs b/Util.cs index 396b3e7..28a6877 100644 --- a/Util.cs +++ b/Util.cs @@ -30,6 +30,7 @@ namespace NewsCrawler delegate void InsertLogDelegate(RichTextBox LogBox, LOG_TYPE enType, string strLog); static InsertLogDelegate m_InsertLogDelegate = new InsertLogDelegate(InsertLog); + static object m_LogLock = new object(); public static void SetLogView(RichTextBox logBox) { @@ -104,7 +105,8 @@ namespace NewsCrawler string strTime = DateTime.Now.ToString("[HH:mm:ss:fff] "); string strMessage = strTime+strLogLevel+strLog; - File.AppendAllText(m_strLogFile, strMessage+Environment.NewLine, new UTF8Encoding(true)); + lock(m_LogLock) + File.AppendAllText(m_strLogFile, strMessage+Environment.NewLine, new UTF8Encoding(true)); if(m_LogBox != null) InsertLog(m_LogBox, enType, strMessage+Environment.NewLine);