예제 #1
0
        /// <summary>
        /// Makes a shallow copy of the current TestCandidateCollection.
        /// as the parent object.
        /// </summary>
        /// <returns>TestCandidateCollection</returns>
        public TestCandidateCollection Clone()
        {
            TestCandidateCollection clonedTestCandidate = new TestCandidateCollection(_count);

            lock (this)
            {
                foreach (TestCandidate item in this)
                {
                    clonedTestCandidate.Add(item);
                }
            }
            return(clonedTestCandidate);
        }
예제 #2
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);
        }