public ActionResult Add(MatchReport report) { List <SelectListItem> matcheslist = new List <SelectListItem>(); MatchesRepository matchesrep = new MatchesRepository(); var mymatches = matchesrep.GetAllMatches().OrderByDescending(k => k.Timestamp); if (mymatches.Count() > 0) { foreach (Match m in mymatches) { SelectListItem sli = new SelectListItem(); sli.Value = m.Id.ToString(); sli.Text = m.HomeTeamName + " (" + m.HomeGoals + " - " + m.AwayGoals + ") " + m.AwayTeamName; matcheslist.Add(sli); } } ViewData["Matches"] = matcheslist; if (!String.IsNullOrEmpty(report.Contents)) { MatchReportRepository matchreportrep = new MatchReportRepository(); matchreportrep.Add(report); matchreportrep.SaveChanges(); return(Redirect("/matchreports")); } else { ModelState.AddModelError("Contents", "Please make sure you've entered a match report"); } return(View(report)); }
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()); } }
public ActionResult Add(MatchReport report) { List <SelectListItem> matchesList = new List <SelectListItem>(); MatchesRepository matchesRep = new MatchesRepository(); var myMatches = matchesRep.GetAllMatches().OrderBy(k => k.TimeStamp); if (myMatches.Count() > 0) { foreach (Match m in myMatches) { SelectListItem sli = new SelectListItem(); sli.Value = m.Id.ToString(); sli.Text = m.HomeTeamName + " ( " + m.HomeGoals + "-" + m.AwayGoals + " ) " + m.AwayTeamName; matchesList.Add(sli); } ViewData["Matches"] = matchesList; if (ModelState.IsValid) { MatchReportsRepository matchreportrep = new MatchReportsRepository(); matchreportrep.Add(report); matchreportrep.SaveChanges(); return(RedirectToAction("Index")); } } return(View(report)); }
/// <summary> /// Invokes while the /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OpenFileDialog_Ok(object sender, CancelEventArgs e) { if (String.IsNullOrEmpty(_dialog.FileName)) { MessageBox.Show("请先选择文件"); } try { _match = IOUtil.BinRead <MatchReport>(_dialog.FileName, 0); DataMgr.FillFormData(_match); } catch { MessageBox.Show("打开文件失败!"); return; } if (_match != null) { _timer.Stop(); _round = 0; _maxRound = GetMaxRound(); ResetPlayer(); PlayGame(this, new EventArgs()); } }
public static MatchReport LoadProcess(string fileName, Guid matchId) { MatchReport match = null; try { match = IOUtil.BinRead <MatchReport>(fileName, 0); const string xmlpath = @"d:\test\datainfofromdb.xml"; IOUtil.XmlWrite(xmlpath, match); return(match); } catch (Exception ex) { if (match != null) { try { string xmlpath = @"d:\test\data" + matchId + ".xml"; IOUtil.XmlWrite(xmlpath, match); } catch { } } LogHelper.Insert(ex, fileName); return(null); } }
public ActionResult Edit(MatchReport report) { List <SelectListItem> matchesList = new List <SelectListItem>(); MatchesRepository matchesRep = new MatchesRepository(); var myMatches = matchesRep.GetAllMatches().OrderBy(k => k.TimeStamp); if (myMatches.Count() > 0) { foreach (Match m in myMatches) { SelectListItem sli = new SelectListItem(); sli.Value = m.Id.ToString(); sli.Text = m.HomeTeamName + " ( " + m.HomeGoals + "-" + m.AwayGoals + " ) " + m.AwayTeamName; matchesList.Add(sli); } ViewData["Matches"] = matchesList; if (ModelState.IsValid) { MatchReport model = db.MatchReports.Where(l => l.Id == report.Id).FirstOrDefault(); model.Contents = report.Contents; db.SubmitChanges(); return(RedirectToAction("Index")); } } return(View(report)); }
public byte[] Exec(BaseMatchData stateObj, MatchInput matchInput) { MatchReport resultEntity = null; var home = stateObj.Home.ManagerId; var away = stateObj.Away.ManagerId; int i = 0; do { try { byte[] process = null; //固定新手引导首场 if (ShareUtil.IsAppRXYC && stateObj.IsGuide && stateObj.MatchType == (int)EnumMatchType.PlayerKill) { process = MatchReportCache.Instance().GetReport(); } if (null == process) { process = _matchClient.CreateMatch(matchInput); } if (process != null && process.Length > 10) { resultEntity = NB.Match.Base.Util.IOUtil.BinRead <MatchReport>(process, 0); } if (resultEntity == null) { throw new Exception("the callback MatchStream is empty"); } else { if (stateObj.NoDraw && resultEntity.HomeScore == resultEntity.AwayScore) { i++; } else { stateObj.ErrorCode = (int)MessageCode.Success; stateObj.Home.Score = resultEntity.HomeScore; stateObj.Away.Score = resultEntity.AwayScore; return(process); } } } catch (Exception ex) { i++; if (i >= MATCHRetryTimes) { SystemlogMgr.Error("MatchThread Exec", string.Format("Home:{0},Away:{1},Message:{2},StackTrace:{3}", home, away, ex.Message, ex.StackTrace)); //SystemlogMgr.Error("MatchThread Exec", ex); stateObj.ErrorCode = (int)MessageCode.Exception; return(null); } } }while (i < MATCHRetryTimes); return(null); }
public void ShowMatchPlay(EnumMatchType matchType, Guid matchId, MatchReport match) { //var form = new MatchView(match); //form.ShowDialog(); //if (form.DialogResult.HasValue && form.DialogResult == true) //{ // var resultView = new MatchResultControl(matchType,matchId); // ShowMainControl(resultView); //} }
public void CreateCallback(Guid matchId, int count, long cost, MatchReport matchResult) { var entity = new BatchMatchEntity(matchId, count, cost, matchResult); _testMatchList.Add(entity); EmulatorHelper.SaveMatchToFile(matchResult, matchId, _folderName); EmulatorHelper.LoadTestProcess(_folderName, matchId); //LogHelper.Insert("matchId:"+matchId,LogType.Info); ProgressBar1.Value = count; lblProcess.Content = string.Format("{0}/{1}", count, _matchTimes); }
public BatchMatchEntity(Guid matchId, int id, long cost, MatchReport match) { MatchId = matchId; Id = id; Cost = cost; Round = EmulatorHelper.GetMaxRound(match); HomeManager = new BatchManagerEntity(match, Round, true); AwayManager = new BatchManagerEntity(match, Round, false); HomeScore = match.HomeScore; AwayScore = match.AwayScore; }
public ActionResult SingleReport(int id) { MatchReport list = MatchReportCollection.GetMatchReportByID(id); if (list == null) { return(RedirectToAction("Reports", "Oversight")); } ViewBag.Matchreport = list; return(View()); }
public async Task <Match> UpdateReport(MatchReport report) { using (var dbContext = new TtcDbContext()) { var existingMatch = await dbContext.Matches.FirstAsync(x => x.Id == report.MatchId); existingMatch.ReportPlayerId = report.PlayerId; existingMatch.Description = report.Text; await dbContext.SaveChangesAsync(); } var newMatch = await GetMatch(report.MatchId); return(newMatch); }
public MatchEntity(MatchInput input) { _status.Round = -1; _status.Minute = -1; //_status.TotalRound = Convert.ToInt32(input.TranTime / Defines.Match.ROUND_TIME); _status.TotalRound = 2 * Convert.ToInt32(input.TranTime / Defines.Match.ROUND_TIME); input.HomeManager.BalanceProp(); input.AwayManager.BalanceProp(); this._input = input; this._football = new Football(this); this._homeManager = new Manager(input.HomeManager, this, Side.Home); this._awayManager = new Manager(input.AwayManager, this, Side.Away); this._openSide = this.RandomBool() ? Side.Home : Side.Away; this._report = new MatchReport(input); }
public static int GetMaxRound(MatchReport match) { int round = 0; foreach (var m in new[] { match.HomeManager, match.AwayManager }) { foreach (var p in m.Players) { if (p.CntMoveResults > round) { round = p.CntMoveResults; } } } return(round); }
public Main(MatchReport match, StatisticsMatchEntity statistics) : this() { _match = match; _statisticsMatch = statistics; if (_match != null) { _timer.Stop(); _round = 0; _maxRound = GetMaxRound(); ResetPlayer(); //ResetBall(); btnNewGame.IsEnabled = false; PlayGame(this, new EventArgs()); } }
public IActionResult NewMatchReportAdded(MatchReportViewModel matchreport) { if (!ModelState.IsValid) { return(RedirectToAction("NewReport", "Reports")); } try { MatchReport newreport = new MatchReport(0, DateTime.Now, matchreport.Title, matchreport.Report, null); MatchReportCollection.AddMatchReport(newreport); return(RedirectToAction("Oversight", "Reports")); } catch (AddMatchReportFailedException exception) { ModelState.AddModelError("", exception.Message); return(RedirectToAction("NewReport", "Reports")); } }
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()); } }
public static bool SaveMatchToFile(MatchReport match) { try { if (match == null) { return(false); } const string path = @"d:\test\data.bin"; const string xmlpath = @"d:\test\datainfo.xml"; IOUtil.BinWrite(path, match, 0); IOUtil.XmlWrite(xmlpath, match); return(true); } catch (Exception ex) { LogHelper.Insert(ex); return(false); } }
public BatchManagerEntity(MatchReport match, int round, bool isHome) : this() { TotalRound = round; _isHome = isHome; _match = match; if (_isHome) { Score = match.HomeScore; TotalRound = round; _homeReport = match.HomeManager; _awayReport = match.AwayManager; } else { Score = match.AwayScore; _homeReport = match.AwayManager; _awayReport = match.HomeManager; } BuildData(); }
public async Task <bool> ReportGameAsync(MatchReport matchReport, CancellationToken cancellationToken) { await Task.Yield(); return(Retry.Invoke(() => { try { using (var connection = this.connection.GetConnection()) { var collection = connection.GetCollection <MatchReportDocument>(CollectionName); var doc = new MatchReportDocument { Id = matchReport.Id, PlayerDeckCode = matchReport.PlayerDeckCode, PlayerName = matchReport.PlayerName, OpponentName = matchReport.OpponentName, Regions = matchReport.Regions, Result = matchReport.Result, FinishTime = matchReport.FinishTime.UtcDateTime, Type = matchReport.Type }; collection.Insert(doc); this.logger.Debug("Match report stored"); return true; } } catch (Exception ex) { this.logger.Error($"Error occurred storing match report: {ex.Message}"); return false; } })); }
public async Task <MatchReport> GetMatchReportByIdAsync(string id, CancellationToken cancellationToken) { await Task.Yield(); return(Retry.Invoke <MatchReport>(() => { try { using (var connection = this.connection.GetConnection()) { var collection = connection.GetCollection <MatchReportDocument>(CollectionName); var matchReportDoc = collection.FindById(id); this.logger.Debug($"Match report with id '{id}' retrieved"); var matchReport = new MatchReport { Id = matchReportDoc.Id, PlayerDeckCode = matchReportDoc.PlayerDeckCode, PlayerName = matchReportDoc.PlayerName, OpponentName = matchReportDoc.OpponentName, Regions = matchReportDoc.Regions, Result = matchReportDoc.Result, FinishTime = matchReportDoc.FinishTime, Type = matchReportDoc.Type }; return matchReport; } } catch (Exception ex) { this.logger.Error($"Error occurred retrieving match report with id '{id}': {ex.Message}"); return null; } })); }
public static bool SaveMatchToFile(MatchReport match, Guid matchId, string folderName) { try { if (match == null) { return(false); } string folder = "d:\\test\\" + folderName + "\\"; if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } string path = folder + matchId + ".bin"; IOUtil.BinWrite(path, match, 0); return(true); } catch (Exception ex) { LogHelper.Insert(ex); return(false); } }
public ActionResult Edit(int?Id) { List <SelectListItem> matchesList = new List <SelectListItem>(); MatchesRepository matchesRep = new MatchesRepository(); var myMatches = matchesRep.GetAllMatches().OrderBy(k => k.TimeStamp); if (myMatches.Count() > 0) { foreach (Match m in myMatches) { SelectListItem sli = new SelectListItem(); sli.Value = m.Id.ToString(); sli.Text = m.HomeTeamName + " ( " + m.HomeGoals + "-" + m.AwayGoals + " ) " + m.AwayTeamName; matchesList.Add(sli); } } ViewData["Matches"] = matchesList; MatchReport model = db.MatchReports.Where(l => l.Id == Id).FirstOrDefault(); return(View(model)); }
public List <MatchReport> GetRecentMatches(string count) { int quantity = 0; try { quantity = CheckCount(count); } catch (Exception exc) { if (exc.Message == "Count is less or equal zero") { return(new List <MatchReport>()); } else { Program.log.Error(exc, "An error occured for HTTP GET GetRecentMatches"); throw exc; } } try { using (var database = new LiteDatabase(Program.databasePath)) { var matchesCollection = database.GetCollection <Match>("matches"); matchesCollection.EnsureIndex(x => x.DateTimeTimestamp); return(MatchReport.GetRecentMatches(matchesCollection, quantity)); } } catch (Exception exc) { Program.log.Error(exc, "An error occured for HTTP GET GetRecentMatches"); throw exc; } }
public async Task <Match> Report([FromBody] MatchReport report) { var result = await _service.UpdateReport(report); return(result); }
/// <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, "系统错误"); } }
public void EndGame(Global.PLAY_TYPE playType, MatchPlayer local, MatchPlayer other, MatchReport result) { UI_InGamePopup.Get().SetViewWaiting(false); // 인디케이터도 다시 안보이게.. if (UI_InGamePopup.Get().IsIndicatorActive() == true) { UI_InGamePopup.Get().ViewGameIndicator(false); } StopAllCoroutines(); SoundManager.instance?.StopBGM(); BroadcastMessage("EndGameUnit", SendMessageOptions.DontRequireReceiver); UI_InGame.Get().ClearUI(); StartCoroutine(EndGameCoroutine(playType, local, other, result)); }
//KZSee: 결과처리 IEnumerator EndGameCoroutine(Global.PLAY_TYPE playType, MatchPlayer localPlayer, MatchPlayer otherPlayer, MatchReport result) { yield return(new WaitForSeconds(4f)); //KZSee: 이벤트로그 //playerController.SendEventLog_BatCheck(); UI_InGamePopup.Get().SetPopupResult(playType, localPlayer, otherPlayer, true, result.WinLose, result.WinStreak, result.IsPerfect, result.NormalRewards, result.StreakRewards, result.PerfectRewards, result.LoseReward); SoundManager.instance.Play(result.WinLose ? Global.E_SOUND.BGM_INGAME_WIN : Global.E_SOUND.BGM_INGAME_LOSE); }