Exemple #1
0
        public void GetDistributionListVoiceName_Test()
        {
            //use the same string for the alias and display name here
            String strWavName = "TempWAV_" + Guid.NewGuid().ToString();

            //create new list with GUID in the name to ensure uniqueness
            DistributionList oList;

            WebCallResult res = DistributionList.GetDistributionList(out oList, _connectionServer, "", "allvoicemailusers");

            Assert.IsTrue(res.Success, "Fetch of AllVoiceMailUsers list failed:" + res.ToString());
            Assert.AreNotEqual(oList, null, "Fetch of AllVoiceMailUsers list failed returning an empty list");

            //first, get from static method without voice name
            res = DistributionList.GetDistributionListVoiceName(_connectionServer, strWavName, oList.ObjectId);
            Assert.IsTrue(res.Success, "Static method fetch of voice name for allVoiceMailUsers failed:" + res.ToString());
            Assert.IsTrue(File.Exists(strWavName), "Static method voice name fetch did not produce a wav file as expected.");

            File.Delete(strWavName);

            //generate new wav name just to be save
            strWavName = "TempWAV_" + Guid.NewGuid().ToString();

            //now fetch from list instance
            res = oList.GetVoiceName(strWavName);

            Assert.IsTrue(res.Success, "Instance method voice name fetch failed:" + res.ToString());
            Assert.IsTrue(File.Exists(strWavName), "Instance method voice name fetch did not produce a wav file as expected.");

            //clean up the temporary WAV file name
            File.Delete(strWavName);
        }
Exemple #2
0
        //user wants to update one of the top level items for a user - they may have edited the first/last name, display name, alias or extension (any or all of them).
        //All the values will be sent over regardless of if they've changed - a more sophisticated "dirty flag" approach or the like is left as an exercize for reader.
        private void buttonUpdateItem_Click(object sender, EventArgs e)
        {
            DisableFormControls();

            ConnectionPropertyList oPropList = new ConnectionPropertyList();

            string strObjectID = gridUsers.SelectedRows[0].Cells["ObjectId"].Value.ToString();

            //the property names are case sensitive
            oPropList.Add("Alias", textUserAlias.Text);
            oPropList.Add("FirstName", textUserFirstName.Text);
            oPropList.Add("LastName", textUserLastName.Text);
            oPropList.Add("DisplayName", textUserDisplayName.Text);
            oPropList.Add("DtmfAccessId", textUserExtension.Text);

            //do the call to update the items via CUPI
            WebCallResult res = UserBase.UpdateUser(GlobalItems.CurrentConnectionServer, strObjectID, oPropList);

            EnableFormControls();

            if (res.Success)
            {
                MessageBox.Show("User updated");
                Logger.Log(string.Format("User updated:{0}\r\n{1}", strObjectID, oPropList));
                gridUsers.Refresh();
            }
            else
            {
                MessageBox.Show("User failed to update:" + res.ErrorText);
                Logger.Log(string.Format("User failed to update:{0}, error=[{1}]\r\n{2}", strObjectID, res.ErrorText, oPropList));

                //dump out all the results information send from the server for diag purposes
                Logger.Log(res.ToString());
            }
        }
