/// <summary> /// 获取代码所属的撮合机实体 /// </summary> /// <returns></returns> public Entity.RC_MatchMachine GetMatchMachinebyCommodity(string CommodityCode) { try { LogHelper.WriteDebug("Debug-8234获取代码所属的撮合机实体方法名称:GetMatchMachinebyCommodity(string CommodityCode) 参数:" + CommodityCode + " " + DateTime.Now); //根据代码返回其它商品代码所属的撮合机实体(普通现货和股指期货) RC_TradeCommodityAssignBLL RC_TradeCommodityAssignBLL = new RC_TradeCommodityAssignBLL(); List <Entity.RC_TradeCommodityAssign> rC_TradeCommodityAssignList = RC_TradeCommodityAssignBLL.GetListArray(string.Format("CommodityCode='{0}'", CommodityCode)); if (rC_TradeCommodityAssignList.Count > 0) { Entity.RC_TradeCommodityAssign rC_TradeCommodityAssign = rC_TradeCommodityAssignList[0]; if (rC_TradeCommodityAssign != null) { return(GetMatchMachine(rC_TradeCommodityAssign.MatchMachineID)); } } return(null); } catch (Exception ex) { string errCode = "GL-8234"; string errMsg = "获取代码所属的撮合机实体失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(null); } }
private void btn_OK_Click(object sender, EventArgs e) { try { List <RC_TradeCommodityAssign> ladd = new List <RC_TradeCommodityAssign>(); List <RC_TradeCommodityAssign> ldel = new List <RC_TradeCommodityAssign>(); RC_TradeCommodityAssign TradeCommodityAssign; foreach (object obj in listReconce.Items) { UComboItemCode item = (UComboItemCode)obj; if (item.Start_HasRight == false && item.End_Hasright == true) { TradeCommodityAssign = new RC_TradeCommodityAssign(); TradeCommodityAssign.CommodityCode = item.ValueStr; TradeCommodityAssign.CodeFormSource = item.CodeFormSource; ladd.Add(TradeCommodityAssign); } } foreach (object obj in listCanUse.Items) { UComboItemCode item = (UComboItemCode)obj; if (item.Start_HasRight == true && item.End_Hasright == false) { TradeCommodityAssign = new RC_TradeCommodityAssign(); TradeCommodityAssign.CommodityCode = item.ValueStr; ldel.Add(TradeCommodityAssign); } } ManagementCenter.BLL.RC_TradeCommodityAssignBLL TradeCommodityAssignBLL = new RC_TradeCommodityAssignBLL(); if (TradeCommodityAssignBLL.Update(matchMachine.MatchMachineID, ladd, ldel)) { ShowMessageBox.ShowInformation("保存成功!"); this.Close(); } else { ShowMessageBox.ShowInformation("保存失败!"); } } catch (Exception ex) { ShowMessageBox.ShowInformation("保存失败!"); string errCode = "GL-2032"; string errMsg = "保存失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); } }
/// <summary> /// 获取一个撮合机分配的代码列表 /// </summary> /// <param name="MatchMachineID"></param> /// <returns></returns> public List <Entity.RC_TradeCommodityAssign> GetCommodityAssignByMachineID(int MatchMachineID) { try { LogHelper.WriteDebug("Debug-8232获取一个撮合机分配的代码列表方法名称:GetCommodityAssignByMachineID(int MatchMachineID)" + DateTime.Now); RC_TradeCommodityAssignBLL RC_TradeCommodityAssign = new RC_TradeCommodityAssignBLL(); return(RC_TradeCommodityAssign.GetListArray(string.Format("MatchMachineID={0}", MatchMachineID))); } catch (Exception ex) { string errCode = "GL-8232"; string errMsg = "获取一个撮合机分配的代码列表失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(null); } }
/// <summary> /// 获取撮合机—代码分配列表 /// </summary> /// <returns></returns> public List <Entity.RC_TradeCommodityAssign> GetAllTradeCommodityAssign() { try { LogHelper.WriteDebug("Debug-8231获取撮合机—代码分配列表方法名称:GetAllTradeCommodityAssign()" + DateTime.Now); RC_TradeCommodityAssignBLL RC_TradeCommodityAssign = new RC_TradeCommodityAssignBLL(); return(RC_TradeCommodityAssign.GetListArray(string.Empty)); } catch (Exception ex) { string errCode = "GL-8231"; string errMsg = "获取撮合机—代码分配列表失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(null); } }
/// <summary> /// 页面加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CodeAssign_Load(object sender, EventArgs e) { try { this.txt_MachineID.Text = matchMachine.MatchMachineID.ToString(); this.txt_MachineName.Text = matchMachine.MatchMachineName.ToString(); this.txt_MachineID.Enabled = this.txt_MachineName.Enabled = false; ManagementCenter.BLL.RC_TradeCommodityAssignBLL TradeCommodityAssignBLL = new RC_TradeCommodityAssignBLL(); DataSet ds = TradeCommodityAssignBLL.GetCodeListByMatchMachineID(matchMachine.MatchMachineID); InitListBox(ds, 2); DataSet dss = TradeCommodityAssignBLL.GetNotAssignCodeByBourseTypeID((int)matchMachine.BourseTypeID); InitListBox(dss, 1); } catch (Exception ex) { ShowMessageBox.ShowInformation("代码分配窗体加载失败!"); string errCode = "GL-2031"; string errMsg = "代码分配窗体加载失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); throw; } }
/// <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; } }