계좌 선택 기능 추가

This commit is contained in:
2016-12-20 09:16:28 +09:00
parent 034c061a1b
commit a93faf9eb5
7 changed files with 156 additions and 29 deletions

View File

@@ -77,5 +77,22 @@ namespace NewsCrawler
m_Data["buy-price"] = iPrice.ToString();
Save();
}
public static void SetAccount(string strAccount, string strAccountSub)
{
m_Data["account"] = strAccount;
m_Data["sub-account"] = strAccountSub;
Save();
}
public static string GetAccount()
{
return m_Data["account"];
}
public static string GetSubAccount()
{
return m_Data["sub-account"];
}
}
}

54
ConfigForm.Designer.cs generated
View File

@@ -58,6 +58,10 @@
this.tbBuyPrice = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.cbAccount = new System.Windows.Forms.ComboBox();
this.tbAccountSub = new System.Windows.Forms.TextBox();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.btnAccountApply = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox6.SuspendLayout();
@@ -68,6 +72,7 @@
this.groupBox8.SuspendLayout();
this.groupBox9.SuspendLayout();
this.groupBox10.SuspendLayout();
this.groupBox11.SuspendLayout();
this.SuspendLayout();
//
// tbVolume
@@ -382,11 +387,51 @@
this.groupBox10.TabStop = false;
this.groupBox10.Text = "매수";
//
// cbAccount
//
this.cbAccount.FormattingEnabled = true;
this.cbAccount.Location = new System.Drawing.Point(14, 21);
this.cbAccount.Name = "cbAccount";
this.cbAccount.Size = new System.Drawing.Size(121, 20);
this.cbAccount.TabIndex = 16;
//
// tbAccountSub
//
this.tbAccountSub.Location = new System.Drawing.Point(141, 20);
this.tbAccountSub.Name = "tbAccountSub";
this.tbAccountSub.Size = new System.Drawing.Size(27, 21);
this.tbAccountSub.TabIndex = 17;
this.tbAccountSub.Text = "10";
this.tbAccountSub.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// groupBox11
//
this.groupBox11.Controls.Add(this.btnAccountApply);
this.groupBox11.Controls.Add(this.cbAccount);
this.groupBox11.Controls.Add(this.tbAccountSub);
this.groupBox11.Location = new System.Drawing.Point(10, 316);
this.groupBox11.Name = "groupBox11";
this.groupBox11.Size = new System.Drawing.Size(262, 57);
this.groupBox11.TabIndex = 18;
this.groupBox11.TabStop = false;
this.groupBox11.Text = "계좌";
//
// btnAccountApply
//
this.btnAccountApply.Location = new System.Drawing.Point(184, 10);
this.btnAccountApply.Name = "btnAccountApply";
this.btnAccountApply.Size = new System.Drawing.Size(72, 39);
this.btnAccountApply.TabIndex = 5;
this.btnAccountApply.Text = "적용";
this.btnAccountApply.UseVisualStyleBackColor = true;
this.btnAccountApply.Click += new System.EventHandler(this.btnAccountApply_Click);
//
// ConfigForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(548, 320);
this.ClientSize = new System.Drawing.Size(548, 385);
this.Controls.Add(this.groupBox11);
this.Controls.Add(this.groupBox10);
this.Controls.Add(this.groupBox9);
this.Controls.Add(this.groupBox2);
@@ -395,6 +440,7 @@
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "설정";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ConfigForm_FormClosing);
this.Load += new System.EventHandler(this.ConfigForm_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
@@ -408,6 +454,8 @@
this.groupBox9.ResumeLayout(false);
this.groupBox10.ResumeLayout(false);
this.groupBox10.PerformLayout();
this.groupBox11.ResumeLayout(false);
this.groupBox11.PerformLayout();
this.ResumeLayout(false);
}
@@ -443,5 +491,9 @@
private System.Windows.Forms.TextBox tbBuyPrice;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.GroupBox groupBox10;
private System.Windows.Forms.ComboBox cbAccount;
private System.Windows.Forms.TextBox tbAccountSub;
private System.Windows.Forms.GroupBox groupBox11;
private System.Windows.Forms.Button btnAccountApply;
}
}

View File

