/// <summary> /// 根据品种获取最后交易日实体 /// </summary> /// <param name="breedclass"></param> /// <returns></returns> public QH_LastTradingDay GetLastTradingDayEntity(int breedclass) { QH_FuturesTradeRulesDAL FuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); QH_LastTradingDayDAL LastTradingDayDAL = new QH_LastTradingDayDAL(); QH_FuturesTradeRules FuturesTradeRules = FuturesTradeRulesDAL.GetModel(breedclass); QH_LastTradingDay LastTradingDay = LastTradingDayDAL.GetModel((int)FuturesTradeRules.LastTradingDayID); return(LastTradingDay); }
/// <summary> /// 得到期货前缀代号 /// </summary> /// <param name="BreedClassID"></param> /// <returns></returns> public string GetQH_PrefixCodeByID(int BreedClassID) { QH_FuturesTradeRulesDAL FuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); QH_FuturesTradeRules FuturesTradeRules = FuturesTradeRulesDAL.GetModel(BreedClassID); if (FuturesTradeRules == null) { return(string.Empty); } return(FuturesTradeRules.FutruesCode); }
/// <summary> /// 更新期货交易规则 /// </summary> /// <param name="model">期货_品种_交易规则实体</param> /// <returns></returns> public bool UpdateFuturesTradeRules(ManagementCenter.Model.QH_FuturesTradeRules model) { try { QH_FuturesTradeRulesDAL qHFuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); return(qH_FuturesTradeRulesDAL.Update(model)); } catch (Exception ex) { string errCode = "GL-6002"; string errMsg = "更新期货交易规则失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(false); } }
/// <summary> /// 根据品种ID,判断期货交易规则是否已存在 /// </summary> /// <param name="BreedClassID">品种ID</param> /// <returns></returns> public bool ExistsFuturesTradeRules(int BreedClassID) { try { QH_FuturesTradeRulesDAL qHFuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); return(qHFuturesTradeRulesDAL.Exists(BreedClassID)); } catch (Exception ex) { string errCode = "GL-6000"; string errMsg = "根据品种ID,判断期货交易规则是否已存在失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(false); } }
/// <summary> /// 根据期货_品种_交易规则表中的品种标识获取品种名称 /// </summary> /// <returns></returns> public DataSet GetQHBreedClassNameByBreedClassID() { try { QH_FuturesTradeRulesDAL qHFuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); return(qH_FuturesTradeRulesDAL.GetQHBreedClassNameByBreedClassID()); } catch (Exception ex) { string errCode = "GL-6008"; string errMsg = "根据期货_品种_交易规则表中的品种标识获取品种名称失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(null); } }
/// <summary> /// 根据品种ID,获取期货交易规则对象实体 /// </summary> /// <param name="BreedClassID"></param> /// <returns></returns> public ManagementCenter.Model.QH_FuturesTradeRules GetFuturesTradeRulesModel(int BreedClassID) { try { QH_FuturesTradeRulesDAL qHFuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); return(qHFuturesTradeRulesDAL.GetModel(BreedClassID)); } catch (Exception ex) { string errCode = "GL-6005"; string errMsg = " 根据品种ID,获取期货交易规则对象实体失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(null); } }
/// <summary> /// 删除期货_品种_交易规则 /// </summary> /// <param name="BreedClassID">品种标识</param> public bool DeleteFuturesTradeRules(int BreedClassID) { try { QH_FuturesTradeRulesDAL qHFuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); return(qH_FuturesTradeRulesDAL.Delete(BreedClassID)); } catch (Exception ex) { string errCode = "GL-6003"; string errMsg = "删除期货_品种_交易规则失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(false); } }
/// <summary> /// 获取所有期货_品种_交易规则 /// </summary> /// <param name="BreedClassName">品种名称</param> /// <param name="pageNo">当前页</param> /// <param name="pageSize">显示记录数</param> /// <param name="rowCount">总行数</param> /// <returns></returns> public DataSet GetAllFuturesTradeRules(string BreedClassName, int pageNo, int pageSize, out int rowCount) { try { QH_FuturesTradeRulesDAL qHFuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); return(qH_FuturesTradeRulesDAL.GetAllFuturesTradeRules(BreedClassName, pageNo, pageSize, out rowCount)); } catch (Exception ex) { rowCount = AppGlobalVariable.INIT_INT; string errCode = "GL-6007"; string errMsg = "获取所有期货_品种_交易规则失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(null); } }
/// <summary> ///根据品种标识,删除期货品种交易规则(规则相关表全部删除) /// </summary> /// <param name="BreedClassID">品种标识</param> /// <returns></returns> public bool DeleteFuturesTradeRulesAboutAll(int BreedClassID) { QH_FuturesTradeRulesDAL qHFuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); QH_AgreementDeliveryMonthDAL qH_AgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL(); QH_ConsignQuantumDAL qH_ConsignQuantumDAL = new QH_ConsignQuantumDAL(); QH_SingleRequestQuantityDAL qH_SingleRequestQuantityDAL = new QH_SingleRequestQuantityDAL(); QH_LastTradingDayDAL qH_LastTradingDayDAL = new QH_LastTradingDayDAL(); DbConnection Conn = null; Database db = DatabaseFactory.CreateDatabase(); Conn = db.CreateConnection(); if (Conn.State != ConnectionState.Open) { Conn.Open(); } DbTransaction Tran = Conn.BeginTransaction(); try { int ConsignQuantumID = AppGlobalVariable.INIT_INT; int LastTradingDayID = AppGlobalVariable.INIT_INT; QH_FuturesTradeRules qHFuturesTradeRules = new QH_FuturesTradeRules(); qHFuturesTradeRules = qHFuturesTradeRulesDAL.GetModel(BreedClassID); if (qHFuturesTradeRules != null) { if (!string.IsNullOrEmpty(qHFuturesTradeRules.ConsignQuantumID.ToString())) { ConsignQuantumID = Convert.ToInt32(qHFuturesTradeRules.ConsignQuantumID); } if (!string.IsNullOrEmpty(qHFuturesTradeRules.LastTradingDayID.ToString())) { LastTradingDayID = Convert.ToInt32(qHFuturesTradeRules.LastTradingDayID); } if (ConsignQuantumID != AppGlobalVariable.INIT_INT) { if (!qH_SingleRequestQuantityDAL.DeleteSingleRQByConsignQuantumID(ConsignQuantumID, Tran, db)) { Tran.Rollback(); return(false); } } List <Model.QH_AgreementDeliveryMonth> qHAgreementDeliveryM = qH_AgreementDeliveryMonthDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID), Tran, db); foreach (Model.QH_AgreementDeliveryMonth MonthID in qHAgreementDeliveryM) { if (!qH_AgreementDeliveryMonthDAL.Delete((Int32)MonthID.MonthID, BreedClassID)) //?处理 { Tran.Rollback(); return(false); } } if (!qHFuturesTradeRulesDAL.Delete(BreedClassID, Tran, db)) { Tran.Rollback(); return(false); } if (ConsignQuantumID != AppGlobalVariable.INIT_INT) { if (!qH_ConsignQuantumDAL.Delete(ConsignQuantumID, Tran, db)) { Tran.Rollback(); return(false); } } if (LastTradingDayID != AppGlobalVariable.INIT_INT) { if (!qH_LastTradingDayDAL.Delete(LastTradingDayID, Tran, db)) { Tran.Rollback(); return(false); } } } Tran.Commit(); return(true); } catch (Exception ex) { Tran.Rollback(); string errCode = "GL-6004"; string errMsg = " 根据品种标识,删除期货品种交易规则(规则相关表全部删除)失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return(false); } finally { if (Conn.State == ConnectionState.Open) { Conn.Close(); } } }
/// <summary> /// 检测期货代码是否到期 /// </summary> public void CheckCodeIsExpired() { try { QH_AgreementDeliveryMonthDAL AgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL(); //一般品种,交割月为1~12月份 QH_FuturesTradeRulesDAL FuturesTradeRulesDAL = new QH_FuturesTradeRulesDAL(); //获取交易规则 List <QH_FuturesTradeRules> L = FuturesTradeRulesDAL.GetListArray(string.Empty); if (L != null) { foreach (QH_FuturesTradeRules FuturesTradeRules in L) { #region old //List<QH_AgreementDeliveryMonth> listQHAgreDeMonth = AgreementDeliveryMonthDAL.GetListArray(string.Format("BreedClassID={0}", FuturesTradeRules.BreedClassID)); //foreach (QH_AgreementDeliveryMonth AgreementDeliveryMonth in listQHAgreDeMonth) //{ // if ((int)AgreementDeliveryMonth.MonthID != 13) // { // Production(FuturesTradeRules.BreedClassID); // } //} #endregion //交割月份要么等于13,要么不等于,因此不需循环,造成重复执行多遍 //update by 董鹏 2010-03-31 //获取交易规则中的交割月份 List <QH_AgreementDeliveryMonth> listQHAgreDeMonth = AgreementDeliveryMonthDAL.GetListArray(string.Format("BreedClassID={0} and MonthID!={1}", FuturesTradeRules.BreedClassID, 13)); if (listQHAgreDeMonth.Count != 0) { Production(FuturesTradeRules.BreedClassID); } } } else { LogHelper.WriteDebug("期货交易规则数据为空"); } #region old ////特殊处理,本月下月随后的两个季度月份 ////QH_AgreementDeliveryMonthDAL AgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL(); //List<QH_AgreementDeliveryMonth> L_m = AgreementDeliveryMonthDAL.GetListArray(string.Empty); //if (L_m != null) //{ // foreach (QH_AgreementDeliveryMonth AgreementDeliveryMonth in L_m) // { // if ((int)AgreementDeliveryMonth.MonthID == 13) // { // QH_LastTradingDay LastTradingDayEntity = // GetLastTradingDayEntity((int)AgreementDeliveryMonth.BreedClassID); // if (System.DateTime.Now.Day == // GetLastTradingDay(LastTradingDayEntity, (int)AgreementDeliveryMonth.BreedClassID)) // { // SpecialQHCodeUpdate((int)AgreementDeliveryMonth.BreedClassID); // } // } // } //} //else //{ // LogHelper.WriteDebug("期货合约交割月份数据为空"); //} #endregion //update by 董鹏 2010-03-31 //特殊处理,本月下月随后的两个季度月份 //QH_AgreementDeliveryMonthDAL AgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL(); List <QH_AgreementDeliveryMonth> L_m = AgreementDeliveryMonthDAL.GetListArray(string.Format("MonthID={0}", 13)); if (L_m != null) { foreach (QH_AgreementDeliveryMonth AgreementDeliveryMonth in L_m) { QH_LastTradingDay LastTradingDayEntity = GetLastTradingDayEntity((int)AgreementDeliveryMonth.BreedClassID); if (System.DateTime.Now.Day == GetLastTradingDay(LastTradingDayEntity, (int)AgreementDeliveryMonth.BreedClassID)) { SpecialQHCodeUpdate((int)AgreementDeliveryMonth.BreedClassID); } } } else { LogHelper.WriteDebug("期货合约交割月份数据为空"); } } catch (Exception ex) { string errCode = "GL-7000"; string errMsg = "更新期货和约代码失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); } }