Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
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>();
                }
            }
        }
Exemplo n.º 4
0
        // private variables
        private void OnTraceEventInternal(object sender, TraceEventArgs e)
        {
            try
            {
                if (_globalOptions.TraceDirectQuery && _filterForCurrentSession)
                {
                    if ((e.SessionID != null) && (e.SessionID != _sessionId))
                    {
                        System.Diagnostics.Debug.Print("Skipped event by session {0} - {1}", e.EventClass.ToString(), e.SessionID);
                        Log.Verbose("Skipped event by session {EventClass} - {sessionId}", e.EventClass.ToString(), e.SessionID);
                        return;
                    }
                    // Check ActivityId only for DirectQueryEnd event (others should be already filtered by SessionID)
                    if (e.EventClass == TraceEventClass.DirectQueryEnd)
                    {
                        bool bSkipByActivity = string.IsNullOrEmpty(_activityId);
                        if (!bSkipByActivity)
                        {
                            bSkipByActivity = e[TraceColumn.ActivityID] != _activityId;
                        }
                        if (bSkipByActivity)
                        {
                            System.Diagnostics.Debug.Print("Skipped event by activity {0} - {1}", e.EventClass.ToString(), e[TraceColumn.ActivityID]);
                            Log.Verbose("Skipped event by activity {EventClass} - {sessionId}", e.EventClass.ToString(), e[TraceColumn.ActivityID]);
                            return;
                        }
                    }
                }
                // we are using CommandBegin as a "heartbeat" to check if the trace
                // has started capturing events
                if (!_traceStarted)
                {
                    System.Diagnostics.Debug.Print("Pending TraceEvent: {0}", e.EventClass.ToString());
                    Log.Verbose("Pending TraceEvent: {EventClass} - {EventSubClass}", e.EventClass.ToString(), e.EventSubclass.ToString());
                    Log.Verbose("Saving ActivityID: {ActivityID}", e[TraceColumn.ActivityID]);

                    StopTimer();
                    _traceStarted = true;
                    _connection.Close(false);
                    Status = QueryTraceStatus.Started;
                    if (TraceStarted != null)
                    {
                        Log.Debug("{class} {method} {message}", "QueryTraceEngine", "OnTraceEventInternal", "Notifying subscribers that Trace has started");
                        TraceStarted(this, null);
                    }
                    else
                    {
                        Log.Debug("{class} {method} {message}", "QueryTraceEngine", "OnTraceEventInternal", "No Trace started subscribers found");
                    }
                }
                else
                {
                    System.Diagnostics.Debug.Print("TraceEvent: {0}", e.EventClass.ToString());
                    Log.Verbose("TraceEvent: {EventClass} - {EventSubClass} - {ActivityId}", e.EventClass.ToString(), e.EventSubclass.ToString(), e[TraceColumn.ActivityID]);
                    if (e.EventClass == TraceEventClass.QueryBegin)
                    {
                        // Save activityId and skip event handling
                        _activityId = e[TraceColumn.ActivityID];
                        Log.Verbose("Started ActivityId: {EventClass} - {ActivityId}", e.EventClass.ToString(), e[TraceColumn.ActivityID]);
                        return;
                    }

                    OnTraceEvent(e);
                    _capturedEvents.Add(new DaxStudioTraceEventArgs(e, _powerBIFileName));
                    if (e.EventClass == TraceEventClass.QueryEnd)
                    {
                        // Raise an event with the captured events
                        if (TraceCompleted != null)
                        {
                            TraceCompleted(this, _capturedEvents);
                        }
                        // reset the captured events collection
                        _capturedEvents = new List <DaxStudioTraceEventArgs>();

                        // Reset activity ID
                        _activityId = null;
                    }
                }
            }
            catch (Exception ex)
            {
                Execute.OnUIThreadAsync(() => RaiseError(ex));
            }
        }
