public static void RefreshMappings(Project project, ProgressUpdate progressUpdate)
        {
            int currentItem = -1;
            int totalItems  = (2 * project.UserSettings.Connections.Count);

            foreach (var connection in project.UserSettings.Connections)
            {
                string         description = connection.GetDescription();
                DatabaseWorker worker      = DatabaseWorker.GetInstance(connection);

                if (progressUpdate != null)
                {
                    progressUpdate($"{description}: Refreshing mappings...", ++currentItem, totalItems);
                }

                worker.Refresh(project, connection);

                if (progressUpdate != null)
                {
                    progressUpdate($"{description}: Sorting...", ++currentItem, totalItems);
                }

                project.SortAll();

                if (progressUpdate != null)
                {
                    progressUpdate($"{description}: Refresh complete.", ++currentItem, totalItems);
                }
            }
        }
        public static DatabaseWorker GetInstance(Connection connection)
        {
            string databaseType = connection.DatabaseType;

            if (databaseType.IsNullOrEmpty())
            {
                throw new EmptyDatabaseWorkerSpecifiedException();
            }
            else
            {
                DatabaseWorker worker = DatabaseWorkerManager.Instance[connection.DatabaseType];

                if (worker == null)
                {
                    throw new NonExistentDatabaseWorkerSpecifiedException("Could not locate database worker named: {0}.".FormatString(databaseType));
                }

                return(worker);
            }
        }
 private void OnDatabaseTypeChanged(DatabaseWorker worker)
 {
     if (DatabaseTypeChanged != null)
         DatabaseTypeChanged(this, worker);
 }
        private void InitializeDatabaseParameters(DatabaseWorker worker)
        {
            parametersGridView.Rows.Clear();

            if (worker != null && worker.Parameters.Any())
            {
                string[] allParameterNames = worker.Parameters.Select(o => o.Name).ToArray();

                this.Connection.Attributes.RemoveAll(o => !allParameterNames.Contains(o.Key));

                foreach (DatabaseParameter parameter in worker.Parameters)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    string value = this.Connection.Attributes.SingleOrDefault(o => o.Key.Equals(parameter.Name)).ValueOrDefault(o => o.Value);

                    row.CreateCells(parametersGridView, parameter.Name, value);
                    row.Cells[databaseParametersNameColumn.Index].ToolTipText = parameter.Description;
                    row.Cells[databaseParametersValueColumn.Index].ToolTipText = parameter.Description;
                    parametersGridView.Rows.Add(row);
                }

                tabs.TabPages.Add(parametersTab);
            }
            else {
                this.Connection.Attributes.Clear();
                tabs.TabPages.Remove(parametersTab);
            }
        }