void _diagOpenFile_FileOk(object sender, CancelEventArgs e) { string path = _diagOpenFile.FileName; if (String.IsNullOrEmpty(path)) { MessageBox.Show("请先选择文件"); return; } try { _match = IOUtil.BinRead <MatchReport>(path, 0); DataMgr.FillFormData(_match); DataMgr.FillRoundData(_match); } catch { MessageBox.Show("打开文件失败!"); return; } _diagOpenFile.FileName = string.Empty; if (_match != null) { _timer.Stop(); _round = 0; DataMgr.FillFormData(_match); DataMgr.FillRoundData(_match); this._maxRound = GetMaxRound(); Interlocked.Exchange(ref this._isEndStart, 1); _waitTimer.Start(); ResetPlayer(); PlayGame(this, new EventArgs()); } }
private void btnLoadFromDB_Click(object sender, RoutedEventArgs e) { string txt = txtMatchId.Text; Guid matchId = Guid.Empty; if (!Guid.TryParse(txt, out matchId)) { MessageBox.Show("比赛Id格式不正确!"); return; } int matchType = ComboBoxHelper.GetSelectValueInt(cmbMatchType); byte[] process = EmulatorHelper.GetProcess(matchId, matchType); if (process != null) { try { _match = IOUtil.BinRead <MatchReport>(process, 0); DataMgr.FillFormData(_match); DataMgr.FillRoundData(_match); this._maxRound = GetMaxRound(); Interlocked.Exchange(ref this._isEndStart, 1); _waitTimer.Start(); //const string xmlpath = @"d:\test\datainfofromdb.xml"; //IOUtil.XmlWrite(xmlpath,_match); } catch (Exception ex) { MessageBox.Show("获取比赛失败!" + ex.Message); return; } } else { MessageBox.Show("获取比赛失败!"); return; } if (_match != null) { PlayGame(this, new EventArgs()); } }
/// <summary> /// Start a new match. /// (This method is working on another thread.) /// </summary> private void StartNewMatch(object o) { Interlocked.Exchange(ref this._isEndStart, 0); MatchInput matchIn = null; if (hmid == Guid.Empty && amid == Guid.Empty) { double time; if (!double.TryParse(o.ToString(), out time)) { time = 120; } matchIn = DataMgr.CreateDebugMatch((int)time); } else { matchIn = LocalHelper.GetLocalMatchInput(hmid, homeIsNpc, amid, awayIsNpc, _time); } if (matchIn == null) { MessageBox.Show("创建比赛失败,创建MatchInput失败,请检查输入账号."); return; } IMatch match = new MatchEntity(matchIn, StatisticsAddProcess); if (_openStatistics) { _statisticsMatch = new StatisticsMatchEntity(match); } using (var watch = new Games.NB.Match.Log.LogWatch()) { EmulatorHelper.CreateMatch(match, _statisticsMatch); watch.LogCostTime(string.Format("Guid:{0}[{1}] vs Guid:{2}[{3}]. Result {4}:{5})", match.Input.HomeManager.Mid, match.Input.HomeManager.Name, match.Input.AwayManager.Mid, match.Input.AwayManager.Name, match.HomeScore, match.AwayScore)); var bytes = IOUtil.BinWrite(match.Report, ReportAsset.RPTVerNo); watch.LogCostTime("BinWrite"); _match = IOUtil.BinRead <MatchReport>(bytes, 0); watch.LogCostTime("BinRead"); } if (_match == null) { MessageBox.Show("创建比赛失败"); return; } else { MessageBox.Show("创建比赛成功"); } DataMgr.FillFormData(_match); DataMgr.FillRoundData(_match); try { //_match = MatchFacade.CreateMatch(DataMgr.CreateDebugMatch((int)time * 60, 335, 300)).Report; this._maxRound = GetMaxRound(); Interlocked.Exchange(ref this._isEndStart, 1); _loadingTimer.Start(); _waitTimer.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message + ":\n" + ex.StackTrace, "系统错误"); } }