Exemple #1
0
        private async Task RunFileProcessorAsync()
        {
            Log.Info($"Starting {FileHelper.ExeNameAndVersion}.");

            StatusIndicator = new StatusIndicator();

            var fileProcessor = new FileDetector
            {
                Context            = Context,
                CancellationToken  = CancellationTokenSource.Token,
                StatusIndicator    = StatusIndicator,
                CancellationAction = () => CancellationTokenSource.Cancel()
            };

            await Task.Run(() => fileProcessor.Run(), CancellationTokenSource.Token);
        }
        private void Validate()
        {
            if (string.IsNullOrWhiteSpace(Context.HotFolderPath))
            {
                throw new ExpectedException($"You must specify a /{nameof(Context.HotFolderPath)} option.");
            }

            Context.HotFolderPath = ResolvePath(FileHelper.ExeDirectory, Context.HotFolderPath);

            SourceFolder = Context.HotFolderPath;

            ThrowIfFolderIsMissing(SourceFolder);

            StatusIndicator.Activate(SourceFolder);

            ProcessingFolder = ResolveSourceFolderPath(Context.ProcessingFolder);
            PartialFolder    = ResolveSourceFolderPath(Context.PartialFolder);
            ArchivedFolder   = ResolveSourceFolderPath(Context.ArchivedFolder);
            UploadedFolder   = ResolveSourceFolderPath(Context.UploadedFolder);
            FailedFolder     = ResolveSourceFolderPath(Context.FailedFolder);

            FileMasks = (Context.FileMask ?? "*.*")
                        .Split(FileMaskDelimiters, StringSplitOptions.RemoveEmptyEntries)
                        .Where(mask => !string.IsNullOrWhiteSpace(mask))
                        .Select(CreateRegexFromDosWildcard)
                        .ToList();

            LoadLocalPlugins();

            Log.Info($"{LoadedPlugins.Count} local plugins ready for parsing field data files.");

            foreach (var loadedPlugin in LoadedPlugins)
            {
                Log.Info($"{PluginLoader.GetPluginNameAndVersion(loadedPlugin.Plugin)}");
            }
        }