Пример #1
0
 internal FormatDetectionStep(PreprocessingStepParams srcFile, IExtensionsRegistry extentions, IStepsFactory preprocessingStepsFactory, IFileSystem fileSystem)
 {
     this.sourceFile = srcFile;
     this.preprocessingStepsFactory = preprocessingStepsFactory;
     this.extentions = extentions;
     this.fileSystem = fileSystem;
 }
Пример #2
0
        async Task <PreprocessingStepParams> IPreprocessingStep.ExecuteLoadedStep(IPreprocessingStepCallback callback, string param)
        {
            PreprocessingStepParams ret = null;

            await ExecuteInternal(callback, param, x => { ret = x; return(false); });

            return(ret);
        }
Пример #3
0
 IPreprocessingStep CreateStepByName(string name, PreprocessingStepParams param)
 {
     return
         (extensions
          .Items
          .Select(e => e.CreateStepByName(name, param))
          .FirstOrDefault(s => s != null));
 }
Пример #4
0
 internal UntarStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAggregator,
     IStepsFactory preprocessingStepsFactory)
 {
     this.@params = srcFile;
     this.preprocessingStepsFactory = preprocessingStepsFactory;
     this.progressAggregator        = progressAggregator;
 }
Пример #5
0
 internal GunzippingStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAggregator,
     IPreprocessingStepsFactory preprocessingStepsFactory)
 {
     this.sourceFile = srcFile;
     this.preprocessingStepsFactory = preprocessingStepsFactory;
     this.progressAggregator        = progressAggregator;
 }
Пример #6
0
 static PreprocessingStepParams SetArgument(PreprocessingStepParams p, string argument)
 {
     return(new PreprocessingStepParams(
                p?.Location,
                p?.FullPath,
                p?.PreprocessingHistory,
                p?.DisplayName,
                argument
                ));
 }
Пример #7
0
 internal UnpackingStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAggregator,
     ICredentialsCache credCache,
     IPreprocessingStepsFactory preprocessingStepsFactory)
 {
     this.sourceFile = srcFile;
     this.preprocessingStepsFactory = preprocessingStepsFactory;
     this.progressAggregator        = progressAggregator;
     this.credCache = credCache;
 }
Пример #8
0
 internal TimeAnomalyFixingStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAggregator,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IPreprocessingStepsFactory preprocessingStepsFactory)
 {
     this.sourceFile = srcFile;
     this.preprocessingStepsFactory  = preprocessingStepsFactory;
     this.progressAggregator         = progressAggregator;
     this.logProviderFactoryRegistry = logProviderFactoryRegistry;
 }
Пример #9
0
 static bool IsGzip(PreprocessingStepParams fileInfo, IStreamHeader header)
 {
     if (HasGzExtension(fileInfo.Location) || HasGzExtension(fileInfo.FullPath))
     {
         if (header.Header.Take(2).SequenceEqual(new byte[] { 0x1f, 0x8b }))
         {
             return(IsGzipFile(fileInfo.Location));
         }
     }
     return(false);
 }
Пример #10
0
 static bool IsZip(PreprocessingStepParams fileInfo, IStreamHeader header)
 {
     if (HasZipExtension(fileInfo.Location) || HasZipExtension(fileInfo.FullPath))
     {
         if (header.Header.Take(4).SequenceEqual(new byte[] { 0x50, 0x4b, 0x03, 0x04 }))
         {
             return(Ionic.Zip.ZipFile.IsZipFile(fileInfo.Location, false));
         }
     }
     return(false);
 }
Пример #11
0
 internal UnpackingStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAggregator,
     ICredentialsCache credCache,
     IStepsFactory preprocessingStepsFactory,
     IFileSystem fileSystem)
 {
     this.@params = srcFile;
     this.preprocessingStepsFactory = preprocessingStepsFactory;
     this.progressAggregator        = progressAggregator;
     this.credCache  = credCache;
     this.fileSystem = fileSystem;
 }
Пример #12
0
 internal TimeAnomalyFixingStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAggregator,
     ILogProviderFactoryRegistry logProviderFactoryRegistry,
     IStepsFactory preprocessingStepsFactory,
     RegularExpressions.IRegexFactory regexFactory)
 {
     this.@params = srcFile;
     this.preprocessingStepsFactory  = preprocessingStepsFactory;
     this.progressAggregator         = progressAggregator;
     this.logProviderFactoryRegistry = logProviderFactoryRegistry;
     this.regexFactory = regexFactory;
 }
Пример #13
0
 internal URLTypeDetectionStep(
     PreprocessingStepParams srcFile,
     IStepsFactory preprocessingStepsFactory,
     Workspaces.IWorkspacesManager workspacesManager,
     AppLaunch.ILaunchUrlParser appLaunch,
     IExtensionsRegistry extensions
     )
 {
     this.sourceFile = srcFile;
     this.preprocessingStepsFactory = preprocessingStepsFactory;
     this.workspacesManager         = workspacesManager;
     this.appLaunch  = appLaunch;
     this.extensions = extensions;
 }
Пример #14
0
        public static void DumpToConnectionParams(this PreprocessingStepParams prepParams, IConnectionParams connectParams)
        {
            int stepIdx = 0;

            foreach (var step in prepParams.PreprocessingHistory)
            {
                connectParams[$"{ConnectionParamsKeys.PreprocessingStepParamPrefix}{stepIdx}"] = step.ToString();
                ++stepIdx;
            }
            connectParams[ConnectionParamsKeys.IdentityConnectionParam] = prepParams.FullPath.ToLower();
            if (!string.IsNullOrEmpty(prepParams.DisplayName))
            {
                connectParams[ConnectionParamsKeys.DisplayNameConnectionParam] = prepParams.DisplayName;
            }
        }
Пример #15
0
        public static void DumpToConnectionParams(this PreprocessingStepParams prepParams, IConnectionParams connectParams)
        {
            int stepIdx = 0;

            foreach (var step in prepParams.PreprocessingSteps)
            {
                connectParams[string.Format("{0}{1}", ConnectionParamsUtils.PreprocessingStepParamPrefix, stepIdx)] = step;
                ++stepIdx;
            }
            connectParams[ConnectionParamsUtils.IdentityConnectionParam] = prepParams.FullPath.ToLower();
            if (!string.IsNullOrEmpty(prepParams.DisplayName))
            {
                connectParams[ConnectionParamsUtils.DisplayNameConnectionParam] = prepParams.DisplayName;
            }
        }
Пример #16
0
            async Task <PreprocessingStepParams> IPreprocessingStepCallback.ReplayHistory(ImmutableArray <PreprocessingHistoryItem> history)
            {
                PreprocessingStepParams currentParams = null;

                foreach (var loadedStep in history)
                {
                    currentParams = await ProcessLoadedStep(loadedStep, currentParams).ConfigureAwait(continueOnCapturedContext: !isLongRunning);

                    if (currentParams == null)
                    {
                        return(null);
                    }
                }
                return(currentParams);
            }
Пример #17
0
            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);
                    }
                };
            }
Пример #18
0
        static bool IsTar(PreprocessingStepParams fileInfo, IStreamHeader header)
        {
            var tarHeader = new ICSharpCode.SharpZipLib.Tar.TarHeader
            {
                Magic = "xxxxx"
            };

            try
            {
                tarHeader.ParseBuffer(header.Header);
            }
            catch (Exception)
            {
                return(false);
            }
            return(tarHeader.IsChecksumValid ||
                   tarHeader.Magic?.Contains(ICSharpCode.SharpZipLib.Tar.TarHeader.TMAGIC) == true);
        }
Пример #19
0
 internal DownloadingStep(
     PreprocessingStepParams srcFile,
     Progress.IProgressAggregator progressAgg,
     Persistence.IWebContentCache cache,
     ICredentialsCache credCache,
     WebViewTools.IWebViewTools webBrowserDownloader,
     ILogsDownloaderConfig config,
     IStepsFactory preprocessingStepsFactory
     )
 {
     this.sourceFile = srcFile;
     this.preprocessingStepsFactory = preprocessingStepsFactory;
     this.progressAggregator        = progressAgg;
     this.cache                = cache;
     this.credCache            = credCache;
     this.webBrowserDownloader = webBrowserDownloader;
     this.config               = config;
 }
Пример #20
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
                });
            }
        }
Пример #21
0
        IPreprocessingStep IPreprocessingManagerExtension.CreateStepByName(string stepName, PreprocessingStepParams stepParams)
        {
            switch (stepName)
            {
            case GetPreprocessingStep.name:
                return(new GetPreprocessingStep(stepParams));

            case DownloadingStep.name:
                return(stepsFactory.CreateDownloadingStep(stepParams));

            case UnpackingStep.name:
                return(stepsFactory.CreateUnpackingStep(stepParams));

            case GunzippingStep.name:
                return(stepsFactory.CreateGunzippingStep(stepParams));

            case TimeAnomalyFixingStep.name:
                return(stepsFactory.CreateTimeAnomalyFixingStep(stepParams));

            default:
                return(null);
            }
        }
Пример #22
0
 IPreprocessingStep IPreprocessingManagerExtension.DetectFormat(PreprocessingStepParams param, IStreamHeader header)
 {
     return(null);
 }
Пример #23
0
 IPreprocessingStep IStepsFactory.CreateUntarStep(PreprocessingStepParams p)
 {
     return(new UntarStep(p, progressAggregator, this));
 }
Пример #24
0
 IPreprocessingStep IStepsFactory.CreateTimeAnomalyFixingStep(PreprocessingStepParams p)
 {
     return(new TimeAnomalyFixingStep(p, progressAggregator, logProviderFactoryRegistry, this, regexFactory));
 }
Пример #25
0
 IPreprocessingStep IStepsFactory.CreateLocationTypeDetectionStep(PreprocessingStepParams p)
 {
     return(new LocationTypeDetectionStep(p, this));
 }
Пример #26
0
 IPreprocessingStep IStepsFactory.CreateOpenWorkspaceStep(PreprocessingStepParams p)
 {
     return(new OpenWorkspaceStep(p, workspacesManager, invoke));
 }
Пример #27
0
 IPreprocessingStep IStepsFactory.CreateURLTypeDetectionStep(PreprocessingStepParams p)
 {
     return(new URLTypeDetectionStep(p, this, workspacesManager, appLaunch, extentions));
 }
Пример #28
0
 IPreprocessingStep IStepsFactory.CreateUnpackingStep(PreprocessingStepParams p)
 {
     return(new UnpackingStep(p, progressAggregator, credCache, this));
 }
Пример #29
0
 IPreprocessingStep IStepsFactory.CreateDownloadingStep(PreprocessingStepParams p)
 {
     return(new DownloadingStep(p, progressAggregator, cache, credCache, webViewTools, logsDownloaderConfig, this));
 }
Пример #30
0
 IPreprocessingStep IStepsFactory.CreateFormatDetectionStep(PreprocessingStepParams p)
 {
     return(new FormatDetectionStep(p, extentions, this));
 }