private Draw InitializeDraw(DrawSize drawSize, TournamentRound startingRound, int matchesCount) { var draw = new Draw(); switch (drawSize) { case DrawSize.draw8: draw.InitialRound = TournamentRound.round4; draw.MatchesCount = 7; break; case DrawSize.draw16: draw.InitialRound = TournamentRound.round3; draw.MatchesCount = 15; break; case DrawSize.draw32: draw.InitialRound = TournamentRound.round2; draw.MatchesCount = 31; break; case DrawSize.draw64: draw.InitialRound = TournamentRound.round1; draw.MatchesCount = 63; break; } ; return(draw); }
protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); // If the bounds of this container changed, add or remove the number of child sprites to fill the visible space. if (!DrawSize.Equals(lastSize)) { updateLayout(); lastSize = DrawSize; } }
public static bool PrintRequest(string path, DrawSize size, string printerName, bool color) { PrintDevice.size = size; return(PrintRequest(path, printerName, color)); }
public async Task <DrawDTO> CreateOrUpdateMatchesForTournament(DrawSize drawSize, int tournamentId, List <MatchDTO> matchDTOs = null) { var matches = await _dbContext.Matches.Where(m => m.TournamentId == tournamentId).ToListAsync(); var drawDto = new DrawDTO(); if (matches == null || matches.Count == 0) { var startingRound = TournamentRound.round1; var matchesCount = 0; var draw = InitializeDraw(drawSize, startingRound, matchesCount); matches = GetMatchesForNewDraw(draw.InitialRound, draw.MatchesCount, tournamentId); //// reverse matches because when not In DB, stored first match is final(round6), then round5, round4.. //matches.Reverse(); var matchesEntries = new List <MatchEntry>(); using (var transaction = _dbContext.Database.BeginTransaction()) { var bulkConfig = new BulkConfig { PreserveInsertOrder = true, SetOutputIdentity = true }; InsertOrdered(matches, m => m.Id); //_dbContext.BulkInsert(matches, bulkConfig); int matchIndex = 0, round2index = 0; //// checkin matches id //matches.Reverse(); foreach (var match in matches) { if (match.Round != draw.InitialRound) { foreach (var entry in match.MatchEntries) { entry.MatchId = match.Id; entry.ParentMatchId = matches[round2index].Id; round2index++; } } else { foreach (var entry in match.MatchEntries) { entry.MatchId = match.Id; } } matchesEntries.AddRange(match.MatchEntries); matchIndex++; } _dbContext.BulkInsert(matchesEntries, bulkConfig); transaction.Commit(); } } else { // update list MatchDTO, implementovat FE a tak vyskusat // TODO - nejaky check na parent a winner var matchesDB = Mapper.Map <List <MatchDTO>, List <Match> >(matchDTOs); var matchesEntries = matchesDB.SelectMany(m => m.MatchEntries).ToList(); CheckMatches(matchesDB); await _dbContext.BulkUpdateAsync(matchesDB); await _dbContext.BulkUpdateAsync(matchesEntries); } await _dbContext.SaveChangesAsync(); //// BUG on bulk - need to reverse inserted data //ReverseMatchesIds(matches); matchDTOs = Mapper.Map <List <Match>, List <MatchDTO> >(matches); var roundMatches = matchDTOs.GroupBy(m => m.Round).Select(g => new RoundMatchDTO { Round = (int)g.Key, Matches = g.ToList() }); drawDto.RoundMatches = roundMatches.ToList(); return(drawDto); }
public DrawInstruction(DrawDisplay display, DrawSize size) { this.display = display; this.size = size; }
public static bool PrintRequest(string path, DrawSize size, string printerName, bool color) { PrintDevice.size = size; return PrintRequest(path, printerName, color); }