private void button1_Click(object sender, EventArgs e)
 {
     foreach(ListViewItem lv in listView1.Items) {
         Order o;
         for (int i = 0; i < Convert.ToInt32(lv.SubItems[2].Text); i++ )
         {
             if (lv.SubItems[0].Text.Equals("Bar"))
                 o = new Order(DateTime.Now, table, 1, Convert.ToDouble(lv.SubItems[3].Text) / Convert.ToDouble(lv.SubItems[2].Text), lv.SubItems[1].Text, OrderStatus.NotStarted, Locations.Bar);
             else
                 o = new Order(DateTime.Now, table, 1, Convert.ToDouble(lv.SubItems[3].Text) / Convert.ToDouble(lv.SubItems[2].Text), lv.SubItems[1].Text, OrderStatus.NotStarted, Locations.Kitchen);
             orders.Add(o);
         }
     }
     this.Close();
 }
        public void NewOrderNotification(Order order)
        {
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    NewOrderNotification(order);
                });
                return;
            }
            if (order.Price >= 0)
            {
                TreeNode tn = new TreeNode(order.Description);
                tn.BackColor = Color.IndianRed;
                tn.Name = order.Id;
                TreeNode temp = null;

                foreach (TreeNode tn2 in treeView1.Nodes)
                    if (tn2.Text.Equals(order.Table))
                        temp = tn2;

                temp.Nodes.Add(tn);

                temp.Expand();
                label7.Text = ordersServer.GetTableCheck(order.Table).ToString() + " €";
                label3.Text = ordersServer.GetTableTime(order.Table);
            }
            else if (order.Price == -1.0)
            {
                treeView1.Nodes.Add(order.Description);
            }
            else if (order.Price == -2.0)
            {

                foreach (TreeNode tn in treeView1.Nodes)
                {
                    if (tn.Text.Equals(order.Description))
                    {
                        treeView1.Nodes.Remove(tn);
                        return;
                    }
                }
            }
        }
        public void NewServerNotification(Operations op, Order order)
        {
            switch (op)
            {
                case Operations.NewOrder:
                    NewOrderNotification(order);
                    break;
                case Operations.Started:
                    OrderStartedNotification(order);
                    break;
                case Operations.Finished:
                    OrderFinishedNotification(order);
                    break;
                case Operations.Removed:
                    OrderRemovedNotification(order);
                    break;

            }
        }
 //-- 20075
 public void ORDER_CXL_CONFIRMATION_TR(byte[] buffer)
 {
     Console.WriteLine("ORDER_CXL_CONFIRMATION_TR ******** count " + ++count12);
     MS_OE_RESPONSE_TR obj = (MS_OE_RESPONSE_TR)DataPacket.RawDeserialize(buffer, typeof(MS_OE_RESPONSE_TR));
     int ch = Holder.holderOrder[LogicClass.DoubleEndianChange(obj.OrderNumber)].GetType();
     switch (ch)
     {
         case 1:
             {
                 var ob = new Order((int)_Type.MS_OE_REQUEST);
                 Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.OrderNumber), out ob);
                 break;
             }
         case 2:
             {
                 var ob = new Order((int)_Type.MS_OE_RESPONSE_TR);
                 Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.OrderNumber), out ob);
                 break;
             }
         case 3:
             {
                 var ob = new Order((int)_Type.MS_SPD_OE_REQUEST);
                 Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.OrderNumber), out ob);
                 break;
             }
     }
 }
 //-- 2075
 public void ORDER_CANCEL_CONFIRM_OUT(byte[] buffer)
 {
     MS_OE_REQUEST obj = (MS_OE_REQUEST)DataPacket.RawDeserialize(buffer, typeof(MS_OE_REQUEST));
     var ob = new Order((int)_Type.MS_OE_REQUEST);
     Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.OrderNumber), out ob);
 }
        //-- 20222
        public void TRADE_CONFIRMATION_TR(byte[] buffer)
        {
            var obj = (MS_TRADE_CONFIRM_TR)DataPacket.RawDeserialize(buffer, typeof(MS_TRADE_CONFIRM_TR));
            int ch = 0;
            if (Holder.holderOrder.ContainsKey(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber)))
                ch = Holder.holderOrder[LogicClass.DoubleEndianChange(obj.ResponseOrderNumber)].GetType();
            else
                Console.WriteLine("Error while remove order from dictionary " + (long)LogicClass.DoubleEndianChange(obj.ResponseOrderNumber));
            switch (ch)
            {
                case 1:
                    {
                        var ob = new Order((int)_Type.MS_OE_REQUEST);
                        Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                        break;
                    }
                case 2:
                    {
                        var ob = new Order((int)_Type.MS_OE_RESPONSE_TR);
                        Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                        break;
                    }
                case 3:
                    {
                        var ob = new Order((int)_Type.MS_SPD_OE_REQUEST);
                        Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                        break;
                    }
            }

            Console.WriteLine(
                " Token  : " + IPAddress.HostToNetworkOrder(obj.Token) +
                ", ResponseOrderNumber : " + (long)LogicClass.DoubleEndianChange(obj.ResponseOrderNumber) +
                ", Buy_SellIndicator : " + IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) +
                ", FillPrice : " + IPAddress.HostToNetworkOrder(obj.FillPrice) +
                ", Price : " + IPAddress.HostToNetworkOrder(obj.Price) +
                ", DisclosedVolumeRemaining : " + IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) +
                ", DisclosedVolume : " + IPAddress.HostToNetworkOrder(obj.DisclosedVolume) +
                ", VolumeFilledToday : " + IPAddress.HostToNetworkOrder(obj.VolumeFilledToday) +
                ", OriginalVolume : " + IPAddress.HostToNetworkOrder(obj.OriginalVolume) +
                ", RemainingVolume : " + IPAddress.HostToNetworkOrder(obj.RemainingVolume)
                );
        }
		public void GenerateInvoice(Order o)
		{
			
		}
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode.Nodes.Count > 0)
            {
                MessageBox.Show("Não é possível eliminar a mesa pois contém pedidos. ");
            }
            else
            {
                Order o = new Order(DateTime.Now, treeView1.SelectedNode.Text, 1, -2.0, treeView1.SelectedNode.Text, OrderStatus.NotStarted, Locations.Bar);

                ordersServer.AddOrder(o);

                //treeView1.Nodes.Remove(treeView1.SelectedNode);
            }
        }
        private void addTable_Click(object sender, EventArgs e)
        {
            if (!tableID.Text.Equals(""))
            {
                String mesa = "Mesa " + tableID.Text;
                foreach(TreeNode t in treeView1.Nodes)
                {
                    if (t.Text.Equals(mesa))
                    {
                        MessageBox.Show("A mesa já existe!", "Aviso");
                        return;
                    }
                }

                Order o = new Order(DateTime.Now, mesa, 1, -1.0, mesa, OrderStatus.NotStarted, Locations.Bar);

               ordersServer.AddOrder(o);
            }
        }
        public void OrderStartedNotification(Order order)
        {
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    OrderStartedNotification(order);
                });
                return;
            }
            TreeNode temp = null;

            foreach (TreeNode tn2 in treeView1.Nodes)
                if (tn2.Text.Equals(order.Table))
                    temp = tn2;

            temp.Expand();
            foreach (TreeNode t in temp.Nodes)
            {
                if (t.Name == order.Id)
                {
                    t.BackColor = Color.Khaki;
                    break;
                }
            }
        }
        public void OrderRemovedNotification(Order order)
        {
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    OrderRemovedNotification(order);
                });
                return;
            }

            TreeNode temp = null;

            foreach (TreeNode tn2 in treeView1.Nodes)
                if (tn2.Text.Equals(order.Table))
                    temp = tn2;

            foreach (TreeNode t in temp.Nodes)
            {
                if (t.Name == order.Id)
                {
                    temp.Nodes.Remove(t);
                    break;
                }
            }

            label7.Text = ordersServer.GetTableCheck(order.Table).ToString() + " €";
        }
