private void Initialize()
        {
            //如果不全部加载设置就在每次调用的时候再加载
            if (GetLoadConfig())
            {
                List <UA_UserAccountAllocationTableInfo> userList = userDal.GetAll();

                foreach (var user in userList)
                {
                    AddUser(user);
                }

                List <UA_UserBasicInformationTableInfo> basicUserList = basicUserDal.GetAll();
                foreach (var basicUser in basicUserList)
                {
                    basicUserCahce.Add(basicUser.UserID, basicUser);
                }
            }

            //不管以后修改是否初始化缓存都以缓存以下数据
            accountTypeLsit = bdAccountTypeDal.GetAll();
            foreach (var accountTypeInfo in accountTypeLsit)
            {
                accountTypeDic[accountTypeInfo.AccountTypeLogo] = accountTypeInfo;
            }
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="list"></param>
        protected override void InternalIntialize(List <XH_CapitalAccountTableInfo> list)
        {
            base.InternalIntialize(list);

            foreach (var capital in list)
            {
                string key = GetKey(capital.UserAccountDistributeLogo, capital.TradeCurrencyType);
                int    val = capital.CapitalAccountLogo;
                capitalIDCache.Add(key, val);
            }
        }
        public void ProcessDoOrder(OrderResponse response, HKOrderRequest request)
        {
            HKMessage message = new HKMessage();

            message.BuySell        = request.BuySell == GTA.VTS.Common.CommonObject.Types.TransactionDirection.Buying ? "买" : "卖";
            message.CapitalAccount = request.FundAccountId;
            message.Code           = request.Code;
            message.EntrustAmount  = request.OrderAmount.ToString();
            message.EntrustNumber  = response.OrderId;
            message.EntrustPrice   = request.OrderPrice.ToString();
            //message.EntrustType = request.OrderWay == TypesOrderPriceType.OPTLimited ? "限价" : "市价";
            switch (request.OrderWay)
            {
            case Types.HKPriceType.LO:
                message.EntrustType = "限价单";
                break;

            case Types.HKPriceType.ELO:
                message.EntrustType = "增强限价单";
                break;

            case Types.HKPriceType.SLO:
                message.EntrustType = "特别限价单";
                break;
            }

            message.OrderMessage = response.OrderMessage;
            message.OrderStatus  = "未报02";
            message.TradeAmount  = "0";
            message.TradeTime    = "";

            listLock.EnterWriteLock();
            try
            {
                hkMessageList.Add(message);
            }
            finally
            {
                listLock.ExitWriteLock();
            }

            if (!response.IsSuccess)
            {
                message.EntrustNumber = System.Guid.NewGuid().ToString();
                message.OrderStatus   = "废单06";
            }

            hkMessageCache.Add(message.EntrustNumber, message);

            HasChanged = true;
        }
Beispiel #4
0
        public void ProcessDoOrder(OrderResponse response, StockIndexFuturesOrderRequest request)
        {
            QHMessage message = new QHMessage();

            message.BuySell        = request.BuySell == GTA.VTS.Common.CommonObject.Types.TransactionDirection.Buying ? "买" : "卖";
            message.CapitalAccount = request.FundAccountId;
            message.Code           = request.Code;
            message.EntrustAmount  = request.OrderAmount.ToString();
            message.EntrustNumber  = response.OrderId;
            message.EntrustPrice   = request.OrderPrice.ToString();
            message.EntrustType    = request.OrderWay == TypesOrderPriceType.OPTLimited ? "限价" : "市价";
            message.OrderMessage   = response.OrderMessage;
            message.OrderStatus    = "未报02";
            message.TradeAmount    = "0";
            message.TradeTime      = "";
            message.OpenClose      = Utils.GetFutureOpenCloseType(request.OpenCloseType);

            qhMessageList.Add(message);
            if (!response.IsSuccess)
            {
                message.EntrustNumber = Guid.NewGuid().ToString();
                message.OrderStatus   = "废单06";
            }

            qhMessageCache.Add(message.EntrustNumber, message);

            HasChanged = true;
        }
        /// <summary>
        /// 添加一个持仓id映射
        /// </summary>
        /// <param name="hold"></param>
        private bool AddHoldID(XH_AccountHoldTableInfo hold)
        {
            string key = GetKey(hold.UserAccountDistributeLogo, hold.Code, hold.CurrencyTypeId);
            int    val = hold.AccountHoldLogoId;

            if (holdIDCache.Contains(key))
            {
                return(false);
            }

            holdIDCache.Add(key, val);

            string account = hold.UserAccountDistributeLogo;
            int    id      = hold.AccountHoldLogoId;

            if (holdAccountCache.Contains(account))
            {
                SyncList <int> idList = holdAccountCache.Get(account);
                idList.Add(id);
            }
            else
            {
                SyncList <int> idList = new SyncList <int>();
                idList.Add(id);
                holdAccountCache.Add(account, idList);
            }

            return(true);
        }
        /// <summary>
        /// Create By:李健华
        /// Create Date:2009-08-12
        /// Title:更新缓存表中的数据用户账号状态
        /// Desc.:因为用户账户信息主要有的是解冻和冻结状态的改变所以这里的更新方法主要是对
        ///       解冻和冻结的更新
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="accountType">账号类型</param>
        /// <param name="state">状态</param>
        public void UpdateUser(string userID, int accountType, bool state)
        {
            UA_UserAccountAllocationTableInfo ua = GetAccountByUserIDAndAccountType(userID, accountType);

            if (ua != null)
            {
                ua.WhetherAvailable = state;
                accountCache.Delete(ua.UserAccountDistributeLogo);
                accountCache.Add(ua.UserAccountDistributeLogo, ua);
            }
            if (userCache.Contains(userID))
            {
                var accountList = userCache.Get(userID).GetAll();
                foreach (var item in accountList)
                {
                    if (item.AccountTypeLogo == accountType)
                    {
                        item.WhetherAvailable = state;
                    }
                }
            }
        }
        /// <summary>
        /// 向缓存数据添加一条用户账号信息记录
        /// </summary>
        /// <param name="user">要添加的用户账号实体</param>
        public void AddUser(UA_UserAccountAllocationTableInfo user)
        {
            try
            {
                if (!accountCache.Contains(user.UserAccountDistributeLogo))
                {
                    accountCache.Add(user.UserAccountDistributeLogo, user);
                    LogHelper.WriteDebug("添加一条账号信息记录当前用户ID:" + user.UserID + " 添加账号:" + user.UserAccountDistributeLogo + " 账号列表数:" + accountCache.GetAll().Count);
                }

                SyncList <UA_UserAccountAllocationTableInfo> accountList = null;
                if (userCache.Contains(user.UserID))
                {
                    accountList = userCache.Get(user.UserID);
                }
                else
                {
                    accountList = new SyncList <UA_UserAccountAllocationTableInfo>();
                    userCache.Add(user.UserID, accountList);
                    LogHelper.WriteDebug("【第一次】添加一条【用户拥有账号记录】ID:" + user.UserID + " 添加账号:" + user.UserAccountDistributeLogo + "  账号类型: " + user.AccountTypeLogo + " 账号列表数:" + accountList.GetAll().Count);
                }
                //如果存在不再添加  这样判断好象有问题用forearch
                //if (!accountList.Contains(user))
                //{
                bool isAdd = true;
                List <UA_UserAccountAllocationTableInfo> models = accountList.GetAll();
                foreach (var item in accountList.GetAll())
                {
                    if (item.AccountTypeLogo == user.AccountTypeLogo &&
                        item.UserAccountDistributeLogo == user.UserAccountDistributeLogo &&
                        item.UserID == user.UserID)
                    {
                        isAdd = false;
                        break;
                    }
                }
                if (isAdd)
                {
                    accountList.Add(user);
                    LogHelper.WriteDebug("添加一条【用户拥有账号记录】ID:" + user.UserID + " 添加账号:" + user.UserAccountDistributeLogo + "  账号类型: " + user.AccountTypeLogo + " 账号列表数:" + accountList.GetAll().Count);
                }
                //}
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("向缓存数据添加一条用户账号信息记录异常" + ex.Message, ex);
            }
        }
        /// <summary>
        /// 缓存要自动撤单的列表
        /// </summary>
        /// <param name="entrustNumber">委托单号</param>
        /// <param name="value">委托单时间</param>
        public void AddAutoCanceOrder(string entrustNumber, DateTime value)
        {
            if (string.IsNullOrEmpty(entrustNumber))
            {
                return;
            }

            if (autoCanceOrder.Contains(entrustNumber))
            {
                return;
            }
            AutoCanceEntry item = new AutoCanceEntry();

            item.EntrustNumber = entrustNumber;
            item.OrderTime     = value;
            autoCanceOrder.Add(entrustNumber, item);
        }
 /// <summary>
 /// 添加类型3改单委托到缓存中
 /// </summary>
 /// <param name="request"></param>
 private void AddType3Reqest(HKModifyOrderRequest request)
 {
     type3Cache.Add(request.EntrustNubmer, request);
 }
 /// <summary>
 /// 添加类型2改单委托到缓存中
 /// </summary>
 /// <param name="request"></param>
 public void AddType2Reqest(HKModifyOrderRequest request)
 {
     type2Cache.Add(request.EntrustNubmer, request);
 }