/// <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)); } }
/// <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); }