Beispiel #12
0
        private void loadbackfill_data()
        {
            DataSet ds = new DataSet();

            ds.ReadXml(Application.StartupPath + Path.DirectorySeparatorChar + "001.xml");

            ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "InstrumentName"; // "InstrumentName";
            ds.Tables[0].Columns["SYMBOL"].ColumnName = "Symbol";

            ds.Tables[0].Columns["TOKENNO"].ColumnName = "TokenNo";
              //  ds.Tables[0].Columns["TOKENNO"].DataType = typeof(Int32);
            ds.Tables[0].Columns["Buy_SellIndicator"].ColumnName = "Buy_SellIndicator";
            ds.Tables[0].Columns["OPTIONTYPE"].ColumnName = "OptionType";
            ds.Tables[0].Columns["STRIKEPRICE"].ColumnName = "StrikePrice";
             //   ds.Tables[0].Columns["PRICE"].DataType = typeof(double);
            ds.Tables[0].Columns["PRICE"].ColumnName = "Price";
            //ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "FillPrice";
            ds.Tables[0].Columns["VOLUME"].ColumnName = "Volume";
            ds.Tables[0].Columns["STATUS"].ColumnName = "Status";
            ds.Tables[0].Columns["ACCOUNTNUMBER"].ColumnName = "AccountNumber";
            ds.Tables[0].Columns["BOOKTYPE"].ColumnName = "BookType";
            ds.Tables[0].Columns["BRANCHID"].ColumnName = "BranchId";
            ds.Tables[0].Columns["CLOSEOUTFLAG"].ColumnName = "CloseoutFlag";
            ds.Tables[0].Columns["EXPIRYDATE"].ColumnName = "ExpiryDate";
            ds.Tables[0].Columns["DISCLOSEDVOLUME"].ColumnName = "DisclosedVolume";
            ds.Tables[0].Columns["DISCLOSEDVOLUMEREMAINING"].ColumnName = "DisclosedVolumeRemaining";
            ds.Tables[0].Columns["ENTRYDATETIME"].ColumnName = "EntryDateTime";
            ds.Tables[0].Columns["FILLER"].ColumnName = "filler";
            ds.Tables[0].Columns["GOODTILLDATE"].ColumnName = "GoodTillDate";
            ds.Tables[0].Columns["LASTMODIFIED"].ColumnName = "LastModified";
            ds.Tables[0].Columns["LOGTIME"].ColumnName = "LogTime";
            ds.Tables[0].Columns["Modified_CancelledBy"].ColumnName = "Modified_CancelledBy";
            ds.Tables[0].Columns["NNFFIELD"].ColumnName = "nnffield";
            ds.Tables[0].Columns["OPEN_CLOSE"].ColumnName = "Open_Close";
            ds.Tables[0].Columns["OrderNumber"].ColumnName = "OrderNumber";
            //  ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "RejectReason";
            ds.Tables[0].Columns["PRO_CLIENTINDICATOR"].ColumnName = "Pro_ClientIndicator";
            ds.Tables[0].Columns["REASONCODE"].ColumnName = "ReasonCode";
            ds.Tables[0].Columns["SETTLOR"].ColumnName = "Settlor";
            // ds.Tables[0].Columns["TIMESTAMP1"].ColumnName = "TimeStamp1";
            //ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "TimeStamp2";
            ds.Tables[0].Columns["TOTALVOLUMEREMAINING"].ColumnName = "TotalVolumeRemaining";
            ds.Tables[0].Columns["TRADERID"].ColumnName = "TraderId";
            ds.Tables[0].Columns["TRANSACTIONCODE"].ColumnName = "TransactionCode";
            ds.Tables[0].Columns["USERID"].ColumnName = "UserId";
              //  ds.Tables[0].Columns["VOLUMEFILLEDTODAY"].DataType = typeof(Int32);
            ds.Tables[0].Columns["VOLUMEFILLEDTODAY"].ColumnName = "VolumeFilledToday";
            //  ds.Tables[0].Columns["INSTRUMENT"].ColumnName = "TimeStamp1";
            Global.Instance.OrdetTable = ds.Tables[0];

            DataRow[] dr_selectbal = Global.Instance.OrdetTable.Select("STATUS='Open'");

              //  double d=
            foreach (var item in dr_selectbal)
            {
                Order ord = new Order(1);
                ord.mS_OE_RESPONSE_TR.AccountNumber = System.Text.Encoding.ASCII.GetBytes(item["AccountNumber"].ToString());
                var a=(Convert.ToInt64( item["OrderNumber"]));
                ord.mS_OE_RESPONSE_TR.OrderNumber =  Convert.ToDouble(Convert.ToInt64( item["OrderNumber"]));//Convert.ToDouble(item["OrderNumber"].ToString());

                var c = (long)LogicClass.DoubleEndianChange(ord.mS_OE_RESPONSE_TR.OrderNumber);
                ord.mS_OE_RESPONSE_TR.Buy_SellIndicator =(short) IPAddress.HostToNetworkOrder(Convert.ToInt32( item["Buy_SellIndicator"] == "BUY"?"1":"2" ));
             //    MS_OE_RESPONSE_TR obj = (MS_OE_RESPONSE_TR)DataPacket.RawDeserialize(buffer, typeof(MS_OE_RESPONSE_TR));
                Holder.holderOrder.TryAdd(LogicClass.DoubleEndianChange(ord.mS_OE_RESPONSE_TR.OrderNumber), ord);
                Holder.holderOrder[LogicClass.DoubleEndianChange(ord.mS_OE_RESPONSE_TR.OrderNumber)].mS_OE_RESPONSE_TR = ord.mS_OE_RESPONSE_TR;
            }
        }
