public FolderFileDetection(ILibraryConfiguration config)
        {
            this.Config = config;

            this.AddedFiles    = new ConcurrentDictionary <string, Record>();
            this.DetectedFiles = new ConcurrentBag <string>();
            this.UpdatedFiles  = new ConcurrentDictionary <string, Record>();
            this.SkippedFiles  = new ConcurrentBag <string>();
        }
Ejemplo n.º 2
0
        public LibraryCreator(Library library, ILibraryConfiguration config)
        {
            this.Config  = config;
            this.library = library;

            this.LoadedSubject         = new Subject <LibraryLoadResult>().AddTo(this.Disposables);
            this.LoadingSubject        = new BehaviorSubject <string>(null).AddTo(this.Disposables);
            this.FileEnumeratedSubject = new BehaviorSubject <int>(0).AddTo(this.Disposables);
            this.FileLoadedSubject     = new BehaviorSubject <int>(0).AddTo(this.Disposables);
        }
 public DomainServiceImplementation(ILibraryConfiguration xXXLibraryConfiguration, IDomainRepository domainRepository)
 {
     _domainRepository = domainRepository;
 }
Ejemplo n.º 4
0
 public static void SetConfig(ILibraryConfiguration config)
 {
     defaultConfig = config;
 }
Ejemplo n.º 5
0
        public Library(ILibraryConfiguration config)
        {
            this.config = config;

            this.librarySettingXml = new XmlSettingManager <LibrarySettings>
                                         (System.IO.Path.Combine(config.SaveDirectory, librarySettingFileName));



            this.MessageSubject         = new Subject <string>().AddTo(this.Disposables);
            this.IsCreatingSubject      = new BehaviorSubject <bool>(false).AddTo(this.Disposables);
            this.DatabaseUpdatedSubject = new Subject <DatabaseUpdatedEventArgs>().AddTo(this.Disposables);

            this.Searcher = new SearchSortManager();


            //Initialize Database

            this.Database = new DatabaseFront(System.IO.Path.Combine(config.SaveDirectory, databaseFileName))
            {
                Version = databaseVersion,
            };

            this.Records = new TypedTable <Record, string>(this.Database, nameof(Records))
            {
                IsIdAuto = false,
                Version  = databaseVersion,
            };

            this.RecordTracker = new Tracker <Record, string>(this.Records).AddTo(this.Disposables);

            this.DefineMigration();



            this.Tags        = new TagDictionary().AddTo(this.Disposables);
            this.TagDatabase = new AutoTrackingTable <TagInformation, int>
                                   (this.Database, nameof(TagDatabase), trackIntervalTime, this.Tags.Added, databaseVersion)
                               .AddTo(this.Disposables);

            this.Folders        = new FolderDictionary().AddTo(this.Disposables);
            this.FolderDatabase = new AutoTrackingTable <FolderInformation, int>
                                      (this.Database, nameof(FolderDatabase), trackIntervalTime, this.Folders.Added, databaseVersion)
                                  .AddTo(this.Disposables);

            this.ExifManager            = new ExifManager().AddTo(this.Disposables);
            this.ExifVisibilityDatabase = new AutoTrackingTable <ExifVisibilityItem, int>
                                              (this.Database, nameof(ExifVisibilityDatabase), trackIntervalTime, this.ExifManager.Added, databaseVersion)
                                          .AddTo(this.Disposables);


            this.Folders.FileTypeFilter = this.config.FileTypeFilter;
            this.Folders.FolderUpdated.Subscribe(x => this.CheckFolderUpdateAsync(x).FireAndForget())
            .AddTo(this.Disposables);

            this.RecordTracker.Updated.Subscribe(this.DatabaseUpdatedSubject).AddTo(this.Disposables);


            this.RecordQuery = new RecordQuery(this.Records, this);
            this.GroupQuery  = new GroupQuery(this.Records, this);
            this.Grouping    = new Grouping(this.Records, this);

            this.QueryHelper = new LibraryQueryHelper(this.Records, this);
            this.QueryHelper.Updated.Subscribe(this.DatabaseUpdatedSubject).AddTo(this.Disposables);

            this.Creator = new LibraryCreator(this, this.config)
            {
                TagDictionary  = this.Tags,
                Records        = this.Records,
                CompletingTask = this.MakeDirectoryTree,
            }
            .AddTo(this.Disposables);

            this.Creator.Loaded.Select(_ => new DatabaseUpdatedEventArgs()
            {
                Action = DatabaseAction.Refresh,
                Sender = this.Creator,
            })
            .Subscribe(this.DatabaseUpdatedSubject)
            .AddTo(this.Disposables);



            this.IsLibrarySettingsLoaded = false;
        }
Ejemplo n.º 6
0
        private async Task <Library> CreateLibraryAsync()
        {
            LibraryOwner.Reset();
            //this.settings?.Folders?.Clear();
            this.FileEnumerator?.Clear();

            var path   = System.IO.Directory.GetCurrentDirectory();
            var config = new LibraryConfigurationDummy(path);

            this.FileEnumerator = new Dictionary <string, FolderContainerDummy>();// = new FolderAccesserDummy();
            //config.FolderAccesser = this.FileEnumerator;

            config.GetChildFoldersFunction = s =>
            {
                var key = s.TrimEnd(System.IO.Path.DirectorySeparatorChar);

                if (!this.FileEnumerator.ContainsKey(key))
                {
                    Debug.WriteLine(key);
                    this.FileEnumerator.ForEach(x => Debug.WriteLine(x.Key + "," + x.Value.Path));
                    return(null);
                }
                return(this.FileEnumerator[key]
                       .Folders?.Select(x => x.Value.Path) ?? new string[0]);
            };

            config.GetFolderFunction = s =>
            {
                var key = s.TrimEnd(System.IO.Path.DirectorySeparatorChar);
                FolderContainerDummy f;
                this.FileEnumerator.TryGetValue(key, out f);
                return(f);
            };

            this.config = config;
            LibraryOwner.SetConfig(config);

            //config.Folders.Add(folder);
            //config.FileExistingChecker = _ => false;

            var library = LibraryOwner.GetCurrent();

            this.settings = new LibrarySettings()
            {
                Version = 10,
            };


            library.InitializeLibrarySettings(settings);

            await library.LoadAsync();


            await library.ClearAsync();

            data.ForEach((x, c) =>
            {
                var f = LoadTestData(x);
                this.AddFolder(f);
                library.Folders.Add(new FolderInformation(f.Path));
            });

            await library.RefreshLibraryAsync(true);

            var search = new SearchInformation(new ComplexSearch(false));

            library.Searcher.AddSearchToDictionary(search);

            return(library);
        }
 public MyLibraryCore(ILibraryConfiguration config)
 {
     _config = config;
 }