Esempio n. 1
0
        public void CreateBulkOfMatches(List<IMatch> matches)
        {
            if (matches == null)
                throw new ArgumentNullException("matches");

            // Get the overall batch identification from the Mediator.
            IBatch batchId = ProxyHome.Instance.RetrieveExecutionIdentification(DataAccessKeyKeeper.Instance.AccessKey);

            using (CodeAnalyzerContainer ctx = new CodeAnalyzerContainer())
            {
                Model.Batch batch = new Model.Batch { TimeStamp = batchId.TimeStamp };

                foreach (IMatch match in matches)
                {
                    // Mapping: Domain Model => Entity Model.
                    Model.Match m = new Model.Match()
                    {
                        LineNumber        = match.LineNumber,
                        CodeExtract       = match.CodeExtract,
                        RootDirectoryPath = match.RootDirectoryPath,
                        Filename          = match.Filename,
                        Batch             = batch,
                        Status            = (int)match.Result,
                        RuleDeclaration   = ToEntityModelMapper.RuleDeclarationMapper(match.RuleDeclarationRef, ctx),
                    };

                    // Do the actual DB update.
                    ctx.Match.Add(m);
                }
                ctx.SaveChanges();
            }
        }
Esempio n. 2
0
        public void validarInicioBatalha()
        {
            Rectangle areaBusca = new Rectangle(200, 200, Proporcao.Width / 2, Proporcao.Height - 200);

            Model.Match objMatchIniciarBatalha = ImagemBusca.obterInstancia().buscarImagemPorTemplate(BotaoAcao.obterInstancia().obterBotaoAcao("IniciarBatalha").Imagem, Imagem.EnumRegiaoImagem.COMPLETO, areaBusca);


            bool isIniciarBatalha = false;

            if (objMatchIniciarBatalha.Semelhanca > 0)
            {
                isIniciarBatalha = true;
            }
            else
            {
                Model.Match objMatchPassarTurno = ImagemBusca.obterInstancia().buscarImagemPorTemplate(BotaoAcao.obterInstancia().obterBotaoAcao("PassarTurno").Imagem, Imagem.EnumRegiaoImagem.COMPLETO, areaBusca);
                if (objMatchPassarTurno.Semelhanca > 0)
                {
                    isIniciarBatalha = true;
                }
            }
            if (isIniciarBatalha)
            {
                System.Windows.Forms.SendKeys.SendWait(" ");
                Batalha.obterInstancia().iniciar(Batalha.EnumTiposBatalha.AntiBOT);
            }
        }
Esempio n. 3
0
        public void tratarCliqueBotaoFechar()
        {
            Rectangle areaBusca = new Rectangle(57, 24, Proporcao.Width - 57, Proporcao.Height - 24);

            Model.Match objMatch = ImagemBusca.obterInstancia().buscarImagemPorTemplate((new BotaoFechar()).Imagem, Imagem.EnumRegiaoImagem.COMPLETO, areaBusca);
            if (objMatch.Semelhanca > 0)
            {
                Win32.clicarBotaoEsquerdo(objMatch.Location.X + 15, objMatch.Location.Y + 5);
            }
        }
Esempio n. 4
0
        public void tratarRecusaDeGrupo()
        {
            Rectangle areaBusca = new Rectangle(60, 20, Proporcao.Width - 60, Proporcao.Height - 20);

            Model.Match objMatch = ImagemBusca.obterInstancia().buscarImagemPorTemplate((new BotaoNao()).Imagem, Imagem.EnumRegiaoImagem.COMPLETO, areaBusca);
            if (objMatch.Semelhanca > 0)
            {
                Win32.clicarBotaoEsquerdo(objMatch.Location.X + 15, objMatch.Location.Y + 5);
            }
        }
Esempio n. 5
0
        public void validarFechamentoMensagens()
        {
            Rectangle areaBusca = new Rectangle(50, 50, Proporcao.Width - 50, Proporcao.Height - 50);

            Model.Match objMatch = ImagemBusca.obterInstancia().buscarImagemPorTemplate((new BotaoFecharX()).Imagem, Imagem.EnumRegiaoImagem.COMPLETO, areaBusca);
            if (objMatch.Semelhanca > 0)
            {
                Win32.clicarBotaoEsquerdo(objMatch.Location.X + 5, objMatch.Location.Y + 5);
            }
        }
