Пример #1
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.");
        }
Пример #2
0
        /// <summary>
        /// remove the currently selected member in the grid (either user or distributionlist) after confirming with the user
        /// </summary>
        private void buttonRemoveItem_Click(object sender, EventArgs e)
        {
            if (gridMembers.SelectedRows.Count < 1)
            {
                MessageBox.Show("You must first select a distribution list member to delete");
                return;
            }

            //the objectID and alias values will always be in the result set.
            string strMemberObjectID = gridMembers.SelectedRows[0].Cells["ObjectId"].Value.ToString();
            string strDisplayName    = gridMembers.SelectedRows[0].Cells["DisplayName"].Value.ToString();

            //verify with the user before deleting
            if (MessageBox.Show("Are you sure you want to delete the list member: " + strDisplayName + "?", "DELETE Confirmation",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                //the user changed their minds, bail out
                return;
            }

            DisableFormControls();

            //remove the call handler
            WebCallResult res = DistributionList.RemoveMember(GlobalItems.CurrentConnectionServer, DistributionListObjectId, strMemberObjectID);

            EnableFormControls();

            if (res.Success)
            {
                MessageBox.Show("Distribution List member removed");
                Logger.Log(string.Format("Distribution list member [{0}] objectId={1} removed.", strDisplayName, strMemberObjectID));

                //need to rebuild the list without the DL member we just deleted in it.
                LoadMembers();
            }
            else
            {
                MessageBox.Show("Failure removing distribution list member:" + res.ErrorText);
                Logger.Log(string.Format("Failed to remove distribution list member with display name={0} and objectId={1}.  Error={2}", strDisplayName, strMemberObjectID, res.ToString()));
            }
        }