Esempio n. 1
0
        public static List <VRASCopyBlob> GetFiles(VRASCopyConfiguration config)
        {
            try
            {
                List <VRASCopyBlob> blobList = new List <VRASCopyBlob>();

                DirectoryInfo          dir = new DirectoryInfo(config.BaseFolderPath);
                IEnumerable <FileInfo> files;
                IEnumerable <FileInfo> qry;

                // set the query of folder enum based on the CopyType
                if (config.CopyType == SourceTypeCopyType.CombineToRoot || config.CopyType == SourceTypeCopyType.Mirror)
                {
                    files = dir.EnumerateFiles("*", SearchOption.AllDirectories);
                }
                else
                {
                    files = dir.EnumerateFiles("*", SearchOption.TopDirectoryOnly);
                }

                // choose query on file list returned based on the flag for copy 0 byte
                if (config.CopyZeroByteFiles)
                {
                    qry =
                        from file in files
                        where file.LastWriteTimeUtc < DateTime.UtcNow.AddSeconds(-1 * config.NewFileDelaySeconds) && file.Length >= 0
                        orderby file.LastWriteTimeUtc ascending
                        select file;
                }
                else
                {
                    qry =
                        from file in files
                        where file.LastWriteTimeUtc < DateTime.UtcNow.AddSeconds(-1 * config.NewFileDelaySeconds) && file.Length > 0
                        orderby file.LastWriteTimeUtc ascending
                        select file;
                }

                foreach (FileInfo f in qry)
                {
                    if (StringMatchesFileAndFolderRegEx(f, config.FileRegExFilter, config.FolderRegExFilter))
                    {
                        VRASCopyBlob blob = new VRASCopyBlob(config, f);

                        blobList.Add(blob);
                    }
                    else
                    {
                    }
                }

                return(blobList);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("Error Enumerating Directory: {0}", ex.Message));
            }
        }
Esempio n. 2
0
        public VRASThreadManager(VRASCopyConfiguration config, int timesToRun)
        {
            if (config.CopyThreadPerSource <= 0)
            {
                throw new ArgumentOutOfRangeException("copyThreadPerSource");
            }

            this.copyConfig              = config;
            this.timeToQuit              = false;
            this.threads                 = new List <Thread>(this.copyConfig.CopyThreadPerSource);
            this.queue                   = new Queue <WaitQueueItem>();
            this.workWaiting             = new Semaphore(0, int.MaxValue);
            this.timesToRunTheWorkFinder = timesToRun;
            this.workingCopyThreads      = 0;
        }
Esempio n. 3
0
 public VRASCopyBlob(VRASCopyConfiguration c, FileInfo f)
 {
     this.copyConfig = c;
     this.file       = f;
 }