コード例 #1
0
ファイル: NntpClient.cs プロジェクト: haoasqui/MailSystem.NET
        /// <summary>
		/// Retrieves the server's newsgroups.
		/// </summary>
		/// <returns>The server's newsgroups.</returns>
		/// <example>
		/// <code>
		/// C#
		/// 
		/// NntpClient nttp = new NntpClient();
		/// nntp.Connect("news.myhost.com");
		/// NewsGroupCollection groups = nntp.GetNewsGroups();
		/// nntp.Disconnect();
		/// 
		/// VB.NET
		/// 
		/// Dim nttp as New NntpClient()
		/// nntp.Connect("news.myhost.com") 
		/// Dim groups as NewsGroupCollection = nntp.GetNewsGroups()
		/// nntp.Disconnect()
		/// 
		/// JScript.NET
		/// 
		/// var nntp:NntpClient = new NntpClient();
		/// nntp.Connect("news.myhost.com");
		/// var groups:NewsGroupCollection = nntp.GetNewsGroups();
		/// nntp.Disconnect();
		/// </code>
		/// </example>
		public NewsGroupCollection GetNewsGroups()
		{
            byte[] data = this.CommandMultiline("list");
            string response = System.Text.Encoding.ASCII.GetString(data,0,data.Length);
			NewsGroupCollection groups = new NewsGroupCollection();
			string[] _groups = System.Text.RegularExpressions.Regex.Split(response,"\r\n");
			for(int i=1;i<_groups.Length-1;i++) 
			{
				string[] _splitted = _groups[i].Split(' ');
				groups.Add(new NewsGroup(_splitted[0],System.Convert.ToInt32(_splitted[2]),System.Convert.ToInt32(_splitted[1]),(_splitted[3].ToLower()=="y") ? true : false,this));
			}
			return groups;
		}
コード例 #2
0
ファイル: NntpClient.cs プロジェクト: haoasqui/MailSystem.NET
		/// <summary>
		/// Retrieves the server's newsgroups that have been created since the specified date/time.
		/// </summary>
		/// <param name="startDate">The minimum creation date/time.</param>
		/// <param name="gmt">Specifies if startDate is GMT or not.</param>
		/// <param name="distribution">Distribution filter of the articles.</param>
		/// <returns>The server's newsgroups that have been created since the specified date/time and that contain articles for the specified distribution.</returns>
		/// <example>
		/// <code>
		/// C#
		/// 
		/// NntpClient nttp = new NntpClient();
		/// nntp.Connect("news.myhost.com");
		/// //Get groups created less than one months ago (GMT time) and containing articles to be distributed to "staff".
		/// NewsGroupCollection groups = nntp.GetNewsGroups(System.DateTime.Now.AddMonth(-1),true,"staff");
		/// nntp.Disconnect();
		/// 
		/// VB.NET
		/// 
		/// Dim nttp as New NntpClient()
		/// nntp.Connect("news.myhost.com") 
		/// 'Get groups created less than one months ago (GMT time) and containing articles to be distributed to "staff".
		/// Dim groups as NewsGroupCollection = nntp.GetNewsGroups(System.DateTime.Now.AddMonth(-1),True,"staff")
		/// nntp.Disconnect()
		/// 
		/// JScript.NET
		/// 
		/// var nntp:NntpClient = new NntpClient();
		/// nntp.Connect("news.myhost.com");
		/// //Get groups created less than one months ago (GMT time) and containing articles to be distributed to "staff".
		/// var groups:NewsGroupCollection = nntp.GetNewsGroups(System.DateTime.Now.AddMonth(-1),true,"staff");
		/// nntp.Disconnect();
		/// </code>
		/// </example>
		public NewsGroupCollection GetNewsGroups(System.DateTime startDate, bool gmt, string distribution)
		{
			string sdistribution = (distribution.Length>0) ? " "+distribution : "";
			string sgmt = (gmt) ? " GMT" : "";
            byte[] data = this.CommandMultiline("newgroups " + startDate.ToString("yyMMdd hhmmss") + sgmt + sdistribution);
            string response = System.Text.Encoding.ASCII.GetString(data,0,data.Length);
            ActiveUp.Net.Mail.NewsGroupCollection groups = new ActiveUp.Net.Mail.NewsGroupCollection();
			string[] _groups = System.Text.RegularExpressions.Regex.Split(response,"\r\n");
			for(int i=1;i<_groups.Length-1;i++) 
			{
				string[] _splitted = _groups[i].Split(' ');
                groups.Add(new ActiveUp.Net.Mail.NewsGroup(_splitted[0], System.Convert.ToInt32(_splitted[2]), System.Convert.ToInt32(_splitted[1]), (_splitted[3].ToLower() == "y") ? true : false, this));
			}
			return groups;
		}