示例#1
0
        protected override void ProcessRecord()
        {
            // get config file, input directory/files, and output directory
            string searchPattern = Path.GetFileName(this.Input);

            this.Input = Path.GetDirectoryName(this.Input);
            if (String.IsNullOrEmpty(this.Input))
            {
                this.Input = this.SessionState.Path.CurrentFileSystemLocation.Path;
            }

            if (String.IsNullOrEmpty(this.Output))
            {
                this.Output = this.Input;
            }

            // canononicalize any paths relative to the current PowerShell file system location as Environment.CurrentDirectory is usually elsewhere
            this.Config = this.RootPath(this.Config);
            this.Input  = this.RootPath(this.Input);
            this.Output = this.RootPath(this.Output);

            using (this.dspEngine = new CrossTimeEngine(this.Config, this.dspEngineLog))
            {
                // process specified files
                DateTime startTimeUtc = DateTime.UtcNow;
                Task     filterFiles  = Task.Run(() => { dspEngine.FilterFiles(this.Input, searchPattern, this.Output); });

                // rely on polling for log messages as Progress<T>.Report() crashes PowerShell
                while (filterFiles.IsCompleted == false)
                {
                    Thread.Sleep(Constant.PowerShellMessagePollInterval);
                    this.WriteMessages();
                }

                // flush any remaining log messages
                this.WriteMessages();
                TimeSpan elapsedTime = DateTime.UtcNow - startTimeUtc;
                this.WriteVerbose(String.Format("Completed in {0}.", elapsedTime.ToString(Constant.ElapsedTimeFormat)));
            }
        }
示例#2
0
 public SyncFiles()
 {
     this.dspEngine    = null;
     this.dspEngineLog = new CrossTimeEngineLog();
 }