|
The problem is, code does not detected telephone tones(telephone button press).Language is vb.net.
Code is::
Imports TAPI3Lib<br />
Imports SpeechLib<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
<br />
#Region " Windows Form Designer generated code "<br />
<br />
Public Sub New()<br />
MyBase.New()<br />
<br />
'This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
initializetapi3()<br />
'Add any initialization after the InitializeComponent() call<br />
<br />
End Sub<br />
Sub initializetapi3()<br />
m_TAPI.Initialize()<br />
'oTAPI = m_TAPI<br />
cn = New notification<br />
AddHandler m_TAPI.ITTAPIEventNotification_Event_Event, New TAPI3Lib.ITTAPIEventNotification_EventEventHandler(AddressOf cn.sEvent)<br />
<br />
End Sub<br />
<br />
'Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
m_TAPI.Shutdown()<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
<br />
'Required by the Windows Form Designer<br />
Private components As System.ComponentModel.IContainer<br />
<br />
'NOTE: The following procedure is required by the Windows Form Designer<br />
'It can be modified using the Windows Form Designer. <br />
'Do not modify it using the code editor.<br />
Friend WithEvents Button1 As System.Windows.Forms.Button<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
Me.Button1 = New System.Windows.Forms.Button<br />
Me.SuspendLayout()<br />
'<br />
'Button1<br />
'<br />
Me.Button1.Location = New System.Drawing.Point(144, 64)<br />
Me.Button1.Name = "Button1"<br />
Me.Button1.Size = New System.Drawing.Size(104, 40)<br />
Me.Button1.TabIndex = 0<br />
Me.Button1.Text = "answer"<br />
'<br />
'Form1<br />
'<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
Me.ClientSize = New System.Drawing.Size(292, 273)<br />
Me.Controls.Add(Me.Button1)<br />
Me.Name = "Form1"<br />
Me.Text = "Form1"<br />
Me.ResumeLayout(False)<br />
<br />
End Sub<br />
<br />
#End Region<br />
<br />
<br />
Private MediaAudio As Integer<br />
Private MediaModem As Integer = 24<br />
Private MediaFax As Integer<br />
Private MediaVideo As Integer<br />
Dim MediaTypes As Integer<br />
Private cn As notification<br />
'Private WithEvents button1 As System.Windows.Forms.Button<br />
'Private WithEvents oTAPI As TAPI3Lib.TAPI ' will hold our TAPI object<br />
'Private oTAPI As TAPI3Lib.TAPI<br />
Dim m_TAPI As New TAPIClass<br />
Private line_token As Integer<br />
Private oAddress As ITAddress ' will hold our selected address (you can hold many address in an array)<br />
<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim myspeak As New SpeechLib.SpVoiceClass<br />
Dim S1 As New SpeechLib.SpFileStream<br />
Const FILENAME1 = "c:\my.wav"<br />
Dim ec As IEnumCall = oAddress.EnumerateCalls()<br />
Dim arg As System.UInt32 = Convert.ToUInt32(0) 'ToDo: Unsigned Integers not supported<br />
Dim ici As ITCallInfo<br />
Dim reject = False<br />
Dim eobj<br />
Dim aa As New Byte<br />
Dim val As Integer<br />
<br />
'Trya<br />
ec.Next(Convert.ToUInt32(2), ici, arg)<br />
Dim bc As ITBasicCallControl = CType(ici, TAPI3Lib.ITBasicCallControl)<br />
' Dim con As ITBasicCallControl = CType(ici, TAPI3Lib.ITBasicCallControl)<br />
'If Not reject Then<br />
MsgBox("hello how r u")<br />
bc.Answer()<br />
MsgBox("hello")<br />
'Dim tone As TAPI3Lib.ITToneDetectionEvent = CType(ici, TAPI3Lib.ITToneDetectionEvent)<br />
'Dim a = tone.Call()<br />
<br />
<br />
<br />
<br />
<br />
'Try<br />
' S1.Open(FILENAME1, SpeechStreamFileMode.SSFMCreateForWrite)<br />
' myspeak.AudioOutputStream = S1<br />
' myspeak.Speak("welcome to telemail,how r u girls")<br />
<br />
' S1.Close()<br />
' MsgBox("file is created")<br />
' Sound.PlayWaveFile(FILENAME1)<br />
<br />
'Catch ex As Exception<br />
' MsgBox(e.ToString)<br />
'End Try<br />
<br />
<br />
<br />
<br />
End Sub<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
' creating a new instance to first initialize TAPI befor attaching the events<br />
Try<br />
<br />
' a variable to hold supported media types for the address<br />
<br />
' initializing TAPI<br />
'''m_TAPI.Initialize()<br />
'''oTAPI = m_TAPI<br />
'm_TAPI = Nothing<br />
'oTAPI.EventFilter = (TAPI_EVENT.TE_CALLNOTIFICATION Or TAPI_EVENT.TE_CALLSTATE Or TAPI_EVENT.TE_CALLINFOCHANGE)<br />
' attaching event sink<br />
'oTAPI = m_TAPI<br />
' getting red of the private instance as we have another global instance (oTAPI)<br />
'm_TAPI = Nothing<br />
<br />
Dim AddressCollection As ITCollection = m_TAPI.Addresses()<br />
<br />
For Each Address As ITAddress In AddressCollection ' looping through address collection<br />
<br />
If Address.State = ADDRESS_STATE.AS_INSERVICE Then ' checking if address is working <br />
<br />
Dim MediaSupport As ITMediaSupport = Address ' extracting meida support interface from the address<br />
<br />
MediaTypes = MediaSupport.MediaTypes ' extracting media types supporting<br />
<br />
MediaSupport = Nothing ' dispose of the object<br />
<br />
'If MediaTypes And MediaModem = MediaModem Then<br />
' the address is a data Modem<br />
If MediaTypes = MediaModem Then<br />
' the address supports Audio<br />
oAddress = Address ' select this address<br />
MsgBox("we have selected this address: " + oAddress.AddressName) ' show the selected address name<br />
MsgBox("no is" + CType(MediaTypes, String))<br />
Exit For<br />
End If<br />
End If<br />
<br />
'End If<br />
<br />
Next Address<br />
<br />
<br />
'If Not oAddress Is Nothing Then<br />
' registering notifications for the selected address<br />
line_token = m_TAPI.RegisterCallNotifications(oAddress, True, True, MediaTypes, 2)<br />
m_TAPI.EventFilter = TAPI_EVENT.TE_CALLNOTIFICATION Or TAPI_EVENT.TE_DIGITEVENT Or TAPI_EVENT.TE_PHONEEVENT Or TAPI_EVENT.TE_CALLSTATE Or TAPI_EVENT.TE_GENERATEEVENT Or TAPI_EVENT.TE_GATHERDIGITS Or TAPI_EVENT.TE_REQUEST Or TAPI_EVENT.TE_TONEEVENT Or TAPI_EVENT.TE_CALLMEDIA<br />
<br />
Catch ex As Exception<br />
MsgBox("Error occured:" & vbCrLf & ex.Message, MsgBoxStyle.Critical, "VBCITY.VBTAPI")<br />
End Try<br />
End Sub<br />
<br />
<br />
<br />
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)<br />
<br />
End Sub<br />
End Class<br />
''-----------------------------SOUND CLASS-------------------------------<br />
Public Class Sound<br />
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _<br />
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer<br />
<br />
<br />
Public Const SND_FILENAME = &H20000 ' name is file name <br />
<br />
Public Shared Sub PlayWaveFile(ByVal fileWaveFullPath As String)<br />
Try<br />
PlaySound(fileWaveFullPath, 0, SND_FILENAME)<br />
Catch<br />
End Try<br />
End Sub<br />
End Class<br />
Class notification<br />
'Implements TAPI3Lib.ITTAPIEventNotification<br />
'Implements TAPI3Lib.ITDigitDetectionEvent<br />
<br />
<br />
<br />
'Delegate Sub listshow(ByVal str As String)<br />
'Publicmsgbox As listshow<br />
<br />
<br />
Public Sub sEvent(ByVal te As TAPI3Lib.TAPI_EVENT, ByVal eobj As Object)<br />
'Implements ITTAPIEventNotification.Event,ITDetectTone<br />
Dim aa As New Byte<br />
Dim val As Integer<br />
<br />
Select Case te<br />
<br />
<br />
Case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION<br />
MsgBox("call notification event has occured")<br />
<br />
<br />
Case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT<br />
MsgBox("digit is detected")<br />
Dim dd As TAPI3Lib.ITDigitDetectionEvent = CType(eobj, TAPI3Lib.ITDigitDetectionEvent)<br />
'MsgBox("my digit")<br />
MsgBox(("Dialed digit" + dd.ToString()))<br />
<br />
<br />
<br />
<br />
'aa = dd.Digit()<br />
'val = dd.DigitMode<br />
'MsgBox(val)<br />
'Select Case val<br />
' Case val = 1<br />
' MsgBox("u have enter 1")<br />
'End Select<br />
<br />
''''''''''''<br />
<br />
Case TAPI_EVENT.TE_CALLMEDIA<br />
MsgBox("media is changed")<br />
<br />
<br />
Case TAPI_EVENT.TE_PHONEEVENT<br />
MsgBox("phone event is occured")<br />
Case TAPI_EVENT.TE_TONEEVENT<br />
MsgBox("tone is detected")<br />
Case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT<br />
Dim dg As TAPI3Lib.ITDigitGenerationEvent = CType(eobj, TAPI3Lib.ITDigitGenerationEvent)<br />
<br />
<br />
MsgBox("digit dialed!")<br />
MsgBox(("Dialed digit" + dg.ToString()))<br />
Case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT<br />
MsgBox("A phone event!")<br />
Case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS<br />
MsgBox("Gather digit event!")<br />
<br />
Case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE<br />
MsgBox("welcome to call state")<br />
Dim a As TAPI3Lib.ITCallStateEvent = CType(eobj, TAPI3Lib.ITCallStateEvent)<br />
Dim b As TAPI3Lib.ITCallInfo = a.Call<br />
<br />
Select Case b.CallState<br />
Case TAPI3Lib.CALL_STATE.CS_INPROGRESS<br />
MsgBox("dialing")<br />
Case TAPI3Lib.CALL_STATE.CS_CONNECTED<br />
MsgBox("Connected")<br />
<br />
Case TAPI3Lib.CALL_STATE.CS_DISCONNECTED<br />
MsgBox("Disconnected")<br />
Case TAPI3Lib.CALL_STATE.CS_OFFERING<br />
MsgBox("A party wants to communicate with you!")<br />
Case TAPI3Lib.CALL_STATE.CS_IDLE<br />
MsgBox("Call is created!")<br />
Case CALL_STATE.CS_HOLD<br />
MsgBox("hold the call")<br />
End Select<br />
End Select<br />
End Sub 'Event<br />
<br />
<br />
<br />
<br />
<br />
<br />
End Class 'callnotification<br />
<br />
<br />
|
|
|
|
|
Until recently I enjoyed the benefits of .Net Framework v1.1 (for 1 year or so). It is a very simple and flexible framework sustaind by a strong language - c#.
But afther I developped a very simple application someone asked me "how much memory does the application 'eats'". My surprise was to find out that a tiny aplication that uses ADO.NET (a few tables with data from a binary file - 4000 records) goes up to 30 MB. So the first thing that camed into my mind was to test how much RAM needs a WindosApplication Template (VS .Net 2003), the result was 9 MB.
Is there something that can be done to avoid this huge amount of memory spent for the application? .Net is designed in order to run even on Windows 98, but a machine that uses Win 98 may have 64, 32 or even less RAM so the memory necessary for the application will be taken from the virtual memory => a much slower speed...
Did anybody faced this problem or does anybody have any recommendation for lowering the memory necessary for .Net applications?
I hope you understand...because I do not...
-- modified at 16:56 Tuesday 30th August, 2005
|
|
|
|
|
No, because you're not looking in the right place to measure the memory consumption.
Yes, there is an overhead for using the .NET Framework and no you can't get rid of it.
Now, like most other people, you probably looked in the Task Manger to see how much RAM was allocated to your process. This is NOT how much memory your process is actually using. The .NET Framework execution environment is a virtual machine with it's own Memory Manager. The .NET Memory Manager grabs a rather large block of memory for your application. Even if you're not using it. This is because it can quickly allocate object on the managed heaps, as opposed to grabbing unmanaged memory, adding it to the managed pool, then allocating your object.
Just because the Task Manager says that your application is taking up X amount of memory, doesn't mean the your application is actually using it. It's RESERVED as far as the .NET Memory Manager is concerned.
Now, on Win98, the memory requirements for using the .NET Framework is at least 32MB of RAM, with 96MB being the recommended minimum. .NET Framework System Requirements[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you for your answer...
So you say that because of the large amount of memory avaliable on my machine the framework pre-allocates more (just in case), and that on other machines (with much lesser memory) the framework will pre-allocate lesser... This is a good news for me.
Now I have another question...is there possible to convert .Net code (a binary file) into Machine code, but not at execution time. I mean are thare any compilers capable of converting a .Net application into a standard application (exporting all the used libraryes, or whatever it neads)?
I hope I understand...because is a rough world out there...
|
|
|
|
|
Hey,
I assume you are looking for a way to run your code without a framework!
try Thinstall Thinstall HP
I used it for some tests and it works quite fine. But i think "normal" people wont buy it because of the very high price!
|
|
|
|
|
Does anybody knowes an application that is under a free license which can do a result like Thinstall?
Or an free obfuscation tool?
Or should I reorinet my programming skils to develop such applications as the ones mentioned above?
I hope we understand...because is a rough world out there...
|
|
|
|
|
Vlad Stanciu wrote:
is there possible to convert .Net code (a binary file) into Machine code, but not at execution time.
Yes and no. The .NET Framework comes with a tool call NGEN that will do just that. But! It converts the code to VERY processor specific code, on the processor that it's running on. Say you compile this code on a Pentium IV Step 5. In all likelyhood, it won't run on a Pentium III or and AMD chip. Now you'll have to generate code for each type of processor, and version of, out there.
Completely impractical...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Do you think an article on Virtual memory and .NET Memory management would be a good idea? This is not the first time someone mistook Task Manager memory values to be the actual memory consumption of the application.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Yes it would. But I don't have the time to write it, or more to the point, support it afterwards.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Is there an easy way to just get the abbreviated for of the current time zone, as opposed to the whole name written out?
And can this be done in Daylight Saving Time as opposed to Standard Time.
So I get EDT instead of Eastern Daylight Time or Eastern Saving Time.
Thanks!
RABB17
|
|
|
|
|
I was recently looking for something like this and didn't find anything. If you absolutely need the abbreviation, you may have to create an array or enum listing them all and do the conversion yourself based on TimeZone.CurrentTimeZone.StandardName.
|
|
|
|
|
Now we have Monoppix, a linux powered with mono, the open source CLI implementation.
www.monoppix.com
Eduardo Diaz
Dark Side Programming"
|
|
|
|
|
Ok! I have a .NET (C#) app that I'm having a problem running on a Win 2003 box from a different Win 2003 box. I mean files physically are installed on that second win 2003 server, and I'm trying to start it on this first one. I get security error. I know about that .NET framework wizard that allows you to adjust .NET level of protection to internet/intranet/trusted and so on but that doesn't help.
This doesn't happen on XP/2000. Any ideas!
Thanks a lot in advance!
Please help! It's very urgent!
|
|
|
|
|
Code comming from a network source runs under a lot more restrictions than if you were to launch the exact same code from the local hard drive. Use the .NET Framework configuration tool in your Administrative Tools folder to increase the trust for that code running from a network zone.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know it is possible to enable your .NET applications to use Microsoft .NET Passport.
Yeah, but ... how to do that? It is free of charge or a subscription is needed?
If anyone knows something, please help!
Thanks
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
You might want to start by reading the Business Implementation[^] section of the .NET Passport SGK documentation.
AFAIK, there is no subscription fee. But there may be a compliance checkout and fee before your site is allowed to go into production. I have no idea what that charge might be.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hmmmm... it seems to be a mystery. However, thanks a lot, you have completely *resized* my problem.
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
Is is possible to access a USB Flash drive / disk from the .NET framework.
I want to be able to detect when a Flash drive has been inserted, write to a CF and then allow the user to safely remove it.
Will .NET 2.0 have this capability?
Thanks,
Liam
|
|
|
|
|
When you put in the computer doesn't it just show up as "Removable Storage" or something? It's acting like a hard drive, so if you just want to save/read files on it, just use the normal steps.
/\ |_ E X E GG
|
|
|
|
|
When I boot I will boot directly to my application and bypass the standard windows environment. There will be no task bar available to the user.
So I have to mimic what is done in the task bar in a programmatic way within the C# code.
Thanks,
Liam
|
|
|
|
|
Hello Everybody !
Does anybody know, why in some articles here, and also in VS.NET -generated Databound form the following logic is used to save DataSet changes to database:
SaveChanges(){
DataSet datasetWithChanges=dataSetUsedByControls.GetChanges();
if (datasetWithChanges != null)
{
SaveChangesToDB(datasetWithChanges); // function where adapters save changes to db.
dataSetUsedByControls.Merge(datasetWithChanges);
dataSetUsedByControls.AcceptChanges();
}
}
I tend to use:
SaveChanges(){
if (dataSetUsedByControls.HasChanges())
{
SaveChangesToDB(dataSetUsedByControls); // function where adapters save changes to db.
dataSetUsedByControls.AcceptChanges();
}
}
So why GetChanges - apply them and then merge with original dataset ? We can simply pass the originald ataset to adapter and changes will also be saved.
Can anyone explain why Microsoft has implemented the first variant it it's data-bound form wizard, and also why some articles use this variant as well ? Where is the trick ?
For example here:
http://www.codeproject.com/csharp/PracticalGuideDataGrids4.asp[^]
-- modified at 6:13 Tuesday 30th August, 2005
|
|
|
|
|
DataSet newbie wrote:
DataSet datasetWithChanges=dataSetUsedByControls.GetChanges();
The dataset "datasetWithChanges" is a new dataset that only has the records from the "dataSetUsedByControls" that actually has changes. Therefore you when the execute the
SaveChangesToDB(datasetWithChanges); //Notice it is the smaller dataset being sent
less network traffic is generated and therefore faster performance. Then the datasets are merged. Your way sends the entire ds back including all the records that do not have any changes to them.
hth
Al
|
|
|
|
|
Thanks, and Stop !
We should clear out the configuration where the code works (I had to write it in my first post probably):
If this is a Local Windows Forms application, then dataset and data adapter are on the same machine, so
during SaveChangesToDB(dataSetUsedByControls); //full dataset
dataset is processed locally throught the adapter and adapter applies only changed data to datasource.
If I understand you, you talk about some distributed application, where dataset and dataadapter are separated through some communication channel, right ?
So If I did understand you correctly this means:
1.Use GetChanges-Update-Merge for Distributed applications
2.Use direct Update from Full Dataset in local applications (this will even have some performance gain, because we avoid creation of new dataset and, later, Merge)
right ?
|
|
|
|
|
MSDN states that on the acceptchanges method ALL rows of each table are updated. So in my situation, which you are correct is distributed, I extract a smaller dataset to send to a webservice. The webservice hooks the dataset into the dataadapter and performs the update.
IMHO, on a local app then I would probably find out how much data actually got changed, if a small amount (<20% perhaps) then create a new dataset and only process it. But if a significant amount (>70% ?) then why waste the resources of creating a new dataset, just update with the acceptchanges like you are doing.
Al
|
|
|
|
|
The truth is somewhere near.
Generally I think that .GetChanges has sence for distributed case.
The costs are:
Case with Merge:
GetChanges (full iteration through full Dataset) fi
Update (iteration through subset) si
Merge (iteration through Full Dataset + subset) fi+si
totally fi+si+fi+si=2*fi+2*si
Case with direct update:
Update - full iteration
AcceptChanges - full iteration
totally 2*fi
Also look here:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataDataSetClassMergeTopic2.asp?frame=true[^]
Thanks !
Andrei
|
|
|
|