示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrontEndLoader"/> class.
        /// </summary>
        public ConnectPage()
        {
            InitializeComponent();
            LoadExcavatorTypes();

            if (ExcavatorTypes.Any())
            {
                SelectedImportType = ExcavatorTypes.FirstOrDefault();
                InitializeDBConnection();
            }
            else
            {
                btnNext.Visibility          = Visibility.Hidden;
                lblNoData.Visibility        = Visibility.Visible;
                lblDatabaseTypes.Visibility = Visibility.Hidden;
                lstDatabaseTypes.Visibility = Visibility.Hidden;
            }

            DataContext = this;
        }
示例#2
0
        /// <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;
            }
        }