Exemple #1
0
 /// <summary>
 /// Handle Hang up call event.
 /// </summary>
 /// <param name="commandData"></param>
 /// <returns></returns>
 public override bool HangUpCall(CtiCommandRequest commandData)
 {
     if (myLine != null)
     {
         int iCallID = TranslateCallID(commandData.CtiCallId);
         if (iCallID != -1)
         {
             if (CanHangUp(iCallID))
             {
                 using (SelectCallDlg dlg = new SelectCallDlg(myLine, "&Hangup"))
                 {
                     if (dlg.MatchingCalls > 1)
                     {
                         dlg.ShowDialog();
                     }
                     CallClassProvider call = dlg.SelectedCall;
                     if (call != null)
                     {
                         call.Hangup();
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
 private void btnCancel_Click(object sender, System.EventArgs e)
 {
     // setting the selected call to null prevents code using this dialog
     // from taking action on a call.
     selectedCall = null;
     DialogResult = DialogResult.Cancel;
 }
Exemple #3
0
        /// <summary>
        /// Handle Pick up Call...
        /// this is also used for UnHold.
        /// </summary>
        /// <param name="commandData"></param>
        /// <returns></returns>
        public override bool PickupCall(CtiCommandRequest commandData)
        {
            if (myLine != null)
            {
                int iCallId = TranslateCallID(commandData.CtiCallId);
                if (iCallId != -1)
                {
                    // is the call on hold?
                    if (cti.GetCall(iCallId).State == CallClassProvider.CallState.Hold)
                    {
                        // Pick a call to retrieve
                        using (SelectCallDlg dlg = new SelectCallDlg(myLine, "&Unhold"))
                        {
                            if (dlg.MatchingCalls > 1)
                            {
                                dlg.ShowDialog();
                            }

                            CallClassProvider call = dlg.SelectedCall;
                            if (call != null)
                            {
                                // place any call on hold that can be held
                                if (cti.GetActiveCall() != null)
                                {
                                    cti.GetActiveCall().Hold();
                                }
                                call.Unhold();
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Exemple #4
0
 /// <summary>
 /// Answer a Call
 /// </summary>
 /// <param name="commandData"></param>
 /// <returns></returns>
 public override bool AnswerCall(CtiCommandRequest commandData)
 {
     if (myLine != null)
     {
         // Pick a call to answer
         using (SelectCallDlg dlg = new SelectCallDlg(myLine, "&Answer"))
         {
             if (dlg.MatchingCalls > 1)
             {
                 dlg.ShowDialog();
             }
             CallClassProvider call = dlg.SelectedCall;
             if (call != null)
             {
                 // place any call on hold that can be held
                 if (cti.GetActiveCall() != null)
                 {
                     cti.GetActiveCall().Hold();
                 }
                 call.Answer();
                 return(true);
             }
         }
     }
     return(false);
 }
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            int sel = 0;

            // see if a call is selected
            if (callsList.SelectedItems.Count == 0)
            {
                TopMostMessageBox.Show(ResourceStrings.SELECT_CALL_DLG_SELECT_A_CALL, this.Text, MessageBoxButtons.OK);
                DialogResult = DialogResult.None;
            }
            else
            {
                sel          = callsList.SelectedIndices[0];
                selectedCall = (CallClassProvider)callsList.Items[sel].Tag;
                DialogResult = DialogResult.OK;
            }
        }
Exemple #6
0
 /// <summary>
 ///  Handle Hold event...
 /// </summary>
 /// <param name="commandData"></param>
 /// <returns></returns>
 public override bool HoldCall(CtiCommandRequest commandData)
 {
     if (myLine != null)
     {
         // Pick a call to place on hold
         using (SelectCallDlg dlg = new SelectCallDlg(myLine, "&Hold"))
         {
             if (dlg.MatchingCalls > 1)
             {
                 dlg.ShowDialog();
             }
             CallClassProvider call = dlg.SelectedCall;
             if (call != null)
             {
                 call.Hold();
                 return(true);
             }
         }
     }
     return(false);
 }
        public SelectCallDlg(LineClassProvider myLine, string command)
        {
            bool         showThisCall;
            ListViewItem item;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();


            this.Text = ResourceStrings.SELECT_CALL_DLG_TEXT;

            if (command != null)
            {
                btnOk.Text = command;
                command    = command.Replace("&", "");
                command    = command.ToLower(System.Globalization.CultureInfo.InvariantCulture);
            }
            foreach (CallClassProvider call in myLine.Calls)
            {
                showThisCall = false;
                if (command == "unhold" && call.CanUnhold())
                {
                    showThisCall = true;
                }
                else if (command == "hold" && call.CanHold())
                {
                    showThisCall = true;
                }
                else if (command == "answer" && call.CanAnswer())
                {
                    showThisCall = true;
                }
                else if (command == "hangup" && call.CanHangup())
                {
                    showThisCall = true;
                }
                else if (command == "transfer" && call.CanTransfer())
                {
                    showThisCall = true;
                }
                else if (command == null)                    // use as default for all
                {
                    showThisCall = true;
                }

                if (showThisCall)
                {
                    item = callsList.Items.Add(call.Started.ToShortTimeString());
                    item.SubItems.Add(CallClassProvider.CallStateText(call.State));

                    if (call.UserTag != null)
                    {
                        item.SubItems.Add(call.UserTag + "  " + call.Parties);
                    }
                    else
                    {
                        item.SubItems.Add(call.Parties);
                    }
                    item.Tag = call;
                }
            }
            if (callsList.Items.Count > 0)
            {
                callsList.Items[0].Selected = true;
            }
            if (callsList.Items.Count == 1)
            {
                selectedCall = (CallClassProvider)callsList.Items[0].Tag;
            }
        }
Exemple #8
0
        public override bool TransferCall(CtiCommandRequest commandData)
        {
            Guid transferToAgentID = Guid.Empty;

            try
            {
                if (myLine != null)
                {
                    // Find call that can be transferred
                    using (SelectCallDlg dlg = new SelectCallDlg(myLine, "&Transfer"))
                    {
                        if (dlg.MatchingCalls > 1)
                        {
                            dlg.ShowDialog();
                        }

                        CallClassProvider call = dlg.SelectedCall;
                        var agentStateService  = AifServiceContainer.Instance.GetService <IAgentStateService>();
                        if (call != null)
                        {
                            using (GetAgentId numberDlg = new GetAgentId())
                            {
                                if (numberDlg.ShowDialog() == DialogResult.OK)
                                {
                                    try
                                    {
                                        // See if this is being transferred to an agent

                                        if (agentStateService != null)
                                        {
                                            transferToAgentID = agentStateService.GetAgentId(numberDlg.AgentNumber);

                                            if (transferToAgentID != Guid.Empty && sessionMgr.ActiveSession != null)
                                            {
                                                string state = sessionMgr.ActiveSession.Save(true);
                                                if (!String.IsNullOrEmpty(state))
                                                {
                                                    agentStateService.SetSessionTransferInformation(transferToAgentID, call.CallerNumber, state);
                                                }
                                            }
                                            // Make sure the transfer works
                                            if (call.Transfer(numberDlg.AgentNumber) < 0)
                                            {
                                                // if anything failed, clear the session transfer info
                                                if (transferToAgentID != Guid.Empty)
                                                {
                                                    agentStateService.SetSessionTransferInformation(transferToAgentID, "", "");
                                                }
                                            }
                                            // Transfer is probably working
                                            else
                                            {
                                                // Ask in case the agent is expected to do wrap up or
                                                //   in case the call did not really transfer.
                                                // Don't do this if there is only a global session.
                                                if (sessionMgr.ActiveSession != null &&
                                                    !sessionMgr.ActiveSession.Global &&
                                                    TopMostMessageBox.Show(ResourceStrings.DESKTOP_CLOSE_AFTER_TRANSFER, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
                                                {
                                                    sessionMgr.CloseSession(sessionMgr.ActiveSession, false);
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception exp)
                                    {
                                        Logging.Error(Application.ProductName, ResourceStrings.DESKTOP_ERR_TRANSFERRING_CALL, exp);

                                        // if anything failed, clear the session transfer info
                                        if (transferToAgentID != Guid.Empty)
                                        {
                                            if (agentStateService != null)
                                            {
                                                agentStateService.SetSessionTransferInformation(transferToAgentID, "", "");
                                            }
                                        }
                                        return(false);
                                    }                                     // try...catch
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception exp)
            {
                Logging.Error(Application.ProductName, ResourceStrings.DESKTOP_ERR_TRANSFERRING_CALL, exp);
                return(false);
            }
            return(true);
        }
Exemple #9
0
 /// <summary>
 /// Find the length of the call passed in
 /// </summary>
 /// <param name="call"></param>
 /// <returns></returns>
 public string LengthOfCall(CallClassProvider call)
 {
     return(cti.LengthOfCall(call));
 }
        public SelectCallDlg(LineClassProvider myLine, string command)
        {
            bool         showThisCall;
            ListViewItem item;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.startedCol.Text = localize.SELECT_CALL_DLG_STARTED_COL;
            this.stateCol.Text   = localize.SELECT_CALL_DLG_STATE_COL;
            this.partiesCol.Text = localize.SELECT_CALL_DLG_PARTIES_COL;
            this.btnOk.Text      = localize.SELECT_CALL_DLG_BTN_OK;
            this.btnCancel.Text  = localize.SELECT_CALL_DLG_BTN_CANCEL;
            this.label1.Text     = localize.SELECT_CALL_DLG_LABEL1;
            this.Text            = localize.SELECT_CALL_DLG_TEXT;

            if (command != null)
            {
                btnOk.Text = command;
                command    = command.Replace("&", "");
                command    = command.ToLower();
            }
            foreach (CallClassProvider call in myLine.Calls)
            {
                showThisCall = false;
                if (command == "unhold" && call.CanUnhold())
                {
                    showThisCall = true;
                }
                else if (command == "hold" && call.CanHold())
                {
                    showThisCall = true;
                }
                else if (command == "answer" && call.CanAnswer())
                {
                    showThisCall = true;
                }
                else if (command == "hangup" && call.CanHangup())
                {
                    showThisCall = true;
                }
                else if (command == "transfer" && call.CanTransfer())
                {
                    showThisCall = true;
                }
                else if (command == null)                    // use as default for all
                {
                    showThisCall = true;
                }

                if (showThisCall)
                {
                    item = callsList.Items.Add(call.Started.ToShortTimeString());
                    item.SubItems.Add(CallClassProvider.CallStateText(call.State));

                    if (call.UserTag != null)
                    {
                        item.SubItems.Add(call.UserTag + "  " + call.Parties);
                    }
                    else
                    {
                        item.SubItems.Add(call.Parties);
                    }
                    item.Tag = call;
                }
            }
            if (callsList.Items.Count > 0)
            {
                callsList.Items[0].Selected = true;
            }
            if (callsList.Items.Count == 1)
            {
                selectedCall = (CallClassProvider)callsList.Items[0].Tag;
            }
        }