Exemplo n.º 1
0
        /// <summary>
        /// Write the Locations database.
        /// </summary>
        /// <param name="dstDir">Destination directory.</param>
        /// <returns>Full path to destination directory.</returns>
        public string Write(string dstDir)
        {
            PDB pdb = new PDB("Locations");

            for (int i = 0; i < list.Count; i++)
            {
                pdb.AddRecord(enc.GetBytes((string)list[i]));
            }

            pdb.Write(dstDir);
            return(pdb.fullPath);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Build a PDB file.
        /// </summary>
        /// <param name="dstDir">Destination Directory.</param>
        /// <param name="key">Index key.</param>
        /// <param name="list">Index list.</param>
        /// <returns>Returns the full path to the file.</returns>
        public string BuildPDBFile(string dstDir, int key, ArrayList list)
        {
            string      prevSurname = null, pdbName = "index" + hexChars[((key >> 4) & 0xf)] + hexChars[(key & 0x0f)];
            ByteBuilder bb     = new ByteBuilder(8192);
            int         recIdx = 0;
            Person      p;
            PDB         pdb;

            wizard.cStatus.Text = "Creating PDB file: " + pdbName;
            wizard.cProgressBar.PerformStep();
            Application.DoEvents();

            pdb = new PDB(pdbName);
            for (int i = 0; i < list.Count; i++)
            {
                p = (Person)list[i];
                if (prevSurname == null)
                {
                    prevSurname = p.iSurname;
                    bb.Append(p.iSurname);
                    bb.Append(0);
                    AppendPerson(recIdx, key, bb, p);
                }
                else if (p.iSurname.CompareTo(prevSurname) == 0)
                {
                    AppendPerson(recIdx, key, bb, p);
                }
                else
                {
                    pdb.AddRecord(bb.ToBytes());
                    recIdx++;
                    bb.Reset();
                    prevSurname = p.iSurname;
                    bb.Append(p.iSurname);
                    bb.Append(0);
                    AppendPerson(recIdx, key, bb, p);
                }
            }

            if (bb.Count > 0)
            {
                pdb.AddRecord(bb.ToBytes());
            }

            pdb.Write(dstDir);
            return(pdb.fullPath);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Write the managers database.
        /// </summary>
        /// <param name="dstDir">Destination directory.</param>
        /// <returns>Full path to managers database.</returns></returnss>
        public string Write(string dstDir)
        {
            PDB pdb = new PDB("Managers");
            int idx;

            for (idx = 0; idx < mgrKey.Length; idx++)
            {
                byte[] bytes = new byte[5];

                bytes[0] = mgrKey[idx];
                bytes[1] = (byte)((mgrRIdx[idx] >> 8) & 0xff);
                bytes[2] = (byte)(mgrRIdx[idx] & 0xff);
                bytes[3] = (byte)((mgrPIdx[idx] >> 8) & 0xff);
                bytes[4] = (byte)(mgrPIdx[idx] & 0xff);
                pdb.AddRecord(bytes);
            }

            pdb.Write(dstDir);
            return(pdb.fullPath);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Write the phone databases.
        /// <param name="dstDir">Destination directory.</param>
        /// </summary>
        public void WritePhoneDBs(string dstDir)
        {
            string      prevKey = "", curKey;
            ByteBuilder bb = new ByteBuilder(32);
            SortedList  sl;
            int         i, j, x;
            Person      p;
            string      phone;
            PDB         pdb;
            int         idx;
            byte        b;

            for (i = 0; i < 10; i++)
            {
                sl = slPhones[i];

                if (sl.Count == 0)
                {
                    continue;
                }

                wizard.cStatus.Text = "Writing Phone database " + (i + 1);
                wizard.cProgressBar.PerformStep();

                pdb = new PDB("phones" + (char)(i + '0'));
                bb.Reset();

                for (j = 0; j < sl.Count; j++)
                {
                    Application.DoEvents();
                    if (fWizard.appStopped)
                    {
                        return;
                    }

                    phone = (string)sl.GetKey(j);
                    p     = (Person)sl.GetByIndex(j);

                    curKey = phone.Substring(1, 2);
                    phone  = phone.Substring(3);

                    if ((curKey != prevKey) || (bb.Count > 64000))
                    {
                        if (bb.Count > 0)
                        {
                            pdb.AddRecord(bb.ToBytes());
                            bb.Reset();
                        }
                        prevKey = curKey;
                        bb.Append(curKey);
                    }

                    bb.Append((ushort)p.pRecIndex);
                    bb.Append((ushort)p.pOffset);
                    bb.Append((byte)p.pKey);

                    idx = phone.Length >> 1;
                    if ((phone.Length & 1) == 1)
                    {
                        idx++;
                    }
                    bb.Append((byte)idx);

                    for (idx = 0; idx < ((phone.Length >> 1) << 1);)
                    {
                        x  = (phone[idx++] - '0') << 4;
                        b  = (byte)x;
                        x  = (phone[idx++] - '0');
                        b |= (byte)x;
                        bb.Append(b);
                    }

                    if (idx < phone.Length)
                    {
                        bb.Append((byte)((phone[idx] - '0') << 4));
                    }
                }

                if (bb.Count > 0)
                {
                    pdb.AddRecord(bb.ToBytes());
                }

                pdb.Write(dstDir);
                InstallFile(wizard.config.palmProfile, pdb.fullPath);
            }
        }