Beispiel #1
0
        private void Submit_Click( object sender, RoutedEventArgs e )
        {
            ToggleSubmit( Submit );

            string serverName = ServerName.Text;
            string databaseName = DatabaseName.Text;
            string outputFolder = OutputFolder.Text;

            if (string.IsNullOrWhiteSpace( serverName )
                || string.IsNullOrWhiteSpace( databaseName )
                || string.IsNullOrWhiteSpace( outputFolder ))
            {
                throw new Exception( "Please complete all form fields" );
            }

            var command = new BimlRequest
                {
                    ServerName = serverName,
                    DatabaseName = databaseName,
                    OutputFolder = outputFolder,
                    HasConnections = (bool) HasConnections.IsChecked,
                    HasDatabases = (bool) HasDatabase.IsChecked,
                    HasSchemas = (bool) HasSchemas.IsChecked,
                    HasTables = (bool) HasTables.IsChecked,
                    HasFactsAndDimensions = (bool) HasFactsAndDimensions.IsChecked
                };

            var result = Task.Run( () => GetBiml( command ) );
            result.ContinueWith( t => OpenExplorer( outputFolder ) );
            result.ContinueWith( t => ToggleSubmit( Submit ),
                                 CancellationToken.None,
                                 TaskContinuationOptions.None,
                                 TaskScheduler.FromCurrentSynchronizationContext() );
        }
Beispiel #2
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            ToggleSubmit(Submit);

            string serverName   = ServerName.Text;
            string databaseName = DatabaseName.Text;
            string outputFolder = OutputFolder.Text;

            if (string.IsNullOrWhiteSpace(serverName) ||
                string.IsNullOrWhiteSpace(databaseName) ||
                string.IsNullOrWhiteSpace(outputFolder))
            {
                throw new Exception("Please complete all form fields");
            }

            var command = new BimlRequest
            {
                ServerName            = serverName,
                DatabaseName          = databaseName,
                OutputFolder          = outputFolder,
                HasConnections        = (bool)HasConnections.IsChecked,
                HasDatabases          = (bool)HasDatabase.IsChecked,
                HasSchemas            = (bool)HasSchemas.IsChecked,
                HasTables             = (bool)HasTables.IsChecked,
                HasFactsAndDimensions = (bool)HasFactsAndDimensions.IsChecked
            };

            var result = Task.Run(() => GetBiml(command));

            result.ContinueWith(t => OpenExplorer(outputFolder));
            result.ContinueWith(t => ToggleSubmit(Submit),
                                CancellationToken.None,
                                TaskContinuationOptions.None,
                                TaskScheduler.FromCurrentSynchronizationContext());
        }
Beispiel #3
0
        public static Biml BuildBiml( BimlRequest request )
        {
            // Configure SQL SMO
            var server = new Server( request.ServerName );
            var scriptingOptions = new ScriptingOptions { Encoding = Encoding.UTF8 };
            server.Script( scriptingOptions );
            var database = new Microsoft.SqlServer.Management.Smo.Database( server, request.DatabaseName );
            database.Refresh();

            var bimlService = new BimlService();
            var output = new Biml();

            // Selectively build sections
            if ( request.HasConnections )
                output.Connections = bimlService.GetConnections( server, database );
            if ( request.HasDatabases )
                output.Databases = bimlService.GetDatabases( database );
            if( request.HasSchemas )
                output.Schemas = bimlService.GetSchemas( database );
            if (request.HasTables)
            {
                output.Tables = bimlService.GetTables( database, request.HasFactsAndDimensions );
            }
            if (request.HasFactsAndDimensions)
            {
                output.Facts = bimlService.GetFacts( database );
                output.Dimensions = bimlService.GetDimensions( database );
            }

            return output;
        }
Beispiel #4
0
 private void GetBiml( BimlRequest request)
 {
     var biml = BimlGenerator.GetBiml( request );
     if( !string.IsNullOrEmpty( biml ) )
     {
         var now = DateTime.Now;
         var timestamp = "" + now.Hour + now.Minute + now.Second;
         File.WriteAllText( string.Format( "{0}\\{1}{2}.biml", request.OutputFolder, request.DatabaseName, timestamp ), biml );
     }
 }
Beispiel #5
0
        private void GetBiml(BimlRequest request)
        {
            var biml = BimlGenerator.GetBiml(request);

            if (!string.IsNullOrEmpty(biml))
            {
                var now       = DateTime.Now;
                var timestamp = "" + now.Hour + now.Minute + now.Second;
                File.WriteAllText(string.Format("{0}\\{1}{2}.biml", request.OutputFolder, request.DatabaseName, timestamp), biml);
            }
        }
Beispiel #6
0
        public static string GetBiml( BimlRequest request )
        {
            var biml = BuildBiml( request );

            var serializer = new XmlSerializer( biml.GetType() );
            using (var writer = new StringWriter())
            {
                serializer.Serialize( writer, biml );
                return writer.ToString();
            }
        }
Beispiel #7
0
        public static string GetBiml(BimlRequest request)
        {
            var biml = BuildBiml(request);

            var serializer = new XmlSerializer(biml.GetType());

            using (var writer = new StringWriter())
            {
                serializer.Serialize(writer, biml);
                return(writer.ToString());
            }
        }
Beispiel #8
0
        public static Biml BuildBiml(BimlRequest request)
        {
            // Configure SQL SMO
            var server           = new Server(request.ServerName);
            var scriptingOptions = new ScriptingOptions {
                Encoding = Encoding.UTF8
            };

            server.Script(scriptingOptions);
            var database = new Microsoft.SqlServer.Management.Smo.Database(server, request.DatabaseName);

            database.Refresh();

            var bimlService = new BimlService();
            var output      = new Biml();

            // Selectively build sections
            if (request.HasConnections)
            {
                output.Connections = bimlService.GetConnections(server, database);
            }
            if (request.HasDatabases)
            {
                output.Databases = bimlService.GetDatabases(database);
            }
            if (request.HasSchemas)
            {
                output.Schemas = bimlService.GetSchemas(database);
            }
            if (request.HasTables)
            {
                output.Tables = bimlService.GetTables(database, request.HasFactsAndDimensions);
            }
            if (request.HasFactsAndDimensions)
            {
                output.Facts      = bimlService.GetFacts(database);
                output.Dimensions = bimlService.GetDimensions(database);
            }

            return(output);
        }