Exemplo n.º 1
0
        /// <summary>
        ///     Searches the book title by single author.
        /// </summary>
        public void SearchBookTitleBySingleAuthor()
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var dirAuthors = BookListPathsProperties.PathAuthorsDirectory;

            var cls1     = new CombinePathsClass();
            var filePath = cls1.CombineDirectoryPathWithFileName(dirAuthors,
                                                                 BookListPathsProperties.CurrentWorkingFileName);

            var coll = new BookDataCollection();

            coll.ClearCollection();

            var titles = new BookTitlesCollection();

            titles.ClearCollection();

            var cls2 = new InputClass();

            cls2.ReadTitlesFromFileLoop(filePath);

            this.FindTitlesInString();

            if (titles.GetItemsCount() < 1)
            {
                titles.AddItem("No titles with this search criteria were found.");
            }
        }
        /// <summary>
        ///     Gets the authors directory path.
        /// </summary>
        /// <returns>
        ///     True if directory exists or was created else False.
        /// </returns>
        public bool GetAuthorsDirectoryPath()
        {
            var dirFileOp = new FileClass();
            var validate  = new ValidationClass();

            var dirTop  = BookListPathsProperties.PathTopLevelDirectory;
            var dirName = BookListPathsProperties.NameAuthorsDirectory;

            var cls     = new CombinePathsClass();
            var dirPath = cls.CombineExistingDirectoryPathWithDirectoryName(
                dirTop, dirName);

            if (validate.ValidateDirectoryExists(dirPath))
            {
                BookListPathsProperties.PathAuthorsDirectory = dirPath;
                return(true);
            }

            var clsPaths = new FileClass();

            if (!GetPermissionToCreateDirectory(dirPath))
            {
                return(false);
            }

            BookListPathsProperties.PathAuthorsDirectory = dirPath;
            return(true);
        }
        /// <summary>
        ///     Creates the new author directory.
        /// </summary>
        /// <param name="dirPath">The dir path.</param>
        /// <returns>True if directory created else False.</returns>
        public bool CreateNewAuthorDirectory(string dirPath)
        {
            var dirFileOp = new FileClass();

            var cls = new CombinePathsClass();

            cls.CreateNewDirectoryReturnPath(dirPath);

            return(_validate.ValidateDirectoryExists(dirPath));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the book list titles file path.
        /// </summary>
        /// <returns>True if path found else False.</returns>
        public bool GetBookListTitlesFilePath()
        {
            var dirFileOp = new FileClass();
            var validate  = new ValidationClass();

            var dirPath = BookListPathsProperties.PathTitlesDirectory;

            var fileName = BookListPathsProperties.NameTitlesBookListFile;

            var cls      = new CombinePathsClass();
            var filePath = cls.CombineDirectoryPathWithFileName(
                dirPath, fileName);

            var fileExists = validate.ValidateFileExists(filePath, true);

            if (!fileExists)
            {
                var dlgResult = this._msgBox.ShowQuestionMessageBox();

                // Create directory if it does not exist.
                if (dlgResult == DialogResult.Yes)
                {
                    dirFileOp.CreateNewFile(filePath);

                    if (validate.ValidateFileExists(filePath, true))
                    {
                        BookListPathsProperties.PathTitleNamesListFile = filePath;
                        return(true);
                    }
                    else
                    {
                        // return no directory created.
                        BookListPathsProperties.PathTitleNamesListFile = String.Empty;
                        return(false);
                    }
                }
                else
                {
                    // return user does not want to create the directory.
                    BookListPathsProperties.PathTitleNamesListFile = String.Empty;
                    return(false);
                }
            }
            else
            {
                BookListPathsProperties.PathTitleNamesListFile = filePath;
                return(true);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Authors the names search loop.
        /// </summary>
        private void AuthorNamesSearchLoop()
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;



            var coll1      = new AuthorsFileNamesCollection();
            var totalCount = coll1.GetItemsCount();

            for (var i = 0; i < totalCount; i++)
            {
                var fileName = coll1.GetItemAt(i);

                var dirAuthors = BookListPathsProperties.PathAuthorsDirectory;

                var coll2    = new CombinePathsClass();
                var filePath = coll2.CombineDirectoryPathWithFileName(dirAuthors, fileName);

                var coll3 = new InputClass();
                coll3.ReadTitlesFromFileLoop(filePath);

                this.FindTitlesInString();
            }
        }