CISCO IP Telephony using ATAPI

Jan 9, 2014 at 10:29 AM
Edited Jan 9, 2014 at 12:28 PM
I need to create an app which will allow Supervisors to Monitor/Coach Agents on CISCO IP phone from server. The app will be in C#. I have tried using ATAPI wrapper, but it can't detect active call in the server. Please let me know what configuration or code is needed for me. Please provide sample code which will satisfy my requirements.

I am using the following code to get active calls:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using JulMar.Atapi;

namespace Monitor
{
public partial class Form1 : Form
{
    TapiManager tapiManager = new TapiManager("Monitor");

    const int COLUMNS_CID = 1;
    const int COLUMNS_STATE = 2;
    const int COLUMNS_CALLER = 3;
    const int COLUMNS_CALLED = 4;

    string lineName;

    public Form1()
    {
        InitializeComponent();
        btnStart.Click += btnStart_Click;
    }

    #region Button
    protected void btnStart_Click(object sender, EventArgs e)
    {
        if (tapiManager.Initialize() == false)
        {
            MessageBox.Show("No Tapi devices found.");
            this.Close();
            return;
        }

        foreach (TapiLine line in tapiManager.Lines)
        {
            try
            {
                line.NewCall += OnNewCall;
                line.CallStateChanged += OnCallStateChanged;
                line.CallInfoChanged += OnCallInfoChanged;
                line.Monitor();

                //TapiCall[] calls = line.GetCalls();
            }
            catch (TapiException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
    #endregion

    #region TapiLine
    private void OnNewCall(object sender, NewCallEventArgs e)
    {
        if (this.InvokeRequired)
        {
            EventHandler<NewCallEventArgs> eh = OnNewCall;
            this.BeginInvoke(eh, new object[] { sender, e });
            return;
        }

        TapiLine line = (TapiLine)sender;
        TapiCall call = e.Call;

        ListViewItem lvi = new ListViewItem(line.Name);
        lvi.Tag = call;

        lvi.SubItems.AddRange(
            new string[] {
                string.Format("0x{0:X}", call.Id),
                call.CallState.ToString(),
                string.Format("{0} {1}", call.CallerId, call.CallerName),
                string.Format("{0} {1}", call.CalledId, call.CalledName),
            });
        lvCalls.Items.Add(lvi);
    }

    private void OnCallInfoChanged(object sender, CallInfoChangeEventArgs e)
    {
        if (this.InvokeRequired)
        {
            EventHandler<CallInfoChangeEventArgs> eh = OnCallInfoChanged;
            this.BeginInvoke(eh, new object[] { sender, e });
            return;
        }

        TapiLine line = (TapiLine)sender;
        TapiCall call = e.Call;

        if ((e.Change & (CallInfoChangeTypes.CalledId | CallInfoChangeTypes.CallerId)) > 0)
        {
            foreach (ListViewItem lvi in lvCalls.Items)
            {
                if (lvi.Tag == call)
                {
                    lvi.SubItems[COLUMNS_CALLER].Text = string.Format("{0} {1}", call.CallerId, call.CallerName);
                    lvi.SubItems[COLUMNS_CALLED].Text = string.Format("{0} {1}", call.CalledId, call.CalledName);
                    break;
                }
            }
        }
    }

    private void OnCallStateChanged(object sender, CallStateEventArgs e)
    {
        if (this.InvokeRequired)
        {
            EventHandler<CallStateEventArgs> eh = OnCallStateChanged;
            this.BeginInvoke(eh, new object[] { sender, e });
            return;
        }

        TapiLine line = (TapiLine)sender;
        TapiCall call = e.Call;

        foreach (ListViewItem lvi in lvCalls.Items)
        {
            if (lvi.Tag == call)
            {
                lvi.SubItems[COLUMNS_STATE].Text = call.CallState.ToString();

                if (call.CallState == CallState.Idle)
                {
                    call.Dispose();
                    lvCalls.Items.Remove(lvi);
                }
                break;
            }
        }
    }
    #endregion

    #region Methods
    private TapiCall GetActiveCall()
    {
        if (lvCalls.SelectedItems.Count > 0)
        {
            return (TapiCall)lvCalls.SelectedItems[0].Tag;
        }
        return null;
    }        
    #endregion
}
}

Please suggest how to monitor/coach (whispering) with ATAPI.