private void StartImport(Configuration.Configuration config) { // clean the plate TasksListView.Items.Clear(); TasksListView.Groups.Clear(); // build the configuration object and then the loader BulkLoader loader = BulkLoader.Create(config); // since we want to track progress of tasks, lets // get an aggregated list of tasks from the loader's jobs List<BulkCopyTask> tasks = new List<BulkCopyTask>(); loader.Jobs.ForEach(j => j.Tasks.ForEach(tasks.Add)); // add a list group for each site being loaded. // TODO: relocate targets to the loader config.Targets.ForEach(t => TasksListView.Groups.Add(new ListViewGroup(t.Name, t.Name))); // create the list items and event handler tasks.ForEach(t => { ListViewItem item = new ListViewItem(); item.SubItems.Add(t.Table); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); TasksListView.Items.Add(item); item.Group = TasksListView.Groups[t.Site]; t.RowsInserted += (ss, eee) => TasksListView.Invoke(() => UpdateTaskItem(t, item, eee)); }); // set up the import completion handler loader.Jobs.Complete += (ss, ee) => ImportButton.Invoke(() => { ImportButton.Text = "Import"; ImportButton.Enabled = true; panel1.Enabled = true; _timer.Stop(); long count = loader.Jobs.Select(j => j.Tasks.Sum(t => t.Count)).Sum(); StatusLabel.Text = string.Format((_abort ? Resources.Rs_ImpAbort : Resources.Rs_ImpComplete) + "\r\n", count.ToString("#,##0"), _timer.ElapsedMilliseconds / 1000f / 60f); }); // start the job _timer.Reset(); _timer.Start(); ImportButton.Text = "Abort"; new Thread(() => loader.ProcessJobs(config)).Start(); }
public FrmUI(Configuration.Configuration configuration) { InitializeComponent(); InitializeUiFromConfig(configuration); }
private void InitializeUiFromConfig(Configuration.Configuration configuration) { _importTargets = configuration.Targets; dbProvidersBindingSource.DataSource = DbProviders.Instance; indicesCheckBox.Checked = configuration.Indices; splitCheckBox.Checked = configuration.Split; fullTextCheckBox.Checked = configuration.FullText; BatchSizeNumericUpDown.Value = configuration.BatchSize; if (configuration.Provider != null) { dbProvidersComboBox.SelectedValue = configuration.Provider.Name; } else { dbProvidersComboBox.SelectedValue = Settings.Default.ProviderName; } OnProviderChange(); sourceTextBox.Text = configuration.Source; DbProviderInfo provider = configuration.Provider; if (provider != null) { targetTextBox.Text = provider.ConnectionString; } }