Exemplo n.º 5
0
        private void OnTraceEventInternal(object sender, TraceEventArgs e)
        {
            try
            {
                if (_globalOptions.TraceDirectQuery && _filterForCurrentSession)
                {
                    if ((e.SessionID != null) && (e.SessionID != _sessionId))
                    {
                        System.Diagnostics.Debug.Print("Skipped event by session {0} - {1}", e.EventClass.ToString(), e.SessionID);
                        Log.Verbose("Skipped event by session {EventClass} - {sessionId}", e.EventClass.ToString(), e.SessionID);
                        return;
                    }
                    // Check ActivityId only for DirectQueryEnd event (others should be already filtered by SessionID)
                    if (e.EventClass == TraceEventClass.DirectQueryEnd)
                    {
                        bool bSkipByActivity = string.IsNullOrEmpty(_activityId);
                        if (!bSkipByActivity)
                        {
                            bSkipByActivity = e[TraceColumn.ActivityID] != _activityId;
                        }
                        if (bSkipByActivity)
                        {
                            System.Diagnostics.Debug.Print("Skipped event by activity {0} - {1}", e.EventClass.ToString(), e[TraceColumn.ActivityID]);
                            Log.Verbose("Skipped event by activity {EventClass} - {sessionId}", e.EventClass.ToString(), e[TraceColumn.ActivityID]);
                            return;
                        }
                    }
                }
                // we are using CommandBegin as a "heartbeat" to check if the trace
                // has started capturing events
                if (!_traceStarted)
                {
                    System.Diagnostics.Debug.Print("Pending TraceEvent: {0}", e.EventClass.ToString());
                    Log.Verbose("Pending TraceEvent: {EventClass} - {EventSubClass}", e.EventClass.ToString(), e.EventSubclass.ToString());
                    Log.Verbose("Saving ActivityID: {ActivityID}", e[TraceColumn.ActivityID]);

                    StopTimer();
                    _traceStarted = true;
                    _connection.Close(false);
                    Status = QueryTraceStatus.Started;
                    if (TraceStarted != null)
                    {
                        Log.Debug("{class} {method} {message}", "QueryTraceEngine", "OnTraceEventInternal", "Notifying subscribers that Trace has started");
                        TraceStarted(this, null);
                    }
                    else
                    {
                        Log.Debug("{class} {method} {message}", "QueryTraceEngine", "OnTraceEventInternal", "No Trace started subscribers found");
                    }
                }
                else
                {
                    // exit early if there is no text in the query
                    if ((e.EventClass == TraceEventClass.QueryBegin ||
                         e.EventClass == TraceEventClass.QueryEnd) && e.TextData.StartsWith("/* PING */"))
                    {
                        Debug.WriteLine("Skipping Empty <Statement>");
                        return;
                    }


                    System.Diagnostics.Debug.Print("TraceEvent: {0}", e.EventClass.ToString());
                    Log.Verbose("TraceEvent: {EventClass} - {EventSubClass} - {ActivityId}", e.EventClass.ToString(), e.EventSubclass.ToString(), e[TraceColumn.ActivityID]);
                    if (e.EventClass == TraceEventClass.QueryBegin)
                    {
                        // Save activityId and skip event handling
                        _activityId = e[TraceColumn.ActivityID];
                        Log.Verbose("Started ActivityId: {EventClass} - {ActivityId}", e.EventClass.ToString(), e[TraceColumn.ActivityID]);
                        //return;
                    }

                    OnTraceEvent(e);
                    _capturedEvents.Add(new DaxStudioTraceEventArgs(e, _powerBiFileName));
                    if (e.EventClass == TraceEventClass.QueryEnd)
                    {
                        // if this is not an internal DAX Studio query
                        // like the one we issue after a ClearCache to re-establish the session
                        // then call TraceCompleted, otherwise we clear out the captured events
                        // and keep waiting
                        if (!e.TextData.Contains(Constants.InternalQueryHeader))
                        {
                            // Raise an event with the captured events
                            TraceCompleted?.Invoke(this, _capturedEvents);
                        }
                        // reset the captured events collection
                        _capturedEvents = new List <DaxStudioTraceEventArgs>();

                        // Reset activity ID
                        _activityId = null;
                    }
                }
            }
            catch (Exception ex)
            {
                Execute.OnUIThreadAsync(() => RaiseError(ex));
            }
        }