private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!isValidView)
            {
                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);

            // 확인
            DialogResult result = MessageBox.Show("자료명: " + dataTypeName + "\n자료일자: " + dataDate + "\n자료시간: " + dataTime +
                                                  "\n\n삭제하시겠습니까? 삭제는 되돌릴 수 없습니다.", "주의", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result != DialogResult.Yes)
            {
                return;
            }

            // 삭제요청
            // 등록URL: data/<자료종류>/<자료일자>/<자료시간>
            string         resource_value = dataTypeId + "/" + dataDate + "/" + dataTime;
            HttpRestClient client         = new HttpRestClient(HttpRestClient.REST_METHOD_DELETE, "data/" + resource_value);

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

            MessageBox.Show("삭제요청이 처리되었습니다.", "완료");
        }
Пример #2
0
        /// <summary>
        /// 삭제 클릭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // 자료일자
            DateTime dateTimeFrom = this.dateTimeFrom.Value;
            DateTime dateTimeTo   = this.dateTimeTo.Value;
            DateTime curDate      = DateTime.Now;

            if (dateTimeFrom.Date > dateTimeTo.Date)
            {
                MessageBox.Show("대상일자 오류입니다. (시작일이 종료일보다 큼)");
                return;
            }

            if (dateTimeTo.Date >= curDate.Date)
            {
                MessageBox.Show("삭제대상일이 현재일자보다 같거나 큽니다.");
                return;
            }

            string dateFrom = dateTimeFrom.ToString("yyyyMMdd");
            string dateTo   = dateTimeTo.ToString("yyyyMMdd");
            string dataDate = dateFrom;

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

            // 확인
            DialogResult result = MessageBox.Show("자료일자: " + dataDate +
                                                  "\n\n삭제하시겠습니까? 삭제는 되돌릴 수 없습니다.", "주의", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result != DialogResult.Yes)
            {
                return;
            }

            // 자료 삭제요청
            // 삭제URL: manager/log/<자료일자>
            HttpRestClient client = new HttpRestClient(HttpRestClient.REST_METHOD_DELETE, "manager/log/" + dataDate);

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

            MessageBox.Show("삭제요청이 처리되었습니다.", "완료");
        }
