Пример #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var config = new Configuration();
                config.GetConfiguration();

                var directory = new DirectoryInfo(Globe.RootDir + "ligler\\");
                var leagueDir = directory.GetDirectories();

                foreach (DirectoryInfo league in leagueDir)
                {
                    var updateDB = new UpdateDataBase(league.Name, league.FullName);
                    await Task.Factory.StartNew(() =>
                    {
                        updateDB.LoadFolder();
                        updateDB.LoadFolder2();
                    });
                }
            }
            catch (Exception ex)
            {
                Globe.WriteLog("Veritabanına yazamadım : " + ex.Message);
            }
        }
Пример #2
0
        private void ReadConfig()
        {
            Globe.ConfigDic.Clear();

            try
            {
                StreamReader configReader = new StreamReader(Globe.ConfigFile, Encoding.Default);

                string line = string.Empty;

                while (line != null)
                {
                    line = configReader.ReadLine();

                    if (line != null && !line.Equals(string.Empty) && !line.StartsWith("//"))
                    {
                        string[] temp = line.Split('=');
                        Globe.ConfigDic.Add(temp[0].Trim(), temp[1].Trim());
                    }
                }

                configReader.Close();
            }
            catch (Exception ex)
            {
                Globe.WriteLog("Configuration.ReadConfig: " + ex.Message);
            }
        }
Пример #3
0
        private async void btnMacBilgileri_Click(object sender, EventArgs e)
        {
            try
            {
                CheckForIllegalCrossThreadCalls = false;
                var config = new Configuration();
                config.GetConfiguration();
                lstMacBilgileri.Items.Clear();

                var directory = new DirectoryInfo(Globe.RootDir + "ligler\\");
                var leagueDir = directory.GetDirectories();

                foreach (DirectoryInfo league in leagueDir)
                {
                    await Task.Factory.StartNew(() =>
                    {
                        var updateDB = new UpdateDataBase(league.Name, league.FullName);
                        updateDB.LoadFolder(VeriTabaniWriter);
                        lstMacBilgileri.SelectedIndex = lstMacBilgileri.Items.Count - 1;
                    });
                }
            }
            catch (Exception ex)
            {
                Globe.WriteLog("Veritabanına yazamadım : " + ex.Message);
            }
        }
Пример #4
0
        private void btnTurkiyeLigi_Click(object sender, EventArgs e)
        {
            var config = new Configuration();

            config.GetTurkConfiguration();

            try
            {
                var spider = new SpiderAsync();
                spider.GetAllLeagues();
            }
            catch (Exception ex)
            {
                Globe.WriteLog("Lig klasörlerini oluştururken bir sorun oluştu : " + ex.Message);
            }

            try
            {
                var spider = new SpiderAsync();
                spider.GetAllMatches(MaclarWriter, MacWriter);
            }
            catch (Exception ex)
            {
                Globe.WriteLog("Maç dosyalarını oluştururken bir sorun oluştu : " + ex.Message);
            }
        }
Пример #5
0
        private void InsertData2(MatchInfo matchInfo)
        {
            //Maç bilgileri haricinde takım ve oyunucu istatistiklerini dolduruyor.
            DAL dal = new DAL();

            if (matchInfo.League == "England_BarclaysPL" || matchInfo.League == "Germany-Bundesliga" || matchInfo.League == "Brazil_LigaDoBrasil" || matchInfo.League == "Italy-Serie-A" || matchInfo.League == "Spain-La-Liga" || matchInfo.League == "League 1" || matchInfo.League == "Netherlands-Eredivisie" || matchInfo.League == "Russia-Premier-League" || matchInfo.League == "Major League Soccer" || matchInfo.League == "Turkey-Super-Lig" || matchInfo.League == "Championship" || matchInfo.League == "Europe-UEFA-Champions-League" || matchInfo.League == "UEFA Europa League")
            {
                if (matchInfo.HomeTeamStatistics.rating > 0 || matchInfo.AwayTeamStatistics.rating > 0)
                {
                    dal.InsertTeamStatistics(matchInfo.HomeTeamStatistics, matchInfo.League, matchInfo.id, true);
                    dal.InsertTeamStatistics(matchInfo.AwayTeamStatistics, matchInfo.League, matchInfo.id, false);
                }

                if (matchInfo.HomeTeamPlayerStatistics[0] != null)
                {
                    foreach (PlayerStatistics player in matchInfo.HomeTeamPlayerStatistics)
                    {
                        dal.InsertPlayerStatistics(player, matchInfo.HomeTeamStatistics.id, matchInfo.HomeTeamStatistics.name, matchInfo.League, matchInfo.id, true);
                    }

                    foreach (PlayerStatistics player in matchInfo.AwayTeamPlayerStatistics)
                    {
                        dal.InsertPlayerStatistics(player, matchInfo.AwayTeamStatistics.id, matchInfo.AwayTeamStatistics.name, matchInfo.League, matchInfo.id, false);
                    }
                }
            }
            else
            {
                Globe.WriteLog(matchInfo.League + " istatistik çekilecek bir lig değil!!!");
            }
        }
