/// <summary> /// Handles the DoWork event of the bwLoadSchema control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> private void bwPreview_DoWork(object sender, DoWorkEventArgs e) { var selectedExcavator = (string)e.Argument; var filePicker = new OpenFileDialog(); filePicker.Multiselect = true; var supportedExtensions = ExcavatorTypes.Where(t => t.FullName.Equals(selectedExcavator)) .Select(t => t.FullName + " |*" + t.ExtensionType).ToList(); filePicker.Filter = string.Join("|", supportedExtensions); if (filePicker.ShowDialog() == true) { excavator = ExcavatorTypes.Where(t => t.FullName.Equals(selectedExcavator)).FirstOrDefault(); if (excavator != null) { bool loadedSuccessfully = false; foreach (var file in filePicker.FileNames) { loadedSuccessfully = excavator.LoadSchema(file); if (!loadedSuccessfully) { e.Cancel = true; break; } Dispatcher.BeginInvoke((Action)(() => FilesUploaded.Children.Add(new TextBlock { Text = System.IO.Path.GetFileName(file) }) )); } } } else { e.Cancel = true; } }
/// <summary> /// Handles the DoWork event of the bwLoadSchema control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> private void bwPreview_DoWork( object sender, DoWorkEventArgs e ) { var selectedExcavator = (string)e.Argument; var filePicker = new OpenFileDialog(); filePicker.Multiselect = true; var supportedExtensions = ExcavatorTypes.Where( t => t.FullName.Equals( selectedExcavator ) ) .Select( t => t.FullName + " |*" + t.ExtensionType ).ToList(); filePicker.Filter = string.Join( "|", supportedExtensions ); if ( filePicker.ShowDialog() == true ) { excavator = ExcavatorTypes.Where( t => t.FullName.Equals( selectedExcavator ) ).FirstOrDefault(); if ( excavator != null ) { bool loadedSuccessfully = false; foreach ( var file in filePicker.FileNames ) { loadedSuccessfully = excavator.LoadSchema( file ); if ( !loadedSuccessfully ) { e.Cancel = true; break; } Dispatcher.BeginInvoke( (Action)( () => FilesUploaded.Children.Add( new TextBlock { Text = System.IO.Path.GetFileName( file ) } ) ) ); } } } else { e.Cancel = true; } }
/// <summary> /// Handles the DoWork event of the bwLoadSchema control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> private void bwPreview_DoWork( object sender, DoWorkEventArgs e ) { var mdfPicker = new OpenFileDialog(); mdfPicker.Filter = "SQL Database files|*.mdf"; mdfPicker.AddExtension = false; if ( mdfPicker.ShowDialog() == true ) { var database = new Database( mdfPicker.FileName ); if ( database != null ) { var dbType = (string)e.Argument; excavator = frontEndLoader.excavatorTypes.Where( t => t.FullName.Equals( dbType ) ).FirstOrDefault(); if ( excavator != null ) { bool loadedSuccessfully = excavator.LoadSchema( database ); e.Cancel = !loadedSuccessfully; } } } else { e.Cancel = true; } }