/// <summary> /// Initializes a new instance of the <see cref="FrontEndLoader"/> class. /// </summary> public ConnectPage() { InitializeComponent(); LoadBulldozerTypes(); if (BulldozerTypes.Any()) { SelectedImportType = BulldozerTypes.FirstOrDefault(); InitializeDBConnection(); } else { btnNext.Visibility = Visibility.Hidden; lblHeader.Visibility = Visibility.Hidden; lblNoData.Visibility = Visibility.Visible; } DataContext = this; }
/// <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 selectedBulldozer = (string)e.Argument; var filePicker = new OpenFileDialog(); filePicker.Multiselect = true; var supportedExtensions = BulldozerTypes.Where(t => t.FullName.Equals(selectedBulldozer)) .Select(t => t.FullName + " |*" + t.ExtensionType).ToList(); filePicker.Filter = string.Join("|", supportedExtensions); if (filePicker.ShowDialog() == true) { bulldozer = BulldozerTypes.Where(t => t.FullName.Equals(selectedBulldozer)).FirstOrDefault(); if (bulldozer != null) { bool loadedSuccessfully = false; foreach (var file in filePicker.FileNames) { loadedSuccessfully = bulldozer.LoadSchema(file); if (!loadedSuccessfully) { e.Cancel = true; break; } Dispatcher.BeginInvoke((Action)(() => FilesUploaded.Children.Add(new TextBlock { Text = Path.GetFileName(file) }) )); } } } else { e.Cancel = true; } }