private async void OnRecordingSnugglerAbort(AbortType abortType) { if (abortType == AbortType.TimeOut) { IAudioService audioService = new NAudioService(); IDataStorage dataStorage = new MongoDatabaseHandler(conectionString, "Shaitan", "Songs", "Hash"); var result = await QueryCommandBuilder.Instance.BuildQueryCommand() .From(recorderSnuggler.FilePath) .UsingServices(dataStorage, audioService) .Query(); if (result.BestMath != null) { var notificationManager = new NotificationManager(); notificationManager.Show(new NotificationContent { Title = result.BestMath.Title, Message = result.BestMath.Artist, Type = NotificationType.Success }); prevMatch = result.BestMath; isNoty = true; } } isRecordingSunn = !isRecordingSunn; }
private async void RecognizeFile(string filePath) { DownImageVisibility = Visibility.Visible; IAudioService audioService = new NAudioService(); IDataStorage dataStorage = new MongoDatabaseHandler(conectionString, "Shaitan", "Songs", "Hash"); var result = await QueryCommandBuilder.Instance.BuildQueryCommand() .From(filePath) .UsingServices(dataStorage, audioService) .Query(); PushResultOrNoResultPape(result); }
private void InitSimilar(List <SongMatchCount> songMatches) { if (songMatches.Count > 0 && songMatches != null) { IDataStorage dataStorage = new MongoDatabaseHandler(conectionString, "Shaitan", "Songs", "Hash"); foreach (var item in songMatches) { Song song = dataStorage.GetSong(item.SongId); cards.Add(new LastLokingForModel(song.Title, song.Artist, item.Num)); } } else { return; } }
private async void HashAndQuery() { foreach (var item in cards) { IAudioService audioService = new NAudioService(); IDataStorage dataStorage = new MongoDatabaseHandler(conectionString, "Shaitan", "Songs", "Hash"); if (File.Exists(item.PathToFile)) { try { await FingerprintCommandBuilder.Instance.BuildFingerprintCommand() .From(item.PathToFile) .UsingAudioReaderServices(audioService) .UsingStorage(dataStorage) .Add(); } catch (Exception ex) { MakeNotification("Ошибка", $"Ошибка типа {ex.Message}. Добавление треков отмененно ", NotificationType.Error); cards.Clear(); IsDropAllow = true; IsHashingBtnEnable = true; ImageVisibility = Visibility.Hidden; return; } MakeNotification("Добавлен " + item.Title, $"Песня {item.Title} {item.Performer} успешна добавленна ", NotificationType.Information); ProgressValue += dx; } else { MakeNotification("Файл не найден", $"Путь к песне {item.Title} {item.Performer} не найден. Не беспокойтесь добавлнение остальных треков будет продолженно ", NotificationType.Warning); ProgressValue += dx; } } MakeNotification("Работа завершена", "Все успешно добавленно", NotificationType.Success); cards.Clear(); IsDropAllow = true; IsHashingBtnEnable = true; ImageVisibility = Visibility.Hidden; }