/// <summary> /// /// </summary> /// <param name="InvestorID"></param> /// <returns></returns> public static List<TradingServer.ClientBusiness.Command> FacadeGetBinaryCommandByInvestorID(int InvestorID, int MarketArea) { List<ClientBusiness.Command> Result = new List<ClientBusiness.Command>(); List<Business.OpenTrade> tempResult = new List<Business.OpenTrade>(); if (Business.Market.InvestorList != null) { int count = Business.Market.InvestorList.Count; for (int i = 0; i < count; i++) { if (Business.Market.InvestorList[i].InvestorID == InvestorID) { if (Business.Market.InvestorList[i].BinaryCommandList != null) { int countCommand = Business.Market.InvestorList[i].BinaryCommandList.Count; for (int j = 0; j < countCommand; j++) { tempResult.Add(Business.Market.InvestorList[i].BinaryCommandList[j]); } } } } } if (tempResult != null) { int count = tempResult.Count; for (int i = 0; i < count; i++) { TradingServer.ClientBusiness.Command newCommand = new ClientBusiness.Command(); newCommand.ClosePrice = tempResult[i].ClosePrice; newCommand.CommandID = tempResult[i].ID; newCommand.CommandType = tempResult[i].Type.ID.ToString(); newCommand.Commission = tempResult[i].Commission; newCommand.InvestorID = tempResult[i].Investor.InvestorID; switch (tempResult[i].Type.ID) { case 3: newCommand.IsBuy = true; break; case 4: newCommand.IsBuy = false; break; } newCommand.OpenPrice = tempResult[i].OpenPrice.ToString(); newCommand.Size = int.Parse(tempResult[i].Size.ToString()); newCommand.StopLoss = tempResult[i].StopLoss; newCommand.Swap = tempResult[i].Swap; newCommand.Symbol = tempResult[i].Symbol.Name; newCommand.TakeProfit = tempResult[i].TakeProfit; newCommand.Time = tempResult[i].OpenTime.ToString(); newCommand.TimeExpiry = tempResult[i].ExpTime; newCommand.ClientCode = tempResult[i].ClientCode; newCommand.CommandCode = tempResult[i].CommandCode; Result.Add(newCommand); } } return Result; }
/// <summary> /// /// </summary> /// <param name="value"></param> public void ClientPort(string value, string ipAddress) { string[] subValue = value.Split('$'); switch (subValue[0]) { #region BUYSPOT COMMAND case "BuyCommand": { TradingServer.ClientBusiness.Command objCommand = TradingServer.Model.BuildCommand.Instance.ConvertStringToCommand(subValue[1]); objCommand.IsBuy = true; objCommand.CommandType = "1"; objCommand.IpAddress = ipAddress; TradingServer.ClientFacade.FacadeMakeCommand(objCommand); } break; #endregion #region SELLSPOT COMMAND case "SellCommand": { TradingServer.ClientBusiness.Command objCommand = TradingServer.Model.BuildCommand.Instance.ConvertStringToCommand(subValue[1]); objCommand.IsBuy = false; objCommand.CommandType = "2"; objCommand.IpAddress = ipAddress; //CHECK VALID IPADDRESS //bool checkIp = TradingServer.Business.ValidIPAddress.Instance.ValidIpAddress(objCommand.InvestorID, ipAddress); //bool checkOnline = false; //checkIp = true; //if (checkIp) // checkOnline = TradingServer.Business.Investor.investorInstance.CheckInvestorOnline(objCommand.InvestorID, objCommand.LoginKey); //else // return; //if (!checkOnline) // return; TradingServer.ClientFacade.FacadeMakeCommand(objCommand); } break; #endregion #region BUYSTOP COMMAND case "BuyStop": { TradingServer.ClientBusiness.Command objCommand = TradingServer.Model.BuildCommand.Instance.ConvertStringToCommand(subValue[1]); objCommand.IsBuy = true; objCommand.CommandType = "9"; objCommand.IpAddress = ipAddress; //CHECK VALID IPADDRESS bool checkIp = TradingServer.Business.ValidIPAddress.Instance.ValidIpAddress(objCommand.InvestorID, ipAddress); bool checkOnline = false; if (checkIp) checkOnline = TradingServer.Business.Investor.investorInstance.CheckInvestorOnline(objCommand.InvestorID, objCommand.LoginKey); else return; if (!checkOnline) return; TradingServer.ClientFacade.FacadeMakeCommand(objCommand); } break; #endregion #region BUYLIMIT COMMAND case "BuyLimit": { TradingServer.ClientBusiness.Command objCommand = TradingServer.Model.BuildCommand.Instance.ConvertStringToCommand(subValue[1]); objCommand.IsBuy = true; objCommand.CommandType = "7"; objCommand.IpAddress = ipAddress; //CHECK VALID IPADDRESS bool checkIp = TradingServer.Business.ValidIPAddress.Instance.ValidIpAddress(objCommand.InvestorID, ipAddress); bool checkOnline = false; if (checkIp) checkOnline = TradingServer.Business.Investor.investorInstance.CheckInvestorOnline(objCommand.InvestorID, objCommand.LoginKey); else return; if (!checkOnline) return; TradingServer.ClientFacade.FacadeMakeCommand(objCommand); } break; #endregion #region SELLSTOP COMMAND case "SellStop": { TradingServer.ClientBusiness.Command objCommand = TradingServer.Model.BuildCommand.Instance.ConvertStringToCommand(subValue[1]); objCommand.IsBuy = false; objCommand.CommandType = "10"; objCommand.IpAddress = ipAddress; //CHECK VALID IPADDRESS bool checkIp = TradingServer.Business.ValidIPAddress.Instance.ValidIpAddress(objCommand.InvestorID, ipAddress); bool checkOnline = false; if (checkIp) checkOnline = TradingServer.Business.Investor.investorInstance.CheckInvestorOnline(objCommand.InvestorID, objCommand.LoginKey); else return; if (!checkOnline) return; TradingServer.ClientFacade.FacadeMakeCommand(objCommand); } break; #endregion #region SELLLIMIT COMMAND case "SellLimit": { TradingServer.ClientBusiness.Command objCommand = TradingServer.Model.BuildCommand.Instance.ConvertStringToCommand(subValue[1]); objCommand.IsBuy = false; objCommand.CommandType = "8"; objCommand.IpAddress = ipAddress; //CHECK VALID IPADDRESS bool checkIp = TradingServer.Business.ValidIPAddress.Instance.ValidIpAddress(objCommand.InvestorID, ipAddress); bool checkOnline = false; if (checkIp) checkOnline = TradingServer.Business.Investor.investorInstance.CheckInvestorOnline(objCommand.InvestorID, objCommand.LoginKey); else return; if (!checkOnline) return; TradingServer.ClientFacade.FacadeMakeCommand(objCommand); } break; #endregion #region UPDATE ONLINE COMMAND case "UpdateOnlineCommand": //Update Online Command And Pending Order Command { // TradingServer.ClientBusiness.Command objCommand = TradingServer.Model.BuildCommand.Instance.ConvertStringToCommands(subValue[1]); objCommand.IpAddress = ipAddress; //CHECK VALID IPADDRESS bool checkIp = TradingServer.Business.ValidIPAddress.Instance.ValidIpAddress(objCommand.InvestorID, ipAddress); bool checkOnline = false; if (checkIp) checkOnline = TradingServer.Business.Investor.investorInstance.CheckInvestorOnline(objCommand.InvestorID, objCommand.LoginKey); else return; if (!checkOnline) return; TradingServer.ClientFacade.FacadeUpdateOnlineCommand(objCommand); } break; #endregion #region CLOSE COMMAND case "CloseCommand": { string[] subParameter = subValue[1].Split('{'); int commandID = -1; double size = -1; double closePrice = -1; int investorID = -1; int.TryParse(subParameter[0], out commandID); double.TryParse(subParameter[1], out closePrice); double.TryParse(subParameter[2], out size); int.TryParse(subParameter[5], out investorID); TradingServer.ClientBusiness.Command objCommand = new ClientBusiness.Command(); objCommand.CommandID = commandID; objCommand.ClosePrice = closePrice; objCommand.Size = size; objCommand.Symbol = subParameter[3]; objCommand.LoginKey = subParameter[4]; objCommand.IpAddress = ipAddress; objCommand.InvestorID = investorID; //CHECK VALID IPADDRESS //bool checkIp = TradingServer.Business.ValidIPAddress.Instance.ValidIpAddress(objCommand.InvestorID, ipAddress); //bool checkOnline = false; //if (checkIp) // checkOnline = TradingServer.Business.Investor.investorInstance.CheckInvestorOnline(objCommand.InvestorID, objCommand.LoginKey); //else // return; //if (!checkOnline) // return; TradingServer.ClientFacade.FacadeCloseSpotCommand(objCommand); } break; #endregion } }
/// <summary> /// /// </summary> /// <param name="investorID"></param> /// <returns></returns> public static List<TradingServer.ClientBusiness.Command> FacadeGetPendingOrderByInvestorID(int investorID) { List<ClientBusiness.Command> Result = new List<ClientBusiness.Command>(); List<Business.OpenTrade> tempResult = new List<Business.OpenTrade>(); try { #region GET PENDING ORDER OF INVESTOR if (Business.Market.InvestorList != null) { int count = Business.Market.InvestorList.Count; for (int i = 0; i < count; i++) { if (Business.Market.InvestorList[i].InvestorID == investorID) { if (Business.Market.InvestorList[i].CommandList != null) { int countCommand = Business.Market.InvestorList[i].CommandList.Count; for (int j = 0; j < countCommand; j++) { if (Business.Market.InvestorList[i].CommandList[j].Type.ID == 7 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 8 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 9 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 10 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 17 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 18 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 19 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 20) { tempResult.Add(Business.Market.InvestorList[i].CommandList[j]); //update time last connect Business.Market.InvestorList[i].UpdateLastConnect(investorID, Business.Market.InvestorList[i].LoginKey); } } } break; } } } #endregion #region MAP OBJECT OPEN TRADE TO COMMAND CLIENT if (tempResult != null) { int count = tempResult.Count; for (int i = 0; i < count; i++) { string CommandType = string.Empty; TradingServer.ClientBusiness.Command newCommand = new ClientBusiness.Command(); newCommand.ClosePrice = tempResult[i].ClosePrice; newCommand.CommandID = tempResult[i].ID; if (tempResult[i].Type != null) { switch (tempResult[i].Type.ID) { case 1: CommandType = "Open"; newCommand.IsBuy = true; break; case 2: newCommand.IsBuy = false; CommandType = "Open"; break; case 7: CommandType = "BuyLimit"; break; case 8: CommandType = "SellLimit"; break; case 9: CommandType = "BuyStop"; break; case 10: CommandType = "SellStop"; break; case 11: CommandType = "BuyFutureCommand"; newCommand.IsBuy = true; break; case 12: CommandType = "SellFutureCommand"; newCommand.IsBuy = false; break; case 17: CommandType = "BuyStop"; break; case 18: CommandType = "SellStop"; break; case 19: CommandType = "BuyLimit"; break; case 20: CommandType = "SellLimit"; break; } } newCommand.CommandType = CommandType; newCommand.Commission = tempResult[i].Commission; newCommand.InvestorID = tempResult[i].Investor.InvestorID; newCommand.OpenPrice = tempResult[i].OpenPrice.ToString(); newCommand.Size = double.Parse(tempResult[i].Size.ToString()); newCommand.StopLoss = tempResult[i].StopLoss; newCommand.Swap = tempResult[i].Swap; newCommand.Symbol = tempResult[i].Symbol.Name; newCommand.TakeProfit = tempResult[i].TakeProfit; newCommand.Time = tempResult[i].OpenTime.ToString(); newCommand.TimeExpiry = tempResult[i].ExpTime; newCommand.ClientCode = tempResult[i].ClientCode; newCommand.CommandCode = tempResult[i].CommandCode; newCommand.TypeID = tempResult[i].Type.ID; newCommand.Margin = tempResult[i].Margin; newCommand.FreezeMargin = tempResult[i].FreezeMargin; newCommand.IsHedged = tempResult[i].Symbol.IsHedged; newCommand.Profit = tempResult[i].Profit; newCommand.Comment = tempResult[i].Comment; Result.Add(newCommand); } } #endregion } catch (Exception ex) { } return Result; }
/// <summary> /// /// </summary> /// <param name="InvestorID"></param> /// <returns></returns> public static List<TradingServer.ClientBusiness.Command> FacadeGetOnlineCommandByInvestor(string code, int MarketArea) { List<ClientBusiness.Command> Result = new List<ClientBusiness.Command>(); List<Business.OpenTrade> tempResult = new List<Business.OpenTrade>(); try { #region GET ONLINE COMMAND if (Business.Market.InvestorList != null && Business.Market.InvestorList.Count > 0) { for (int i = 0; i < Business.Market.InvestorList.Count; i++) { if (Business.Market.InvestorList[i].Code.ToUpper().Trim() == code.ToUpper().Trim()) { if (Business.Market.InvestorList[i].CommandList != null && Business.Market.InvestorList[i].CommandList.Count > 0) { for (int j = 0; j < Business.Market.InvestorList[i].CommandList.Count; j++) { if (Business.Market.InvestorList[i].CommandList[j].Type.ID == 1 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 2 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 11 || Business.Market.InvestorList[i].CommandList[j].Type.ID == 12) { tempResult.Add(Business.Market.InvestorList[i].CommandList[j]); } } } break; } } } #endregion #region MAP OBJECT OPEN TRADE TO COMMAND CLIENT if (tempResult != null) { int count = tempResult.Count; for (int i = 0; i < count; i++) { string CommandType = string.Empty; TradingServer.ClientBusiness.Command newCommand = new ClientBusiness.Command(); newCommand.ClosePrice = tempResult[i].ClosePrice; newCommand.CommandID = tempResult[i].ID; #region MAP COMMAND TYPE if (tempResult[i].Type != null) { switch (tempResult[i].Type.ID) { case 1: CommandType = "Open"; newCommand.IsBuy = true; break; case 2: newCommand.IsBuy = false; CommandType = "Open"; break; case 7: CommandType = "BuyLimit"; break; case 8: CommandType = "SellLimit"; break; case 9: CommandType = "BuyStop"; break; case 10: CommandType = "SellStop"; break; case 11: CommandType = "BuyFutureCommand"; newCommand.IsBuy = true; break; case 12: CommandType = "SellFutureCommand"; newCommand.IsBuy = false; break; } } #endregion newCommand.CommandType = CommandType; newCommand.Commission = tempResult[i].Commission; newCommand.InvestorID = tempResult[i].Investor.InvestorID; newCommand.OpenPrice = tempResult[i].OpenPrice.ToString(); newCommand.Size = double.Parse(tempResult[i].Size.ToString()); newCommand.StopLoss = tempResult[i].StopLoss; newCommand.Swap = tempResult[i].Swap; newCommand.Symbol = tempResult[i].Symbol.Name; newCommand.TakeProfit = tempResult[i].TakeProfit; newCommand.Time = tempResult[i].OpenTime.ToString(); newCommand.TimeExpiry = tempResult[i].ExpTime; newCommand.ClientCode = tempResult[i].ClientCode; newCommand.CommandCode = tempResult[i].CommandCode; newCommand.TypeID = tempResult[i].Type.ID; newCommand.Margin = tempResult[i].Margin; newCommand.FreezeMargin = tempResult[i].FreezeMargin; newCommand.IsHedged = tempResult[i].Symbol.IsHedged; newCommand.Profit = tempResult[i].Profit; newCommand.Comment = tempResult[i].Comment; newCommand.Digit = tempResult[i].Symbol.Digit; Result.Add(newCommand); } } #endregion } catch (Exception ex) { } return Result; }
/// <summary> /// /// </summary> /// <param name="investorID"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public static List<TradingServer.ClientBusiness.Command> FacadeGetCommandHistoryWithDateTime(int investorID, DateTime startTime, DateTime endTime) { List<ClientBusiness.Command> Result = new List<ClientBusiness.Command>(); List<Business.OpenTrade> tempResult = new List<Business.OpenTrade>(); if (Business.Market.IsConnectMT4) { if (Business.Market.InvestorList != null) { int count = Business.Market.InvestorList.Count; for (int i = 0; i < count; i++) { if (Business.Market.InvestorList[i].InvestorID == investorID) { string cmd = BuildCommandElement5ConnectMT4.Mode.BuildCommand.Instance.ConvertGetCommandHistoryToString(Business.Market.InvestorList[i].Code, startTime, endTime); //string cmdResult = Business.Market.InstanceSocket.SendToMT4(Business.Market.DEFAULT_IPADDRESS, Business.Market.DEFAULT_PORT, cmd); string cmdResult = Element5SocketConnectMT4.Business.SocketConnect.Instance.SendSocket(cmd); if (!string.IsNullOrEmpty(cmdResult)) { //List<BuildCommandElement5ConnectMT4.Business.OnlineTrade> listHistory = BuildCommandElement5ConnectMT4.Mode.ReceiveCommand.Instance.ConvertOnlineTradeToListString(cmdResult); List<BuildCommandElement5ConnectMT4.Business.OnlineTrade> listHistory = BuildCommandElement5ConnectMT4.Mode.ReceiveCommand.Instance.ConvertHistoryToListString(cmdResult); if (listHistory != null) { int countHistory = listHistory.Count; for (int j = 0; j < countHistory; j++) { Business.OpenTrade newOpenTrade = new Business.OpenTrade(); //newOpenTrade.ClientCode = tbCommandHistory[i].ClientCode; newOpenTrade.ClosePrice = listHistory[j].ClosePrice; newOpenTrade.CloseTime = listHistory[j].CloseTime; newOpenTrade.CommandCode = listHistory[j].CommandCode; newOpenTrade.Commission = listHistory[j].Commission; newOpenTrade.ExpTime = listHistory[j].TimeExpire; newOpenTrade.ID = listHistory[j].CommandID; //Investor #region FILL COMMAND TYPE switch (listHistory[j].CommandType) { case "0": { Business.TradeType resultType = Business.Market.marketInstance.GetTradeType(1); newOpenTrade.Type = resultType; } break; case "1": { Business.TradeType resultType = Business.Market.marketInstance.GetTradeType(2); newOpenTrade.Type = resultType; } break; case "2": { Business.TradeType resultType = Business.Market.marketInstance.GetTradeType(7); newOpenTrade.Type = resultType; } break; case "3": { Business.TradeType resultType = Business.Market.marketInstance.GetTradeType(8); newOpenTrade.Type = resultType; } break; case "4": { Business.TradeType resultType = Business.Market.marketInstance.GetTradeType(9); newOpenTrade.Type = resultType; } break; case "5": { Business.TradeType resultType = Business.Market.marketInstance.GetTradeType(10); newOpenTrade.Type = resultType; } break; case "6": { if (listHistory[j].Profit >= 0) { Business.TradeType resultType = new Business.TradeType(); resultType.ID = 13; resultType.Name = "Deposit"; newOpenTrade.Type = resultType; } else { Business.TradeType resultType = new Business.TradeType(); resultType.ID = 14; resultType.Name = "Withdraw"; newOpenTrade.Type = resultType; } } break; case "7": { if (listHistory[j].Profit >= 0) { Business.TradeType resultType = new Business.TradeType(); resultType.ID = 15; resultType.Name = "CreditIn"; newOpenTrade.Type = resultType; } else { Business.TradeType resultType = new Business.TradeType(); resultType.ID = 16; resultType.Name = "CreditOut"; newOpenTrade.Type = resultType; } } break; } #endregion #region Find Investor In Investor List if (Business.Market.InvestorList != null) { int countInvestor = Business.Market.InvestorList.Count; for (int m = 0; m < countInvestor; m++) { if (Business.Market.InvestorList[m].Code.ToUpper().Trim() == listHistory[j].InvestorCode) { newOpenTrade.Investor = Business.Market.InvestorList[m]; break; } } } #endregion newOpenTrade.OpenPrice = listHistory[j].OpenPrice; newOpenTrade.OpenTime = listHistory[j].OpenTime; if (newOpenTrade.Type.ID == 13 || newOpenTrade.Type.ID == 14 || newOpenTrade.Type.ID == 15 || newOpenTrade.Type.ID == 16) { newOpenTrade.CloseTime = newOpenTrade.OpenTime; } newOpenTrade.Profit = listHistory[j].Profit; newOpenTrade.Size = listHistory[j].Size; newOpenTrade.StopLoss = listHistory[j].StopLoss; newOpenTrade.Swap = listHistory[j].Swap; //newOpenTrade.Taxes = listHistory[j].Taxes; newOpenTrade.Comment = listHistory[j].Comment; //newOpenTrade.AgentCommission = listHistory[j].AgentCommission; newOpenTrade.TakeProfit = listHistory[j].TakeProfit; #region Find Symbol In Symbol List if (Business.Market.SymbolList != null) { bool Flag = false; int countSymbol = Business.Market.SymbolList.Count; for (int k = 0; k < countSymbol; k++) { if (Flag == true) break; if (Business.Market.SymbolList[k].Name.ToUpper().Trim() == listHistory[j].SymbolName.ToUpper().Trim()) { newOpenTrade.Symbol = Business.Market.SymbolList[k]; Flag = true; break; } } } #endregion tempResult.Add(newOpenTrade); } } } break; } } } } else { tempResult = ClientFacade.OpenTradeInstance.GetCommandHistoryWithTime(investorID, startTime, endTime); } if (tempResult != null) { int count = tempResult.Count; for (int i = 0; i < count; i++) { if (tempResult[i].Investor == null || tempResult[i].Type == null) continue; ClientBusiness.Command newCommand = new ClientBusiness.Command(); newCommand.ClosePrice = tempResult[i].ClosePrice; newCommand.CommandID = tempResult[i].ID; if (tempResult[i].Type != null) { newCommand.CommandType = tempResult[i].Type.Name; newCommand.TypeID = tempResult[i].Type.ID; } newCommand.Commission = tempResult[i].Commission; newCommand.InvestorID = tempResult[i].Investor.InvestorID; bool IsBuy = false; if (tempResult[i].Type != null) { if (tempResult[i].Type.ID == 1 || tempResult[i].Type.ID == 3 || tempResult[i].Type.ID == 5 || tempResult[i].Type.ID == 7 || tempResult[i].Type.ID == 9 || tempResult[i].Type.ID == 11) IsBuy = true; } newCommand.IsBuy = IsBuy; newCommand.OpenPrice = tempResult[i].OpenPrice.ToString(); newCommand.Size = double.Parse(tempResult[i].Size.ToString()); newCommand.StopLoss = tempResult[i].StopLoss; newCommand.Swap = tempResult[i].Swap; if (tempResult[i].Symbol != null) { newCommand.Symbol = tempResult[i].Symbol.Name; } newCommand.TakeProfit = tempResult[i].TakeProfit; newCommand.Time = tempResult[i].OpenTime.ToString(); newCommand.TimeExpiry = tempResult[i].ExpTime; newCommand.Profit = Math.Round(tempResult[i].Profit, 2); newCommand.ClientCode = tempResult[i].ClientCode; newCommand.CommandCode = tempResult[i].CommandCode; newCommand.CloseTime = tempResult[i].CloseTime; newCommand.Comment = tempResult[i].Comment; Result.Add(newCommand); } } return Result; }
/// <summary> /// /// </summary> /// <param name="InvestorID"></param> /// <returns></returns> public static List<TradingServer.ClientBusiness.Command> FacadeGetCommandHistoryByInvestor(int InvestorID) { List<ClientBusiness.Command> Result = new List<ClientBusiness.Command>(); List<Business.OpenTrade> tempResult = new List<Business.OpenTrade>(); //tempResult = ClientFacade.OpenTradeInstance.GetCommandHistoryByInvestor(InvestorID); tempResult = ClientFacade.OpenTradeInstance.GetCommandHistoryByInvestorInMonth(InvestorID); if (tempResult != null) { int count = tempResult.Count; for (int i = 0; i < count; i++) { if (tempResult[i].Symbol == null || tempResult[i].Investor == null || tempResult[i].Type == null) continue; if (tempResult[i].Symbol != null) { ClientBusiness.Command newCommand = new ClientBusiness.Command(); newCommand.ClosePrice = tempResult[i].ClosePrice; newCommand.CommandID = tempResult[i].ID; if (tempResult[i].Type != null) { newCommand.CommandType = tempResult[i].Type.Name; } newCommand.Commission = tempResult[i].Commission; newCommand.InvestorID = tempResult[i].Investor.InvestorID; bool IsBuy = false; if (tempResult[i].Type != null) { if (tempResult[i].Type.ID == 1 || tempResult[i].Type.ID == 3 || tempResult[i].Type.ID == 5 || tempResult[i].Type.ID == 7 || tempResult[i].Type.ID == 9 || tempResult[i].Type.ID == 11) IsBuy = true; } newCommand.IsBuy = IsBuy; newCommand.OpenPrice = tempResult[i].OpenPrice.ToString(); newCommand.Size = double.Parse(tempResult[i].Size.ToString()); newCommand.StopLoss = tempResult[i].StopLoss; newCommand.Swap = tempResult[i].Swap; if (tempResult[i].Symbol != null) { newCommand.Symbol = tempResult[i].Symbol.Name; } newCommand.TakeProfit = tempResult[i].TakeProfit; newCommand.Time = tempResult[i].OpenTime.ToString(); newCommand.TimeExpiry = tempResult[i].ExpTime; newCommand.Profit = Math.Round(tempResult[i].Profit, 2); newCommand.ClientCode = tempResult[i].ClientCode; newCommand.CommandCode = tempResult[i].CommandCode; Result.Add(newCommand); } } } return Result; }