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

fixed opening of available XML files; fixes

parent 5476b6cb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ namespace INAF.Apps.Uwp.SLabDataManager
                /* usercontrols viewmodels */
                .AddScoped<AlignmentViewModel>()
                .AddScoped<InfoMeasurementInfoViewModel>()
                .AddScoped<InfoSampleDataViewModel>()
                .AddSingleton<InfoSampleDataViewModel>()
                .AddSingleton<SegmentsFitViewModel>()
                .AddScoped<SmoothingViewModel>()
                .AddSingleton<UserControlsViewModelFactory>()
+4 −4
Original line number Diff line number Diff line
@@ -2,12 +2,12 @@
<logbook>
	<updates>
		<fixes>
			<fix>Fixed connection configuration</fix>
			<fix>Fixed error in saving spectrum sample data and measurement info</fix>
			<fix>Issue in retrieving saved grain sizes</fix>
			<!--<fix>Fixed management of sample data/measurement info panel when changing RAW file</fix>
			<fix>Fixed file deletion when changing RAW file</fix>-->
		</fixes>
		<!--<addings>
			<adding>Creation of averaged files from single acquisitions</adding>
			<adding>Save single acquisitions into DB as source of averaged file and retrieve as info</adding>
			<adding>Added percentage of minerals for mix</adding>
		</addings>-->
	</updates>
</logbook>
 No newline at end of file
