public static xlAmo.TraceEvent CreateTrace(xlAmo.TraceEventClass eventClass) { xlAmo.TraceEvent trc = new xlAmo.TraceEvent(eventClass); trc.Columns.Add(xlAmo.TraceColumn.EventClass); trc.Columns.Add(xlAmo.TraceColumn.EventSubclass); trc.Columns.Add(xlAmo.TraceColumn.TextData); trc.Columns.Add(xlAmo.TraceColumn.CurrentTime); if (eventClass != xlAmo.TraceEventClass.VertiPaqSEQueryCacheMatch) { trc.Columns.Add(xlAmo.TraceColumn.StartTime); } trc.Columns.Add(xlAmo.TraceColumn.Spid); trc.Columns.Add(xlAmo.TraceColumn.SessionID); switch (eventClass) { case xlAmo.TraceEventClass.CommandEnd: case xlAmo.TraceEventClass.CalculateNonEmptyEnd: case xlAmo.TraceEventClass.DirectQueryEnd: case xlAmo.TraceEventClass.DiscoverEnd: case xlAmo.TraceEventClass.ExecuteMdxScriptEnd: case xlAmo.TraceEventClass.FileSaveEnd: case xlAmo.TraceEventClass.ProgressReportEnd: case xlAmo.TraceEventClass.QueryCubeEnd: case xlAmo.TraceEventClass.QueryEnd: case xlAmo.TraceEventClass.QuerySubcube: case xlAmo.TraceEventClass.QuerySubcubeVerbose: case xlAmo.TraceEventClass.VertiPaqSEQueryEnd: trc.Columns.Add(xlAmo.TraceColumn.Duration); trc.Columns.Add(xlAmo.TraceColumn.CpuTime); break; case xlAmo.TraceEventClass.Error: trc.Columns.Add(xlAmo.TraceColumn.Error); break; } return trc; }
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) { StopTimer(); _traceStarted = true; Status = QueryTraceStatus.Started; if (TraceStarted != null) TraceStarted(this, null); } else { //OnTraceEvent(e); _capturedEvents.Add( CreateTraceEventArg(e)); if (e.EventClass == xlAmo.TraceEventClass.QueryEnd) { // Raise an event with the captured events if (TraceCompleted != null) TraceCompleted(this, _capturedEvents); // reset the captured events collection _capturedEvents = new List<DaxStudioTraceEventArgs>(); } } }
private void SetupTrace(xlAmo.Trace trace, List<DaxStudioTraceEventClass> events) { // Add CommandBegin so we can catch the heartbeat events if (trace.Events.Find(xlAmo.TraceEventClass.CommandBegin) == null) trace.Events.Add(TraceEventFactoryExcel.CreateTrace(xlAmo.TraceEventClass.CommandBegin)); // Add QueryEnd so we know when to stop the trace if (trace.Events.Find(xlAmo.TraceEventClass.QueryEnd)==null) trace.Events.Add(TraceEventFactoryExcel.CreateTrace(xlAmo.TraceEventClass.QueryEnd)); //reset the watcher so it can clear any cached events ///watcher.Reset(); // catch the events in the ITraceWatcher foreach (DaxStudioTraceEventClass eventClass in events) { var amoEventClass = (ExcelAmo.Microsoft.AnalysisServices.TraceEventClass)eventClass; if (trace.Events.Find(amoEventClass) != null) continue; xlAmo.TraceEvent trcEvent = TraceEventFactoryExcel.CreateTrace(amoEventClass); trace.Events.Add(trcEvent); } trace.Update(); }
private DaxStudioTraceEventArgs CreateTraceEventArg(xlAmo.TraceEventArgs traceEvent) { long cpuTime; long duration; // not all events have CpuTime try { cpuTime = traceEvent.CpuTime; } catch (ArgumentNullException) { cpuTime = 0; } // not all events have a duration try { duration = traceEvent.Duration; } catch (ArgumentNullException) { duration = 0; } var dsEvent = new DaxStudioTraceEventArgs( traceEvent.EventClass.ToString(), traceEvent.EventSubclass.ToString(), duration, cpuTime, traceEvent.TextData); return dsEvent; }