Ejemplo n.º 1
0
        public override void Execute(NntpSession session)
        {
            switch (state)
            {
            case RequestState.StartingRequest:
                state = RequestState.ReceivingHeaders;
                session.Connection.SendLine("340 Send article to be posted");
                break;

            case RequestState.RequestFinished:
                using (INntpConnection connection = session.Repository.CreateConnection())
                {
                    INntpArticle article = connection.CreateArticle();

                    SetOverviewHeaders(article);
                    SetOtherHeaders(article);
                    article.Body = body.ToString();

                    connection.PostArticle(article);
                }

                session.Connection.SendLine("240 Article received OK");
                break;
            }
        }
Ejemplo n.º 2
0
        private void SetOtherHeaders(INntpArticle article)
        {
            Dictionary <string, string> headers
                = new Dictionary <string, string>(this.headers);

            headers.Remove(NntpHeaderName.Subject);
            headers.Remove(NntpHeaderName.From);
            headers.Remove(NntpHeaderName.Date);
            headers.Remove(NntpHeaderName.Newsgroups);
            headers.Remove(NntpHeaderName.References);

            foreach (KeyValuePair <string, string> header in headers)
            {
                article.Headers[header.Key] = header.Value;
            }
        }
Ejemplo n.º 3
0
        private void SetOverviewHeaders(INntpArticle article)
        {
            article.Subject = headers[NntpHeaderName.Subject];
            article.From    = headers[NntpHeaderName.From];

            if (headers.ContainsKey(NntpHeaderName.Date))
            {
                article.Date = headers[NntpHeaderName.Date];
            }

            article.Newsgroups = headers[NntpHeaderName.Newsgroups];

            if (headers.ContainsKey(NntpHeaderName.References))
            {
                article.References = headers[NntpHeaderName.References];
            }
        }
Ejemplo n.º 4
0
 void INntpConnection.PostArticle(INntpArticle article)
 {
     session.Save(article);
     transaction.Commit();
 }
Ejemplo n.º 5
0
 void INntpConnection.PostArticle(INntpArticle article)
 {
     throw new Exception("The method or operation is not implemented.");
 }