Esempio n. 1
0
        // LineUp 만들기
        public void MakeLineUp()
        {
            DataMaker.Manager mgr = new DataMaker.Manager();
            try
            {
                Util.DataBaseManager dbMgr = new Util.DataBaseManager();

                var matches = from match in dbMgr.SelectAll <Match>()
                              join lineUp in dbMgr.SelectAll <LineUp>()
                              on match.Id equals lineUp.Id into t
                              from subLineUp in t.DefaultIfEmpty()
                              where subLineUp == null
                              select match;

                foreach (var match in matches)
                {
                    var boxScore = (from b in dbMgr.SelectAll <BoxScore_W>()
                                    where b.GameId == match.GameId
                                    select b).First();
                    var lineUps = mgr.MakeLineUp(match.Id, boxScore);
                    dbMgr.Save <LineUp>(lineUps);
                }
            }
            finally
            {
            }
        }
Esempio n. 2
0
        // LineUp 만들기
        public void MakeLineUp()
        {
            DataMaker.Manager mgr = new DataMaker.Manager();
            try
            {
                Util.DataBaseManager dbMgr = new Util.DataBaseManager();

                var matches = from match in dbMgr.SelectAll<Match>()
                              join lineUp in dbMgr.SelectAll<LineUp>()
                              on match.Id equals lineUp.Id into t
                              from subLineUp in t.DefaultIfEmpty()
                              where subLineUp == null
                              select match;
                            
                foreach(var match in matches)
                {
                    var boxScore = (from b in dbMgr.SelectAll<BoxScore_W>()
                                    where b.GameId == match.GameId
                                    select b).First();
                    var lineUps = mgr.MakeLineUp(match.Id, boxScore);
                    dbMgr.Save<LineUp>(lineUps);
                }
            }
            finally
            {
            }
        }
Esempio n. 3
0
        // Match Data 만들기
        public void MakeMatch()
        {
            DataMaker.Manager mgr = new DataMaker.Manager();
            try
            {
                Util.DataBaseManager dbMgr = new Util.DataBaseManager();
                var schedules = from schedule in dbMgr.SelectAll<Schedule>()
                                join match in dbMgr.SelectAll<Match>()
                                on schedule.GameId equals match.GameId into t
                                from subMatch in t.DefaultIfEmpty()
                                where schedule.LeagueId == 1 && schedule.SeriesId == 0
                                && schedule.Href != null && subMatch.GameId == null
                                select schedule;

                schedules = from schedule in schedules
                            where schedule.Year >= 2013
                            select schedule;

                //schedules = from schedule in dbMgr.SelectAll<Schedule>()
                //            where schedule.GameId == "20150902LGWO0"
                //            select schedule;


                foreach (var schedule in schedules)
                {
                    dbMgr = new Util.DataBaseManager();
                    var situation = (from s in dbMgr.SelectAll<Situation_W>()
                                     where s.GameId == schedule.GameId
                                     select s).First();

                    var boxScore = (from b in dbMgr.SelectAll<BoxScore_W>()
                                    where b.GameId == schedule.GameId
                                    select b).First();

                    var match = mgr.MakeMatch(situation, boxScore);

                    // Match 저장
                    List<Match> matchs = new List<Match>();
                    matchs.Add(match);
                    dbMgr.Save<Match>(matchs);

                    // Th 저장
                    List<Th> ths = new List<Th>();
                    foreach (var th in match.Ths)
                    {
                        th.MatchId = match.Id;
                        ths.Add(th);
                    }
                    dbMgr.Save<Th>(ths);

                    // Bat 저장
                    List<Bat> bats = new List<Bat>();
                    foreach (var th in match.Ths)
                    {
                        if (th.AwayBats != null)
                        {
                            foreach (var bat in th.AwayBats)
                            {
                                bat.ThId = th.Id;
                                bats.Add(bat);
                            }
                        }

                        if (th.HomeBats != null)
                        {
                            foreach (var bat in th.HomeBats)
                            {
                                bat.ThId = th.Id;
                                bats.Add(bat);
                            }
                        }
                    }
                    dbMgr.Save<Bat>(bats);

                    // Ball 저장
                    List<Ball> balls = new List<Ball>();
                    foreach (var th in match.Ths)
                    {
                        if (th.AwayBats != null)
                        {
                            foreach (var bat in th.AwayBats)
                            {
                                foreach (var ball in bat.Balls)
                                {
                                    ball.BatId = bat.Id;
                                    balls.Add(ball);
                                }
                            }
                        }

                        if (th.HomeBats != null)
                        {
                            foreach (var bat in th.HomeBats)
                            {
                                foreach (var ball in bat.Balls)
                                {
                                    ball.BatId = bat.Id;
                                    balls.Add(ball);
                                }
                            }
                        }
                    }
                    dbMgr.Save<Ball>(balls);
                }
            }
            finally
            {
            }
        }
