Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var files = Directory.GetFiles(@"C:\DATA\RetroSheet", "2014PIT*.EV*");

            var system          = ActorSystem.Create("baseball");
            var gameCoordinator = system.ActorOf <GameCoordinator>("gameCoordinator");

            foreach (var file in files)
            {
                Console.WriteLine("Processing {0}", file);
                using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read))
                {
                    var reader = new StreamReader(stream);
                    var gameId = "";
                    while (!reader.EndOfStream)
                    {
                        var item   = reader.ReadLine();
                        var record = GameRecordParser.Parse(item);

                        if (record is IdGameRecord)
                        {
                            gameId = ((IdGameRecord)record).Id;
                        }

                        var msg = new GameRecordMessage(gameId, record);

                        gameCoordinator.Tell(msg);
                    }

                    gameCoordinator.Tell(new EndOfFeed());
                }
                Console.WriteLine("Completed {0}", file);
            }

            Console.ReadLine();
        }
 private void ParseStartRecord()
 {
     _gameRecord = GameRecordParser.Parse(_startRecord) as SubGameRecord;
 }
Ejemplo n.º 3
0
 private void ParseStartRecord()
 {
     _gameRecord = GameRecordParser.Parse(_dataRecord) as DataGameRecord;
 }
Ejemplo n.º 4
0
 private void ParseStartRecord()
 {
     _gameRecord = GameRecordParser.Parse(_startRecord) as CommentGameRecord;
 }
Ejemplo n.º 5
0
 private void ParseStartRecord()
 {
     _gameRecord = GameRecordParser.Parse(_versionRecord) as VersionGameRecord;
 }
Ejemplo n.º 6
0
 private void ParseStartRecord()
 {
     _gameRecord = GameRecordParser.Parse(_playRecord) as PlayGameRecord;
 }
 private void ParseStartRecord()
 {
     _gameRecord = GameRecordParser.Parse(_infoRecord) as InfoGameRecord;
 }
Ejemplo n.º 8
0
        private static void ConvertGgfMenu()
        {
            var userChoice = 0;

            while (true)
            {
                userChoice = GetUserChoice(
                    "Convert GGF Menu", new[]
                {
                    "<- Back",
                    $"GGF file: {_ggfFilePath}",
                    $"Save to : {_saveConvertedFilePath}",
                    "Convert Now!"
                }, userChoice);

                if (userChoice == 0)
                {
                    return;
                }
                if (userChoice == 1)
                {
                    var tempPath       = (string)ConsoleUtil.Prompt("GGF file", _ggfFilePath);
                    var validExtension = FileUtils.CheckFileExtension(tempPath, ".ggf");
                    if (validExtension)
                    {
                        _ggfFilePath = tempPath;
                    }
                    else
                    {
                        ConsoleUtil.WriteAndWaitKey("[!] GGF file extension must be '.ggf'");
                    }
                }
                else if (userChoice == 2)
                {
                    var tempPath       = (string)ConsoleUtil.Prompt("Save to", _saveConvertedFilePath);
                    var validExtension = FileUtils.CheckFileExtension(tempPath, ".txt");
                    if (validExtension)
                    {
                        _saveConvertedFilePath = tempPath;
                    }
                    else
                    {
                        ConsoleUtil.WriteAndWaitKey("[!] Game-record file extension must be '.txt'");
                    }
                }
                else
                {
                    try
                    {
                        var parser = new GameRecordParser();
                        parser.Parse(_ggfFilePath);
                        parser.SaveParsedGame(_saveConvertedFilePath);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"[!] ERROR: {e}");
                    }

                    ConsoleUtil.WriteAndWaitKey("> Convert GGF End.");
                }
            }
        }