Esempio n. 1
0
        /// <summary>
        /// Armed with the ObjectId of a distribution list (passed in via a public property to this form) this routine will
        /// get a list of members from Connection and display them in the grid on the form for review.
        /// </summary>
        private void LoadMembers()
        {
            //while we're loading members make sure the user can't try and edit anything
            DisableFormControls();

            gridMembers.DataSource = null;

            WebCallResult res;
            List <DistributionListMember> oMembers;

            res = DistributionList.GetMembersList(GlobalItems.CurrentConnectionServer, DistributionListObjectId, out oMembers);

            EnableFormControls();

            //if the list has no members fals is returned but the member list object will not be null - only bark an error here if it's null meaning
            //there was really a problem with the fetch.
            if (res.Success == false & oMembers == null)
            {
                MessageBox.Show("Failure fetching distribution list membership:" + res.ErrorText);
                //again, nothing can be done here without membership data so just exit the form.
                this.Close();
            }

            labelListCountValue.Text = string.Format("Members in list: {0}", oMembers.Count);

            //in a production application you'd want to rename columns to be neater and hide colums you didn't want folks to see and such -
            //here we just show everything returned.
            gridMembers.DataSource = oMembers;
            gridMembers.Refresh();
        }
Esempio n. 2
0
        public void DistributionList_MembershipEdit()
        {
            //Add a user to it.
            UserBase      oUser;
            WebCallResult res = UserBase.GetUser(out oUser, _connectionServer, "", "operator");

            Assert.IsTrue(res.Success, "Getting operator for new distribution list failed: " + res.ToString());

            res = _tempList.AddMemberUser(oUser.ObjectId);
            Assert.IsTrue(res.Success, "Adding operator user to new distribution list failed: " + res.ToString());

            //Add a list to it
            DistributionList oNewList;

            res = DistributionList.GetDistributionList(out oNewList, _connectionServer, "", "allvoicemailusers");
            Assert.IsTrue(res.Success, "Get AllVoiceMail users list failed: " + res.ToString());

            res = _tempList.AddMemberList(oNewList.ObjectId);
            Assert.IsTrue(res.Success, "Adding AllUsersDistribution list as a member to the new list failed: " + res.ToString());

            //get count - make sure it equals 2
            List <DistributionListMember> oMemberList;

            res = _tempList.GetMembersList(out oMemberList);
            Assert.IsTrue(res.Success, "Getting membership list from new distribution list failed: " + res.ToString());
            Assert.AreEqual(oMemberList.Count, 2, "Membership list fetch from new distribution list did not return 2 members as it should.");

            //remove both members from it - also exercise the DistributionListMember toString and DumpAll here
            foreach (DistributionListMember oMember in oMemberList)
            {
                Console.WriteLine(oMember.ToString());
                Console.WriteLine(oMember.DumpAllProps());
                res = _tempList.RemoveMember(oMember.ObjectId);

                Assert.IsTrue(res.Success, "Removal of member from new distribution list failed for:" + oMember);
            }

            //get count - make sure it equals 0
            res = _tempList.GetMembersList(out oMemberList);
            Assert.IsTrue(res.Success, "Failed getting members list:" + res);
            Assert.AreEqual(oMemberList.Count, 0, "After removal of members from the new distribution list the count of members reports more than 0.");
        }