Exemple #1
0
        private async Task <List <TableModel> > GetTablesAsync(DatabaseInfo dbInfo, bool useEFCore5, SchemaInfo[] schemas)
        {
            if (dbInfo.DataConnection != null)
            {
                dbInfo.DataConnection.Open();
                dbInfo.ConnectionString = DataProtection.DecryptString(dbInfo.DataConnection.EncryptedConnectionString);
            }

            var builder = new TableListBuilder(dbInfo.ConnectionString, dbInfo.DatabaseType, schemas);

            return(await System.Threading.Tasks.Task.Run(() => builder.GetTableDefinitions(useEFCore5)));
        }
        public List <TableInformationModel> GetTables(DatabaseInfo dbInfo, bool useEFCore5, SchemaInfo[] schemas)
        {
            if (dbInfo.DataConnection != null)
            {
                dbInfo.DataConnection.Open();
                dbInfo.ConnectionString = DataProtection.DecryptString(dbInfo.DataConnection.EncryptedConnectionString);
            }

            var builder = new TableListBuilder(dbInfo.ConnectionString, dbInfo.DatabaseType, schemas);

            return(builder.GetTableDefinitions(useEFCore5));
        }
        public List <TableInformationModel> GetTables(string connectionString, DatabaseType databaseType, bool useEFCore5, SchemaInfo[] schemas)
        {
            var builder = new TableListBuilder(connectionString, databaseType, schemas);

            return(builder.GetTableDefinitions(useEFCore5));
        }
        public List <TableInformationModel> GetDacpacTables(string dacpacPath, bool useEFCore5)
        {
            var builder = new TableListBuilder(dacpacPath, DatabaseType.Undefined, null);

            return(builder.GetTableDefinitions(useEFCore5));
        }
Exemple #5
0
        static int Main(string[] args)
        {
            try
            {
                Console.OutputEncoding = Encoding.UTF8;

                if (args.Length > 0)
                {
                    if (args[0].EndsWith(".dacpac", StringComparison.OrdinalIgnoreCase))
                    {
                        return(BuildDacpacList(args[0]));
                    }

                    if ((args.Count() == 2 || args.Count() == 3) && int.TryParse(args[0], out int dbTypeInt))
                    {
                        SchemaInfo[] schemas = null;
                        if (args.Length == 3)
                        {
                            schemas = args[2].Split(',').Select(s => new SchemaInfo {
                                Name = s
                            }).ToArray();
                        }
                        var builder = new TableListBuilder(dbTypeInt, args[1], schemas);

                        var value = builder.GetTableDefinitions();

                        var buildResult = new List <TableInformationModel>();
                        buildResult.AddRange(value.Select(v => new TableInformationModel(v.Item1, v.Item2)).ToList());

                        var procedures = builder.GetProcedures(dbTypeInt);
                        buildResult.AddRange(procedures.Select(p => new TableInformationModel(p, false, false, RevEng.Shared.ObjectType.Procedure)).ToList());

                        Console.Out.WriteLine("Result:");
                        Console.Out.WriteLine(buildResult.Write());

                        return(0);
                    }

                    if (!File.Exists(args[0]))
                    {
                        Console.Out.WriteLine("Error:");
                        Console.Out.WriteLine($"Could not open options file: {args[0]}");
                        return(1);
                    }

                    var options = ReverseEngineerOptionsExtensions.TryDeserialize(File.ReadAllText(args[0], System.Text.Encoding.UTF8));

                    if (options == null)
                    {
                        Console.Out.WriteLine("Error:");
                        Console.Out.WriteLine("Could not read options");
                        return(1);
                    }

                    var runner = new ReverseEngineerRunner();

                    var result = runner.GenerateFiles(options);

                    Console.Out.WriteLine("Result:");
                    Console.Out.WriteLine(result.Write());
                }
                else
                {
                    Console.Out.WriteLine("Error:");
                    Console.Out.WriteLine("Invalid command line");
                    return(1);
                }
                return(0);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Error:");
                Console.Out.WriteLine(ex);
                return(1);
            }
        }
Exemple #6
0
        private async Task <List <TableModel> > GetDacpacTablesAsync(string dacpacPath, bool useEFCore5)
        {
            var builder = new TableListBuilder(dacpacPath, DatabaseType.SQLServerDacpac, null);

            return(await System.Threading.Tasks.Task.Run(() => builder.GetTableDefinitions(useEFCore5)));
        }
        private async Task <List <TableModel> > GetDacpacTablesAsync(string dacpacPath, bool useEFCore5)
        {
            var builder = new TableListBuilder(dacpacPath, DatabaseType.Undefined, null);

            return(await Task.Run(() => builder.GetTableDefinitions(useEFCore5)));
        }
Exemple #8
0
        static int Main(string[] args)
        {
            try
            {
                if (args.Length > 0)
                {
                    if (args[0].EndsWith(".dacpac", StringComparison.OrdinalIgnoreCase))
                    {
                        return(BuildDacpacList(args[0]));
                    }

                    if (args.Count() == 2 && int.TryParse(args[0], out int dbTypeInt))
                    {
                        var builder = new TableListBuilder(dbTypeInt, args[1]);

                        var value = builder.GetTableDefinitions();

                        var buildResult = new List <TableInformationModel>();
                        buildResult.AddRange(value.Select(v => new TableInformationModel(v.Item1, v.Item2)).ToList());

                        Console.Out.WriteLine("Result:");
                        Console.Out.WriteLine(buildResult.Write());

                        return(0);
                    }

                    if (!File.Exists(args[0]))
                    {
                        Console.Out.WriteLine("Error:");
                        Console.Out.WriteLine($"Could not open options file: {args[0]}");
                        return(1);
                    }

                    var options = ReverseEngineerOptionsExtensions.TryDeserialize(File.ReadAllText(args[0], System.Text.Encoding.UTF8));

                    if (options == null)
                    {
                        Console.Out.WriteLine("Error:");
                        Console.Out.WriteLine("Could not read options");
                        return(1);
                    }

                    var runner = new ReverseEngineerRunner();

                    var result = runner.GenerateFiles(options);

                    Console.Out.WriteLine("Result:");
                    Console.Out.WriteLine(result.Write());
                }
                else
                {
                    Console.Out.WriteLine("Error:");
                    Console.Out.WriteLine("Invalid command line");
                    return(1);
                }
                return(0);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Error:");
                Console.Out.WriteLine(ex);
                return(1);
            }
        }