Click or drag to resize
TapiLineDial Method (String, Boolean, TapiMediaMode, TapiAddress)
Dials an outgoing call on the line using specified media mode and originating TapiAddress.

Namespace: Traysoft.AddTapi
Assembly: Traysoft.AddTapi (in Traysoft.AddTapi.dll) Version: 6.0.0.1110
Syntax
public TapiCall Dial(
	string number,
	bool useDialingRules,
	TapiMediaMode mediaMode,
	TapiAddress address
)

Parameters

number
Type: SystemString
A string that contains a number to dial.
useDialingRules
Type: SystemBoolean
Indicates if the dialing rules specified in the Control Panel should be applied.
mediaMode
Type: Traysoft.AddTapiTapiMediaMode
Expected media type of the call.
address
Type: Traysoft.AddTapiTapiAddress
Originating address for the call.

Return Value

Type: TapiCall
A newly created call.
Exceptions
ExceptionCondition
TapiExceptionDial failed because of Telephony API (TAPI) error.
TapiExceptionDial failed because of Telephony API (TAPI) error.
Remarks

In order to dial an outgoing call, the line must be opened using Open(Boolean, TapiCallHandler) method first. The application can open the line for outgoing calls by passing false as the first parameter of Open(Boolean, TapiCallHandler). Also, outgoing calls can be dialed on the line open for incoming calls.

After an outgoing call is connected, AddTapi.NET fires CallConnected event and executes TapiCallHandler method passed as the second parameter of Open(Boolean, TapiCallHandler). If outgoing call cannot be completed because there is no dailtone, a busy signal was detected or if the called party did not answer within the time interval set in NoAnswerTimeout property, AddTapi.NET fires CallDisconnected event. The application can find out the reason for disconnect by examining the DisconnectMode property of the disconnected call. After CallDisconnected event occurs, another outgoing call can be placed on the same line.

The line must support predictive dialing (also called hardware answer detection) in order for AddTapi.NET to detect if outgoing call was answered. Most voice modems do not support predictive dialing and report that the call is connected immediately after the number has been dialed, before called party picks up the phone. In such case "no answer" is never reported.

When useDialingRules parameter is false, a number to dial is passed directly to the telephony hardware without any translation. In this case the number parameter follows a standard dialable number format. A dialable number can contain the following DTMF or pulse digits: '0'-'9', 'A'-'D', '*' and '#'. A dialable number can also contain the following modifiers (if supported by the telephony hardware):

ModifierMeaning
!Hex (21). Indicates that a hookflash (one-half second onhook, followed by one-half second offhook before continuing) is to be inserted in the dial string.
P pHex (50) or Hex (70). An uppercase or lowercase P indicates that pulse dialing is to be used for the digits following it.
T tHex (54) or Hex (74). An uppercase or lowercase T indicates that tone (DTMF) dialing is to be used for the digits following it.
,Hex (27). A comma indicates that dialing is to be paused. The duration of a pause is device specific (usually 500 ms). Multiple commas can be used to provide longer pauses.
W wHex (57) or Hex (77). An uppercase or lowercase W indicates that dialing should proceed only after a dial tone has been detected.
@Hex (40). Indicates that dialing is to "wait for quiet answer" before dialing the remainder of the dialable number. This means to wait for at least one ringback tone followed by several seconds of silence.

When useDialingRules parameter is true, a number to dial is translated using dialing rules specified in the Telephony applet in the Control Panel. In this case the number parameter should follow canonical format. A canonical phone number is a text string with the following structure:

+ CountryCode Space [(AreaCode) Space] SubscriberNumber

Plus sign (hex 2B) indicates that the number that follows it uses the canonical format. The plus sign is followed by the variably sized country code (CountryCode element) without any spaces between the plus sign and the country code. CountryCode is followed by exactly one space character (hex 20). AreaCode is the area code part of the number and is optional. If the area code is present, it must be preceded by exactly one left parenthesis character (hex 28), and be followed by exactly one right parenthesis character (hex 29) and one space character (hex 20). SubscriberNumber may include digits '0' - '9', 'A' - 'D' , '*' and '#'. Other dial control characters described above in the dialable number format are also allowed. The subscriber number should not contain the left parenthesis or right parenthesis character (which are used only to delimit the area code). The following nondigit characters in the subscriber number are allowed: spaces, periods '.' and dashes '-'. They are used for display purposes and are ignored. For example, the canonical representation of the US phone number 555-123-4567 would be:

+1 (555) 123-4567

The mediaMode parameter indicates what media type is expected on the call. The application should specify TapiMediaMode.AutomatedVoice media mode in order to use voice functionality such as playing wave files using Play(String) and speaking to the caller using Speak(String).

The address parameter allows to select originating address for lines that have multiple associated addresses. This parameter must contain one of the addresses listed in the Addresses collection.

Examples
The following code shows how to open the line for outgoing calls and make a call. Error handling has been omitted for clarity.
TapiApp.Initialize("MyApp");
TapiLine line = TapiApp.Lines[0];
line.Open(false, CallHandler, TapiMediaMode.AutomatedVoice);
line.Dial("15551234567", false, TapiMediaMode.AutomatedVoice, line.Addresses[0]);
...

// This method will be called when outgoing call is answered
private void CallHandler(TapiCall call)
{
    call.Play("welcome.wav");
    call.Speak("Press 1 to hear the current time. Press any other button to disconnect.");
    if(call.WaitForDigit(20) == "1")
    {
        call.Speak(DateTime.Now.ToString());
        call.WaitUntilDone(10);
    }
    call.Disconnect();
}
See Also