Beispiel #1
0
        /// <summary>
        /// 获取持仓内存表,如果内存中不存在,那么再到数据库查找
        /// </summary>
        /// <param name="accountHoldLogoId">持仓id</param>
        /// <returns></returns>
        public static HKHoldMemoryTable GetHoldMemoryTable(int accountHoldLogoId)
        {
            HKHoldMemoryTable holdMemory = null;

            try
            {
                holdMemory = MemoryDataManager.HKHoldMemoryList.GetByAccountHoldLogoId(accountHoldLogoId);
                //如果持仓为空,那么先从数据库加载,看是不是内存表没有加载
                if (holdMemory == null)
                {
                    HK_AccountHoldDal dal = new HK_AccountHoldDal();
                    var hold = dal.GetModel(accountHoldLogoId);
                    //如果数据库有,那么直接加载到内存表中
                    if (hold != null)
                    {
                        MemoryDataManager.HKHoldMemoryList.AddAccountHoldTableToMemory(hold);
                    }
                    else
                    {
                        //如果数据库也没有,那么代表无持仓
                        return(null);
                    }

                    holdMemory = MemoryDataManager.HKHoldMemoryList.GetByAccountHoldLogoId(accountHoldLogoId);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("HKCommonLogic.GetHoldMemoryTable-" + ex.Message, ex);
            }

            return(holdMemory);
        }
Beispiel #2
0
        /// <summary>
        /// 新增港股持仓
        /// </summary>
        /// <param name="baseTable"></param>
        /// <returns></returns>
        public bool InsertBaseTable(HK_AccountHoldInfo baseTable)
        {
            HK_AccountHoldDal dal = new HK_AccountHoldDal();
            var hold = dal.GetHKAccountHoldInfo(baseTable.UserAccountDistributeLogo, baseTable.Code,
                                                baseTable.CurrencyTypeID);

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

            int id = dal.Add(baseTable);

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

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

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

            return(holdMemory);
        }
Beispiel #4
0
        /// <summary>
        /// 更新数据库改变量
        /// </summary>
        /// <param name="delta"></param>
        public void PersistChange(HK_AccountHoldInfo_Delta delta)
        {
            HK_AccountHoldDal dal = new HK_AccountHoldDal();

            dal.AddUpdate(delta);
        }
Beispiel #5
0
        /// <summary>
        /// 删除持仓记录
        /// </summary>
        /// <param name="baseTable"></param>
        public void DeleteBaseTable(HK_AccountHoldInfo baseTable)
        {
            HK_AccountHoldDal dal = new HK_AccountHoldDal();

            dal.Delete(baseTable.AccountHoldLogoID);
        }
Beispiel #6
0
        /// <summary>
        /// 获取指定Id的公共持仓实体
        /// </summary>
        /// <param name="k"></param>
        /// <returns></returns>
        public HK_AccountHoldInfo GetBaseTable(int k)
        {
            HK_AccountHoldDal dal = new HK_AccountHoldDal();

            return(dal.GetModel(k));
        }
Beispiel #7
0
        /// <summary>
        /// 获取全部港股持仓实体
        /// </summary>
        /// <returns></returns>
        public List <HK_AccountHoldInfo> GetAllBaseTable()
        {
            HK_AccountHoldDal dal = new HK_AccountHoldDal();

            return(dal.GetAllListArray());
        }
Beispiel #8
0
        /// <summary>
        /// 带事务更新数据库
        /// </summary>
        /// <param name="delta">数据库变化对象</param>
        /// <param name="db">数据库对象</param>
        /// <param name="transaction">事务对象</param>
        public void PersistChangeWithTransaction(HK_AccountHoldInfo_Delta delta, Database db, DbTransaction transaction)
        {
            HK_AccountHoldDal dal = new HK_AccountHoldDal();

            dal.AddUpdate(delta, db, transaction);
        }
Beispiel #9
0
        /// <summary>
        /// 更新数据库持仓
        /// </summary>
        /// <param name="baseTable">港股持仓实体</param>
        /// <param name="db">数据库对象</param>
        /// <param name="transaction">事务对象</param>
        public void PersistBase(HK_AccountHoldInfo baseTable, Database db, DbTransaction transaction)
        {
            HK_AccountHoldDal dal = new HK_AccountHoldDal();

            dal.Update(baseTable, db, transaction);
        }
Beispiel #10
0
        /// <summary>
        /// 更新数据库持仓
        /// </summary>
        /// <param name="baseTable"></param>
        public void PersistBase(HK_AccountHoldInfo baseTable)
        {
            HK_AccountHoldDal dal = new HK_AccountHoldDal();

            dal.Update(baseTable);
        }