Beispiel #13
0
        //-- 20075
        public void ORDER_CXL_CONFIRMATION_TR(byte[] buffer)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new ORDER_ERROR_OUTDel(ORDER_CXL_CONFIRMATION_TR), buffer);
                    return;
                }

                object ob1 = new object();
                lock (ob1)
                {

                    MS_OE_RESPONSE_TR obj = (MS_OE_RESPONSE_TR)DataPacket.RawDeserialize(buffer, typeof(MS_OE_RESPONSE_TR));
                    int ch = 0;
                    if (Holder.holderOrder.ContainsKey(LogicClass.DoubleEndianChange(obj.OrderNumber)))
                        ch = Holder.holderOrder[LogicClass.DoubleEndianChange(obj.OrderNumber)].GetType();
                    switch (ch)
                    {
                        case 1:
                            {
                                var ob = new Order((int)_Type.MS_OE_REQUEST);
                                Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.OrderNumber), out ob);
                                break;
                            }
                        case 2:
                            {
                                var ob = new Order((int)_Type.MS_OE_RESPONSE_TR);
                                Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.OrderNumber), out ob);
                                //   int lotSize = CSV_Class.cimlist.Where(q => q.Token == IPAddress.HostToNetworkOrder(obj.TokenNo)).Select(a => a.BoardLotQuantity).First();
                                DataRow[] dr = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.OrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.TokenNo)).ToString() + "'");
                                if (dr.Length == 0)
                                    return;
                                dr[0]["Status"] = orderStatus.Cancel.ToString();
                                //  dr[0]["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                                //   dr[0]["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                                dr[0]["EntryDateTime"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.EntryDateTime));
                                dr[0]["LastModified"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LastModified));
                                dr[0]["Modified_CancelledBy"] = Convert.ToChar(obj.Modified_CancelledBy);
                                dr[0]["ReasonCode"] = IPAddress.HostToNetworkOrder(obj.ReasonCode);
                                  dr[0]["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                                //    dr[0]["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.TotalVolumeRemaining) / lotSize;
                                //    dr[0]["Volume"] = IPAddress.HostToNetworkOrder(obj.Volume) / lotSize;
                                //      dr[0]["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday) / lotSize;
                                dr[0]["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                                //if (!DGV.InvokeRequired)
                                //{
                                //    DGV.Refresh();
                                //}

                                //if (!DGV2.InvokeRequired)
                                //{
                                //    DGV2.Refresh();

                                //}
                                //if (!frmLog.Instance.tbelog.InvokeRequired)
                                //{
                                //    frmLog.Instance.tbelog.Text = IPAddress.HostToNetworkOrder(obj.ErrorCode) != 0 ? frmLog.Instance.tbelog.Text :
                                //         frmLog.Instance.tbelog.Text + Environment.NewLine +
                                //             " Order cancel successfully  Order No:" + (long)LogicClass.DoubleEndianChange((obj.OrderNumber));
                                //}
                                break;
                            }
                        case 3:
                            {
                                var ob = new Order((int)_Type.MS_SPD_OE_REQUEST);
                                Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.OrderNumber), out ob);
                                //if (!frmLog.Instance.tbelog.InvokeRequired)
                                //{
                                //    frmLog.Instance.tbelog.Text = IPAddress.HostToNetworkOrder(obj.ErrorCode) != 0 ? frmLog.Instance.tbelog.Text :
                                //         frmLog.Instance.tbelog.Text + Environment.NewLine +
                                //             " Order cancel successfully  Order No:" + (long)LogicClass.DoubleEndianChange((obj.OrderNumber));
                                //}

                                break;
                            }
                    }
                }
            }
            catch (Exception ex)
            {

              //MessageBox.Show("Order Book -  Funtion Name-  ORDER_CXL_CONFIRMATION_TR  " + ex.Message);
            }
        }
Beispiel #14
0
        //-- 2075
        public void ORDER_CANCEL_CONFIRM_OUT(byte[] buffer)
        {
            try{
            MS_OE_REQUEST obj = (MS_OE_REQUEST)DataPacket.RawDeserialize(buffer, typeof(MS_OE_REQUEST));
            var ob = new Order((int)_Type.MS_OE_REQUEST);
            Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.OrderNumber), out ob);
             }
            catch (Exception ex)
            {

            //                MessageBox.Show("Order Book -  Funtion Name-  ORDER_CANCEL_CONFIRM_OUT  " + ex.Message);
            }
        }
