示例#1
0
        /// <summary>
        /// 插入记录
        /// </summary>
        /// <param name="baseTable"></param>
        /// <returns></returns>
        public bool InsertBaseTable(QH_HoldAccountTableInfo baseTable)
        {
            QH_HoldAccountTableDal dal = new QH_HoldAccountTableDal();
            var hold = dal.GetQhAccountHoldTable(baseTable.UserAccountDistributeLogo, baseTable.Contract,
                                                 baseTable.TradeCurrencyType, baseTable.BuySellTypeId);

            if (hold != null)
            {
                return(false);
            }

            int id = dal.Add(baseTable);

            baseTable.AccountHoldLogoId = id;
            return(true);
        }
示例#2
0
        /// <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);
        }