/// <summary>Page Load.</summary>
  public void Page_Load
  (
   object     sender, 
   EventArgs  e
  ) 
  {
  
   string databaseConnectionString = null;
   string newsGroupCurrent         = null; 
   string newsServerCurrent        = null; 
     
   serverMapPath = this.MapPath("");
   if ( serverMapPath != null)
   {
    filenameConfigurationXml = serverMapPath + @"\" + filenameConfigurationXml;
   }//if ( serverMapPath != null)

   if ( !Page.IsPostBack )
   {
    UtilityNetworkNewsTransferProtocolNNTP.ConfigurationFile();

    databaseConnectionString  =  UtilityNetworkNewsTransferProtocolNNTP.DatabaseConnectionString;
    newsServerCurrent         =  UtilityNetworkNewsTransferProtocolNNTP.NewsServer;
    newsGroupCurrent          =  UtilityNetworkNewsTransferProtocolNNTP.NewsGroup;
   
    NewsServer = newsServerCurrent;
    NewsGroup  = newsGroupCurrent;

   }//if ( !Page.IsPostBack ) 
   
  }//Page_Load
  }//PageCancel()	

  /// <summary>PageSubmit().</summary>
  public void PageSubmit()
  {
   string newsGroupCurrent  = null;
   string newsServerCurrent = null;
   
   StringBuilder sbResponse = null;
  
   newsGroupCurrent  = NewsGroup;
   newsServerCurrent = NewsServer;
   
   Feedback   = "";
   
   UtilityNetworkNewsTransferProtocolNNTP.NewsClient
   (
    ref newsServerCurrent,
    ref newsGroupCurrent,
    ref sbResponse
   );
   
   if ( sbResponse != null )
   {
   	Feedback = sbResponse.ToString();
   }
   
  }//PageSubmit()	
Ejemplo n.º 3
0
  }//public static void Main(string[] args) 

  ///<summary>The news server.</summary>
  ///<param name="newsServer">NewsServer.</param>
  ///<param name="newsGroup">NewsGroup.</param>  
  ///<param name="sbResponse">Response.</param>
  public static void NewsClient
  (
   ref string        newsServer,
   ref string        newsGroup,
   ref StringBuilder sbResponse
  )  
  {
  	
   string                                 newsGroupCurrent                       = null;

   ArrayList                              newsGroupList                          = null;
   ArrayList                              news                                   = null;
   
   UtilityNetworkNewsTransferProtocolNNTP utilityNetworkNewsTransferProtocolNNTP = null;

   sbResponse = new StringBuilder();

   try
   {
    utilityNetworkNewsTransferProtocolNNTP = new UtilityNetworkNewsTransferProtocolNNTP(); 
    utilityNetworkNewsTransferProtocolNNTP.Connect(newsServer); 

    if ( newsGroup != null && newsGroup != String.Empty )
    {
     newsGroupList = new ArrayList();
     newsGroupList.Add( newsGroup );
    }
    else
    {
     newsGroupList = utilityNetworkNewsTransferProtocolNNTP.GetNewsgroups();
    }    	

    foreach(object arrayListCurrent in newsGroupList)
    {
     newsGroupCurrent = (String) arrayListCurrent;
     
     sbResponse.Append( "<b>NewsGroup:</b>" );
     sbResponse.Append( newsGroupCurrent );
     sbResponse.Append( "<br />" );
     System.Console.WriteLine("Newsgroup: {0}", newsGroupCurrent);
     news = utilityNetworkNewsTransferProtocolNNTP.GetNews(newsGroupCurrent);
     foreach (string newsCurrent in news)
     {
      sbResponse.Append( newsCurrent );
      sbResponse.Append( "<br />" );
      System.Console.WriteLine("News :{0}", newsCurrent);
     }//foreach (string newsCurrent in news)
    }//foreach(string newsGroupCurrent in newsGroup)  

    utilityNetworkNewsTransferProtocolNNTP.Disconnect(); 
   }//try 
   catch (UtilityNetworkNewsTransferProtocolNNTPException e ) 
   {
    sbResponse = new StringBuilder();
    sbResponse.Append( "Exception: " );
    sbResponse.Append( e.ToString() );
    System.Console.WriteLine( e.ToString() ); 
   } 
   catch (System.Exception exception) 
   {
    sbResponse = new StringBuilder();
    sbResponse.Append( "Exception: " );
    sbResponse.Append( exception.Message );
    System.Console.WriteLine("Exception: {0}", exception.Message); 
   } 
  }//}//public static void NewsClient()