Example #1
0
        public void SellerBook(GetBuySellBook Data, string Pair)
        {
            try
            {
                SignalRComm <GetBuySellBook> CommonData = new SignalRComm <GetBuySellBook>();
                CommonData.EventType    = Enum.GetName(typeof(enSignalREventType), enSignalREventType.Channel);
                CommonData.Method       = Enum.GetName(typeof(enMethodName), enMethodName.SellerBook);
                CommonData.ReturnMethod = Enum.GetName(typeof(enReturnMethod), enReturnMethod.RecieveSellerBook);
                CommonData.Subscription = Enum.GetName(typeof(enSubscriptionType), enSubscriptionType.Broadcast);
                CommonData.ParamType    = Enum.GetName(typeof(enSignalRParmType), enSignalRParmType.PairName);
                CommonData.Data         = Data;
                CommonData.Parameter    = Pair;

                //SignalRDataSellerBook SendData = new SignalRDataSellerBook();
                SignalRData SendData = new SignalRData();
                SendData.Method    = enMethodName.SellerBook;
                SendData.Parameter = CommonData.Parameter;
                SendData.DataObj   = JsonConvert.SerializeObject(CommonData);
                _mediator.Send(SendData);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
                //throw ex;
            }
        }
Example #2
0
 public void OnStatusSuccess(short Status, TransactionQueue Newtransaction, TradeTransactionQueue NewTradeTransaction, string Token, short OrderType)
 {
     try
     {
         GetTradeHistoryInfo historyInfo  = new GetTradeHistoryInfo();
         GetBuySellBook      BuySellmodel = new GetBuySellBook();
         //update Recent Order
         //pop OpenOrder
         //add tradehistory
         //add orderhistory
         //pop buyer/seller book;
         //HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, "Call ---- TransactionQueue :" + JsonConvert.SerializeObject(Newtransaction) + " TradeTransactionQueue :" + JsonConvert.SerializeObject(NewTradeTransaction));
         if (string.IsNullOrEmpty(Token))
         {
             Token = GetTokenByUserID(NewTradeTransaction.MemberID.ToString());
         }
         if (!string.IsNullOrEmpty(Token))
         {
             BuySellmodel.Amount      = 0;
             BuySellmodel.OrderId     = new Guid();
             BuySellmodel.RecordCount = 0;
             if (NewTradeTransaction.TrnType == 4)//Buy
             {
                 BuySellmodel.Price = NewTradeTransaction.BidPrice;
                 BuyerBook(BuySellmodel, NewTradeTransaction.PairName);
                 HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, "BuyerBook call TRNNO:" + Newtransaction.Id);
             }
             else//Sell
             {
                 BuySellmodel.Price = NewTradeTransaction.AskPrice;
                 SellerBook(BuySellmodel, NewTradeTransaction.PairName);
                 HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, "SellerBook call TRNNO:" + Newtransaction.Id);
             }
             GetAndSendRecentOrderData(Newtransaction, NewTradeTransaction, Token, OrderType);  //Update Recent
             HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, " Aftre Recent Order Socket call TRNNO:" + Newtransaction.Id);
             GetAndSendOpenOrderData(Newtransaction, NewTradeTransaction, Token, OrderType, 1); //update OpenOrder
             HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, " Aftre Open Order Socket call TRNNO:" + Newtransaction.Id);
             historyInfo = GetAndSendTradeHistoryInfoData(Newtransaction, NewTradeTransaction, OrderType);
             OrderHistory(historyInfo, historyInfo.PairName); //Order
             HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, " Aftre Order History Socket call  : TRNNO:" + Newtransaction.Id);
             TradeHistory(historyInfo, Token);                //TradeHistory
             HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, " Aftre Trade History Socket call  : TRNNO:" + Newtransaction.Id);
             var msg = EnResponseMessage.SignalRTrnSuccessfullySettled;
             msg = msg.Replace("#Price#", historyInfo.Price.ToString());
             msg = msg.Replace("#Qty#", historyInfo.Amount.ToString());
             msg = msg.Replace("#Total#", historyInfo.Total.ToString());
             ActivityNotification(msg, Token);
         }
     }
     catch (Exception ex)
     {
         HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex);
         //throw ex;
     }
 }
