public void GetMatchMachinebyCommodityTest() { CommonParaService target = new CommonParaService(); // TODO: Initialize to an appropriate value string CommodityCode = "000001"; // TODO: Initialize to an appropriate value RC_MatchMachine expected = null; // TODO: Initialize to an appropriate value RC_MatchMachine actual; actual = target.GetMatchMachinebyCommodity(CommodityCode); Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); }
/// <summary> /// 代码分配 /// </summary> /// <param name="MachineNO">撮合机个数</param> /// <param name="BourseTypeID">交易所标识ID</param> /// <param name="MatchCenterID">撮合中心ID</param> /// <param name="Tran">事务</param> /// <param name="db">数据库</param> /// <returns></returns> private bool AssignCode(int MachineNO, int BourseTypeID, int MatchCenterID, DbTransaction Tran, Database db) { RC_MatchMachineDAL MatchMachineDAL = new RC_MatchMachineDAL(); RC_TradeCommodityAssignDAL TradeCommodityAssignDAL = new RC_TradeCommodityAssignDAL(); try { RC_MatchMachine MatchMachine; RC_TradeCommodityAssign TradeCommodityAssign; DataSet ds = TradeCommodityAssignDAL.GetCodeListByBourseTypeID(BourseTypeID); int CodeNum = ds.Tables[0].Rows.Count; int M_C_Num = (int)CodeNum / MachineNO; for (int i = 1; i <= MachineNO; i++) { MatchMachine = new RC_MatchMachine(); MatchMachine.BourseTypeID = BourseTypeID; MatchMachine.MatchCenterID = MatchCenterID; int MachineID = MatchMachineDAL.Add(MatchMachine, Tran, db); int start, end; if (i < MachineNO) { start = (i - 1) * M_C_Num; end = i * M_C_Num; } else { start = (i - 1) * M_C_Num; end = CodeNum; } for (int j = start; j < end; j++) { TradeCommodityAssign = new RC_TradeCommodityAssign(); TradeCommodityAssign.CommodityCode = ds.Tables[0].Rows[j]["CommodityCode"].ToString(); TradeCommodityAssign.MatchMachineID = MachineID; //代码来源那个表:1是CM_Commodity表;2:是HK_Commodity表 TradeCommodityAssign.CodeFormSource = Convert.ToInt32(ds.Tables[0].Rows[j]["CodeFormSource"].ToString()); TradeCommodityAssignDAL.Add(TradeCommodityAssign, Tran, db); } } return(true); } catch (Exception ex) { string errCode = "GL-2202"; string errMsg = "代码分配失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); return(false); } }
/// <summary> /// 确定按纽事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_OK_Click(object sender, EventArgs e) { try { RC_MatchMachine rcMatchMachine = GetMatchMachine(); if (rcMatchMachine != null) { if (edit == 1) { int i = MatchMachineBLL.Add(GetMatchMachine()); if (i > 0) { ShowMessageBox.ShowInformation("添加成功!"); this.btn_Add.Text = "添加"; this.btn_Modify.Text = "修改"; edit = 0; SetMatchMachine(null); SetControlEnAbled(); Init(); return; } ShowMessageBox.ShowInformation("添加失败!"); } else if (edit == 2) { MatchMachineBLL.Update(GetMatchMachine()); ShowMessageBox.ShowInformation("修改成功!"); this.btn_Add.Text = "添加"; this.btn_Modify.Text = "修改"; edit = 0; SetMatchMachine(null); SetControlEnAbled(); Init(); return; } } } catch (Exception ex) { ShowMessageBox.ShowInformation("保存失败!"); string errCode = "GL-2021"; string errMsg = "保存失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); } }
/// <summary> /// 表格单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridCenter_Click(object sender, EventArgs e) { DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi = this.ViewMachine.CalcHitInfo(((Control)sender).PointToClient(Control.MousePosition)); if (this.ViewMachine != null && this.ViewMachine.FocusedRowHandle >= 0 && hi.RowHandle >= 0) { m_cutRow = this.ViewMachine.FocusedRowHandle; DataRow dw = ViewMachine.GetDataRow(m_cutRow); int MatchMachineID = int.Parse(dw["MatchMachineID"].ToString()); MatchMachine = MatchMachineBLL.GetModel(MatchMachineID); SetMatchMachine(MatchMachine); } //else //{ // ShowMessageBox.ShowInformation("请选中记录行"); //} }
/// <summary> /// 得到凑合机实体 /// </summary> /// <returns></returns> public RC_MatchMachine GetMatchMachine() { if (MatchMachine == null) { MatchMachine = new RC_MatchMachine(); } MatchMachine.BourseTypeID = ((UComboItem)ddl_BourseType.SelectedItem).ValueIndex; MatchMachine.MatchCenterID = ((UComboItem)ddl_Center.SelectedItem).ValueIndex; MatchMachine.MatchMachineID = Convert.ToInt32(this.txt_MachineID.Text); if (!string.IsNullOrEmpty(this.txt_MachineName.Text)) { MatchMachine.MatchMachineName = this.txt_MachineName.Text; } else { ShowMessageBox.ShowInformation("请填写撮合机名称!"); return(null); } return(MatchMachine); }
/// <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; } }