public static bool insertOrder(string symbol, string expiry, string callput, string exch, string strike, double price, int qty, char action, TradingBoxV2 tb) { tradingBox = tb; try { //Console.WriteLine("Format : INS:SYM:Price:Quantity:direction:machineID:userID\n"); //Console.WriteLine("usage Number of Test Cases followed by input per line <INS:AAPL:111.90:1:B> or <CAN:AAPL:0:111.90:1:B>\nDesc : INS:SYMBOL:PRICE:QTY:DIR"); /*byte[] bytesFrom = new byte[(int)clientSocket.ReceiveBufferSize + 1]; * networkStream.Read(bytesFrom, 0, (int)clientSocket.ReceiveBufferSize); * reqType = System.Text.Encoding.ASCII.GetString(bytesFrom); * Console.WriteLine("Received : " + reqType); * clientSocket.Close(); */ string reqType = null; Byte[] sendBytes = null; //stringToStruct("INS:AAPL0000:111.90:1:B:21:25", ref os); string input = "INS:" + symbol + ":" + price + ":" + qty + ":" + strike + ":" + action + ":" + expiry + ":" + callput + ":" + exch + ":" + MachineGuid + ":" + UserGuid; tradingBox.displayTextArea(input); OrderStruct os = new OrderStruct(8, 8); stringToStruct(input, ref os); os.display(); TcpClient clientSocket = new TcpClient(); tradingBox.displayTextArea("Connecting....."); clientSocket.Connect("127.0.0.1", 5552); // use the ipaddress as in the server program tradingBox.displayTextArea("Connected ..."); NetworkStream networkStream = clientSocket.GetStream(); sendBytes = (getBytes(os)); networkStream.Write(sendBytes, 0, sendBytes.Length); tradingBox.displayTextArea("written " + sendBytes.Length + " bytes."); System.Threading.Thread.Sleep(200); networkStream.Flush(); byte[] bytesFrom = new byte[(Int32)clientSocket.ReceiveBufferSize + 1]; networkStream.Read(bytesFrom, 0, (Int32)clientSocket.ReceiveBufferSize); reqType = System.Text.Encoding.ASCII.GetString(bytesFrom); tradingBox.displayTextArea("Received : " + reqType); clientSocket.Close(); return(true); } catch (Exception e) { tradingBox.displayTextArea("Error..... " + e.StackTrace); } return(false); }
private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridView dgv = sender as DataGridView; if (dgv == null) { return; } if (dgv.CurrentRow.Selected) { //do you staff. DataGridViewRow row = dgv.CurrentRow; DataGridViewCell dgvCell1 = row.Cells[1]; string symbol = dgvCell1.Value.ToString(); DataGridViewCell dgvCell2 = row.Cells[2]; string expiry = dgvCell2.Value.ToString(); DataGridViewCell dgvCell3 = row.Cells[3]; string strike = dgvCell3.Value.ToString(); DataGridViewCell dgvCell4 = row.Cells[4]; string callput = dgvCell4.Value.ToString(); DataGridViewCell dgvCell5 = row.Cells[5]; string exch = dgvCell5.Value.ToString(); DataGridViewCell dgvCell7 = row.Cells[7]; string LTP = dgvCell7.Value.ToString(); DataGridViewCell dgvCell8 = row.Cells[8]; string quantity = dgvCell8.Value.ToString(); string feedKey = symbol + "," + expiry + "," + strike + "," + callput + "," + exch; TradingBoxV2 box1 = new TradingBoxV2(feedKey); box1.Show(); } }