Exemplo n.º 1
0
        private static void DownloadAndParseAndStoreScores(string sport, string directoryRepo)
        {
            var dir    = System.IO.Directory.CreateDirectory("../../../Data/" + sport);
            var sqlite = new UtilityDAL.Sqlite.KeyValueLite(dir.FullName);

            foreach (var(date, directory) in from directory in Directory.EnumerateDirectories(directoryRepo)
                     let name = Path.GetFileName(directory)
                                where Common.FileNameHelper.TryGetDateFromDirectoryName(name, out _)
                                where sqlite.FindDate(directory) == null
                                let date = Common.FileNameHelper.GetDateTimeFromDirectory(name)
                                           select
                                               (date, directory))
            {
                var info = MatchRepository.SelectInformation(directory);

                //var ids = Smarkets.DAL.Sqlite.MatchRepository.Select(date).Select(a => a.EventId.ToString()).ToArray();
                var newResults = Download2(100, date, info.Select(a => a.id.ToString()).ToArray());

                Console.WriteLine($"results downloaded {newResults.Count()}");
                foreach (var(ifo, newResult) in from ifo in info
                         join newResult in newResults
                         on ifo.id.ToString() equals newResult.id
                         select(ifo, newResult))
                {
                    int transferred = MatchRepository.TransferToDB(newResult.Item2, ifo.name);
                    Console.WriteLine($"results added {transferred}");
                    Console.Write(ifo.name);
                    Console.Write(ifo.id);
                }

                sqlite.Insert(new KeyValuePair <string, long>(directory, date.Ticks));
            }
            Console.WriteLine("Finished");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        private static void DownloadAndParseAndStoreScores2(string sport, string directoryRepo)
        {
            var dir    = Directory.CreateDirectory("../../../Data/" + sport);
            var kvLite = new UtilityDAL.Sqlite.KeyValueLite(dir.FullName);

            using var sqlite = new SQLite.SQLiteConnection(Path.Combine(dir.FullName, "Teams.sqlite"));
            var results = sqlite.Table <Result>().ToArray();

            foreach (var(date, directory) in from directory in Directory.EnumerateDirectories(directoryRepo)
                     let name = Path.GetFileName(directory)
                                where Common.FileNameHelper.TryGetDateFromDirectoryName(name, out _)
                                where kvLite.FindDate(directory) == null
                                let date = Common.FileNameHelper.GetDateTimeFromDirectory(name)
                                           select
                                               (date, directory))
            {
                foreach ((string ifo, Result result) in from ifo in MatchRepository.SelectInformation(directory)
                         join result in results
                         on ifo.id equals result.Id
                         select(ifo.name, result))
                {
                    Console.WriteLine(ifo);
                    var newResults = Map.ResultMap.ToResults(result);
                    try
                    {
                        int transferred = MatchRepository.TransferToDB(newResults, ifo);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.ReadLine();
                    }
                }
                kvLite.Insert(new KeyValuePair <string, long>(directory, date.Ticks));
            }
            Console.WriteLine("Finished");
            Console.ReadLine();
        }