using TAPI3Lib;
namespace Tapi_App1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox textBox2;
protected System.Web.UI.WebControls.Button button6;
protected System.Web.UI.WebControls.Button button5;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button4;
protected System.Web.UI.WebControls.Button button2;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.DropDownList comboBox1;
protected System.Web.UI.WebControls.CheckBox checkBox2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox textBox1;
protected System.Web.UI.WebControls.CheckBox checkBox1;
private TAPIClass tobj;
public ITAddress[] ia=new TAPI3Lib.ITAddress[10];
private ITBasicCallControl bcc;
private callnotification cn;
private bool h323,reject;
uint lines;
int line;
int[] registertoken=new int[10];
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!(IsPostBack))
{
string strContactNo;
//strContactNo = Request.QueryString["ContactNo"];
strContactNo = "***********";
callContact(strContactNo);
}
}
public void callContact(string strContactNo)
{
initializetapi3();
h323=true;
reject=true;
registertoken[line] =
tobj.RegisterCallNotifications(ia[0],true,true,TapiConstants.TAPIMEDIATYPE_AUDIO,2);
TAPI3Lib.ITAddress ln=null;
ln=ia[line];
if(strContactNo.Length!=0)
{
try
{
if(!h323)
{
bcc =
ln.CreateCall(strContactNo,TapiConstants.LINEADDRESSTYPE_PHONENUMBER|TapiConstants.LINEADDRESSTYPE_IPADDRESS,TapiConstants.TAPIMEDIATYPE_DATAMODEM|TapiConstants.TAPIMEDIATYPE_AUDIO);
bcc.SetQOS(TapiConstants.TAPIMEDIATYPE_DATAMODEM|TapiConstants.TAPIMEDIATYPE_AUDIO,QOS_SERVICE_LEVEL.QSL_BEST_EFFORT);
bcc.Connect(false);
}
else
{
bcc =
ln.CreateCall(strContactNo,TapiConstants.LINEADDRESSTYPE_IPADDRESS,TapiConstants.TAPIMEDIATYPE_AUDIO);
bcc.Connect(false);
}
}
catch(Exception exp)
{
Response.Write("Failed to create call!");
tobj.Shutdown();
}
}
else
{
Response.Write("Please enter number to dial.. ");
tobj.Shutdown();
}
}
void initializetapi3()
{
try
{
tobj = new TAPIClass();
tobj.Initialize();
IEnumAddress ea=tobj.EnumerateAddresses();
ITAddress ln;
uint arg3=0;
lines=0;
tobj.ITTAPIEventNotification_Event_Event+= new
TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cn.Event);
tobj.EventFilter=(int)(TAPI_EVENT.TE_CALLNOTIFICATION|
TAPI_EVENT.TE_DIGITEVENT|
TAPI_EVENT.TE_PHONEEVENT|
TAPI_EVENT.TE_CALLSTATE|
TAPI_EVENT.TE_GENERATEEVENT|
TAPI_EVENT.TE_GATHERDIGITS|
TAPI_EVENT.TE_REQUEST);
for(int i=0;i<10;i++)
{
ea.Next(1,out ln,ref arg3);
ia[i]=ln;
if(ln!=null)
{
comboBox1.Items.Add(ia[i].AddressName);
if (!(ln.AddressName.IndexOf("Cisco").Equals(-1)))
{
ia[0] = ln;
break;
}
lines++;
}
else
break;
}
}
catch(Exception e)
{
Response.Write(e.ToString());
}
}
private void Button4_Click(object sender, System.EventArgs e)
{
IEnumCall ec = ia[line].EnumerateCalls();
uint arg = 0;
ITCallInfo ici;
try
{
ec.Next(1,out ici,ref arg);
ITBasicCallControl bc=(ITBasicCallControl)ici;
bcc.Disconnect(DISCONNECT_CODE.DC_NORMAL);
ici.ReleaseUserUserInfo();
}
catch(Exception exp)
{
Response.Write("No call to disconnect!");
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button4.Click += new System.EventHandler(this.Button4_Click);
//this.button2.Click += new System.EventHandler(this.button2_Click);
this.comboBox1.SelectedIndexChanged += new
System.EventHandler(this.comboBox1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void comboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
line=comboBox1.SelectedIndex;
}
}
class callnotification:TAPI3Lib.ITTAPIEventNotification
{
public delegate void listshow(string str);
public listshow addtolist;
public void Event(TAPI3Lib.TAPI_EVENT te,object eobj)
{
switch(te)
{
case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION:
addtolist("call notification event has occured");
break;
case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT:
TAPI3Lib.ITDigitDetectionEvent dd=(TAPI3Lib.ITDigitDetectionEvent)eobj;
addtolist("Dialed digit"+dd.ToString());
break;
case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT:
TAPI3Lib.ITDigitGenerationEvent dg=(TAPI3Lib.ITDigitGenerationEvent)eobj;
addtolist("Dialed digit"+dg.ToString());
break;
case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT:
addtolist("A phone event!");
break;
case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS:
addtolist("Gather digit event!");
break;
case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
TAPI3Lib.ITCallStateEvent a=(TAPI3Lib.ITCallStateEvent)eobj;
TAPI3Lib.ITCallInfo b=a.Call;
switch(b.CallState)
{
case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
addtolist("dialing");
break;
case TAPI3Lib.CALL_STATE.CS_CONNECTED:
addtolist("Connected");
break;
case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
addtolist("Disconnected");
break;
case TAPI3Lib.CALL_STATE.CS_OFFERING:
addtolist("A party wants to communicate with you!");
break;
case TAPI3Lib.CALL_STATE.CS_IDLE:
addtolist("Call is created!");
break;
}
break;
}
}
}
}
RK,
Regarding TAPI and .NET see KB article "841712 - Telephony Application
Programming Interface (TAPI) functionality is not supported from managed
code".
See my TAPI and TSPI FAQ:
Q: Are there any .NET wrappers for TAPI2 available ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Are_there_4
You may want to take a look at JulMar's
ITAPI3 - TAPI 3.0 wrapper for .NET 2.0
and
TAPI2 ATAPI.NET - TAPI Application class library for .NET 2.0:
http://www.julmar.com/samples.htm
http://www.julmar.com/blog/mark/CategoryView,category,Tapi.aspx
--
Best Regards
Andreas Marschall
Microsoft MVP for TAPI / Windows SDK
TAPI / TSP Developer and Tester
My TAPI and TSPI FAQ:
http://www.I-B-A-M.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm
My Toto® Tools (a collection of free, mostly TAPI related tools):
http://www.i-b-a-m.de/Andreas_Marschall's_Toto_Tools.htm
TAPI development around the world (Frappr! map):
http://www.frappr.com/TAPIaroundTheWorld
* Please post all messages and replies to the newsgroup so all may
* benefit from the discussion. Private mail is usually not replied to.
* This posting is provided "AS IS" with no warranties, and confers no rights.
Help needed ASAP.
Thanks
RK
"RK" <R...@discussions.microsoft.com> wrote in message
news:487CB9BA-8464-4EEA...@microsoft.com...
"RK" <R...@discussions.microsoft.com> wrote in message
news:2A9F0549-CA42-4E2B...@microsoft.com...
"RK" <R...@discussions.microsoft.com> wrote in message
news:B34E8054-A21F-4685...@microsoft.com...
RK,
See my TAPI and TSPI FAQ:
Q: Is there a user guide available for TAPI Browser TB3x ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Is_there_2