public override async Task ExecuteAsync() { var vstDirectories = (from vstDirectory in GlobalService.RuntimeConfiguration.VstDirectories where vstDirectory.Active select vstDirectory).ToList(); ApplicationService.StartApplicationOperation(this, "Scanning VST directories for plugins", vstDirectories.Count); var progress = ApplicationService.GetApplicationProgress(); try { var vstPluginDLLFiles = _pluginService.GetPluginDlls(vstDirectories, progress); var plugins = GlobalService.Plugins; ApplicationService.StopApplicationOperation("VST directory scan completed."); if (!progress.CancellationToken.IsCancellationRequested) { ApplicationService.StartApplicationOperation(this, "Adding / Verifying plugins", plugins.Count); var pluginsToAdd = await _pluginService.VerifyPlugins(plugins, vstPluginDLLFiles, ApplicationService.GetApplicationProgress()) .ConfigureAwait(false); using (plugins.SuspendChangeNotifications()) { plugins.AddRange(pluginsToAdd); } ApplicationService.StopApplicationOperation("Verifying plugins complete"); } ApplicationService.StartApplicationOperation(this, "Saving plugins", vstDirectories.Count); _dataPersisterService.Save(); ApplicationService.StopApplicationOperation("Saving plugins complete"); } catch (Exception e) { ApplicationService.AddApplicationOperationError("An unexpected error occured: " + e.Message); LogTo.Debug(e.StackTrace); } ApplicationService.StopApplicationOperation(progress.CancellationToken.IsCancellationRequested ? "VST directory scan aborted." : "VST directory scan completed."); }
protected override async Task ExecuteAsync(object parameter) { var result = await _messageService.ShowAsync( "This action will remove the selected plugin(s) from the database. Note: If the plugins are still in " + "the configured VST directories, they will be analyzed again unless you disable them." + Environment.NewLine + Environment.NewLine + "This will also remove any imported presets for these plugins." + Environment.NewLine + Environment.NewLine + "Do you wish to continue?", "Remove Plugins: Please confirm", MessageButton.YesNo, MessageImage.Question); if (result == MessageResult.Yes) { var pluginsToRemove = _globalFrontendService.SelectedPlugins.ToList(); ApplicationService.StartApplicationOperation(this, "Removing plugins", pluginsToRemove.Count); var progress = ApplicationService.GetApplicationProgress(); var progressStatus = new CountProgress(pluginsToRemove.Count); foreach (var plugin in pluginsToRemove) { progressStatus.Current = pluginsToRemove.IndexOf(plugin); progressStatus.Status = $"Removing {plugin.PluginName} and associated presets. This may take up to several minutes."; progress.Progress.Report(progressStatus); await _dispatcherService.InvokeAsync(async() => { _globalService.Plugins.Remove(plugin); }); _dataPersister.DeletePresetsForPlugin(plugin); await _presetDataPersister.DeletePresetDataForPlugin(plugin, true); } progressStatus.Status = $"Compacting database. This may take up to several minutes."; progress.Progress.Report(progressStatus); await _presetDataPersister.VacuumDatabase(); _dataPersister.Save(); ApplicationService.StopApplicationOperation("Finished removing plugins"); } }
public void Save() { _dataPersister.Save(); }
protected override async Task ExecuteAsync(object parameter) { var pluginsToReport = GetPluginsToReport(); var pluginReport = JObject.FromObject(new { pluginSubmission = new { email = _licenseService.GetCurrentLicense().Customer.Email, plugins = from p in pluginsToReport where p.PluginLocation != null orderby p.VstPluginId select new { vendorName = p.PluginVendor, pluginName = p.PluginName, pluginId = p.VstPluginId, pluginSupported = p.IsSupported, pluginPresetParser = p.PresetParser != null ? p.PresetParser.PresetParserType : "", pluginSupportedSince = GlobalService.PresetMagicianVersion, pluginType = p.PluginTypeDescription, dllHash = p.PluginLocation.DllHash, pluginCapabilities = p.PluginCapabilities, pluginRemarks = p.PresetParser != null ? p.PresetParser.Remarks : "" } } }); HttpContent content = new StringContent(pluginReport.ToString()); var client = new HttpClient(); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); // List data response. try { var response = await client.PostAsync(GetPluginReportSite(), content); if (response.StatusCode == HttpStatusCode.OK) { _applicationService.ReportStatus("Report submitted successfully"); pluginsToReport.ForEach(c => c.IsReported = true); _dataPersisterService.Save(); } else { _applicationService.ReportStatus("An error occured during report submission; see log for details"); var responseString = await response.Content.ReadAsStringAsync(); LogTo.Error(responseString); } } catch (HttpRequestException e) { _applicationService.ReportStatus("An error occured during report submission; see log for details"); LogTo.Error(e.ToString()); } base.Execute(parameter); }
protected override async Task ExecuteThreaded(object parameter) { var pluginsToScan = GetPluginsToScan(); var pluginsToUpdateMetadata = (from p in GlobalService.Plugins where p.RequiresMetadataScan orderby p.PluginName, p.DllFilename select p).ToList(); _applicationService.StartApplicationOperation(this, "Analyzing VST plugins: Loading missing metadata", pluginsToUpdateMetadata.Count); var pluginsToRemove = new List <Plugin>(); var mergedPlugins = new List <(Plugin oldPlugin, Plugin mergedIntoPlugin)>(); var progress = _applicationService.GetApplicationProgress(); // First pass: Load missing metadata try { var result = await TaskHelper.Run( async() => await _pluginService.UpdateMetadata(pluginsToUpdateMetadata, progress), true, progress.CancellationToken); pluginsToRemove = result.removedPlugins; mergedPlugins = result.mergedPlugins; await _dispatcherService.InvokeAsync(() => { foreach (var plugin in pluginsToRemove) { GlobalService.Plugins.Remove(plugin); if (pluginsToScan.Contains(plugin)) { pluginsToScan.Remove(plugin); } } }); } catch (Exception e) { _applicationService.AddApplicationOperationError( $"Unable to update metadata because of {e.GetType().FullName}: {e.Message}"); LogTo.Debug(e.StackTrace); } _applicationService.StopApplicationOperation("Analyzing VST plugins Metadata analysis complete."); if (mergedPlugins.Count > 0) { var sb = new StringBuilder(); foreach (var merge in (from p in mergedPlugins orderby p.oldPlugin.LastKnownGoodDllPath select p)) { sb.AppendLine( $"{merge.oldPlugin.LastKnownGoodDllPath} => {merge.mergedIntoPlugin.LastKnownGoodDllPath}"); } var result = await _messageService.ShowAsync( "Automatically merged different plugin DLLs to the same plugin. Affected plugin(s):" + Environment.NewLine + Environment.NewLine + sb + Environment.NewLine + Environment.NewLine + "Would you like to abort the analysis now, so that you can review the settings for each affected plugin? (Highly recommended!)", "Auto-merged Plugins", HelpLinks.SETTINGS_PLUGIN_DLL, MessageButton.YesNo, MessageImage.Question); if (result == MessageResult.Yes) { // ReSharper disable once MethodSupportsCancellation _dataPersisterService.Save(); _commandManager.ExecuteCommand(Commands.Application.CancelOperation); } } if (!progress.CancellationToken.IsCancellationRequested && !SkipPresetLoading) { _applicationService.StartApplicationOperation(this, "Analyzing VST plugins", pluginsToScan.Count); progress = _applicationService.GetApplicationProgress(); await TaskHelper.Run( async() => await AnalyzePlugins(pluginsToScan.OrderBy(p => p.PluginName).ToList(), progress.CancellationToken), true, progress.CancellationToken); // ReSharper disable once MethodSupportsCancellation _dataPersisterService.Save(); } if (progress.CancellationToken.IsCancellationRequested) { _applicationService.StopApplicationOperation("Plugin analysis cancelled."); } else { _applicationService.StopApplicationOperation("Plugin analysis completed."); } var unreportedPlugins = (from plugin in GlobalService.Plugins where !plugin.IsReported && !plugin.DontReport && !plugin.IsSupported && plugin.HasMetadata && plugin.IsEnabled select plugin).ToList(); if (unreportedPlugins.Any()) { var result = await _messageService.ShowCustomRememberMyChoiceDialogAsync( "There are unsupported plugins which are not reported." + Environment.NewLine + "Would you like to report them, so we can implement support for them?", "Report Unsupported Plugins", null, MessageButton.YesNo, MessageImage.Question, "Don't ask again for the currently unreported plugins"); if (result.result == MessageResult.Yes) { _commandManager.ExecuteCommand(Commands.Plugin.ReportUnsupportedPlugins); } if (result.dontChecked) { foreach (var plugin in unreportedPlugins) { plugin.DontReport = true; } _dataPersisterService.Save(); } } }