Exemple #3
0
        public void DistributionList_TopLevel()
        {
            //call update with no edits - this should fail
            WebCallResult res = _tempList.Update();

            Assert.IsFalse(res.Success, "Call to update with no pending changes should fail");

            //Edit the list's name
            string strNewName = _tempList.DisplayName + "x";

            _tempList.DisplayName = strNewName;
            res = _tempList.Update();
            Assert.IsTrue(res.Success, "Call to update distribution list failed:" + res.ToString());

            res = _tempList.RefetchDistributionListData();
            Assert.IsTrue(res.Success, "Failed refetching list data:" + res);
            Assert.IsTrue(_tempList.DisplayName.Equals(strNewName), "Updated name did not match after refresh");

            _tempList.PartitionObjectId = "bogus";
            res = _tempList.Update();
            Assert.IsFalse(res.Success, "Setting invalid partition value did not fail:" + res);

            res = _tempList.SetVoiceNameToStreamFile("");
            Assert.IsFalse(res.Success, "Calling SetVoiceNameToStreamFile with empty ID did not fail");

            res = _tempList.SetVoiceName("CiscoUnityConnectionRestFunctions.dll", true);
            Assert.IsFalse(res.Success, "Attempting to apply an DLL as a voice name did not fail:" + res);
        }
        public void Greeting_Test()
        {
            Greeting oGreeting;

            WebCallResult res = CallHandler.GetCallHandler(out _callHandler, _connectionServer, "", "opening greeting");

            Assert.IsTrue(res.Success, "Failed to get opening greeting call handler");
            Assert.IsNotNull(_callHandler, "Null handler returned from search");

            //first, test getting a bogus greeting
            res = _callHandler.GetGreeting(GreetingTypes.Invalid, out oGreeting);
            Assert.IsFalse(res.Success, "GetGreeting should fail with an invalid greeting name");

            //get the alternate greeting rule and set it to play a new greeting we upload
            res = _callHandler.GetGreeting(GreetingTypes.Standard, out oGreeting);
            Assert.IsTrue(res.Success, "Failed fetching greeting rule:" + res.ToString());
            Assert.IsNotNull(oGreeting, "Null greeting returned from greeting fetch");

            oGreeting.ClearPendingChanges();

            //update a greeting with no pending changes should fail
            res = oGreeting.Update();
            Assert.IsFalse(res.Success, "Updating a greeting with no pending changes should fail");

            //iterate over all the greetings and dump their properties
            foreach (Greeting oGreetings in _callHandler.GetGreetings())
            {
                Console.WriteLine(oGreetings.ToString());
                Console.WriteLine(oGreetings.DumpAllProps());
            }
        }
        public void GreetingStream_Test()
        {
            Greeting oGreeting;

            //get the alternate greeting rule and set it to play a new greeting we upload
            WebCallResult res = _callHandler.GetGreeting(GreetingTypes.Standard, out oGreeting);

            Assert.IsTrue(res.Success, "Failed fetching greeting rule:" + res.ToString());
            Assert.IsNotNull(oGreeting, "Null greeting returned from greeting fetch");


            GreetingStreamFile oStream;

            //get specific greeting stream file back out
            res = oGreeting.GetGreetingStreamFile(11, out oStream);
            Assert.IsFalse(res.Success, "Invalid language code should fail");

            List <GreetingStreamFile> oStreams = oGreeting.GetGreetingStreamFiles();

            Assert.IsNotNull(oStreams, "Null list of stream files returned");
            Assert.IsTrue(oStreams.Count > 0, "Empty list of stream files returned.");

            //dump all greeting stream file props
            foreach (GreetingStreamFile oTemp in oStreams)
            {
                oStream = oTemp;
                Console.WriteLine(oTemp.ToString());
                Console.WriteLine(oTemp.DumpAllProps());
            }

            res = oStream.GetGreetingWavFile("tempout.wav");
            Assert.IsTrue(res.Success, "Failed fetching stream file from GreetingStreamFile object");
        }
Exemple #6
0
        public void AddEditDeleteCallHandler_TopLevelTest()
        {
            //call update with no edits - this should fail
            WebCallResult res = _tempHandler.Update();

            Assert.IsFalse(res.Success, "Call to update with no pending changes should fail");

            //Edit the handler's name
            _tempHandler.DisplayName   = _tempHandler.DisplayName + "x";
            _tempHandler.PrependDigits = "123";

            res = _tempHandler.Update();
            Assert.IsTrue(res.Success, "Call to update call handler failed:" + res.ToString());

            res = _tempHandler.RefetchCallHandlerData();
            Assert.IsTrue(res.Success, "Refetching handler data failed:" + res);
            Assert.IsTrue(_tempHandler.PrependDigits == "123", "Pepend digits value did not match after refetch:" + res);

            _tempHandler.DtmfAccessId = "____";
            res = _tempHandler.Update();
            Assert.IsFalse(res.Success, "Setting call handler to illegal primary extension did not fail:" + res);

            _tempHandler.ClearPendingChanges();

            _tempHandler.AfterMessageAction                = ActionTypes.GoTo;
            _tempHandler.AfterMessageTargetConversation    = ConversationNames.PHTransfer;
            _tempHandler.AfterMessageTargetHandlerObjectId = _tempHandler.ObjectId;
            res = _tempHandler.Update();

            Assert.IsTrue(res.Success, "Failed setting after message action to loop back to self:" + res);
        }
