- DartAPI 요청 버그 수정

- 8092 종목명 찾기 수정
- 실패한 종목명 배경색 추가
This commit is contained in:
2017-02-05 16:55:15 +09:00
parent f33be2f4eb
commit 994e0168a8
4 changed files with 21 additions and 28 deletions

View File

@@ -221,7 +221,7 @@ namespace NewsCrawler
public static bool CheckRightsIssue() public static bool CheckRightsIssue()
{ {
return (bool)m_Data["ann-ann-rights-issue"]; return (bool)m_Data["ann-rights-issue"];
} }
public static bool CheckPatent() public static bool CheckPatent()

View File

@@ -692,7 +692,8 @@ namespace NewsCrawler
return; return;
} }
foreach(var data in jObj["list"]) var List = jObj["list"];
foreach(var data in List)
{ {
string strTime = "00:00"; string strTime = "00:00";
string strTitle = data["rpt_nm"]; string strTitle = data["rpt_nm"];
@@ -728,8 +729,8 @@ namespace NewsCrawler
public void ReadDartAPI(bool bInitial = false) public void ReadDartAPI(bool bInitial = false)
{ {
if (Util.IsDebugging() == true) //if (Util.IsDebugging() == true)
return; // return;
if(m_iDartAPIRetry <= 0) if(m_iDartAPIRetry <= 0)
return; return;
@@ -737,7 +738,7 @@ namespace NewsCrawler
try try
{ {
string strAuthKey = Config.GetDartAPIKey(); 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; HttpWebRequest HttpReq = WebRequest.Create(strURL) as HttpWebRequest;
HttpReq.Credentials = CredentialCache.DefaultCredentials; HttpReq.Credentials = CredentialCache.DefaultCredentials;
HttpReq.Timeout = 2000; HttpReq.Timeout = 2000;

View File

@@ -475,27 +475,18 @@ namespace NewsCrawler
int iID = lvList.Items.Count+1; int iID = lvList.Items.Count+1;
CodeList.CODE_VALUE Code = null; CodeList.CODE_VALUE Code = m_CodeList.SearchCode(strTitle);
if(bInitial == false) if(bInitial == false && Code != null)
{
if(strCode == "")
Code = m_CodeList.SearchCode(strTitle);
else
Code = m_CodeList.GetCode(strCode);
if(Code != null)
ProcessSearchAndBuy(new NEWS_ITEM(iID, strTitle, strCode, Code, time, ResTime, strRef, strURL, (float)dElapseT)); ProcessSearchAndBuy(new NEWS_ITEM(iID, strTitle, strCode, Code, time, ResTime, strRef, strURL, (float)dElapseT));
}
var AddedItem = lvList.Items.Add(new ListViewItem(new string[] {
lvList.Items.Add(new ListViewItem(new string[] {
iID.ToString(), iID.ToString(),
time.ToString("HH:mm:ss"), time.ToString("HH:mm:ss"),
ResTime.ToString("HH:mm:ss:fff"), ResTime.ToString("HH:mm:ss:fff"),
string.Format("{0:n3} ms", dElapseT), string.Format("{0:n3} ms", dElapseT),
strRef, strRef,
strTitle, strTitle,
(Code != null) ? Code.m_strName : "", (Code != null) ? Code.m_strName : strName,
"", "",
"", "",
"", "",
@@ -503,14 +494,15 @@ namespace NewsCrawler
"", "",
strURL })); 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) foreach(ColumnHeader col in lvList.Columns)
{
if (!(col == chPriceS || col == chPriceLow || col == chPriceHigh))
col.Width = -2; col.Width = -2;
} }
}
lock(m_URLs) lock(m_URLs)
m_URLs.Add(strURL); m_URLs.Add(strURL);
@@ -597,7 +589,6 @@ namespace NewsCrawler
ListViewItem item = lvList.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chId.Index].Text == Data.m_iID.ToString()); ListViewItem item = lvList.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chId.Index].Text == Data.m_iID.ToString());
item.SubItems[chPriceLow.Index].Text = string.Format("{0:n0}", Data.m_iPriceLow); 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; 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); item.SubItems[chPriceLowP.Index].Text = string.Format("{0:n}", fLowRate);
if(fLowRate > 0) if(fLowRate > 0)
item.SubItems[chPriceLowP.Index].ForeColor = Color.Red; 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); 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; float fLowRate = (Data.m_iPriceLow-Data.m_iPriceStart)*100/(float)Data.m_iPriceStart;
item.SubItems[chPriceLowP.Index].Text = string.Format("{0:n}", fLowRate); item.SubItems[chPriceLowP.Index].Text = string.Format("{0:n}", fLowRate);
item.UseItemStyleForSubItems = false;
if(fLowRate > 0) if(fLowRate > 0)
item.SubItems[chPriceLowP.Index].ForeColor = Color.Red; item.SubItems[chPriceLowP.Index].ForeColor = Color.Red;
else if(fLowRate < 0) else if(fLowRate < 0)

View File

@@ -30,6 +30,7 @@ namespace NewsCrawler
delegate void InsertLogDelegate(RichTextBox LogBox, LOG_TYPE enType, string strLog); delegate void InsertLogDelegate(RichTextBox LogBox, LOG_TYPE enType, string strLog);
static InsertLogDelegate m_InsertLogDelegate = new InsertLogDelegate(InsertLog); static InsertLogDelegate m_InsertLogDelegate = new InsertLogDelegate(InsertLog);
static object m_LogLock = new object();
public static void SetLogView(RichTextBox logBox) public static void SetLogView(RichTextBox logBox)
{ {
@@ -104,6 +105,7 @@ namespace NewsCrawler
string strTime = DateTime.Now.ToString("[HH:mm:ss:fff] "); string strTime = DateTime.Now.ToString("[HH:mm:ss:fff] ");
string strMessage = strTime+strLogLevel+strLog; string strMessage = strTime+strLogLevel+strLog;
lock(m_LogLock)
File.AppendAllText(m_strLogFile, strMessage+Environment.NewLine, new UTF8Encoding(true)); File.AppendAllText(m_strLogFile, strMessage+Environment.NewLine, new UTF8Encoding(true));
if(m_LogBox != null) if(m_LogBox != null)
InsertLog(m_LogBox, enType, strMessage+Environment.NewLine); InsertLog(m_LogBox, enType, strMessage+Environment.NewLine);