public void TestVertipaqAnalyzerProfile()
        {
            //var cnnStr = ConnectionString;
            //var cnnStr = @"Data Source=http://localhost:9000/xmla;Workstation ID=C:\Users\c950497\Downloads\RAD Model.xlsx";
            var cnnStr = @"Data Source=localhost:9134;";
            var cnn    = new ADOTabular.ADOTabularConnection(cnnStr, ADOTabular.AdomdClientWrappers.AdomdType.AnalysisServices);

            cnn.Open();
            var db      = cnn.Database;
            var profile = ModelAnalyzer.Create(cnn);



            JsonSerializer serializer = new JsonSerializer();

            //serializer.Converters.Add(new JavaScriptDateTimeConverter());
            serializer.NullValueHandling = NullValueHandling.Ignore;

            using (StreamWriter sw = new StreamWriter(@"d:\temp\BUSINESS_NBN_CUBE_VertipaqAnalyzerProfile.json"))
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    serializer.Serialize(writer, profile);
                    // {"ExpiryDate":new Date(1230375600000),"Price":0}
                }

            cnn.Close();
        }
Beispiel #2
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (_trace != null)
                    {
                        _trace.OnEvent -= OnTraceEventInternal;
                        _trace?.Drop();
                        _trace?.Dispose();
                        _trace = null;
                    }

                    _connection?.Dispose();
                    _connection = null;

                    _server?.Disconnect();
                    _server?.Dispose();
                    _server = null;

                    if (_startingTimer != null)
                    {
                        _startingTimer.Stop();
                        _startingTimer.Elapsed -= OnTimerElapsed;
                        _startingTimer.Dispose();
                        _startingTimer = null;
                    }
                }

                disposedValue = true;
            }
        }
        public void TestAdventureWorksProfile()
        {
            var cnn = new ADOTabular.ADOTabularConnection(ConnectionString, ADOTabular.AdomdClientWrappers.AdomdType.AnalysisServices);

            cnn.Open();
            var db      = cnn.Database;
            var profile = DatabaseProfiler.Create(db);

            Assert.AreEqual(db.Name, profile.Name);
            Assert.AreEqual(7, profile.Tables.Count);

            JsonSerializer serializer = new JsonSerializer();

            //serializer.Converters.Add(new JavaScriptDateTimeConverter());
            serializer.NullValueHandling = NullValueHandling.Ignore;

            using (StreamWriter sw = new StreamWriter(@"c:\temp\profile.json"))
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    serializer.Serialize(writer, profile);
                    // {"ExpiryDate":new Date(1230375600000),"Price":0}
                }

            cnn.Close();
        }
Beispiel #4
0
        private void Start()
        {
            try
            {
                Log.Verbose("{class} {method} {message}", "QueryTraceEngine", "Start", "entering");
                if (_trace != null)
                {
                    if (_trace.IsStarted || Status == QueryTraceStatus.Starting || Status == QueryTraceStatus.Started)
                    {
                        return; // exit here if trace is already started
                    }
                }
                if (Status != QueryTraceStatus.Started)
                {
                    Status = QueryTraceStatus.Starting;
                }
                Log.Verbose("{class} {method} {event}", "QueryTraceEngine", "Start", "Connecting to: " + _connectionString);
                if (_connection != null)
                {
                    _connection.Dispose();
                }
                ConfigureTrace(_connectionString, _connectionType, _sessionId, _applicationName, _databaseName, _filterForCurrentSession);
                _connection = new ADOTabular.ADOTabularConnection(_connectionString, _connectionType);
                try
                {
                    _connection.Open();
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "{class} {method} {message}", "QueryTraceEngine", "Start (connection.open catch)", ex.Message);
                    // try again?
                    _connection.Open();
                }
                _trace = GetTrace();
                SetupTrace(_trace, Events);

                _trace.OnEvent += OnTraceEventInternal;
                _trace.Start();

                // create timer to "ping" the server with DISCOVER_SESSION requests
                // until the trace events start to fire.
                if (_startingTimer == null)
                {
                    _startingTimer = new Timer();
                }

                _startingTimer.Interval = 500;
                _startingTimer.Elapsed += OnTimerElapsed;
                _startingTimer.Enabled  = true;
                _startingTimer.Start();
                utcPingStart = DateTime.UtcNow;
                // Wait for Trace to become active
                Log.Verbose("{class} {method} {message}", "QueryTraceEngine", "Start", "exiting");
            }
            catch (Exception ex)
            {
                RaiseError(ex);
                //Log.Error("{class} {method} {message}","QueryTraceEngine" , "Start", ex.Message);
            }
        }
