diff --git a/DataSaver/MainForm.Designer.cs b/DataSaver/MainForm.Designer.cs index f8a78b0..c912fc6 100644 --- a/DataSaver/MainForm.Designer.cs +++ b/DataSaver/MainForm.Designer.cs @@ -45,9 +45,6 @@ this.button_AllMarketDataAcc = new System.Windows.Forms.Button(); this.button_SelectedMarketDataAcc = new System.Windows.Forms.Button(); this.comboBoxEdit1 = new DevExpress.XtraEditors.ComboBoxEdit(); - this.comboBoxEdit_Payment = new DevExpress.XtraEditors.ComboBoxEdit(); - this.bt_RealTimeSave = new DevExpress.XtraEditors.SimpleButton(); - this.bt_RealTimeCancel = new DevExpress.XtraEditors.SimpleButton(); ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit(); this.panelControl1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.listBoxControl_logViewer)).BeginInit(); @@ -59,7 +56,6 @@ ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_PaymentType.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_MarketInfo.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit1.Properties)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_Payment.Properties)).BeginInit(); this.SuspendLayout(); // // panelControl1 @@ -68,7 +64,7 @@ this.panelControl1.Dock = System.Windows.Forms.DockStyle.Right; this.panelControl1.Location = new System.Drawing.Point(246, 0); this.panelControl1.Name = "panelControl1"; - this.panelControl1.Size = new System.Drawing.Size(227, 550); + this.panelControl1.Size = new System.Drawing.Size(227, 441); this.panelControl1.TabIndex = 0; // // listBoxControl_logViewer @@ -76,20 +72,17 @@ this.listBoxControl_logViewer.Dock = System.Windows.Forms.DockStyle.Fill; this.listBoxControl_logViewer.Location = new System.Drawing.Point(2, 2); this.listBoxControl_logViewer.Name = "listBoxControl_logViewer"; - this.listBoxControl_logViewer.Size = new System.Drawing.Size(223, 546); + this.listBoxControl_logViewer.Size = new System.Drawing.Size(223, 437); this.listBoxControl_logViewer.TabIndex = 0; // // panelControl2 // - this.panelControl2.Controls.Add(this.bt_RealTimeCancel); - this.panelControl2.Controls.Add(this.bt_RealTimeSave); - this.panelControl2.Controls.Add(this.comboBoxEdit_Payment); this.panelControl2.Controls.Add(this.groupBox_DB접속); this.panelControl2.Controls.Add(this.groupBox_데이터누적); this.panelControl2.Dock = System.Windows.Forms.DockStyle.Fill; this.panelControl2.Location = new System.Drawing.Point(0, 0); this.panelControl2.Name = "panelControl2"; - this.panelControl2.Size = new System.Drawing.Size(246, 550); + this.panelControl2.Size = new System.Drawing.Size(246, 441); this.panelControl2.TabIndex = 1; // // groupBox_DB접속 @@ -244,38 +237,11 @@ this.comboBoxEdit1.Size = new System.Drawing.Size(100, 20); this.comboBoxEdit1.TabIndex = 2; // - // comboBoxEdit_Payment - // - this.comboBoxEdit_Payment.Location = new System.Drawing.Point(26, 445); - this.comboBoxEdit_Payment.Name = "comboBoxEdit_Payment"; - this.comboBoxEdit_Payment.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { - new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.comboBoxEdit_Payment.Size = new System.Drawing.Size(183, 20); - this.comboBoxEdit_Payment.TabIndex = 1; - // - // bt_RealTimeSave - // - this.bt_RealTimeSave.Location = new System.Drawing.Point(26, 472); - this.bt_RealTimeSave.Name = "bt_RealTimeSave"; - this.bt_RealTimeSave.Size = new System.Drawing.Size(183, 23); - this.bt_RealTimeSave.TabIndex = 2; - this.bt_RealTimeSave.Text = "실시간 데이터 저장"; - this.bt_RealTimeSave.Click += new System.EventHandler(this.bt_RealTimeSave_Click); - // - // bt_RealTimeCancel - // - this.bt_RealTimeCancel.Location = new System.Drawing.Point(27, 502); - this.bt_RealTimeCancel.Name = "bt_RealTimeCancel"; - this.bt_RealTimeCancel.Size = new System.Drawing.Size(182, 23); - this.bt_RealTimeCancel.TabIndex = 3; - this.bt_RealTimeCancel.Text = "실시간 데이터 저장 취소"; - this.bt_RealTimeCancel.Click += new System.EventHandler(this.bt_RealTimeCancel_Click); - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(473, 550); + this.ClientSize = new System.Drawing.Size(473, 441); this.Controls.Add(this.comboBoxEdit1); this.Controls.Add(this.panelControl2); this.Controls.Add(this.panelControl1); @@ -294,7 +260,6 @@ ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_PaymentType.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_MarketInfo.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit1.Properties)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_Payment.Properties)).EndInit(); this.ResumeLayout(false); } @@ -317,10 +282,7 @@ private System.Windows.Forms.Label label_종목이름; private System.Windows.Forms.CheckedListBox checkedListBox1; private System.Windows.Forms.Label label1; - private DevExpress.XtraEditors.SimpleButton bt_RealTimeSave; - private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit_Payment; private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit1; - private DevExpress.XtraEditors.SimpleButton bt_RealTimeCancel; } } diff --git a/DataSaver/MainForm.cs b/DataSaver/MainForm.cs index 5b0bca7..1311e2b 100644 --- a/DataSaver/MainForm.cs +++ b/DataSaver/MainForm.cs @@ -57,10 +57,7 @@ namespace DataSaver for (int i = 0; i < checkedListBox1.Items.Count; i++) { checkedListBox1.SetItemChecked(i, true); - } - - comboBoxEdit_Payment.Properties.Items.AddRange(Enum.GetNames(enumType: typeof(Million.CommonProperty.PaymentType))); - comboBoxEdit_Payment.SelectedIndex = 0; + } } /// @@ -143,7 +140,7 @@ namespace DataSaver var recentlyDbDataList = Million.DbManagement.DbServiceFunctions.GetOldNewDataList_FromDB (marketList, placeName, (CommonProperty.MCandleTimeType)item); - Million.DbManagement.DbServiceFunctions.SetCandleData(placeName, type, recentlyDbDataList, (CommonProperty.MCandleTimeType)item); + //Million.DbManagement.DbServiceFunctions.SetCandleData(placeName, type, recentlyDbDataList, (CommonProperty.MCandleTimeType)item); } MessageBox.Show("Completed Set Candle Data"); } @@ -224,28 +221,5 @@ namespace DataSaver if(!string.IsNullOrWhiteSpace(sqlQuery)) Million.DbManagement.DBConnection.QueryUpdateExcuter(CommonProperty.DbConnectionMarket, sqlQuery); } - - /// - /// 실시간 데이터 저장 - /// - /// - /// - private void bt_RealTimeSave_Click(object sender, EventArgs e) - { - CommonProperty.RealTimeFlag = true; - var payment = comboBoxEdit_Payment.SelectedItem.ToString(); - - DbServiceFunctions.SetRealTimeCandleData(payment, comboBoxEdit_ExchangePlace.SelectedItem.ToString()); - } - - /// - /// 실시간 데이터 저장 기능 취소 - /// - /// - /// - private void bt_RealTimeCancel_Click(object sender, EventArgs e) - { - CommonProperty.RealTimeFlag = false; - } } } diff --git a/Million/DbMangement/DBConnection.cs b/Million/DbMangement/DBConnection.cs index b99883e..084c861 100644 --- a/Million/DbMangement/DBConnection.cs +++ b/Million/DbMangement/DBConnection.cs @@ -93,42 +93,42 @@ namespace Million.DbManagement try { conn.Open(); - using (SqlDataAdapter sda = new SqlDataAdapter()) - { - cmd.Connection = conn; - sda.SelectCommand = cmd; - using (DataSet ds = new DataSet()) - { - sda.Fill(ds); + //using (SqlDataAdapter sda = new SqlDataAdapter()) + //{ + // cmd.Connection = conn; + // sda.SelectCommand = cmd; + // using (DataSet ds = new DataSet()) + // { + // sda.Fill(ds); + // } + //} + + + using (var rdr = cmd.ExecuteReader()) + { + while (rdr.Read()) + { + var dateTime = rdr["DateTime"]?.ToString(); + double.TryParse(rdr["StartValue"]?.ToString(), out var startValue); + double.TryParse(rdr["EndValue"]?.ToString(), out var endValue); + double.TryParse(rdr["HighValue"]?.ToString(), out var highValue); + double.TryParse(rdr["LowValue"]?.ToString(), out var lowValue); + double.TryParse(rdr["MoneyVolume"]?.ToString(), out var moneyVolume); + int.TryParse(rdr["CandleTimeType"]?.ToString(), out var candleTimeType); + + var data = new CandleData(); + data.DateTime = Convert.ToDateTime(dateTime); + data.StartValue = startValue; + data.EndValue = endValue; + data.HighValue = highValue; + data.LowValue = lowValue; + data.MoneyVolume = moneyVolume; + data.CandleTimeType = candleTimeType; + + returnData.Add(data); } } - - - //using (var rdr = cmd.ExecuteReader()) - //{ - // while (rdr.Read()) - // { - // var dateTime = rdr["DateTime"]?.ToString(); - // double.TryParse(rdr["StartValue"]?.ToString(), out var startValue); - // double.TryParse(rdr["EndValue"]?.ToString(), out var endValue); - // double.TryParse(rdr["HighValue"]?.ToString(), out var highValue); - // double.TryParse(rdr["LowValue"]?.ToString(), out var lowValue); - // double.TryParse(rdr["MoneyVolume"]?.ToString(), out var moneyVolume); - // int.TryParse(rdr["CandleTimeType"]?.ToString(), out var candleTimeType); - - // var data = new CandleData(); - // data.DateTime = Convert.ToDateTime(dateTime); - // data.StartValue = startValue; - // data.EndValue = endValue; - // data.HighValue = highValue; - // data.LowValue = lowValue; - // data.MoneyVolume = moneyVolume; - // data.CandleTimeType = candleTimeType; - - // returnData.Add(data); - // } - //} conn.Close(); } catch (Exception ex) diff --git a/Million/DbMangement/DBServiceFunctions.cs b/Million/DbMangement/DBServiceFunctions.cs index 3386f42..8a1dc6d 100644 --- a/Million/DbMangement/DBServiceFunctions.cs +++ b/Million/DbMangement/DBServiceFunctions.cs @@ -191,14 +191,7 @@ namespace Million.DbManagement { var returnData = new List(); - var strDbCon = CommonProperty.DbConnectionStr + databaseName; - var sql = ""; - var codeFullNameList = marketNameList.Select(t => t.CodeFullName).ToList(); - foreach(var item in codeFullNameList) - { - sql += string.Format(@"SELECT TOP(1) [DateTime],[StartValue],[EndValue],[HighValue],[LowValue],[MoneyVolume],[CandleTimeType] FROM [{0}] WHERE [CandleTimeType] = {1} ORDER BY [DateTime] DESC;", item, ((int)candleTimeType).ToString()); - } - var recentlyDataList = DBConnection.QueryGetExcuter_Candle(strDbCon, sql); + var strDbCon = CommonProperty.DbConnectionStr + databaseName; //최신 데이터 foreach (var item in marketNameList) @@ -239,56 +232,7 @@ namespace Million.DbManagement } return returnData; - } - - /// - /// 실시간 데이터 입력(1분, 1시간) - /// - /// - /// - public static void SetRealTimeCandleData(string payment, string placeName) - { - var marketList = DbServiceFunctions.GetMarketDatas(placeName, payment); - - //1분, 1시간 - - Thread threadOneM = new Thread(new ParameterizedThreadStart(InserRealTimeDataOneMThread)); - threadOneM.Start(marketList); - - Thread threadOneH = new Thread(new ParameterizedThreadStart(InserRealTimeDataOneHThread)); - threadOneM.Start(marketList); - } - /// - /// 1시간단위(1분 단위 먼저 data insert 이후 처리) - /// - /// - public static void InserRealTimeDataOneHThread(object marketObj) - { - var marketList = (List)marketObj; - var recentlyDbDataList = GetOldNewDataList_FromDB - (marketList, "Upbit", (MCandleTimeType.H1)); - - //기존의 누락된 데이터 쌓기 - while (CommonProperty.RealTimeFlag) - { - var flag = SetCandleData("Upbit", ExchangeWebReqType.UpbitCandleStick, recentlyDbDataList); - - if (flag) - { - var date = DateTime.Now; - if (date.Minute < 60) - { - var temp = 60 - date.Minute; - Thread.Sleep(temp * 1000 * 60); - recentlyDbDataList = GetOldNewDataList_FromDB(marketList, "Upbit", (MCandleTimeType.H1)); - } - } - else - { - recentlyDbDataList = GetOldNewDataList_FromDB(marketList, "Upbit", (MCandleTimeType.H1)); - } - } - } + } /// /// 1분단위