public override void Call() { if (IsCanceled) { _synchronizer.Redo(); return; } var path = Menu.GetUserInput("path:"); //@"C:\Users\Alexandr\Desktop\TEST"; var tager = new Tager(new FileLoader()); var analyzer = new Analyzer(tager, s => Path.GetExtension(s).ToLower() == ".mp3"); Menu.PrintHelp(); var mask = new Mask(Menu.GetUserInput("mask:")); analyzer.Analyze(Directory.GetFiles(path), mask); _synchronizer = new Synchronizer(tager,Menu.SelectSyncRule()); _synchronizer.Sync(analyzer.NotSynchronizedFiles.Keys, mask); Menu.PrintChanges(_synchronizer.ModifiedFiles); if (Menu.GetYesNoAnswer("Save changes?\nY/N:")) { _synchronizer.Save(); Menu.PrintMessage("Successfully"); Menu.PrintCollection(string.Format("with {0} errors", _synchronizer.ErrorFiles.Count), _synchronizer.ErrorFiles, ConsoleColor.Red); Menu.GetUserInput("Press enter..."); } }
public override void Call() { Menu.PrintHelp(); var path = Menu.GetUserInput("path:"); //@"C:\Users\Alexandr\Desktop\TEST"; var analyzer = new Analyzer(new Tager(new FileLoader())); var mask = new Mask(Menu.GetUserInput("mask:")); var plan=analyzer.BuildPlan(Directory.GetFiles(path), mask); if (!analyzer.NotSynchronizedFiles.Any()&&!analyzer.ErrorFiles.Keys.Any()) { Menu.PrintMessage("All files is OK"); Menu.GetUserInput("Press enter..."); return; } if (analyzer.ErrorFiles.Keys.Any()) Menu.PrintCollection( string.Format("{0} files can't be synchronized", analyzer.ErrorFiles.Count()), analyzer.ErrorFiles,ConsoleColor.Red); Menu.PrintCollection("Not synchronized files:", (from file in analyzer.NotSynchronizedFiles select file.Key.Name + ".mp3 with "+file.Value), ConsoleColor.Red); Menu.PrintCollection("Synchronized files:", (from file in analyzer.SynchronizedFiles select file.Name+".mp3"), ConsoleColor.Green); Menu.PrintPlan(plan); if (Menu.GetYesNoAnswer("Save this plan?\nY/N:")) { PlanProvider provider=new PlanProvider(); provider.Save(plan,Menu.GetUserInput("path:")); } }
public void Init() { _analyzerWithoutFiltr = new Analyzer(new Tager(new TestFileLoader())); _analyzerWithFiltr = new Analyzer(new Tager(new TestFileLoader()), str => !str.Contains(".UnknownExtension")); _expectedSynchronizedFile = "testArtist testAlbum"; _expectedNotSynchronizedFile = "testArtist testGenre"; _expectedErrorFile = "test1.UnknownExtension"; _expectedSynchronizedFilesCount = 1; _expectedNotSynchronizedFilesCount = 1; _testPaths = new string[] { _expectedErrorFile, _expectedSynchronizedFile, _expectedNotSynchronizedFile }; }
public override void Call() { if (IsCanceled) { synchronizer.Redo(); return; } var path = Menu.GetUserInput("path:"); //@"C:\Users\Alexandr\Desktop\TEST\New folder"; var tager = new Tager(new FileLoader()); var analyzer = new Analyzer(tager, s => Path.GetExtension(s).ToLower() == ".mp3"); Menu.PrintHelp(); var mask = new Mask(Menu.GetUserInput("mask:")); analyzer.Analyze(Directory.GetFiles(path), mask); synchronizer = new Synchronizer(tager); foreach (var notSynchronizedFile in analyzer.NotSynchronizedFiles) { Console.Clear(); Menu.PrintMessage(notSynchronizedFile.Key.Name+" with "+notSynchronizedFile.Value); synchronizer.Sync(notSynchronizedFile.Key,mask,Menu.SelectSyncRule()); Menu.PrintChanges(notSynchronizedFile.Key); if (Menu.GetYesNoAnswer("Save changes?\nY/N:")) { try { synchronizer.SaveLast(); Menu.PrintMessage("Successfully"); Menu.GetUserInput("Press enter..."); } catch { Menu.PrintError("Can't save file"); } } else { synchronizer.RestoreLast(); } } }