@@ -2,6 +2,7 @@
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Linq;
namespace NewsCrawler
{
@@ -19,6 +20,12 @@ namespace NewsCrawler
{
tbVolume.Text = Config.GetManualPrice().ToString();
tbBuyPrice.Text = Config.GetBuyPrice().ToString();
cbAccount.Items.Clear();
string[] Accounts = m_Listener.GetAccounts();
cbAccount.Items.AddRange(Accounts);
if(Config.GetAccount() != "" && Accounts.Contains(Config.GetAccount()))
cbAccount.SelectedItem = Config.GetAccount();
}
private void OpenFile(string strName)
@@ -124,5 +131,15 @@ namespace NewsCrawler
Config.SetBuyPrice(iPrice);
}
#endregion
private void btnAccountApply_Click(object sender, EventArgs e)
{
m_Listener.ApplyAccount(cbAccount.SelectedItem as string, tbAccountSub.Text);
}
private void ConfigForm_FormClosing(object sender, FormClosingEventArgs e)
{
m_Listener.OnConfigFormClosing();
}
}
}

View File

@@ -14,7 +14,6 @@ namespace NewsCrawler
DSCBO1Lib.StockMst m_CPStockMst = new DSCBO1Lib.StockMst();
CPTRADELib.CpTd0311 m_CP0311 = new CPTRADELib.CpTd0311();
bool m_bInitialized = false;
string m_strAccountNumber;
public CybosHelper()
{
@@ -42,9 +41,11 @@ namespace NewsCrawler
Util.Log(Util.LOG_TYPE.ERROR, "[TradeInit] 취소되었습니다");
break;
}
}
m_strAccountNumber = m_CPUtil.AccountNumber[0];
Util.Log(Util.LOG_TYPE.VERVOSE, string.Format("{0}개의 계좌 중 첫번째 계좌 {1}이 선택되었습니다", m_CPUtil.AccountNumber.Length, m_strAccountNumber));
public string[] GetAccounts()
{
return m_CPUtil.AccountNumber;
}
public int GetLimitRemainCountTrace()
@@ -82,10 +83,12 @@ namespace NewsCrawler
int iCount = iMaxPrice/iCurPrice;
m_CP0311.SetInputValue(0, 2);
m_CP0311.SetInputValue(1, m_strAccountNumber);
m_CP0311.SetInputValue(1, Config.GetAccount());
m_CP0311.SetInputValue(2, Config.GetSubAccount());
m_CP0311.SetInputValue(3, Code.m_strCode);
m_CP0311.SetInputValue(4, iCount);
m_CP0311.SetInputValue(5, 0);
m_CP0311.SetInputValue(7, "0");
m_CP0311.SetInputValue(8, "03");
m_CP0311.BlockRequest2(0);

View File

@@ -30,12 +30,13 @@
{
this.btnYes = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.tbMsg = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btnYes
//
this.btnYes.Location = new System.Drawing.Point(123, 67);
this.btnYes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnYes.Location = new System.Drawing.Point(164, 118);
this.btnYes.Name = "btnYes";
this.btnYes.Size = new System.Drawing.Size(75, 23);
this.btnYes.TabIndex = 0;
@@ -45,7 +46,8 @@
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(204, 67);
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.Location = new System.Drawing.Point(245, 118);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 1;
@@ -53,21 +55,22 @@
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// label1
// tbMsg
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(38, 12);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
this.tbMsg.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.tbMsg.Location = new System.Drawing.Point(12, 12);
this.tbMsg.Multiline = true;
this.tbMsg.Name = "tbMsg";
this.tbMsg.ReadOnly = true;
this.tbMsg.Size = new System.Drawing.Size(308, 100);
this.tbMsg.TabIndex = 3;
//
// ModelessPopup
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(291, 102);
this.Controls.Add(this.label1);
this.ClientSize = new System.Drawing.Size(332, 153);
this.Controls.Add(this.tbMsg);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnYes);
this.Name = "ModelessPopup";
@@ -81,6 +84,6 @@
private System.Windows.Forms.Button btnYes;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox tbMsg;
}
}

View File

@@ -25,7 +25,10 @@ namespace NewsCrawler
public void SetMessage(string strMsg, CodeList.CODE_VALUE Code)
{
m_Code = Code;
label1.Text = strMsg;
tbMsg.Text = "";
foreach(string strLine in strMsg.Split('\n'))
tbMsg.Text += strLine + Environment.NewLine;
}
private void btnYes_Click(object sender, EventArgs e)

View File

