Esempio n. 1
0
 /// <summary>
 /// 根据撮合机得到所属的交易所类型和所属的撮合中心-即撮合机实体
 /// </summary>
 /// <returns></returns>
 public Entity.RC_MatchMachine GetMatchMachine(int MatchMachineID)
 {
     try
     {
         LogHelper.WriteDebug("Debug-8230根据撮合机得到所属的交易所类型和所属的撮合中心-即撮合机实体方法名称:GetMatchMachine(int MatchMachineID)" + DateTime.Now);
         RC_MatchMachineBLL            RC_MatchMachine     = new RC_MatchMachineBLL();
         List <Entity.RC_MatchMachine> rC_MatchMachineList =
             RC_MatchMachine.GetListArray(string.Format("MatchMachineID={0}", MatchMachineID));
         if (rC_MatchMachineList.Count > 0)
         {
             Entity.RC_MatchMachine rC_MatchMachine = rC_MatchMachineList[0];
             if (rC_MatchMachine != null)
             {
                 return(rC_MatchMachine);
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8230";
         string      errMsg  = "根据撮合机得到所属的交易所类型和所属的撮合中心-即撮合机实体失败";
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         return(null);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 根据撮合中心获取撮合机列表
 /// </summary>
 /// <param name="MatchCenterID"></param>
 /// <returns></returns>
 public List <Entity.RC_MatchMachine> GetAllMatchMachineByMatchCenter(int MatchCenterID)
 {
     try
     {
         LogHelper.WriteDebug("Debug-8229根据撮合中心获取撮合机列表方法名称:GetAllMatchMachineByMatchCenter(int MatchCenterID)" + DateTime.Now);
         RC_MatchMachineBLL RC_MatchMachine = new RC_MatchMachineBLL();
         return(RC_MatchMachine.GetListArray(string.Format("MatchCenterID={0}", MatchCenterID)));
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8229";
         string      errMsg  = "根据撮合中心获取撮合机列表失败";
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         return(null);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 获取撮合机列表
 /// </summary>
 /// <returns></returns>
 public List <Entity.RC_MatchMachine> GetAllMatchMachine()
 {
     try
     {
         LogHelper.WriteDebug("Debug-8228获取撮合机列表方法名称:GetAllMatchMachine()" + DateTime.Now);
         RC_MatchMachineBLL RC_MatchMachine = new RC_MatchMachineBLL();
         return(RC_MatchMachine.GetListArray(string.Empty));
     }
     catch (Exception ex)
     {
         string      errCode = "GL-8228";
         string      errMsg  = "获取撮合机列表失败";
         VTException vte     = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(vte.ToString(), vte.InnerException);
         return(null);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 删除按纽事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Del_Click(object sender, EventArgs e)
        {
            try
            {
                if (ShowMessageBox.ShowQuestion("确认删除吗?") == DialogResult.No)
                {
                    return;
                }
                DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi =
                    this.ViewCenter.CalcHitInfo(((Control)sender).PointToClient(Control.MousePosition));
                if (this.ViewCenter != null && this.ViewCenter.FocusedRowHandle >= 0)
                {
                    m_cutRow = this.ViewCenter.FocusedRowHandle;

                    DataRow dw            = ViewCenter.GetDataRow(m_cutRow);
                    int     MatchCenterID = int.Parse(dw["MatchCenterID"].ToString());
                    ManagementCenter.BLL.RC_MatchMachineBLL _MatchMachineBLL = new RC_MatchMachineBLL();
                    DataSet ds = _MatchMachineBLL.GetList(string.Format("MatchCenterID={0}", MatchCenterID));
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        ShowMessageBox.ShowInformation("该中心下存在撮合机,不允许删除!");
                        return;
                    }
                    MatchCenterBLL.Delete(MatchCenterID);
                    ShowMessageBox.ShowInformation("删除成功!");
                    SetTextValue(null);
                    SetControlEnAbled();
                    LoadCenterList();
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox.ShowInformation("删除失败!");
                string      errCode = "GL-2002";
                string      errMsg  = "删除失败";
                VTException vte     = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(vte.ToString(), vte.InnerException);
            }
            SetTextValue(null);
            SetControlEnAbled();
        }
        /// <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;
            }
        }