Пример #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ScoreBoardManager" /> class.
 ///     Precondition: none
 ///     Postcondition: A new scoreboard manager is created
 /// </summary>
 public ScoreBoardManager()
 {
     this.ScoreBoard = new ScoreBoard();
     this.FileReader = new FileReader();
     this.SaveFile   = new SaveFileWriter();
     this.viewModel  = new ScoreBoardViewModel();
 }
Пример #2
0
        private async void SaveAllEndButton_Click(object sender, RoutedEventArgs e)
        {
            var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description = "保存先フォルダを選択",
            };

            folderBrowserDialog.ShowDialog();
            var folder = folderBrowserDialog.SelectedPath;

            var saveFileWriter = new SaveFileWriter(folder);

            foreach (var std in StationReader.GetAllEnds())
            {
                await saveFileWriter.SaveTrainData(std.StationId);
            }
        }
Пример #3
0
        private async Task DataGeter(CancellationToken cancellationToken, IEnumerable <int> id, string saveFolderPath)
        {
            while (true)
            {
                var savePath = saveFolderPath + $"\\{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}";
                Directory.CreateDirectory(savePath);

                var saveFileWriter = new SaveFileWriter(savePath);
                await Task.Run(() =>
                {
                    Parallel.ForEach(id, async staId =>
                    {
                        try
                        {
                            await saveFileWriter.SaveTrainData(staId);
                            if (staId < 5)
                            {
                                LogText.WriteLine($"{DateTime.Now}: 広域データID{staId}を保存しました...");
                            }
                            else
                            {
                                LogText.WriteLine($"{DateTime.Now}: {StationReader.GetStationById(staId).Name}を保存しました...");
                            }
                        }
                        catch (TrainDataGetException ex)
                        {
                            LogText.WriteLine("通信中に例外が発生しました...");
                            throw;
                        }
                    });
                });

                LogText.WriteLine("取得プロセス一時停止(取得完了)...");
                await Task.Delay(DelayTime * 60 * 1000, cancellationToken);

                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }
            }
        }
Пример #4
0
        private async void SaveJsonButton_Click(object sender, RoutedEventArgs e)
        {
            if (TryGetStationId(StationIdTextBox.Text, out var id))
            {
                var saveFileDialog = new System.Windows.Forms.SaveFileDialog()
                {
                    FileName = SaveFileWriter.GetSaveFileName(id),
                    Filter   = "jsonファイル|*.json",
                };
                saveFileDialog.ShowDialog();

                var path = saveFileDialog.FileName;
                var data = await TrainInfoReader.GetTrainDataJsonAsync(id);

                SaveFileWriter.SaveJsonData(path, data);
            }
            else
            {
                MessageBox.Show("駅IDの入力が正しくありません。");
            }
        }
 public BackUpController()
 {
     _fileLocator = new SaveFileLocator();
     _fileReader = new SaveFileReader();
     _saveFileWriter = new SaveFileWriter();
 }