示例#1
0
        public void sort()
        {
            DeviceUserEntry entry = UserInputService.get_user_entry(_Console);

            if (entry.Equals(default(DeviceUserEntry)))
            {
                return;
            }

            //TODO check for parser for all modules
            var files = Directory.EnumerateFiles(_parser.DirPath, "*.*") // Remove/Add SearchOption if dont need to resort
                        .Where(s => s.EndsWith(".png") || s.EndsWith(".jpg") || s.EndsWith(".tif"));

            if (files.Count() == 0)
            {
                return;
            }
            var sortPath = Directory.CreateDirectory(Path.Combine(_parser.DirPath, entry.SortWord));

            int index = 0;

            foreach (var file in files)
            {
                FileInfo curFile = DevicePathService.get_file(file);
                if (!(entry.SortTime.Year == curFile.CreationTime.Year &&
                      entry.SortTime.Day == curFile.CreationTime.Day &&
                      entry.SortTime.Month == curFile.CreationTime.Month))
                {
                    continue;
                }
                try
                {
                    System.IO.File.Move(curFile.FullName, Path.Combine(sortPath.FullName, curFile.Name));
                    index++;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            if (index == 0)
            {
                Directory.Delete(sortPath.FullName);
                _Console.WriteLine("No entries with this creation date found.");
                _Console.ReadLine();
            }
            else
            {
                DeviceNoteService.add_entry(_parser.DirPath, entry);
                var tree = new Node(_parser.DirPath);

                _Console.Clear();
                _Console.WriteLine("Your new Structure! Press Any Key to proceed.");
                _Console.WriteLine("");
                NodePrinter.print_tree(tree, "", true);
                _Console.ReadLine();
            }
        }
        public void get_file_path_test()
        {
            const string path = "./";

            Assert.AreEqual(DevicePathService.get_file(path).FullName + ".photon.json", DeviceNoteService.get_file_path(path, false));
        }
示例#3
0
        public void get_file_test()
        {
            const string path = "./sa";

            Assert.AreEqual(new FileInfo(path).Name, DevicePathService.get_file(path).Name);
        }
示例#4
0
 public void get_file_exception_test()
 {
     Assert.ThrowsException <InvalidDataException>(() => DevicePathService.get_file(null));
 }
示例#5
0
 public void path_valid_true_test()
 {
     Assert.AreEqual(true, DevicePathService.path_valid("./"));
 }
示例#6
0
 public void path_valid_null_test()
 {
     Assert.AreEqual(false, DevicePathService.path_valid(null));
 }