Beispiel #5
0
        private void OnTraceEventInternal(object sender, xlAmo.TraceEventArgs e)
        {
            // we are using CommandBegin as a "heartbeat" to check if the trace
            // has started capturing events
            if (!_traceStarted)
            {
                Log.Debug("{class} {mothod} Pending TraceEvent: {eventClass}", "QueryTraceEngineExcel", "OnTraceEventInternal", e.EventClass.ToString());
                StopTimer();
                _traceStarted = true;
                _connection.Close(false);
                _connection.Dispose();
                _connection = null;
                Status      = QueryTraceStatus.Started;
                TraceStarted?.Invoke(this, null);

                var f = new System.IO.FileInfo(_trace.Parent.Name);
                _friendlyServerName = f.Name;
            }
            else
            {
                Log.Debug("{class} {method} TraceEvent: {eventClass}", "QueryTraceEngineExcel", "OnTraceEventInternal", e.EventClass.ToString());
                //OnTraceEvent(e);
                _capturedEvents.Add(CreateTraceEventArg(e, _friendlyServerName));
                if (e.EventClass == xlAmo.TraceEventClass.QueryEnd)
                {
                    // Raise an event with the captured events
                    TraceCompleted?.Invoke(this, _capturedEvents);
                    // reset the captured events collection
                    _capturedEvents = new List <DaxStudioTraceEventArgs>();
                }
            }
        }
Beispiel #6
0
        public void Start()
        {
            try
            {
                Log.Debug("{class} {method} {event}", "QueryTraceEngine", "Start", "entered");

                if (_trace != null)
                {
                    if (_trace.IsStarted || Status == QueryTraceStatus.Starting || Status == QueryTraceStatus.Started)
                    {
                        Log.Debug("{class} {method} {event}", "QueryTraceEngine", "Start", "exiting method - trace already started");
                        return; // if threturn; // exit here if trace is already startede trace is already running exit here
                    }
                }

                if (Status != QueryTraceStatus.Started)
                {
                    Status = QueryTraceStatus.Starting;
                }
                Log.Debug("{class} {method} {event}", "QueryTraceEngine", "Start", "Connecting to: " + _connectionString);
                //HACK - wait 1.5 seconds to allow trace to start
                //       using the ping method thows a connection was lost error when starting a second trace
                _connection = new ADOTabular.ADOTabularConnection($"{_originalConnectionString};SessionId={_sessionId}", _connectionType);
                _connection.Open();
                _trace = GetTrace();
                SetupTrace(_trace, Events);

                _trace.OnEvent += OnTraceEventInternal;
                _trace.Start();

                // create timer to "ping" the server with DISCOVER_SESSION requests
                // until the trace events start to fire.
                if (_startingTimer == null)
                {
                    _startingTimer = new Timer();
                }
                //HACK - wait 1.5 seconds to allow trace to start
                //       using the ping method thows a connection was lost error when starting a second trace
                _startingTimer.Interval = 300;
                _startingTimer.Elapsed += OnTimerElapsed;
                _startingTimer.Enabled  = true;
                _startingTimer.Start();
                utcPingStart = DateTime.UtcNow;
                // Wait for Trace to become active
                Log.Debug("{class} {method} {event}", "QueryTraceEngine", "Start", "exit");
            }
            catch (Exception ex)
            {
                OutputError($"Error starting trace: {ex.Message}");
                Log.Error("{class} {method} {message} {stacktrace}", "QueryTraceEngine", "Start", ex.Message, ex.StackTrace);
            }
        }
        public static bool ShouldAutoRefreshMetadata(this ADOTabular.ADOTabularConnection conn, IGlobalOptions options)
        {
            switch (conn.ConnectionType)
            {
            case ADOTabular.ADOTabularConnectionType.Cloud:
                return(options.AutoRefreshMetadataCloud);

            case ADOTabular.ADOTabularConnectionType.LocalNetwork:
                return(options.AutoRefreshMetadataLocalNetwork);

            case ADOTabular.ADOTabularConnectionType.LocalMachine:
                return(options.AutoRefreshMetadataLocalMachine);

            default:
                return(true);
            }
        }
