Esempio n. 1
0
        public async Task Initialize(DatabaseSession databaseSession, CancellationToken cancellationToken)
        {
            databaseSession = databaseSession.Owner ?? databaseSession;
            var oracleSessionValues = (OracleSessionValues)databaseSession.ProviderValues;

            if (_oracleSessionValues != null && _oracleSessionValues.Instance == oracleSessionValues.Instance && _oracleSessionValues.Id == oracleSessionValues.Id && String.Equals(_oracleSessionValues.SqlId, oracleSessionValues.SqlId) && _oracleSessionValues.ExecutionId == oracleSessionValues.ExecutionId)
            {
                await Refresh(cancellationToken);

                return;
            }

            Shutdown();

            DatabaseSession = databaseSession;

            try
            {
                _oracleSessionValues = oracleSessionValues.Clone();

                if (!String.IsNullOrEmpty(_oracleSessionValues.SqlId) && _oracleSessionValues.ExecutionId.HasValue)
                {
                    var monitorDataProvider = new SqlMonitorDataProvider(_oracleSessionValues.Instance, _oracleSessionValues.Id, _oracleSessionValues.ExecutionStart.Value, _oracleSessionValues.ExecutionId.Value, _oracleSessionValues.SqlId, _oracleSessionValues.ChildNumber.Value);
                    await OracleDatabaseModel.UpdateModelAsync(OracleConnectionStringRepository.GetBackgroundConnectionString(_connectionString.ConnectionString), null, false, cancellationToken, monitorDataProvider);

                    _planItemCollection = monitorDataProvider.ItemCollection;
                    _planItemCollection.RefreshPeriod = DefaultRefreshPeriod;
                    //QueryCoordinatorLongOperations = _planItemCollection.QueryCoordinatorLongOperations;

                    if (_planItemCollection.RootItem != null)
                    {
                        ExecutionPlanTreeView.RootItem = _planItemCollection.RootItem;
                        SessionItems = _planItemCollection.SessionItems;
                        var collectionView = CollectionViewSource.GetDefaultView(SessionItems);
                        collectionView.SortDescriptions.Add(new SortDescription {
                            PropertyName = "SessionIdentifier.Instance"
                        });
                        collectionView.SortDescriptions.Add(new SortDescription {
                            PropertyName = "ParallelServerGroup"
                        });
                        collectionView.SortDescriptions.Add(new SortDescription {
                            PropertyName = "ParallelServerSet"
                        });
                        collectionView.SortDescriptions.Add(new SortDescription {
                            PropertyName = "ParallelServerNumber"
                        });

                        SummarySession.Inititalize(_planItemCollection);

                        await SafeRefresh();
                    }
                }
            }
            finally
            {
                AutoRefreshEnabled = true;
            }
        }
Esempio n. 2
0
        public async Task Refresh(CancellationToken cancellationToken)
        {
            if (_isBusy)
            {
                return;
            }

            lock (LockObject)
            {
                if (_isBusy || _planItemCollection == null)
                {
                    return;
                }

                _isBusy = true;
            }

            try
            {
                var planItemCollection               = _planItemCollection;
                var sessionMonitorDataProvider       = new SessionMonitorDataProvider(planItemCollection);
                var activeSessionHistoryDataProvider = new SqlMonitorActiveSessionHistoryDataProvider(planItemCollection);
                var planMonitorDataProvider          = new SqlMonitorSessionPlanMonitorDataProvider(planItemCollection);
                var sessionLongOperationDataProvider = new SessionLongOperationPlanMonitorDataProvider(planItemCollection);
                await OracleDatabaseModel.UpdateModelAsync(OracleConnectionStringRepository.GetBackgroundConnectionString(_connectionString.ConnectionString), null, false, cancellationToken, sessionMonitorDataProvider, planMonitorDataProvider, activeSessionHistoryDataProvider, sessionLongOperationDataProvider);

                if (planItemCollection != _planItemCollection)
                {
                    return;
                }

                IsParallel = planItemCollection.SessionItems.Count > 1;
            }
            finally
            {
                _isBusy = false;
            }
        }