public void CanRunPostprocessingIfItWasNotRunBefore()
        {
            pp1outputXmlSection.Reader.Returns((XmlReader)null);
            EmitLogSource1Addition();
            mockedSyncContext.Deplete();

            var exposedOutput = manager.LogSourcePostprocessors.Single();

            Assert.AreSame(null, exposedOutput.OutputData);
            Assert.AreEqual(LogSourcePostprocessorState.Status.NeverRun, exposedOutput.OutputStatus);
            Assert.AreSame(null, exposedOutput.LastRunSummary);
            Assert.AreSame(new double?(), exposedOutput.Progress);
            Assert.AreEqual(logSource1, exposedOutput.LogSource);
            Assert.AreEqual(logSourcePP1, exposedOutput.Postprocessor);


            var pp1runResult = new TaskCompletionSource <IPostprocessorRunSummary>();

            logSourcePP1.Run(null).ReturnsForAnyArgs(pp1runResult.Task);

            Task runTask = manager.RunPostprocessors(
                new[] { exposedOutput }, null);

            mockedSyncContext.Deplete();
            Assert.IsFalse(runTask.IsCompleted);

            exposedOutput = manager.LogSourcePostprocessors.Single();
            Assert.AreSame(null, exposedOutput.OutputData);
            Assert.AreEqual(LogSourcePostprocessorState.Status.InProgress, exposedOutput.OutputStatus);
            Assert.AreSame(null, exposedOutput.LastRunSummary);
            Assert.AreSame(new double?(), exposedOutput.Progress);
            Assert.AreEqual(logSource1, exposedOutput.LogSource);
            Assert.AreEqual(logSourcePP1, exposedOutput.Postprocessor);


            pp1outputXmlSection.Reader.Returns(Substitute.For <XmlReader>());
            pp1runResult.SetResult(pp1RunSummary);
            mockedSyncContext.Deplete();
            Assert.IsTrue(runTask.IsCompleted);

            exposedOutput = manager.LogSourcePostprocessors.Single();
            Assert.AreEqual(LogSourcePostprocessorState.Status.Finished, exposedOutput.OutputStatus);
            Assert.AreSame(pp1PostprocessorOutput, exposedOutput.OutputData);
            Assert.AreSame(pp1RunSummary, exposedOutput.LastRunSummary);
            Assert.AreSame(new double?(), exposedOutput.Progress);
            Assert.AreEqual(logSource1, exposedOutput.LogSource);
            Assert.AreEqual(logSourcePP1, exposedOutput.Postprocessor);
        }
 void IToastNotificationItem.PerformAction(string actionId)
 {
     ppm.RunPostprocessors(
         ppm.LogSourcePostprocessors.GetPostprocessorOutputsByPostprocessorId(postprocessorKind)
         );
 }
Exemplo n.º 3
0
        void Refresh()
        {
            bool somethingChanged = false;

            foreach (LogSourceRecord rec in knownLogSources.Values)
            {
                rec.logSourceIsAlive = false;
            }
            foreach (var src in EnumLogSourcesOfKnownTypes())
            {
                if (!knownLogSources.TryGetValue(src.Key, out LogSourceRecord rec))
                {
                    rec = new LogSourceRecord(src.Key, src.Value);
                    foreach (var postprocessorType in rec.metadata.SupportedPostprocessors)
                    {
                        rec.PostprocessorsOutputs.Add(new PostprocessorOutputRecord(
                                                          postprocessorType, rec, updater.Invoke,
                                                          FireChangedEvent, tracer,
                                                          heartbeat, modelSyncContext, threadPoolSyncContext, telemetry, outputDataDeserializer));
                    }

                    knownLogSources  = knownLogSources.Add(src.Key, rec);
                    somethingChanged = true;
                }
                rec.logSourceIsAlive = true;

                foreach (var parserOutput in rec.PostprocessorsOutputs)
                {
                    if (parserOutput.SetState(parserOutput.state.Refresh()))
                    {
                        somethingChanged = true;
                    }
                }
            }
            foreach (LogSourceRecord rec in new List <LogSourceRecord>(knownLogSources.Values))
            {
                if (rec.logSource.IsDisposed)
                {
                    rec.logSourceIsAlive = false;
                }
                if (!rec.logSourceIsAlive)
                {
                    if (!rec.cancellation.IsCancellationRequested)
                    {
                        rec.cancellation.Cancel();
                    }
                    knownLogSources = knownLogSources.Remove(rec.logSource);
                    rec.PostprocessorsOutputs.ForEach(ppo => ppo.Dispose());
                    somethingChanged = true;
                }
            }
            if (somethingChanged)
            {
                FireChangedEvent();
            }

            if (somethingChanged && settingsAccessor.EnableAutoPostprocessing)
            {
                IManagerInternal intf = this;
                var outputs           = intf.LogSourcePostprocessors.GetAutoPostprocessingCapableOutputs().ToArray();
                if (outputs.Length > 0)
                {
                    intf.RunPostprocessors(outputs);
                }
            }
        }
Exemplo n.º 4
0
 async void IViewControlHandler.ExecuteAction(string actionId, ClickFlags flags)
 {
     await postprocessorsManager.RunPostprocessors(getOutputs());
 }