public static void RefreshFilteredFilesList(Log4jConnectionProperties properties)
        {
            var folders = properties.Folder.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries);

            var getFilesQuery = folders.AsParallel()
                .Where(Directory.Exists)
                .SelectMany(Directory.GetFiles);

            if (!string.IsNullOrEmpty(properties.FileNameFilter))
            {
                var filter = new Regex(properties.FileNameFilter);
                getFilesQuery = getFilesQuery
                    .Where(f => filter.Match(f).Success);
            }

            var dateFilterMode = properties.DateFilterMode;
            if (dateFilterMode != DateFilterMode.None)
            {
                DateTime filterDate;
                if (dateFilterMode == DateFilterMode.SpecificDate)
                    filterDate = properties.SpecificDate.Value;
                else
                {
                    var daysToSubstract = dateFilterMode == DateFilterMode.LastDay
                        ? 1
                        : dateFilterMode == DateFilterMode.PreviousTwoDays ? 2 : 7;
                    filterDate = DateTime.Today.AddDays(-daysToSubstract);
                }

                getFilesQuery = getFilesQuery.Where(f => File.GetLastWriteTimeUtc(f) > filterDate.ToUniversalTime());

            }
            _activeFiles = getFilesQuery.ToList();
        }
 public ConnectionEditorViewModel(Log4jConnectionProperties properties)
 {
     _properties = properties;
     Apply = new RelayCommand(ApplyExecute);
     Cancel = new RelayCommand(() => ConnectionEditor.CloseEditor(false));
     SelectFolder = new RelayCommand(ExecuteSelectFolder);
 }
 public ConnectionStringEditor(IConnectionInfo cxInfo)
 {
     var properties = new Log4jConnectionProperties(cxInfo);
     var viewModel = new ConnectionEditorViewModel(properties);
     viewModel.ConnectionEditor = this;
     DataContext = viewModel;
     InitializeComponent();
 }
 public override object[] GetContextConstructorArguments(IConnectionInfo cxInfo)
 {
     var properties = new Log4jConnectionProperties(cxInfo);
     return new object[] {properties};
 }
 public override bool AreRepositoriesEquivalent(IConnectionInfo c1, IConnectionInfo c2)
 {
     var f1 = new Log4jConnectionProperties(c1).Folder;
     var f2 = new Log4jConnectionProperties(c2).Folder;
     return f1.Equals(f2, StringComparison.OrdinalIgnoreCase);
 }
 public static IEnumerable<string> GetActiveFiles(Log4jConnectionProperties properties)
 {
     if (_activeFiles == null || !_activeFiles.Any())
         RefreshFilteredFilesList(properties);
     return _activeFiles;
 }
 public Log4jDataContext(Log4jConnectionProperties properties)
 {
     _properties = properties;
 }