Changeset 15280 for branches/Async/HeuristicLab.Problems.Instances.DataAnalysis/3.3/DataAnalysisInstanceProvider.cs
- Timestamp:
- 07/23/17 00:52:14 (7 years ago)
- Location:
- branches/Async
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Async
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Problems.Instances.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis (added) merged: 13395,13397,13411,13413-13414,13440-13442,13445,13447,13526,13584,13644,13890,13901,13925,13939,13963
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Problems.Instances.DataAnalysis/3.3/DataAnalysisInstanceProvider.cs
r12012 r15280 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.ComponentModel; 25 26 using System.Globalization; 26 27 using System.IO; … … 35 36 where ImportType : DataAnalysisImportType { 36 37 38 public event ProgressChangedEventHandler ProgressChanged; 37 39 38 40 public TData ImportData(string path, ImportType type, DataAnalysisCSVFormat csvFormat) { 39 41 TableFileParser csvFileParser = new TableFileParser(); 42 long fileSize = new FileInfo(path).Length; 43 csvFileParser.ProgressChanged += (sender, e) => { 44 OnProgressChanged(e / (double)fileSize); 45 }; 40 46 csvFileParser.Parse(path, csvFormat.NumberFormatInfo, csvFormat.DateTimeFormatInfo, csvFormat.Separator, csvFormat.VariableNamesAvailable); 41 47 return ImportData(path, type, csvFileParser); 48 } 49 50 protected virtual void OnProgressChanged(double d) { 51 var handler = ProgressChanged; 52 if (handler != null) 53 handler(this, new ProgressChangedEventArgs((int)(100 * d), null)); 42 54 } 43 55 … … 89 101 strBuilder.AppendLine(); 90 102 } 91 92 using (var writer = new StreamWriter(path)) { 93 writer.Write(strBuilder); 103 using (var fileStream = new FileStream(path, FileMode.Create)) { 104 Encoding encoding = Encoding.GetEncoding(Encoding.Default.CodePage, 105 new EncoderReplacementFallback("*"), 106 new DecoderReplacementFallback("*")); 107 using (var writer = new StreamWriter(fileStream, encoding)) { 108 writer.Write(strBuilder); 109 } 94 110 } 95 111 }
Note: See TracChangeset
for help on using the changeset viewer.