/// <inheritdoc />
        public override async Task HandleClickAsync()
        {
            loader.OnLoadingStarted();

            IReadOnlyCollection <string> valueViews;

            try
            {
                valueViews = await parameterValues
                             .MostRecentAsync()
                             .OrderBy(view => view.Link.Name)
                             .Select(view => $"{view.Link.Name,-36}{view.Value}")
                             .ToArrayAsync();
            }
            catch (Exception exception)
            {
                messageBox.Error("failed to load values from host app", exception);
                return;
            }
            finally
            {
                loader.OnLoadingFinished();
            }

            outputWindow
            .Titled("calculated values")
            .Show(valueViews);

            if (!valueViews.Any())
            {
                messageBox.Info("unable to load parameter values", "there are no any calculated values found!");
            }
        }
예제 #2
0
        public static IMessageBox Error([NotNull] this IMessageBox definition, [CanBeNull] IResult result)
        {
            if (definition == null)
            {
                throw new ArgumentNullException(nameof(definition));
            }

            return(definition.Error((result?.HasError ?? false) ? null : result?.ErrorDescription));
        }
예제 #3
0
        public static IMessageBox Error([NotNull] this IMessageBox definition, [NotNull] Exception exception)
        {
            if (definition == null)
            {
                throw new ArgumentNullException(nameof(definition));
            }

            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }

            return(definition.Error(exception.GetOriginalMessage()));
        }
        /// <summary>
        /// Export parameter values to file.
        /// </summary>
        private async Task ExportOnConfirmed()
        {
            loader.OnLoadingStarted();
            NonEmptyString fileName;

            try
            {
                var values = await parameterValues.MostRecentAsync().ToArrayAsync();

                fileName = await valuesExport.ExportAsync(values);
            }
            catch (Exception exception)
            {
                messageBox.Error("failed to export values", exception);
                return;
            }
            finally
            {
                loader.OnLoadingFinished();
            }

            messageBox.Info("values are exported successfully", $"script file name: '{fileName}'");
        }