+23 −23
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions
            return spectrum.Elements.Where(x => x.X >= xMin && x.X <= xMax);
        }

        private static double getXMax(ISpectrumModel spectrum,
        private static double getXMax(IChartSpectrumModel spectrum,
                                      double xMax,
                                      bool isXMaxHighestBoundary)
        {
@@ -103,7 +103,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions
            return xMax;
        }

        private static double getXMin(ISpectrumModel spectrum,
        private static double getXMin(IChartSpectrumModel spectrum,
                                      double xMin,
                                      bool isXMinLowestBoundary)
        {
@@ -158,7 +158,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions
            return xMin;
        }

        public static IEnumerable<ElementModel> GetLeftSegmentElements(this ISpectrumModel spectrum,
        public static IEnumerable<ElementModel> GetLeftSegmentElements(this IChartSpectrumModel spectrum,
                                                                       double xMin,
                                                                       bool isXMinLowestBoundary,
                                                                       double xMax,
@@ -178,7 +178,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions
            return spectrum.Elements.Where(x => x.X >= xMin && x.X <= xMax);
        }

        public static IEnumerable<ElementModel> GetRightSegmentElements(this ISpectrumModel spectrum,
        public static IEnumerable<ElementModel> GetRightSegmentElements(this IChartSpectrumModel spectrum,
                                                                       double xMin,
                                                                       bool isXMinLowestBoundary,
                                                                       double xMax,
@@ -198,7 +198,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions
            return spectrum.Elements.Where(x => x.X >= xMin && x.X <= xMax);
        }

        public static void UpdateElements(this ISpectrumModel spectrum,
        public static void UpdateElements(this IChartSpectrumModel spectrum,
                                          IEnumerable<ElementModel> elements)
        {
            foreach (var element in elements)
@@ -270,7 +270,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions
        }

        #region local files
        public static string ToTxt(this ISpectrumModel spectrum)
        public static string ToTxt(this IChartSpectrumModel spectrum)
        {
            if (spectrum == null || spectrum.Elements == null || spectrum.Elements.Count == 0)
                return null;
@@ -672,22 +672,22 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions
            return new SolidColorBrush(color);
        }

        public static IChartSpectrumModel ToChartSpectrumModel(this FileSpectrumModel fileSpectrum)
        {
            List<ElementModel> elements = new List<ElementModel>();
            foreach (var element in fileSpectrum.Elements)
            {
                elements.Add(new ElementModel(element.X, element.Y));
            }

            return new ChartSpectrumModel()
            {
                Id = fileSpectrum.Id,
                Filename = fileSpectrum.Filename,
                ParentId = fileSpectrum.ParentId,
                Type = fileSpectrum.Type,
                Elements = new ObservableCollection<ElementModel>(elements)
            };
        }
        //public static IChartSpectrumModel ToChartSpectrumModel(this FileSpectrumModel fileSpectrum)
        //{
        //    List<ElementModel> elements = new List<ElementModel>();
        //    foreach (var element in fileSpectrum.Elements)
        //    {
        //        elements.Add(new ElementModel(element.X, element.Y));
        //    }

        //    return new ChartSpectrumModel()
        //    {
        //        Id = fileSpectrum.Id,
        //        Filename = fileSpectrum.Filename,
        //        ParentId = fileSpectrum.ParentId,
        //        Type = fileSpectrum.Type,
        //        Elements = new ObservableCollection<ElementModel>(elements)
        //    };
        //}
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -102,13 +102,13 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders.SpectrumFiles
    public class DeserializedElement
    {
        [XmlAttribute(AttributeName = "Wavelength", DataType = "double")]
        public string Wavelength { get; set; }
        public double Wavelength { get; set; }

        [XmlAttribute(AttributeName = "Value", DataType = "double")]
        public string Value { get; set; }
        public double Value { get; set; }

        [XmlAttribute(AttributeName = "YStdDev", DataType = "double")]
        public string YStdDev { get; set; }
        public double YStdDev { get; set; }

        [XmlText]
        public string Text { get; set; }
+29 −20
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ using INAF.Apps.Uwp.SLabDataManager.Models.Chart;
using INAF.Libraries.Uwp.Logging;
using INAF.Libraries.Uwp.Settings;
using INAF.Libraries.Uwp.Xml;
using System;
using System.IO;
using System.Threading.Tasks;
using System.Xml.Serialization;
@@ -23,7 +24,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders
            this.xmlHelper = xmlHelper;
        }

        public new async Task<(IChartSpectrumModel spectrum, string exMsg)> readFileAsync(string fileKey)
        public async Task<(IChartSpectrumModel spectrum, string exMsg)> readFileAsync(string fileKey)
        {
            IChartSpectrumModel chartSpectrumModel = null;
            string exMsg = string.Empty;
@@ -42,13 +43,15 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders
            DeserializedSpectrum spectrumObj = null;

            await Task.Run(async () =>
            {
                try
                {
                    /* read all xml file */
                    XmlDocument dom = await xmlHelper.getXmlDocumentAsync(file);
                    if (dom == null)
                    {
                    logger.Write<XmlSpectrumFileReader>($"Error while parsing xml spectrum!", Serilog.Events.LogEventLevel.Error);
                    exMsg = "Error while parsing config.xml!";
                        logger.Write<XmlSpectrumFileReader>($"Error while parsing {file.Path}", Serilog.Events.LogEventLevel.Error);
                        exMsg = $"{"ProcessedReadingErrorMessage".GetText()} {file.Path}";
                        return;
                    }

@@ -62,12 +65,18 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders

                    if (spectrumObj == null)
                    {
                    logger.Write<XmlSpectrumFileReader>($"Error while deserializing xml spectrum!", Serilog.Events.LogEventLevel.Error);
                    exMsg = "Error while deserializing xml spectrum!";
                        logger.Write<XmlSpectrumFileReader>($"Error while deserializing {file.Path}", Serilog.Events.LogEventLevel.Error);
                        exMsg = $"{"ProcessedReadingErrorMessage".GetText()} {file.Path}";
                        return;
                    }
                }
                catch (Exception ex)
                {
                    exMsg = $"{"ProcessedReadingErrorMessage".GetText()} {file.Path}";
                }
            });

            if (string.IsNullOrEmpty(exMsg))
                chartSpectrumModel = spectraFactory.build(spectrumObj);

            return (chartSpectrumModel, exMsg);
Loading