private void SaveNewTrainingEntry(TrainingEntry entry) { SQLiteCommand command = new SQLiteCommand(); command.CommandText = "INSERT INTO training_entries(word, phonetics) VALUES(@word, @phonetics)"; command.Connection = _connection; command.Parameters.AddWithValue("@word", entry.Word); command.Parameters.AddWithValue("@phonetics", entry.Phonetics); command.ExecuteNonQuery(); entry.ID = GetMaxID("training_entries"); }
public TrainingEntry GetEntry(String word) { if (_entriesWordIndex.ContainsKey(word)) { return(_entriesWordIndex[word]); } TrainingEntry entry = new TrainingEntry(); entry.Word = word; _entriesWordIndex.Add(word, entry); _content.Add(entry); return(entry); }
private void SaveNewAudioFile(TrainingAudioFile file, TrainingEntry entry, int index) { SQLiteCommand command = new SQLiteCommand(); command.CommandText = $"INSERT INTO audio_files(file_name, format, sampling_rate, bit_rate, entry_id, provider) VALUES(@file_name, {(int)file.AudioFormat}, {file.AudioSamplingRate}, {file.AudioBitrateInKB}, {entry.ID}, @provider)"; command.Connection = _connection; String fileName = $"{entry.ID}_{index}.{GetExtension(file.AudioFormat)}"; command.Parameters.AddWithValue("@file_name", fileName); command.Parameters.AddWithValue("@provider", file.Provider); command.ExecuteNonQuery(); File.WriteAllBytes(GetAudioDirectory() + fileName, file.RawContent); file.ID = -1; }
private void LoadTrainingEntries() { SQLiteCommand command = new SQLiteCommand("SELECT * FROM training_entries", _connection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { TrainingEntry entry = new TrainingEntry(); entry.ID = Convert.ToInt32(reader["id"]); entry.Word = Convert.ToString(reader["word"]); entry.Phonetics = Convert.ToString(reader["phonetics"]); _content.Add(entry); _entriesWordIndex.Add(entry.Word, entry); _entriesIDIndex.Add(entry.ID, entry); } reader.Close(); }