Compare commits
2 Commits
1cd307b45a
...
9864e46d5f
| Author | SHA1 | Date | |
|---|---|---|---|
| 9864e46d5f | |||
| 6ca9067be0 |
@@ -157,6 +157,13 @@ namespace NewsCrawler
|
||||
LoadCodeType(strPath, CODE_TYPE.DENIAL);
|
||||
}
|
||||
|
||||
public void ClearDuplicatedList()
|
||||
{
|
||||
string strPath = Util.GetConfigPath() + "/code-duplicated.txt";
|
||||
File.WriteAllBytes(strPath, new byte[] { });
|
||||
LoadCodeType(strPath, CODE_TYPE.DUPLICATED);
|
||||
}
|
||||
|
||||
public void LoadDuplicatedList()
|
||||
{
|
||||
string strPath = Util.GetConfigPath()+"/code-duplicated.txt";
|
||||
|
||||
2
ConfigForm.Designer.cs
generated
2
ConfigForm.Designer.cs
generated
@@ -658,7 +658,7 @@
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(132, 12);
|
||||
this.label9.TabIndex = 20;
|
||||
this.label9.Text = "Version : 2018.01.04.12";
|
||||
this.label9.Text = "Version : 2018.12.04.13";
|
||||
//
|
||||
// cbMockTrading
|
||||
//
|
||||
|
||||
14
NewsForm.Designer.cs
generated
14
NewsForm.Designer.cs
generated
@@ -58,6 +58,7 @@
|
||||
this.chBuy = new System.Windows.Forms.CheckBox();
|
||||
this.cbPriceCheck = new System.Windows.Forms.CheckBox();
|
||||
this.btnManualBuy = new System.Windows.Forms.Button();
|
||||
this.btClearDuplicate = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
@@ -317,11 +318,23 @@
|
||||
this.btnManualBuy.UseVisualStyleBackColor = true;
|
||||
this.btnManualBuy.Click += new System.EventHandler(this.btnManualBuy_Click);
|
||||
//
|
||||
// btClearDuplicate
|
||||
//
|
||||
this.btClearDuplicate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btClearDuplicate.Location = new System.Drawing.Point(864, 3);
|
||||
this.btClearDuplicate.Name = "btClearDuplicate";
|
||||
this.btClearDuplicate.Size = new System.Drawing.Size(91, 23);
|
||||
this.btClearDuplicate.TabIndex = 12;
|
||||
this.btClearDuplicate.Text = "중복종목 삭제";
|
||||
this.btClearDuplicate.UseVisualStyleBackColor = true;
|
||||
this.btClearDuplicate.Click += new System.EventHandler(this.btClearDuplicate_Click);
|
||||
//
|
||||
// NewsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1040, 649);
|
||||
this.Controls.Add(this.btClearDuplicate);
|
||||
this.Controls.Add(this.btnManualBuy);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Controls.Add(this.cbPriceCheck);
|
||||
@@ -378,6 +391,7 @@
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;
|
||||
private System.Windows.Forms.ColumnHeader chCodeName;
|
||||
private System.Windows.Forms.Button btnManualBuy;
|
||||
private System.Windows.Forms.Button btClearDuplicate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
100
NewsForm.cs
100
NewsForm.cs
@@ -79,24 +79,17 @@ namespace NewsCrawler
|
||||
int m_iCrawlInterval = 500;
|
||||
bool m_bBuy = false;
|
||||
|
||||
List<string> m_URLs = new List<string>();
|
||||
ConcurrentQueue<ListViewItem> m_NewItems = new ConcurrentQueue<ListViewItem>();
|
||||
ConcurrentBag<string> m_URLs = new ConcurrentBag<string>();
|
||||
|
||||
System.Timers.Timer m_SystemTimer = new System.Timers.Timer();
|
||||
|
||||
ConcurrentQueue<PRICE_CHECK_DATA> m_PriceCheckList = new ConcurrentQueue<PRICE_CHECK_DATA>();
|
||||
System.Timers.Timer m_PriceCheckTimer = new System.Timers.Timer();
|
||||
|
||||
delegate void InsertListView(string strTitle, string strName, string strCode, DateTime time, DateTime ResTime, string strURL, string strRef, double responseT, bool bInitial);
|
||||
InsertListView m_InsertListViewDelegate = null;
|
||||
|
||||
Crawler m_Crawler = null;
|
||||
|
||||
ExcelHandler m_Excel = null;
|
||||
|
||||
object m_lvListLock = new object();
|
||||
|
||||
|
||||
|
||||
|
||||
public NewsForm()
|
||||
{
|
||||
@@ -116,8 +109,6 @@ namespace NewsCrawler
|
||||
|
||||
//MessageBox.Show("Keywords : \n\n" + m_Condition.GetKeywordsCnt());
|
||||
|
||||
m_InsertListViewDelegate = new InsertListView(this.InsertItem);
|
||||
|
||||
m_Crawler.ReadKIND(true);
|
||||
m_Crawler.ReadDart(true);
|
||||
m_Crawler.ReadEtoday(true);
|
||||
@@ -532,30 +523,21 @@ namespace NewsCrawler
|
||||
if(strURL == "")
|
||||
return false;
|
||||
|
||||
lock(m_URLs)
|
||||
return m_URLs.Any(s => s == strURL);
|
||||
return m_URLs.Any(s => s == strURL);
|
||||
}
|
||||
|
||||
public void InsertItem(string strTitle, string strName, string strCode, DateTime time, DateTime ResTime, string strURL, string strRef, double dElapseT, bool bInitial)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(m_InsertListViewDelegate, strTitle, strName, strCode, time, ResTime, strURL, strRef, dElapseT, bInitial);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(IsDuplicatedURL(strURL) == true)
|
||||
return;
|
||||
if (IsDuplicatedURL(strURL) == true)
|
||||
return;
|
||||
|
||||
int iID = lvList.Items.Count+1;
|
||||
int iID = lvList.Items.Count + 1;
|
||||
|
||||
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));
|
||||
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));
|
||||
|
||||
var AddedItem = lvList.Items.Add(new ListViewItem(new string[] {
|
||||
var newItem = new ListViewItem(new string[] {
|
||||
iID.ToString(),
|
||||
time.ToString("HH:mm:ss"),
|
||||
ResTime.ToString("HH:mm:ss:fff"),
|
||||
@@ -568,31 +550,42 @@ namespace NewsCrawler
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
strURL }));
|
||||
strURL });
|
||||
newItem.UseItemStyleForSubItems = false;
|
||||
if (Code == null && strCode != "")
|
||||
newItem.SubItems[chCodeName.Index].BackColor = Color.Gray;
|
||||
|
||||
AddedItem.UseItemStyleForSubItems = false;
|
||||
if(Code == null && strCode != "")
|
||||
AddedItem.SubItems[chCodeName.Index].BackColor = Color.Gray;
|
||||
m_NewItems.Enqueue(newItem);
|
||||
m_URLs.Add(strURL);
|
||||
|
||||
if(lvList.Items.Count < 2)
|
||||
Action insert = delegate
|
||||
{
|
||||
if (m_NewItems.IsEmpty == false)
|
||||
{
|
||||
List<ListViewItem> itemList = new List<ListViewItem>();
|
||||
ListViewItem item;
|
||||
while (m_NewItems.TryDequeue(out item))
|
||||
itemList.Add(item);
|
||||
|
||||
lvList.BeginUpdate();
|
||||
lvList.Items.AddRange(itemList.ToArray());
|
||||
if (lvList.Items.Count < 2)
|
||||
{
|
||||
foreach(ColumnHeader col in lvList.Columns)
|
||||
foreach (ColumnHeader col in lvList.Columns)
|
||||
col.Width = -2;
|
||||
}
|
||||
|
||||
lock(m_URLs)
|
||||
m_URLs.Add(strURL);
|
||||
|
||||
if(bInitial == false)
|
||||
if (bInitial == false)
|
||||
lvList.Sort();
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Util.Log(Util.LOG_TYPE.ERROR, ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
lvList.EndUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
if (lvList.InvokeRequired)
|
||||
lvList.Invoke(insert);
|
||||
else
|
||||
insert();
|
||||
}
|
||||
|
||||
private void SystemTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
@@ -639,6 +632,9 @@ namespace NewsCrawler
|
||||
|
||||
private void UpdateStartPrice(int iID, int iPrice)
|
||||
{
|
||||
if (iID < 0)
|
||||
return;
|
||||
|
||||
if(lvList.InvokeRequired)
|
||||
{
|
||||
lvList.BeginInvoke((MethodInvoker)delegate ()
|
||||
@@ -774,9 +770,11 @@ namespace NewsCrawler
|
||||
{
|
||||
SortOrder Order = (lvList.Sorting == SortOrder.Descending || lvList.Sorting == SortOrder.None) ? SortOrder.Ascending : SortOrder.Descending;
|
||||
|
||||
lvList.BeginUpdate();
|
||||
lvList.ListViewItemSorter = new ListViewItemComparer(e.Column, Order);
|
||||
lvList.Sorting = Order;
|
||||
lvList.Sort();
|
||||
lvList.EndUpdate();
|
||||
}
|
||||
|
||||
private void lvList_DoubleClick(object sender, EventArgs e)
|
||||
@@ -1009,6 +1007,13 @@ namespace NewsCrawler
|
||||
{
|
||||
Config.SetAccount(strAccount, strAccountSub);
|
||||
}
|
||||
|
||||
private void btClearDuplicate_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult dialogResult = MessageBox.Show("중복 종목을 삭제합니다", "확인", MessageBoxButtons.YesNo);
|
||||
if(dialogResult == DialogResult.Yes)
|
||||
m_CodeList.ClearDuplicatedList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1033,7 +1038,10 @@ namespace NewsCrawler
|
||||
if(double.TryParse(item1.SubItems[m_iColumn].Text, out num1) &&
|
||||
double.TryParse(item2.SubItems[m_iColumn].Text, out num2))
|
||||
{
|
||||
return (num1>num2)?1:-1;
|
||||
if (m_Order == SortOrder.Ascending)
|
||||
return (num1 > num2) ? 1 : -1;
|
||||
else
|
||||
return (num1 > num2) ? -1 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
14
Program.cs
14
Program.cs
@@ -14,16 +14,16 @@ namespace NewsCrawler
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
//try
|
||||
//{
|
||||
try
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new NewsForm());
|
||||
//}
|
||||
//catch(Exception ex)
|
||||
//{
|
||||
// Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
//}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user