/// <summary> /// 获取撮合中心UComboItem集合 /// </summary> /// <returns></returns> public static List <UComboItem> GetMatchCenterList() { UComboItem item; List <UComboItem> listUComboItem = new List <UComboItem>(); try { ManagementCenter.BLL.RC_MatchCenterBLL MatchCenterBLL = new RC_MatchCenterBLL(); List <RC_MatchCenter> l = MatchCenterBLL.GetListArray(string.Empty); if (l == null) { return(null); } foreach (RC_MatchCenter MatchCenter in l) { item = new UComboItem(MatchCenter.MatchCenterName, MatchCenter.MatchCenterID); listUComboItem.Add(item); } } catch { return(null); } return(listUComboItem); }
/// <summary> /// 根据IP和端口获取撮合中心 /// </summary> /// <param name="ip"></param> /// <param name="port"></param> /// <returns></returns> public Entity.RC_MatchCenter GetMatchCenterByIpAndPort(string ip, int port) { try { LogHelper.WriteDebug("Debug-8227根据IP和端口获取撮合中心方法名称:GetMatchCenterByIpAndPort(string ip, int port)" + DateTime.Now); RC_MatchCenterBLL MatchCenterBLL = new RC_MatchCenterBLL(); List <Entity.RC_MatchCenter> rC_MatchCenterList = MatchCenterBLL.GetListArray(string.Format("IP='{0}' AND Port={1}", ip, port)); if (rC_MatchCenterList.Count > 0) { Entity.RC_MatchCenter rC_MatchCenter = rC_MatchCenterList[0]; if (rC_MatchCenter != null) { return(rC_MatchCenter); } } return(null); } catch (Exception ex) { string errCode = "GL-8227"; string errMsg = "根据IP和端口获取撮合中心失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(null); } }
/// <summary> /// 获取撮合中心列表 /// </summary> /// <returns></returns> public List <Entity.RC_MatchCenter> GetAllMatchCenter() { try { LogHelper.WriteDebug("Debug-8226获取撮合中心列表方法名称:GetAllMatchCenter()" + DateTime.Now); RC_MatchCenterBLL MatchCenterBLL = new RC_MatchCenterBLL(); return(MatchCenterBLL.GetListArray(string.Empty)); } catch (Exception ex) { string errCode = "GL-8226"; string errMsg = "获取撮合中心列表失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(null); } }
/// <summary> /// 保存数据事件 /// </summary> /// <returns></returns> public bool SaveDate() { try { ManagementCenter.BLL.RC_MatchCenterBLL RC_MatchCenter = new RC_MatchCenterBLL(); if (RC_MatchCenter.GuideSave(CenterInfo.Instance.MatchCenter, Bourse_Machine.Instance.ds.Tables[0])) { return(true); } else { return(false); } } catch (Exception ex) { string errCode = "GL-2050"; string errMsg = "保存数据事件失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(false); } }
/// <summary> /// 测试柜台服务和撮合服务连接状态 /// </summary> private static void TestConnState() { while (true) { int timegap = 0; try { ManagementCenter.BLL.CT_CounterBLL CounterBLL = new CT_CounterBLL(); CounterBLL.CenterTestConnection(); ManagementCenter.BLL.RC_MatchCenterBLL MatchCenterBLL = new RC_MatchCenterBLL(); MatchCenterBLL.CenterTestConnection(); if (!int.TryParse(System.Configuration.ConfigurationManager.AppSettings["TestConnGapTime"].ToString(), out timegap)) { timegap = 600000; } } catch (Exception ex) { LogHelper.WriteError("测试柜台和撮合服务是否连接的方法失败", ex.InnerException); } Thread.Sleep(timegap); } }
/// <summary> /// 把新增的现货代码(StockInfo表和HKStockInfo表中)新增的代码自动添加到交易商品_撮合机_分配表中 /// </summary> public void XHCodeAutoRCTradeCommodityAssign() { try { //交易所类型ID int bourseTypeID = 0; StockInfoBLL stockInfoBLL = new StockInfoBLL(); HKStockInfoBLL hKStockInfoBLL = new HKStockInfoBLL(); CM_BreedClassBLL cM_BreedClassBLL = new CM_BreedClassBLL(); RC_MatchCenterBLL rcMatchCenterBll = new RC_MatchCenterBLL(); RC_MatchMachineBLL rcMatchMachineBll = new RC_MatchMachineBLL(); RC_TradeCommodityAssignBLL rcTradeCommodityAssignBll = new RC_TradeCommodityAssignBLL(); RC_MatchMachine rcMatchMachine = new RC_MatchMachine(); RC_MatchCenter rcMatchCenterModel = new RC_MatchCenter(); RC_TradeCommodityAssign rcTradeCommodityAssignModel = new RC_TradeCommodityAssign(); //获取撮合中心记录 List <ManagementCenter.Model.RC_MatchCenter> rcMatchCenters = rcMatchCenterBll.GetListArray(string.Empty); if (rcMatchCenters.Count == 0) { string errCode = "GL-7005"; string errMsg = "撮合中心记录不存在!"; LogHelper.WriteDebug(errCode + errMsg); VTException exception = new VTException(errCode, errMsg); LogHelper.WriteError(exception.ToString(), exception.InnerException); return; } //获取所有新添加的普通代码 string strWhereStock = " StockCode not in (select CommodityCode from CM_Commodity) "; List <StockInfo> stockInfoList = stockInfoBLL.GetStockInfoList(strWhereStock); //获取所有新添加的港股代码 string strWhereHKStock = " StockCode not in (select HKCommodityCode from HK_Commodity) "; List <HKStockInfo> hKStockInfoList = hKStockInfoBLL.GetHKStockInfoList(strWhereHKStock); if (stockInfoList.Count > 0) { int breedClassID = 0;//品种标识 foreach (StockInfo info in stockInfoList) { if (breedClassID != info.BreedClassID) { breedClassID = info.BreedClassID; //获取相同品种ID的所有代码 string strWhereStock1 = " StockCode not in (select CommodityCode from CM_Commodity) and BreedClassID={0} "; List <StockInfo> _stockInfoList = stockInfoBLL.GetStockInfoList(string.Format(strWhereStock1, breedClassID));//(string.Format(" and BreedClassID={0}", breedClassID)); if (_stockInfoList == null || _stockInfoList.Count == 0) { string errCode = "GL-7006"; string errMsg = "相同品种ID的所有普通代码为空!"; LogHelper.WriteDebug(errCode + errMsg); VTException exception = new VTException(errCode, errMsg); LogHelper.WriteError(exception.ToString(), exception.InnerException); continue; } //根据品种ID获取交易所ID CM_BreedClass cmBreedClass = cM_BreedClassBLL.GetModel(breedClassID); if (cmBreedClass != null) { bourseTypeID = (int)cmBreedClass.BourseTypeID; //根据交易所类型ID,获取撮合机记录 List <ManagementCenter.Model.RC_MatchMachine> rcMatchMachines = rcMatchMachineBll.GetListArray(string.Format("BourseTypeID={0}", bourseTypeID)); if (rcMatchMachines.Count == 0) { string errCode = "GL-7007"; string errMsg = "获取撮合机记录不存在!"; LogHelper.WriteDebug(errCode + errMsg); VTException exception = new VTException(errCode, errMsg); LogHelper.WriteError(exception.ToString(), exception.InnerException); return; } //把同一品种ID的所有代码添加到交易商品_撮合机_分配表中 foreach (StockInfo _stockInfo in _stockInfoList) { rcTradeCommodityAssignModel.CommodityCode = _stockInfo.StockCode; rcTradeCommodityAssignModel.MatchMachineID = rcMatchMachines[0].MatchMachineID; rcTradeCommodityAssignModel.CodeFormSource = (int)GTA.VTS.Common.CommonObject.Types.IsCodeFormSource.Yes; //_stockInfo.CodeFromSource; rcTradeCommodityAssignBll.Add(rcTradeCommodityAssignModel); } } } continue; } } if (hKStockInfoList.Count > 0) { int breedClassID = 0;//品种标识 foreach (HKStockInfo hKInfo in hKStockInfoList) { if (breedClassID != hKInfo.BreedClassID) { breedClassID = hKInfo.BreedClassID; //获取相同品种ID的所有港股代码 string strWhereHKStock1 = " StockCode not in (select HKCommodityCode from HK_Commodity) and BreedClassID={0} "; List <HKStockInfo> _hKStockInfoList = hKStockInfoBLL.GetHKStockInfoList(string.Format(strWhereHKStock1, breedClassID));//(string.Format(" and BreedClassID={0}", breedClassID)); if (_hKStockInfoList == null || _hKStockInfoList.Count == 0) { string errCode = "GL-7008"; string errMsg = "相同品种ID的所有港股代码为空!"; LogHelper.WriteDebug(errCode + errMsg); VTException exception = new VTException(errCode, errMsg); LogHelper.WriteError(exception.ToString(), exception.InnerException); continue; } //根据品种ID获取交易所ID CM_BreedClass cmBreedClass = cM_BreedClassBLL.GetModel(breedClassID); if (cmBreedClass != null) { bourseTypeID = (int)cmBreedClass.BourseTypeID; //根据交易所类型ID,获取撮合机记录 List <ManagementCenter.Model.RC_MatchMachine> rcMatchMachines = rcMatchMachineBll.GetListArray(string.Format("BourseTypeID={0}", bourseTypeID)); if (rcMatchMachines.Count == 0) { string errCode = "GL-7009"; string errMsg = "获取撮合机记录不存在!"; LogHelper.WriteDebug(errCode + errMsg); VTException exception = new VTException(errCode, errMsg); LogHelper.WriteError(exception.ToString(), exception.InnerException); return; } //把同一品种ID的所有港股代码添加到交易商品_撮合机_分配表中 foreach (HKStockInfo _hKStockInfo in _hKStockInfoList) { rcTradeCommodityAssignModel.CommodityCode = _hKStockInfo.StockCode; rcTradeCommodityAssignModel.MatchMachineID = rcMatchMachines[0].MatchMachineID; rcTradeCommodityAssignModel.CodeFormSource = (int)GTA.VTS.Common.CommonObject.Types.IsCodeFormSource.No; //_hKStockInfo.CodeFromSource; rcTradeCommodityAssignBll.Add(rcTradeCommodityAssignModel); } } } continue; } } } catch (Exception ex) { string errCode = "GL-7010"; string errMsg = "把新增的现货代码(StockInfo表和HKStockInfo表中)新增的代码添加到交易商品_撮合机_分配表中失败!"; LogHelper.WriteDebug(errCode + errMsg); VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); } }
/// <summary> /// 把期货新增的代码自动添加到可交易商品_撮合机_分配表中 /// </summary> /// <param name="CommodityName">商品代码</param> /// <param name="BreedClassID">品种ID</param> public void QHCodeAutoRCTradeCommodityAssign(string CommodityName, int BreedClassID) { try { //交易所类型ID int bourseTypeID = 0; CM_BreedClassBLL cM_BreedClassBLL = new CM_BreedClassBLL(); RC_MatchCenterBLL rcMatchCenterBll = new RC_MatchCenterBLL(); RC_MatchMachineBLL rcMatchMachineBll = new RC_MatchMachineBLL(); RC_TradeCommodityAssignBLL rcTradeCommodityAssignBll = new RC_TradeCommodityAssignBLL(); RC_MatchMachine rcMatchMachine = new RC_MatchMachine(); RC_MatchCenter rcMatchCenterModel = new RC_MatchCenter(); RC_TradeCommodityAssign rcTradeCommodityAssignModel = new RC_TradeCommodityAssign(); //根据品种ID获取交易所ID CM_BreedClass cmBreedClass = cM_BreedClassBLL.GetModel(BreedClassID); if (cmBreedClass != null) { bourseTypeID = (int)cmBreedClass.BourseTypeID; } //获取撮合中心记录 List <ManagementCenter.Model.RC_MatchCenter> rcMatchCenters = rcMatchCenterBll.GetListArray(string.Empty); //撮合中心记录存在 if (rcMatchCenters.Count > 0) { //根据交易所类型ID,获取撮合机记录 List <ManagementCenter.Model.RC_MatchMachine> rcMatchMachines = rcMatchMachineBll.GetListArray(string.Format("BourseTypeID={0}", bourseTypeID)); //有撮合机存在,则向可交易商品_撮合机_分配表中添加新代码 if (rcMatchMachines.Count > 0) { //判断代码分配记录已存在则退出 add by 董鹏 2010-03-31 if (rcTradeCommodityAssignBll.Exists(CommodityName, rcMatchMachines[0].MatchMachineID)) { return; } rcTradeCommodityAssignModel.CommodityCode = CommodityName; rcTradeCommodityAssignModel.MatchMachineID = rcMatchMachines[0].MatchMachineID; rcTradeCommodityAssignBll.Add(rcTradeCommodityAssignModel); } else { //撮合机不存在,则添加撮合机 rcMatchMachine.MatchCenterID = rcMatchCenters[0].MatchCenterID; rcMatchMachine.MatchMachineName = "自动添加的撮合机名称";//保证不重复 rcMatchMachine.BourseTypeID = bourseTypeID; int result = rcMatchMachineBll.Add(rcMatchMachine); if (result > 0) { rcTradeCommodityAssignModel.CommodityCode = CommodityName; rcTradeCommodityAssignModel.MatchMachineID = rcMatchMachines[0].MatchMachineID; rcTradeCommodityAssignBll.Add(rcTradeCommodityAssignModel); } else { //写错误日志 LogHelper.WriteDebug("添加撮合机失败"); } } } else { //添加撮合中心记录 rcMatchCenterModel.MatchCenterName = "自动添加的撮合中心名称"; rcMatchCenterModel.IP = "127.0.0.1"; rcMatchCenterModel.Port = 9281; rcMatchCenterModel.CuoHeService = "OrderDealRpt"; rcMatchCenterModel.XiaDanService = "DoOrderService"; int addrcMatchCResultID = rcMatchCenterBll.Add(rcMatchCenterModel); if (addrcMatchCResultID > 0) { //撮合中心添加成功,则添加撮合机 rcMatchMachine.MatchCenterID = addrcMatchCResultID; // rcMatchCenterslist[0].MatchCenterID; rcMatchMachine.MatchMachineName = "自动添加的撮合机名称"; //保证不重复 rcMatchMachine.BourseTypeID = bourseTypeID; int resultMatchMachineID = rcMatchMachineBll.Add(rcMatchMachine); //撮合机添加成功,则向可交易商品_撮合机_分配表中添加新代码 if (resultMatchMachineID > 0) { rcTradeCommodityAssignModel.CommodityCode = CommodityName; rcTradeCommodityAssignModel.MatchMachineID = resultMatchMachineID;// rcMatchMachineslist[0].MatchMachineID; rcTradeCommodityAssignBll.Add(rcTradeCommodityAssignModel); } else { //写错误日志 LogHelper.WriteDebug("向可交易商品_撮合机_分配表中添加新代码失败"); } } else { //写错误日志 LogHelper.WriteDebug("添加撮合中心失败"); } } } catch (Exception ex) { string errCode = "GL-7004"; string errMsg = "执行期货新增代码自动添加到可交易商品撮合机分配表中失败"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return; } }