DB Saver기능 추가 및 수정
This commit is contained in:
102
DataSaver/MainForm.Designer.cs
generated
102
DataSaver/MainForm.Designer.cs
generated
@@ -35,15 +35,13 @@
|
||||
this.label_ExchangePlace = new System.Windows.Forms.Label();
|
||||
this.comboBoxEdit_ExchangePlace = new DevExpress.XtraEditors.ComboBoxEdit();
|
||||
this.groupBox_데이터누적 = new System.Windows.Forms.GroupBox();
|
||||
this.label_종목타입 = new System.Windows.Forms.Label();
|
||||
this.label_종목이름 = new System.Windows.Forms.Label();
|
||||
this.label_종목코드 = new System.Windows.Forms.Label();
|
||||
this.comboBoxEdit_PaymentType = new DevExpress.XtraEditors.ComboBoxEdit();
|
||||
this.comboBoxEdit_MarketInfo = new DevExpress.XtraEditors.ComboBoxEdit();
|
||||
this.button_AllMarketDataAcc = new System.Windows.Forms.Button();
|
||||
this.button_SelectedMarketDataAcc = new System.Windows.Forms.Button();
|
||||
this.groupBox_종목업데이트 = new System.Windows.Forms.GroupBox();
|
||||
this.button_SelectedPlaceMarketUpdate = new System.Windows.Forms.Button();
|
||||
this.comboBoxEdit_PaymentType = new DevExpress.XtraEditors.ComboBoxEdit();
|
||||
this.label_종목타입 = new System.Windows.Forms.Label();
|
||||
this.label_종목이름 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
|
||||
this.panelControl1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.listBoxControl_logViewer)).BeginInit();
|
||||
@@ -52,9 +50,8 @@
|
||||
this.groupBox_DB접속.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_ExchangePlace.Properties)).BeginInit();
|
||||
this.groupBox_데이터누적.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_MarketInfo.Properties)).BeginInit();
|
||||
this.groupBox_종목업데이트.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_PaymentType.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_MarketInfo.Properties)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panelControl1
|
||||
@@ -63,7 +60,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, 322);
|
||||
this.panelControl1.Size = new System.Drawing.Size(227, 251);
|
||||
this.panelControl1.TabIndex = 0;
|
||||
//
|
||||
// listBoxControl_logViewer
|
||||
@@ -71,18 +68,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, 318);
|
||||
this.listBoxControl_logViewer.Size = new System.Drawing.Size(223, 247);
|
||||
this.listBoxControl_logViewer.TabIndex = 0;
|
||||
//
|
||||
// panelControl2
|
||||
//
|
||||
this.panelControl2.Controls.Add(this.groupBox_DB접속);
|
||||
this.panelControl2.Controls.Add(this.groupBox_데이터누적);
|
||||
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, 322);
|
||||
this.panelControl2.Size = new System.Drawing.Size(246, 251);
|
||||
this.panelControl2.TabIndex = 1;
|
||||
//
|
||||
// groupBox_DB접속
|
||||
@@ -124,13 +120,31 @@
|
||||
this.groupBox_데이터누적.Controls.Add(this.comboBoxEdit_MarketInfo);
|
||||
this.groupBox_데이터누적.Controls.Add(this.button_AllMarketDataAcc);
|
||||
this.groupBox_데이터누적.Controls.Add(this.button_SelectedMarketDataAcc);
|
||||
this.groupBox_데이터누적.Location = new System.Drawing.Point(13, 132);
|
||||
this.groupBox_데이터누적.Location = new System.Drawing.Point(13, 62);
|
||||
this.groupBox_데이터누적.Name = "groupBox_데이터누적";
|
||||
this.groupBox_데이터누적.Size = new System.Drawing.Size(215, 181);
|
||||
this.groupBox_데이터누적.TabIndex = 0;
|
||||
this.groupBox_데이터누적.TabStop = false;
|
||||
this.groupBox_데이터누적.Text = "데이터 누적";
|
||||
//
|
||||
// label_종목타입
|
||||
//
|
||||
this.label_종목타입.AutoSize = true;
|
||||
this.label_종목타입.Location = new System.Drawing.Point(14, 74);
|
||||
this.label_종목타입.Name = "label_종목타입";
|
||||
this.label_종목타입.Size = new System.Drawing.Size(63, 14);
|
||||
this.label_종목타입.TabIndex = 4;
|
||||
this.label_종목타입.Text = "종목 타입 : ";
|
||||
//
|
||||
// label_종목이름
|
||||
//
|
||||
this.label_종목이름.AutoSize = true;
|
||||
this.label_종목이름.Location = new System.Drawing.Point(14, 103);
|
||||
this.label_종목이름.Name = "label_종목이름";
|
||||
this.label_종목이름.Size = new System.Drawing.Size(63, 14);
|
||||
this.label_종목이름.TabIndex = 4;
|
||||
this.label_종목이름.Text = "종목 이름 : ";
|
||||
//
|
||||
// label_종목코드
|
||||
//
|
||||
this.label_종목코드.AutoSize = true;
|
||||
@@ -140,6 +154,15 @@
|
||||
this.label_종목코드.TabIndex = 4;
|
||||
this.label_종목코드.Text = "종목 코드";
|
||||
//
|
||||
// comboBoxEdit_PaymentType
|
||||
//
|
||||
this.comboBoxEdit_PaymentType.Location = new System.Drawing.Point(83, 71);
|
||||
this.comboBoxEdit_PaymentType.Name = "comboBoxEdit_PaymentType";
|
||||
this.comboBoxEdit_PaymentType.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
|
||||
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
|
||||
this.comboBoxEdit_PaymentType.Size = new System.Drawing.Size(113, 20);
|
||||
this.comboBoxEdit_PaymentType.TabIndex = 3;
|
||||
//
|
||||
// comboBoxEdit_MarketInfo
|
||||
//
|
||||
this.comboBoxEdit_MarketInfo.Location = new System.Drawing.Point(83, 97);
|
||||
@@ -171,59 +194,11 @@
|
||||
this.button_SelectedMarketDataAcc.UseVisualStyleBackColor = true;
|
||||
this.button_SelectedMarketDataAcc.Click += new System.EventHandler(this.button_SelectedMarketDataAcc_Click);
|
||||
//
|
||||
// groupBox_종목업데이트
|
||||
//
|
||||
this.groupBox_종목업데이트.Controls.Add(this.button_SelectedPlaceMarketUpdate);
|
||||
this.groupBox_종목업데이트.Location = new System.Drawing.Point(13, 69);
|
||||
this.groupBox_종목업데이트.Name = "groupBox_종목업데이트";
|
||||
this.groupBox_종목업데이트.Size = new System.Drawing.Size(215, 57);
|
||||
this.groupBox_종목업데이트.TabIndex = 0;
|
||||
this.groupBox_종목업데이트.TabStop = false;
|
||||
this.groupBox_종목업데이트.Text = "종목 업데이트";
|
||||
//
|
||||
// button_SelectedPlaceMarketUpdate
|
||||
//
|
||||
this.button_SelectedPlaceMarketUpdate.Location = new System.Drawing.Point(14, 21);
|
||||
this.button_SelectedPlaceMarketUpdate.Name = "button_SelectedPlaceMarketUpdate";
|
||||
this.button_SelectedPlaceMarketUpdate.Size = new System.Drawing.Size(182, 23);
|
||||
this.button_SelectedPlaceMarketUpdate.TabIndex = 0;
|
||||
this.button_SelectedPlaceMarketUpdate.Text = "선택 거래소 종목 업데이트";
|
||||
this.button_SelectedPlaceMarketUpdate.UseVisualStyleBackColor = true;
|
||||
this.button_SelectedPlaceMarketUpdate.Click += new System.EventHandler(this.button_SelectedPlaceMarketUpdate_Click);
|
||||
//
|
||||
// comboBoxEdit_PaymentType
|
||||
//
|
||||
this.comboBoxEdit_PaymentType.Location = new System.Drawing.Point(83, 71);
|
||||
this.comboBoxEdit_PaymentType.Name = "comboBoxEdit_PaymentType";
|
||||
this.comboBoxEdit_PaymentType.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
|
||||
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
|
||||
this.comboBoxEdit_PaymentType.Size = new System.Drawing.Size(113, 20);
|
||||
this.comboBoxEdit_PaymentType.TabIndex = 3;
|
||||
this.comboBoxEdit_PaymentType.SelectedIndexChanged += new System.EventHandler(this.comboBoxEdit_ExchangePlace_SelectedIndexChanged);
|
||||
//
|
||||
// label_종목타입
|
||||
//
|
||||
this.label_종목타입.AutoSize = true;
|
||||
this.label_종목타입.Location = new System.Drawing.Point(14, 74);
|
||||
this.label_종목타입.Name = "label_종목타입";
|
||||
this.label_종목타입.Size = new System.Drawing.Size(63, 14);
|
||||
this.label_종목타입.TabIndex = 4;
|
||||
this.label_종목타입.Text = "종목 타입 : ";
|
||||
//
|
||||
// label_종목이름
|
||||
//
|
||||
this.label_종목이름.AutoSize = true;
|
||||
this.label_종목이름.Location = new System.Drawing.Point(14, 103);
|
||||
this.label_종목이름.Name = "label_종목이름";
|
||||
this.label_종목이름.Size = new System.Drawing.Size(63, 14);
|
||||
this.label_종목이름.TabIndex = 4;
|
||||
this.label_종목이름.Text = "종목 이름 : ";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(473, 322);
|
||||
this.ClientSize = new System.Drawing.Size(473, 251);
|
||||
this.Controls.Add(this.panelControl2);
|
||||
this.Controls.Add(this.panelControl1);
|
||||
this.Name = "MainForm";
|
||||
@@ -238,9 +213,8 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_ExchangePlace.Properties)).EndInit();
|
||||
this.groupBox_데이터누적.ResumeLayout(false);
|
||||
this.groupBox_데이터누적.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_MarketInfo.Properties)).EndInit();
|
||||
this.groupBox_종목업데이트.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_PaymentType.Properties)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_MarketInfo.Properties)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@@ -250,13 +224,11 @@
|
||||
private DevExpress.XtraEditors.PanelControl panelControl1;
|
||||
private DevExpress.XtraEditors.ListBoxControl listBoxControl_logViewer;
|
||||
private DevExpress.XtraEditors.PanelControl panelControl2;
|
||||
private System.Windows.Forms.GroupBox groupBox_종목업데이트;
|
||||
private System.Windows.Forms.GroupBox groupBox_DB접속;
|
||||
private System.Windows.Forms.Label label_ExchangePlace;
|
||||
private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit_ExchangePlace;
|
||||
private System.Windows.Forms.GroupBox groupBox_데이터누적;
|
||||
private System.Windows.Forms.Button button_SelectedMarketDataAcc;
|
||||
private System.Windows.Forms.Button button_SelectedPlaceMarketUpdate;
|
||||
private System.Windows.Forms.Button button_AllMarketDataAcc;
|
||||
private System.Windows.Forms.Label label_종목코드;
|
||||
private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit_MarketInfo;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Million;
|
||||
using Million.Data;
|
||||
|
||||
namespace DataSaver
|
||||
{
|
||||
@@ -21,10 +24,9 @@ namespace DataSaver
|
||||
// 거래소 정보 콤보박스 초기화
|
||||
comboBoxEdit_ExchangePlace.Properties.Items.Clear();
|
||||
// Million으로부터 거래소 정보 가져오기
|
||||
comboBoxEdit_ExchangePlace.Properties.Items.AddRange(Enum.GetNames(enumType: typeof(Million.CommonProperty.ExchangePlace)));
|
||||
///TODO 임시로 Upbit 우선순위 설정
|
||||
comboBoxEdit_ExchangePlace.SelectedIndex = 1;
|
||||
|
||||
var exchangePlaceNames = Enum.GetNames(enumType: typeof(Million.CommonProperty.ExchangePlace));
|
||||
comboBoxEdit_ExchangePlace.Properties.Items.AddRange(exchangePlaceNames);
|
||||
|
||||
// 종목 타입 설정
|
||||
comboBoxEdit_PaymentType.Properties.Items.AddRange(Enum.GetNames(enumType: typeof(Million.CommonProperty.PaymentType)));
|
||||
comboBoxEdit_PaymentType.SelectedIndex = 0;
|
||||
@@ -33,10 +35,21 @@ namespace DataSaver
|
||||
var strConn = Million.CommonProperty.DbConnectionStr + comboBoxEdit_ExchangePlace.EditValue;
|
||||
Million.CommonProperty.ConDbConnectionStr = strConn;
|
||||
|
||||
// DB 종목(Market) 정보 가져오기
|
||||
// Market Table없으면 생성해주기
|
||||
foreach (var placeName in exchangePlaceNames)
|
||||
{
|
||||
var createTableSql = Million.DbManagement.DbServiceFunctions.CreateMarketTableQuery(placeName);
|
||||
Million.DbManagement.DBConnection.QueryUpdateExcuter
|
||||
(CommonProperty.DbConnectionMarket, createTableSql);
|
||||
}
|
||||
|
||||
/////TODO 임시로 Upbit 우선순위 설정
|
||||
comboBoxEdit_ExchangePlace.SelectedIndex = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 거래소 콤보박스 아이템 변경 시 이벤트
|
||||
/// </summary>
|
||||
@@ -45,8 +58,12 @@ namespace DataSaver
|
||||
private void comboBoxEdit_ExchangePlace_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// DB 서버 정보 수정
|
||||
var strConn = Million.CommonProperty.DbConnectionStr + comboBoxEdit_ExchangePlace.EditValue;
|
||||
Million.CommonProperty.ConDbConnectionStr = strConn;
|
||||
//var strConn = Million.CommonProperty.DbConnectionStr + comboBoxEdit_ExchangePlace.EditValue;
|
||||
//Million.CommonProperty.ConDbConnectionStr = strConn;
|
||||
|
||||
// DB 종목(Market) 정보 가져오기
|
||||
Million.DbManagement.DbServiceFunctions.GetMarketTable_FromDB(comboBoxEdit_ExchangePlace.SelectedItem.ToString());
|
||||
updateMarketTableOfPlace();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,22 +86,65 @@ namespace DataSaver
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 선택한 거래소의 종목(Market) 업데이트
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void button_SelectedPlaceMarketUpdate_Click(object sender, EventArgs e)
|
||||
private void updateMarketTableOfPlace()
|
||||
{
|
||||
// DB에서 종목(Market) 정보 조회 후 없으면 추가 생성하기
|
||||
var dbMarketDataList = CommonProperty.selectedMarketOfPlaceList;
|
||||
|
||||
// #1. Web에서 Market 정보 가져오기
|
||||
// TODO 추후 공통화
|
||||
var marketDataList_FromWeb = Million.WebServices.WebConnection.SendWebServer(CommonProperty.ExchangeWebReqType.UpbitMarket, DateTime.Now);
|
||||
// #1-1. DB에서 Market 정보 조
|
||||
var marketDataListFromDb = Million.DbManagement.DbServiceFunctions.GetMarketTable_FromDB(
|
||||
comboBoxEdit_ExchangePlace.SelectedItem.ToString());
|
||||
// #2. 비교후 Market 테이블 생성
|
||||
//거래소 가져오기
|
||||
var placeIndex = comboBoxEdit_ExchangePlace.SelectedIndex;
|
||||
CommonProperty.recentlyMarketOfPlaceList = new List<MarketData>();
|
||||
|
||||
switch (placeIndex)
|
||||
{
|
||||
case (int)CommonProperty.ExchangePlace.Upbit:
|
||||
CommonProperty.recentlyMarketOfPlaceList = (List<MarketData>)
|
||||
Million.WebServices.WebConnection.SendWebServer(CommonProperty.ExchangeWebReqType.UpbitMarket,
|
||||
DateTime.Now);
|
||||
|
||||
break;
|
||||
//case (int)CommonProperty.ExchangePlace.Bithumb:
|
||||
// marketList = Million.DbManagement.DbServiceFunctions.GetMarketTable_FromDB(
|
||||
// comboBoxEdit_ExchangePlace.SelectedItem.ToString());
|
||||
// break;
|
||||
}
|
||||
|
||||
// 비교
|
||||
// insert (신규)
|
||||
var insertData = new List<MarketData>();
|
||||
|
||||
var sqlQuery = "";
|
||||
|
||||
var insertDatasss = CommonProperty.recentlyMarketOfPlaceList
|
||||
.Where(x => dbMarketDataList.Count(s => x.CodeFullName == s.CodeFullName) == 0).ToList();
|
||||
|
||||
|
||||
//var insertDatas = CommonProperty.recentlyMarketOfPlaceList.Except(dbMarketDataList).ToList();
|
||||
|
||||
|
||||
foreach (var data in CommonProperty.recentlyMarketOfPlaceList)
|
||||
{
|
||||
if (!dbMarketDataList.Any(t => t.CodeFullName == data.CodeFullName))
|
||||
sqlQuery += string.Format(
|
||||
"INSERT INTO [dbo].[{0}]([CodeFullName], [ExchangePlace], [KorName], [CodeName], [Payment], [IsValid]) VALUES ('{1}','{2}','{3}','{4}','{5}',{6})",
|
||||
comboBoxEdit_ExchangePlace.SelectedItem, data.CodeFullName,
|
||||
data.ExchangePlace, data.KorName, data.CodeName, data.Payment, 1);
|
||||
}
|
||||
|
||||
foreach (var data in dbMarketDataList)
|
||||
{
|
||||
if (!CommonProperty.recentlyMarketOfPlaceList.Any(t => t.CodeFullName == data.CodeFullName) && data.IsValid)
|
||||
sqlQuery += string.Format(
|
||||
"UPDATE [dbo].[{0}] SET IsValid = 0 WHERE [CodeFullName] = '{1}'",
|
||||
comboBoxEdit_ExchangePlace.SelectedItem,
|
||||
data.CodeFullName);
|
||||
}
|
||||
if(!string.IsNullOrWhiteSpace(sqlQuery))
|
||||
Million.DbManagement.DBConnection.QueryUpdateExcuter(CommonProperty.DbConnectionMarket, sqlQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
4
DataSaver/packages.config
Normal file
4
DataSaver/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.12" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user