Exemple #7
0
        /// <summary>
        /// Allow the uer to select a subscriber to add to the distribution list as a member - you'd follow the same procedure to add a list just use
        /// the AddMemberPublicList function off the DistributionList class instead of the AddMemberUser.
        /// </summary>
        private void buttonAddUser_Click(object sender, EventArgs e)
        {
            using (FormFindUser oForm = new FormFindUser())
            {
                oForm.ShowDialog();
                if (oForm.DialogResult == DialogResult.Cancel)
                {
                    //user canceled - nothing to do here
                    return;
                }

                WebCallResult res = DistributionList.AddMemberUser(GlobalItems.CurrentConnectionServer,
                                                                   DistributionListObjectId,
                                                                   oForm.UserObjectId);

                //if the user added ok force the membership grid to update to reflect that - otherwise give the user the error message and exit.
                if (res.Success)
                {
                    MessageBox.Show("User added");
                    LoadMembers();
                }
                else
                {
                    //note, adding a duplicate member will result in an error.
                    MessageBox.Show("Error adding user:" + res.ToString());
                }
            }
        }
        public void ScheduleDetailTests()
        {
            //cover all lists on the server - there must be at least one
            List <Schedule> oSchedules;
            WebCallResult   res = Schedule.GetSchedules(_connectionServer, out oSchedules);

            Assert.IsTrue(res.Success, "Failed to fetch schedule list:" + res.ToString());

            string strScheduleObjectId = "";

            foreach (var oSchedule in oSchedules)
            {
                if (oSchedule.ScheduleDetails().Count > 0)
                {
                    strScheduleObjectId = oSchedule.ObjectId;
                    break;
                }
            }

            Assert.IsFalse(string.IsNullOrEmpty(strScheduleObjectId), "Failed to find a schedule with at least one detail element");

            List <ScheduleDetail> oScheduleDetails;
            string strScheduleDetailObjectId = "";

            res = ScheduleDetail.GetScheduleDetails(_connectionServer, strScheduleObjectId, out oScheduleDetails);
            Assert.IsTrue(res.Success, "Failed to fetch schedule details from schedule:" + res);

            foreach (var oDetail in oScheduleDetails)
            {
                Console.WriteLine(oDetail.ToString());
                Console.WriteLine(oDetail.DumpAllProps());

                oDetail.IsScheduleDetailActive(DateTime.Now, true);
                oDetail.IsScheduleDetailActive(DateTime.Now, false);

                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(1), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(2), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(3), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(4), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(5), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(6), false);
                strScheduleDetailObjectId = oDetail.ObjectId;
            }

            res = ScheduleDetail.GetScheduleDetails(null, strScheduleObjectId, out oScheduleDetails);
            Assert.IsFalse(res.Success, "Schedule detail fetch with null Connection server should fail");

            try
            {
                ScheduleDetail oScheduleDetail = new ScheduleDetail(_connectionServer, strScheduleObjectId,
                                                                    strScheduleDetailObjectId);
                Console.WriteLine(oScheduleDetail);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false, "Failed to create a ScheduleDetial instance with valid objectIds:" + ex);
            }
        }
        private Port HelperGetPort()
        {
            List <Port> oPorts;

            WebCallResult res = Port.GetPorts(_connectionServer, out oPorts);

            Assert.IsTrue(res.Success, "Failed to fetch ports:" + res.ToString());
            Assert.IsTrue(oPorts.Count > 0, "No ports configured");
            return(oPorts[0]);
        }
