Exemple #1
0
        private ReadResult <SurfaceLine> ReadSurfaceLines(SurfaceLinesCsvReader reader)
        {
            int itemCount = GetNumberOfSurfaceLines(reader);

            if (itemCount == -1)
            {
                return(new ReadResult <SurfaceLine>(true));
            }

            string stepName = string.Format(RiskeerCommonIOResources.SurfaceLinesCsvImporter_Read_SurfaceLines_0_,
                                            Path.GetFileName(FilePath));

            NotifyProgress(stepName, 0, itemCount);

            var readSurfaceLines = new List <SurfaceLine>(itemCount);

            for (var i = 0; i < itemCount && !Canceled; i++)
            {
                try
                {
                    AddValidSurfaceLineToCollection(readSurfaceLines, reader);
                }
                catch (CriticalFileReadException e)
                {
                    return(HandleCriticalReadError <SurfaceLine>(e));
                }

                NotifyProgress(stepName, i + 1, itemCount);
            }

            return(new ReadResult <SurfaceLine>(false)
            {
                Items = readSurfaceLines
            });
        }
Exemple #2
0
 private int GetNumberOfSurfaceLines(SurfaceLinesCsvReader reader)
 {
     try
     {
         return(reader.GetSurfaceLinesCount());
     }
     catch (CriticalFileReadException e)
     {
         Log.Error(e.Message, e);
         return(-1);
     }
 }
Exemple #3
0
        private ReadResult <SurfaceLine> ReadSurfaceLines()
        {
            NotifyProgress(RiskeerCommonIOResources.SurfaceLinesCsvImporter_Reading_surface_line_file, 1, 1);
            using (SurfaceLinesCsvReader reader = CreateSurfaceLineReader())
            {
                if (reader == null)
                {
                    return(new ReadResult <SurfaceLine>(true));
                }

                ReadResult <SurfaceLine> readSurfaceLines = ReadSurfaceLines(reader);

                return(readSurfaceLines);
            }
        }
Exemple #4
0
 /// <summary>
 /// Adds a valid <see cref="SurfaceLine"/> read from <paramref name="reader"/> to the <paramref name="list"/>.
 /// </summary>
 /// <param name="list">The list to add the valid <see cref="SurfaceLine"/> to.</param>
 /// <param name="reader">The reader to read the <see cref="SurfaceLine"/> from.</param>
 /// <exception cref="CriticalFileReadException">Thrown when <paramref name="list"/> already contains a <see cref="SurfaceLine"/>
 /// with the same name as the new <see cref="SurfaceLine"/>.</exception>
 private void AddValidSurfaceLineToCollection(List <SurfaceLine> list, SurfaceLinesCsvReader reader)
 {
     try
     {
         SurfaceLine surfaceLine = reader.ReadSurfaceLine();
         if (IsSurfaceLineAlreadyDefined(list, surfaceLine))
         {
             PruneConsecutiveDuplicateGeometryPoints(surfaceLine);
             list.Add(surfaceLine);
         }
     }
     catch (LineParseException e)
     {
         Log.ErrorFormat(RiskeerCommonIOResources.SurfaceLinesCsvImporter_ReadSurfaceLines_ParseErrorMessage_0_SurfaceLine_skipped,
                         e.Message);
     }
 }