internal void Connect(int[] serverObjectIds)
        {
            SqlConnectionStringBuilder scsb;

            _confirmedServerObjectIds.Clear();
            LongRunningOperationManager.NewOperationBatch(true, false, new[] { new LongRunningOperation(string.Format("Connecting to all server objects...")) });

            if (!LongRunningOperationManager.IsBusy)
            {
                foreach (int serverObjectId in serverObjectIds)
                {
                    scsb = new SqlConnectionStringBuilder(_pool[serverObjectId].ConnectionString);
                    //lro.Add(new LongRunningOperation(string.Format("Connecting to '{0}'", scsb.DataSource), 1.0 / serverObjectIds.Length));
                }

                LongRunningOperationManager.DoWork += lrom_DoWorkConnectToSqlServer;
                LongRunningOperationManager.RunAsync(_pool);
            }

            _confirmedServerObjectIds.AddRange((int[])LongRunningOperationManager.ProcessResult);

            /*
             * if (LongRunningOperationManager.ProcessResult == null)
             * {
             *  _unconfirmedConnections.Remove(serverObjectId);
             *  MyOutput.NewMessage(EOutputMessageType.ERROR, string.Format("Cannot establish connection to '{0}'", scsb.DataSource), true);
             *  return false;
             * }
             * else
             * {
             *  _confirmedConnections.Add(serverObjectId, _unconfirmedConnections[serverObjectId]);
             *  MyOutput.NewMessage(EOutputMessageType.ERROR, string.Format("Connected to '{0}'", scsb.DataSource), true);
             *  return true;
             * }*/
        }
        private void button1_Click(object sender, EventArgs e)
        {
            LongRunningOperationManager.NewOperationBatch(true, true, new [] { new LongRunningOperation("a", 0.6), new LongRunningOperation("b", 0.3), new LongRunningOperation("c", 0.1) });

            LongRunningOperationManager.DoWork += LongRunningOperationManager_DoWork;

            LongRunningOperationManager.RunAsync();
        }
Exemple #3
0
 private void tsbShowInThisWindow_Click(object sender, EventArgs e)
 {
     LongRunningOperationManager.NewOperationBatch(true, true, new[] { new LongRunningOperation("Executing query") });
     LongRunningOperationManager.DoWork          += LongRunningOperationManager_DoWorkExecQuery;
     LongRunningOperationManager.WorkCompleted   += LongRunningOperationManager_ExecQueryCompleted;
     LongRunningOperationManager.WorkerPreCancel += LongRunningOperationManager_WorkerPreCancel;
     LongRunningOperationManager.RunAsync();
 }
Exemple #4
0
        public void newDependencyCheck(object sender, EventArgs e)
        {
            bool useWizard = sender.ToString().Contains("Wizard");

            if (mySqlServer1.ConnectionPool.GetConnection(0).State == ConnectionState.Open && mySqlServer1.SqlCheckedDatabases.Any())
            {
                NewDependencyCheckForm   ndcf = null;
                NewDependencyCheckWizard ndcw = null;

                if (sender.ToString().Contains("Wizard"))
                {
                    ndcw = new NewDependencyCheckWizard(mySqlServer1.SqlCheckedDatabases);
                }
                else
                {
                    ndcf = new NewDependencyCheckForm();
                }

                if ((!useWizard && ndcf.ShowDialog() == DialogResult.OK) || (useWizard && ndcw.ShowDialog() == DialogResult.OK))
                {
                    if (!LongRunningOperationManager.IsBusy)
                    {
                        do
                        {
                            LongRunningOperationManager.NewOperationBatch(true, true, new[] { new LongRunningOperation("Initializing objects and dependencies", 0.45), new LongRunningOperation("Searching for dependencies", 0.45), new LongRunningOperation("Drawing objects", 0.10) });

                            string[]        objTypes = (useWizard) ? ndcw.ObjectTypes : null;
                            string          objName  = (useWizard) ? ndcw.ObjectName : ndcf.ObjectName;
                            bool            topDown  = (useWizard) ? ndcw.IsTopDownDiscovery : ndcf.IsTopDownDiscovery;
                            EMatchMethod    mm       = (useWizard) ? ndcw.MatchMethod : EMatchMethod.Contains;
                            bool            forceInternalDbReload = (useWizard) ? ndcw.IsForceReload : false;
                            string          title     = (useWizard) ? ndcw.SearchObjectFullDescription : ndcf.SearchObjectFullDescription;
                            MySqlDatabase[] searchDbs = (useWizard) ? ndcw.SearchDatabases : null;

                            BwObject bwo = new BwObject {
                                CheckedDatabases = mySqlServer1.SqlCheckedDatabases, ObjectTypes = objTypes, ObjectName = objName, IsTopDownDiscovery = topDown, MatchMethod = mm, IsForceReload = forceInternalDbReload, SearchDatabases = searchDbs, SearchObjectFullDescription = title
                            };

                            LongRunningOperationManager.DoWork        += lrom_DoWorkViewDependencies;
                            LongRunningOperationManager.WorkCompleted += lrom_ViewDependenciesCompleted;
                            LongRunningOperationManager.RunAsync(bwo);
                        }while (LongRunningOperationManager.ProcessResult != null && ((DependencyBackgroundWorkerResult)LongRunningOperationManager.ProcessResult).ResultType == EResultType.RERUN);
                    }
                    else
                    {
                        MessageBox.Show("Please wait for background process to finish.");
                    }
                }
            }
            else
            {
                if (mySqlServer1.ConnectionPool.GetConnection(0).State != ConnectionState.Open)
                {
                    MessageBox.Show("Please connect to SQL Server and then select at least one database from the list to search for dependencies.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }

                if (mySqlServer1.ConnectionPool.GetConnection(0).State == ConnectionState.Open && !mySqlServer1.SqlCheckedDatabases.Any())
                {
                    MessageBox.Show("Please select at least one database from the list to search for dependencies.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }