Esempio n. 1
0
        public void Remove(TestCandidate value)
        {
            OnCollectionChanged(EventArgs.Empty);
            int index = IndexOf(value);

            if (index == -1)
            {
                throw(new Exception("TestCandidate not found in collection."));
            }
            RemoveAt(index);
        }
Esempio n. 2
0
 public int IndexOf(TestCandidate value)
 {
     lock (this)
     {
         for (int x = 0; x < _count; x++)
         {
             if (_candidates[x].Equals(value))
             {
                 return(x);
             }
         }
         return(-1);
     }
 }
Esempio n. 3
0
 public int Add(TestCandidate value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         _count++;
         // Resize the array if the _count is greater than the length
         // of the array.
         if (_count > _candidates.GetUpperBound(0) + 1)
         {
             TestCandidate[] temp_candidates = new TestCandidate[_count * 2];
             Array.Copy(_candidates, temp_candidates, _count - 1);
             _candidates = temp_candidates;
         }
         _candidates[_count - 1] = value;
     }
     return(_count - 1);
 }
Esempio n. 4
0
 public void Insert(int index, TestCandidate value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         _count++;
         // Resize the array if the _count is greater than the length
         // of the array.
         if (_count > _candidates.GetUpperBound(0) + 1)
         {
             TestCandidate[] temp_candidates = new TestCandidate[_count * 2];
             Array.Copy(_candidates, temp_candidates, _count - 1);
             _candidates = temp_candidates;
         }
         for (int x = index + 1; x == _count - 2; x++)
         {
             _candidates[x] = _candidates[x - 1];
         }
         _candidates[index] = value;
     }
 }
Esempio n. 5
0
 public bool Contains(TestCandidate value)
 {
     return(IndexOf(value) != -1);
 }
Esempio n. 6
0
        public TestCandidateCollection BuildTestList(DojoTestList list)
        {
            DojoTestListJournalEntryManager    journal;
            DojoTestListJournalEntryCollection entries;
            DojoTestListJournalEntry           entry;
            DojoTestListJournalEntry           lastEntry;
            DojoTestListJournalEntryType       type;
            TestCandidate           candidate;
            TestCandidateCollection candidates;

            journal =
                new DojoTestListJournalEntryManager();

            // Get journal entries by testlist and be sure to sort by
            // member and create date. This will allow processing members
            // without nested loops.
            entries =
                journal.GetCollection("TestListID=" + list.ID.ToString(),
                                      "RankID, " +
                                      "LastName, " +
                                      "FirstName, " +
                                      "MemberID, " +
                                      "Member.CreateDate ASC",
                                      DojoTestListJournalEntryFlags.Member,
                                      DojoTestListJournalEntryFlags.MemberPrivateContact);

            if (entries.Count > 0)
            {
                candidates = new TestCandidateCollection();
                candidate  = new TestCandidate(entries[0].Member);
                lastEntry  = entries[0];
                type       = lastEntry.EntryType;

                for (int i = 0; i < entries.Count; i++)
                {
                    entry = entries[i];

                    // If the new entry's member does not match the
                    // last member, then check to see if the last
                    // member was left in the add state. If so, add
                    // the member to the candidates list.
                    // The candidate's last type becomes the status
                    if (candidate.Member.ID != entry.Member.ID)
                    {
                        candidate.LastEntry = lastEntry;
                        candidates.Add(candidate);
                        candidate = new TestCandidate(entry.Member);
                    }

                    lastEntry = entry;
                    type      = entry.EntryType;

                    // Enable memberAdd flag if the entry
                    // was added.
                    if (entry.EntryType.Eligible)
                    {
                        candidate.IsRemoved = false;
                        candidate.Eligibility.Add(entry);
                    }

                    // Disable memberAdd flag if the entry
                    // was removed.
                    if (entry.EntryType.Ineligible)
                    {
                        candidate.IsRemoved = true;
                        candidate.Eligibility.Add(entry);
                    }

                    if (entry.EntryType.CertificateRequest |
                        entry.EntryType.CertificatePending |
                        entry.EntryType.CertificateReceived)
                    {
                        candidate.Certification.Add(entry);
                    }
                }

                // Process Last Entry
                candidate.LastEntry = lastEntry;
                candidates.Add(candidate);
            }
            else
            {
                candidates = null;
            }

            return(candidates);
        }