Пример #1
0
        private void BackgroundCreateRCADDBCompleted(object sender, RunWorkerCompletedEventArgs args)
        {
            CreatingDB = false;
            if (args.Cancelled)
            {
                StatusMessage = FAILED_CREATING_RCAD_DB_INTERNALERROR_MESSAGE;
                Database      = null;
                if (UsingSQLExpress)
                {
                    ScriptTargetFile = null;
                }
                CommandManager.InvalidateRequerySuggested();
                return;
            }

            bool?createResult = args.Result as bool?;

            if (createResult != null)
            {
                if (createResult.Value)
                {
                    _desiredServer.Refresh();
                    LocalDatabases.Clear();
                    foreach (Database db in _desiredServer.Databases)
                    {
                        _localDatabases.Add(db.Name);
                    }
                    if (UsingSQLExpress)
                    {
                        StatusMessage = SUCCESSFULLY_CEREATE_RCAD_DBANDSCRIPT_MESSAGE;
                    }
                    else
                    {
                        StatusMessage = SUCCESSFULLY_CREATED_RCAD_DB_MESSAGE;
                    }
                    Database = null;
                    if (UsingSQLExpress)
                    {
                        ScriptTargetFile = null;
                    }
                    CommandManager.InvalidateRequerySuggested();
                    return;
                }
            }

            StatusMessage = FAILED_CREATING_RCAD_DB_MESSAGE;
            Database      = null;
            if (UsingSQLExpress)
            {
                ScriptTargetFile = null;
            }
            CommandManager.InvalidateRequerySuggested();
            return;
        }
Пример #2
0
        private void OnCreateRCADDB()
        {
            if (ConnectionValid && _desiredServer != null && !string.IsNullOrEmpty(Database))
            {
                if (LocalDatabases.Contains(Database))
                {
                    IMessageVisualizer mesg = Resolve <IMessageVisualizer>();
                    mesg.Show("Error",
                              string.Format("Error: Database with name {0} exists on selected instance, please select another name or delete the existing database first.", Database),
                              MessageButtons.OK);
                    Database = null;
                    return;
                }

                CreatingDB = true;
                rCADConnection ssisOleConn = new rCADConnection();
                ssisOleConn.Database     = Database;
                ssisOleConn.Instance     = Instance;
                ssisOleConn.Host         = Host;
                ssisOleConn.SecurityType = SecurityType.WindowsAuthentication;
                ssisOleConn.Provider     = "SQLNCLI10.1";

                if (!UsingSQLExpress)
                {
                    CreateRCADDBArgs args = new CreateRCADDBArgs()
                    {
                        TargetInstance       = _desiredServer,
                        RCADConnectionString = ssisOleConn.BuildConnectionString(),
                        InstallDirectory     = _installDirectory,
                        DataDirectory        = _dataDirectory,
                        LoadRCADDBPackage    = _rCADLoaderSSISPkg,
                        RCADDatabaseName     = Database
                    };
                    StatusMessage = CREATING_RCAD_DB_MESSAGE;
                    _workerDTS.RunWorkerAsync(args);
                }
                else
                {
                    CreateRCADDBArgs args = new CreateRCADDBArgs()
                    {
                        TargetInstance   = _desiredServer,
                        RCADDatabaseName = Database,
                        TargetSQLFile    = ScriptTargetFile,
                        InstallDirectory = _installDirectory,
                        DataDirectory    = _dataDirectory
                    };
                    StatusMessage = CREATING_RCAD_DB_INSTALLSCRIPT;
                    _workerSQLCMD.RunWorkerAsync(args);
                }
            }
        }