コード例 #1
0
 protected override void DisposeTraces()
 {
     TraceFile.Close();
     TraceFile = null;
     OnLogLine = null;
     Tracable.DefaultOnLogLine = null;
 }
コード例 #2
0
 public void CloseDataFile()
 {
     if (TraceFile != null)
     {
         TraceFile.Close();
         TraceFile = null;
     }
 }
コード例 #3
0
ファイル: Debug.cs プロジェクト: complabs/TextUI
 public static void CloseTraceFile()
 {
     if (TraceStream != null)
     {
         TraceLine("*** END ***");
         TraceStream.Close();
         TraceFile.Close();
         TraceStream = null;
         TraceFile   = null;
     }
 }
コード例 #4
0
 protected override void ProcessRecord()
 {
     // this resolves relative paths and wildcards to a collection of resolved paths
     foreach (PathInfo filePath in this.SessionState.Path.GetResolvedPSPathFromPSPath(mTraceFile))
     {
         TraceFile tf = new TraceFile();
         tf.InitializeAsReader(filePath.ProviderPath);
         while (tf.Read())
         {
             // dynamically build a powershell response object based on
             // the available fields in the trace file.
             PSObject pso = new PSObject();
             for (int i = 0; i < tf.FieldCount; i++)
             {
                 if (!tf.IsNull(i) && tf.GetFieldType(i) == typeof(System.DateTime))
                 {
                     DateTime dt = tf.GetDateTime(i);
                     dt = new DateTime(dt.Ticks, DateTimeKind.Utc);
                     pso.Properties.Add(new PSNoteProperty(tf.GetName(i), dt.ToLocalTime()));
                 }
                 else
                 {
                     pso.Properties.Add(new PSNoteProperty(tf.GetName(i), tf.GetValue(i)));
                 }
             }
             if (!tf.IsNull(tf.GetOrdinal("EventSubclass")) && OutputSSASTraceSubclasses)
             {
                 //pso.Properties.Add(new PSNoteProperty("EventSubClassName",tf.TranslateSubclass((string)tf.GetValue(tf.GetOrdinal("EventClass")),"1" , (int)tf.GetValue(tf.GetOrdinal("EventSubclass")) )));
                 pso.Properties.Add(new PSNoteProperty("EventSubclassName"
                                                       , System.Enum.GetName(typeof(Microsoft.AnalysisServices.TraceEventSubclass), tf.GetValue(tf.GetOrdinal("EventSubclass")))
                                                       ));
             }
             WriteObject(pso);
         }
         tf.Close();
     }
 }
コード例 #5
0
 //public event WriteNotifyEventHandler WriteNotifyEventHandler;
 // Optional Notify handler
 //void writer_WriteNotify(object sender, TraceEventArgs args)
 //{
 //    this.toolStripStatusLabel1.Text = string.Format("Writing: {0}", args.CurrentRecord[0]);
 //    args.SkipRecord = false;
 //}
 public void Save(string filename)
 {
     TraceFile writer = new TraceFile();
     writer.InitializeAsWriter(this.trace, filename);
     //if (WriteNotifyEventHandler != null) writer.WriteNotify += WriteNotifyEventHandler;
     while (writer.Write()) ;
     writer.Close();
 }
コード例 #6
0
        private void ReadTraceFile(string filename)
        {
            var traceFile = new TraceFile();
            traceFile.InitializeAsReader(filename);

            var eventClassOrdinal = traceFile.GetOrdinal("EventClass");
            var textDataOrdinal = traceFile.GetOrdinal("TextData");
            //var databaseNameOrdinal = traceFile.GetOrdinal("DatabaseName");
            var startTimeOrdinal = traceFile.GetOrdinal("StartTime");
            var durationOrdinal = traceFile.GetOrdinal("Duration");

            while (traceFile.Read())
            {
                var eventClass = traceFile.GetString(eventClassOrdinal);

                // skip on start, end on stop
                if (eventClass.Equals("trace start", StringComparison.InvariantCultureIgnoreCase)) continue;
                if (eventClass.Equals("trace stop", StringComparison.InvariantCultureIgnoreCase)) break;

                var textData = traceFile.GetString(textDataOrdinal);
                //var databaseName = traceFile.GetString(databaseNameOrdinal);
                var startTime = traceFile.GetDateTime(startTimeOrdinal);
                var duration = traceFile.GetInt64(durationOrdinal)/1000; // duration is in microseconds

                // send the canonical query to the agent
                _agentConnect.Store(new Sample
                                        {
                                            //Method = databaseName,
                                            Uri = _parser.Rewrite(textData),
                                            ResponseTime = duration,
                                            Timestamp = startTime.Ticks
                                        }, Logger);
                DebugHelper.LogEntry(_eventLog, string.Format("Data sent: '{0}'", textData), EventLogEntryType.SuccessAudit);
            }

            traceFile.Close();
        }
コード例 #7
0
 public bool TearDownService()
 {
     IsCreate = false;
     return(_traceFile.Close());
 }