diff --git a/DataSaver/MainForm.Designer.cs b/DataSaver/MainForm.Designer.cs index 8f42afb..0b0fd02 100644 --- a/DataSaver/MainForm.Designer.cs +++ b/DataSaver/MainForm.Designer.cs @@ -36,9 +36,11 @@ this.label_ExchangePlace = new System.Windows.Forms.Label(); this.comboBoxEdit_ExchangePlace = new DevExpress.XtraEditors.ComboBoxEdit(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.button1 = new System.Windows.Forms.Button(); - this.textEdit_DbServerIp = new DevExpress.XtraEditors.TextEdit(); - this.label_DbServerIp = new System.Windows.Forms.Label(); + this.label_QueryStr = new System.Windows.Forms.Label(); + this.textEdit_SqLQuery = new DevExpress.XtraEditors.TextEdit(); + this.button_QueryTest = new System.Windows.Forms.Button(); + this.button_TotalDataSave = new System.Windows.Forms.Button(); + this.button_ExchangePlaceSave = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit(); this.panelControl1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.listBoxControl_logViewer)).BeginInit(); @@ -47,7 +49,7 @@ this.groupBox_ButtonMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_ExchangePlace.Properties)).BeginInit(); this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.textEdit_DbServerIp.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_SqLQuery.Properties)).BeginInit(); this.SuspendLayout(); // // panelControl1 @@ -81,17 +83,19 @@ // this.groupBox_ButtonMenu.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox_ButtonMenu.Controls.Add(this.button_ExchangePlaceSave); + this.groupBox_ButtonMenu.Controls.Add(this.button_TotalDataSave); this.groupBox_ButtonMenu.Controls.Add(this.button_CreateTable); - this.groupBox_ButtonMenu.Location = new System.Drawing.Point(5, 64); + this.groupBox_ButtonMenu.Location = new System.Drawing.Point(5, 97); this.groupBox_ButtonMenu.Name = "groupBox_ButtonMenu"; - this.groupBox_ButtonMenu.Size = new System.Drawing.Size(679, 95); + this.groupBox_ButtonMenu.Size = new System.Drawing.Size(679, 96); this.groupBox_ButtonMenu.TabIndex = 0; this.groupBox_ButtonMenu.TabStop = false; this.groupBox_ButtonMenu.Text = "메뉴"; // // button_CreateTable // - this.button_CreateTable.Location = new System.Drawing.Point(6, 21); + this.button_CreateTable.Location = new System.Drawing.Point(102, 21); this.button_CreateTable.Name = "button_CreateTable"; this.button_CreateTable.Size = new System.Drawing.Size(75, 23); this.button_CreateTable.TabIndex = 0; @@ -122,40 +126,60 @@ | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.label_ExchangePlace); this.groupBox1.Controls.Add(this.comboBoxEdit_ExchangePlace); - this.groupBox1.Controls.Add(this.label_DbServerIp); - this.groupBox1.Controls.Add(this.textEdit_DbServerIp); - this.groupBox1.Controls.Add(this.button1); + this.groupBox1.Controls.Add(this.label_QueryStr); + this.groupBox1.Controls.Add(this.textEdit_SqLQuery); + this.groupBox1.Controls.Add(this.button_QueryTest); this.groupBox1.Location = new System.Drawing.Point(5, 5); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(679, 53); + this.groupBox1.Size = new System.Drawing.Size(679, 73); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "DB 접속"; // - // button1 + // label_QueryStr // - this.button1.Location = new System.Drawing.Point(382, 20); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 0; - this.button1.Text = "연결"; - this.button1.UseVisualStyleBackColor = true; + this.label_QueryStr.AutoSize = true; + this.label_QueryStr.Location = new System.Drawing.Point(17, 50); + this.label_QueryStr.Name = "label_QueryStr"; + this.label_QueryStr.Size = new System.Drawing.Size(39, 14); + this.label_QueryStr.TabIndex = 4; + this.label_QueryStr.Text = "쿼리 : "; // - // textEdit_DbServerIp + // textEdit_SqLQuery // - this.textEdit_DbServerIp.Location = new System.Drawing.Point(244, 21); - this.textEdit_DbServerIp.Name = "textEdit_DbServerIp"; - this.textEdit_DbServerIp.Size = new System.Drawing.Size(121, 20); - this.textEdit_DbServerIp.TabIndex = 1; + this.textEdit_SqLQuery.Location = new System.Drawing.Point(62, 47); + this.textEdit_SqLQuery.Name = "textEdit_SqLQuery"; + this.textEdit_SqLQuery.Size = new System.Drawing.Size(537, 20); + this.textEdit_SqLQuery.TabIndex = 1; // - // label_DbServerIp + // button_QueryTest // - this.label_DbServerIp.AutoSize = true; - this.label_DbServerIp.Location = new System.Drawing.Point(175, 24); - this.label_DbServerIp.Name = "label_DbServerIp"; - this.label_DbServerIp.Size = new System.Drawing.Size(63, 14); - this.label_DbServerIp.TabIndex = 4; - this.label_DbServerIp.Text = "서버 주소 : "; + this.button_QueryTest.Location = new System.Drawing.Point(605, 46); + this.button_QueryTest.Name = "button_QueryTest"; + this.button_QueryTest.Size = new System.Drawing.Size(68, 23); + this.button_QueryTest.TabIndex = 0; + this.button_QueryTest.Text = "보내기"; + this.button_QueryTest.UseVisualStyleBackColor = true; + this.button_QueryTest.Click += new System.EventHandler(this.button_QueryTest_Click); + // + // button_TotalDataSave + // + this.button_TotalDataSave.Location = new System.Drawing.Point(7, 50); + this.button_TotalDataSave.Name = "button_TotalDataSave"; + this.button_TotalDataSave.Size = new System.Drawing.Size(108, 23); + this.button_TotalDataSave.TabIndex = 0; + this.button_TotalDataSave.Text = "전 종목 데이터 누적"; + this.button_TotalDataSave.UseVisualStyleBackColor = true; + // + // button_ExchangePlaceSave + // + this.button_ExchangePlaceSave.Location = new System.Drawing.Point(10, 21); + this.button_ExchangePlaceSave.Name = "button_ExchangePlaceSave"; + this.button_ExchangePlaceSave.Size = new System.Drawing.Size(86, 23); + this.button_ExchangePlaceSave.TabIndex = 0; + this.button_ExchangePlaceSave.Text = "종목 업데이트"; + this.button_ExchangePlaceSave.UseVisualStyleBackColor = true; + this.button_ExchangePlaceSave.Click += new System.EventHandler(this.button_ExchangePlaceSave_Click); // // MainForm // @@ -175,7 +199,7 @@ ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_ExchangePlace.Properties)).EndInit(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.textEdit_DbServerIp.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.textEdit_SqLQuery.Properties)).EndInit(); this.ResumeLayout(false); } @@ -190,9 +214,11 @@ private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Label label_ExchangePlace; private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit_ExchangePlace; - private System.Windows.Forms.Label label_DbServerIp; - private DevExpress.XtraEditors.TextEdit textEdit_DbServerIp; - private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label_QueryStr; + private DevExpress.XtraEditors.TextEdit textEdit_SqLQuery; + private System.Windows.Forms.Button button_QueryTest; + private System.Windows.Forms.Button button_TotalDataSave; + private System.Windows.Forms.Button button_ExchangePlaceSave; } } diff --git a/DataSaver/MainForm.cs b/DataSaver/MainForm.cs index 486897c..7fae904 100644 --- a/DataSaver/MainForm.cs +++ b/DataSaver/MainForm.cs @@ -19,31 +19,40 @@ namespace DataSaver initForm(); } + /// + /// 초기 동작 + /// private void initForm() { - // DB 서버 정보 생성 - var strConn = "Data Source=192.168.0.21;uid=sqlm;pwd=12345678;Database=Upbit"; - - // DB Connection 생성하기 - // 거래소 정보 콤보박스 초기화 comboBoxEdit_ExchangePlace.Properties.Items.Clear(); // Million으로부터 거래소 정보 가져오기 comboBoxEdit_ExchangePlace.Properties.Items.AddRange(Enum.GetNames(typeof(Million.CommonProperty.ExchangePlace))); comboBoxEdit_ExchangePlace.SelectedIndex = 0; - + // DB 서버 정보 생성 + var strConn = Million.CommonProperty.DbConnectionStr + comboBoxEdit_ExchangePlace.EditValue; + Million.CommonProperty.curDBConStrDataSaver = strConn; } - private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) + /// + /// 쿼리 테스트 버튼 클릭 + /// + /// + /// + private void button_QueryTest_Click(object sender, EventArgs e) { - // Table 없으면 추가 - /* - if not exists(select * from sysobjects where name = 'krw_btc' and xtype = 'U') - create table krw_btc( - Name varchar(64) not null - ) - go*/ + Million.FileDBManagement.DBConnection.DataBasaConnection(Million.CommonProperty.curDBConStrDataSaver, textEdit_SqLQuery.Text); + } + + /// + /// 종목 업데이트 버튼 클릭 + /// + /// + /// + private void button_ExchangePlaceSave_Click(object sender, EventArgs e) + { + //illion. } } } diff --git a/Million/CommonProperty.cs b/Million/CommonProperty.cs index 95722cd..7ed04a1 100644 --- a/Million/CommonProperty.cs +++ b/Million/CommonProperty.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -27,15 +28,28 @@ namespace Million Upbit = 1 } - // 캔들 데이터 (1분) - // 캔들 데이터 (3분) - // 캔들 데이터 (5분) - // 캔들 데이터 (10분) - // 캔들 데이터 (30분) - // 캔들 데이터 (1시간) - // 캔들 데이터 (6시간) - // 캔들 데이터 (12시간) - // 캔들 데이터 (24시간) + /// + /// TODO 업비트 기능 추가 + /// + // 빗썸 Web 요청 타입 + public enum ExchangeWebReqType + { + #region 빗썸 웹 요청 타입 + [Description("/Public/CandleStick")] + BithumCandleStick = 0, + [Description("/public/ticker")] + BithumCandleTicker = 1, + [Description("/public/Orderbook")] + BithumCoinGoods = 2, + #endregion + + #region 업비트 웹 요청 타입 + UpbitCoinGoods = 11 + #endregion + + } + + // 캔들 데이터 (1분) (3분) (5분) (10분) (30분) (1시간) (6시간) (12시간) (24시간) public enum CanldeTimeType { M1 = 1, M3 = 3, M5= 5, M10 = 10, M30 = 30, H1 = 60, H6 = 360, M12 = 720, D1 = 1440 @@ -77,9 +91,9 @@ namespace Million #region # 데이터 베이스 정보 # - - public static string DbServerIP = "192.168.0.21"; - //public static string + public static string DbConnectionStr = "Data Source=192.168.0.21;uid=sqlm;pwd=12345678;Database="; + public static string curDBConStrMillion = "Data Source=192.168.0.21;uid=sqlm;pwd=12345678;Database="; + public static string curDBConStrDataSaver = "Data Source=192.168.0.21;uid=sqlm;pwd=12345678;Database="; #endregion } } diff --git a/Million/FileDBManagement/DBConnection.cs b/Million/FileDBManagement/DBConnection.cs index 23d0e2b..dc789b3 100644 --- a/Million/FileDBManagement/DBConnection.cs +++ b/Million/FileDBManagement/DBConnection.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; +using DevExpress.DashboardWin.Design; namespace Million.FileDBManagement { @@ -24,5 +26,33 @@ namespace Million.FileDBManagement } return resultstring; } + + public static bool DataBasaConnection(string dbConStr, string sqlQuery) + { + using (var conn = new SqlConnection(dbConStr)) + using (var cmd = new SqlCommand(sqlQuery, conn)) + { + try + { + conn.Open(); + using (var rdr = cmd.ExecuteReader()) + { + while (rdr.Read()) { } + + rdr.Close(); + } + conn.Close(); + } + catch (Exception ex) + { + Console.WriteLine(" ============= exception ==============="); + Console.WriteLine(ex.Message); + conn.Close(); + return false; + } + } + + return true; + } } }