Exemple #10
0
        public void GetCallHandlers_FetchTest()
        {
            List <CallHandler> oHandlerList;
            CallHandler        oHoldHandler = null;

            //limit the fetch to the first 3 handlers to be sure this passes even on a default install
            string[] pClauses = { "rowsPerPage=3" };

            WebCallResult res = CallHandler.GetCallHandlers(_connectionServer, out oHandlerList, 1, 2, pClauses);

            Assert.IsTrue(res.Success, "Fetching of top three call handlers failed: " + res);
            Assert.AreEqual(oHandlerList.Count, 3, "Fetching of the top three call handlers returned a different number of handlers: " + res.ToString());

            //exercise the ToString and DumpAllProperties as part of this test as well
            foreach (CallHandler oHandler in oHandlerList)
            {
                Console.WriteLine(oHandler.ToString());
                Console.WriteLine(oHandler.DumpAllProps());
                oHoldHandler = oHandler;
            }

            res = CallHandler.GetCallHandlers(_connectionServer, out oHandlerList, 1, 1, null);
            Assert.IsTrue(res.Success, "Failed to fetch call handlers:" + res);
            Assert.IsTrue(oHandlerList.Count == 1, "Failed to return single call handler");

            res = CallHandler.GetCallHandlers(_connectionServer, out oHandlerList, 1, 1, "query=(ObjectId is bogus)");
            Assert.IsTrue(res.Success, "fetching handlers with invalid query should not fail:" + res);
            Assert.IsTrue(oHandlerList.Count == 0, "Invalid query string should return an empty handler list:" + oHandlerList.Count);

            //exercise the menu entry action descriptions
            MenuEntry oMenu;

            res = oHoldHandler.GetMenuEntry("0", out oMenu);
            Assert.IsTrue(res.Success, "Fetching of 0 menu entry key failed: " + res.ToString());

            Console.WriteLine(_connectionServer.GetActionDescription(oMenu.Action, oMenu.TargetConversation, oMenu.TargetHandlerObjectId));

            res = oHoldHandler.GetMenuEntry("*", out oMenu);
            Assert.IsTrue(res.Success, "Fetching of * menu entry key failed: " + res.ToString());

            Console.WriteLine(_connectionServer.GetActionDescription(oMenu.Action, oMenu.TargetConversation, oMenu.TargetHandlerObjectId));
        }
Exemple #11
0
        public new static void MyClassInitialize(TestContext testContext)
        {
            BaseIntegrationTests.MyClassInitialize(testContext);

            //create new handler with GUID in the name to ensure uniqueness
            String strName = "Tenant" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8);

            WebCallResult res = Tenant.AddTenant(_connectionServer, strName, strName + ".org", strName, "", "", out _tempTenant);

            Assert.IsTrue(res.Success, "Failed creating temporary tenant:" + res.ToString());
        }
        public new static void MyClassInitialize(TestContext testContext)
        {
            BaseIntegrationTests.MyClassInitialize(testContext);

            //create new contact with GUID in the name to ensure uniqueness
            String strName = "TempContact_" + Guid.NewGuid().ToString().Replace("-", "");

            WebCallResult res = Contact.AddContact(_connectionServer, "systemcontacttemplate", strName, "", "", strName, null, out _tempContact);

            Assert.IsTrue(res.Success, "Failed creating temporary contact:" + res.ToString());
        }
Exemple #13
0
        public new static void MyClassInitialize(TestContext testContext)
        {
            BaseIntegrationTests.MyClassInitialize(testContext);

            //create new handler with GUID in the name to ensure uniqueness
            String strName = "TempRule_" + Guid.NewGuid().ToString().Replace("-", "");

            WebCallResult res = RoutingRule.AddRoutingRule(_connectionServer, strName, null, out _tempRule);

            Assert.IsTrue(res.Success, "Failed creating temporary routing rule:" + res.ToString());
        }
        public void GetTimeZone_Success()
        {
            var timeZones = new TimeZones(_connectionServer);

            ConnectionTimeZone oTemp;

            WebCallResult res = timeZones.GetTimeZone(227, out oTemp);

            Assert.IsTrue(res.Success, "Failed to fetch 227 time zone:" + res.ToString());

            Console.WriteLine(oTemp.ToString());
        }
Exemple #15
0
        /// <summary>
        /// grab all the messages for a the UserObjectID passed in.
        /// </summary>
        private void FormUserMessages_Load(object sender, EventArgs e)
        {
            List <UserMessage> oMessages;

            WebCallResult res = UserMessage.GetMessages(GlobalItems.CurrentConnectionServer, UserObjectId, out oMessages);

            if (res.Success == false)
            {
                MessageBox.Show("Failure fetching messages:" + res.ToString());
            }

            this.gridMessages.DataSource = oMessages;
        }
Exemple #16
0
        public new static void MyClassInitialize(TestContext testContext)
        {
            BaseIntegrationTests.MyClassInitialize(testContext);

            //create new list with GUID in the name to ensure uniqueness
            String strUserAlias = "TempUserMbx_" + Guid.NewGuid().ToString().Replace("-", "");

            //generate a random number and tack it onto the end of some zeros so we're sure to avoid any legit numbers on the system.
            Random random       = new Random();
            int    iExtPostfix  = random.Next(100000, 999999);
            string strExtension = "000000" + iExtPostfix.ToString();

            //use a bogus extension number that's legal but non dialable to avoid conflicts
            WebCallResult res = UserBase.AddUser(_connectionServer, "voicemailusertemplate", strUserAlias, strExtension, null, out _tempUser);

            Assert.IsTrue(res.Success, "Failed creating temporary user:" + res.ToString());
        }