Esempio n. 6
0
 // POST api/<controller>
 public async Task<IHttpActionResult> Post(Match match)
 {
     try
     {
         _matchService.Insert(match);
         await _unitOfWorkAsync.SaveChangesAsync();
         return Ok(match.MatchID);
     }
     catch (Exception ex)
     {
         return BadRequest("Can't Create Match");
     }
 }
Esempio n. 7
0
        public void CreateMatch(IMatch match)
        {
            if (match == null)
            {
                throw new ArgumentNullException("match");
            }

            using (CodeAnalyzerContainer context = new CodeAnalyzerContainer())
            {
                // Mapping: Domain Model => Entity Model.
                Model.Match m = ToEntityModelMapper.MatchMapper(match, context);

                // Do the actual DB update.
                context.Match.Add(m);
                context.SaveChanges();
            }
        }
Esempio n. 8
0
        public void CreateBulkOfMatches(List <IMatch> matches)
        {
            if (matches == null)
            {
                throw new ArgumentNullException("matches");
            }

            // Get the overall batch identification from the Mediator.
            IBatch batchId = ProxyHome.Instance.RetrieveExecutionIdentification(DataAccessKeyKeeper.Instance.AccessKey);

            using (CodeAnalyzerContainer ctx = new CodeAnalyzerContainer())
            {
                Model.Batch batch = new Model.Batch {
                    TimeStamp = batchId.TimeStamp
                };

                foreach (IMatch match in matches)
                {
                    // Mapping: Domain Model => Entity Model.
                    Model.Match m = new Model.Match()
                    {
                        LineNumber        = match.LineNumber,
                        CodeExtract       = match.CodeExtract,
                        RootDirectoryPath = match.RootDirectoryPath,
                        Filename          = match.Filename,
                        Batch             = batch,
                        Status            = (int)match.Result,
                        RuleDeclaration   = ToEntityModelMapper.RuleDeclarationMapper(match.RuleDeclarationRef, ctx),
                    };

                    // Do the actual DB update.
                    ctx.Match.Add(m);
                }
                ctx.SaveChanges();
            }
        }
        public override void MigrateMatchDetails(int matchId, int matchRound, int season, int htSeriesId)
        {
            var matchDetails = GetMatchDetails(matchId);
            Session.Clear();
            var repository = new SeriesRepository(Session);
            var series = repository.GetAll().First(s => s.HtSeriesId == htSeriesId);

            var match = series.Matches.FirstOrDefault(m => m.MatchId == matchId);
            var htMatch = matchDetails.Match.First();
            DateTime matchFinishDate;
            if (DateTime.TryParse(htMatch.FinishedDate, out matchFinishDate))
            {
                var htAwayTeam = htMatch.AwayTeam.First();
                var htHomeTeam = htMatch.HomeTeam.First();
                if (match == null)
                {
                    match = new Match
                    {
                        HtMatchId = int.Parse(htMatch.MatchID),
                        MatchDate = DateTime.Parse(htMatch.MatchDate),
                        FinishedDate = DateTime.Parse(htMatch.FinishedDate),
                        MatchArena = new MatchArena
                        {
                            ArenaName = htMatch.MatchArena.ArenaName,
                            HtArenaId = int.Parse(htMatch.MatchArena.ArenaID),
                            WeatherId = short.Parse(htMatch.MatchArena.WeatherID)
                        },
                        MatchType = short.Parse(htMatch.MatchType),
                        MatchSeason = (short)season,
                        MatchRound = (short)matchRound
                    };
                    match.SetMatchHomeTeam(GetMatchTeam(series.Country, htHomeTeam, htMatch.PossessionFirstHalfHome,
                                                        htMatch.PossessionSecondHalfHome));
                    match.SetMatchAwayTeam(GetMatchTeam(series.Country, htAwayTeam, htMatch.PossessionFirstHalfAway,
                                                        htMatch.PossessionSecondHalfAway));
                    ProcessScorers(match, htMatch);
                    ProcessInjuries(match, htMatch);
                    ProcessBookings(match, htMatch);
                    ProcessEvents(match, htMatch);
                    series.AddMatch(match);
                }
            }
            repository.SaveUpdate(series);
            Session.Flush();
        }
        private static void ProcessScorers(Match match, HattrickDataMatch htMatch)
        {
            foreach (var matchScorer in htMatch.MatchScorers)
            {
                int scorerTeamId = int.Parse(matchScorer.ScorerTeamID);
                bool isHomeScorer = match.MatchHomeTeam.Team.TeamId == scorerTeamId;
                var scorer = new MatchScorer
                                 {
                                     OppositionGoals =
                                         isHomeScorer
                                             ? short.Parse(matchScorer.ScorerAwayGoals)
                                             : short.Parse(matchScorer.ScorerHomeGoals),
                                     TeamGoals =
                                         isHomeScorer
                                             ? short.Parse(matchScorer.ScorerHomeGoals)
                                             : short.Parse(matchScorer.ScorerAwayGoals),
                                     PlayerId = int.Parse(matchScorer.ScorerPlayerID),
                                     PlayerName = matchScorer.ScorerPlayerName,
                                     ScorerMinute = short.Parse(matchScorer.ScorerMinute)
                                 };

                if (isHomeScorer)
                    match.AddHomeMatchScorer(scorer);
                else
                    match.AddAwayMatchScorer(scorer);
            }
        }
 private static void ProcessInjuries(Match match, HattrickDataMatch htMatch)
 {
     foreach (var htInjury in htMatch.MatchInjuries)
     {
         int injuryTeamId = int.Parse(htInjury.InjuryTeamID);
         var injury = new MatchInjury
                          {
                              PlayerId = int.Parse(htInjury.InjuryPlayerID),
                              PlayerName = htInjury.InjuryPlayerName,
                              InjuryMinute = short.Parse(htInjury.InjuryMinute),
                              InjuryType = short.Parse(htInjury.InjuryType),
                          };
         if (match.MatchHomeTeam.Team.TeamId == injuryTeamId)
             match.AddHomeTeamMatchInjury(injury);
         else if (match.MatchAwayTeam.Team.TeamId == injuryTeamId)
             match.AddAwayTeamMatchInjury(injury);
     }
 }
 private static void ProcessEvents(Match match, HattrickDataMatch htMatch)
 {
     foreach (var htMatchEvent in htMatch.EventList)
     {
         MatchEvent matchEvent = new MatchEvent();
         matchEvent.EventIndex = short.Parse(htMatchEvent.Index);
         matchEvent.EventText = htMatchEvent.EventText;
         matchEvent.EventTypeID = short.Parse(htMatchEvent.EventTypeID);
         matchEvent.EventVariation = short.Parse(htMatchEvent.EventVariation);
         matchEvent.Minute = short.Parse(htMatchEvent.Minute);
         matchEvent.ObjectPlayerID = string.IsNullOrEmpty(htMatchEvent.ObjectPlayerID) ? (int?)null : int.Parse(htMatchEvent.ObjectPlayerID);
         matchEvent.SubjectPlayerID = string.IsNullOrEmpty(htMatchEvent.SubjectPlayerID) ? (int?)null : int.Parse(htMatchEvent.SubjectPlayerID);
         matchEvent.SubjectTeamID = string.IsNullOrEmpty(htMatchEvent.SubjectTeamID) ? (int?)null : int.Parse(htMatchEvent.SubjectTeamID);
         match.AddMatchEvent(matchEvent);
     }
 }
 private static void ProcessBookings(Match match, HattrickDataMatch htMatch)
 {
     foreach (var htBooking in htMatch.Bookings)
     {
         int bookingTeamId = int.Parse(htBooking.BookingTeamID);
         var booking = new MatchBooking
                           {
                               PlayerId = int.Parse(htBooking.BookingPlayerID),
                               PlayerName = htBooking.BookingPlayerName,
                               BookingMinute = short.Parse(htBooking.BookingMinute),
                               BookingType = short.Parse(htBooking.BookingType)
                           };
         if (match.MatchHomeTeam.Team.TeamId == bookingTeamId)
             match.AddHomeTeamMatchBooking(booking);
         else if (match.MatchAwayTeam.Team.TeamId == bookingTeamId)
             match.AddAwayTeamMatchBooking(booking);
     }
 }
