/// <summary> /// 获取持仓内存表,如果内存中不存在,那么再到数据库查找 /// </summary> /// <param name="accountHoldLogoId">持仓id</param> /// <returns></returns> public static QHHoldMemoryTable GetHoldMemoryTable(int accountHoldLogoId) { QHHoldMemoryTable holdMemory = null; try { holdMemory = MemoryDataManager.QHHoldMemoryList.GetByAccountHoldLogoId(accountHoldLogoId); //如果持仓为空,那么先从数据库加载,看是不是内存表没有加载 if (holdMemory == null) { QH_HoldAccountTableDal dal = new QH_HoldAccountTableDal(); var hold = dal.GetModel(accountHoldLogoId); //如果数据库有,那么直接加载到内存表中 if (hold != null) { MemoryDataManager.QHHoldMemoryList.AddQHHoldAccountTableToMemeory(hold); } else { //如果数据库也没有,那么代表无持仓 return(null); } holdMemory = MemoryDataManager.QHHoldMemoryList.GetByAccountHoldLogoId(accountHoldLogoId); } } catch (Exception ex) { LogHelper.WriteError("QHCommonLogic.GetHoldMemoryTable-" + ex.Message, ex); } return(holdMemory); }
/// <summary> /// 获取持仓内存表,如果内存中不存在,那么再到数据库查找 /// </summary> /// <param name="holdAccount">持仓账户</param> /// <param name="code">代码</param> /// <param name="tradeCurrencyType">币种</param> /// <param name="buySellType">买卖方向</param> /// <returns>内存表</returns> public static QHHoldMemoryTable GetHoldMemoryTable(string holdAccount, string code, int tradeCurrencyType, int buySellType) { QHHoldMemoryTable holdMemory = null; try { holdMemory = MemoryDataManager.QHHoldMemoryList.GetByHoldAccountAndCurrencyType(holdAccount, code, buySellType, tradeCurrencyType); //如果持仓为空,那么先从数据库加载,看是不是内存表没有加载 if (holdMemory == null) { QH_HoldAccountTableDal dal = new QH_HoldAccountTableDal(); var hold = dal.GetQhAccountHoldTable(holdAccount, code, tradeCurrencyType, buySellType); //如果数据库有,那么直接加载到内存表中 if (hold != null) { MemoryDataManager.QHHoldMemoryList.AddQHHoldAccountTableToMemeory(hold); } else { //如果数据库也没有,那么代表无持仓 return(null); } holdMemory = MemoryDataManager.QHHoldMemoryList.GetByHoldAccountAndCurrencyType(holdAccount, code, buySellType, tradeCurrencyType); } } catch (Exception ex) { LogHelper.WriteError("QHCommonLogic.GetHoldMemoryTable-" + ex.Message, ex); } return(holdMemory); }