예제 #1
0
        /// <summary>
        /// Get Member Info
        /// </summary>
        /// <param name="index">Index</param>
        /// <returns>Member Info</returns>
        public MemberInfo GetMemberInfo(int index)
        {
            if (index < 0 || index >= total || (total == 0))
            {
                Debug.PrintLine("MemberListModel.GetMemberInfo() called with index out of the range or when total == 0");

                // FIXME: Figure out the right exception to throw here
                throw new Exception("GetValue called when no items are present");
            }

            MemberInfo memberInfoReturn;

            if (memberInfos.Contains(index))
            {
                memberInfoReturn = (MemberInfo)memberInfos[index];
            }
            else
            {
                if (searchContext == null)
                {
                    // Somehow the searchContext was closed out prematurely
                    // FIXME: Figure out a better exception for when a searchContext is nulled out prematurely
                    throw new Exception("searchContext was closed too soon");
                }

                // Here's where the good stuff comes.  If we don't have it in our
                // hash table (and we didn't fail with a bad index earlier, that means
                // we need to go search for more data from the Domain Provider, store
                // the results into memberInfos and return the MemberInfo being asked
                // for.
                try
                {
                    MemberInfo[] newMemberList;
                    simws.FindSeekMembers(domainID, ref searchContext,
                                          index, iFolderUserSelector.NumOfMembersToReturnDefault,
                                          out newMemberList);
                    int currentIndex = index;
                    foreach (MemberInfo memberInfo in newMemberList)
                    {
                        if (memberFullNames.Contains(memberInfo.FullName))
                        {
                            // If the one we've stored has the same username (CN)
                            // then it's not really a duplicate.
                            string username = (string)memberFullNames[memberInfo.FullName];
                            if (!username.Equals(memberInfo.Name))
                            {
                                // We've found a duplicate
                                duplicateMembers[memberInfo.FullName] = 0;
                            }
                        }
                        else
                        {
                            memberFullNames[memberInfo.FullName] = memberInfo.Name;
                        }

                        memberInfos[currentIndex] = memberInfo;
                        currentIndex++;
                    }
                }
                catch (Exception e)
                {
                    Debug.PrintLine(String.Format("Exception thrown calling simws.FindSeekMembers(): {0}", e.Message));
                }

                memberInfoReturn = (MemberInfo)memberInfos[index];
            }

            if (memberInfoReturn == null)
            {
                throw new Exception("Could not find the specified member");
            }

            return(memberInfoReturn);
        }