Esempio n. 14
0
        public bool acaoIniciarBatalha()
        {
            System.Threading.Thread.Sleep(1000);
            System.Windows.Forms.SendKeys.SendWait(" ");
            System.Threading.Thread.Sleep(4000);
            try
            {
                Size bounds = Proporcao.obterProporcao();

                if (ImagemCaptura.obterInstancia().objBitmap != null)
                {
                    ImagemCaptura.obterInstancia().objBitmap.Dispose();
                }
                Bitmap objBitmap = ImagemCaptura.obterInstancia().obterImagemTela(true);

                int eixoHorizontal = 275;
                int eixoVertical   = 405;
                //Acrescentado 21 pixels na altura/largura do retangulo do personagem e gato, estava cortando no meio do retangulo do número.
                int larguraEAlturaRetangulo = 107 + 21;

                Rectangle retanguloPersonagem = new Rectangle(eixoHorizontal, eixoVertical, larguraEAlturaRetangulo, larguraEAlturaRetangulo);

                eixoHorizontal = 448;
                Rectangle retanguloGato = new Rectangle(eixoHorizontal, eixoVertical, larguraEAlturaRetangulo, larguraEAlturaRetangulo);

                Dictionary <int, Model.Match> MatchesGato = new Dictionary <int, Model.Match>();
                AntiBOT objAntiBOT = new AntiBOT();
                for (int numeroMatch = 1; numeroMatch <= 8; numeroMatch++)
                {
                    MatchesGato.Add(numeroMatch, ImagemBusca.obterInstancia().buscarImagemPorTemplateRotacionado(
                                        objAntiBOT.numerosMatch["Numero" + numeroMatch],
                                        Imagem.EnumRegiaoImagem.RETANGULO,
                                        retanguloGato
                                        )
                                    );
                }
                Application.DoEvents();

                List <Model.Match> Verificar      = new List <Model.Match>();
                List <Model.Match> NaoEncontrados = new List <Model.Match>();

                //Buscar os números até encontrar pelo menos 3 do lado do gato
                Verificar.Clear();
                foreach (Model.Match m in MatchesGato.Values)
                {
                    if (m.Semelhanca > 0)
                    {
                        Verificar.Add(m);
                    }
                    else
                    {
                        NaoEncontrados.Add(m);
                    }
                }

                List <Model.Match> Clicar = new List <Model.Match>();
                bool conflito             = false;
                if (Verificar.Count > 3)
                {
                    for (int i = 0; i < Verificar.Count; i++)
                    {
                        conflito = false;

                        for (int j = 0; j < Verificar.Count; j++)
                        {
                            if (i == j)
                            {
                                continue;
                            }

                            if (new Rectangle(Verificar[i].Location, new Size(24, 24)).Contains(Verificar[j].Location))
                            {
                                conflito = true;
                                if (Verificar[i].Semelhanca > Verificar[j].Semelhanca)
                                {
                                    Clicar.Add(Verificar[i]);
                                }
                                else
                                {
                                    Clicar.Add(Verificar[j]);
                                }
                            }
                        }
                        if (!conflito)
                        {
                            Clicar.Add(Verificar[i]);
                        }
                    }
                }
                else
                {
                    Clicar.AddRange(Verificar);
                }
                System.Threading.Thread.Sleep(1100);
                foreach (Model.Match objMatch in Clicar)
                {
                    //System.Threading.Thread.Sleep(2000);
                    Model.Match matchClicar = ImagemBusca.obterInstancia().buscarImagemPorTemplateRotacionado(objAntiBOT.numerosMatch["Numero" + objMatch.Numero.ToString()], Imagem.EnumRegiaoImagem.RETANGULO, retanguloPersonagem);

                    System.Windows.Forms.SendKeys.SendWait("1");
                    System.Threading.Thread.Sleep(800);
                    Common.Lib.Win32.clicarBotaoEsquerdo(matchClicar.Location.X, matchClicar.Location.Y);
                }

                Application.DoEvents();

                System.Threading.Thread.Sleep(5000);
                Busca.obterInstancia().validarFechamentoMensagens();
            }
            catch (Exception objException)
            {
                MessageBox.Show(objException.Message);
            }
            return(true);
        }