示例#1
0
        /// <summary>
        /// Loop threw all authors.
        /// </summary>
        public void AllAuthorsLoop()
        {
            var coll = new AuthorNamesCollection();

            var totalCount = coll.GetItemsCount();

            if (totalCount == 0)
            {
                return;
            }

            Debug.AutoFlush = true;
            Debug.Indent();
            Debug.WriteLine("All Authors loop - Authors Count  " + coll.GetItemsCount().ToString());
            Debug.Unindent();

            for (var index = 0; index < totalCount; index++)
            {
                if (!this._valid.ValidateStringIsNotNull(coll.GetItemAt(index)))
                {
                    continue;
                }

                var author = coll.GetItemAt(index).Trim();

                if (!this._valid.ValidateStringIsNotNull(author))
                {
                    continue;
                }

                BookListPathsProperties.CurrentWorkingFileName = coll.GetItemAt(index);

                this.SearchBookTitleBySingleAuthor();
            }
        }
        public static void RemoveAuthorNamesFRomAuthorsList(List<string> authorsList)
        {
            for (int i = 0; i < AuthorNamesCollection.ItemsCount(); i++)
            {
                var authorsListName = AuthorNamesCollection.GetItemAt(i);

                if (!authorsList.Contains(authorListName))
            }
        }
        /// <summary>Fills the Author names list collection with authors names.</summary>
        private void FillListWithAuthorsNames()
        {
            var coll = new AuthorNamesCollection();

            lstAuthor.Sorted = true;
            for (var index = 0; index < coll.ItemsCount(); index++)
            {
                lstAuthor.Items.Add(coll.GetItemAt(index));
            }
        }
        public static void RemoveAuthorNamesFRomAuthorsList(List<string> authorsList)
        {
            for (int i = 0; i < AuthorNamesCollection.ItemsCount(); i++)
            {
                if (!authorsList.Contains(Au)
                {

                }
            }
        }
 public static void AddAuthorNamesFromAuthorsList(List <string> authorsList)
 {
     // add file name author to authors list file.
     foreach (var author in authorsList)
     {
         if (!AuthorNamesCollection.ContainsItem(author))
         {
             AuthorNamesCollection.AddItem(author);
         }
     }
 }
示例#6
0
        /// <summary>
        ///     Make the list of author names match the FileNames.
        /// </summary>
        private void GetAuthorFileNamesAddToAuthorsNamesList()
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var coll1 = new AuthorNamesCollection();
            var coll2 = new AuthorsFileNamesCollection();

            coll1.ClearCollection();
            for (var index = 0; index < coll2.GetItemsCount(); index++)
            {
                coll1.AddItem(coll2.GetItemAt(index));
            }
        }
        /// <summary>
        ///     The GetAuthorFileNamesFromAuthorsList.
        /// </summary>
        public void GetAuthorFileNamesFromAuthorsList()
        {
            var coll  = new AuthorNamesCollection();
            var input = new InputClass();

            var authorNames = input.ReadAuthorNamesFromFile(BookListPathsProperties.PathAuthorsNamesListFile);

            coll.ClearCollection();
            foreach (var name in authorNames)
            {
                coll.AddItem(name);
            }
        }
示例#8
0
        /// <summary>Fills the Author names list collection with authors names.</summary>
        public void FillListWithAuthorsNames()
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var coll = new AuthorNamesCollection();

            coll.ClearCollection();

            var cls = new InputClass();

            cls.ReadAuthorsNamesFromFile(BookListPathsProperties.PathAuthorsNamesListFile);

            coll.SortCollection();
        }
示例#9
0
        /// <summary>
        ///     Read all authors names from authors list. Used to find the Authors
        ///     file.
        /// </summary>
        /// <param name="filePath">The file path to the Authors List.</param>
        public void ReadAuthorsNamesFromFile(string filePath)
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            var coll = new AuthorNamesCollection();

            coll.ClearCollection();


            try
            {
                if (!this._validate.ValidateStringIsNotNull(filePath))
                {
                    return;
                }
                if (!this._validate.ValidateStringHasLength(filePath))
                {
                    return;
                }
                if (!this._validate.ValidateFileExists(filePath, true))
                {
                    return;
                }

                using (var sr = new StreamReader(filePath))
                {
                    string line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        coll.AddItem(line);
                    }
                }
            }
            catch (OutOfMemoryException ex)
            {
                this._msgBox.Msg = "Not enough memory to continue. Try closing other windows.";

                Debug.WriteLine(ex.ToString());

                this._msgBox.ShowErrorMessageBox();
            }
        }
示例#10
0
        /// <summary>
        ///     Write Arthur names to file.
        /// </summary>
        /// <param name="filePath"><see cref="Path" /> to write file to.</param>
        /// <returns>
        ///     True if file is written else false.
        /// </returns>
        public bool WriteArthurFileNamesToListFile(string filePath)
        {
            this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name;

            if (!this._validate.ValidateStringIsNotNull(filePath))
            {
                return(false);
            }
            if (!this._validate.ValidateStringHasLength(filePath))
            {
                return(false);
            }
            if (!this._validate.ValidateFileExists(filePath, true))
            {
                return(false);
            }

            try
            {
                var coll = new AuthorNamesCollection();

                using (var streamWriter = new StreamWriter(filePath, false))
                {
                    for (var index = 0; index < coll.ItemsCount(); index++)
                    {
                        if (!this._validate.ValidateIndex(index, coll.ItemsCount()))
                        {
                            continue;
                        }
                        var item = coll.GetItemAt(index);
                        // if index out of range will return empty string. so skip adding.
                        if (string.IsNullOrEmpty(item))
                        {
                            continue;
                        }
                        streamWriter.WriteLine(coll.GetItemAt(index));
                    }
                }

                return(true);
            }
            catch (UnauthorizedAccessException ex)
            {
                this._msgBox.Msg = "You do not have access writes for this operation.";

                Debug.WriteLine(ex.ToString());

                this._msgBox.ShowErrorMessageBox();
            }
            catch (PathTooLongException ex)
            {
                this._msgBox.Msg = "the file path is to long.";

                Debug.WriteLine(ex.ToString());

                this._msgBox.ShowErrorMessageBox();
            }
            catch (SecurityException ex)
            {
                this._msgBox.Msg = "The operation has caused a security violation.";

                Debug.WriteLine(ex.ToString());
            }

            return(false);
        }