private static void InsertCassette(string path, CashMachine atm) { var reader = ReaderSelector.Select(path); if (reader == null) { Console.WriteLine(ConsoleLanguagePack.FormatIsntDetected); return; } try { atm.InsertCassettes(reader.Read(path)); } catch (FileNotFoundException) { Console.WriteLine(ConsoleLanguagePack.FileNotFound); return; } catch (SerializationException) { Console.WriteLine(ConsoleLanguagePack.FileCantBeRead); return; } Console.WriteLine(ConsoleLanguagePack.ReadSuccessfully); }
private void InsertCassettesCommand() { var reader = ReaderSelector.Select(_parametres); if (reader == null) { Console.WriteLine(ConsoleLanguagePack.FormatIsntDetected); _result = true; } try { if (reader != null) { _atm.InsertCassettes(reader.Read(_parametres)); } } catch (FileNotFoundException) { Console.WriteLine(ConsoleLanguagePack.FileNotFound); _result = true; } catch (SerializationException) { Console.WriteLine(ConsoleLanguagePack.FileCantBeRead); _result = true; } catch { _result = false; } Console.WriteLine(ConsoleLanguagePack.ReadSuccessfully); _result = true; }
private void inputCassettesToolStripMenuItem_Click(object sender, EventArgs e) { var openFileDialog = new OpenFileDialog { Filter = @"Json (*.json)|*.json|Xml (*.xml*)|*.xml*|CSV (*.csv*)|*.csv*" }; if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } var reader = ReaderSelector.Select(openFileDialog.FileName); Atm.InsertCassettes(reader.Read(openFileDialog.FileName)); buttonEnter.Enabled = true; }
private void buttonInsertCassettes_Click(object sender, EventArgs e) { listBoxMoney.Items.Clear(); string pathToMoney = "PathToMoney"; string extension = comboBoxExtension.Text; _cassetteReader = ReadersCollection.GetReader(extension); if (_cassetteReader != null) { pathToMoney += extension; List <Cassette> cassettes = _cassetteReader.LoadCassettes(ConfigurationManager.AppSettings[pathToMoney]); if (cassettes != null) { _atm.InsertCassettes(cassettes); } DisplayMoney(_atm.AllMoney); } }
private void InsertCassettes() { string pathToMoney = "PathToMoney"; string extension = _secondParam; ICassetteReader <List <Cassette> > cassetteReader = ReadersCollection.GetReader(extension); if (cassetteReader != null) { pathToMoney += extension; List <Cassette> cassettes = cassetteReader.LoadCassettes(ConfigurationManager.AppSettings[pathToMoney]); if (cassettes != null) { _atm.InsertCassettes(cassettes); } } _result = true; }