示例#1
0
        /// <summary>
        /// Recursive sync of two folders
        /// </summary>
        static void Test100()
        {
            FolderRepository dbRepository     = new FolderRepository("DbFolder");
            FolderRepository uploadRepository = new FolderRepository("UploadFolder");

            // We will make changes to the upload repository and sync with the DbRepository
            // At the top level
            uploadRepository.Create("", "Top.new.file.txt");
            uploadRepository.Create("", "Top.new.folder", true);
            // At the folder1 level
            uploadRepository.Create("Folder1", "Folder1.new.file.txt");
            uploadRepository.Create("Folder1", "Folder1.new.folder", true);
            // At the folder2 level
            uploadRepository.Delete(@"Folder1\Folder2", true);
            // At the Folder1.new.folder level
            uploadRepository.Create("Top.new.folder", "File.inside.folder1.txt");
            //Now find the difference between the two repository
            var            root        = new DirectoryInfo(uploadRepository.FolderPath);
            var            directories = root.GetDirectories("*.*", System.IO.SearchOption.AllDirectories);
            List <Storage> difference  = Utils.Compare(dbRepository, uploadRepository, string.Empty);

            dbRepository.ApplyChanges(string.Empty, difference);
            foreach (var directoryInfo in directories)
            {
                string folder = directoryInfo.FullName.Substring(root.FullName.Length + 1);
                difference = Utils.Compare(dbRepository, uploadRepository, folder);
                dbRepository.ApplyChanges(folder, difference);
            }
        }
示例#2
0
        static void Test1()
        {
            FolderRepository dbRepository     = new FolderRepository("DbFolder");
            FolderRepository uploadRepository = new FolderRepository("UploadFolder");

            uploadRepository.Create(string.Empty, "XXX");
            List <Storage> output = Utils.Compare(dbRepository, uploadRepository, string.Empty);
        }
示例#3
0
        static void Test81()
        {
            FolderRepository uploadRepository = new FolderRepository("UploadFolder");
            DateTime         createdTime      = uploadRepository.CreateFolder("Folder1", "Dutta");
            DbRepository     dbRepository     = new DbRepository(
                "DbFolder");

            dbRepository.CreateFolder("Folder1", "Dutta", createdTime);
            List <Storage> difference = Utils.Compare(dbRepository, uploadRepository, "Folder1");
        }
示例#4
0
        static void Test82()
        {
            FolderRepository uploadRepository = new FolderRepository("UploadFolder");
            Stream           fileStream       = File.OpenRead(@"UploadFolder\file1.txt");
            DateTime         createdTime      = uploadRepository.CreateFile("Folder1", fileStream, "Dutta.txt");
            DbRepository     dbRepository     = new DbRepository(
                "DbFolder");

            dbRepository.CreateFile("Folder1", "Dutta.txt", createdTime);
            List <Storage> difference = Utils.Compare(dbRepository, uploadRepository, "Folder1");
        }
示例#5
0
        static void Test6()
        {
            FolderRepository folderRepository = new FolderRepository("DbFolder");

            folderRepository.Delete("Folder1", true);
        }
示例#6
0
        static void Test61()
        {
            FolderRepository folderRepository = new FolderRepository("DbFolder");

            folderRepository.Delete(@"Folder1\file2.txt", false);
        }
示例#7
0
 static void Test92()
 {
     FolderRepository uploadRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");
     DateTime         updatedDate      = uploadRepository.MoveFolder(@"Folder1\Folder2", "");
 }
示例#8
0
        static void Test11()
        {
            FolderRepository uploadRepository = new FolderRepository("UploadFolder");

            uploadRepository.Create(string.Empty, "XXX");
        }