Пример #1
0
 private void buttonMoveLastPage_Click(object sender, EventArgs e)
 {
     PeopleStore.MoveLast();
     GoPreviousPage(1);
     PeopleStore.MoveNext();
     DisplayPage();
 }
Пример #2
0
        public static void ImportPeople()
        {
            var json   = File.ReadAllText("../../../datasets/persons.json");
            var people = JsonConvert.DeserializeObject <IEnumerable <PersonDto> >(json);

            PeopleStore.AddPeople(people);
        }
Пример #3
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();
        }
Пример #4
0
        public void PopulateReadAllDeleteItems_Test()
        {
            // set default directory ahead of LogLevel
            Sop.Log.Logger.DefaultLogDirectory = "c:\\SopBin";
            //Sop.Log.Logger.Instance.LogLevel = Sop.Log.LogLevels.Verbose;
            //**
            IStoreFactory sf = new StoreFactory();

            PeopleStore       = sf.GetPersistentValue <long, Person>(Server.SystemFile.Store, "People");
            PeopleStoreByName = sf.GetPersistentKey <PersonKey, long>(Server.SystemFile.Store, "PeopleByName", new PersonComparer());

            // repeat Populate, Read all, Delete each Item routines: iterate for n times...
            const int iterationCount = 6;

            for (int i = 0; i < iterationCount; i++)
            {
                Populate();
                ReadAll();
                if (i % 2 == 0)
                {
                    DeleteEachItem();
                }
                else
                {
                    PeopleStore.Delete();
                    PeopleStoreByName.Delete();
                }
                Assert.IsTrue(PeopleStore.Count == 0, "Expected 0 elements but found {0}", PeopleStore.Count);
            }
        }
Пример #5
0
        void UpdateReadAll()
        {
            // update some people's blobs...
            for (int i = 100; i < 5000; i++)
            {
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", i),
                    LastName  = string.Format("Peter{0}", i)
                };
                var blob = new PersonBlob
                {
                    Blob = new byte[PersonBlob.BlobAvgSize + 100]
                };
                blob.Blob[2]   = (byte)i;
                PeopleStore[p] = blob;
            }
            PeopleStore.Transaction.Commit();

            // now, read them all..
            PeopleStore.MoveFirst();
            PeopleStore.HintBatchCount = 103;
            var pk  = new PersonBlob[BatchCount];
            int Ctr = 0;

            do
            {
                Ctr++;
                var blob = PeopleStore.CurrentValue;
            } while (PeopleStore.MoveNext());
            Console.WriteLine("Processed {0} records.", Ctr);
        }
Пример #6
0
 private void buttonMoveNextPage_Click(object sender, EventArgs e)
 {
     if (!PeopleStore.EndOfTree())
     {
         DisplayPage();
     }
 }
Пример #7
0
        void ReadAll()
        {
            PeopleStoreByName.MoveFirst();
            PersonKey pk;
            int       Ctr = 0;

            long[] Pids          = new long[1000];
            int    i             = 0;
            bool   personMissing = false;

            do
            {
                Ctr++;
                pk = PeopleStoreByName.CurrentKey;
                long PersonID = PeopleStoreByName.CurrentValue;
                Pids[i++] = PersonID;
                if (i == 1000)
                {
                    //** query a thousand people... batching like this is optimal use of SOP container...
                    QueryResult <long>[] People;
                    foreach (var pid in Pids)
                    {
                        if (!PeopleStore.Search(pid))
                        {
                            personMissing = true;
                            Assert.Fail("Person with ID {0} not found.", pid);
                        }
                    }
                    i = 0;
                }
            } while (PeopleStoreByName.MoveNext());
            if (i > 0)
            {
                QueryResult <long>[] People;
                long[] d = new long[i];
                Array.Copy(Pids, 0, d, 0, i);
                foreach (var l in d)
                {
                    if (!PeopleStore.Search(l))
                    {
                        personMissing = true;
                        Assert.Fail("Person with ID {0} not found.", l);
                    }
                }
            }
            if (personMissing)
            {
                Assert.Fail("Failed! Mising person detected.");
                return;
            }
            if (Ctr != PeopleStore.Count)
            {
                Assert.Fail("Failed! Read {0}, expected {1}", Ctr, PeopleStore.Count);
            }
            else
            {
                Console.WriteLine("Read {0} items.", Ctr);
            }
        }
Пример #8
0
        void Populate()
        {
            int ZipCodeCtr = 5000;

            Person[] NewPeople         = new Person[1000];
            int      NewPeopleIndex    = 0;
            bool     oneTimeUpdateRead = true;

            for (int i = 0; i < MaxCount; i++)
            {
                int    pid = GetNextSequence();
                Person p   = new Person()
                {
                    PersonID = pid,
                    Key      = new PersonKey()
                    {
                        FirstName = string.Format("Joe{0}", pid),
                        LastName  = string.Format("Peter{0}", pid)
                    },
                    PhoneNumber = "510-555-9999"
                };
                PeopleStore.Add(p.PersonID, p);
                NewPeople[NewPeopleIndex++] = p;
                //** do inserts on People Store By Name every batch of 1000 records
                //** to minimize disk I/O head jumps, causing more optimal insertion times...
                if (NewPeopleIndex == 1000)
                {
                    foreach (Person np in NewPeople)
                    {
                        PeopleStoreByName.Add(np.Key, np.PersonID);
                    }
                    NewPeopleIndex = 0;
                }
                //** NOTE: SOP supports very large transactions.
                //** In this case we've set it to commit every x00,000 insertions on two tables.
                //** Each one of these operations is a high speed operation and requires fairly reasonable resource footprint
                if (i > 0 && i % TransactionSize == 0)
                {
                    if (NewPeopleIndex > 0)
                    {
                        for (int i2 = 0; i2 < NewPeopleIndex; i2++)
                        {
                            Person np = NewPeople[i2];
                            PeopleStoreByName.Add(np.Key, np.PersonID);
                        }
                        NewPeopleIndex = 0;
                    }
                    ZipCodeCtr++;
                }
            }
            if (NewPeopleIndex > 0)
            {
                for (int i2 = 0; i2 < NewPeopleIndex; i2++)
                {
                    Person np = NewPeople[i2];
                    PeopleStoreByName.Add(np.Key, np.PersonID);
                }
            }
        }
Пример #9
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     BayWind.Person p = GetSelectedPerson();
     if (p != null)
     {
         PeopleStore.Remove(p.GetKey());
         GoPreviousPage();
         DisplayPage();
     }
 }
Пример #10
0
        void Populate()
        {
            int ZipCodeCtr = 5000;

            Person[] PeopleBuffer      = new Person[BatchCount];
            int      PeopleBufferIndex = 0;

            for (int i = 0; i < MaxCount; i++)
            {
                int    pid = (int)PeopleStore.GetNextSequence();
                Person p   = new Person()
                {
                    PersonID = pid,
                    Key      = new PersonKey()
                    {
                        FirstName = string.Format("Joe{0}", pid),
                        LastName  = string.Format("Peter{0}", pid)
                    },
                    PhoneNumber = "510-555-9999"
                };
                PeopleStore.Add(p.PersonID, p);
                PeopleBuffer[PeopleBufferIndex++] = p;

                //** Insert to PeopleStoreByName every batch of BatchCount People
                //** This allows optimal insertion across two tables as low level File pointer jumps are minimized
                if (PeopleBufferIndex == BatchCount)
                {
                    PeopleStore.Flush();
                    foreach (Person p2 in PeopleBuffer)
                    {
                        PeopleStoreByName.Add(p2.Key, p2.PersonID);
                    }
                    PeopleStoreByName.Flush();
                    PeopleBufferIndex = 0;
                }
                if (i % 500 == 0)
                {
                    ZipCodeCtr++;
                }
            }
            if (PeopleBufferIndex > 0)
            {
                PeopleStore.Flush();
                foreach (Person p2 in PeopleBuffer)
                {
                    PeopleStoreByName.Add(p2.Key, p2.PersonID);
                }
                PeopleStoreByName.Flush();
            }
            else
            {
                PeopleStore.Flush();
                PeopleStoreByName.Flush();
            }
        }
Пример #11
0
 private void buttonSearch_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(textBoxFirstName.Text))
     {
         PeopleStore.Search(new BayWind.PersonKey()
         {
             FirstName = textBoxFirstName.Text, LastName = textBoxLastName.Text
         });
         DisplayPage();
     }
 }
Пример #12
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            MvcApplication.PeopleStore = new PeopleStore();
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",                    // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                );
        }
Пример #13
0
        void ReadAll()
        {
            // nullify some people's blobs...
            for (int i = 100; i < 5000; i++)
            {
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", i),
                    LastName  = string.Format("Peter{0}", i)
                };
                PeopleStore[p] = null;
            }
            Server.CycleTransaction();
            // update nullified people's blobs...
            for (int i = 100; i < 5000; i++)
            {
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", i),
                    LastName  = string.Format("Peter{0}", i)
                };
                var blob = new PersonBlob
                {
                    Blob = new byte[PersonBlob.BlobAvgSize + 7000]
                };
                blob.Blob[2]   = (byte)i;
                PeopleStore[p] = blob;
            }
            PeopleStore.Transaction.Commit();

            var personBatch = new Person[1000];
            int index       = 0;
            int Ctr         = 0;

            for (int i = 0; i < MaxCount; i++)
            {
                Ctr++;
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", i),
                    LastName  = string.Format("Peter{0}", i)
                };
                personBatch[index++] = p;
                if (index >= personBatch.Length)
                {
                    QueryResult <Person>[] r;
                    PeopleStore.Query(QueryExpression <Person> .Package(personBatch), out r);
                    index = 0;
                }
            }
            Console.WriteLine("Processed {0} records.", Ctr);
        }
Пример #14
0
        public PeopleListingViewModel(PeopleStore peopleStore, INavigationService addPersonNavigationService)
        {
            _peopleStore = peopleStore;

            AddPersonCommand = new NavigateCommand(addPersonNavigationService);
            _people          = new ObservableCollection <PersonViewModel>();

            _people.Add(new PersonViewModel("SingletonSean"));
            _people.Add(new PersonViewModel("Mary"));
            _people.Add(new PersonViewModel("Joe"));

            _peopleStore.PersonAdded += OnPersonAdded;
        }
Пример #15
0
        void ReadAll()
        {
            PeopleStore.MoveFirst();
            PeopleStore.HintBatchCount = 103;
            var pk  = new PersonBlob[BatchCount];
            int Ctr = 0;

            do
            {
                Ctr++;
                var blob = PeopleStore.CurrentValue;
            } while (PeopleStore.MoveNext());
            Console.WriteLine("Processed {0} records.", Ctr);
        }
Пример #16
0
        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();
        }
Пример #17
0
        void Populate()
        {
            int ZipCodeCtr = 5000;

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

            for (int i = 0; i < MaxCount; i++)
            {
                int    pid = (int)PeopleStore.GetNextSequence();
                Person p   = new Person()
                {
                    FirstName = string.Format("Joe{0}", pid),
                    LastName  = string.Format("Peter{0}", pid)
                };
                BatchedRecords[BatchedIndex] = new CacheRecord()
                {
                    p    = p,
                    blob = new PersonBlob
                    {
                        Blob = new byte[PersonBlob.BlobAvgSize]
                    }
                };
                BatchedRecords[BatchedIndex].blob.Blob[0] = 1;
                BatchedRecords[BatchedIndex].blob.Blob[5] = 54;
                BatchedIndex++;
                if (BatchedIndex == BatchCount)
                {
                    for (int i2 = 0; i2 < BatchedIndex; i2++)
                    {
                        PeopleStore.Add(BatchedRecords[i2].p, BatchedRecords[i2].blob);
                    }
                    PeopleStore.Flush();
                    if (i % 500 == 0)
                    {
                        ZipCodeCtr++;
                    }
                    BatchedIndex = 0;
                }
            }
            if (BatchedIndex > 0)
            {
                for (int i2 = 0; i2 < BatchedIndex; i2++)
                {
                    PeopleStore.Add(BatchedRecords[i2].p, BatchedRecords[i2].blob);
                }
                PeopleStore.Flush();
            }
        }
        void ReadAll()
        {
            var personBatch = new Person[1000];
            int index       = 0;
            int Ctr         = 0;

            for (int i = 0; i < MaxCount; i++)
            {
                Ctr++;
                var p = new Person()
                {
                    FirstName = string.Format("Joe{0}", Ctr),
                    LastName  = string.Format("Peter{0}", Ctr)
                };
                personBatch[index++] = p;
                if (index >= personBatch.Length)
                {
                    QueryResult <Person>[]   r;
                    QueryFilterFunc <object> filterFunction = (value) =>
                    {
                        return(((PersonBlob)value).Blob[5] == 54);
                    };
                    if (!PeopleStore.Query(QueryExpression <Person> .Package(personBatch, filterFunction), out r))
                    {
                        Console.WriteLine("Failed to read a batch!");
                    }
                    else
                    {
                        try
                        {
                            for (int x = 0; x < r.Length; x++)
                            {
                                if (!r[x].Found)
                                {
                                    Console.WriteLine("Failed to read Person {0}!", r[x].Key.FirstName);
                                }
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Failed to read a Person.");
                        }
                    }
                    index = 0;
                }
            }
            Console.WriteLine("Processed {0} records.", Ctr);
        }
Пример #19
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());
        }
Пример #20
0
        void ReadAll()
        {
            //** Set Sort Order to descending to retrieve in opposite key ordering
            PeopleStoreByName.SortOrder = SortOrderType.Descending;

            long[] PeopleBuffer      = new long[BatchCount];
            int    PeopleBufferIndex = 0;
            int    Ctr = 0;

            foreach (KeyValuePair <PersonKey, long> kvp in PeopleStoreByName)
            {
                Ctr++;
                long PersonID = kvp.Value;
                PeopleBuffer[PeopleBufferIndex++] = PersonID;
                if (PeopleBufferIndex == BatchCount)
                {
                    QueryResult <long>[] PeopleFound;
                    if (PeopleStore.Query(QueryExpression <long> .Package(PeopleBuffer), out PeopleFound))
                    {
                        for (int i = 0; i < PeopleBufferIndex; i++)
                        {
                            if (PeopleFound[i].Found)
                            {
                                Person p = (Person)PeopleFound[i].Value;
                            }
                        }
                    }
                    PeopleBufferIndex = 0;
                }
            }
            if (PeopleBufferIndex > 0)
            {
                QueryResult <long>[] PeopleFound;
                if (PeopleStore.Query(QueryExpression <long> .Package(PeopleBuffer), out PeopleFound))
                {
                    for (int i = 0; i < PeopleBufferIndex; i++)
                    {
                        if (PeopleFound[i].Found)
                        {
                            Person p = (Person)PeopleFound[i].Value;
                        }
                    }
                }
            }
        }
Пример #21
0
        void LoadData()
        {
            if (BayWind == null)
            {
                BayWind = new BayWind();
            }

            //** Create a Dictionary Factory
            Sop.StoreFactory StoreFactory = new Sop.StoreFactory();

            //** retrieve the Object Stores from BayWind DB...
            PeopleStore =
                StoreFactory.Get <BayWind.PersonKey, BayWind.Person>(BayWind.Server.SystemFile.Store, "People", new BayWind.PersonComparer());
            AddressStore =
                StoreFactory.Get <int, BayWind.Address>(BayWind.Server.SystemFile.Store, "Address");
            PeopleStore.MoveFirst();
            DisplayPage();
        }
Пример #22
0
 void GoPreviousPage(int PageCount)
 {
     for (int ctr = 0; !PeopleStore.EndOfTree() && ctr < PageCount; ctr++)
     {
         int i = 0;
         while (i < PageSize &&
                !PeopleStore.EndOfTree())
         {
             i++;
             if (!PeopleStore.MovePrevious())
             {
                 break;
             }
         }
     }
     if (PeopleStore.EndOfTree())
     {
         PeopleStore.MoveFirst();
     }
 }
Пример #23
0
        protected void Application_Start()
        {
            MvcApplication.PeopleStore = new PeopleStore();
            RouteTable.Routes.MapHubs();

            AreaRegistration.RegisterAllAreas();

            // Use LocalDB for Entity Framework by default
            // Database.DefaultConnectionFactory = new SqlConnectionFactory(@"Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            InitiGPIO();

            Thread threadSmartCard = new Thread(new ThreadStart(ThreadSmartCard));

            threadSmartCard.Start();

            return;
        }
Пример #24
0
        void DisplayPage()
        {
            BayWind.Person[] PeopleInPage = new BayWind.Person[PageSize];
            int i = 0;

            while (i < PeopleInPage.Length &&
                   !PeopleStore.EndOfTree())
            {
                PeopleInPage[i++] = PeopleStore.CurrentValue;
                if (!PeopleStore.MoveNext())
                {
                    break;
                }
            }
            if (PeopleStore.EndOfTree())
            {
                PeopleStore.MoveLast();
            }
            dataGridViewPeople.AutoGenerateColumns = true;
            dataGridViewPeople.DataSource          = PeopleInPage;
            textBoxCount.Text = PeopleStore.Count.ToString();
        }
Пример #25
0
        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());
        }
Пример #26
0
        //** read all the 5 million records
        void ReadAll()
        {
            PeopleStoreByName.MoveFirst();
            PeopleStoreByName.HintBatchCount = 303;
            PersonKey pk;
            int       Ctr = 0;

            long[] Pids          = new long[1000];
            int    i             = 0;
            bool   personMissing = false;

            do
            {
                Ctr++;
                pk = PeopleStoreByName.CurrentKey;
                long PersonID = PeopleStoreByName.CurrentValue;
                Pids[i++] = PersonID;
                if (i == 1000)
                {
                    //** query a thousand people... batching like this is optimal use of SOP container...
                    QueryResult <long>[] People;
                    if (PeopleStore.Query(QueryExpression <long> .Package(Pids), out People))
                    {
                        foreach (var p in People)
                        {
                            if (!p.Found)
                            {
                                personMissing = true;
                                Console.WriteLine("Person with ID {0} not found.", p.Key);
                            }
                        }
                    }
                    i = 0;
                }
            } while (PeopleStoreByName.MoveNext());
            if (i > 0)
            {
                QueryResult <long>[] People;
                long[] d = new long[i];
                Array.Copy(Pids, 0, d, 0, i);
                if (PeopleStore.Query(QueryExpression <long> .Package(d), out People))
                {
                    foreach (var p in People)
                    {
                        if (!p.Found)
                        {
                            personMissing = true;
                            Console.WriteLine("Person with ID {0} not found.", p.Key);
                        }
                    }
                }
            }
            if (personMissing)
            {
                Console.WriteLine("Failed! Mising person detected.");
                return;
            }
            if (Ctr != PeopleStore.Count)
            {
                Console.WriteLine("Failed! Read {0}, expected {1}", Ctr, PeopleStore.Count);
            }
            else
            {
                Console.WriteLine("Read {0} items.", Ctr);
            }
        }
Пример #27
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);
            }
        }
Пример #28
0
        void DeleteEachItem()
        {
            if (server.Transaction == null)
            {
                server.BeginTransaction();
            }

            PeopleStoreByName.MoveFirst();
            PeopleStoreByName.HintBatchCount = 303;
            PersonKey pk;
            int       Ctr = 0;

            long[] Pids          = new long[1000];
            int    i             = 0;
            bool   personMissing = false;

            do
            {
                Ctr++;
                pk = PeopleStoreByName.CurrentKey;
                long PersonID = PeopleStoreByName.CurrentValue;
                Pids[i++] = PersonID;
                if (i == 1000)
                {
                    //** query a thousand people... batching like this is optimal use of SOP container...
                    QueryResult <long>[] People;
                    if (PeopleStore.Remove(QueryExpression <long> .Package(Pids), out People))
                    {
                        foreach (var p in People)
                        {
                            if (!p.Found)
                            {
                                personMissing = true;
                                Assert.Fail("Person with ID {0} not found.", p.Key);
                            }
                        }
                    }
                    else
                    {
                        Assert.Fail("Failed to Remove a 1,000 people starting with PID {0}.", Pids[0]);
                    }
                    i = 0;
                }
            } while (PeopleStoreByName.MoveNext());
            if (i > 0)
            {
                QueryResult <long>[] People;
                long[] d = new long[i];
                Array.Copy(Pids, 0, d, 0, i);
                if (PeopleStore.Remove(QueryExpression <long> .Package(d), out People))
                {
                    foreach (var p in People)
                    {
                        if (!p.Found)
                        {
                            personMissing = true;
                            Assert.Fail("Person with ID {0} not found.", p.Key);
                        }
                    }
                }
            }
            if (personMissing)
            {
                Assert.Fail("Failed! Mising person detected.");
                return;
            }
            if (Ctr != MaxCount)
            {
                Assert.Fail("Failed! Deleted {0}, expected {1}", Ctr, MaxCount);
            }
            else
            {
                Console.WriteLine("Deleted {0} items on 2ndary store.", Ctr);
            }

            Ctr = 0;
            while (PeopleStoreByName.MoveFirst())
            {
                Ctr++;
                pk = PeopleStoreByName.CurrentKey;
                PeopleStoreByName.Remove();
            }
            Console.WriteLine("Deleted {0} items.", Ctr);
            server.Commit();
        }
Пример #29
0
 public AddPersonCommand(AddPersonViewModel addPersonViewModel, PeopleStore peopleStore, INavigationService navigationService)
 {
     _addPersonViewModel = addPersonViewModel;
     _peopleStore        = peopleStore;
     _navigationService  = navigationService;
 }
Пример #30
0
 private void buttonFirstPage_Click(object sender, EventArgs e)
 {
     PeopleStore.MoveFirst();
     DisplayPage();
 }