Exemplo 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;
            }
        }
Exemplo n.º 2
0
		public OracleConnectionAdapter(OracleDatabaseModel databaseModel)
		{
			_databaseModel = databaseModel;

			var identifier = Convert.ToString(Interlocked.Increment(ref _counter));
			UpdateModuleName(identifier);

			InitializeUserConnection();

			SwitchCurrentSchema();
		}
Exemplo n.º 3
0
        public void BasicTest()
        {
            var databaseModel = OracleDatabaseModel.GetDatabaseModel(ConnectionString, "DebuggerTestConnection");

            databaseModel.Initialize().Wait();
            var connectionAdapter = (OracleConnectionAdapter)databaseModel.CreateConnectionAdapter();

            OracleConfiguration.Configuration.StartupScript = "ALTER SESSION SET plsql_debug = true";

            const string sql =
                @"DECLARE
	var1 NUMBER NOT NULL := 1;
	var2 VARCHAR2(30);
	var3 SYS.ODCIVARCHAR2LIST := SYS.ODCIVARCHAR2LIST('value 1', 'value 2');
BEGIN
	var1 := var1 + 1;
	var2 := 'Dummy test';
END;";

            var statement = OracleSqlParser.Instance.Parse(sql).Single();

            statement.ParseStatus.ShouldBe(ParseStatus.Success);
            var validationModel = _validator.BuildValidationModel(_validator.BuildSemanticModel(sql, statement, databaseModel));

            var batchModel =
                new StatementBatchExecutionModel
            {
                Statements =
                    new []
                {
                    new StatementExecutionModel
                    {
                        StatementText   = sql,
                        ValidationModel = validationModel,
                        BindVariables   = new BindVariableModel[0]
                    }
                },
                EnableDebug = true
            };

            var task = connectionAdapter.ExecuteStatementAsync(batchModel, CancellationToken.None);

            task.Wait();

            connectionAdapter.DebuggerSession.ShouldNotBeNull();

            connectionAdapter.DebuggerSession.Attached += DebuggerSessionAttachedHandler;
            connectionAdapter.DebuggerSession.Start(CancellationToken.None);

            _resetEvent.WaitOne();

            connectionAdapter.DebuggerSession.ShouldBeNull();
        }
Exemplo n.º 4
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;
            }
        }
 public IDatabaseModel CreateDatabaseModel(ConnectionStringSettings connectionString, string identifier)
 {
     return(OracleDatabaseModel.GetDatabaseModel(connectionString, identifier));
 }
 static OracleInfrastructureFactory()
 {
     OracleDatabaseModel.ValidateConfiguration();
 }