⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nntp.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;

namespace AspNetForums.Components {

    public class Nntp {

        private void AddForumPosts () {
            string nntpServer = "msnews.microsoft.com";

            NntpClient nntp = new NntpClient(nntpServer);
        }

        public static void UpdateNntpForum (int forumID, String nntpServer, String nntpGroup) {

            ForumsDataProvider dp = ForumsDataProvider.Instance();
            NntpClient nntp = new NntpClient(nntpServer);
            int startArticleID = dp.NntpGetLastPostNumber(forumID);
            int maxBackArticles = 1000;

            // Get the article IDs from NNTP
            //
            String [] articleIDs = nntp.GetArticleIDs(nntpGroup, startArticleID, maxBackArticles);

            foreach(String articleID in articleIDs) {

                try {

                    // Get the requested article
                    //
                    NntpPost post = nntp.GetArticle(articleID);

                    // Add the article to the database
                    //
                    dp.NntpAddPost( forumID, post );

                }
                catch (Exception errInfo) {
                    Console.WriteLine("Error with articleId: " + articleID);
                    Console.WriteLine("Error message: " + errInfo);
                }
            }

            Console.WriteLine("Added " + articleIDs.Length + " articles");

            nntp.Close();        
        }

        public void UpdateForums() {
            bool forumsToUpdate = false;

            // Get an instance of the data provider
            //
            ForumsDataProvider dp = ForumsDataProvider.Instance();

            // Pull down any new messages that we don't have
            //
            try {

                ArrayList forums = dp.NntpGetNntpForums();

                foreach (NntpForum forum in forums) {

                    forumsToUpdate = true;

                    Console.WriteLine("Updating for newsgroup: " + forum.NntpGroup);

                    UpdateNntpForum(forum.ForumID, forum.NntpServer, forum.NntpGroup);        
                }


                if (!forumsToUpdate)
                    Console.WriteLine("No forums to update.");

                AddForumPosts();
            }
            catch(Exception errInfo) {
            
                Console.WriteLine("Error Update Forums: " + errInfo);
            }

        }    
    }

    public enum NntpCommand {
        Group,
        List,
        Xhdr,
        Head,
        Body,
        Post,
        EndOfText
    }

    public enum ResponseCode {
        HelpText                            = 100,
        DebugOutput                         = 199,
        ServerReadyPostingAllowed           = 200,
        ServerReadyNoPostingAllowed         = 201,
        SlaveStatusNoted                    = 202,
        ClosingConnection                   = 205,
        GroupSelected                       = 211,
        ListOfNewsGroupsFollows             = 215,
        ArticleRetrievedHeadAndBodyFollows  = 220,
        ArticleRetrievedHeadFollows         = 221,
        ArticleRetrievedBodyFollows         = 222,
        ArticleRetrievedTextSeparately      = 223,
        ListOfNewArticlesByMessageIDFollows = 230,
        ListOfNewsgroupsFollows             = 231,
        ArticleTransferredOk                = 235,
        ArticlePostedOk                     = 240,
        SendArticleToTransfer               = 335,
        SendArticleToPost                   = 340,
        ServiceDiscontinued                 = 400,
        NoSuchNewsgroup                     = 411,
        NoNewsgroupSelected                 = 412,
        NoCurrentArticleSelected            = 420,
        NoNextArticleInThisGroup            = 421,
        NoPrevArticleInThisGroup            = 422,
        NoArticleNumberInThisGroup          = 423,
        NoSuchArticleFound                  = 430,
        ArticleNotFoundDoNotSend            = 435,
        TransferFailedTryAgainLater         = 436,
        ArticleRejectedDoNotTryAgain        = 437,
        PostingNotAllowed                   = 440,
        PostingFailed                       = 441,
        CommandNotRecognized                = 500,
        CommandSyntaxError                  = 501,
        PermissionDenied                    = 502,
        ProgramFault                        = 503
    }

    class NntpRequest {
        NntpCommand requestCommand;


    }

    class NntpResponse {

        ResponseCode responseCode;
        string message;

        public NntpResponse(ResponseCode responseCode, string responseMessage) {
            this.responseCode = responseCode;
            this.message = responseMessage;
        }

        public ResponseCode ResponseCode {
            get {
                return responseCode;
            }
        }

        public string RawResponse {
            get {
                return message;
            }
        }

    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -