Пример #1
0
        /// <summary>
        /// Start the capture
        /// </summary>
        /// <param name="filter">A filter string</param>
        /// <param name="parse">Whether parsing the message during capturing</param>
        /// <param name="clearExistingMessages">Whether clear existing messages in the capture lists of capture</param>
        public virtual void Start(string filter = null, bool parse = true, bool clearExistingMessages = false)
        {
            // clear
            if (clearExistingMessages)
            {
                ClearExistingMessage();
            }

            // set event
            viewJournal.ContentChanged += OnViewJournalContentChanged;

            // Create and Set query
            QueryBuilder queryBuilder = monitor.CreateQueryBuilder();

            queryBuilder.FromCompleted();
            queryBuilder.FromAborted();
            queryBuilder.FromStalled();

            if (filter != null)
            {
                queryBuilder.WhereFilter(filter);
            }

            if (!parse)
            {
                captureJournal.DisableParsing = true;
            }
            captureJournal.Query = queryBuilder.Compile();

            // Start Session and Journal
            captureJournal.Start(clearExistingMessages);
            captureJournal.CaptureSession.Start();
            viewJournal.Start(clearExistingMessages);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="monitor"></param>
        /// <param name="catchAllMessages">
        /// False by default and not recommanded to set as true because of the performance.
        /// So far, it is only used in Grouping test scenario
        /// </param>
        internal CaptureFileSession(IMonitor monitor, string filePath, bool isDisablePersistence, bool catchAllMessages)
            : base(monitor)
        {
            this.catchAllMessages     = catchAllMessages;
            this.isDisablePersistence = isDisablePersistence;

            // Only use a default query, Since the query of CaptureJournal of LiveCapture will be updated when start.
            QueryBuilder qb = monitor.CreateQueryBuilder();

            qb.FromCompleted();
            qb.FromAborted();
            qb.FromStalled();
            Query query = qb.Compile();

            captureJournal = monitor.CreateCaptureJournal(query);
            viewJournal    = captureJournal.CreateView(monitor.CreateQueryBuilder().Compile());
            captureJournal.DisablePersistence = isDisablePersistence;

            // Create and initial capture session for capturJournal
            CaptureSession.CreateCaptureSession(monitor, captureJournal, false);
            IMessageReader messageReader = CreateMessageReader(filePath);

            captureJournal.CaptureSession.AddReader(messageReader);

            // Create Monitor work control thread
            monitorWorkControlThread = new Thread(new ThreadStart(MonitorWorkControl));
            monitorWorkControlThread.IsBackground = true;

            if (this.catchAllMessages)
            {
                frameStorage = new FramesStorage();
            }

            // Create Monitor work control thread
            monitorWorkControlThread = new Thread(new ThreadStart(MonitorWorkControl));
            monitorWorkControlThread.IsBackground = true;
        }