public async void DownloadStoreData()
        {
            ProgressVisible = true;

            await Task.Run(() =>
            {
                try
                {
                    if (extensions.Plugins.TryGetValue(Game.PluginId, out var plugin))
                    {
                        if (LibraryPluginMetadataDownloader == null)
                        {
                            dialogs.ShowErrorMessage(
                                resources.GetString("LOCErrorNoMetadataDownloader"),
                                resources.GetString("LOCGameError"));
                            return;
                        }

                        var metadata = LibraryPluginMetadataDownloader.GetMetadata(EditingGame);
                        if (metadata != null)
                        {
                            Application.Current.Dispatcher.Invoke(() => PreviewGameData(metadata));
                        }
                    }
                    else
                    {
                        dialogs.ShowErrorMessage(
                            resources.GetString("LOCErrorLibraryPluginNotFound"),
                            resources.GetString("LOCGameError"));
                        return;
                    }
                }
                catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
                {
                    logger.Error(exc, string.Format("Failed to download metadata, {0}, {1}", Game.PluginId, Game.GameId));
                    dialogs.ShowMessage(
                        string.Format(resources.GetString("LOCMetadataDownloadError"), exc.Message),
                        resources.GetString("LOCDownloadError"),
                        MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    ProgressVisible = false;
                }
            });
        }
Exemplo n.º 2
0
        public void DownloadStoreData()
        {
            var res = dialogs.ActivateGlobalProgress((args) =>
            {
                if (extensions.Plugins.TryGetValue(Game.PluginId, out var plugin))
                {
                    if (LibraryPluginMetadataDownloader == null)
                    {
                        dialogs.ShowErrorMessage(
                            resources.GetString("LOCErrorNoMetadataDownloader"),
                            resources.GetString("LOCGameError"));
                        return;
                    }

                    var metadata = LibraryPluginMetadataDownloader.GetMetadata(EditingGame);
                    if (metadata != null)
                    {
                        Application.Current.Dispatcher.Invoke(() => PreviewGameData(ConvertGameInfo(metadata)));
                    }
                }
                else
                {
                    dialogs.ShowErrorMessage(
                        resources.GetString("LOCErrorLibraryPluginNotFound"),
                        resources.GetString("LOCGameError"));
                    return;
                }
            }, new GlobalProgressOptions(LOC.DownloadingLabel)
            {
                IsIndeterminate = true,
                Cancelable      = true
            });

            if (res.Error != null)
            {
                logger.Error(res.Error, string.Format("Failed to download metadata, {0}, {1}", Game.PluginId, Game.GameId));
                dialogs.ShowMessage(
                    string.Format(resources.GetString("LOCMetadataDownloadError"), res.Error.Message),
                    resources.GetString("LOCDownloadError"),
                    MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }