コード例 #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            string Msg;

            if (!Validate(out Msg))
            {
                MessageBox.Show(Msg);
                return;
            }
            BayWind.Address addr = new BayWind.Address()
            {
                Street    = textBoxStreet.Text,
                City      = textBoxCity.Text,
                State     = textBoxState.Text,
                Country   = textBoxCountry.Text,
                ZipCode   = textBoxZip.Text,
                AddressID = (int)AddressStore.GetNextSequence()
            };
            BayWind.Person p = new BayWind.Person()
            {
                FirstName   = textBoxFirstName.Text,
                LastName    = textBoxLastName.Text,
                PhoneNumber = textBoxPhone.Text,
                AddressID   = addr.AddressID
            };
            PeopleStore.Add(p.GetKey(), p);
            AddressStore.Add(addr.AddressID, addr);
            GoPreviousPage();
            DisplayPage();
        }
コード例 #2
0
ファイル: PeopleDirectory.cs プロジェクト: kouweizhong/Sop
        void Populate()
        {
            int ZipCodeCtr = 5000;

            for (int i = 0; i < MaxCount; i++)
            {
                int     aid  = (int)AddressStore.GetNextSequence();
                Address addr = new Address()
                {
                    AddressID = aid,
                    Key       = new AddressKey()
                    {
                        Street  = string.Format("143{0} LoveLane", aid),
                        City    = "Fremont",
                        Country = "USA",
                        State   = "California",
                        ZipCode = ZipCodeCtr.ToString()
                    }
                };
                int    pid = (int)PeopleStore.GetNextSequence();
                Person p   = new Person()
                {
                    PersonID  = pid,
                    AddressID = addr.AddressID,
                    Key       = new PersonKey()
                    {
                        FirstName = string.Format("Joe{0}", pid),
                        LastName  = string.Format("Peter{0}", pid)
                    },
                    PhoneNumber = "510-555-9999"
                };
                AddressStore.Add(addr.AddressID, addr);
                PeopleStore.Add(p.PersonID, p);
                PeopleStoreByName.Add(p.Key, p.PersonID);
                AddressStoreByAddress.Add(addr.Key, addr.AddressID);
                if (i % 500 == 0)
                {
                    ZipCodeCtr++;
                    AddressStore.Flush();
                    PeopleStore.Flush();
                    PeopleStoreByName.Flush();
                    AddressStoreByAddress.Flush();
                }
            }
            AddressStore.Flush();
            PeopleStore.Flush();
            PeopleStoreByName.Flush();
            AddressStoreByAddress.Flush();
        }
コード例 #3
0
 void DisplayFields(BayWind.Person p)
 {
     textBoxFirstName.Text = p.FirstName;
     textBoxLastName.Text  = p.LastName;
     textBoxPhone.Text     = p.PhoneNumber;
     if (AddressStore.Search(p.AddressID))
     {
         BayWind.Address addr = AddressStore.CurrentValue;
         textBoxStreet.Text  = addr.Street;
         textBoxCity.Text    = addr.City;
         textBoxState.Text   = addr.State;
         textBoxCountry.Text = addr.Country;
         textBoxZip.Text     = addr.ZipCode;
     }
 }
コード例 #4
0
        void ReadAll()
        {
            PeopleStoreByName.MoveFirst();
            PeopleStoreByName.HintBatchCount = 103;
            long[] Pids      = new long[BatchCount];
            int    PidsIndex = 0;

            PersonKey[] pk  = new PersonKey[BatchCount];
            int         Ctr = 0;

            do
            {
                Ctr++;
                pk[PidsIndex++] = PeopleStoreByName.CurrentKey;
                if (PidsIndex == BatchCount)
                {
                    QueryResult <PersonKey>[] PeopleIDs;
                    if (PeopleStoreByName.Query(QueryExpression <PersonKey> .Package(pk), out PeopleIDs))
                    {
                        for (int i = 0; i < PeopleIDs.Length; i++)
                        {
                            Pids[i] = (long)PeopleIDs[i].Value;
                        }

                        QueryResult <long>[] PeopleFound;
                        if (PeopleStore.Query(QueryExpression <long> .Package(Pids), out PeopleFound))
                        {
                            long[] Aids = new long[PidsIndex];
                            int    i    = 0;
                            foreach (QueryResult <long> pf in PeopleFound)
                            {
                                if (pf.Found)
                                {
                                    Aids[i++] = ((Person)pf.Value).AddressID;
                                }
                            }
                            QueryResult <long>[] AddressesFound;
                            if (AddressStore.Query(QueryExpression <long> .Package(Aids), out AddressesFound))
                            {
                                //** process found Address records here...
                            }
                        }
                    }
                    PidsIndex = 0;
                }
            } while (PeopleStoreByName.MoveNext());
        }
コード例 #5
0
ファイル: PeopleDirectory.cs プロジェクト: kouweizhong/Sop
        void ReadAll()
        {
            PeopleStoreByName.MoveFirst();
            PeopleStoreByName.HintBatchCount = 103;
            PersonKey pk;
            int       Ctr = 0;

            do
            {
                Ctr++;
                pk = PeopleStoreByName.CurrentKey;

                long PersonID = PeopleStoreByName.CurrentValue;

                if (PeopleStore.Search(PersonID))
                {
                    Person p = PeopleStore.CurrentValue;
                    if (AddressStore.Search(p.AddressID))
                    {
                        Address addr = AddressStore.CurrentValue;
                    }
                }
            } while (PeopleStoreByName.MoveNext());
        }
コード例 #6
0
        void ReadAll()
        {
            PeopleStoreByName.MoveFirst();
            PeopleStoreByName.HintBatchCount = 103;
            long[] Pids      = new long[BatchCount];
            int    PidsIndex = 0;

            PersonKey[] pk  = new PersonKey[BatchCount];
            int         Ctr = 0;

            do
            {
                Ctr++;
                pk[PidsIndex++] = PeopleStoreByName.CurrentKey;
                if (PidsIndex == BatchCount)
                {
                    QueryResult <PersonKey>[] PeopleIDs;
                    if (PeopleStoreByName.Query(QueryExpression <PersonKey> .Package(pk), out PeopleIDs))
                    {
                        for (int i = 0; i < PeopleIDs.Length; i++)
                        {
                            Pids[i] = (long)PeopleIDs[i].Value;
                        }

                        QueryResult <long>[] PeopleFound;
                        if (PeopleStore.Query(QueryExpression <long> .Package(Pids), out PeopleFound))
                        {
                            long[] Aids = new long[PidsIndex];
                            int    i    = 0;
                            foreach (QueryResult <long> pf in PeopleFound)
                            {
                                if (pf.Found)
                                {
                                    Aids[i++] = ((Person)pf.Value).AddressID;
                                }
                            }
                            QueryResult <long>[] AddressesFound;
                            if (AddressStore.Query(QueryExpression <long> .Package(Aids), out AddressesFound))
                            {
                                //** process found Address records here...
                                int ctr2 = 0;
                                foreach (var a in AddressesFound)
                                {
                                    ctr2++;
                                    if (!a.Found)
                                    {
                                        Console.WriteLine("Failed to read {0}.", a.Key);
                                    }
                                }
                                if (ctr2 != 1000)
                                {
                                    Console.WriteLine("Failed to read 1000 records, 'only read {0}.", ctr2);
                                }
                            }
                        }
                    }
                    PidsIndex = 0;
                }
            } while (PeopleStoreByName.MoveNext());

            if (Ctr != PeopleStore.Count)
            {
                Console.WriteLine("Failed! Read {0}, expected {1}", Ctr * 4, PeopleStore.Count * 4);
            }
            else
            {
                Console.WriteLine("Read {0} items.", Ctr * 4);
            }
        }
コード例 #7
0
        void Populate()
        {
            int ZipCodeCtr = 5000;

            CacheRecord[] BatchedRecords = new CacheRecord[BatchCount];
            int           BatchedIndex   = 0;

            for (int i = 0; i < MaxCount; i++)
            {
                int     aid  = (int)AddressStore.GetNextSequence();
                Address addr = new Address()
                {
                    AddressID = aid,
                    Key       = new AddressKey()
                    {
                        Street  = string.Format("143{0} LoveLane", aid),
                        City    = "Fremont",
                        Country = "USA",
                        State   = "California",
                        ZipCode = ZipCodeCtr.ToString()
                    }
                };
                int    pid = (int)PeopleStore.GetNextSequence();
                Person p   = new Person()
                {
                    PersonID  = pid,
                    AddressID = addr.AddressID,
                    Key       = new PersonKey()
                    {
                        FirstName = string.Format("Joe{0}", pid),
                        LastName  = string.Format("Peter{0}", pid)
                    },
                    PhoneNumber = "510-555-9999"
                };
                BatchedRecords[BatchedIndex++] = new CacheRecord()
                {
                    p       = p,
                    pKey    = p.Key,
                    addr    = addr,
                    addrKey = addr.Key
                };
                if (BatchedIndex == BatchCount)
                {
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        AddressStore.Add(BatchedRecords[i2].addr.AddressID,
                                         BatchedRecords[i2].addr);
                    }
                    AddressStore.Flush();
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        PeopleStore.Add(BatchedRecords[i2].p.PersonID,
                                        BatchedRecords[i2].p);
                    }
                    PeopleStore.Flush();
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        PeopleStoreByName.Add(BatchedRecords[i2].p.Key,
                                              BatchedRecords[i2].p.PersonID);
                    }
                    PeopleStoreByName.Flush();
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        AddressStoreByAddress.Add(BatchedRecords[i2].addr.Key,
                                                  BatchedRecords[i2].addr.AddressID);
                    }
                    AddressStoreByAddress.Flush();
                    if (i % 500 == 0)
                    {
                        ZipCodeCtr++;
                    }
                    BatchedIndex = 0;
                }
            }
            if (BatchedIndex > 0)
            {
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    AddressStore.Add(BatchedRecords[i2].addr.AddressID,
                                     BatchedRecords[i2].addr);
                }
                AddressStore.Flush();
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    PeopleStore.Add(BatchedRecords[i2].p.PersonID,
                                    BatchedRecords[i2].p);
                }
                PeopleStore.Flush();
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    PeopleStoreByName.Add(BatchedRecords[i2].p.Key,
                                          BatchedRecords[i2].p.PersonID);
                }
                PeopleStoreByName.Flush();
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    AddressStoreByAddress.Add(BatchedRecords[i2].addr.Key,
                                              BatchedRecords[i2].addr.AddressID);
                }
                AddressStoreByAddress.Flush();
            }
        }