Exemple #17
0
        public new static void MyClassInitialize(TestContext testContext)
        {
            BaseIntegrationTests.MyClassInitialize(testContext);

            //grab the first template - should always be one and it doesn't matter which
            List <CallHandlerTemplate> oTemplates;
            WebCallResult res = CallHandlerTemplate.GetCallHandlerTemplates(_connectionServer, out oTemplates);

            if (res.Success == false || oTemplates == null || oTemplates.Count == 0)
            {
                Assert.Fail("Could not fetch call handler templates:" + res);
            }

            //create new handler with GUID in the name to ensure uniqueness
            String strName = "TempHandler_" + Guid.NewGuid().ToString().Replace("-", "");

            res = CallHandler.AddCallHandler(_connectionServer, oTemplates[0].ObjectId, strName, "", null, out _tempHandler);
            Assert.IsTrue(res.Success, "Failed creating temporary callhandler:" + res.ToString());
        }
Exemple #18
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.");
        }
Exemple #19
0
        /// <summary>
        /// Handle the "button" clicks for the view and pin reset items in the grid control
        /// </summary>
        protected void gridUsers_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            // Retrieve the row index stored in the
            // CommandArgument property.
            int index = Convert.ToInt32(e.CommandArgument);

            // Retrieve the row that contains the button
            // from the Rows collection.
            GridViewRow row = gridUsers.Rows[index];

            //clear the currently selected user from the session variable if it exists
            if (Session["CurrentUser"] != null)
            {
                Session.Remove("CurrentUser");
            }

            //fetch the user based on their ObjectId - we'll then stick this user in the session so we can perform operations
            //on it later.
            UserBase oUser;

            WebCallResult res = Cisco.UnityConnection.RestFunctions.UserBase.GetUser(out oUser, _connectionServer, row.Cells[(int)GridColumnNames.ObjectId].Text);

            if (res.Success == false)
            {
                labelStatus.Text = "Failed to fetch selected user:"******"SelectedUser", oUser);

            //redirect to the appropriate page based on which link/button was clicked
            if (e.CommandName == "ViewPin")
            {
                Response.Redirect("~/ViewPinDetails.aspx");
            }

            if (e.CommandName == "ResetPin")
            {
                Response.Redirect("~/ResetPin.aspx");
            }
        }
