C# 키움선물 API 알람 프로그램 소스코드 공개
마스터욱
1
56
0
0
2018-10-19 16:57:21
완성본이지만 아쉬움이 많이 남음...
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.OleDb;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Timers;
- using System.Windows.Forms;
- using System.Threading;
- namespace FutureSignal
- {
- public partial class FutureSignalMain : Form
- {
- public FutureSignalMain()
- {
- InitializeComponent();
- setTelegramEvent();
- telegramAPIAsync();
- }
- ////////////////////////////// 전역변수 선언
- private string 키움아이디 = "";
- private string 키움이름 = "";
- private string 키움계좌번호 = "";
- public int 화면번호 = 5000;
- Dictionary<string, Dictionary<string, string>> 데이터 = new Dictionary<string, Dictionary<string, string>>();
- private string[] 알람종류 = {
- "hangseng_1", "hangseng_2", "hangseng_3", "hangseng_4", "hangseng_5",
- "oil_1", "oil_2", "oil_3", "oil_4", "oil_5",
- "nasdak_1", "nasdak_2", "nasdak_3", "nasdak_4", "nasdak_5",
- "gold_1", "gold_2", "gold_3", "gold_4", "gold_5",
- "usd_1", "usd_2", "usd_3", "usd_4", "usd_5"
- };
- private string DBString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=알람로그;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
- //Dictionary<string, CustomTimer> 타이머리스트 = new Dictionary<string, CustomTimer>();
- Dictionary<string, Thread> 쓰레드 = new Dictionary<string, Thread>();
- int 폴링타임 = 1000;
- private void Form1_Load(object sender, EventArgs e)
- {
- //send_message("테스트");
- ////////////////////////////// 프로그램 실행후 바로 키움 로그인 창 오픈
- long Result;
- Result = axKFOpenAPI1.CommConnect(1);
- //Result = 0;
- if (Result != 0)
- {
- MessageBox.Show("키움 로그인창을 불러오는데 실패했습니다.\n프로그램 개발자에게 문의바랍니다.");
- }
- else
- {
- LabelLoginInfo.Text = "키움 로그인 창 오픈 성공";
- }
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_2','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_3','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_4','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_5','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('oil_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('oil_2','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('oil_3','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('oil_4','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('oil_5','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('nasdak_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('nasdak_2','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('nasdak_3','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('nasdak_4','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('nasdak_5','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('gold_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('gold_2','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('gold_3','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('gold_4','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('gold_5','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('usd_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('usd_2','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('usd_3','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('usd_4','2018-10-12 07:50:00');
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('usd_5','2018-10-12 07:50:00');
- ---------------------------------------------------------------------------------------------
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_2');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_3');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_4');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_5');
- insert 알람로그.dbo.Config (PushTitle) values('oil_1');
- insert 알람로그.dbo.Config (PushTitle) values('oil_2');
- insert 알람로그.dbo.Config (PushTitle) values('oil_3');
- insert 알람로그.dbo.Config (PushTitle) values('oil_4');
- insert 알람로그.dbo.Config (PushTitle) values('oil_5');
- insert 알람로그.dbo.Config (PushTitle) values('nasdak_1');
- insert 알람로그.dbo.Config (PushTitle) values('nasdak_2');
- insert 알람로그.dbo.Config (PushTitle) values('nasdak_3');
- insert 알람로그.dbo.Config (PushTitle) values('nasdak_4');
- insert 알람로그.dbo.Config (PushTitle) values('nasdak_5');
- insert 알람로그.dbo.Config (PushTitle) values('gold_1');
- insert 알람로그.dbo.Config (PushTitle) values('gold_2');
- insert 알람로그.dbo.Config (PushTitle) values('gold_3');
- insert 알람로그.dbo.Config (PushTitle) values('gold_4');
- insert 알람로그.dbo.Config (PushTitle) values('gold_5');
- insert 알람로그.dbo.Config (PushTitle) values('usd_1');
- insert 알람로그.dbo.Config (PushTitle) values('usd_2');
- insert 알람로그.dbo.Config (PushTitle) values('usd_3');
- insert 알람로그.dbo.Config (PushTitle) values('usd_4');
- insert 알람로그.dbo.Config (PushTitle) values('usd_5');
- */
- foreach(string PushTitle in 알람종류)
- {
- //Console.WriteLine(PushTitle);
- 데이터[PushTitle] = new Dictionary<string, string>();
- getConfig(PushTitle);
- }
- }
- private void getConfig(string PushTitle)
- {
- //Console.WriteLine(PushTitle);
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "SELECT * FROM 알람로그.dbo.Config WHERE PushTitle = '" + PushTitle + "'";
- //Console.WriteLine(sql);
- cmd.CommandText = sql;
- var dr = cmd.ExecuteReader();
- ComboBox bunbong_ctrl = new ComboBox();
- TextBox enver_start_ctrl = new TextBox();
- TextBox enver_end_ctrl = new TextBox();
- TextBox enver_trade_ctrl = new TextBox();
- TextBox alarm_interval_ctrl = new TextBox();
- TextBox code_ctrl = new TextBox();
- foreach (Control item in Controls)
- {
- if (item is GroupBox)
- {
- if (item.Name == "GroupBox_" + PushTitle)
- {
- foreach (Control ctrl in item.Controls)
- {
- if (ctrl.Name.Contains("bunbong"))
- {
- bunbong_ctrl = ctrl as ComboBox;
- }
- else if(ctrl.Name.Contains("enver_start"))
- {
- enver_start_ctrl = ctrl as TextBox;
- }
- else if (ctrl.Name.Contains("enver_end"))
- {
- enver_end_ctrl = ctrl as TextBox;
- }
- else if (ctrl.Name.Contains("enver_trade"))
- {
- enver_trade_ctrl = ctrl as TextBox;
- }
- else if (ctrl.Name.Contains("alarm_interval"))
- {
- alarm_interval_ctrl = ctrl as TextBox;
- }
- else if (ctrl.Name.Contains("code"))
- {
- code_ctrl = ctrl as TextBox;
- }
- }
- break;
- }
- }
- }
- if (dr.Read())
- {
- bunbong_ctrl.SelectedItem = dr["bunbong"].ToString();
- enver_start_ctrl.Text = dr["enver_start"].ToString();
- enver_end_ctrl.Text = dr["enver_end"].ToString();
- enver_trade_ctrl.Text = dr["enver_trade"].ToString();
- alarm_interval_ctrl.Text = dr["alarm_interval"].ToString();
- code_ctrl.Text = dr["code"].ToString();
- }
- conn.Close();
- }
- }
- ////////////////////////////// 로그인
- private void axKFOpenAPI1_OnEventConnect(object sender, AxKFOpenAPILib._DKFOpenAPIEvents_OnEventConnectEvent e)
- {
- 키움아이디 = axKFOpenAPI1.GetLoginInfo("USER_ID");
- 키움계좌번호 = axKFOpenAPI1.GetLoginInfo("ACCNO");
- //키움계좌번호 = 키움계좌번호.Substring(0, 키움계좌번호.Length - 1);
- //Console.WriteLine("키움계좌번호 = " + 키움계좌번호);
- 키움이름 = axKFOpenAPI1.GetLoginInfo("USER_NAME");
- string LabelText = "";
- LabelText += "아이디 : " + 키움아이디;
- LabelText += "\n사용자 : " + 키움이름;
- LabelLoginInfo.Text = LabelText;
- }
- private void axKFOpenAPI1_OnReceiveTrData(object sender, AxKFOpenAPILib._DKFOpenAPIEvents_OnReceiveTrDataEvent e)
- {
- //Console.WriteLine("e.sRQName => " + e.sRQName);
- string 타입 = RQ[0];
- Dictionary<string, string> 임시데이터 = 데이터[타입];
- //Console.WriteLine("임시데이터 => " + 임시데이터);
- bool is_send = 메세지타임_조회(타입);
- if(is_send)
- {
- int nCnt = axKFOpenAPI1.GetRepeatCnt(e.sTrCode, e.sRQName);
- //Console.WriteLine(e.sRQName + " nCnt => " + nCnt);
- if (nCnt > int.Parse(임시데이터["엔벨스타트"]))
- {
- double 기준금액 = 0;
- double 합계 = 0;
- int 루프카운트 = 0;
- for (int i = 0; i <= int.Parse(임시데이터["엔벨스타트"]); i++)
- {
- string 현재가n = axKFOpenAPI1.GetCommData(e.sTrCode, e.sRQName, i, "현재가").TrimStart('0');
- //Console.WriteLine("현재가n => " + 현재가n);
- if (string.IsNullOrEmpty(현재가n) == false)
- {
- 현재가n = 현재가n.Replace("-", "");
- 현재가n = 현재가n.Replace("+", "");
- double 현재가 = double.Parse(현재가n);
- string 체결시간n = axKFOpenAPI1.GetCommData(e.sTrCode, e.sRQName, i, "체결시간").TrimStart('0');
- //체결시간 : 203900, 현재가 : -25179
- //Console.WriteLine("체결시간 : " + 체결시간n + ", 현재가 : " + 현재가n);
- if (루프카운트 == 0)
- {
- 기준금액 = 현재가;
- }
- else
- {
- 합계 += 현재가;
- }
- 루프카운트++;
- }
- }
- double 엔벨기준 = double.Parse(임시데이터["엔벨끝"]) * 0.01;
- double 합계평균 = 합계 / (루프카운트 - 1);
- double 엔벨하단 = 합계평균 - (합계평균 * 엔벨기준);
- double 엔벨상단 = 합계평균 + (합계평균 * 엔벨기준);
- //Console.WriteLine("루프카운트 = "+ 루프카운트 + ", 합계평균 = " + 합계평균 + ", 엔벨기준 = " + 엔벨기준 + ", 엔벨끝 = " + 임시데이터["엔벨끝"]);
- double 엔벨매매 = double.Parse(임시데이터["엔벨매매"]) * 0.01;
- Console.WriteLine(타입 + " => nCnt : " + nCnt + ", 상단 : " + 엔벨상단 + ", 현재 : " + 기준금액 + ", 하단 : " + 엔벨하단);
- string TradeType = "";
- double TradeSize = 0;
- if (엔벨하단 >= 기준금액 || 엔벨상단 <= 기준금액)
- {
- if (엔벨하단 >= 기준금액)
- {
- TradeType = "매수신호";
- TradeSize = 합계평균 - (합계평균 * 엔벨매매);
- }
- else if (엔벨상단 <= 기준금액)
- {
- TradeType = "매도신호";
- TradeSize = 합계평균 + (합계평균 * 엔벨매매);
- }
- string msg = "--- " + 임시데이터["명칭"] + " 알림 ---\n";
- msg += "타입 : " + TradeType + "\n";
- msg += "분봉 : " + 임시데이터["분봉"] + "\n";
- msg += "엔벨 : " + 임시데이터["엔벨스타트"] + " / " + 임시데이터["엔벨끝"] + " / " + 임시데이터["엔벨매매"] + "\n";
- msg += "추천가 : " + TradeSize.ToString() + "\n";
- msg += "개발자 : 욱\n";
- msg += "마지막 업데이트 : 2018-10-16";
- //Console.WriteLine(타입 + " 푸쉬전송 => " + msg);
- send_message(msg);
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.PushLog SET PushTime = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' WHERE PushTitle = '" + 타입 + "'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- }
- }
- }
- else
- {
- //대기
- Console.WriteLine(타입 + " 대기");
- }
- /*
- 타이머리스트[타입] = new CustomTimer
- {
- Interval = 5000,
- Data = 타입
- };
- 타이머리스트[타입].Elapsed += timer_Elapsed;
- 타이머리스트[타입].Start();
- */
- //Console.WriteLine(타입 + " => 타이머 시작");
- //Console.WriteLine(타입);
- Delay(폴링타임);
- if (타입 == "hangseng_1")
- {
- hangseng_1();
- }
- else if (타입 == "hangseng_2")
- {
- hangseng_2();
- }
- else if (타입 == "hangseng_3")
- {
- hangseng_3();
- }
- else if (타입 == "oil_1")
- {
- oil_1();
- }
- else if (타입 == "oil_2")
- {
- oil_2();
- }
- else if (타입 == "oil_3")
- {
- oil_3();
- }
- else if (타입 == "nasdak_1")
- {
- nasdak_1();
- }
- else if (타입 == "nasdak_2")
- {
- nasdak_2();
- }
- else if (타입 == "nasdak_3")
- {
- nasdak_3();
- }
- else if (타입 == "gold_1")
- {
- gold_1();
- }
- else if (타입 == "gold_2")
- {
- gold_2();
- }
- else if (타입 == "gold_3")
- {
- gold_3();
- }
- else if (타입 == "usd_1")
- {
- usd_1();
- }
- else if (타입 == "usd_2")
- {
- usd_2();
- }
- else if (타입 == "usd_3")
- {
- usd_3();
- }
- }
- private bool 메세지타임_조회(string PushTitle)
- {
- string PushTime = "";
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- /*
- string sql = "INSERT 알람로그.dbo.PushLog(PushTitle, PushTime) VALUES(@PushTitle, @PushTime)";
- cmd.CommandText = sql;
- cmd.Parameters.AddWithValue("@PushTitle", "테스트");
- cmd.Parameters.AddWithValue("@PushTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- cmd.ExecuteNonQuery();
- */
- string sql = "SELECT PushTime FROM 알람로그.dbo.PushLog WHERE PushTitle = '" + PushTitle + "'";
- cmd.CommandText = sql;
- var dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- PushTime = dr["PushTime"].ToString();
- }
- conn.Close();
- }
- DateTime dtPreTime = new DateTime(int.Parse(tmp2[0]), int.Parse(tmp2[1]), int.Parse(tmp2[2]), int.Parse(tmp3[0]), int.Parse(tmp3[1]), int.Parse(tmp3[2]));
- string NowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- DateTime dtNowTime = new DateTime(int.Parse(tmp2[0]), int.Parse(tmp2[1]), int.Parse(tmp2[2]), int.Parse(tmp3[0]), int.Parse(tmp3[1]), int.Parse(tmp3[2]));
- TimeSpan timeDiff = dtNowTime - dtPreTime;
- int diffDays = timeDiff.Days;
- int diffHoures = timeDiff.Hours;
- int diffMiniute = timeDiff.Minutes;
- //int diffSecond = timeDiff.Seconds;
- /*
- Console.WriteLine("diffDays = " + diffDays);
- Console.WriteLine("diffHoures = " + diffHoures);
- Console.WriteLine("diffMiniute = " + diffMiniute);
- Console.WriteLine("diffSecond = " + diffSecond);
- */
- int TotalMinute = (diffDays * 60 * 24) + (diffHoures * 60) + diffMiniute;
- if(TotalMinute > int.Parse(데이터[PushTitle]["알람주기"]))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- ////////////////////////////// 항생1 세팅
- private void hangseng_1()
- {
- if (데이터["hangseng_1"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["hangseng_1"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["hangseng_1"]["분봉"]);
- axKFOpenAPI1.CommRqData("hangseng_1;", "opc10002", "", GetScrNum());
- }
- }
- private void start_hangseng_1_Click(object sender, EventArgs e)
- {
- if(키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["hangseng_1"]["명칭"] = "항생";
- 데이터["hangseng_1"]["작동유무"] = "OK";
- Console.WriteLine("hangseng_1 시작");
- start_hangseng_1.Hide();
- end_hangseng_1.Show();
- info_hangseng_1.Show();
- /*
- ThreadStart th = new ThreadStart(hangseng_1);
- 쓰레드["hangseng_1"] = new Thread(th);
- 쓰레드["hangseng_1"].Start();
- */
- hangseng_1();
- }
- private void save_hangseng_1_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'hangseng_1'";
- Console.WriteLine(sql);
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_hangseng_1_Click(object sender, EventArgs e)
- {
- Console.WriteLine("hangseng_1 정지");
- end_hangseng_1.Hide();
- start_hangseng_1.Show();
- info_hangseng_1.Hide();
- 데이터["hangseng_1"]["작동유무"] = "NO";
- //쓰레드["hangseng_1"].Join();
- }
- ////////////////////////////// 항생2 세팅
- private void hangseng_2()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("hangseng_2 => " + 데이터["hangseng_2"]["작동유무"]);
- if (데이터["hangseng_2"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["hangseng_2"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["hangseng_2"]["분봉"]);
- axKFOpenAPI1.CommRqData("hangseng_2;", "opc10002", "", GetScrNum());
- }
- }
- private void start_hangseng_2_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["hangseng_2"]["명칭"] = "항생";
- 데이터["hangseng_2"]["작동유무"] = "OK";
- Console.WriteLine("hangseng_2 시작");
- start_hangseng_2.Hide();
- end_hangseng_2.Show();
- info_hangseng_2.Show();
- hangseng_2();
- }
- private void save_hangseng_2_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'hangseng_2'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_hangseng_2_Click(object sender, EventArgs e)
- {
- Console.WriteLine("hangseng_2 정지");
- end_hangseng_2.Hide();
- start_hangseng_2.Show();
- info_hangseng_2.Hide();
- 데이터["hangseng_2"]["작동유무"] = "NO";
- }
- ////////////////////////////// 항생3 세팅
- private void hangseng_3()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("hangseng_3 => " + 데이터["hangseng_3"]["작동유무"]);
- if (데이터["hangseng_3"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["hangseng_3"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["hangseng_3"]["분봉"]);
- axKFOpenAPI1.CommRqData("hangseng_3;", "opc10002", "", GetScrNum());
- }
- }
- private void start_hangseng_3_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["hangseng_3"]["명칭"] = "항생";
- 데이터["hangseng_3"]["작동유무"] = "OK";
- Console.WriteLine("hangseng_3 시작");
- start_hangseng_3.Hide();
- end_hangseng_3.Show();
- info_hangseng_3.Show();
- hangseng_3();
- }
- private void save_hangseng_3_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'hangseng_3'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_hangseng_3_Click(object sender, EventArgs e)
- {
- Console.WriteLine("hangseng_3 정지");
- end_hangseng_3.Hide();
- start_hangseng_3.Show();
- info_hangseng_3.Hide();
- 데이터["hangseng_3"]["작동유무"] = "NO";
- }
- ////////////////////////////// 오일1 세팅
- private void oil_1()
- {
- if (데이터["oil_1"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["oil_1"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["oil_1"]["분봉"]);
- //axKFOpenAPI1.CommRqData("oil_1;", "opc10002", "", GetScrNum());
- axKFOpenAPI1.CommRqData("oil_1;", "opc10002", "", GetScrNum());
- }
- }
- private void start_oil_1_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["oil_1"]["명칭"] = "오일";
- 데이터["oil_1"]["작동유무"] = "OK";
- Console.WriteLine("oil_1 시작");
- start_oil_1.Hide();
- end_oil_1.Show();
- info_oil_1.Show();
- oil_1();
- }
- private void save_oil_1_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'oil_1'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_oil_1_Click(object sender, EventArgs e)
- {
- Console.WriteLine("oil_1 정지");
- end_oil_1.Hide();
- start_oil_1.Show();
- info_oil_1.Hide();
- 데이터["oil_1"]["작동유무"] = "NO";
- }
- ////////////////////////////// 오일2 세팅
- private void oil_2()
- {
- if (데이터["oil_2"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["oil_2"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["oil_2"]["분봉"]);
- axKFOpenAPI1.CommRqData("oil_2;", "opc10002", "", GetScrNum());
- }
- }
- private void start_oil_2_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["oil_2"]["명칭"] = "오일";
- 데이터["oil_2"]["작동유무"] = "OK";
- Console.WriteLine("oil_2 시작");
- start_oil_2.Hide();
- end_oil_2.Show();
- info_oil_2.Show();
- oil_2();
- }
- private void save_oil_2_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'oil_2'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_oil_2_Click(object sender, EventArgs e)
- {
- Console.WriteLine("oil_2 정지");
- end_oil_2.Hide();
- start_oil_2.Show();
- info_oil_2.Hide();
- 데이터["oil_2"]["작동유무"] = "NO";
- }
- ////////////////////////////// 오일3 세팅
- private void oil_3()
- {
- if (데이터["oil_3"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["oil_3"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["oil_3"]["분봉"]);
- axKFOpenAPI1.CommRqData("oil_3;", "opc10002", "", GetScrNum());
- }
- }
- private void start_oil_3_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["oil_3"]["명칭"] = "오일";
- 데이터["oil_3"]["작동유무"] = "OK";
- Console.WriteLine("oil_3 시작");
- start_oil_3.Hide();
- end_oil_3.Show();
- info_oil_3.Show();
- oil_3();
- }
- private void save_oil_3_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'oil_3'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_oil_3_Click(object sender, EventArgs e)
- {
- Console.WriteLine("oil_3 정지");
- end_oil_3.Hide();
- start_oil_3.Show();
- info_oil_3.Hide();
- 데이터["oil_3"]["작동유무"] = "NO";
- }
- ////////////////////////////// 나스닥1 세팅
- private void nasdak_1()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("nasdak_1 => " + 데이터["nasdak_1"]["작동유무"]);
- if (데이터["nasdak_1"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["nasdak_1"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["nasdak_1"]["분봉"]);
- axKFOpenAPI1.CommRqData("nasdak_1;", "opc10002", "", GetScrNum());
- }
- }
- private void start_nasdak_1_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["nasdak_1"]["명칭"] = "나스닥";
- 데이터["nasdak_1"]["작동유무"] = "OK";
- Console.WriteLine("nasdak_1 시작");
- start_nasdak_1.Hide();
- end_nasdak_1.Show();
- info_nasdak_1.Show();
- nasdak_1();
- }
- private void save_nasdak_1_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'nasdak_1'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_nasdak_1_Click(object sender, EventArgs e)
- {
- Console.WriteLine("nasdak_1 정지");
- end_nasdak_1.Hide();
- start_nasdak_1.Show();
- info_nasdak_1.Hide();
- 데이터["nasdak_1"]["작동유무"] = "NO";
- }
- ////////////////////////////// 나스닥2 세팅
- private void nasdak_2()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("nasdak_2 => " + 데이터["nasdak_2"]["작동유무"]);
- if (데이터["nasdak_2"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["nasdak_2"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["nasdak_2"]["분봉"]);
- axKFOpenAPI1.CommRqData("nasdak_2;", "opc10002", "", GetScrNum());
- }
- }
- private void start_nasdak_2_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["nasdak_2"]["명칭"] = "나스닥";
- 데이터["nasdak_2"]["작동유무"] = "OK";
- Console.WriteLine("nasdak_2 시작");
- start_nasdak_2.Hide();
- end_nasdak_2.Show();
- info_nasdak_2.Show();
- nasdak_2();
- }
- private void save_nasdak_2_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'nasdak_2'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_nasdak_2_Click(object sender, EventArgs e)
- {
- Console.WriteLine("nasdak_2 정지");
- end_nasdak_2.Hide();
- start_nasdak_2.Show();
- info_nasdak_2.Hide();
- 데이터["nasdak_2"]["작동유무"] = "NO";
- }
- ////////////////////////////// 나스닥3 세팅
- private void nasdak_3()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("nasdak_3 => " + 데이터["nasdak_3"]["작동유무"]);
- if (데이터["nasdak_3"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["nasdak_3"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["nasdak_3"]["분봉"]);
- axKFOpenAPI1.CommRqData("nasdak_3;", "opc10002", "", GetScrNum());
- }
- }
- private void start_nasdak_3_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["nasdak_3"]["명칭"] = "나스닥";
- 데이터["nasdak_3"]["작동유무"] = "OK";
- Console.WriteLine("nasdak_3 시작");
- start_nasdak_3.Hide();
- end_nasdak_3.Show();
- info_nasdak_3.Show();
- nasdak_3();
- }
- private void save_nasdak_3_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'nasdak_3'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_nasdak_3_Click(object sender, EventArgs e)
- {
- Console.WriteLine("nasdak_3 정지");
- end_nasdak_3.Hide();
- start_nasdak_3.Show();
- info_nasdak_3.Hide();
- 데이터["nasdak_3"]["작동유무"] = "NO";
- }
- ////////////////////////////// 골드1 세팅
- private void gold_1()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("gold_1 => " + 데이터["gold_1"]["작동유무"]);
- if (데이터["gold_1"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["gold_1"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["gold_1"]["분봉"]);
- axKFOpenAPI1.CommRqData("gold_1;", "opc10002", "", GetScrNum());
- }
- }
- private void start_gold_1_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["gold_1"]["명칭"] = "골드";
- 데이터["gold_1"]["작동유무"] = "OK";
- Console.WriteLine("gold_1 시작");
- start_gold_1.Hide();
- end_gold_1.Show();
- info_gold_1.Show();
- gold_1();
- }
- private void save_gold_1_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'gold_1'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_gold_1_Click(object sender, EventArgs e)
- {
- Console.WriteLine("gold_1 정지");
- end_gold_1.Hide();
- start_gold_1.Show();
- info_gold_1.Hide();
- 데이터["gold_1"]["작동유무"] = "NO";
- }
- ////////////////////////////// 골드2 세팅
- private void gold_2()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("gold_2 => " + 데이터["gold_2"]["작동유무"]);
- if (데이터["gold_2"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["gold_2"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["gold_2"]["분봉"]);
- axKFOpenAPI1.CommRqData("gold_2;", "opc10002", "", GetScrNum());
- }
- }
- private void start_gold_2_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["gold_2"]["명칭"] = "골드";
- 데이터["gold_2"]["작동유무"] = "OK";
- Console.WriteLine("gold_2 시작");
- start_gold_2.Hide();
- end_gold_2.Show();
- info_gold_2.Show();
- gold_2();
- }
- private void save_gold_2_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'gold_2'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_gold_2_Click(object sender, EventArgs e)
- {
- Console.WriteLine("gold_2 정지");
- end_gold_2.Hide();
- start_gold_2.Show();
- info_gold_2.Hide();
- 데이터["gold_2"]["작동유무"] = "NO";
- }
- ////////////////////////////// 골드3 세팅
- private void gold_3()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("gold_3 => " + 데이터["gold_3"]["작동유무"]);
- if (데이터["gold_3"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["gold_3"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["gold_3"]["분봉"]);
- axKFOpenAPI1.CommRqData("gold_3;", "opc10002", "", GetScrNum());
- }
- }
- private void start_gold_3_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["gold_3"]["명칭"] = "골드";
- 데이터["gold_3"]["작동유무"] = "OK";
- Console.WriteLine("gold_3 시작");
- start_gold_3.Hide();
- end_gold_3.Show();
- info_gold_3.Show();
- gold_3();
- }
- private void save_gold_3_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'gold_3'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_gold_3_Click(object sender, EventArgs e)
- {
- Console.WriteLine("gold_3 정지");
- end_gold_3.Hide();
- start_gold_3.Show();
- info_gold_3.Hide();
- 데이터["gold_3"]["작동유무"] = "NO";
- }
- ////////////////////////////// 유로1 세팅
- private void usd_1()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("usd_1 => " + 데이터["usd_1"]["작동유무"]);
- if (데이터["usd_1"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["usd_1"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["usd_1"]["분봉"]);
- axKFOpenAPI1.CommRqData("usd_1;", "opc10002", "", GetScrNum());
- }
- }
- private void start_usd_1_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["usd_1"]["명칭"] = "유로";
- 데이터["usd_1"]["작동유무"] = "OK";
- Console.WriteLine("usd_1 시작");
- start_usd_1.Hide();
- end_usd_1.Show();
- info_usd_1.Show();
- usd_1();
- }
- private void save_usd_1_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'usd_1'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_usd_1_Click(object sender, EventArgs e)
- {
- Console.WriteLine("usd_1 정지");
- end_usd_1.Hide();
- start_usd_1.Show();
- info_usd_1.Hide();
- 데이터["usd_1"]["작동유무"] = "NO";
- }
- ////////////////////////////// 유로2 세팅
- private void usd_2()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("usd_2 => " + 데이터["usd_2"]["작동유무"]);
- if (데이터["usd_2"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["usd_2"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["usd_2"]["분봉"]);
- axKFOpenAPI1.CommRqData("usd_2;", "opc10002", "", GetScrNum());
- }
- }
- private void start_usd_2_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["usd_2"]["명칭"] = "유로";
- 데이터["usd_2"]["작동유무"] = "OK";
- Console.WriteLine("usd_2 시작");
- start_usd_2.Hide();
- end_usd_2.Show();
- info_usd_2.Show();
- usd_2();
- }
- private void save_usd_2_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'usd_2'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_usd_2_Click(object sender, EventArgs e)
- {
- Console.WriteLine("usd_2 정지");
- end_usd_2.Hide();
- start_usd_2.Show();
- info_usd_2.Hide();
- 데이터["usd_2"]["작동유무"] = "NO";
- }
- ////////////////////////////// 유로3 세팅
- private void usd_3()
- {
- /*
- insert 알람로그.dbo.PushLog (PushTitle, PushTime) values('hangseng_1','2018-10-12 07:50:00');
- insert 알람로그.dbo.Config (PushTitle) values('hangseng_1');
- */
- //Console.WriteLine("usd_3 => " + 데이터["usd_3"]["작동유무"]);
- if (데이터["usd_3"]["작동유무"] == "OK")
- {
- axKFOpenAPI1.SetInputValue("종목코드", 데이터["usd_3"]["코드"]);
- axKFOpenAPI1.SetInputValue("시간단위", 데이터["usd_3"]["분봉"]);
- axKFOpenAPI1.CommRqData("usd_3;", "opc10002", "", GetScrNum());
- }
- }
- private void start_usd_3_Click(object sender, EventArgs e)
- {
- if (키움아이디 == "")
- {
- MessageBox.Show("로그인이 되지 않았습니다.\n로그인 중이라면 5초후에 다시 눌러주세요.");
- return;
- }
- 데이터["usd_3"]["명칭"] = "유로";
- 데이터["usd_3"]["작동유무"] = "OK";
- Console.WriteLine("usd_3 시작");
- start_usd_3.Hide();
- end_usd_3.Show();
- info_usd_3.Show();
- usd_3();
- }
- private void save_usd_3_Click(object sender, EventArgs e)
- {
- using (SqlConnection conn = new SqlConnection(DBString))
- {
- conn.Open();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = conn;
- string sql = "UPDATE 알람로그.dbo.Config SET ";
- sql += "WHERE PushTitle = 'usd_3'";
- cmd.CommandText = sql;
- cmd.ExecuteNonQuery();
- conn.Close();
- }
- MessageBox.Show("저장완료", "알림");
- }
- private void end_usd_3_Click(object sender, EventArgs e)
- {
- Console.WriteLine("usd_3 정지");
- end_usd_3.Hide();
- start_usd_3.Show();
- info_usd_3.Hide();
- 데이터["usd_3"]["작동유무"] = "NO";
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////// 화면번호생성(별 의미는 없다. 걍 랜덤번호 생성)
- public string GetScrNum()
- {
- if (화면번호 < 9999)
- {
- 화면번호++;
- }
- else
- {
- 화면번호 = 5000;
- }
- return 화면번호.ToString();
- }
- ////////////////////////////// 텔레그램 푸시 API
- private Telegram.Bot.TelegramBotClient Bot = new Telegram.Bot.TelegramBotClient("439977575:AAFTeHSLC_prhoJBlJpTSUJJBsAYMG6tEFw");
- private string[] Telegram_User = { "132544306", "429568902", "479630766" };
- private async void telegramAPIAsync()
- {
- var me = await Bot.GetMeAsync();
- //Console.WriteLine("내 이름은 {0}", me.FirstName);
- }
- private void setTelegramEvent()
- {
- Bot.OnMessage += Bot_OnMessage;
- Bot.StartReceiving();
- }
- private async void Bot_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
- {
- var msg = e.Message;
- await Bot.SendTextMessageAsync(msg.Chat.Id, msg.Text);
- //Console.WriteLine("받은 메시지 : {0}", msg.Text);
- }
- private void send_message(string msg)
- {
- foreach (string tid in Telegram_User)
- {
- Bot.SendTextMessageAsync(tid, msg);
- }
- }
- private static DateTime Delay(int MS)
- {
- DateTime ThisMoment = DateTime.Now;
- TimeSpan duration = new TimeSpan(0, 0, 0, 0, MS);
- DateTime AfterWards = ThisMoment.Add(duration);
- while (AfterWards >= ThisMoment)
- {
- ThisMoment = DateTime.Now;
- }
- return DateTime.Now;
- }
- }
- }