Example #1
0
 /// <summary>
 /// Setup conversion.
 /// </summary>
 /// <param name="w">Wizard.</param>
 /// <param name="p">Path to database file</param>
 public Convert(fWizard w, string p)
 {
     wizard = w;
     dbPath = p;
     zip    = new Zip();
 }
Example #2
0
        /// <summary>
        /// Build the Person array. Reads and parses the zip file. Build a sorted
        /// list with all the records.
        /// </summary>
        public void BuildPersonArray()
        {
            int    cnt = 0, bump = 0;
            Regex  regex = new Regex("\t");
            long   uid   = 1;
            string s;

            for (;;)
            {
                if (bump > 8)
                {
                    Application.DoEvents();
                    if (fWizard.appStopped)
                    {
                        return;
                    }

                    bump = 0;
                }
                else
                {
                    bump++;
                }

                if ((s = zip.GetLine()) != null)
                {
                    Person p = new Person(addr, mgr, s, regex, uid);
                    int    i;
                    string surname;

                    if (p.valid == true)
                    {
                        if ((surname = p.iSurname).Length == 0)
                        {
                            surname = ".";
                        }

                        if ((i = slMain.IndexOfKey(surname)) == -1)
                        {
                            slMain.Add(surname, new SortedList(InvariantComparer.Default));
                            if ((i = slMain.IndexOfKey(surname)) == -1)
                            {
                                throw new Exception("Cannot find newly created node - low on memory?");
                            }
                        }

                        SortedList sl = (SortedList)slMain.GetByIndex(i);
                        sl.Add(p.uid, p);

                        cnt++;
                        uid++;
                    }
                }
                else
                {
                    if (zip.contFlag < 0)
                    {
                        break;
                    }
                }

                if (zip.SwitchedFile() == true)
                {
                    wizard.cProgressBar.PerformStep();
                    wizard.cStatus.Text = "Reading from: " + zip.currentFile;
                }
            }

            zip.Close();
            zip = null;
        }