Exemple #20
0
        /// <summary>
        /// Just dump the credential information we have for the user's PIN to a text string and show it in a message box - nothing
        /// fancy here.
        /// </summary>
        private void buttonShowPin_Click(object sender, EventArgs e)
        {
            if (gridUsers.SelectedRows.Count < 1)
            {
                MessageBox.Show("You must first select a user to show PIN credentials information for.");
                return;
            }

            string strObjectID = gridUsers.SelectedRows[0].Cells["ObjectId"].Value.ToString();

            UserBase oUser;

            WebCallResult res = UserBase.GetUser(out oUser, GlobalItems.CurrentConnectionServer, strObjectID);

            if (res.Success == false)
            {
                MessageBox.Show("Failed to fetch selected user:"******"PIN Credential info:" + Environment.NewLine + oUser.Pin().DumpAllProps());
        }
        public void ContactVoiceNameTests()
        {
            //Voice name tests
            WebCallResult res = _tempContact.GetVoiceName("temp.wav");

            Assert.IsFalse(res.Success, "Newly created contact should have no voice name but the fetch call did not fail");

            res = _tempContact.SetVoiceName("Dummy.wav", true);
            Assert.IsTrue(res.Success, "Updating contact voice name failed:" + res.ToString());

            res = _tempContact.RefetchContactData();
            Assert.IsTrue(res.Success, "Failed to refetch contact:" + res);

            res = _tempContact.GetVoiceName("temp.wav");
            Assert.IsTrue(res.Success, "Failed to fetch voice name from contact after updating it:" + res);

            res = Contact.GetContact(out _tempContact, _connectionServer, "", _tempContact.Alias);
            Assert.IsTrue(res.Success, "Failed to refetch contact with alias:" + res);

            res = _tempContact.SetVoiceNameToStreamFile("");
            Assert.IsFalse(res.Success, "Call to set voice name to streamFile with empty stream file name did not fail");
        }
        /// <summary>
        ///user wants to update one of the top level items for a list - they may have edited the display name and/or extension.
        ///All the values will be sent over regardless of if they've changed - a more sophisticated "dirty flag" approach or the like is left as an exercize for the reader.
        /// </summary>
        private void buttonUpdateItem_Click(object sender, EventArgs e)
        {
            DisableFormControls();

            ConnectionPropertyList oPropList = new ConnectionPropertyList();

            string strObjectID = gridLists.SelectedRows[0].Cells["ObjectId"].Value.ToString();

            //the property names are case sensitive
            oPropList.Add("DisplayName", textListDisplayName.Text);

            //currently CUPI does not like you setting DtmfAccessId to blank - even though for lists this is legal, so for now screen this out
            if (textListExtension.Text.Length > 0)
            {
                oPropList.Add("DtmfAccessId", textListExtension.Text);
            }

            //do the call to update the items via CUPI
            WebCallResult res = DistributionList.UpdateDistributionList(GlobalItems.CurrentConnectionServer, strObjectID, oPropList);

            EnableFormControls();

            if (res.Success)
            {
                MessageBox.Show("List updated");
                Logger.Log(string.Format("List updated:{0}\r\n{1}", strObjectID, oPropList));
                gridLists.Refresh();
            }
            else
            {
                MessageBox.Show("List failed to update:" + res.ErrorText);
                Logger.Log(string.Format("List failed to update:{0}, error=[{1}]\r\n{2}", strObjectID, res.ErrorText, oPropList));

                //dump out all the results information send from the server
                Logger.Log(res.ToString());
            }
        }
        public void ResetPassword_Success()
        {
            WebCallResult res = _tempUser.ResetPassword("as!aAsdfui09au", false, false, false, true);

            Assert.IsTrue(res.Success, "Resetting user password failed:" + res.ToString());
        }
Exemple #24
0
        public void DistributionList_VoiceName()
        {
            //try to download voice name- this should fail
            WebCallResult res = _tempList.GetVoiceName(@"c:\temp.wav");

            Assert.IsFalse(res.Success, "Empty voice name fetch should return false for newly created list");

            //upload an invalid wav file
            res = _tempList.SetVoiceName("wavcopy.exe", true);
            Assert.IsFalse(res.Success, "Updating invalid voice wav file was not caught");

            //upload a voice name to the list
            res = _tempList.SetVoiceName("Dummy.wav", true);
            Assert.IsTrue(res.Success, "Updating voice name on new distribution list failed: " + res.ToString());

            //upload real name
            res = _tempList.SetVoiceName("temp.wav");
            Assert.IsTrue(res.Success, "Failed uploading voice name:" + res);

            string strFileName = Guid.NewGuid().ToString() + ".wav";

            res = _tempList.GetVoiceName(strFileName);
            Assert.IsTrue(res.Success, "Failed to donwload voice name just uploaded:" + res);
            Assert.IsTrue(File.Exists(strFileName), "Voice name just downloaded does not exist on hard drive:" + strFileName);

            try
            {
                File.Delete(strFileName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to delete temporary file:" + ex);
            }
        }
        /// <summary>
        /// User wishes to add a new distribution list to Connection - this routine shows a modal form for gathering the name, alias and optionally
        /// an extension number and then adds the new list and shows it in the grid by itself.
        /// </summary>
        private void buttonAddItem_Click(object sender, EventArgs e)
        {
            using (FormNewDistributionListInfo oForm = new FormNewDistributionListInfo())
            {
                if (oForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                //the call can take a minute to return - disable controls on the form to indicate we're busy.
                DisableFormControls();

                WebCallResult res = DistributionList.AddDistributionList(GlobalItems.CurrentConnectionServer,
                                                                         oForm.DisplayName,
                                                                         oForm.Alias,
                                                                         oForm.Extension,
                                                                         null);
                EnableFormControls();

                if (res.Success)
                {
                    //force a refresh of the grid and then select the list you just added - the ObjectId of the newly added list is returned
                    //in the WebCallResult structure as the ReturnObjectID.
                    _currentPage = 0;
                    UpdateDataDisplay(res.ReturnedObjectId);
                    Logger.Log(string.Format("New distribution list added:{0},{1}", oForm.DisplayName, res.ReturnedObjectId));
                }
                else
                {
                    Logger.Log(string.Format(string.Format("New distribution list add failed:{0}\r\n{1}", oForm.DisplayName, res.ToString())));
                    MessageBox.Show(String.Format("Error adding new distribution list: {0}\r\nresponse from CUPI: {1}", res.ErrorText, res.ResponseText));
                }
            }
        }
        public void ScheduleFetchAndCreateTests()
        {
            //cover all lists on the server - there must be at least one
            List <Schedule> oSchedules;
            WebCallResult   res = Schedule.GetSchedules(_connectionServer, out oSchedules, 1, 2, null);

            Assert.IsTrue(res.Success, "Failed to fetch schedule list:" + res.ToString());

            string strObjectId = "";

            foreach (var oSchedule in oSchedules)
            {
                Console.WriteLine(oSchedule.ToString());
                Console.WriteLine(oSchedule.DumpAllProps());

                List <ScheduleDetail> oDetails;
                oSchedule.GetScheduleDetails(out oDetails);

                Console.WriteLine(oSchedule.GetScheduleState(DateTime.Now));

                strObjectId = oSchedule.ObjectId;
            }

            //create a new schedule instance from objectId
            Schedule oNewSchedule;

            try
            {
                oNewSchedule = new Schedule(_connectionServer, strObjectId);
                ScheduleState oState = oNewSchedule.GetScheduleState(DateTime.Now);
                Assert.IsNotNull(oState, "Failed to fetch schedule state from schedule objectId:" + strObjectId);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false, "Failed to create new schedule instance from ObjectId:" + ex);
            }

            Schedule oTempSchedule;

            res = Schedule.GetSchedule(out oTempSchedule, _connectionServer, "", oSchedules[0].DisplayName);
            Assert.IsTrue(res.Success, "Failed to fetch schedule by valid name:" + res);

            try
            {
                oNewSchedule = new Schedule(_connectionServer, "", "blah");
                Assert.IsTrue(false, "Creating schedule class with invalid schedule name should throw an exception");
                Console.WriteLine(oNewSchedule);
            }
            catch (Exception)
            {
                Console.WriteLine("Expected error for creation failure");
            }

            res = Schedule.GetSchedule(out oNewSchedule, _connectionServer, "", "bogus");
            Assert.IsFalse(res.Success, "Fetching schedule by invalid name did not fail");


            res = Schedule.GetSchedules(_connectionServer, out oSchedules, 1, 2, "query=(ObjectId is Bogus)");
            Assert.IsTrue(res.Success, "fetching schedules with invalid query should not fail:" + res);
            Assert.IsTrue(oSchedules.Count == 0, "Invalid query string should return an empty schedules list:" + oSchedules.Count);
        }
Exemple #27
0
        //create a new user - pop a dialog that allows the user to provide an alias, first name, last name, display name and extension - if at least
        //the alias and extension are provided this routine will then attempt to create that user on the Connection server.
        private void buttonAddItem_Click(object sender, EventArgs e)
        {
            //gather the new subscriber data from the user.
            using (FormNewUserInfo oForm = new FormNewUserInfo())
            {
                if (oForm.ShowDialog() != DialogResult.OK)
                {
                    //user canceled or closed the dialog without going through OK - bail out.
                    return;
                }

                //the call can take a minute to return - disable controls on the form to indicate we're busy.
                DisableFormControls();

                ConnectionPropertyList oProps = new ConnectionPropertyList();

                //fill up the props with the other items (if any) that are not blank
                if (oForm.FirstName.Length > 0)
                {
                    oProps.Add("FirstName", oForm.FirstName);
                }
                if (oForm.LastName.Length > 0)
                {
                    oProps.Add("LastName", oForm.LastName);
                }
                if (oForm.DisplayName.Length > 0)
                {
                    oProps.Add("DisplayName", oForm.DisplayName);
                }

                WebCallResult res = UserBase.AddUser(GlobalItems.CurrentConnectionServer, oForm.TemplateAlias, oForm.Alias, oForm.Extension, oProps);

                EnableFormControls();

                if (res.Success)
                {
                    //force a refresh of the grid and then select the user you just added - the ObjectId of the newly added user is returned
                    //in the WebCallResult structure as the ReturnObjectID.
                    _currentPage = 0;
                    UpdateDataDisplay(res.ReturnedObjectId);
                    Logger.Log(string.Format("New user added:{0},{1}", oForm.Alias, res.ReturnedObjectId));
                }
                else
                {
                    Logger.Log(string.Format(string.Format("New user add failed:{0}\r\n{1}", oForm.Alias, res.ToString())));
                    MessageBox.Show(String.Format("Error adding user: {0}\nresponse from CUPI: {1}", res.ErrorText, res.ResponseText));
                }
            }
        }
Exemple #28
0
        public void DistributionList_GetDistributionLists()
        {
            ConnectionServerRest    pConnectionServer = _connectionServer;
            List <DistributionList> pDistributionLists;

            //limit the fetch to the first 3 lists to be sure this passes even on a default install
            string[] pClauses = { "rowsPerPage=3" };

            WebCallResult res = DistributionList.GetDistributionLists(pConnectionServer, out pDistributionLists, pClauses);

            Assert.IsTrue(res.Success, "Fetching of top three distribution lists failed: " + res.ToString());
            Assert.AreEqual(pDistributionLists.Count, 3, "Fetching of the top three distribution list returned a different number of lists: " + res.ToString());

            //exercise the ToString and DumpAllProperties as part of this test as well
            foreach (DistributionList oList in pDistributionLists)
            {
                Console.WriteLine(oList.ToString());
                Console.WriteLine(oList.DumpAllProps());
            }

            res = DistributionList.GetDistributionLists(pConnectionServer, out pDistributionLists, 1, 2, "query=(ObjectId is Bogus)");
            Assert.IsTrue(res.Success, "fetching lists with invalid query should not fail:" + res);
            Assert.IsTrue(pDistributionLists.Count == 0, "Invalid query string should return an empty DL list:" + pDistributionLists.Count);
        }
        /// <summary>
        /// remove the currently selected distribution list in the grid after confirming with the user that's what they wish to do.
        /// </summary>
        private void buttonRemoveItem_Click(object sender, EventArgs e)
        {
            if (gridLists.SelectedRows.Count < 1)
            {
                MessageBox.Show("You must first select a distribution list to delete");
                return;
            }

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

            //verify with the user before deleting
            if (MessageBox.Show("Are you sure you want to delete the list: " + 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.DeleteDistributionList(GlobalItems.CurrentConnectionServer, strObjectID);

            EnableFormControls();

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

                //rebuild the grid - if we were traversing a list of lists before, be sure to reset the current page to 0 here because we
                //need to rebuild the list without the DL we just deleted in it.
                _currentPage = 0;
                UpdateDataDisplay();
            }
            else
            {
                MessageBox.Show("Failure removing distribution list:" + res.ErrorText);
                Logger.Log(string.Format("Failed to remove distribution list with display name={0} and objectId={1}.  Error={2}", strDisplayName, strObjectID, res.ToString()));
            }
        }
Exemple #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void buttonOK_Click(object sender, EventArgs e)
        {
            long lTemp;

            //check PINs
            if (TextBoxNewPin.Text.Trim().Length < 3)
            {
                LabelStatus.Text = "Invalid PIN - must be at least 3 digits long";
                return;
            }

            if (long.TryParse(TextBoxNewPin.Text, out lTemp) == false)
            {
                LabelStatus.Text = "Invalid PIN - must be all digits.";
                return;
            }

            if (TextBoxNewPin.Text.Equals(TextBoxVerifyNewPin.Text) == false)
            {
                LabelStatus.Text = "The two PINs you entered do not match.";
                return;
            }

            //reset the PIN - pass in null's for the flag values we aren't allowing the user to fiddle with so their current
            //values will be left alone.  Easy enough to extend the PIN collection form to allow passing the "can't change" and
            //"locked" values if you want.
            WebCallResult res = _user.ResetPin(TextBoxNewPin.Text, false, checkMustChange.Checked, null,
                                               checkDoesNotExpire.Checked, checkClearHackedLockout.Checked);

            if (res.Success == false)
            {
                LabelStatus.Text = string.Format("PIN reset failed for user: {0}/nError={1}", _user.Alias, GlobalItems.FormatStringForHTML(res.ToString()));
                return;
            }

            Session["ErrorNote"] = "PIN reset for: " + _user.ToString();

            //remove user object from session
            try
            {
                Session.Remove("SelectedUser");
            }
            catch { }

            Response.Redirect("~/SelectUser.aspx");
        }