Beispiel #1
0
        private string GetFilename()
        {
            var path = Parent.WorkingDirectory;
            var file = FileMask.Replace("%count%", Counter.ToString());

            Directory.CreateDirectory(path);
            return(Path.Combine(path, file));
        }
Beispiel #2
0
 public FtpDownloader(
     HostTracking tracking,
     IDestination destination,
     IPredicate predicate)
 {
     Guard.NotNull(() => tracking, tracking);
     Guard.NotNull(() => destination, destination);
     Guard.NotNull(() => predicate, predicate);
     maskRegex = FileMask.GenerateFitMask(tracking.Config.FileMask);
     log.Debug("Generated mask: {0}", maskRegex);
     this.tracking    = tracking;
     this.destination = destination;
     this.predicate   = predicate;
 }
Beispiel #3
0
 protected override void Validate()
 {
     if (ReceiveFolder.IsNullOrEmpty())
     {
         throw new BindingException("Inbound file adapter has no source folder.");
     }
     if (FileMask.IsNullOrEmpty())
     {
         throw new BindingException("Inbound file adapter has no source file mask.");
     }
     if (!Path.IsNetworkPath(ReceiveFolder) && !NetworkCredentials.UserName.IsNullOrEmpty())
     {
         throw new BindingException("Alternate credentials to access the file folder cannot be supplied while accessing local drive or a mapped network drive.");
     }
 }
 private void RemoveReaderWithFileNameCheck(string path)
 {
     if (!FileMask.IsMatch(Path.GetFileName(path)))
     {
         return;
     }
     lock (_readers)
     {
         if (_readers.ContainsKey(path))
         {
             _readers[path].Dispose();
             _readers.Remove(path);
         }
     }
 }
Beispiel #5
0
            public SkipItem(XElement element)
            {
                Condition     = (string)element.Attribute("condition");
                FileMask      = (string)element.Value;
                FileMaskRegex = new Regex(FileMask.Replace(".", "[.]").Replace("*", ".*").Replace("?", ".").Replace("\\", @"\\"));
                var      name = element.Name.LocalName;
                SkipMode mode;

                Enum.TryParse <SkipMode>(name, out mode);
                Mode = mode;
                if (mode == SkipMode.Iteration)
                {
                    int count;
                    int.TryParse((string)element.Attribute("count"), out count);
                    Count = count;
                }
            }
 private void AddReaderWithFileNameCheck(string path)
 {
     if (!FileMask.IsMatch(Path.GetFileName(path)))
     {
         return;
     }
     lock (_readers)
     {
         if (!_readers.ContainsKey(path))
         {
             ILogReader reader = _logReaderFactory.CreateReader(path, new FileInfo(path).Length, Encoding);
             reader.LineReaded += EvaluateEvents;
             reader.BeginRead();
             _readers.Add(path, reader);
         }
     }
 }
Beispiel #7
0
 public bool Equals(LogDescriptionConfig other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.FileMask.ToString(), FileMask.ToString()) &&
            Equals(other.Encoding, Encoding) &&
            Equals(other.Id, Id) &&
            Equals(other.ConfigFileName, ConfigFileName) &&
            other.LogDirectories.Count == LogDirectories.Count &&
            other.LogDirectories.All(dir => LogDirectories.Contains(dir)));
 }
Beispiel #8
0
        private string GetFilename()
        {
            var path = Parent.WorkingDirectory;
            var file = FileMask.Replace("%count%", _counter.ToString());

            Directory.CreateDirectory(path);
            var fullPath = Path.Combine(path, file);

            int sameCount = 1;

            while (File.Exists(fullPath))
            {
                var newFilename = Path.GetFileNameWithoutExtension(file) + $" ({sameCount++})" + Path.GetExtension(file);
                fullPath = Path.Combine(path, newFilename);
            }

            return(fullPath);
        }
Beispiel #9
0
        private string GetFilename(InputPort port, string ext)
        {
            var name = string.IsNullOrEmpty(port.Connection?.Parent.Description) ? "signal" : port.Connection.Parent.Description;
            var path = WorkingDirectory;
            var file = FileMask.Replace("%count%", _counter.ToString())
                       .Replace("%name%", name)
                       .Replace("%ext%", ext);

            Directory.CreateDirectory(path);
            var fullPath = Path.Combine(path, file);

            int sameCount = 1;

            while (File.Exists(fullPath))
            {
                var newFilename = Path.GetFileNameWithoutExtension(file) + $" ({sameCount++})" + Path.GetExtension(file);
                fullPath = Path.Combine(path, newFilename);
            }

            return(fullPath);
        }
Beispiel #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (FileMask.Length != 0)
            {
                hash ^= FileMask.GetHashCode();
            }
            if (StartDir.Length != 0)
            {
                hash ^= StartDir.GetHashCode();
            }
            if (Recursive != false)
            {
                hash ^= Recursive.GetHashCode();
            }
            if (IgnoreErrors != false)
            {
                hash ^= IgnoreErrors.GetHashCode();
            }
            return(hash);
        }
Beispiel #11
0
 private string GetInfoForMask(string mask)
 {
     if (mask.Length == 0) return "";
     FileMask fileMask = new FileMask(mask);
     if (fileMask.type == FileMask.Type.Mask)
     {
         string ext = mask.Substring(2);
         return ShellIcon.GetTypeInfo("x." + ext);
     }
     return fileMask.GetTypeInfo();
 }
        public FindInFilesViewModel()
        {
            Title = "Find Results";

            FindCommand = ReactiveCommand.Create(async() =>
            {
                Results     = null;
                SearchStats = null;

                var service = IoC.Get <IFindInFilesService>();

                var results = service.Find(_searchTerm, CaseSensitive, WholeWords, Regex, FileMask?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));

                Results = await Task.Run(() => new ObservableCollection <FindResultViewModel>(results.Select(r => new FindResultViewModel(r))));

                SearchStats = $"{Results.Count} matches in {Results.GroupBy(r => r.FilePath).Count()} files";
            });
        }
Beispiel #13
0
            public bool PassesLocalIncludes(string path, MatchReason reason)
            {
                IncludeFiltersRow[] includes = GetIncludeFiltersRows();

                // it must match at least one global include
                foreach (IncludeFiltersRow include in includes)
                {
                    FileMask wildcard = new FileMask(include.Mask);
                    if (wildcard.IsMatch(path))
                    {
                        reason.Set(include.Mask, MatchReason.Status.Included);
                        return true;
                    }
                }

                // didn't match any include
                return false;
            }
Beispiel #14
0
            public bool PassesLocalExcludes(string path, MatchReason reason)
            {
                ExcludeFiltersRow[] excludes = GetExcludeFiltersRows();

                // it must not match any global exclude
                foreach (ExcludeFiltersRow exclude in excludes)
                {
                    FileMask wildcard = new FileMask(exclude.Mask);
                    if (wildcard.IsMatch(path))
                    {
                        reason.Set(exclude.Mask, MatchReason.Status.Excluded);
                        return false;
                    }
                }

                // passed excludes
                return true;
            }
Beispiel #15
0
        public bool PassesGlobalIncludes(string path, MatchReason reason)
        {
            // it must match at least one global include
            foreach (GlobalIncludeFiltersRow row in GlobalIncludeFilters)
            {
                FileMask wildcard = new FileMask(row.Mask);
                if (wildcard.IsMatch(path))
                {
                    reason.Set(row.Mask, MatchReason.Status.Included);
                    return true;
                }
            }

            // didn't match any include
            return false;
        }
Beispiel #16
0
 public bool PassesGlobalExcludes(string path)
 {
     // it must not match any global exclude
     foreach (GlobalExcludeFiltersRow row in GlobalExcludeFilters)
     {
         FileMask wildcard = new FileMask(row.Mask);
         if (wildcard.IsMatch(path))
         {
             return false;
         }
     }
     return true;
 }