protected void Initi(ConcurrentDictionary <int, BaseUser> _pos2user, int minnum, int maxnum, int gameid, BaseSendDataServer _bsds, TimerCallback callback) { lock (objLock) { _tablRecord = new tb_tablerecord(); Interlocked.Exchange(ref _userTokenPos, 0); MoneyRecordList = new ConcurrentQueue <MoneyRecord>(); //记录 DateTime tempDT = DateTime.Now; _tableMathCode = ToolsEx.GetRoomEnterSixID(); _guid = Guid.NewGuid().ToString("N"); _haveCheckRoomCard = false; _applyExitTable = false; _pos2userbase = _pos2user; _num_max = maxnum; _num_min = minnum; _gameid = gameid; _tablestatus = TableStatusEnum.Initi; _bsDataServer = _bsds; ForeashAllDoBase((i) => { _pos2userbase[i]._WaitSecond = _TurnWaitTime; //20 }); _tableSendData.Clear(); _tableEnterSendData.Clear(); } }
/// <summary> /// 写入一桌的金钱交易记录,每个人一条 /// </summary> protected void LogWriteToDB(tb_tablerecord tr) { BLL_Record bll = new BLL_Record(); BLL_MoneyLog money = new BLL_MoneyLog(); //var cacheSet = new ShareCacheStruct<tb_tablerecord>(); bll.Add(tr); //cacheSet.Add(tr); var cacheSetmoneylog = new ShareCacheStruct <tb_TableMoneyLog>(); try { ForeashAllDoBase((i) => { tb_TableMoneyLog _moneylogtemp = new tb_TableMoneyLog(); if (_pos2Money.ContainsKey(i)) { _moneylogtemp.AddorReduceMoney = _pos2Money[i]; } if (_pos2Win.ContainsKey(i)) { _moneylogtemp._win = _pos2Win[i]; } _moneylogtemp.gameid = _gameid; _moneylogtemp.MatchCode = tr.MatchCode; _moneylogtemp._guid = tr._guid; _moneylogtemp.TableRecordID = tr.id; if (_pos2UserID.ContainsKey(i)) { _moneylogtemp.UserID = _pos2UserID[i]; } if (_pos2IPPort.ContainsKey(i)) { _moneylogtemp._ipport = _pos2IPPort[i]; } _moneylogtemp._pos = i; if (_pos2CardList.ContainsKey(i)) { _moneylogtemp._cardList = _pos2CardList[i]; } _moneylogtemp._isover = tr._isover; if (_pos2BullRate.ContainsKey(i)) { _moneylogtemp._bullrate = _pos2BullRate[i]; } if (_pos2Watch.ContainsKey(i)) { _moneylogtemp._isWatch = _pos2Watch[i]; } var result = money.Add(_moneylogtemp); //直接写入数据库 待测 //cacheSetmoneylog.Add(_moneylogtemp); }); } catch (Exception ex) { } }
protected void ResetBase(bool _no_again) { if (_numpertable < _num_min) { _tablestatus = TableStatusEnum.WaitforReady; //人数不够了,,停止循环 } MoneyRecordList = new ConcurrentQueue <MoneyRecord>(); List <int> _removeKey = new List <int>(); for (int i = 1; i <= _num_max; i++) { foreach (int key in _removeKey) { if (i != key) { continue; } BaseUser _buser; _pos2userbase.TryRemove(i, out _buser); } } _numpertable -= _removeKey.Count;//看一下 下一局还有多少人在够格继续 _tablRecord = new tb_tablerecord(); ForeashAllDoBase((i) => { _pos2userbase[i].ResetBase(); }); Interlocked.Exchange(ref _userTokenPos, 0); _tableSendData.Clear(); //一局完了清理,断线后的逻辑 if (_no_again) { _tableEnterSendData.Clear(); //一局完了清理,断线后的逻辑 //// _isUsed = false; //房卡模式需要全踢 ForeashAllDoBase((i) => { if (_pos2userbase[i]._isRobot) { _bsDataServer.QueRobotUser.Reverse(); //回收机器人 //1.断开机器人的连接 _bsDataServer.QueRobotUser.Enqueue(_pos2userbase[i]._tbUser); _bsDataServer.RobotExistNumReduceOne(); } UserStatus us = BaseLobby.instanceBase.GetUserStatusbyUserID(_pos2userbase[i]._userid); if (us == null) { ErrorRecord.Record("201612052103BaseTable 必须找到的UserID: " + _pos2userbase[i]._userid); return; } us.Status = UserStatusEnum.InLobby; us.RoomID = 0; BaseLobby.instanceBase.AddorUpdateUserStatus(us); }); } }
public bool Add(tb_tablerecord model) { if (string.IsNullOrEmpty(model.id)) { model.id = Guid.NewGuid().ToString(); } var command = Provider.CreateCommandStruct("tb_tablerecord", CommandMode.Insert); command.AddParameter("id", model.id); command.AddParameter("_guid", model._guid); command.AddParameter("_isover", model._isover); command.AddParameter("MatchCode", model.MatchCode); command.AddParameter("StartTime", model.StartTime); command.AddParameter("EndTime", model.EndTime); command.AddParameter("ActionList", model.ActionList); command.AddParameter("LookCount", model.LookCount); command.AddParameter("gameid", model.gameid); command.Parser(); return(Provider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0); }
/// <summary> /// 此桌结束了,所有人 比完了, ===============喜钱,,,两种喜钱============================== /// </summary> private void DoExecuteAllEnd(bool _forceOver) { lock (objLock) { bool isEnd = false;//必须提前处理 if (GetGiveUp() >= _numpertable - 1) { isEnd = true; //一桌结束, } if (!isEnd) { return; } List <int> _wincard = new List <int>(); List <CommonPosValSD> _moneylist = new List <CommonPosValSD>();//缺的清单信息 ForeashAllDo((i) => { _moneylist.Add(new CommonPosValSD() { pos = i, val = _DicPos2User[i]._tempMoney }); if (!_DicPos2User[i]._isgiveup) { _wincard = _DicPos2User[i]._shouPaiArr; } }); //只有最后一家才有收喜钱,,,还有一种规则是直接看牌的不给喜钱, ForeashAllDo((i) => { }); //向X家返回结果 通知 结束 List <UserIDMSG> imList = new List <UserIDMSG>(); ForeashAllDo((i) => { TCUser tempUser = _DicPos2User[i]; sc_end_tc_n _end_n = new sc_end_tc_n() { fn = "sc_end_tc_n", result = 1 }; // 显示结束面板就行 _end_n.allmoney = _allMoney; _end_n.winCard = _wincard; _end_n.endMoneylist = _moneylist; _end_n.EasterEgg = 0; imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_end_n), tempUser._isRobot, tempUser._isDisconnet)); }); TCSendDataServer.instance.SendDataDelay(imList); _tableSendData.Add(imList); ForeashAllDo((i) => { _DicPos2User[i].SetTimeOutAction(1, "sc_end_tc_n"); });//下把的自动开始功能 ReStart(); //写入此桌的录相 记录 _tablRecord.ActionList = ""; _tablRecord.EndTime = DateTime.Now; try { tb_tablerecord tr = new tb_tablerecord() { MatchCode = _tablRecord.MatchCode, StartTime = _tablRecord.StartTime, EndTime = _tablRecord.EndTime, //PostoIPArr = _tablRecord.PostoIPArr, //posarr = _tablRecord.posarr, ActionList = _tablRecord.ActionList, //ActionCount = _tablRecord.ActionCount, LookCount = _tablRecord.LookCount }; //// LogWriteToDB(0, tr); } catch (Exception ex) { ErrorRecord.Record(ex, " 201207231051TC"); } //重置此桌信息 ///// Reset(CheckResetTable()); } }