/// <summary> /// 保存全局参数配置。 /// </summary> /// <param name="config"></param> public void SaveGlobalFontServerConfig(GlobalFontServerConfig config) { try { USeXmlSerializer.SaveToXml(this.GlobalFontServerConfigFilePath, config); } catch (Exception ex) { throw new Exception("SaveGlobalFontServerConfig failed,Error:" + ex.Message); } }
private void btnOK_Click(object sender, EventArgs e) { List <FrontSeverConfig> serverList = new List <FrontSeverConfig>(); GlobalFontServerConfig globalConfig = new GlobalFontServerConfig(); try { foreach (FrontSeverConfigViewModel data in m_dataSource) { if (VerifyDataCheck(data) == false) { return; } FrontSeverConfig itemConfig = new FrontSeverConfig(); itemConfig.BrokerID = data.BrokerID; //经纪商代码 itemConfig.BrokerName = data.BrokerName; //经纪商 itemConfig.QuoteFrontAddress = data.QuoteFrontAddress; //行情地址 itemConfig.QuoteFrontPort = data.QuoteFrontPort; //行情端口 itemConfig.TradeFrontAddress = data.TradeFrontAddress; //交易地址 itemConfig.TradeFrontPort = data.TradeFrontPort; //交易端口 itemConfig.AuthCode = data.AuthCode; itemConfig.UserProductInfo = data.UserProductInfo; serverList.Add(itemConfig); } globalConfig.ServerList = serverList; if (serverList.Count > 0) { globalConfig.DefaultBrokerId = serverList[serverList.Count - 1].BrokerID; } } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, "保存服务信息失败," + ex.Message); return; } try { USeManager.Instance.DataAccessor.SaveGlobalFontServerConfig(globalConfig); } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, "保存服务信息失败," + ex.Message); return; } this.DialogResult = DialogResult.Yes; this.Close(); }
private void FrontServerConfigForm_Load(object sender, EventArgs e) { m_dataSource = new BindingList <FrontSeverConfigViewModel>(); this.gridServerConfig.AutoGenerateColumns = false; this.gridServerConfig.DataSource = m_dataSource; GlobalFontServerConfig globalConfig = USeManager.Instance.DataAccessor.GetGlobalFontServerConfig(); if (globalConfig != null && globalConfig.ServerList != null && globalConfig.ServerList.Count > 0) { foreach (FrontSeverConfig item in globalConfig.ServerList) { m_dataSource.Add(FrontSeverConfigViewModel.Create(item)); } } }
/// <summary> /// 获取前置服务配置信息。 /// </summary> /// <returns></returns> public GlobalFontServerConfig GetGlobalFontServerConfig() { GlobalFontServerConfig config = null; try { if (File.Exists(this.GlobalFontServerConfigFilePath) == false) { config = new GlobalFontServerConfig(); config.DefaultBrokerId = "9999"; //FrontSeverConfig guoTaiJunAnConfigItem = new FrontSeverConfig() { // BrokerID = "2071", // BrokerName = "国泰君安(模拟)", // QuoteFrontAddress = "180.169.77.111", // QuoteFrontPort = 42213, // TradeFrontAddress = "180.169.77.111", // TradeFrontPort = 42205 //}; FrontSeverConfig simNowConfigItem = new FrontSeverConfig() { BrokerID = "9999", BrokerName = "SimNow", QuoteFrontAddress = "180.168.146.187", QuoteFrontPort = 10010, TradeFrontAddress = "180.168.146.187", TradeFrontPort = 10000 }; //config.ServerList = new List<FrontSeverConfig>() { simNowConfigItem, guoTaiJunAnConfigItem }; config.ServerList = new List <FrontSeverConfig>() { simNowConfigItem }; } else { config = USeXmlSerializer.LoadFromXml <GlobalFontServerConfig>(this.GlobalFontServerConfigFilePath); } return(config); } catch (Exception ex) { throw new Exception("GetGlobalFontServerConfig failed,Error:" + ex.Message); } }