Exemplo n.º 1
0
 public static FileInfo createIncompleteTestEntity()
 => new FileInfo(
     new Uri(@"\test\test.file", UriKind.Relative),
     DateTime.Now.AddMinutes(-5),
     null,
     DateTime.Now,
     DirectorySetupId.New(),
     100,
     false);
Exemplo n.º 2
0
 public static FileInfo createTestEntity()
 => new FileInfo(
     new Uri(@"\test\test.file", UriKind.Relative),
     DateTime.Now.AddMinutes(-5),
     new FileHash(new byte[] { 00, 01, 02, 03, 04, 05 }),
     DateTime.Now,
     DirectorySetupId.New(),
     100,
     false);
Exemplo n.º 3
0
 public IObservableCache <FileInfo, FileInfoId> Get(DirectorySetupId directorySetupId)
 {
     return(this.cache.Connect()
            .Filter(fi => fi.DirectorySetupId == directorySetupId)
            .AsObservableCache());
 }
Exemplo n.º 4
0
 public FileInfo(
     Uri path, DateTime creationTime, FileHash?fileHash, DateTime lastWriteTime, DirectorySetupId directorySetupId, long fileSize,
     bool isAccessible, FileInfoId id, DateTime created, DateTime?lastChange = null)
 {
     this.Path             = path;
     this.FileCreationTime = creationTime;
     this.FileHash         = fileHash;
     this.LastWriteTime    = lastWriteTime;
     this.DirectorySetupId = directorySetupId;
     this.FileSize         = fileSize;
     this.IsAccessible     = isAccessible;
     this.Id         = id;
     this.Created    = created;
     this.LastChange = lastChange ?? DateTime.Now;
     this.Identity   = Guid.NewGuid();
     this.HashKey    = null;
     if (FileInfoHashKey.CanBuild(this))
     {
         this.HashKey = new FileInfoHashKey(this);
     }
 }
Exemplo n.º 5
0
 public FileInfo(
     Uri path, DateTime creationTime, FileHash?fileHash, DateTime lastWriteTime, DirectorySetupId directorySetupId, long fileSize,
     bool isAccessible)
     : this(path, creationTime, fileHash, lastWriteTime, directorySetupId, fileSize, isAccessible, (FileInfoId)Guid.NewGuid(), DateTime.Now)
 {
 }
Exemplo n.º 6
0
 public FileInfo(
     FileInfo origin, Uri path, DateTime creationTime, FileHash?fileHash, DateTime lastWriteTime, DirectorySetupId directorySetupId, long fileSize,
     bool isAccessible)
     : this(path, creationTime, fileHash, lastWriteTime, directorySetupId, fileSize, isAccessible, origin.Id, origin.Created)
 {
 }
Exemplo n.º 7
0
 private DirectorySetup createTestEntity()
 => new DirectorySetup(new Uri(@"C:\test\test.test"), (DirectorySetupName)"testDir", (Description)"testDesc", DirectorySetupId.New(), DateTime.Now.AddMinutes(-5), DateTime.Now);
Exemplo n.º 8
0
        public void RemoveDirectorySetupRecursively(DirectorySetupId dirSetupId)
        {
            Observable.Start(() =>
            {
                var job = notificationCenter.CreateSingleTaskJob(out var process, "removing directory setup");
                try
                {
                    process.AddProgress(7, "removing setup");
                    this.directoryDataService.Delete(dirSetupId);

                    process.OnNextStep("looking for files");
                    var files =
                        fileDataService
                        .Get()
                        .Items
                        .Where(file => file.DirectorySetupId == dirSetupId)
                        .ToList();

                    process.OnNextStep("removing files");
                    fileDataService
                    .Delete(
                        files
                        .Select(file => file.Id)
                        );

                    process.OnNextStep("looking for links");
                    var hashes = files.Select(x => x.HashKey);
                    files      = null;

                    var removedLinks =
                        fileItemLinkService
                        .Get()
                        .Items
                        .WhereIn(hashes, link => link.FileKey)
                        .ToArray();

                    process.OnNextStep("removing links");
                    fileItemLinkService
                    .Delete(
                        removedLinks
                        .Select(link => link.Id)
                        );

                    process.OnNextStep("looking for items");
                    var remainingFileKeys =
                        fileItemLinkService
                        .Get()
                        .Items
                        .Select(x => x.FileKey);

                    var completelyRemovedItemIDs =
                        removedLinks
                        .WhereNotIn(remainingFileKeys, link => link.FileKey)
                        .Select(link => link.ItemId)
                        .ToArray();

                    removedLinks = null;

                    process.OnNextStep("removing items");
                    this.itemService.Delete(completelyRemovedItemIDs);
                    process.OnNextStep("done");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), $"{nameof(LibraryManagementService)}.{nameof(RemoveDirectorySetupRecursively)}");
                }
            }, RxApp.TaskpoolScheduler);
        }