Пример #1
0
        /// <summary>
        /// 추가 조회 버튼 클릭시 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearchNext_Click(object sender, EventArgs e)
        {
            if (workTable == null)
            {
                MessageBox.Show("조회 후 추가 조회하세요.");
                return;
            }

            // 자료일자
            string dateFrom = this.dateTimeFrom.Value.ToString("yyyyMMdd");
            string dateTo   = this.dateTimeTo.Value.ToString("yyyyMMdd");

            string dataDate = dateFrom;

            if (!dateFrom.Equals(dateTo))
            {
                dataDate += "-" + dateTo;
            }

            // 자료 조회
            // 조회URL: manager/log/<자료일자>?옵션
            HttpRestClient client = new HttpRestClient("manager/log/" + dataDate);

            // 조회조건
            if (comboAPIKEY.Text.Length > 0)
            {
                client.QueryString.Add("apikey", comboAPIKEY.Text);
            }

            if (comboMethod.Text.Length > 0)
            {
                client.QueryString.Add("type", comboMethod.Text);
            }

            if (txtRequestId.Text.Length > 0)
            {
                client.QueryString.Add("requestid", txtRequestId.Text);
            }

            // 페이징처리...
            if (lastNo != null && lastNo.Length > 0)
            {
                client.QueryString.Add("startno", lastNo);
            }

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            // 응답 데이터 처리
            dynamic json = client.getJsonObject();

            foreach (dynamic item in json.dataList)
            {
                DataRow workRow = workTable.NewRow();
                workRow["No"] = item["no"];

                string date = (string)item["date"];
                date            = date.Substring(0, 4) + "-" + date.Substring(4, 2) + "-" + date.Substring(6, 2);
                workRow["Date"] = date;

                string time = (string)item["time"];
                time            = time.Substring(0, 2) + ":" + time.Substring(2, 2) + ":" + time.Substring(4, 2);
                workRow["Time"] = time;

                workRow["API Key"]   = item["apiKey"];
                workRow["Ticket ID"] = item["reuqestId"];
                workRow["Method"]    = item["method"];
                workRow["Resource"]  = item["resource"];
                workRow["Metadata"]  = item["metadata"];

                workTable.Rows.Add(workRow);

                lastNo = (string)item["no"];
            }

            dataGridView1.AutoResizeColumns();
        }
