- Timestamp:
- 05/07/14 15:18:41 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/TransformationView.cs
r10814 r10819 22 22 using System; 23 23 using System.Windows.Forms; 24 using HeuristicLab.Data;25 24 using HeuristicLab.MainForm; 26 25 using HeuristicLab.MainForm.WindowsForms; … … 54 53 55 54 var transformator = new PreprocessingTransformator(Content.Data); 56 bool success = transformator.ApplyTransformations(transformations); 55 string errorMsg; 56 bool success = transformator.ApplyTransformations(transformations, out errorMsg); 57 57 if (success) { 58 //foreach (var transformation in transformations)59 // Content.CheckedTransformationCollection.SetItemCheckedState(transformation, false);60 58 Content.CheckedTransformationCollection.Clear(); 61 59 MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); 60 } else { 61 MessageBox.Show(this, 62 "Error in Transformation.\nValue is copied when transformion of cell failed.\n" + errorMsg, 63 "Transformation failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); 62 64 } 65 63 66 } 64 67 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/PreprocessingTransformator.cs
r10814 r10819 33 33 } 34 34 35 public bool ApplyTransformations(IEnumerable<ITransformation> transformations ) {36 bool success = true;35 public bool ApplyTransformations(IEnumerable<ITransformation> transformations, out string errorMsg) { 36 bool success; 37 37 38 preprocessingData.InTransaction(() => { 38 preprocessingData.BeginTransaction(DataPreprocessingChangedEventType.Transformation); 39 try { 39 40 var doubleTransformations = transformations.OfType<Transformation<double>>().ToList(); 40 ApplyDoubleTranformations(doubleTransformations, out success );41 } , DataPreprocessingChangedEventType.Transformation);42 43 if (!success) {44 preprocessingData.Undo();41 ApplyDoubleTranformations(doubleTransformations, out success, out errorMsg); 42 } finally { 43 preprocessingData.EndTransaction(); 44 //if (!success) 45 //preprocessingData.Undo(); 45 46 } 46 47 … … 48 49 } 49 50 50 private void ApplyDoubleTranformations(IEnumerable<Transformation<double>> transformations, out bool success) { 51 private void ApplyDoubleTranformations(IEnumerable<Transformation<double>> transformations, out bool success, out string errorMsg) { 52 errorMsg = string.Empty; 53 success = true; 51 54 foreach (var transformation in transformations) { 52 55 int colIndex = preprocessingData.GetColumnIndex(transformation.Column); 53 56 54 57 var originalData = preprocessingData.GetValues<double>(colIndex); 55 var transformedData = ApplyDoubleTransformation(transformation, originalData, out success); 56 if (!success) return; 57 58 string errorMsgPart; 59 bool successPart; 60 var transformedData = ApplyDoubleTransformation(transformation, originalData, out successPart, out errorMsgPart); 61 errorMsg += errorMsgPart + Environment.NewLine; 62 //if (!success) return; 63 if (!successPart) success = false; 58 64 preprocessingData.SetValues(colIndex, transformedData.ToList()); 59 65 preprocessingData.Transformations.Add(transformation); 60 66 } 61 success = true; 67 62 68 } 63 69 64 private IEnumerable<double> ApplyDoubleTransformation(Transformation<double> transformation, IEnumerable<double> data, out bool success) { 65 string errorMsg; 66 if (transformation.Check(data, out errorMsg)) { 67 success = true; 68 return transformation.Apply(data); 69 } 70 throw new NotImplementedException("Display Check Result"); 70 private IEnumerable<double> ApplyDoubleTransformation(Transformation<double> transformation, IEnumerable<double> data, out bool success, out string errorMsg) { 71 success = transformation.Check(data, out errorMsg); 72 return transformation.Apply(data); 71 73 } 72 74 }
Note: See TracChangeset
for help on using the changeset viewer.