@@ -37,7 +37,6 @@ namespace NewsCrawler
Config.Init();
Util.SetLogView(tbLog);
m_ConfigForm = new ConfigForm(this);
m_CodeList = new CodeList();
m_Condition = new TextCondition();
@@ -65,9 +64,12 @@ namespace NewsCrawler
lvList.SelectedItems[0].EnsureVisible();
}
Console.WriteLine(string.Format("{0} ddd", m_CrawlTimer.SynchronizingObject));
Console.WriteLine(string.Format("init thread {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()));
m_CrawlTimer.Elapsed+=CrawlTimer_Tick;
m_CrawlTimer.Interval=m_iCrawlInterval;
m_CrawlTimer.Start();
m_CybosHelper = new CybosHelper();
@@ -131,7 +133,10 @@ namespace NewsCrawler
if(m_bBuy == true)
{
ModelessPopup ManualPopup = new ModelessPopup(this);
ManualPopup.SetMessage(string.Format("{0} 매수하시겠습니까?", Code.ToString()), Code);
ManualPopup.SetMessage(string.Format("{0}\n[{1}] {2}\n(keyword:{3}, code:{4})\n\n매수하시겠습니까?",
DateTime.Now.ToString("[hh:mm:ss]"),
strRef, strTitle, MatchResult.m_strKeyword, Code), Code);
ManualPopup.TopMost = true;
ManualPopup.Show();
}
break;
@@ -232,7 +237,7 @@ namespace NewsCrawler
}
catch(Exception e)
{
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
Console.WriteLine(e.ToString());
}
return bHasNew;
@@ -282,7 +287,7 @@ namespace NewsCrawler
}
catch(Exception e)
{
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
Console.WriteLine(e.ToString());
}
return bHasNew;
@@ -340,7 +345,7 @@ namespace NewsCrawler
}
catch(Exception e)
{
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
Console.WriteLine(e.ToString());
}
return bHasNew;
@@ -398,7 +403,7 @@ namespace NewsCrawler
}
catch(Exception e)
{
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
Console.WriteLine(e.ToString());
}
return bHasNew;
@@ -452,7 +457,7 @@ namespace NewsCrawler
}
catch(Exception e)
{
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
Console.WriteLine(e.ToString());
}
return bHasNew;
@@ -511,7 +516,7 @@ namespace NewsCrawler
}
catch(Exception e)
{
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
Console.WriteLine(e.ToString());
}
return bHasNew;
@@ -558,7 +563,7 @@ namespace NewsCrawler
}
catch(Exception e)
{
Util.Log(Util.LOG_TYPE.ERROR, e.ToString());
Console.WriteLine(e.ToString());
}
return bHasNew;
@@ -591,6 +596,8 @@ namespace NewsCrawler
{
m_CrawlTimer.Enabled = false;
Console.WriteLine(string.Format("timer thread {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()));
if(chAutoReload.Checked == true)
{
ReadKIND();
@@ -615,7 +622,7 @@ namespace NewsCrawler
string strURL = lvList.SelectedItems[0].SubItems[chLink.Index].Text;
wbView.ScriptErrorsSuppressed = true;
wbView.Navigate(strURL);
//wbView.Navigate(strURL);
}
private void tbInterval_KeyPress(object sender, KeyPressEventArgs e)
@@ -641,6 +648,9 @@ namespace NewsCrawler
private void btnConfig_Click(object sender, EventArgs e)
{
if(m_ConfigForm == null)
m_ConfigForm = new ConfigForm(this);
FormCollection OpenForms = Application.OpenForms;
bool bOpen = false;
foreach(Form form in OpenForms)
@@ -662,6 +672,11 @@ namespace NewsCrawler
}
}
public void OnConfigFormClosing()
{
m_ConfigForm = null;
}
public void OnManualCodeClick(int iPrice)
{
m_CodeList.MakeManualList(iPrice);
@@ -705,11 +720,28 @@ namespace NewsCrawler
{
m_bBuy = chBuy.Checked;
if(m_bBuy == true && Config.GetAccount() == "")
{
chBuy.Checked = false;
MessageBox.Show("계좌를 선택해주시기 바랍니다");
return;
}
if(m_bBuy == true)
Util.Log(Util.LOG_TYPE.VERVOSE, "매수 시작");
else
Util.Log(Util.LOG_TYPE.VERVOSE, "매수 취소");
}
public string[] GetAccounts()
{
return m_CybosHelper.GetAccounts();
}
public void ApplyAccount(string strAccount, string strAccountSub)
{
Config.SetAccount(strAccount, strAccountSub);
}
}