public byte[] ToBytesForQuotation(Token token,TraderState state,QuotationCommand command) { byte[] result = null; try { if (token.AppType == AppType.Mobile) { result = GetQuotationWhenMobile(token, state, command); } else if (token.AppType == AppType.TradingConsole) { var quotation = Quotation4Bit.TryAddQuotation(command.OverridedQs, state, command.Sequence); if (quotation == null) { return null; } result = quotation.GetData(); } } catch (Exception ex) { _Logger.Error(ex); } return result; }
public byte[] ToBytesForGeneral(Token token, TraderState state,Command command) { byte[] result = null; try { if (state.QuotationFilterSign == null) { return result; } return GetDataBytesInUtf8Format(token, state,command); } catch(Exception ex) { _Logger.Error(ex); result = null; } return result; }
public static Quotation4Bit TryAddQuotation(OverridedQuotation[] overridedQuotations, TraderState state, long sequence) { Quotation4Bit quotation; long filterSign = state.SignMapping; if (_Dict.TryGetValue(filterSign, out quotation)) { return quotation; } quotation = Quotation4BitPool.Default.Pop(); if (quotation == null) { quotation = new Quotation4Bit(overridedQuotations, state); } else { quotation.Initialize(overridedQuotations, state); } quotation.Sequence = sequence; if (_Dict.TryAdd(filterSign, quotation)) { return quotation; } return quotation; }
private Quotation4Bit(OverridedQuotation[] overridedQuotations,TraderState state) { this.OverridedQuotations = overridedQuotations; this.State = state; this.Price = null; }
public void Initialize(OverridedQuotation[] overridedQuotations, TraderState state) { this.OverridedQuotations = overridedQuotations; this.State = state; this.Price = null; }
private DataSet InternalGetQuotePolicyDetailsAndRefreshInstrumentsState(long session,Guid customerID) { DataSet dataSet = Application.Default.TradingConsoleServer.GetQuotePolicyDetails(customerID); TradingConsoleState state = SessionManager.Default.GetTradingConsoleState(session); Application.Default.TradingConsoleServer.RefreshInstrumentsState2(dataSet, ref state, session.ToString()); if (state != null) { TraderState traderState = new TraderState(state); traderState.CaculateQuotationFilterSign(); SessionManager.Default.AddTradingConsoleState(session, traderState); } return dataSet; }
//no use public XmlNode GetParameterForJava(long session,string companyCode, string version) { string physicalPath = SettingManager.Default.PhysicPath+"\\" + companyCode + "\\" + version + "\\"; //Get xml try { string xmlPath = physicalPath + "Setting\\Parameter.xml"; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(xmlPath); xmlPath = physicalPath + "Setting\\Login.xml"; System.Xml.XmlDocument doc2 = new System.Xml.XmlDocument(); doc2.Load(xmlPath); System.Xml.XmlNode node2 = doc2.GetElementsByTagName("Login")[0]; System.Xml.XmlNode parameterXmlNode = doc.GetElementsByTagName("Parameter")[0]; string newsLanguage = node2.SelectNodes("NewsLanguage").Item(0).InnerXml; //this.Context.Session["NewsLanguage"] = newsLanguage.ToLower(); TraderState state = SessionManager.Default.GetTradingConsoleState(session); if (state == null) { state = new TraderState(session.ToString()); } state.Language = newsLanguage.ToLower(); SessionManager.Default.AddTradingConsoleState(session, state); XmlElement newChild = doc.CreateElement("NewsLanguage"); newChild.InnerText = newsLanguage; parameterXmlNode.AppendChild(newChild); System.Xml.XmlNode node = doc.GetElementsByTagName("Parameters")[0]; return node; } catch (System.Exception ex) { AppDebug.LogEvent("TradingConsole.Service.GetParameterForJava", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } return null; }
private XmlNode GetParameterForJava(long session,string companyCode, string version) { SessionManager.Default.AddVersion(session, version); string physicalPath = Path.Combine(GetOrginazationDir(companyCode), version); //Get xml try { string xmlPath = Path.Combine(physicalPath, SettingManager.Default.GetLoginSetting("parameter")); System.Xml.XmlDocument parameterDocument = new System.Xml.XmlDocument(); parameterDocument.Load(xmlPath); System.Xml.XmlNode parameterXmlNode = parameterDocument.GetElementsByTagName("Parameter")[0]; xmlPath = Path.Combine(physicalPath, SettingManager.Default.GetLoginSetting("login")); System.Xml.XmlDocument loginDocument = new System.Xml.XmlDocument(); loginDocument.Load(xmlPath); System.Xml.XmlNode loginXmlNode = loginDocument.GetElementsByTagName("Login")[0]; string newsLanguage = loginXmlNode.SelectNodes("NewsLanguage").Item(0).InnerXml; TraderState state = SessionManager.Default.GetTradingConsoleState(session); if (state == null) { state = new TraderState(session.ToString()); } state.Language = newsLanguage.ToLower(); SessionManager.Default.AddTradingConsoleState(session, state); XmlElement newChild = parameterDocument.CreateElement("NewsLanguage"); newChild.InnerText = loginXmlNode.SelectNodes("NewsLanguage").Item(0).InnerXml; parameterXmlNode.AppendChild(newChild); string agreementContent = ""; string agreementFileFullPath = Path.Combine(physicalPath, SettingManager.Default.GetLoginSetting("agreement")); if (File.Exists(agreementFileFullPath)) { System.Xml.XmlDocument agreementDocument = new System.Xml.XmlDocument(); agreementDocument.Load(agreementFileFullPath); System.Xml.XmlNode agreementXmlNode = agreementDocument.GetElementsByTagName("Agreement")[0]; string showAgreement = agreementXmlNode.SelectNodes("ShowAgreement").Item(0).InnerXml.Trim().ToLower(); if (showAgreement == "true") { agreementContent = agreementXmlNode.SelectNodes("Content").Item(0).InnerXml; } } XmlElement agreementXmlNode2 = parameterDocument.CreateElement("Agreement"); agreementXmlNode2.InnerText = agreementContent; parameterXmlNode.AppendChild(agreementXmlNode2); string columnSettings = Path.Combine(GetOrginazationDir(companyCode), SettingManager.Default.GetLoginSetting("column_setting")); if (File.Exists(columnSettings)) { System.Xml.XmlDocument columnSettingsDocument = new System.Xml.XmlDocument(); columnSettingsDocument.Load(columnSettings); System.Xml.XmlNode columnSettingsXmlNode = columnSettingsDocument.GetElementsByTagName("ColumnSettings")[0]; columnSettingsXmlNode = parameterDocument.ImportNode(columnSettingsXmlNode, true); parameterXmlNode.AppendChild(columnSettingsXmlNode); } string integralitySettings = Path.Combine(GetOrginazationDir(companyCode), SettingManager.Default.GetLoginSetting("integrality_settings")); if (File.Exists(columnSettings)) { System.Xml.XmlDocument integralitySettingsDocument = new System.Xml.XmlDocument(); integralitySettingsDocument.Load(integralitySettings); System.Xml.XmlNode integralitySettingsXmlNode = integralitySettingsDocument.GetElementsByTagName("IntegralitySettings")[0]; integralitySettingsXmlNode = parameterDocument.ImportNode(integralitySettingsXmlNode, true); parameterXmlNode.AppendChild(integralitySettingsXmlNode); } System.Xml.XmlNode node = parameterDocument.GetElementsByTagName("Parameters")[0]; return node; } catch (System.Exception ex) { AppDebug.LogEvent("TradingConsole.Service.GetParameterForJava", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } return null; }
private byte[] GetQuotationWhenMobile(Token token, TraderState state,QuotationCommand command) { byte[] result = null; result = GetQuotationCommon(token, state); if (result == null) { XmlDocument xmlDoc = new XmlDocument(); XmlElement commands = xmlDoc.CreateElement("Commands"); xmlDoc.AppendChild(commands); XmlNode commandNode = command.ToXmlNode(token, state); if (commandNode == null) { return null; } XmlNode commandNode2 = commands.OwnerDocument.ImportNode(commandNode, true); commands.AppendChild(commandNode2); commands.SetAttribute("FirstSequence", command.Sequence.ToString()); commands.SetAttribute("LastSequence", command.Sequence.ToString()); result = Constants.ContentEncoding.GetBytes(commands.OuterXml); CacheQuotationCommon(token.AppType, state.SignMapping, result); } return result; }
private byte[] GetQuotationCommon(Token token, TraderState state) { byte[] result = null; ConcurrentDictionary<long, byte[]> dict = null; if (!this._QuotationFilterByAppTypeDict.TryGetValue(token.AppType, out dict)) { dict = new ConcurrentDictionary<long, byte[]>(); this._QuotationFilterByAppTypeDict.TryAdd(token.AppType,dict); } dict.TryGetValue(state.SignMapping,out result); return result; }
private byte[] GetDataBytesInUtf8Format(Token token, TraderState state,Command command) { var node = ConvertCommand(token, state, command); if (node == null) { return null; } string xml = node.OuterXml; if (string.IsNullOrEmpty(xml)) { return null; } return Constants.ContentEncoding.GetBytes(xml); }