/// <summary> /// Gets the last (previous) article in the list /// </summary> /// <param name="clientUsername">Authenticated username</param> /// <param name="groupName">Newsgroup name</param> /// <returns>Article object</returns> public Article GetLastArticleByNumber(string clientUsername, string groupName, int articleNumber) { Newsgroup group = GetNewsgroup(clientUsername, groupName, true); int newArticleNo = articleNumber - 1; while (newArticleNo >= group.FirstArticle) { var a = GetArticleByNumber(clientUsername, groupName, newArticleNo); if (a != null) { return(a); } newArticleNo--; } return(null); }
///// <summary> ///// Returns the article based on the given number ///// </summary> ///// <param name="clientUsername">Authenticated username</param> ///// <param name="groupName">Newsgroup name</param> ///// <param name="articleNumber">Article number</param> ///// <returns>Article object</returns> //public Article GetArticleByNumber(string clientUsername, string groupName, int articleNumber) //{ // Newsgroup group = GetNewsgroup(clientUsername, groupName); // if (group != null) // { // lock (group.Articles) // { // try // { // Article article = group.Articles[articleNumber]; // return article; // } // catch (KeyNotFoundException) // { // //System.Diagnostics.Trace.WriteLine("Article [" + articleNumber.ToString() + "] in group [" + groupName + "] not found"); // } // catch (Exception ex) // { // Logging.Error("Failed to access article list for group [" + groupName + "]", ex); // } // } // } // return null; //} /// <summary> /// Gets the next article in the list from the given position /// </summary> /// <param name="clientUsername">Authenticated username</param> /// <param name="groupName">Newsgroup name</param> /// <param name="articleNumber">Number of the article</param> /// <returns>Article object</returns> public Article GetNextArticleByNumber(string clientUsername, string groupName, int articleNumber) { Newsgroup group = GetNewsgroup(clientUsername, groupName, true); int newArticleNo = articleNumber + 1; while (newArticleNo <= group.LastArticle) { var a = GetArticleByNumber(clientUsername, groupName, newArticleNo); if (a != null) { return(a); } newArticleNo++; } return(null); //bool returnNextArticle = false; //if (group != null) //{ // lock (group.Articles) // { // foreach (KeyValuePair<int, Article> key in group.Articles) // { // if (returnNextArticle) // { // return key.Value; // } // if (key.Value.Number == articleNumber) // { // returnNextArticle = true; // } // } // } //} // //return null; }