Пример #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //조회
            MasterList master = null;

            if (radioBtn기관.Checked)
            {
                master = DataMasterCache.getDataMasterByName("기관잠정치매매");
            }
            else if (radioBtn외인.Checked)
            {
                master = DataMasterCache.getDataMasterByName("외인잠정치매매");
            }
            else if (radioBtn외인기관.Checked)
            {
                master = DataMasterCache.getDataMasterByName("외인기관쌍끌이잠정치매매");
            }

            if (master == null)
            {
                MessageBox.Show("자료 종류 중 하나를 선택하세요.", "Error");
                return;
            }

            // 자료일자
            DateTime d        = this.datePicker.Value;
            string   dataDate = d.ToString("yyyyMMdd");

            Console.WriteLine("자료종류: " + master.id + ":" + master.name);
            Console.WriteLine("자료일자: " + dataDate);

            // 자료 조회
            // 조회URL: data/<자료종류>/<자료일자>?stockcode=종목코드
            string         resource_value = master.id + "/" + dataDate;
            HttpRestClient client         = new HttpRestClient("report/listview/" + resource_value);

            // 조회조건
            if (txtStockCodes.Text.Length > 0)
            {
                client.QueryString.Add("stockcode", txtStockCodes.Text);
            }

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            // 응답 데이터 처리
            dynamic json = client.getJsonObject();

            DataTable workTable = new DataTable("Report");

            workTable.Columns.Add("종목코드", typeof(String));
            workTable.Columns.Add("종목명", typeof(String));

            workTable.Columns.Add("외0920-계", typeof(int));       // field

            workTable.Columns.Add("외0950-증감", typeof(int));
            workTable.Columns.Add("외0950-계", typeof(int));       // field
            //workTable.Columns.Add("기0950-증감", typeof(int));
            workTable.Columns.Add("기0950-계", typeof(int));       // field
            workTable.Columns.Add("0950-소계", typeof(int));
            workTable.Columns["외0950-증감"].Expression = "[외0950-계] - [외0920-계]";
            workTable.Columns["0950-소계"].Expression  = "[외0950-계] + [기0950-계]";

            workTable.Columns.Add("외1100-증감", typeof(int));
            workTable.Columns.Add("외1100-계", typeof(int));       // field
            workTable.Columns.Add("기1100-증감", typeof(int));
            workTable.Columns.Add("기1100-계", typeof(int));       // field
            workTable.Columns.Add("1100-소계", typeof(int));
            workTable.Columns["외1100-증감"].Expression = "[외0950-계] - [외1100-계]";
            workTable.Columns["기1100-증감"].Expression = "[기0950-계] - [기1100-계]";
            workTable.Columns["1100-소계"].Expression  = "[외1100-계] + [기1100-계]";

            workTable.Columns.Add("외1320-증감", typeof(int));
            workTable.Columns.Add("외1320-계", typeof(int));       // field
            workTable.Columns.Add("기1320-증감", typeof(int));
            workTable.Columns.Add("기1320-계", typeof(int));       // field
            workTable.Columns.Add("1320-소계", typeof(int));
            workTable.Columns["외1320-증감"].Expression = "[외1100-계] - [외1320-계]";
            workTable.Columns["기1320-증감"].Expression = "[기1100-계] - [기1320-계]";
            workTable.Columns["1320-소계"].Expression  = "[외1320-계] + [기1320-계]";

            workTable.Columns.Add("외1505-증감", typeof(int));
            workTable.Columns.Add("외1505-계", typeof(int));       // field
            workTable.Columns.Add("기1505-증감", typeof(int));
            workTable.Columns.Add("기1505-계", typeof(int));       // field
            workTable.Columns.Add("1505-소계", typeof(int));
            workTable.Columns["외1505-증감"].Expression = "[외1320-계] - [외1505-계]";
            workTable.Columns["기1505-증감"].Expression = "[기1320-계] - [기1505-계]";
            workTable.Columns["1505-소계"].Expression  = "[외1505-계] + [기1505-계]";

            foreach (dynamic item in json.dataList)
            {
                //DataRow[] foundRows = workTable.Select("종목코드 = '" + item["stockCode"] + "'");
                //if (foundRows == null || foundRows.Length == 0)
                //{
                DataRow workRow = workTable.NewRow();
                workRow["종목코드"] = item["stockCode"];
                workRow["종목명"]  = item["stockName"];

                workRow["외0920-계"] = strToInt((string)item["fgn_0920"]);

                workRow["외0950-계"] = strToInt((string)item["fgn_0950"]);
                workRow["기0950-계"] = strToInt((string)item["inv_0950"]);
                workRow["외1100-계"] = strToInt((string)item["fgn_1100"]);
                workRow["기1100-계"] = strToInt((string)item["inv_1100"]);
                workRow["외1320-계"] = strToInt((string)item["fgn_1320"]);
                workRow["기1320-계"] = strToInt((string)item["inv_1320"]);
                workRow["외1505-계"] = strToInt((string)item["fgn_1505"]);
                workRow["기1505-계"] = strToInt((string)item["inv_1505"]);

                workTable.Rows.Add(workRow);
                //}
            }

            dataGridView1.DataSource = workTable;
            dataGridView1.AutoResizeColumns();

            dataGridView1.Columns["외0920-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외0950-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외0950-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기0950-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["0950-소계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1100-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1100-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1100-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1100-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["1100-소계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1320-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1320-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1320-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1320-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["1320-소계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1505-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1505-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1505-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1505-계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["1505-소계"].DefaultCellStyle.Alignment  = DataGridViewContentAlignment.MiddleRight;

            dataGridView1.Columns["외0920-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["외0950-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외0950-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["기0950-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["0950-소계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["외1100-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1100-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["기1100-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1100-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["1100-소계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["외1320-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1320-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["기1320-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1320-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["1320-소계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["외1505-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1505-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["기1505-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1505-계"].DefaultCellStyle.Format  = "N0";
            dataGridView1.Columns["1505-소계"].DefaultCellStyle.Format  = "N0";
        }
Пример #3
0
        /// <summary>
        /// 다음 조회 버튼 클릭시 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearchNext_Click(object sender, EventArgs e)
        {
            if (workTable == null)
            {
                MessageBox.Show("조회 후 추가 조회하세요.");
                return;
            }

            // 자료일자
            string dateFrom = this.dateTimeFrom.Value.ToString("yyyyMMdd");
            string dateTo = this.dateTimeTo.Value.ToString("yyyyMMdd");

            string dataDate = dateFrom;
            if (!dateFrom.Equals(dateTo))
                dataDate += "-" + dateTo;

            // 자료 조회
            // 조회URL: manager/log/<자료일자>?옵션
            HttpRestClient client = new HttpRestClient("manager/error/" + dataDate);

            // 조회조건
            if (comboAPIKEY.Text.Length > 0)
                client.QueryString.Add("apikey", comboAPIKEY.Text);

            if (txtRequestId.Text.Length > 0)
                client.QueryString.Add("requestid", txtRequestId.Text);

            // 페이징처리...
            if (lastNo != null && lastNo.Length > 0)
                client.QueryString.Add("startno", lastNo);

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            // 응답 데이터 처리
            dynamic json = client.getJsonObject();

            foreach (dynamic item in json.dataList)
            {
                DataRow workRow = workTable.NewRow();
                workRow["No"] = item["no"];

                string date = (string)item["date"];
                date = date.Substring(0, 4) + "-" + date.Substring(4, 2) + "-" + date.Substring(6, 2);
                workRow["Date"] = date;

                string time = (string)item["time"];
                time = time.Substring(0, 2) + ":" + time.Substring(2, 2) + ":" + time.Substring(4, 2);
                workRow["Time"] = time;

                workRow["API Key"] = item["apiKey"];
                workRow["Ticket ID"] = item["reuqestId"];
                workRow["Message"] = item["message"];
                workRow["Trace"] = item["trace"];

                workTable.Rows.Add(workRow);

                lastNo = (string)item["no"];
            }

            dataGridView1.AutoResizeColumns();
        }
        /// <summary>
        /// 새 버전 체크
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkNewVersion_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HttpRestClient client = new HttpRestClient("clientversion");

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            dynamic json = client.getJsonObject();

            if (json == null)
            {
                MessageBox.Show("전송 오류가 발생했습니다. (JSON 포맷오류)", "Format error!");
                return;
            }
            Console.WriteLine("statusCode: " + json["_metadata"]["statusCode"]);
            Console.WriteLine("version [" + json["clientversion"] + "]");
            Console.WriteLine("setup [" + json["clientsetup"] + "]");
            Console.WriteLine("md5 [" + json["clientmd5"] + "]");

            Version current = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            Version future  = new Version((string)json["clientversion"]);

            if (current >= future)
            {
                if (!hiddenUpdateMessage)
                {
                    MessageBox.Show("최신 버전을 사용하고 있습니다.", "버전 확인");
                }
                hiddenUpdateMessage = false;
                return;
            }
            else
            {
                MessageBox.Show("새 버전이 있습니다. [" + future.ToString() + "]", "버전 확인");

                // 새 버전 자동 다운로드
                client            = new HttpRestClient();
                client.RequestUri = (string)json["clientsetup"];
                if (!client.doWorkDialog())
                {
                    MessageBox.Show("다운로드 오류: " + client.ResponseMessage, "Request error!");
                    return;
                }

                string md5value = "";
                using (MD5 md5sum = MD5.Create())
                {
                    byte[] hashValue = md5sum.ComputeHash(client.ResponseContent);
                    for (int i = 0; i < hashValue.Length; i++)
                    {
                        md5value += hashValue[i].ToString("x2");
                    }
                }
                if (!md5value.Equals((string)json["clientmd5"]))
                {
                    MessageBox.Show("다운로드 파일 오류입니다. (md5 불일치)", "버전 확인");
                    return;
                }

                // 다운로드한 파일을 저장
                string localFileName = AppDomain.CurrentDomain.BaseDirectory + System.IO.Path.DirectorySeparatorChar + "Setup.exe";
                using (FileStream fs = File.Create(localFileName))
                {
                    fs.Write(client.ResponseContent, 0, client.ResponseContent.Length);
                }

                // 저장한 파일을 실행
                System.Diagnostics.Process.Start(localFileName);

                // 현재 프로그램을 종료
                exit_ToolStripMenuItem_Click(sender, e);
            }
        }
Пример #5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //조회
            MasterList master = null;
            if (radioBtn기관.Checked)
                master = DataMasterCache.getDataMasterByName("기관잠정치매매");
            else if (radioBtn외인.Checked)
                master = DataMasterCache.getDataMasterByName("외인잠정치매매");
            else if (radioBtn외인기관.Checked)
                master = DataMasterCache.getDataMasterByName("외인기관쌍끌이잠정치매매");

            if (master == null)
            {
                MessageBox.Show("자료 종류 중 하나를 선택하세요.", "Error");
                return;
            }

            // 자료일자
            DateTime d = this.datePicker.Value;
            string dataDate = d.ToString("yyyyMMdd");

            Console.WriteLine("자료종류: " + master.id + ":" + master.name);
            Console.WriteLine("자료일자: " + dataDate);

            // 자료 조회
            // 조회URL: data/<자료종류>/<자료일자>?stockcode=종목코드
            string resource_value = master.id + "/" + dataDate;
            HttpRestClient client = new HttpRestClient("report/listview/" + resource_value);

            // 조회조건
            if (txtStockCodes.Text.Length > 0)
                client.QueryString.Add("stockcode", txtStockCodes.Text);

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            // 응답 데이터 처리
            dynamic json = client.getJsonObject();

            DataTable workTable = new DataTable("Report");
            workTable.Columns.Add("종목코드", typeof(String));
            workTable.Columns.Add("종목명", typeof(String));

            workTable.Columns.Add("외0920-계", typeof(int));       // field

            workTable.Columns.Add("외0950-증감", typeof(int));
            workTable.Columns.Add("외0950-계", typeof(int));       // field
            //workTable.Columns.Add("기0950-증감", typeof(int));
            workTable.Columns.Add("기0950-계", typeof(int));       // field
            workTable.Columns.Add("0950-소계", typeof(int));
            workTable.Columns["외0950-증감"].Expression = "[외0950-계] - [외0920-계]";
            workTable.Columns["0950-소계"].Expression = "[외0950-계] + [기0950-계]";

            workTable.Columns.Add("외1100-증감", typeof(int));
            workTable.Columns.Add("외1100-계", typeof(int));       // field
            workTable.Columns.Add("기1100-증감", typeof(int));
            workTable.Columns.Add("기1100-계", typeof(int));       // field
            workTable.Columns.Add("1100-소계", typeof(int));
            workTable.Columns["외1100-증감"].Expression = "[외0950-계] - [외1100-계]";
            workTable.Columns["기1100-증감"].Expression = "[기0950-계] - [기1100-계]";
            workTable.Columns["1100-소계"].Expression = "[외1100-계] + [기1100-계]";

            workTable.Columns.Add("외1320-증감", typeof(int));
            workTable.Columns.Add("외1320-계", typeof(int));       // field
            workTable.Columns.Add("기1320-증감", typeof(int));
            workTable.Columns.Add("기1320-계", typeof(int));       // field
            workTable.Columns.Add("1320-소계", typeof(int));
            workTable.Columns["외1320-증감"].Expression = "[외1100-계] - [외1320-계]";
            workTable.Columns["기1320-증감"].Expression = "[기1100-계] - [기1320-계]";
            workTable.Columns["1320-소계"].Expression = "[외1320-계] + [기1320-계]";

            workTable.Columns.Add("외1505-증감", typeof(int));
            workTable.Columns.Add("외1505-계", typeof(int));       // field
            workTable.Columns.Add("기1505-증감", typeof(int));
            workTable.Columns.Add("기1505-계", typeof(int));       // field
            workTable.Columns.Add("1505-소계", typeof(int));
            workTable.Columns["외1505-증감"].Expression = "[외1320-계] - [외1505-계]";
            workTable.Columns["기1505-증감"].Expression = "[기1320-계] - [기1505-계]";
            workTable.Columns["1505-소계"].Expression = "[외1505-계] + [기1505-계]";

            foreach (dynamic item in json.dataList)
            {
                //DataRow[] foundRows = workTable.Select("종목코드 = '" + item["stockCode"] + "'");
                //if (foundRows == null || foundRows.Length == 0)
                //{
                DataRow workRow = workTable.NewRow();
                workRow["종목코드"] = item["stockCode"];
                workRow["종목명"] = item["stockName"];

                workRow["외0920-계"] = strToInt((string)item["fgn_0920"]);

                workRow["외0950-계"] = strToInt((string)item["fgn_0950"]);
                workRow["기0950-계"] = strToInt((string)item["inv_0950"]);
                workRow["외1100-계"] = strToInt((string)item["fgn_1100"]);
                workRow["기1100-계"] = strToInt((string)item["inv_1100"]);
                workRow["외1320-계"] = strToInt((string)item["fgn_1320"]);
                workRow["기1320-계"] = strToInt((string)item["inv_1320"]);
                workRow["외1505-계"] = strToInt((string)item["fgn_1505"]);
                workRow["기1505-계"] = strToInt((string)item["inv_1505"]);

                workTable.Rows.Add(workRow);
                //}
            }

            dataGridView1.DataSource = workTable;
            dataGridView1.AutoResizeColumns();

            dataGridView1.Columns["외0920-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외0950-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외0950-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기0950-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["0950-소계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1100-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1100-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1100-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1100-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["1100-소계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1320-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1320-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1320-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1320-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["1320-소계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1505-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["외1505-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1505-증감"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["기1505-계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            dataGridView1.Columns["1505-소계"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            dataGridView1.Columns["외0920-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외0950-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외0950-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기0950-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["0950-소계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1100-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1100-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1100-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1100-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["1100-소계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1320-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1320-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1320-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1320-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["1320-소계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1505-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["외1505-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1505-증감"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["기1505-계"].DefaultCellStyle.Format = "N0";
            dataGridView1.Columns["1505-소계"].DefaultCellStyle.Format = "N0";
        }
Пример #6
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (isRegistered)
            {
                MessageBox.Show("이미 등록했습니다.", "Error");
                return;
            }

            if (!isParsed)
            {
                MessageBox.Show("미분석 파일입니다.", "Error");
                return;
            }

            if (this.listDataTypes.SelectedIndex < 0)
            {
                MessageBox.Show("자료 종류를 선택하지 않았습니다.", "Error");
                return;
            }

            if (this.listDataTimes.SelectedIndex < 0)
            {
                MessageBox.Show("시간을 선택하지 않았습니다.", "Error");
                return;
            }

            // 자료 종류
            MasterList selectedMaster = (MasterList)this.listDataTypes.SelectedItem;
            string dataTypeName = selectedMaster.name;
            int dataTypeId = selectedMaster.id;

            // 자료 시간
            string dataTime = (string)this.listDataTimes.SelectedValue;

            // 자료일자
            DateTime d = this.datePicker.Value;
            string dataDate = d.ToString("yyyyMMdd");

            Console.WriteLine("자료종류: " + dataTypeId + ":" + dataTypeName);
            Console.WriteLine("자료일자: " + dataDate);
            Console.WriteLine("자료시간: " + dataTime);

            // 자료 등록 처리
            // 등록URL: data/<자료종류>/<자료일자>/<자료시간>
            string resource_value = dataTypeId + "/" + dataDate + "/" + dataTime;
            HttpRestClient client = new HttpRestClient(HttpRestClient.REST_METHOD_CREATE, "data/" + resource_value);

            client.RequestDataFormat = HttpRestClient.DATA_FORMAT_JSON;
            string jsonStr = JsonConvert.SerializeObject(samFileParser.DataItems);
            client.RequestContent = Encoding.UTF8.GetBytes(jsonStr);

            // -------------------------------------------
            //Console.WriteLine(jsonStr);
            //File.WriteAllText("json.txt", jsonStr);

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            dynamic json = client.getJsonObject();
            if (json == null)
            {
                MessageBox.Show("전송 오류가 발생했습니다. (Can't convert json)", "Format error!");
                return;
            }
            Console.WriteLine("statusCode: " + json["_metadata"]["statusCode"]);

            if (json["FieldNotFound"] != null && ((string)json["FieldNotFound"]).Length > 0)
            {
                MessageBox.Show("다음 항목은 미등록 항목으로 저장하지 않았습니다.\n" + ((string)json["FieldNotFound"]), "주의");
            }

            //json["ErrorData"];

            if ((int)json["Rows"] == 0)
                MessageBox.Show("등록 건수가 없습니다. 중복여부를 확인하세요.", "등록오류");
            else
                MessageBox.Show(((string)json["Rows"]) + "건 등록이 완료되었습니다.", "등록완료");

            isRegistered = true;
        }
Пример #7
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //조회
            MasterList master = null;
            if (radioBtn강력.Checked)
                master = DataMasterCache.getDataMasterByName("강력출동");
            else if (radioBtn거래이평.Checked)
                master = DataMasterCache.getDataMasterByName("거래20이평");

            if (master == null)
            {
                MessageBox.Show("자료 종류 중 하나를 선택하세요.", "Error");
                return;
            }

            // 자료일자
            DateTime d1 = this.datePicker1.Value;
            string dataDate1 = d1.ToString("yyyyMMdd");
            DateTime d2 = this.datePicker2.Value;
            string dataDate2 = d2.ToString("yyyyMMdd");

            Console.WriteLine("자료종류: " + master.id + ":" + master.name);
            Console.WriteLine("자료일자: " + dataDate1 + " ~ " + dataDate2);

            string dataDate = dataDate1;
            if (!dataDate1.Equals(dataDate2))
                dataDate += "-" + dataDate2;

            // 자료 조회
            // 조회URL: data/<자료종류>/<자료일자>?stockcode=종목코드
            string resource_value = master.id + "/" + dataDate;
            HttpRestClient client = new HttpRestClient("report/diffview/" + resource_value);

            // 조회조건
            if (txtStockCodes.Text.Length > 0)
                client.QueryString.Add("stockcode", txtStockCodes.Text);

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            // 응답 데이터 처리
            dynamic json = client.getJsonObject();

            DataTable workTable = new DataTable("Report");
            workTable.Columns.Add("자료일자", typeof(String));

            workTable.Columns.Add("09:30", typeof(String));
            workTable.Columns.Add("10:00", typeof(String));
            workTable.Columns.Add("11:00", typeof(String));
            workTable.Columns.Add("12:00", typeof(String));
            workTable.Columns.Add("13:00", typeof(String));
            workTable.Columns.Add("14:00", typeof(String));
            workTable.Columns.Add("15:30", typeof(String));
            workTable.Columns.Add("종목코드", typeof(String));

            foreach (dynamic item in json.dataList)
            {
                DataRow workRow = workTable.NewRow();
                string gsdate = (string)item["gsDate"];
                gsdate = gsdate.Substring(0, 4) + "-" + gsdate.Substring(4, 2) + "-" + gsdate.Substring(6, 2);
                workRow["자료일자"] = gsdate;
                string stCode = (string)item["stockCode"];
                string stName = (string)item["stockName"];
                workRow["종목코드"] = stCode;

                workRow["09:30"] = codeToName((string)item["ST0930"], stCode, stName);
                workRow["10:00"] = codeToName((string)item["ST1000"], stCode, stName);
                workRow["11:00"] = codeToName((string)item["ST1100"], stCode, stName);
                workRow["12:00"] = codeToName((string)item["ST1200"], stCode, stName);
                workRow["13:00"] = codeToName((string)item["ST1300"], stCode, stName);
                workRow["14:00"] = codeToName((string)item["ST1400"], stCode, stName);
                workRow["15:30"] = codeToName((string)item["ST1530"], stCode, stName);

                workTable.Rows.Add(workRow);
            }

            dataGridView1.DataSource = workTable;
            dataGridView1.AutoResizeColumns();
        }
Пример #8
0
        /// <summary>
        /// 새 버전 체크
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkNewVersion_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HttpRestClient client = new HttpRestClient("clientversion");
            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            dynamic json = client.getJsonObject();
            if (json == null)
            {
                MessageBox.Show("전송 오류가 발생했습니다. (JSON 포맷오류)", "Format error!");
                return;
            }
            Console.WriteLine("statusCode: " + json["_metadata"]["statusCode"]);
            Console.WriteLine("version [" + json["clientversion"] + "]");
            Console.WriteLine("setup [" + json["clientsetup"] + "]");
            Console.WriteLine("md5 [" + json["clientmd5"] + "]");

            Version current = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            Version future = new Version((string)json["clientversion"]);

            if (current >= future)
            {
                if (!hiddenUpdateMessage)
                    MessageBox.Show("최신 버전을 사용하고 있습니다.", "버전 확인");
                hiddenUpdateMessage = false;
                return;
            }
            else
            {
                MessageBox.Show("새 버전이 있습니다. [" + future.ToString() + "]", "버전 확인");

                // 새 버전 자동 다운로드
                client = new HttpRestClient();
                client.RequestUri = (string)json["clientsetup"];
                if (!client.doWorkDialog())
                {
                    MessageBox.Show("다운로드 오류: " + client.ResponseMessage, "Request error!");
                    return;
                }

                string md5value = "";
                using (MD5 md5sum = MD5.Create())
                {
                    byte[] hashValue = md5sum.ComputeHash(client.ResponseContent);
                    for (int i = 0; i < hashValue.Length; i++)
                    {
                        md5value += hashValue[i].ToString("x2");
                    }
                }
                if (!md5value.Equals((string)json["clientmd5"]))
                {
                    MessageBox.Show("다운로드 파일 오류입니다. (md5 불일치)", "버전 확인");
                    return;
                }

                // 다운로드한 파일을 저장
                string localFileName = AppDomain.CurrentDomain.BaseDirectory + System.IO.Path.DirectorySeparatorChar + "Setup.exe";
                using (FileStream fs = File.Create(localFileName))
                {
                    fs.Write(client.ResponseContent, 0, client.ResponseContent.Length);
                }

                // 저장한 파일을 실행
                System.Diagnostics.Process.Start(localFileName);

                // 현재 프로그램을 종료
                exit_ToolStripMenuItem_Click(sender, e);
            }
        }
Пример #9
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //조회
            MasterList master = null;

            if (radioBtn강력.Checked)
            {
                master = DataMasterCache.getDataMasterByName("강력출동");
            }
            else if (radioBtn거래이평.Checked)
            {
                master = DataMasterCache.getDataMasterByName("거래20이평");
            }

            if (master == null)
            {
                MessageBox.Show("자료 종류 중 하나를 선택하세요.", "Error");
                return;
            }

            // 자료일자
            DateTime d1        = this.datePicker1.Value;
            string   dataDate1 = d1.ToString("yyyyMMdd");
            DateTime d2        = this.datePicker2.Value;
            string   dataDate2 = d2.ToString("yyyyMMdd");

            Console.WriteLine("자료종류: " + master.id + ":" + master.name);
            Console.WriteLine("자료일자: " + dataDate1 + " ~ " + dataDate2);

            string dataDate = dataDate1;

            if (!dataDate1.Equals(dataDate2))
            {
                dataDate += "-" + dataDate2;
            }

            // 자료 조회
            // 조회URL: data/<자료종류>/<자료일자>?stockcode=종목코드
            string         resource_value = master.id + "/" + dataDate;
            HttpRestClient client         = new HttpRestClient("report/diffview/" + resource_value);

            // 조회조건
            if (txtStockCodes.Text.Length > 0)
            {
                client.QueryString.Add("stockcode", txtStockCodes.Text);
            }

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            // 응답 데이터 처리
            dynamic json = client.getJsonObject();

            DataTable workTable = new DataTable("Report");

            workTable.Columns.Add("자료일자", typeof(String));

            workTable.Columns.Add("09:30", typeof(String));
            workTable.Columns.Add("10:00", typeof(String));
            workTable.Columns.Add("11:00", typeof(String));
            workTable.Columns.Add("12:00", typeof(String));
            workTable.Columns.Add("13:00", typeof(String));
            workTable.Columns.Add("14:00", typeof(String));
            workTable.Columns.Add("15:30", typeof(String));
            workTable.Columns.Add("종목코드", typeof(String));

            foreach (dynamic item in json.dataList)
            {
                DataRow workRow = workTable.NewRow();
                string  gsdate  = (string)item["gsDate"];
                gsdate          = gsdate.Substring(0, 4) + "-" + gsdate.Substring(4, 2) + "-" + gsdate.Substring(6, 2);
                workRow["자료일자"] = gsdate;
                string stCode = (string)item["stockCode"];
                string stName = (string)item["stockName"];
                workRow["종목코드"] = stCode;

                workRow["09:30"] = codeToName((string)item["ST0930"], stCode, stName);
                workRow["10:00"] = codeToName((string)item["ST1000"], stCode, stName);
                workRow["11:00"] = codeToName((string)item["ST1100"], stCode, stName);
                workRow["12:00"] = codeToName((string)item["ST1200"], stCode, stName);
                workRow["13:00"] = codeToName((string)item["ST1300"], stCode, stName);
                workRow["14:00"] = codeToName((string)item["ST1400"], stCode, stName);
                workRow["15:30"] = codeToName((string)item["ST1530"], stCode, stName);

                workTable.Rows.Add(workRow);
            }

            dataGridView1.DataSource = workTable;
            dataGridView1.AutoResizeColumns();
        }
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (isRegistered)
            {
                MessageBox.Show("이미 등록했습니다.", "Error");
                return;
            }

            if (!isParsed)
            {
                MessageBox.Show("미분석 파일입니다.", "Error");
                return;
            }

            if (this.listDataTypes.SelectedIndex < 0)
            {
                MessageBox.Show("자료 종류를 선택하지 않았습니다.", "Error");
                return;
            }

            if (this.listDataTimes.SelectedIndex < 0)
            {
                MessageBox.Show("시간을 선택하지 않았습니다.", "Error");
                return;
            }

            // 자료 종류
            MasterList selectedMaster = (MasterList)this.listDataTypes.SelectedItem;
            string     dataTypeName   = selectedMaster.name;
            int        dataTypeId     = selectedMaster.id;

            // 자료 시간
            string dataTime = (string)this.listDataTimes.SelectedValue;

            // 자료일자
            DateTime d        = this.datePicker.Value;
            string   dataDate = d.ToString("yyyyMMdd");

            Console.WriteLine("자료종류: " + dataTypeId + ":" + dataTypeName);
            Console.WriteLine("자료일자: " + dataDate);
            Console.WriteLine("자료시간: " + dataTime);

            // 자료 등록 처리
            // 등록URL: data/<자료종류>/<자료일자>/<자료시간>
            string         resource_value = dataTypeId + "/" + dataDate + "/" + dataTime;
            HttpRestClient client         = new HttpRestClient(HttpRestClient.REST_METHOD_CREATE, "data/" + resource_value);

            client.RequestDataFormat = HttpRestClient.DATA_FORMAT_JSON;
            string jsonStr = JsonConvert.SerializeObject(samFileParser.DataItems);

            client.RequestContent = Encoding.UTF8.GetBytes(jsonStr);

            // -------------------------------------------
            //Console.WriteLine(jsonStr);
            //File.WriteAllText("json.txt", jsonStr);

            if (!client.doWorkDialog())
            {
                client.showErrorDialog();
                return;
            }

            dynamic json = client.getJsonObject();

            if (json == null)
            {
                MessageBox.Show("전송 오류가 발생했습니다. (Can't convert json)", "Format error!");
                return;
            }
            Console.WriteLine("statusCode: " + json["_metadata"]["statusCode"]);

            if (json["FieldNotFound"] != null && ((string)json["FieldNotFound"]).Length > 0)
            {
                MessageBox.Show("다음 항목은 미등록 항목으로 저장하지 않았습니다.\n" + ((string)json["FieldNotFound"]), "주의");
            }

            //json["ErrorData"];

            if ((int)json["Rows"] == 0)
            {
                MessageBox.Show("등록 건수가 없습니다. 중복여부를 확인하세요.", "등록오류");
            }
            else
            {
                MessageBox.Show(((string)json["Rows"]) + "건 등록이 완료되었습니다.", "등록완료");
            }

            isRegistered = true;
        }