Beispiel #15
0
        //-- 20222
        public void TRADE_CONFIRMATION_TR(byte[] buffer)
        {
            int lotSize=0;
            try
            {
              if (this.InvokeRequired)
                {
                    this.Invoke(new ORDER_ERROR_OUTDel(TRADE_CONFIRMATION_TR), buffer);
                    return;
                }

                object ob1 = new object();
                lock (ob1)
                {
                  var obj = (MS_TRADE_CONFIRM_TR)DataPacket.RawDeserialize(buffer, typeof(MS_TRADE_CONFIRM_TR));

                    int ch = 0;
                    if (Holder.holderOrder.ContainsKey(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber)))
                        ch = Holder.holderOrder[LogicClass.DoubleEndianChange(obj.ResponseOrderNumber)].GetType();
             //else
              //ch = 3;
                    switch (ch)
                    {
                        case 1:
                            {
                                var ob = new Order((int)_Type.MS_OE_REQUEST);
                             //   Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                                break;
                            }
                        case 2:
                            {
                                Order ob;
                               lotSize = Holder._DictLotSize[IPAddress.HostToNetworkOrder(obj.Token)].lotsize;    // CSV_Class.cimlist.Where(q => q.Token == IPAddress.HostToNetworkOrder(obj.Token)).Select(a => a.BoardLotQuantity).First();
                               //DataRow[] dr2 = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");
                               //dr2[0]["Status"] = orderStatus.Cancel.ToString();
                               //DataRow dr = Global.Instance.OrdetTable.NewRow();
                               //lotSize = Holder._DictLotSize[IPAddress.HostToNetworkOrder(obj.Token)].lotsize;
                               //dr["Status"] = orderStatus.Traded.ToString();
                               //dr["AccountNumber"] = Encoding.ASCII.GetString(obj.AccountNumber);
                               //dr["BookType"] = Enum.GetName(typeof(Enums.BookTypes), IPAddress.HostToNetworkOrder(obj.BookType));
                               //dr["BrokerId"] = Encoding.ASCII.GetString(obj.BrokerId);
                               //dr["Buy_SellIndicator"] = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1 ? "BUY" : "SELL";
                               //dr["ExpiryDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.ExpiryDate));
                               //dr["InstrumentName"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.InstrumentName);
                               //dr["OptionType"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.OptionType);
                               //dr["StrikePrice"] = IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.StrikePrice);
                               //dr["Symbol"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol);
                               //dr["GoodTillDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.GoodTillDate));
                               //dr["Open_Close"] = Convert.ToChar(obj.OpenClose);
                               //dr["TokenNo"] = IPAddress.HostToNetworkOrder(obj.Token);
                               //dr["TraderId"] = IPAddress.HostToNetworkOrder(obj.TraderId);
                               //dr["FullName"] = System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == IPAddress.NetworkToHostOrder(obj.Token)).Name);
                               //dr["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                               //dr["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                               //dr["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                               //dr["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                               //dr["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume) / lotSize;
                               //dr["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity); // lotSize;
                               //dr["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday) / lotSize;
                               //dr["LogTime"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff");
                               //dr["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                               //dr["FillNumber"] = IPAddress.HostToNetworkOrder(obj.FillNumber);
                               //dr["OrderNumber"] = (long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber));
                               //dr["Unique_id"] = IPAddress.HostToNetworkOrder((obj.FillNumber)).ToString();
                               //Global.Instance.OrdetTable.Rows.Add(dr);
                              // MessageBox.Show(IPAddress.HostToNetworkOrder(obj.RemainingVolume).ToString());
                               if (IPAddress.HostToNetworkOrder(obj.RemainingVolume) <= 0)
                               {
                                   ob = new Order((int)_Type.MS_OE_RESPONSE_TR);
                                   Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                                   lotSize = Holder._DictLotSize[IPAddress.HostToNetworkOrder(obj.Token)].lotsize;    // CSV_Class.cimlist.Where(q => q.Token == IPAddress.HostToNetworkOrder(obj.Token)).Select(a => a.BoardLotQuantity).First();
                                   DataRow[] dr = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");
                                   dr[0]["Status"] = orderStatus.Traded.ToString();
                                   dr[0]["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                                   dr[0]["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                                   dr[0]["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                                   dr[0]["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                                   dr[0]["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume) / lotSize;
                                   dr[0]["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity); // lotSize;
                                   dr[0]["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday) / lotSize;
                                   dr[0]["LogTime"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff");
                                   dr[0]["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                                   dr[0]["FillNumber"] = IPAddress.HostToNetworkOrder(obj.FillNumber);

                               }
                               else
                               {
                                   DataRow dr = Global.Instance.OrdetTable.NewRow();
                                   lotSize = Holder._DictLotSize[IPAddress.HostToNetworkOrder(obj.Token)].lotsize;
                                   dr["Status"] = orderStatus.Traded.ToString();
                                   dr["AccountNumber"] = Encoding.ASCII.GetString(obj.AccountNumber);
                                   dr["BookType"] = Enum.GetName(typeof(Enums.BookTypes), IPAddress.HostToNetworkOrder(obj.BookType));
                                   dr["BrokerId"] = Encoding.ASCII.GetString(obj.BrokerId);
                                   dr["Buy_SellIndicator"] = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1 ? "BUY" : "SELL";
                                   dr["ExpiryDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.ExpiryDate));
                                   dr["InstrumentName"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.InstrumentName);
                                   dr["OptionType"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.OptionType);
                                   dr["StrikePrice"] = IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.StrikePrice);
                                   dr["Symbol"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol);
                                   dr["GoodTillDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.GoodTillDate));
                                   dr["Open_Close"] = Convert.ToChar(obj.OpenClose);
                                   dr["TokenNo"] = IPAddress.HostToNetworkOrder(obj.Token);
                                   dr["TraderId"] = IPAddress.HostToNetworkOrder(obj.TraderId);
                                   dr["FullName"] = System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == IPAddress.NetworkToHostOrder(obj.Token)).Name);
                                   dr["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                                   dr["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                                   dr["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                                   dr["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                                   dr["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume) / lotSize;
                                   dr["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity); // lotSize;
                                   dr["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday) / lotSize;
                                   dr["LogTime"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff");
                                   dr["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                                   dr["FillNumber"] = IPAddress.HostToNetworkOrder(obj.FillNumber);
                                   dr["OrderNumber"] = (long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber));
                                   dr["Unique_id"] = IPAddress.HostToNetworkOrder((obj.FillNumber)).ToString();
                                   Global.Instance.OrdetTable.Rows.Add(dr);
                               }
                               //Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                               //if (!DGV.InvokeRequired)
                               //{
                               //    DGV.Refresh();
                               //}
                               //if (!DGV2.InvokeRequired)
                               //{
                               //    DGV2.Refresh();
                               //}
                               if (!frmLog.Instance.tbelog.InvokeRequired)
                                   frmLog.Instance.tbelog.Text = frmLog.Instance.tbelog.Text + Environment.NewLine +
                                            " Order Traded  Order No:" + (long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber));
                                break;
                            }
                        case 3:
                            {
                               // MessageBox.Show(System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == IPAddress.NetworkToHostOrder(obj.Token)).Name));
                                var ob = new Order((int)_Type.MS_SPD_OE_REQUEST);
                                Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                               if (Holder._DictLotSize.ContainsKey(IPAddress.HostToNetworkOrder(obj.Token)) == false || IPAddress.HostToNetworkOrder(obj.Token) != 0)
                                {
                                    Holder._DictLotSize.TryAdd(IPAddress.HostToNetworkOrder(obj.Token), new Csv_Struct()
                                    {
                                        lotsize = CSV_Class.cimlist.Where(q => q.Token == IPAddress.HostToNetworkOrder(obj.Token)).Select(a => a.BoardLotQuantity).First()
                                    }
                                    );
                                }
                               // var v = Global.Instance.Ratio.Where(a => a.Key == (IPAddress.HostToNetworkOrder(obj.Token).ToString() + IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.StrikePrice).ToString() + System.Text.ASCIIEncoding.UTF8.GetString(obj.Contr_dec_tr_Obj.OptionType))).Select(b => b.Value).ToList();
                              //var val =Convert.ToInt32(v.FirstOrDefault().ToString());
                              lotSize = Holder._DictLotSize[IPAddress.HostToNetworkOrder(obj.Token)].lotsize;    // CSV_Class.cimlist.Where(q => q.Token == IPAddress.HostToNetworkOrder(obj.Token)).Select(a => a.BoardLotQuantity).First();
                             //DataRow[] dr = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");
                             DataRow dr = Global.Instance.OrdetTable.NewRow();
                             dr["Unique_id"] = ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + (IPAddress.HostToNetworkOrder(obj.FillPrice)).ToString() + (IPAddress.HostToNetworkOrder(obj.LogTime)).ToString();
                             dr["TokenNo"] = IPAddress.HostToNetworkOrder(obj.Token);
                             dr["Status"] = orderStatus.Traded.ToString();
                             dr["Buy_SellIndicator"] =((BUYSELL) IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator)).ToString() ;
                             dr["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume);// / lotSize;
                             dr["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining);// / lotSize;
                             dr["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                             dr["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                             dr["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume);// / lotSize;
                             //  dr[0]["Volume"] = ((IPAddress.HostToNetworkOrder(obj.FillQuantity)/lotSize)*(val*lotSize))/(val*lotSize);
                             dr["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday); // lotSize;
                             dr["LogTime"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff");
                             dr["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                             dr["Symbol"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol);
                             dr["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity) / lotSize;
                             dr["ExpiryDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.ExpiryDate));
                             dr["InstrumentName"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.InstrumentName);
                             dr["OptionType"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.OptionType);
                             dr["StrikePrice"] = IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.StrikePrice);
                             dr["FullName"] = System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == IPAddress.NetworkToHostOrder(obj.Token)).Name);
                             Global.Instance.OrdetTable.Rows.Add(dr);
                             //Global.Instance.MTMDIct.AddOrUpdate(Stat.Parameter.Token, Stat.Parameter.LTP, (k, v) => Stat.Parameter.LTP);
                             /*Global.Instance.Ratio.AddOrUpdate((IPAddress.HostToNetworkOrder(obj.Token).ToString() + IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.StrikePrice).ToString() + System.Text.ASCIIEncoding.UTF8.GetString(obj.Contr_dec_tr_Obj.OptionType))
                             ,);*/
                             //if(!DGV.InvokeRequired)
                             //{
                             //DGV.Refresh();
                             //}
                             //if(!DGV2.InvokeRequired)
                             //{
                             //DGV2.Refresh();
                             //}
                             //if (!frmLog.Instance.tbelog.InvokeRequired)
                             //frmLog.Instance.tbelog.Text = frmLog.Instance.tbelog.Text + Environment.NewLine +
                             //" Order Traded  Order No:" + (long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber));
                                break;
                            }

                    }

                    if (!this.InvokeRequired)
                    {
                        MethodInvoker del = delegate
                        {
                            if (lotSize == 0)
                                goto l;
                            frmNetBook.Instance.netposion(IPAddress.HostToNetworkOrder(obj.Token), lotSize);
                            frmTradeBook.Instance.DGV.Refresh();
                            frmTradeBook.Instance.lblnooftrade.Text = "No Of Trade  =" + frmTradeBook.Instance.DGV.Rows.Count;
                            if (IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1)
                                frmTradeBook.Instance.lblb_q.Text = (Convert.ToDouble(frmTradeBook.Instance.lblb_q.Text == "0" ? "0" : frmTradeBook.Instance.lblb_q.Text) + IPAddress.HostToNetworkOrder(obj.FillQuantity) / lotSize).ToString();
                            else
                                frmTradeBook.Instance.lbls_q.Text = (Convert.ToDouble(frmTradeBook.Instance.lbls_q.Text == "0" ? "0" : frmTradeBook.Instance.lbls_q.Text) + IPAddress.HostToNetworkOrder(obj.FillQuantity) / lotSize).ToString();

                            l:
                            if (IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1)
                            {

                                frmTradeBook.Instance.lblb_V.Text = (Convert.ToDouble(frmTradeBook.Instance.lblb_V.Text == "0" ? "0" : frmTradeBook.Instance.lblb_V.Text) + ((IPAddress.HostToNetworkOrder(obj.FillPrice)) * (IPAddress.HostToNetworkOrder(obj.FillQuantity))) / 100).ToString();
                                // frmTradeBook.Instance.lblb_V.Text = Global.Instance.OrdetTable.AsEnumerable().Where(r => r.Field<string>("Status") == "Traded" && r.Field<string>("Buy_SellIndicator") == "BUY").Sum(r => r.Field<Double>("FillPrice") * Convert.ToDouble(r.Field<string>("Volume"))).ToString();
                            }
                            else
                            {
                                frmTradeBook.Instance.lbls_v.Text = (Convert.ToDouble(frmTradeBook.Instance.lbls_v.Text == "0" ? "0" : frmTradeBook.Instance.lbls_v.Text) + ((IPAddress.HostToNetworkOrder(obj.FillPrice)) * (IPAddress.HostToNetworkOrder(obj.FillQuantity)))/100).ToString();
                             //   frmTradeBook.Instance.lbls_v.Text = Global.Instance.OrdetTable.AsEnumerable().Where(r => r.Field<string>("Status") == "Traded" && r.Field<string>("Buy_SellIndicator") == "SELL").Sum(r => r.Field<Double>("FillPrice") * Convert.ToDouble(r.Field<string>("Volume"))).ToString();
                            }

                            frmTradeBook.Instance.lbln_v.Text = (Convert.ToDouble(frmTradeBook.Instance.lbls_q.Text) - Convert.ToDouble(frmTradeBook.Instance.lblb_q.Text)).ToString();
                            frmTradeBook.Instance.N_V.Text = ((Convert.ToDouble(frmTradeBook.Instance.lbls_v.Text) - Convert.ToDouble(frmTradeBook.Instance.lblb_V.Text))/100).ToString();
                            string str = "BUY_Quantity =\t" + frmTradeBook.Instance.lblb_q.Text + "\t Sell_Quantity =\t" + frmTradeBook.Instance.lbls_q.Text + "\t Buy_Value=\t" + frmTradeBook.Instance.lblb_V.Text + "\tSell_Value=\t" + frmTradeBook.Instance.lbls_v.Text + "\tNet_Value =\t" + frmTradeBook.Instance.N_V.Text;
                         //   LogWriterClass.logwritercls.logs(Global.Instance.Net_File,str);
                           // StreamWriter w = new StreamWriter(Environment.CurrentDirectory + Path.DirectorySeparatorChar + Global.Instance.Net_File + ".doc", true);
                          //w.WriteLine("lblb_q =\t" + frmTradeBook.Instance.lbls_q.Text + "\t lbls_q =\t" + frmTradeBook.Instance.lbls_q.Text + "\tlblb_V=\t" + frmTradeBook.Instance.lblb_V.Text + "\t lbls_v =\t" + frmTradeBook.Instance.lbls_v.Text + "N_V.Text " + frmTradeBook.Instance.N_V.Text);

                            string destPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Global.Instance.Net_File+".txt");
                            File.WriteAllText(destPath,str);

                            string Trade20222 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Trade_20222.txt");

                          //  File.WriteAllText(Trade20222,"Token "+Convert.ToString(IPAddress.HostToNetworkOrder(obj.Token))+"");
                            LogWriterClass.logwritercls.logs(Trade20222, "\tToken\t" + Convert.ToString(IPAddress.HostToNetworkOrder(obj.Token)) + " FillPrice \t" + Convert.ToString(IPAddress.HostToNetworkOrder(obj.FillPrice)) + "FillQuantity\t" + Convert.ToString(IPAddress.HostToNetworkOrder(obj.FillQuantity)) + " Buy_SellIndicator " + Convert.ToString(IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator)));
                        };
                        this.Invoke(del);
                    }
                  }
            }
            catch (Exception ex)
            {

               // MessageBox.Show("Order Book -  Funtion Name-  TRADE_CONFIRMATION_TR  " + ex.Message);
            }
        }
        //-- 20222
        public void TRADE_CONFIRMATION_TR(byte[] buffer)
        {
            try
            {

                if (this.InvokeRequired)
                {
                    this.Invoke(new ORDER_ERROR_OUTDel(TRADE_CONFIRMATION_TR), buffer);
                    return;
                }

                object ob1 = new object();
                lock (ob1)
                {

                    var obj = (MS_TRADE_CONFIRM_TR)DataPacket.RawDeserialize(buffer, typeof(MS_TRADE_CONFIRM_TR));

                    int ch = 0;
                    int val = 0;
                    int lotSize = 0;
                    if (Holder.holderOrder.ContainsKey(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber)))
                        ch = Holder.holderOrder[LogicClass.DoubleEndianChange(obj.ResponseOrderNumber)].GetType();
             //       else
                     ch = 3;
                    switch (ch)
                    {
                        case 1:
                            {
                                var ob = new Order((int)_Type.MS_OE_REQUEST);
                             //   Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                                break;
                            }
                        case 2:
                            {

                                 try
                                {
                                    var ob = new Order((int)_Type.MS_OE_RESPONSE_TR);
                                  //  Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                                    lotSize = Holder._DictLotSize[IPAddress.HostToNetworkOrder(obj.Token)].lotsize;    // CSV_Class.cimlist.Where(q => q.Token == IPAddress.HostToNetworkOrder(obj.Token)).Select(a => a.BoardLotQuantity).First();
                                    var v = Global.Instance.Ratio.Where(a => a.Key == (IPAddress.HostToNetworkOrder(obj.Token))).Select(b => b.Value).ToList();
                                    val = Convert.ToInt32(v.FirstOrDefault().ToString());
                                   // DataRow[] dr = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");

                                    //if (Global.Instance.Filler_dict.ContainsKey(IPAddress.HostToNetworkOrder(obj.FillNumber)))
                                    //{
                                    //    return;
                                    //}
                                    //Global.Instance.Filler_dict.TryAdd(IPAddress.HostToNetworkOrder(obj.FillNumber), IPAddress.HostToNetworkOrder(obj.FillNumber));

                                     DataRow[] dr2 = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");
                                   //  DataRow[] dr = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");
                                     if (dr2.Length == 0)
                                     {
                                         //LogWriterClass.logwritercls.logs("20074trasactioncode", ((long)LogicClass.DoubleEndianChange((obj.OrderNumber))).ToString());
                                         return;
                                     }
                                     if (obj.RemainingVolume <= 0)
                                     {
                                         dr2[0]["Status"] = orderStatus.Traded.ToString();
                                         dr2[0]["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                                         dr2[0]["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                                         dr2[0]["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                                         dr2[0]["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                                         dr2[0]["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume) / lotSize;
                                         dr2[0]["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity) / lotSize;
                                         dr2[0]["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday);// / lotSize;
                                         dr2[0]["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                                     }
                                     else
                                     {
                                         DataRow dr = Global.Instance.OrdetTable.NewRow();
                                         dr["Status"] = orderStatus.Traded.ToString();
                                         dr["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                                         dr["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                                         dr["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                                         dr["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                                         dr["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume);// / lotSize;
                                         dr["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity);// lotSize;
                                         dr["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday); /// lotSize;
                                         dr["LogTime"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff");
                                         dr["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                                         dr["FillNumber"] = IPAddress.HostToNetworkOrder(obj.FillNumber);
                                         dr["OrderNumber"] = (long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber));
                                         dr["Unique_id"] = ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + IPAddress.HostToNetworkOrder(obj.Token).ToString() + IPAddress.HostToNetworkOrder(obj.FillNumber).ToString();
                                         dr["TokenNo"] = IPAddress.HostToNetworkOrder(obj.Token);
                                         dr["Buy_SellIndicator"] = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1 ? "BUY" : "SELL";
                                         //dr["CloseoutFlag"] = Convert.ToChar(obj.CloseoutFlag);
                                         dr["ExpiryDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.ExpiryDate));
                                         dr["InstrumentName"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.InstrumentName);
                                         dr["OptionType"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.OptionType);
                                         dr["StrikePrice"] = IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.StrikePrice) / 100;
                                         dr["Symbol"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol);
                                         dr["FullName"] = System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == IPAddress.NetworkToHostOrder(obj.Token)).Name);
                                         Global.Instance.OrdetTable.Rows.Add(dr);

                                     }

                                }
                                catch(Exception ex)
                                {

                                }

                                break;
                            }
                        case 3:
                            {
                                try
                                {
                                    var ob = new Order((int)_Type.MS_SPD_OE_REQUEST);
                                    //Holder.holderOrder.TryRemove(LogicClass.DoubleEndianChange(obj.ResponseOrderNumber), out ob);
                                    lotSize = Holder._DictLotSize[IPAddress.HostToNetworkOrder(obj.Token)].lotsize;    // CSV_Class.cimlist.Where(q => q.Token == IPAddress.HostToNetworkOrder(obj.Token)).Select(a => a.BoardLotQuantity).First();
                                    var v = Global.Instance.Ratio.Where(a => a.Key == (IPAddress.HostToNetworkOrder(obj.Token))).Select(b => b.Value).ToList();
                                    val = Convert.ToInt32(v.FirstOrDefault().ToString());
                                    //if (Global.Instance.Filler_dict.ContainsKey(IPAddress.HostToNetworkOrder(obj.FillNumber)))
                                    //{
                                    //    return;
                                    //}
                                    //Global.Instance.Filler_dict.TryAdd(IPAddress.HostToNetworkOrder(obj.FillNumber), IPAddress.HostToNetworkOrder(obj.FillNumber));

                                    DataRow[] dr2 = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");
                                    if (dr2.Length > 0)
                                    {
                                        if (Convert.ToString(dr2[0]["Status"]) == orderStatus.Open.ToString() || Convert.ToString(dr2[0]["Status"]) == orderStatus.Modified.ToString())
                                            dr2[0]["Status"] = orderStatus.Cancel.ToString();
                                    }
                                    DataRow dr = Global.Instance.OrdetTable.NewRow();
                                    lotSize = Holder._DictLotSize[IPAddress.HostToNetworkOrder(obj.Token)].lotsize;
                                    dr["Status"] = orderStatus.Traded.ToString();
                                    dr["AccountNumber"] = Encoding.ASCII.GetString(obj.AccountNumber);
                                    dr["BookType"] = Enum.GetName(typeof(Enums.BookTypes), IPAddress.HostToNetworkOrder(obj.BookType));
                                    dr["BrokerId"] = Encoding.ASCII.GetString(obj.BrokerId);
                                    dr["Buy_SellIndicator"] = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1 ? "BUY" : "SELL";
                                    dr["ExpiryDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.ExpiryDate));
                                    dr["InstrumentName"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.InstrumentName);
                                    dr["OptionType"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.OptionType);
                                    dr["StrikePrice"] = IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.StrikePrice);
                                    dr["Symbol"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol);
                                    dr["GoodTillDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.GoodTillDate));
                                    dr["Open_Close"] = Convert.ToChar(obj.OpenClose);
                                    dr["TokenNo"] = IPAddress.HostToNetworkOrder(obj.Token);
                                    dr["TraderId"] = IPAddress.HostToNetworkOrder(obj.TraderId);
                                    dr["FullName"] = System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == IPAddress.NetworkToHostOrder(obj.Token)).Name);
                                    dr["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                                    dr["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                                    dr["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                                    dr["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                                    dr["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume) / lotSize;
                                    dr["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity);//lotSize;
                                    dr["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday) / lotSize;
                                    dr["LogTime"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff");
                                    dr["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                                    dr["FillNumber"] = IPAddress.HostToNetworkOrder(obj.FillNumber);
                                    dr["OrderNumber"] = (long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber));
                                    dr["Unique_id"] = IPAddress.HostToNetworkOrder((obj.FillNumber)).ToString();
                                    Global.Instance.OrdetTable.Rows.Add(dr);
                                     //DataRow[] dr = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");

                                    //DataRow[] dr2 = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");
                                    //DataRow[] dr = Global.Instance.OrdetTable.Select("Unique_id = '" + ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + (IPAddress.HostToNetworkOrder(obj.Token)).ToString() + "'");
                                    //if (dr2.Length == 0)
                                    //{
                                    //    //LogWriterClass.logwritercls.logs("20074trasactioncode", ((long)LogicClass.DoubleEndianChange((obj.OrderNumber))).ToString());
                                    //    return;
                                    //}
                                    //if (IPAddress.HostToNetworkOrder(obj.RemainingVolume) <= 0)
                                    //{
                                    //    dr2[0]["Status"] = orderStatus.Traded.ToString();
                                    //    dr2[0]["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                                    //    dr2[0]["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                                    //    dr2[0]["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                                    //    dr2[0]["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                                    //    dr2[0]["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume) / lotSize;
                                    //    dr2[0]["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity) / lotSize;
                                    //    dr2[0]["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday);// / lotSize;
                                    //    dr2[0]["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                                    //}
                                    //else
                                    //{
                                    //    DataRow dr = Global.Instance.OrdetTable.NewRow();
                                    //    dr["Status"] = orderStatus.Traded.ToString();
                                    //    dr["DisclosedVolume"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolume) / lotSize;
                                    //    dr["DisclosedVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.DisclosedVolumeRemaining) / lotSize;
                                    //    dr["Price"] = IPAddress.HostToNetworkOrder(obj.Price) / 100.00;
                                    //    dr["FillPrice"] = IPAddress.HostToNetworkOrder(obj.FillPrice) / 100.00;
                                    //    dr["TotalVolumeRemaining"] = IPAddress.HostToNetworkOrder(obj.RemainingVolume);// / lotSize;
                                    //    dr["Volume"] = IPAddress.HostToNetworkOrder(obj.FillQuantity);// lotSize;
                                    //    dr["VolumeFilledToday"] = IPAddress.HostToNetworkOrder(obj.VolumeFilledToday); /// lotSize;
                                    //    dr["LogTime"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.LogTime)).ToString("HH:mm:ss.fff");
                                    //    dr["TransactionCode"] = IPAddress.HostToNetworkOrder(obj.TransactionCode);
                                    //    dr["FillNumber"] = IPAddress.HostToNetworkOrder(obj.FillNumber);
                                    //    dr["OrderNumber"] = (long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber));
                                    //    dr["Unique_id"] = ((long)LogicClass.DoubleEndianChange((obj.ResponseOrderNumber))).ToString() + IPAddress.HostToNetworkOrder(obj.Token).ToString() + IPAddress.HostToNetworkOrder(obj.FillNumber).ToString();
                                    //    dr["TokenNo"] = IPAddress.HostToNetworkOrder(obj.Token);
                                    //    dr["Buy_SellIndicator"] = IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1 ? "BUY" : "SELL";
                                    //    dr["ExpiryDate"] = LogicClass.ConvertFromTimestamp(IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.ExpiryDate));
                                    //    dr["InstrumentName"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.InstrumentName);
                                    //    dr["OptionType"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.OptionType);
                                    //    dr["StrikePrice"] = IPAddress.HostToNetworkOrder(obj.Contr_dec_tr_Obj.StrikePrice) / 100;
                                    //    dr["Symbol"] = Encoding.ASCII.GetString(obj.Contr_dec_tr_Obj.Symbol);
                                    //    dr["FullName"] = System.Text.ASCIIEncoding.ASCII.GetString(csv.CSV_Class.cimlist.First(tkn => tkn.Token == IPAddress.NetworkToHostOrder(obj.Token)).Name);
                                    //    Global.Instance.OrdetTable.Rows.Add(dr);
                                    //}

                                }
                                catch(Exception ex)
                                {
                                    LogWriterClass.logwritercls.logs("20222inTrade", ex.Message.ToString());
                                }

                                break;
                            }

                    }

                    if (!this.InvokeRequired)
                    {
                        MethodInvoker del = delegate
                        {

                            frmNetBook.Instance.netposion(IPAddress.HostToNetworkOrder(obj.Token), val * lotSize, lotSize,IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator),IPAddress.HostToNetworkOrder(obj.FillPrice)/100.00);
                          //  frmTradeBook.Instance.DGV.Refresh();
                           // frmNetBook.Instance.DGV.ClearSelection();
                         //  frmNetBook.Instance.DGV.Rows.OfType<DataGridViewRow>().First().Selected = true;
                         //  frmTradeBook.Instance.DGV.ClearSelection();
                         //  frmTradeBook.Instance.DGV.Rows.OfType<DataGridViewRow>().First().Selected = true;
                          //  frmTradeBook.Instance.DGV.FirstDisplayedScrollingRowIndex = frmTradeBook.Instance.DGV.SelectedRows[0].Index;
                           // frmTradeBook.Instance.DGV.Rows.OfType<DataGridViewRow>().First().Selected = true;
                            //   AutoSave();
                            frmTradeBook.Instance.lblnooftrade.Text = "No Of Trade  =" + frmTradeBook.Instance.DGV.Rows.Count;

                            if (IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1)
                                frmTradeBook.Instance.lblb_q.Text = (Convert.ToInt32(frmTradeBook.Instance.lblb_q.Text == "0" ? "0" : frmTradeBook.Instance.lblb_q.Text) + IPAddress.HostToNetworkOrder(obj.FillQuantity)).ToString();
                            else
                                frmTradeBook.Instance.lbls_q.Text = (Convert.ToInt32(frmTradeBook.Instance.lbls_q.Text == "0" ? "0" : frmTradeBook.Instance.lbls_q.Text) + IPAddress.HostToNetworkOrder(obj.FillQuantity)).ToString();

                            if (IPAddress.HostToNetworkOrder(obj.Buy_SellIndicator) == 1)
                            {
                                frmTradeBook.Instance.lblb_V.Text = Global.Instance.OrdetTable.AsEnumerable().Where(r => r.Field<string>("Status") == "Traded" && r.Field<string>("Buy_SellIndicator") == "BUY").Sum(r =>Convert.ToDouble( r.Field<string>("FillPrice")) * Convert.ToDouble(r.Field<string>("Volume"))).ToString();
                            }
                            else
                                frmTradeBook.Instance.lbls_v.Text = Global.Instance.OrdetTable.AsEnumerable().Where(r => r.Field<string>("Status") == "Traded" && r.Field<string>("Buy_SellIndicator") == "SELL").Sum(r =>Convert.ToDouble( r.Field<string>("FillPrice")) * Convert.ToDouble(r.Field<string>("Volume"))).ToString();
                        };
                        this.Invoke(del);
                    }

                }
            }
            catch (Exception ex)
            {

                MessageBox.Show("Order Book -  Funtion Name-  TRADE_CONFIRMATION_TR  " + ex.Message);
            }
        }