Пример #6
0
        private void InitializeUpdateDBFlag()
        {
            if (Globe.ConfigDic.ContainsKey(Globe.CONFIG_UPDATE_DB))
            {
                string updateDBFlag = string.Empty;
                Globe.ConfigDic.TryGetValue(Globe.CONFIG_UPDATE_DB, out updateDBFlag);

                try
                {
                    Globe.UpdateDBFlag = Convert.ToBoolean(int.Parse(updateDBFlag));
                }
                catch (Exception ex)
                {
                    Globe.WriteLog("Configuration.InitializeUpdateDBFlag: " + ex.Message);
                }
            }
        }
Пример #7
0
        private void InsertData(MatchInfo matchInfo)
        {
            // Tüm bilgileri dolduruyor.

            DAL dal = new DAL();

            dal.InsertMatchInformation(matchInfo);

            try
            {
                if (matchInfo.HomeTeamStatistics.rating > 0 || matchInfo.AwayTeamStatistics.rating > 0 || !matchInfo.HomeTeamStatistics.rating.Equals(null) || !matchInfo.AwayTeamStatistics.rating.Equals(null))
                {
                    dal.InsertTeamStatistics(matchInfo.HomeTeamStatistics, matchInfo.League, matchInfo.id, true);
                    dal.InsertTeamStatistics(matchInfo.AwayTeamStatistics, matchInfo.League, matchInfo.id, false);
                }
            }
            catch (Exception ex)
            {
                Globe.WriteLog(string.Empty + matchInfo.id + " : Takım istatistikleri olmadığından yazılamadı.\n HATA : " + ex);
            }

            try
            {
                if (matchInfo.HomeTeamPlayerStatistics[0] != null)
                {
                    foreach (PlayerStatistics player in matchInfo.HomeTeamPlayerStatistics)
                    {
                        dal.InsertPlayerStatistics(player, matchInfo.HomeTeamStatistics.id, matchInfo.HomeTeamStatistics.name, matchInfo.League, matchInfo.id, true);
                    }

                    foreach (PlayerStatistics player in matchInfo.AwayTeamPlayerStatistics)
                    {
                        dal.InsertPlayerStatistics(player, matchInfo.AwayTeamStatistics.id, matchInfo.AwayTeamStatistics.name, matchInfo.League, matchInfo.id, false);
                    }
                }
            }

            catch (Exception ex)
            {
                Globe.WriteLog(string.Empty + matchInfo.id + " : Oyuncu istatistikleri olmadığından yazılamadı.\n HATA : " + ex);
            }
        }
Пример #8
0
        private void InitializeTime()
        {
            if (Globe.ConfigDic.ContainsKey(Globe.CONFIG_WORK_TIME))
            {
                string workTime = string.Empty;
                Globe.ConfigDic.TryGetValue(Globe.CONFIG_WORK_TIME, out workTime);

                try
                {
                    string[] temp = workTime.Split(':');
                    //Yazılı zamanı saat ve dakika olarak ikiye bölüyor
                    Globe.WorkTime_Hour   = int.Parse(temp[0]);
                    Globe.WorkTime_Minute = int.Parse(temp[1]);
                }
                catch (Exception ex)
                {
                    Globe.WriteLog("Configuration.InitializeTime: " + ex.Message);
                }
            }
        }
