All pastes #116019 Raw Edit

Dragon

public text v1 · immutable
#116019 ·published 2006-08-05 01:04 UTC
rendered paste body
            Console.WriteLine("Sorting(1)...");
            ArrayList _processed = new ArrayList();
            ArrayList _encodedposts = new ArrayList();
            ArrayList _incomplete = new ArrayList();
            _total = _unProcessed.Count;
            _done = 0;
            _tt = new Timer(new TimerCallback(_tt_tick), null, 500, 500);
            while (_unProcessed.Count != 0)
            {
                Header H = (Header)_unProcessed[0];
                _unProcessed.RemoveAt(0);
                string[] parms = H.Line.Split('\t');
                string lastword = parms[6].Substring(parms[6].LastIndexOf(' ')+1).Trim();
                if ((lastword.Substring(0, 1) == "(") &&
                    (lastword.Substring(lastword.Length - 1, 1) == ")") &&
                    (lastword.IndexOf("/") > 0))
                {
                    string subject = parms[6].Substring(0, parms[6].LastIndexOf(' '));
                    bool found = false;
                    for (int i=0; i<_incomplete.Count; i++)
                    {
                        EncodedPost sep = (EncodedPost)_incomplete[i];
                        if (sep.Line.CompareTo(subject) == 0)
                        {
                            //found the one to add it to.
                            sep.Pieces.Add(H);
                            if (sep.PieceCount == sep.Pieces.Count)
                            {
                                _encodedposts.Add(sep);
                                _incomplete.RemoveAt(i);
                            }
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        EncodedPost ep = new EncodedPost();
                        ep.Line = subject;
                        ep.Date = H.Date;
                        string count = lastword.Trim(new char[] { '(', ')' });
                        count = count.Substring(count.IndexOf("/") + 1);
                        ep.PieceCount = int.Parse(count);
                        ep.Pieces.Add(H);
                        if (ep.PieceCount == ep.Pieces.Count)
                            _encodedposts.Add(ep);
                        else
                            _incomplete.Add(ep);
                    }
                }
                else
                {
                    _processed.Add(H);
                }
                _done++;
            }