Re: Arraylist.remove problem?? Please help.



this is all I have so far. Haven't added in anything else yet. Don't
know how to go through a hashtable yet. Trying to learn how now.

using System;
using System.Collections;
using System.Text;
using MySql.Data;
using System.Text.RegularExpressions;

namespace groupheaders
{
class Program
{
static Hashtable master;
static MySql.Data.MySqlClient.MySqlConnection conn = new
MySql.Data.MySqlClient.MySqlConnection();
static MySql.Data.MySqlClient.MySqlCommand cmd = new
MySql.Data.MySqlClient.MySqlCommand();
static MySql.Data.MySqlClient.MySqlCommand cmdu = new
MySql.Data.MySqlClient.MySqlCommand();
static string myConnectionString =
"server=127.0.0.1;uid=root;pwd=password;database=test;";
static string[] groups = { "alt.binaries.games.xbox",
"alt.binaries.games.xbox360", "alt.binaries.boneless",
"alt.binaries.nl" };
static Regex seg = new Regex("\\([0-9]*/[0-9]*\\)",
RegexOptions.IgnoreCase);
static string group;
static string table;
static Regex reg = new Regex("\\.");
class RelatedHeaders : IEnumerable
{
private string _realSubject = null;
private ArrayList _list = new ArrayList();


public RelatedHeaders(Header firstHeader)
{
this._realSubject = firstHeader.RealSubject;
this._list.Add(firstHeader);
}


public void Add(Header newHeader)
{
if (newHeader.RealSubject != this._realSubject)
{
throw new ArgumentException(String.Format("New
header has subject '{0}', but should be '{1}'.", newHeader.RealSubject,
this._realSubject), "newHeader");
}
this._list.Add(newHeader);
}


public IEnumerator GetEnumerator()
{
return this._list.GetEnumerator();
}
}
class Header
{
private string numb;
private string subject;
private int messageNumber;
private int maxMessages;
private string realSubject;
private string date;
private string from;
private string msg_id;
private string bytes;
static Regex seg = new Regex("\\([0-9]*/[0-9]*\\)",
RegexOptions.IgnoreCase);

public Header(string numb, string subject, string date,
string
from, string msg_id, string bytes)
{
this.numb = numb;
this.subject = subject;
this.date = date;
this.from = from;
this.msg_id = msg_id;
this.bytes = bytes;
ExtractMessageNumber(this.subject, out
this.messageNumber, out this.maxMessages);
this.realSubject = ExtractMainSubject(this.subject);
}

// Now pull apart the message title... move the
private void ExtractMessageNumber(string subject, out int
number, out int max)
{
Match m = seg.Match(subject);
string segsplit = m.ToString().Replace("(",
"").Replace(")", "");
string[] segments = segsplit.Split('/');
number = int.Parse(segments[0]);
max = int.Parse(segments[1]);
}
private string ExtractMainSubject(string subject)
{
return seg.Replace(subject, "");
}

//ExtractMessageNumber(this.subject, out
this.messageNumber, out this.maxMessages);
//this.realSubject = ExtractMainSubject(this.subject);

public string Number
{
get { return this.numb; }
}


public string Subject
{
get { return this.subject; }
}


public int MessageNumber
{
get { return this.messageNumber; }
}

public int MaxMessages
{
get { return this.maxMessages; }
}
public string RealSubject
{
get { return this.realSubject; }
}
public string Date
{
get { return this.date; }
}
public string From
{
get { return this.from; }
}
public string Msg_id
{
get { return this.msg_id; }
}
public string Bytes
{
get { return this.bytes; }
}
}
static void Main(string[] args)
{
conn.ConnectionString = myConnectionString;
conn.Open();
cmd.Connection = conn;
cmdu.Connection = conn;
for (int x = 0; x < groups.Length; x++)
{
table = reg.Replace(groups[x], "");
group = groups[x];
getheaders();
//Console.WriteLine("Have this many headers {0}",
master.Count);
//Header one = (Header)master[0];
//Console.WriteLine("first one {0} {1}", one.Number,
one.Subject);
//find();
master.Clear();
//prepared = false;
}

}
static void getheaders()
{
cmd.CommandText = "select * from " + table + " where
subject like '%(%/%)%' and subject like '%\"%\"%' limit 200000";
MySql.Data.MySqlClient.MySqlDataReader reader;
reader = cmd.ExecuteReader();
master = new Hashtable();
while (reader.Read())
{
Header h = new Header(reader.GetValue(0).ToString(),
reader.GetValue(1).ToString(), reader.GetValue(3).ToString(),
reader.GetValue(2).ToString(), reader.GetValue(4).ToString(),
reader.GetValue(5).ToString());
RelatedHeaders group =
(RelatedHeaders)master[h.RealSubject];
if (group == null)
{
group = new RelatedHeaders(h);
master.Add(h.RealSubject, group);
}
else
{
group.Add(h);
}


}
reader.Close();
}


}
}

.



Relevant Pages

  • Re: Setting id in a dynmaically generated checkboxlist
    ... > protected Repeater Repeater1; ... > public Category(string title, string explanation, ... > public string Explanation ... > private string explanation; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Threading with an object and Session
    ... thread post the mail body directly to the session, ... private string _DatabaseConnection; ... public string EmailNameField ...
    (microsoft.public.dotnet.framework.aspnet)
  • Default.aspx.cs
    ... string strReturn = SendInvitations(txtName.Text, ... private string SendInvitations(string name, string body, string ... emails, string codedString, ArrayList friend) ... public string subject ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Arraylist.remove problem?? Please help.
    ... static string group; ... private string numb; ... private int messageNumber; ... public string Subject ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: variable length fields for flexibility in subroutines
    ... private string _IntBlock; ... public string IBreturn ... public string IBstreet ...
    (comp.lang.cobol)