Пример #9
0
        private void btnMaclar_Click(object sender, EventArgs e)
        {
            CheckForIllegalCrossThreadCalls = false;
            var config = new Configuration();

            config.GetConfiguration();
            lstMaclar.Items.Clear();
            try
            {
                var spider = new SpiderAsync();
                Task.Factory.StartNew(() =>
                {
                    spider.GetAllMatches(MaclarWriter, MacWriter);
                    MessageBox.Show(@"İşlem Bitti");
                });
            }
            catch (Exception ex)
            {
                Globe.WriteLog("Lig klasörlerini oluştururken bir sorun oluştu : " + ex.Message);
            }
        }
Пример #10
0
        public void LoadFolder(Action <string> VeriTabaniWriter = null)
        {
            DirectoryInfo directory = new DirectoryInfo(LeagueDir);

            FileInfo[] fileInfos = directory.GetFiles();
            //klasör altındaki dosyaları fileInfos dizisine ekledi

            DAL        dal = new DAL();
            List <int> originalMatchIDs = dal.GetOriginalMatchIDs();
            List <int> originalPlayerStatisticsMatchIDs = dal.GetOriginalPlayerStatisticsMatchIDs();
            List <int> originalTeamStatisticsMatchIDs   = dal.GetOriginalTeamStatisticsMatchIDs();

            //veritabanında kayıtlı olanları originalMatchIDs listesine aldı

            if (fileInfos.Length > 0)
            {
                Console.WriteLine(LeagueName + ": yükleniyor...");

                foreach (FileInfo file in fileInfos)
                {
                    if (file.Length < Globe.IncorrectFileSize)
                    {
                        continue;
                    }
                    //dosya uzunluğu 5 Mb altındaysa atla

                    string fileName = Path.GetFileNameWithoutExtension(file.FullName);
                    //string fileName = "865781";
                    if (fileName.Contains("_Teams"))
                    {
                        continue;
                    }

                    if (fileName.Equals("LiveScores") || originalMatchIDs.Contains(int.Parse(fileName)) || originalPlayerStatisticsMatchIDs.Contains(int.Parse(fileName)) || originalTeamStatisticsMatchIDs.Contains(int.Parse(fileName)))
                    {
                        continue;
                    }

                    //Uzantısız Dosya adı Livescores olan ya da veri tabanında kayıtlı olan dosya isimleri varsa atla

                    try
                    {
                        HtmlContent = Globe.LoadFile(file.FullName);
                        //string htmlContent = Globe.LoadFile("C:\\WhoScored-master\\htmlContent\\Italy-Serie-A\\865781.txt");
                    }
                    catch (Exception ex)
                    {
                        Globe.WriteLog(fileName + " : Kaynak çekilemeyen dosya!!! " + ex);
                    }

                    //dosya kaynağını htmlContent'e ata
                    ContentFilter filter = new ContentFilter();

                    try
                    {
                        matchInfo = filter.MacBilgisiOlusturYontem1(int.Parse(fileName), LeagueName, HtmlContent);
                        if (matchInfo.awayid == 0)
                        {
                            matchInfo = filter.MacBilgisiOlusturYontem2(int.Parse(fileName), LeagueName, HtmlContent);
                        }
                    }
                    catch (Exception)
                    {
                        Globe.WriteLog("Hatalı kaynak kodu!!!");
                    }
                    //MatchInfo matchInfo = filter.GetMatchInfo(int.Parse(fileName), LeagueName, HtmlContent);
                    //maç idsi,lig adı ve kaynağa göre maç bilgisini çek.

                    try
                    {
                        InsertData(matchInfo);
                        VeriTabaniWriter?.Invoke(LeagueName + " - " + int.Parse(fileName));
                    }
                    catch (Exception ex)
                    {
                        Globe.WriteLog("Veritabanına yazılamayan maç. Kaynağı kontrol et: " + file.FullName + " " + ex.Message);
                    }
                }
            }
        }