public LogSourcePreprocessing(
                LogSourcesPreprocessingManager owner,
                IPreprocessingUserRequests userRequests,
                Action <YieldedProvider> providerYieldedCallback,
                RecentLogEntry recentLogEntry,
                PreprocessingOptions options
                ) :
                this(owner, userRequests, providerYieldedCallback)
            {
                this.options = options;
                preprocLogic = async() =>
                {
                    IConnectionParams            preprocessedConnectParams = null;
                    IFileBasedLogProviderFactory fileBasedFactory          = recentLogEntry.Factory as IFileBasedLogProviderFactory;
                    bool interrupted = false;
                    if (fileBasedFactory != null)
                    {
                        using (var perfop = new Profiling.Operation(trace, recentLogEntry.Factory.GetUserFriendlyConnectionName(recentLogEntry.ConnectionParams)))
                        {
                            PreprocessingStepParams currentParams = null;
                            foreach (var loadedStep in LoadStepsFromConnectionParams(recentLogEntry.ConnectionParams))
                            {
                                currentParams = await ProcessLoadedStep(loadedStep, currentParams).ConfigureAwait(continueOnCapturedContext: !isLongRunning);

                                perfop.Milestone(string.Format("completed {0} {1}", loadedStep.Action, loadedStep.Param));
                                if (currentParams == null)
                                {
                                    interrupted = true;
                                    break;
                                }
                                currentDescription = genericProcessingDescription;
                            }
                            if (currentParams != null)
                            {
                                preprocessedConnectParams = fileBasedFactory.CreateParams(currentParams.Uri);
                                currentParams.DumpToConnectionParams(preprocessedConnectParams);
                            }
                        }
                    }
                    if (!interrupted)
                    {
                        var provider = new YieldedProvider(recentLogEntry.Factory, preprocessedConnectParams ?? recentLogEntry.ConnectionParams, "",
                                                           (this.options & PreprocessingOptions.MakeLogHidden) != 0);
                        ((IPreprocessingStepCallback)this).YieldLogProvider(provider);
                    }
                };
            }
Esempio n. 2
0
        static void AutodetectFormatAndYield(PreprocessingStepParams file, IPreprocessingStepCallback callback)
        {
            callback.SetStepDescription(string.Format("Detecting format: {0}", file.FullPath));
            var progressHandler = new ProgressHandler()
            {
                callback = callback
            };
            var detectedFormat = callback.FormatAutodetect.DetectFormat(file.Location, file.FullPath, progressHandler.cancellation.Token, progressHandler);

            if (detectedFormat != null)
            {
                file.DumpToConnectionParams(detectedFormat.ConnectParams);
                callback.YieldLogProvider(new YieldedProvider()
                {
                    Factory          = detectedFormat.Factory,
                    ConnectionParams = detectedFormat.ConnectParams,
                    DisplayName      = file.FullPath,
                    IsHiddenLog      = false
                });
            }
        }