public void sendmessage(StremEntity entity) { if (entity != null) { if (entity.header.Equals("0022")) { STRUCT_0022 data = new STRUCT_0022(entity.topic, entity.content); data0022 = data; dataProc(data); /* * if (querrydata != null) * { * mainForm.view2.dataProc(querrydata); * } */ } else if (entity.header.Equals("0374")) { STRUCT_0374 data = new STRUCT_0374(entity.topic, entity.content); if (data0022 != null) { querrydata = dataProc_Query(data, data0022); dataProc(querrydata); } } } }
public STRUCT_0374_0022 dataProc_Query(STRUCT_0374 data, STRUCT_0022 data2) { PropertyInfo[] Props0022 = typeof(STRUCT_0022).GetProperties(BindingFlags.Public | BindingFlags.Instance); DataTable dt0022 = null; string tableName = "STRUCT_0022_" + data.topic; if (mainForm.dataTableMap.ContainsKey(tableName)) { dt0022 = mainForm.dataTableMap[tableName]; } else { dt0022 = new DataTable(); dt0022.TableName = tableName; foreach (PropertyInfo prop in Props0022) { dt0022.Columns.Add(prop.Name); } mainForm.dataTableMap.Add(tableName, dt0022); } if (data.topic.Contains("TXT1")) { seq_topic1++; return(new STRUCT_0374_0022(seq_topic1, data.topic, data, data2)); } else { seq_topic2++; return(new STRUCT_0374_0022(seq_topic2, data.topic, data, data2)); } }
public void GetDataFromQueue() { STRUCT_0374_0022 querrydata = null; STRUCT_0022 data0022 = null; while (true) { while (mainForm.messageQueue.Count > 0) { StremEntity entity = mainForm.messageQueue.Dequeue(); if (entity != null) { if (entity.header.Equals("0022")) { STRUCT_0022 data = new STRUCT_0022(entity.topic, entity.content); data0022 = data; dataProc(data); /* * if (querrydata != null) * { * mainForm.view2.dataProc(querrydata); * } */ } else if (entity.header.Equals("0374")) { STRUCT_0374 data = new STRUCT_0374(entity.topic, entity.content); if (data0022 != null) { querrydata = dataProc_Query(data, data0022); dataProc(querrydata); } } } // Thread.Sleep(1); } } }
public void dataProc(STRUCT_0022 data) { Mainform.logger.Info("STRUCT_0022"); DataTable dt = null; DataTable dt_min = null; PropertyInfo[] Props = typeof(STRUCT_0022).GetProperties(BindingFlags.Public | BindingFlags.Instance); string tableName = "STRUCT_0022_" + data.topic; if (mainForm.dataTableMap.ContainsKey(tableName)) { dt = mainForm.dataTableMap[tableName]; dt_min = mainForm.dataTableMap[tableName + "_MIN"]; } else { dt = new DataTable(); dt_min = new DataTable(); dt.TableName = tableName; dt_min.TableName = tableName + "_MIN"; foreach (PropertyInfo prop in Props) { dt.Columns.Add(prop.Name); dt_min.Columns.Add(prop.Name); if (prop.Name.Equals("formatDateTime") || prop.Name.Equals("VALUE")) { } else { dt_min.Columns[prop.Name].ColumnMapping = MappingType.Hidden; } } mainForm.dataTableMap.Add(tableName, dt); mainForm.dataTableMap.Add(tableName + "_MIN", dt_min); if (this.InvokeRequired) { this.EndInvoke( this.BeginInvoke((Action) delegate { if (data.topic.Contains("TXT1")) { mainForm.view2.chart1.DataSource = dt_min; mainForm.view2.chart1.Series.Add("MSG_VALUE"); mainForm.view2.chart1.Series["MSG_VALUE"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; mainForm.view2.chart1.Series["MSG_VALUE"].XValueMember = "chartTime"; mainForm.view2.chart1.Series["MSG_VALUE"].YValueMembers = "MSG_VALUE"; mainForm.view2.chart1.DataBind(); } else { mainForm.view2.chart2.DataSource = dt_min; mainForm.view2.chart2.Series.Add("MSG_VALUE"); mainForm.view2.chart2.Series["MSG_VALUE"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; mainForm.view2.chart2.Series["MSG_VALUE"].XValueMember = "chartTime"; mainForm.view2.chart2.Series["MSG_VALUE"].YValueMembers = "MSG_VALUE"; mainForm.view2.chart2.DataBind(); } }) ); } } DataRow row = dt.NewRow(); var values = new object[Props.Length]; for (int i = 0; i < Props.Length; i++) { row[i] = Props[i].GetValue(data, null); } dt.Rows.Add(row); if (this.InvokeRequired) { this.EndInvoke( this.BeginInvoke((Action) delegate { DataRow row_min = dt_min.NewRow(); var values_min = new object[Props.Length]; for (int i = 0; i < Props.Length; i++) { row_min[i] = Props[i].GetValue(data, null); } if (data.topic.Contains("TXT1")) { if (chart1min < data.dateTime.Minute) { chart1min = data.dateTime.Minute; dt_min.Rows.Add(row_min); mainForm.view2.dataGridView1.DataSource = dt_min; mainForm.view2.chart1.DataBind(); } } else { if (chart2min < data.dateTime.Minute) { chart2min = data.dateTime.Minute; dt_min.Rows.Add(row_min); mainForm.view2.dataGridView3.DataSource = dt_min; mainForm.view2.chart2.DataBind(); } } }) ); } }
public STRUCT_0374_0022(int seq, string topic, STRUCT_0374 s1, STRUCT_0022 s2) { this.seq = seq; this.topic = topic; this.MSG_LENGTH = s1.MSG_LENGTH; this.MSG_HEADER = s1.MSG_HEADER; this.MSG_DUMMY = s1.MSG_DUMMY; this.MESSAGE_SEQUENCE_NUMBER = s1.MESSAGE_SEQUENCE_NUMBER; this.TRANSACTION_CODE = s1.TRANSACTION_CODE; this.ME_GRP_NO = s1.ME_GRP_NO; this.BOARD_ID = s1.BOARD_ID; this.MEMBER_NUMBER = s1.MEMBER_NUMBER; this.BRANCH_NUMBER = s1.BRANCH_NUMBER; this.ORDER_IDENTIFICATION = s1.ORDER_IDENTIFICATION; this.ORIGINAL_ORDER_IDENTIFICATION = s1.ORIGINAL_ORDER_IDENTIFICATION; this.ISSUE_CODE = s1.ISSUE_CODE; this.TRADING_NUMBER = s1.TRADING_NUMBER; this.TRADING_PRICE = s1.TRADING_PRICE; this.TRADING_VOLUMN = s1.TRADING_VOLUMN; this.SESS_ID = s1.SESS_ID; this.TRADING_DATE = s1.TRADING_DATE; int year = Int32.Parse(TRADING_DATE.Substring(0, 4)); int month = Int32.Parse(TRADING_DATE.Substring(4, 2)); int day = Int32.Parse(TRADING_DATE.Substring(6, 2)); this.TRADING_TIME = s1.TRADING_TIME; int hours = Int32.Parse(TRADING_TIME.Substring(0, 2)); int minute = Int32.Parse(TRADING_TIME.Substring(2, 2)); int sec = Int32.Parse(TRADING_TIME.Substring(4, 2)); int milli = Int32.Parse(TRADING_TIME.Substring(6, 3)); DateTime dateTime = new DateTime(year, month, day, hours, minute, sec, milli); DateTime chartTime = new DateTime(year, month, day, hours, minute, 0, 0); this.formatDateTime = dateTime.ToString("HH:mm:ss.fff"); this.chartTime = chartTime; this.dateTime = dateTime; this.THE_NEARBY_MONTH_TRADING_PRICE = s1.THE_NEARBY_MONTH_TRADING_PRICE; this.THE_FUTURE_MONTH_TRADING_PRICE = s1.THE_FUTURE_MONTH_TRADING_PRICE; this.ASK_BID_TYPE_CODE = s1.ASK_BID_TYPE_CODE; this.ACCOUNT_NUMBER = s1.ACCOUNT_NUMBER; this.MARKET_MAKER_ORDER_TYPE_NUMBER = s1.MARKET_MAKER_ORDER_TYPE_NUMBER; this.TRUST_COMPANY_NUMBER = s1.TRUST_COMPANY_NUMBER; this.SUBSTITUTE_STOCK_CERTIFICATE_ACCOUNT_NUMBER = s1.SUBSTITUTE_STOCK_CERTIFICATE_ACCOUNT_NUMBER; this.MEMBER_USE_AREA = s1.MEMBER_USE_AREA; this.MSG_TIME = s2.MSG_TIME; int hours2 = Int32.Parse(MSG_TIME.Substring(0, 2)); int minute2 = Int32.Parse(MSG_TIME.Substring(3, 2)); int sec2 = Int32.Parse(MSG_TIME.Substring(6, 2)); int milli2 = Int32.Parse(MSG_TIME.Substring(9, 2)); DateTime dateTime2 = new DateTime(year, month, day, hours2, minute2, sec2, milli2); this.dateTime2 = dateTime2; this.formatDateTime2 = dateTime.ToString("HH:mm:ss.fff"); this.MSG_PLUS = s2.MSG_PLUS; this.MSG_VALUE = s2.MSG_VALUE; this.PRICE = (Double.Parse(TRADING_PRICE) * 100).ToString(); if (ASK_BID_TYPE_CODE.Equals("1")) { QTY = "-" + Int32.Parse(TRADING_VOLUMN).ToString();; } else { QTY = "+" + Int32.Parse(TRADING_VOLUMN).ToString(); } this.VALUE = MSG_PLUS + Double.Parse(MSG_VALUE).ToString(); }