Exemple #1
0
        public void Start()
        {
            _consolePrinter.PrintWelcomeMessage();

            var filesNotRead = true;

            //Get input from user
            while (filesNotRead)
            {
                try
                {
                    var folderPath = _consolePrinter.GetEntryFromUser(
                        "Please enter the location of the merged and duplicated photos, or Q  and enter to quit \r\n\nEg c:\\merged photos\\ "
                        );

                    if (folderPath.ToLower() == "q")
                    {
                        Stop();
                    }

                    var folderExists = _fileManager.DoesFolderExist(folderPath);

                    while (!folderExists)
                    {
                        //Get valid input from user

                        folderPath = _consolePrinter.GetEntryFromUser("The folder entered was not found, please check and try again, or press Q and enter to quit"
                                                                      );

                        if (folderPath.ToLower() == "q")
                        {
                            Stop();
                        }

                        folderExists = _fileManager.DoesFolderExist(folderPath);
                    }

                    _consolePrinter.PrintMessage(
                        "Starting read of folder and sub folders, any import errors will be listed below, but not stop the process\r\n"
                        );

                    var files = _fileManager.GetImageFileListFromFolder(folderPath);

                    filesNotRead = false;

                    var fileCount = files.Count;

                    var userNotResponded = true;

                    while (userNotResponded)
                    {
                        var response = _consolePrinter.GetEntryFromUser(
                            "\r\n" +
                            $"{fileCount:##,###}" +
                            " files have been found, high file counts can take a long time to sort for duplicates and will impede your system performance ! \r\nDo you want to continue ? (Y\\N)"
                            );

                        if (response.ToLower() == "y" || response.ToLower() == "n")
                        {
                            userNotResponded = false;

                            if (response.ToLower() == "y")
                            {
                                var duplicates = FindImages(_imageManager, files);

                                DisplayDuplicates(duplicates);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _consolePrinter.PrintError("", e);
                }
            }

            _consolePrinter.PrintMessage("Good bye!");
        }