Commit fea09579 authored by Francesco Carraro's avatar Francesco Carraro
Browse files

almost completed multiple selection processing

parent a9dac9ca
Loading
Loading
Loading
Loading
+13 KiB
Loading image diff...
+1.12 MiB
Loading image diff...
+24 −0
Original line number Diff line number Diff line
@@ -269,6 +269,30 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters
        }
    }

    public sealed class SelectedFilesNumVisibilityInverseConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            try
            {
                int selectedFilesNum = (int)value;
                if (selectedFilesNum > 0)
                    return Visibility.Collapsed;
                else
                    return Visibility.Visible;
            }
            catch (Exception)
            {
                return Visibility.Visible;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }

    public sealed class ShortFilepathConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
+7 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ using INAF.Libraries.Uwp.Logging;
using INAF.Libraries.Uwp.StorageItemsAccess;
using System;
using System.Threading.Tasks;
using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums;

namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders
{
@@ -25,5 +26,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders
        {
            throw new NotImplementedException();
        }

        public virtual Task<(IChartSpectrumModel spectrum, string exMsg)> readFileAsync(string fileKey,
                                                                                        SpectrumType spectrumType)
        {
            throw new NotImplementedException();
        }
    }
}
+26 −22
Original line number Diff line number Diff line
@@ -22,9 +22,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders

        public new async Task<(IChartSpectrumModel spectrum, string exMsg)> readFileAsync(string fileKey)
        {
            IChartSpectrumModel spectrum = null;
            string exMsg = string.Empty;

            SpectrumType spectrumType = fileKey.ToSpectrumType();

            /* retrieve file from storage */
@@ -38,6 +35,32 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders
                return (null, "SpectrumFileNotFoundMessage".GetText());
            }

            return await readFileCommonAsync(file, spectrumType);
        }

        public new async Task<(IChartSpectrumModel spectrum, string exMsg)> readFileAsync(string fileKey,
                                                                                          SpectrumType spectrumType)
        {
            /* retrieve file from storage */
            StorageFile file = (StorageFile)await storageItemsAccessHelper.getAsync(fileKey);
            logger.Write<LabSpectrumFileReader>($"Reading file {file.Path}...", Serilog.Events.LogEventLevel.Information);

            /* handle file selection issue */
            if (file == null)
            {
                logger.Write<LabSpectrumFileReader>($"File {file.Path} NOT FOUND!", Serilog.Events.LogEventLevel.Error);
                return (null, "SpectrumFileNotFoundMessage".GetText());
            }

            return await readFileCommonAsync(file, spectrumType);
        }

        private async Task<(IChartSpectrumModel spectrum, string exMsg)> readFileCommonAsync(StorageFile file,
                                                                                             SpectrumType spectrumType)
        {
            IChartSpectrumModel spectrum = null;
            string exMsg = string.Empty;

            await Task.Run(async () =>
            {
                /* read all lines from file... */
@@ -81,12 +104,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders
                    {
                        isError = true;
                        logger.Write<LabSpectrumFileReader>($"Erro while reading file {file.Path} - ex: {ex.Message}", Serilog.Events.LogEventLevel.Error);

                        //UpdateUIHelper.UpdateUIAsync(() =>
                        //{
                        //    spectraContainer.tryGetSummaryOfType(spectrumType).updateReadingMessage("SpectrumFileReadingErrorMessage".GetText());
                        //    spectraContainer.tryGetSummaryOfType(spectrumType).updateReadingStatus(FileReadingStatus.Error);
                        //});
                    }
                });
                if (isError)
@@ -100,27 +117,14 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders
                {
                    logger.Write<LabSpectrumFileReader>($"No elements retrieved for spectrum!", Serilog.Events.LogEventLevel.Error);

                    //UpdateUIHelper.UpdateUIAsync(() =>
                    //{
                    //    spectraContainer.tryGetSummaryOfType(spectrumType).updateReadingMessage("SpectrumFileNoSpectrumMessage".GetText());
                    //    spectraContainer.tryGetSummaryOfType(spectrumType).updateReadingStatus(FileReadingStatus.Error);
                    //});
                    exMsg = "SpectrumFileNoSpectrumMessage".GetText();
                    return;
                }


                if (spectrum.Elements.Count < (linesNum - 1))
                {
                    logger.Write<LabSpectrumFileReader>($"Retrieved only {spectrum.Elements.Count} elements while file lines num is  {linesNum - 1}", Serilog.Events.LogEventLevel.Warning);

                    /* if retrieved lines num if lower than expected, than warn about possible issue in file content */
                    //UpdateUIHelper.UpdateUIAsync(() =>
                    //{
                    //    spectraContainer.tryGetSummaryOfType(spectrumType).updateReadingMessage("SpectrumFileMissingSpectrumLinesMessage".GetText());
                    //    spectraContainer.tryGetSummaryOfType(spectrumType).updateReadingStatus(FileReadingStatus.Error);
                    //});

                    exMsg = "SpectrumFileMissingSpectrumLinesMessage".GetText();
                    return;
                }
Loading