Example #3
0
 public void OnStatusPartialSuccess(short Status, TransactionQueue Newtransaction, TradeTransactionQueue NewTradeTransaction, string Token, short OrderType)
 {
     try
     {
         GetBuySellBook BuySellmodel = new GetBuySellBook();
         //update Buyer/seller book
         //HelperForLog.WriteLogIntoFile("OnStatusPartialSuccess", ControllerName, " TransactionQueue :" + JsonConvert.SerializeObject(Newtransaction) + " TradeTransactionQueue :" + JsonConvert.SerializeObject(NewTradeTransaction));
         if (string.IsNullOrEmpty(Token))
         {
             Token = GetTokenByUserID(NewTradeTransaction.MemberID.ToString());
         }
         if (!string.IsNullOrEmpty(Token))
         {
             List <GetBuySellBook> list = new List <GetBuySellBook>();
             if (NewTradeTransaction.TrnType == 4)//Buy
             {
                 list = _frontTrnRepository.GetBuyerBook(NewTradeTransaction.PairID, NewTradeTransaction.BidPrice);
                 foreach (var model in list)
                 {
                     BuySellmodel = model;
                     break;
                 }
                 if (BuySellmodel.OrderId.ToString() != "00000000-0000-0000-0000-000000000000")
                 {
                     BuyerBook(BuySellmodel, NewTradeTransaction.PairName);
                     HelperForLog.WriteLogIntoFile("OnStatusPartialSuccess", ControllerName, "BuyerBook call TRNNO:" + Newtransaction.Id);
                 }
             }
             else//Sell
             {
                 list = _frontTrnRepository.GetSellerBook(NewTradeTransaction.PairID, NewTradeTransaction.AskPrice);
                 foreach (var model in list)
                 {
                     BuySellmodel = model;
                     break;
                 }
                 if (BuySellmodel.OrderId.ToString() != "00000000-0000-0000-0000-000000000000")
                 {
                     SellerBook(BuySellmodel, NewTradeTransaction.PairName);
                     HelperForLog.WriteLogIntoFile("OnStatusPartialSuccess", ControllerName, "SellerBook call TRNNO:" + Newtransaction.Id);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         //throw ex;
     }
 }
        public async Task <IActionResult> SellerBook(string Data, String Pair)
        {
            string ReciveMethod = "";

            try
            {
                GetBuySellBook model = new GetBuySellBook();
                model.Amount = 3;
                model.Price  = 150;

                GetBuySellBook temp = JsonConvert.DeserializeObject <GetBuySellBook>(Data);

                SignalRComm <GetBuySellBook> CommonData = new SignalRComm <GetBuySellBook>();
                CommonData.EventType    = Enum.GetName(typeof(enSignalREventType), enSignalREventType.Channel);
                CommonData.Method       = Enum.GetName(typeof(enMethodName), enMethodName.SellerBook);
                CommonData.ReturnMethod = Enum.GetName(typeof(enReturnMethod), enReturnMethod.RecieveSellerBook);
                CommonData.Subscription = Enum.GetName(typeof(enSubscriptionType), enSubscriptionType.OneToOne);
                CommonData.ParamType    = Enum.GetName(typeof(enSignalRParmType), enSignalRParmType.PairName);
                CommonData.Data         = temp;
                CommonData.Parameter    = Pair;// "INR_BTC";

                SignalRData SendData = new SignalRData();
                SendData.Method    = enMethodName.SellerBook;
                SendData.Parameter = CommonData.Parameter;
                SendData.DataObj   = JsonConvert.SerializeObject(CommonData);
                await _mediator.Send(SendData);

                ReciveMethod = CommonData.ReturnMethod;
                return(Ok(new { ReciveMethod = ReciveMethod }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);

                return(Ok());
            }
        }
Example #5
0
        public void OnStatusHold(short Status, TransactionQueue Newtransaction, TradeTransactionQueue NewTradeTransaction, string Token, short OrderType)
        {
            try
            {
                GetTradeHistoryInfo historyInfo  = new GetTradeHistoryInfo();
                GetBuySellBook      BuySellmodel = new GetBuySellBook();
                //add buyer/seller book
                //add OpenOrder
                //add recent order
                // HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, " TransactionQueue :" );
                if (string.IsNullOrEmpty(Token))
                {
                    Token = GetTokenByUserID(NewTradeTransaction.MemberID.ToString());
                }
                List <GetBuySellBook> list = new List <GetBuySellBook>();
                if (!string.IsNullOrEmpty(Token))
                {
                    if (NewTradeTransaction.TrnType == 4)//Buy
                    {
                        list = _frontTrnRepository.GetBuyerBook(NewTradeTransaction.PairID, NewTradeTransaction.BidPrice);
                        foreach (var model in list)
                        {
                            BuySellmodel = model;
                            break;
                        }
                        if (BuySellmodel.OrderId.ToString() != "00000000-0000-0000-0000-000000000000")
                        {
                            BuyerBook(BuySellmodel, NewTradeTransaction.PairName);
                            HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, "BuyerBook call TRNNO:" + Newtransaction.Id + " Pair :" + NewTradeTransaction.PairName);
                        }
                    }
                    else//Sell
                    {
                        list = _frontTrnRepository.GetSellerBook(NewTradeTransaction.PairID, NewTradeTransaction.AskPrice);
                        foreach (var model in list)
                        {
                            BuySellmodel = model;
                            break;
                        }
                        if (BuySellmodel.OrderId.ToString() != "00000000-0000-0000-0000-000000000000")
                        {
                            SellerBook(BuySellmodel, NewTradeTransaction.PairName);
                            HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, "SellerBook call TRNNO:" + Newtransaction.Id + " Pair :" + NewTradeTransaction.PairName);
                        }
                    }
                    //var msg = EnResponseMessage.SignalRTrnSuccessfullyCreated;
                    //msg = msg.Replace("#Price#", historyInfo.Price.ToString());
                    //msg = msg.Replace("#Qty#", historyInfo.Amount.ToString());
                    //ActivityNotification(msg, Token);

                    GetAndSendOpenOrderData(Newtransaction, NewTradeTransaction, Token, OrderType);
                    HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, " Aftre Open Order Socket call  TRNNO:" + Newtransaction.Id);
                    GetAndSendRecentOrderData(Newtransaction, NewTradeTransaction, Token, OrderType);
                    HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, " Aftre Recent Order Socket call  TRNNO:" + Newtransaction.Id);
                }
            }
            catch (Exception ex)
            {
                HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex);
                ////throw ex;
            }
        }