Exemple #1
0
        void LoadObjects(Database d, IDatabaseDictionary databaseDictionary)
        {
            if (!d.IsSystemObject && d.IsAccessible)
            {
                try
                {
                    var analyzer = new PerformanceAnalyzer();

                    LoadTables(d, databaseDictionary);
                    log.Performance("Loading tables " + d.Name, analyzer.Result);

                    LoadStoredProcs(d, databaseDictionary);
                    log.Performance("Loading procedures " + d.Name, analyzer.Result);

                    LoadViews(d, databaseDictionary);
                    log.Performance("Loading views " + d.Name, analyzer.Result);

                    LoadFunctions(d, databaseDictionary);
                    log.Performance("Loading functions " + d.Name, analyzer.Result);

                    analyzer.Stop();
                }
                catch (Exception ex)
                {
                    // this can get thrown for security reasons - probably need to swallow here
                    log.Error("Security Error in database: " + d.Name, ex);
                }
            }
        }
Exemple #2
0
        void FillDatabase(IDatabaseDictionary databaseDictionary)
        {
            var analyzer = new PerformanceAnalyzer();

            Database d = null;

            if (server.Databases.Contains(databaseDictionary.DatabaseName))
            {
                d = server.Databases[databaseDictionary.DatabaseName];
            }
            else
            {
                log.Error("Database name could not be found: " + databaseDictionary.DatabaseName + "; loader failed");
                return;
            }

            databaseDictionary.Clear();

            // do not need to refresh database RefresDatabase(d);

            log.Performance("Refreshing database " + databaseDictionary.DatabaseName, analyzer.Result);

            LoadObjects(d, databaseDictionary);
            databaseDictionary.MarkAsLoaded();

            log.Performance("Loading database " + databaseDictionary.DatabaseName, analyzer.Result);
            analyzer.Stop();
        }
Exemple #3
0
        private void txtSearch_TextChanged(Object sender, TextChangedEventArgs e)
        {
            log.Info(String.Format("Search text changed to '{0}'", txtSearch.Text));
            var analyzer = new PerformanceAnalyzer();

            DoSearch(false);

            log.Performance("Text changed event handled", analyzer.Result);
            analyzer.Stop();
        }
        public void Run()
        {
            while (true)
            {
                var i = WaitHandle.WaitAny(new WaitHandle[] { stop, doWork });

                if (i == 0)
                {
                    break;
                }

                var processRequest = true;

                while (processRequest)
                {
                    var request = GetRequest();

                    if (request != null)
                    {
                        try
                        {
                            log.Info(String.Format("Processing request: type = {0}, parameter = {{ {1} }}", request.RequestType.ToString(), request.Argument));
                            var analyzer = new PerformanceAnalyzer();

                            request.DoWorkFunction(request.Argument);

                            analyzer.Stop();
                            log.Performance("Request process time", analyzer.Result);
                        }
                        catch (Exception ex)
                        {
                            if (RequestFailed != null)
                            {
                                RequestFailed.Invoke(request, ex);
                            }
                        }
                    }
                    else
                    {
                        processRequest = false;
                    }
                }
            }
        }
Exemple #5
0
        private void Async_PerformSearch(Object arg)
        {
            if (arg == null)
            {
                return;
            }

            var par = (SearchAsyncParam)arg;

            // new request was added - this one is outdated
            if (par.SequenceNumber < _requestSequenceNumber)
            {
                return;
            }

            if (SameAsPreviousSearch(par))
            {
                return;
            }

            SetStatus("Searching '" + par.Text + "' in " + par.Database, true);

            var result = StudioController.Find(par.Srv, par.Database, par.Text, _cfg.LimitSearch);

            // new request was added - this one is outdated
            if (par.SequenceNumber < _requestSequenceNumber)
            {
                log.Info("Cancelled search request because new request was added. " + par.Text);
                return;
            }

            SetStatus("Found " + result.Count + " objects");

            InvokeInUI(() =>
            {
                log.Info("Updating UI items");
                var analyzer = new PerformanceAnalyzer();

                var items = ItemFactory.BuildFromEntries(result);

                itemsControl.ItemsSource   = items;
                itemsControl.SelectedIndex = -1;
                itemsControl.ScrollIntoView(itemsControl.SelectedItem);

                if (items.Count == 0)
                {
                    gridEmptyResult.Visibility = System.Windows.Visibility.Visible;
                    itemsControl.Visibility    = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    gridEmptyResult.Visibility = System.Windows.Visibility.Collapsed;
                    itemsControl.Visibility    = System.Windows.Visibility.Visible;
                }

                log.Performance("UI items updated", analyzer.Result);
                analyzer.Stop();
            });

            if (result.Count == 0)
            {
                SetStatus("Found nothing. Try to refresh");
            }
            else if (result.Count == 1)
            {
                SetStatus("Found exactly one object");
            }
            else
            {
                SetStatus("Found " + result.Count + " objects ");
            }
        }