Esempio n. 4
0
        // Match Data 만들기
        public void MakeMatch()
        {
            DataMaker.Manager mgr = new DataMaker.Manager();
            try
            {
                Util.DataBaseManager dbMgr = new Util.DataBaseManager();
                var schedules = from schedule in dbMgr.SelectAll <Schedule>()
                                join match in dbMgr.SelectAll <Match>()
                                on schedule.GameId equals match.GameId into t
                                from subMatch in t.DefaultIfEmpty()
                                where schedule.LeagueId == 1 && schedule.SeriesId == 0 &&
                                schedule.Href != null && subMatch.GameId == null
                                select schedule;

                schedules = from schedule in schedules
                            where schedule.Year >= 2013
                            select schedule;

                //schedules = from schedule in dbMgr.SelectAll<Schedule>()
                //            where schedule.GameId == "20150902LGWO0"
                //            select schedule;


                foreach (var schedule in schedules)
                {
                    dbMgr = new Util.DataBaseManager();
                    var situation = (from s in dbMgr.SelectAll <Situation_W>()
                                     where s.GameId == schedule.GameId
                                     select s).First();

                    var boxScore = (from b in dbMgr.SelectAll <BoxScore_W>()
                                    where b.GameId == schedule.GameId
                                    select b).First();

                    var match = mgr.MakeMatch(situation, boxScore);

                    // Match 저장
                    List <Match> matchs = new List <Match>();
                    matchs.Add(match);
                    dbMgr.Save <Match>(matchs);

                    // Th 저장
                    List <Th> ths = new List <Th>();
                    foreach (var th in match.Ths)
                    {
                        th.MatchId = match.Id;
                        ths.Add(th);
                    }
                    dbMgr.Save <Th>(ths);

                    // Bat 저장
                    List <Bat> bats = new List <Bat>();
                    foreach (var th in match.Ths)
                    {
                        if (th.AwayBats != null)
                        {
                            foreach (var bat in th.AwayBats)
                            {
                                bat.ThId = th.Id;
                                bats.Add(bat);
                            }
                        }

                        if (th.HomeBats != null)
                        {
                            foreach (var bat in th.HomeBats)
                            {
                                bat.ThId = th.Id;
                                bats.Add(bat);
                            }
                        }
                    }
                    dbMgr.Save <Bat>(bats);

                    // Ball 저장
                    List <Ball> balls = new List <Ball>();
                    foreach (var th in match.Ths)
                    {
                        if (th.AwayBats != null)
                        {
                            foreach (var bat in th.AwayBats)
                            {
                                foreach (var ball in bat.Balls)
                                {
                                    ball.BatId = bat.Id;
                                    balls.Add(ball);
                                }
                            }
                        }

                        if (th.HomeBats != null)
                        {
                            foreach (var bat in th.HomeBats)
                            {
                                foreach (var ball in bat.Balls)
                                {
                                    ball.BatId = bat.Id;
                                    balls.Add(ball);
                                }
                            }
                        }
                    }
                    dbMgr.Save <Ball>(balls);
                }
            }
            finally
            {
            }
        }