Пример #3
0
        /// <summary>
        /// 검색버튼 클릭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e)
        {
            // 자료 조회
            // 조회URL: stockcode/?search=검색어
            HttpRestClient client = new HttpRestClient("stockcode");

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

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

            // 응답 데이터 처리
            StockCode data = JsonConvert.DeserializeObject <StockCode>(client.getString());

            // 리스트뷰 뷰 타입
            listView1.View = View.Details;
            // 데이터를 갱신하기 전에 UI쓰레드를 멈춘다.
            listView1.BeginUpdate();

            // 컬럼헤더 Clear
            listView1.Columns.Clear();

            listView1.Columns.Add("stockCode", "종목코드", 5 * 15);
            listView1.Columns.Add("stockName", "종목명", 9 * 15);
            listView1.Columns.Add("stockCate", "소속업종", 9 * 15);

            // 종목코드 찾음, 없을경우 새 row에 등록
            listView1.Items.Clear();
            foreach (StockCodeItem item in data.dataList)
            {
                ListViewItem listItem = new ListViewItem(item.stockCode);
                listItem.Name = item.stockCode;
                listItem.SubItems.Add(item.stockName);
                listItem.SubItems.Add(item.cateName);

                listView1.Items.Add(listItem);
            }

            // UI 쓰레드 재개
            listView1.EndUpdate();
        }
        private void btnSearch_Click(object sender, System.EventArgs e)
        {
            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("data/" + resource_value);

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

            DataRoot data = JsonConvert.DeserializeObject <DataRoot>(client.getString());

            Console.WriteLine("statusCode: " + data._metadata.statusCode);

            // 조회한 자료를 table로 생성한다...

            // 리스트뷰 뷰 타입
            listView.View = View.Details;
            // 데이터를 갱신하기 전에 UI쓰레드를 멈춘다.
            listView.BeginUpdate();

            // 컬럼헤더 Clear
            listView.Columns.Clear();

            listView.Columns.Add("stockCode", "종목코드", 5 * 15);
            listView.Columns.Add("stockName", "종목명", 9 * 15);
            foreach (DataHeader header in selectedMaster.dataHeader)
            {
                ColumnHeader hdrItem = new ColumnHeader();
                hdrItem.Text  = header.name;
                hdrItem.Name  = "" + header.id;
                hdrItem.Width = hdrItem.Text.Length * 15;
                listView.Columns.Add(hdrItem);
            }

            // 종목코드 찾음, 없을경우 새 row에 등록
            foreach (DataList item in data.dataList)
            {
                if (listView.Items.ContainsKey(item.stockCode))
                {
                    // 자료 있음 (기존자료 확인)
                    int idx = listView.Items.IndexOfKey(item.stockCode);
                    for (int i = 0; i < selectedMaster.dataHeader.Count; i++)
                    {
                        if (selectedMaster.dataHeader[i].id == item.itemKey)
                        {
                            // 0: 내부 key
                            // 1: 종목명
                            listView.Items[idx].SubItems[i + 2].Text = item.data;
                        }
                    }
                }
                else
                {
                    // 자료 없음 (새 자료 입력)
                    ListViewItem listItem = new ListViewItem(item.stockCode);
                    listItem.Name = item.stockCode;
                    listItem.SubItems.Add(item.stockName);

                    foreach (DataHeader header in selectedMaster.dataHeader)
                    {
                        if (header.id == item.itemKey)
                        {
                            listItem.SubItems.Add(item.data);
                        }
                        else
                        {
                            listItem.SubItems.Add("");
                        }
                    }

                    listView.Items.Add(listItem);
                }
            }

            // UI 쓰레드 재개
            listView.EndUpdate();

            /*
             * dataGridView1 버전
             * DataTable workTable = new DataTable("Report");
             * foreach (DataHeader header in master.dataHeader)
             * {
             *  workTable.Columns.Add(header.name, typeof(String));
             * }
             *
             * foreach (DataList item in data.dataList)
             * {
             *  DataRow[] foundRows = workTable.Select("종목코드 = '" + item.stockCode + "'");
             *  if (foundRows == null || foundRows.Length == 0)
             *  {
             *      DataRow workRow = workTable.NewRow();
             *      workRow["종목코드"] = item.stockCode;
             *      workRow["종목명"] = item.stockName;
             *      workRow[item.itemName] = item.data;
             *      workTable.Rows.Add(workRow);
             *  }
             *  else
             *  {
             *      foundRows[0].BeginEdit();
             *      foundRows[0][item.itemName] = item.data;
             *      foundRows[0].EndEdit();
             *  }
             * }
             *
             * dataGridView1.DataSource = workTable;
             * dataGridView1.AutoResizeColumns();
             */

            txtDataInfo.Text = dataTypeName + " / " + dataDate + " / " + dataTime;
            isValidView      = true;
        }
Пример #5
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();
        }
Пример #6
0
        /// <summary>
        /// 삭제 버튼 클릭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // 자료일자
            DateTime dateTimeFrom = this.dateTimeFrom.Value;
            DateTime dateTimeTo = this.dateTimeTo.Value;
            DateTime curDate = DateTime.Now;

            if (dateTimeFrom.Date > dateTimeTo.Date)
            {
                MessageBox.Show("대상일자 오류입니다. (시작일이 종료일보다 큼)");
                return;
            }

            if (dateTimeTo.Date >= curDate.Date)
            {
                MessageBox.Show("삭제대상일이 현재일자보다 같거나 큽니다.");
                return;
            }

            string dateFrom = dateTimeFrom.ToString("yyyyMMdd");
            string dateTo = dateTimeTo.ToString("yyyyMMdd");
            string dataDate = dateFrom;
            if (!dateFrom.Equals(dateTo))
                dataDate += "-" + dateTo;

            // 확인
            DialogResult result = MessageBox.Show("자료일자: " + dataDate +
                "\n\n삭제하시겠습니까? 삭제는 되돌릴 수 없습니다.", "주의", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (result != DialogResult.Yes)
                return;

            // 자료 삭제요청
            // 삭제URL: manager/log/<자료일자>
            HttpRestClient client = new HttpRestClient(HttpRestClient.REST_METHOD_DELETE, "manager/error/" + dataDate);

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

            MessageBox.Show("삭제요청이 처리되었습니다.", "완료");
        }
Пример #7
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();
        }
Пример #8
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";
        }
        /// <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);
            }
        }
Пример #10
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";
        }
Пример #11
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;
        }
Пример #12
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();
        }
Пример #13
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);
            }
        }
Пример #14
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;
        }