Exemple #1
0
        /// <summary>
        /// 插入持仓记录
        /// </summary>
        /// <param name="baseTable"></param>
        /// <returns></returns>
        public bool InsertBaseTable(XH_AccountHoldTableInfo baseTable)
        {
            XH_AccountHoldTableDal dal = new XH_AccountHoldTableDal();
            var hold = dal.GetXhAccountHoldTable(baseTable.UserAccountDistributeLogo, baseTable.Code,
                                                 baseTable.CurrencyTypeId);

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

            int id = dal.Add(baseTable);

            baseTable.AccountHoldLogoId = id;
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// 获取持仓内存表,如果内存中不存在,那么再到数据库查找
        /// </summary>
        /// <param name="holdAccount">持仓账户</param>
        /// <param name="code">代码</param>
        /// <param name="tradeCurrencyType">币种</param>
        /// <returns>内存表</returns>
        public static XHHoldMemoryTable GetHoldMemoryTable(string holdAccount, string code, int tradeCurrencyType)
        {
            XHHoldMemoryTable holdMemory = null;

            try
            {
                holdMemory = MemoryDataManager.XHHoldMemoryList.GetByHoldAccountAndCurrencyType(holdAccount, code,
                                                                                                tradeCurrencyType);
                //holdMemory = MemoryDataManager.XHHoldMemoryList.GetByAccountHoldLogoId(HoldingAccountId);
                //如果持仓为空,那么先从数据库加载,看是不是内存表没有加载
                if (holdMemory == null)
                {
                    XH_AccountHoldTableDal dal = new XH_AccountHoldTableDal();
                    var hold = dal.GetXhAccountHoldTable(holdAccount, code, tradeCurrencyType);
                    //如果数据库有,那么直接加载到内存表中
                    if (hold != null)
                    {
                        MemoryDataManager.XHHoldMemoryList.AddXHAccountHoldTableToMemory(hold);
                    }
                    else
                    {
                        //如果数据库也没有,那么代表无持仓
                        return(null);
                    }

                    holdMemory = MemoryDataManager.XHHoldMemoryList.GetByHoldAccountAndCurrencyType(holdAccount, code,
                                                                                                    tradeCurrencyType);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("XHCommonLogic.GetHoldMemoryTable-" + ex.Message, ex);
            }

            return(holdMemory);
        }