示例#1
0
        public static async Task <int> BuildFromSourceAsync(string source, string destination, StorageType storagetype)
        {
            var allFiles = Directory.GetFiles(source, "*.*", SearchOption.AllDirectories);
            List <Task <m_Bool> > tasks = new List <Task <m_Bool> >();

            foreach (string file in allFiles)
            {
                var episodeInfo = FileCategorizer.GetFileInfo(file);
                if (!episodeInfo)
                {
                    continue;
                }
                tasks.Add(Task.Run(() => FileRelocation.RelocateFile(episodeInfo, destination, storagetype)));
            }

            var results = await Task.WhenAll(tasks);

            int c = 0;

            foreach (var result in results)
            {
                if (result)
                {
                    c++;
                }
            }


            return(c);
        }
示例#2
0
        public static int BuildFromSource(string source, string destination)
        {
            var n = 0;

            var allFiles = Directory.GetFiles(source, "*.*", SearchOption.AllDirectories);

            foreach (var f in allFiles)
            {
                var episodeInfo = FileCategorizer.GetFileInfo(f);
                Console.WriteLine(f);
                if (!episodeInfo)
                {
                    continue;
                }

                var mBool = FileRelocation.RelocateFile(episodeInfo, destination, StorageType.FileSystem);

                if (mBool)
                {
                    n++;
                }
            }

            return(n);
        }
 public void TestAll()
 {
     foreach (var pair in _sourceExpectedList)
     {
         var source   = pair.First;
         var expected = pair.Second;
         var actual   = FileCategorizer.GetFileInfo(source);
         CompareMembers(expected, actual);
     }
 }
        public void StandardShownameTestWithX()
        {
            var expectedShowDetails  = new EpisodeInfo("Arrow", 1, 2);
            var incorrectShowDetails = new EpisodeInfo("Arrow", 2, 1);
            var returnedShowDetails  = FileCategorizer.GetFileInfo(DefaultShownameWithX);

            CompareMembers(expectedShowDetails, returnedShowDetails);
            Assert.AreEqual(expectedShowDetails, returnedShowDetails);
            Assert.AreNotEqual(incorrectShowDetails, returnedShowDetails);
        }
示例#5
0
        public static List <string> BuildFromSourceWithOutput(string source, string destination)
        {
            var list     = new List <string>();
            var allFiles = Directory.GetFiles(source, "*.*", SearchOption.AllDirectories);

            foreach (var f in allFiles)
            {
                var episodeInfo = FileCategorizer.GetFileInfo(f);

                if (!episodeInfo)
                {
                    continue;
                }

                var mBool = FileRelocation.RelocateFile(episodeInfo, destination, StorageType.FileSystem);

                if (mBool)
                {
                    list.Add(mBool.Message());
                }
            }
            return(list);
        }