상속: INotifyPropertyChanged
예제 #1
0
        private void ConnectionsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this._tables.Clear();
            GenerateCodeButton.IsEnabled = false;

            if (this.ConnectionsCombo.SelectedItem != null)
            {
                var conn = (GeneratorConfig.Connection) this.ConnectionsCombo.SelectedItem;

                try
                {
                    using (var connection = SqlConnections.New(conn.ConnectionString, conn.ProviderName))
                    {
                        connection.Open();

                        var schemaProvider = SchemaHelper.GetSchemaProvider(connection.GetDialect().ServerType);
                        foreach (var t in schemaProvider.GetTableNames(connection))
                        {
                            var table = conn != null?conn.Tables.FirstOrDefault(x => x.Tablename == t.Tablename) : null;

                            var identifier = (table == null || table.Identifier.IsEmptyOrNull()) ?
                                             RowGenerator.ClassNameFromTableName(t.Table) : table.Identifier;
                            var permission    = table == null ? "Administration:General" : table.PermissionKey;
                            var connectionKey = (table != null && !table.ConnectionKey.IsEmptyOrNull()) ?
                                                table.ConnectionKey : conn.Key;

                            var module = (table != null && table.Module != null) ? table.Module :
                                         (Inflector.Inflector.Pascalize(connectionKey) ?? "").Replace(" ", "");

                            var tableItem = new TableItem
                            {
                                IsChecked     = false,
                                ConnectionKey = conn.Key,
                                Module        = module,
                                Identifier    = identifier,
                                PermissionKey = permission,
                                FullName      = t.Tablename
                            };

                            _tables.Add(tableItem);
                            tableItem.PropertyChanged += (s, e2) =>
                            {
                                var t2 = conn.Tables.FirstOrDefault(x => x.Tablename == tableItem.FullName);
                                if (t2 == null)
                                {
                                    t2           = new GeneratorConfig.Table();
                                    t2.Tablename = tableItem.FullName;
                                    conn.Tables.Add(t2);
                                }
                                t2.Identifier    = tableItem.Identifier;
                                t2.Module        = tableItem.Module;
                                t2.ConnectionKey = tableItem.ConnectionKey;
                                t2.PermissionKey = tableItem.PermissionKey;
                                this.config.Save();

                                GenerateCodeButton.IsEnabled = _tables.Any(x => x.IsChecked);
                            };
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
예제 #2
0
        private void ConnectionsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this._tables.Clear();
            GenerateCodeButton.IsEnabled = false;

            if (this.ConnectionsCombo.SelectedItem != null)
            {
                var conn = (GeneratorConfig.Connection) this.ConnectionsCombo.SelectedItem;

                try
                {
                    using (var connection = SqlConnections.New(conn.ConnectionString, conn.ProviderName))
                    {
                        connection.Open();

                        foreach (var t in SqlSchemaInfo.GetTableNames(connection))
                        {
                            var table = conn != null?conn.Tables.FirstOrDefault(x => x.Tablename == t.Tablename) : null;

                            var permission    = table == null ? "Administration:General" : table.PermissionKey;
                            var connectionKey = (table != null && !table.ConnectionKey.IsEmptyOrNull()) ?
                                                table.ConnectionKey : conn.Key;
                            var module = (table != null && table.Module != null) ? table.Module :
                                         this.adminTables.Any(atbl => $"{config.TablePrefixSettings?.ModulePrefixes?["Administration"]}_{atbl}".Equals(t.Tablename, StringComparison.InvariantCultureIgnoreCase)) ?
                                         "Administration"
                                : Inflector.Inflector.Capitalize(connectionKey);
                            var identifier = (table == null || table.Identifier.IsEmptyOrNull()) ?
                                             RowGenerator.ClassNameFromTableName(RowGenerator.UnprefixTable(t.Table, module, this.config)) : table.Identifier;

                            var tableItem = new TableItem
                            {
                                IsChecked     = false,
                                ConnectionKey = conn.Key,
                                Module        = module,
                                Identifier    = identifier,
                                PermissionKey = permission,
                                FullName      = t.Tablename
                            };

                            _tables.Add(tableItem);
                            tableItem.PropertyChanged += (s, e2) =>
                            {
                                var t2 = conn.Tables.FirstOrDefault(x => x.Tablename == tableItem.FullName);
                                if (t2 == null)
                                {
                                    t2           = new GeneratorConfig.Table();
                                    t2.Tablename = tableItem.FullName;
                                    conn.Tables.Add(t2);
                                }
                                t2.Module = tableItem.Module;
                                if (e2.PropertyName.Equals("Module"))
                                {
                                    tableItem.Identifier = RowGenerator.ClassNameFromTableName(RowGenerator.UnprefixTable(t2.Tablename, t2.Module, this.config));
                                }
                                t2.Identifier    = tableItem.Identifier;
                                t2.ConnectionKey = tableItem.ConnectionKey;
                                t2.PermissionKey = tableItem.PermissionKey;
                                this.config.Save();

                                GenerateCodeButton.IsEnabled = _tables.Any(x => x.IsChecked);
                            };
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
예제 #3
0
        private void ConnectionsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this._tables.Clear();
            GenerateCodeButton.IsEnabled = false;

            if (this.ConnectionsCombo.SelectedItem != null)
            {
                var conn = (GeneratorConfig.Connection) this.ConnectionsCombo.SelectedItem;

                try
                {
                    using (var connection = SqlConnections.New(conn.ConnectionString, conn.ProviderName))
                    {
                        connection.Open();

                        var schemaProvider = SchemaHelper.GetSchemaProvider(connection.GetDialect().ServerType);
                        //foreach (var t in schemaProvider.GetTableNames(connection))
                        List <Data.Schema.TableName> excluiTabelas = new List <Data.Schema.TableName>();
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "EXCEPTIONS"
                        });
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "LANGUAGES"
                        });
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "ROLEPERMISSIONS"
                        });
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "ROLES"
                        });
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "USERPERMISSIONS"
                        });
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "USERPREFERENCES"
                        });
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "USERROLES"
                        });
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "USERS"
                        });
                        excluiTabelas.Add(new Data.Schema.TableName()
                        {
                            Table = "VERSIONINFO"
                        });

                        //foreach (var t in schemaProvider.GetTableNames(connection).Where(x => x.Table != "Exceptions"))
                        foreach (var t in schemaProvider.GetTableNames(connection).Where(x => !excluiTabelas.Any(t => t.Table == x.Table.ToUpper())))
                        {
                            //INICIO - ROLEMBERG FILHO - NÃO MOSTRA AS TABELAS PADRÃO DO SERENITY !!!
                            //switch (t.Table.ToUpper())
                            //{
                            //    case "EXCEPTIONS":
                            //    case "LANGUAGES":
                            //    case "ROLEPERMISSIONS":
                            //    case "ROLES":
                            //    case "USERPERMISSIONS":
                            //    case "USERPREFERENCES":
                            //    case "USERROLES":
                            //    case "USERS":
                            //    case "VERSIONINFO":
                            //        // TABELAS PADRÃO DO SERENITY. NÃO MOSTRA NO SERGEN!!!!
                            //        continue;
                            //    default:
                            //        break;
                            //}
                            //FIM - ROLEMBERG FILHO - NÃO MOSTRA AS TABELAS PADRÃO DO SERENITY !!!



                            var table = conn != null?conn.Tables.FirstOrDefault(x => x.Tablename == t.Tablename) : null;

                            var identifier = (table == null || table.Identifier.IsEmptyOrNull()) ?
                                             RowGenerator.ClassNameFromTableName(t.Table) : table.Identifier;
                            var permission    = table == null ? "Administration:General" : table.PermissionKey;
                            var connectionKey = (table != null && !table.ConnectionKey.IsEmptyOrNull()) ?
                                                table.ConnectionKey : conn.Key;

                            var module = (table != null && table.Module != null) ? table.Module :
                                         (Inflector.Inflector.Pascalize(connectionKey) ?? "").Replace(" ", "");

                            var tableItem = new TableItem
                            {
                                IsChecked     = false,
                                ConnectionKey = conn.Key,
                                Module        = module,
                                Identifier    = identifier,
                                PermissionKey = permission,
                                FullName      = t.Tablename
                            };

                            _tables.Add(tableItem);
                            tableItem.PropertyChanged += (s, e2) =>
                            {
                                var t2 = conn.Tables.FirstOrDefault(x => x.Tablename == tableItem.FullName);
                                if (t2 == null)
                                {
                                    t2           = new GeneratorConfig.Table();
                                    t2.Tablename = tableItem.FullName;
                                    conn.Tables.Add(t2);
                                }
                                t2.Identifier    = tableItem.Identifier;
                                t2.Module        = tableItem.Module;
                                t2.ConnectionKey = tableItem.ConnectionKey;
                                t2.PermissionKey = tableItem.PermissionKey;
                                this.config.Save();

                                GenerateCodeButton.IsEnabled = _tables.Any(x => x.IsChecked);
                            };
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
예제 #4
0
        private void ConnectionsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this._tables.Clear();
            GenerateCodeButton.IsEnabled = false;

            if (this.ConnectionsCombo.SelectedItem != null)
            {
                var conn = (GeneratorConfig.Connection)this.ConnectionsCombo.SelectedItem;

                try
                {
                    using (var connection = SqlConnections.New(conn.ConnectionString, conn.ProviderName))
                    {
                        connection.Open();

                        foreach (var t in SqlSchemaInfo.GetTableNames(connection))
                        {
                            var table = conn != null ? conn.Tables.FirstOrDefault(x => x.Tablename == t.Tablename) : null;
                            var identifier = (table == null || table.Identifier.IsEmptyOrNull()) ?
                                RowGenerator.ClassNameFromTableName(t.Table) : table.Identifier;
                            var permission = table == null ? "Administration:General" : table.PermissionKey;
                            var connectionKey = (table != null && !table.ConnectionKey.IsEmptyOrNull()) ?
                                table.ConnectionKey : conn.Key;

                            var module = (table != null && table.Module != null) ? table.Module :
                                Inflector.Inflector.Capitalize(connectionKey);

                            var tableItem = new TableItem
                            {
                                IsChecked = false,
                                ConnectionKey = conn.Key,
                                Module = module,
                                Identifier = identifier,
                                PermissionKey = permission,
                                FullName = t.Tablename
                            };

                            _tables.Add(tableItem);
                            tableItem.PropertyChanged += (s, e2) =>
                            {
                                var t2 = conn.Tables.FirstOrDefault(x => x.Tablename == tableItem.FullName);
                                if (t2 == null)
                                {
                                    t2 = new GeneratorConfig.Table();
                                    t2.Tablename = tableItem.FullName;
                                    conn.Tables.Add(t2);
                                }
                                t2.Identifier = tableItem.Identifier;
                                t2.Module = tableItem.Module;
                                t2.ConnectionKey = tableItem.ConnectionKey;
                                t2.PermissionKey = tableItem.PermissionKey;
                                this.config.Save();

                                GenerateCodeButton.IsEnabled = _tables.Any(x => x.IsChecked);
                            };
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }