public void ProcessPushBack(FutureDealOrderPushBack drsifi) { var tet = drsifi.StockIndexFuturesOrde; var deals = drsifi.FutureDealList; string entrustNumber = tet.EntrustNumber; if (!qhMessageCache.Contains(entrustNumber)) { LogHelper.WriteDebug("委托" + entrustNumber + "不存在缓存中"); return; } var message = qhMessageCache.Get(entrustNumber); message.EntrustAmount = tet.EntrustAmount.ToString(); message.TradeAmount = tet.TradeAmount.ToString(); message.CancelAmount = tet.CancelAmount.ToString(); message.OrderMessage = tet.OrderMessage; message.OrderStatus = Utils.GetOrderStateMsg(tet.OrderStatusId); if (deals.Count > 0) { message.TradeTime = deals[deals.Count - 1].TradeTime.ToString(); } 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> /// 获取资金表ID /// </summary> /// <param name="capitalAccount"></param> /// <param name="tradeCurrencyType"></param> /// <returns></returns> public int GetCapitalAccountLogo(string capitalAccount, int tradeCurrencyType) { string key = GetKey(capitalAccount, tradeCurrencyType); if (capitalIDCache.Contains(key)) { return(capitalIDCache.Get(key)); } #region add 2010-06-07 李健华 else { bool isAdd = false; //从数据库中获取再添加(同步到内存中) XH_CapitalAccountTableInfo model = persister.GetBaseFromDBByWhere(key); if (model != null) { isAdd = AddXHCapitalTableToMemory(model); } //不管添加是否成功都获取一次,因为有可能在添加的过程中有线程冲突 //if (isAdd) //{ if (capitalIDCache.Contains(key)) { return(capitalIDCache.Get(key)); } //} } #endregion return(-1); }
/// <summary> /// 向缓存数据添加一条用户基本信息记录 /// </summary> /// <param name="userBasicInfo">要添加的用户基本信息实体</param> public void AddUserBasicInfo(UA_UserBasicInformationTableInfo userBasicInfo) { #region old code update 2009-11-25 李健华 ////object obj = new object(); ////lock (obj) ////{ //if (basicUserCahce.Contains(userBasicInfo.UserID)) //{ // basicUserCahce.Add(userBasicInfo.UserID, userBasicInfo); // basicUserList.Add(userBasicInfo); //} ////} #endregion if (basicUserCahce.Contains(userBasicInfo.UserID)) { basicUserCahce.Delete(userBasicInfo.UserID); //basicUserList.Remove(userBasicInfo); basicUserCahce.Add(userBasicInfo.UserID, userBasicInfo); //basicUserList.Add(userBasicInfo); } else { basicUserCahce.Add(userBasicInfo.UserID, userBasicInfo); //basicUserList.Add(userBasicInfo); } }
/// <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); } }
public void ProcessPushBack(HKDealOrderPushBack drsip) { var tet = drsip.HKOrderEntity; var deals = drsip.HKDealList; string entrustNumber = tet.EntrustNumber; //因为Type3的改单的改单回报有可能比这个pushback要迟,所以稍微延迟一下 //进行多次查找 bool canFind = false; for (int i = 0; i < 3; i++) { if (hkMessageCache.Contains(entrustNumber)) { canFind = true; break; } Thread.Sleep(1000); } if (!canFind) { if (!hkMessageCache.Contains(entrustNumber)) { LogHelper.WriteDebug("委托" + entrustNumber + "不存在缓存中"); return; } } var message = hkMessageCache.Get(entrustNumber); message.EntrustAmount = tet.EntrustAmount.ToString(); message.TradeAmount = tet.TradeAmount.ToString(); message.CancelAmount = tet.CancelAmount.ToString(); message.OrderMessage = tet.OrderMessage; message.OrderStatus = Utils.GetOrderStateMsg(tet.OrderStatusId); if (deals.Count > 0) { message.TradeTime = deals[deals.Count - 1].TradeTime.ToString(); } HasChanged = true; }
/// <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="entrustNumber"></param> /// <param name="request"></param> /// <returns></returns> public bool IsExistType3Request(string entrustNumber, out HKModifyOrderRequest request) { request = null; if (type3Cache.Contains(entrustNumber)) { request = type3Cache.Get(entrustNumber); return(true); } return(false); }
/// <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; } } } }