public DataBoxPropertiesChangedArgsWindows(
     SqlDatabaseTableWindows currentTable,
     EntityCacheUniqueWindows currentEntityCache,
     List <string> hiddenProperties,
     List <string> extensionManagedProperties,
     Dictionary <string, Control> inputControls,
     Control firstInputControl,
     object entityUnderUpdate,
     Nullable <Guid> entityIdUnderUpdate,
     string currentDataBoxFilePath,
     bool filtersEnabled,
     bool unsavedChanges,
     bool readOnlyMode,
     bool inUpdateMode)
 {
     _currentTable               = currentTable;
     _currentEntityCache         = currentEntityCache;
     _hiddenProperties           = hiddenProperties;
     _extensionManagedProperties = extensionManagedProperties;
     _inputControls              = inputControls;
     _firstInputControl          = firstInputControl;
     _entityUnderUpdate          = entityUnderUpdate;
     _entityIdUnderUpdate        = entityIdUnderUpdate;
     _currentDataBoxFilePath     = currentDataBoxFilePath;
     _filtersEnabled             = filtersEnabled;
     _unsavedChanges             = unsavedChanges;
     _readOnlyMode               = readOnlyMode;
     _inUpdateMode               = inUpdateMode;
 }
 public MenuClickArgsWindows(
     SqlDatabaseTableWindows currentTable,
     object selectedEntity,
     bool dataBoxInUpdateMode)
 {
     _currentTable        = currentTable;
     _selectedEntity      = selectedEntity;
     _dataBoxInUpdateMode = dataBoxInUpdateMode;
 }
 public AfterRefreshFromServerArgsWindows(bool presentLoadDataBoxForm, SqlDatabaseTableWindows currentTable)
 {
     _presentLoadDataBoxForm = presentLoadDataBoxForm;
     _currentTable           = currentTable;
 }
        public SqlDatabaseWindows GetSqlDatabase(
            bool createOrmAssembly,
            bool saveOrmAssembly,
            string ormAssemblyOutputDirectory,
            bool wrapWebException)
        {
            string             rawOutput = string.Empty;
            SqlDatabaseWindows result    = new SqlDatabaseWindows();
            HttpStatusCode     statusCode;
            string             statusDescription = null;

            result.Name = GetSqlSchema <string>(DatabaseSchemaInfoTypeWindows.DatabaseName, null, out rawOutput, out statusCode, out statusDescription, wrapWebException);
            DataTable tablesSchema = GetSqlSchema <DataTable>(DatabaseSchemaInfoTypeWindows.Tables, null, out rawOutput, out statusCode, out statusDescription, wrapWebException);
            Dictionary <string, DatabaseTableKeyColumnsWindows> tablesKeyColumns = new Dictionary <string, DatabaseTableKeyColumnsWindows>(); //Primary keys of all the tables.

            GetSqlSchema <List <DatabaseTableKeyColumnsWindows> >(DatabaseSchemaInfoTypeWindows.TableKeyColumns, null, out rawOutput, out statusCode, out statusDescription, wrapWebException).ForEach(p => tablesKeyColumns.Add(p.TableName, p));
            Dictionary <string, DatabaseTableForeignKeyColumnsWindows> tablesForeignKeyColumns = new Dictionary <string, DatabaseTableForeignKeyColumnsWindows>(); //Foreign keys of all tables.

            GetSqlSchema <List <DatabaseTableForeignKeyColumnsWindows> >(DatabaseSchemaInfoTypeWindows.TableForeignKeyColumns, null, out rawOutput, out statusCode, out statusDescription, wrapWebException).ForEach(p => tablesForeignKeyColumns.Add(p.TableName, p));
            foreach (DataRow t in tablesSchema.Rows)
            {
                SqlDatabaseTableWindows table = new SqlDatabaseTableWindows(t);
                if (table.IsSystemTable)
                {
                    continue;
                }
                if (!tablesKeyColumns.ContainsKey(table.TableName))
                {
                    throw new UserThrownException(string.Format("Could not find key columns for table {0}.", table.TableName), LoggingLevel.Minimum);
                }
                DatabaseTableKeyColumnsWindows        tableKeys        = tablesKeyColumns[table.TableName];
                DatabaseTableForeignKeyColumnsWindows tableForeignKeys = tablesForeignKeyColumns[table.TableName];
                if (result.Tables.Exists(table.TableName))
                {
                    throw new Exception(string.Format(
                                            "{0} with name {1} already added.",
                                            typeof(SqlDatabaseTableWindows).FullName,
                                            table.TableName));
                }
                result.AddTable(table);
                DataTable columnsSchema = GetSqlSchema <DataTable>(DatabaseSchemaInfoTypeWindows.Columns, table.TableName, out rawOutput, out statusCode, out statusDescription, wrapWebException);
                table.PopulateColumnsFromSchema(columnsSchema);
                foreach (string keyColumn in tableKeys.KeyNames)
                {
                    if (!table.Columns.Exists(keyColumn))
                    {
                        throw new UserThrownException(string.Format("Could not find key column {0} on table {1}.", keyColumn, table.TableName), LoggingLevel.Minimum);
                    }
                    table.Columns[keyColumn].IsKey = true;
                }
                foreach (ForeignKeyInfoWindows foreignKeyColumn in tableForeignKeys.ForeignKeys)
                {
                    if (!table.Columns.Exists(foreignKeyColumn.ChildTableForeignKeyName))
                    {
                        throw new UserThrownException(string.Format("Could not find foreign key column {0} on table {1}.", foreignKeyColumn.ChildTableForeignKeyName, table.TableName), LoggingLevel.Minimum);
                    }
                    DatabaseTableColumnWindows c = table.Columns[foreignKeyColumn.ChildTableForeignKeyName];
                    c.IsForeignKey              = true;
                    c.ParentTableName           = foreignKeyColumn.ParentTableName;
                    c.ParentTablePrimaryKeyName = foreignKeyColumn.ParentTablePrimaryKeyName;
                    c.ConstraintName            = foreignKeyColumn.ConstraintName;
                }
            }
            PopulateSqlDatabaseChildrenTables(result);
            if (createOrmAssembly)
            {
                result.CreateOrmAssembly(saveOrmAssembly, ormAssemblyOutputDirectory);
            }
            return(result);
        }
 public BeforeRefreshFromServerArgsWindows(bool presentLoadDataBoxForm, SqlDatabaseTableWindows selectedTable)
 {
     _presentLoadDataBoxForm = presentLoadDataBoxForm;
     _selectedTable          = selectedTable;
 }