Beispiel #8
0
        public static IQueryTrace CreateRemote(ADOTabular.ADOTabularConnection connection, List <DaxStudioTraceEventClass> events, int port, IGlobalOptions globalOptions, bool filterForCurrentSession)
        {
            var dsEvents = events.Select(e => (DaxStudioTraceEventClass)e).ToList();

            return(new RemoteQueryTraceEngine(connection.ConnectionString, connection.Type, connection.SessionId, dsEvents, port, globalOptions, filterForCurrentSession, connection.FileName));
        }
Beispiel #9
0
        public static IQueryTrace CreateLocal(ADOTabular.ADOTabularConnection connection, List <DaxStudioTraceEventClass> events, IGlobalOptions globalOptions, bool filterForCurrentSession)
        {
            var dsEvents = events.Select(e => (DaxStudioTraceEventClass)e).ToList();

            return(new QueryTraceEngine(connection.ConnectionString, connection.Type, connection.SessionId, connection.ApplicationName, connection?.Database?.Name, dsEvents, globalOptions, filterForCurrentSession, connection.FileName));
        }
        //public void Clear()
        //{
        //    _trace.Events.Clear();
        //}
        public void Start()
        {
            if (_trace != null)
                if (_trace.IsStarted || Status == QueryTraceStatus.Starting )
                    return; // if the trace is already running exit here

            if (Status != QueryTraceStatus.Started)  Status = QueryTraceStatus.Starting;
            _connection = new ADOTabular.ADOTabularConnection(_connectionString, _connectionType);
            _connection.Open();
            _trace = GetTrace();
            SetupTrace(_trace, _eventsToCapture);
            _trace.Start();

            // create timer to "ping" the server with DISCOVER_SESSION requests
            // until the trace events start to fire.
            if (_startingTimer == null)
                _startingTimer = new Timer();
            _startingTimer.Interval = 300;  //TODO - make time interval shorter?
            _startingTimer.Elapsed += OnTimerElapsed;
            _startingTimer.Enabled = true;
            _startingTimer.Start();
            utcPingStart = DateTime.UtcNow;
            // Wait for Trace to become active
        }
Beispiel #11
0
        public static IQueryTrace CreateLocal(ADOTabular.ADOTabularConnection connection, List <DaxStudioTraceEventClass> events, IGlobalOptions globalOptions)
        {
            var dsEvents = events.Select(e => (DaxStudioTraceEventClass)e).ToList();

            return(new QueryTraceEngine(connection.ConnectionString, connection.Type, connection.SessionId, connection.ApplicationName, dsEvents, globalOptions));
        }
        public void Start()
        {
            try
            {
                if (_trace != null)
                    if (_trace.IsStarted || Status == QueryTraceStatus.Starting)
                        return; // exit here if trace is already started

                if (Status != QueryTraceStatus.Started)  Status = QueryTraceStatus.Starting;
                Log.Verbose("{class} {method} {event}", "QueryTraceEngine", "Start", "Connecting to: " + _connectionString);
                _connection = new ADOTabular.ADOTabularConnection(_connectionString, _connectionType);
                _connection.Open();
                _trace = GetTrace();
                SetupTrace(_trace, _eventsToCapture);
                _trace.Start();

                // create timer to "ping" the server with DISCOVER_SESSION requests
                // until the trace events start to fire.
                if (_startingTimer == null)
                    _startingTimer = new Timer();
                _startingTimer.Interval = 300;  //TODO - make time interval shorter?
                _startingTimer.Elapsed += OnTimerElapsed;
                _startingTimer.Enabled = true;
                _startingTimer.Start();
                utcPingStart = DateTime.UtcNow;
                // Wait for Trace to become active
            }
            catch (Exception ex)
            {
                Log.Error("{class} {method} {message}","QueryTraceEngine" , "Start", ex.Message);
            }
        }