Beispiel #1
0
        private void WatchedFolderChanged(object sender, FileSystemEventArgs e)
        {
            logger.Debug("File system action for {0}: {1}.", e.FullPath, e.ChangeType);
            if (!e.Name.ToLower().StartsWith("archive"))
            {
                // we need a change information if a new item is created. however david normally causes to file system notifications. one for the create. and a change when it's done.
                // so only notify if the action is finished.
                switch (e.ChangeType)
                {
                case WatcherChangeTypes.Created:
                    this.filesAwaitingChangedNotification.Add(e.FullPath);
                    break;

                case WatcherChangeTypes.Changed:
                    if (this.filesAwaitingChangedNotification.Contains(e.FullPath))
                    {
                        this.filesAwaitingChangedNotification.Remove(e.FullPath);
                        logger.Debug("Raise Archive changed for {0}.", e.FullPath);

                        foreach (var actionTemplate in this.WatchedArchivingActionTemplates)
                        {
                            this.RaiseInputArchiveChanged(
                                ArchivingAction.FromTemplate(
                                    actionTemplate,
                                    this.filterService,
                                    e.FullPath));
                        }
                    }

                    break;
                }
            }
        }
Beispiel #2
0
        public Worker(ArchiveMonkeySettings settings, Queue <ArchivingAction> queue, IArchiver archiver, UnityContainer iocContainer)
        {
            this.settings        = settings;
            this.queue           = queue;
            this.iocContainer    = iocContainer;
            this.archiveWatchers = new List <IArchiveWatcher>();
            this.archiver        = archiver;
            this.filterService   = iocContainer.Resolve <IFilterService>();
            this.Processing      = false;

            foreach (var action in this.settings.ArchivingActionTemplates.OrderBy(x => x.InputArchive.FullNetworkPath).ThenBy(y => y.Sequence))
            {
                // create one queue entry for every archiving action to ensure changes are processed that might have been missed since last program run
                this.queue.Enqueue(ArchivingAction.FromTemplate(action, this.filterService));
            }
        }