Ejemplo n.º 1
0
        public async Task <string> GetExtensionForFormat(string format)
        {
            var outputFormats = await _apiPortService.GetResultFormatsAsync();

            var outputFormat = outputFormats.Response.FirstOrDefault(f => string.Equals(format, f.DisplayName, StringComparison.OrdinalIgnoreCase));

            if (outputFormat == null)
            {
                throw new UnknownReportFormatException(format);
            }

            return(outputFormat.FileExtension);
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <string> > GetResultFormatsAsync()
        {
            using (var progressTask = _progressReport.StartTask(LocalizedStrings.RetrievingOutputFormats))
            {
                try
                {
                    var outputFormats = await _apiPortService.GetResultFormatsAsync();

                    CheckEndpointStatus(outputFormats.Headers.Status);

                    return(outputFormats.Response.Select(r => r.DisplayName).ToList());
                }
                catch (Exception)
                {
                    progressTask.Abort();
                    throw;
                }
            }
        }
Ejemplo n.º 3
0
        private async Task UpdateResultsAsync()
        {
            var response = await _apiPortService.GetResultFormatsAsync().ConfigureAwait(false);

            var current = new HashSet <string>(Formats.Where(f => f.IsSelected).Select(f => f.MimeType), StringComparer.OrdinalIgnoreCase);

            if (!current.Any())
            {
                var defaultResultFormat = await _apiPortService.GetDefaultResultFormatAsync().ConfigureAwait(false);

                current.Add(defaultResultFormat.Response.MimeType);
            }

            var formats = response.Response.Select(f => new SelectedResultFormat(f, current.Contains(f.MimeType))).ToList();

            UpdateResultFormats(formats);
        }
Ejemplo n.º 4
0
        private async Task UpdateResultsAsync()
        {
            var formats = await _apiPortService.GetResultFormatsAsync();

            var current = new HashSet <string>(Formats.Where(f => f.IsSelected).Select(f => f.MimeType), StringComparer.OrdinalIgnoreCase);

            if (current.Count == 0)
            {
                const string DefaultMimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                current.Add(DefaultMimeType);
            }

            Formats = formats.Response.Select(f => new SelectedResultFormat
            {
                DisplayName   = f.DisplayName,
                FileExtension = f.FileExtension,
                MimeType      = f.MimeType,
                IsSelected    = current.Contains(f.MimeType)
            }).ToList();
        }