⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 三汇CTI示例程序源码
💻 VB
📖 第 1 页 / 共 5 页
字号:
                m_FaxCh(i).nRcvBytes = 0
                m_FaxCh(i).nCheckEnd = 0
                Me.m_cmbFaxCh1.Items.Add(i.ToString())
                Me.m_cmbFaxChNo.Items.Add(i.ToString())
                Me.m_cmbFaxCh.Items.Add(i.ToString())

            Else

                Dim temp As Int32
                'get automatic call progress enable flag and call direction
                nCheck = SsmGetAutoCallDirection(i, temp)
                If (nCheck = -1) Then
                    WriteLog("Fail to call SsmGetAutoCallDirection")
                    'enable automatic call progress
                ElseIf (nCheck = 1) Then
                    m_TrkCh(i).nCallFlag = -1
                    m_TrkCh(i).nStep = TrkChState.TRK_IDLE
                    m_TrkCh(i).szChErrMsg = " "
                    m_TrkCh(i).bEnCalled = True
                    m_TrkCh(i).nAutoOrNot = 0
                    m_TrkCh(i).bRecord = True
                    m_TrkCh(i).szDtmf = ""
                    m_TrkCh(i).szDtmfChose = New Char
                    m_TrkCh(i).bUseful = False
                    m_TrkCh(i).nIndex = 0
                    m_TrkCh(i).nFirstDtmf = 0
                    m_TrkCh(i).bLinked = False
                    m_TrkCh(i).nTimer = -1
                    m_TrkCh(i).szCallerId = ""
                    Me.m_cmbTrkCh1.Items.Add(i.ToString())
                    Me.m_cmbTrkCh.Items.Add(i.ToString())
                    Me.m_cmbTrkChNo.Items.Add(i.ToString())
                End If
            End If
        Next i
        'load speech data "Step1.voc" and "Step2.voc"
        nCheck = SsmLoadIndexData(1, Chr(0), 6, "Step1.voc" + Chr(0), 0, -1)
        nChk = SsmLoadIndexData(2, Chr(0), 6, "Step2.voc" + Chr(0), 0, -1)
        If (nCheck = -1 Or nChk = -1) Then
            MessageBox.Show("Failed to load speech file")
            If (SsmCloseCti() = -1) Then
                WriteLog("Failed to call SsmCloseCti")
                Return False
            End If
        End If
        Return True
    End Function


    ' write log messages
    Public Sub WriteLog(ByVal szLog As String)
        'Dim w As System.IO.StreamWriter
        'If System.IO.File.Exists(path) = False Then
        '    w = System.IO.File.CreateText(path)
        'Else
        '    w = System.IO.File.AppendText(path)
        'End If
        'w.WriteLine("{0} {1}", System.DateTime.Now.ToLongDateString(), System.DateTime.Now.ToLongTimeString())
        'w.WriteLine("  :")
        'w.WriteLine("-------------------------------")
        'w.Flush()
        'w.Close()
    End Sub

    Public Sub InitFaxChListCtrl()

        Dim nIndex As Int32
        Dim i As Int32

        Me.m_FaxChList.Cols = 8
        Me.m_FaxChList.Row = 0

        Me.m_FaxChList.Col = 0
        Me.m_FaxChList.Text = "Ch"

        Me.m_FaxChList.Col = 1
        Me.m_FaxChList.Text = "Channel State"

        Me.m_FaxChList.Col = 2
        Me.m_FaxChList.Text = "Page number"

        Me.m_FaxChList.Col = 3
        Me.m_FaxChList.Text = "Remote ID"

        Me.m_FaxChList.Col = 4
        Me.m_FaxChList.Text = "Current file name"

        Me.m_FaxChList.Col = 5
        Me.m_FaxChList.Text = "Number of fax bytes"

        Me.m_FaxChList.Col = 6
        Me.m_FaxChList.Text = "Execution result of faxing"

        Me.m_FaxChList.Col = 7
        Me.m_FaxChList.Text = "Error message"

        Me.m_FaxChList.set_ColWidth(0, 30 * 12)
        Me.m_FaxChList.set_ColWidth(1, 130 * 12)
        Me.m_FaxChList.set_ColWidth(2, 40 * 12)
        Me.m_FaxChList.set_ColWidth(3, 100 * 12)
        Me.m_FaxChList.set_ColWidth(4, 150 * 12)
        Me.m_FaxChList.set_ColWidth(5, 150 * 12)
        Me.m_FaxChList.set_ColWidth(6, 200 * 12)
        Me.m_FaxChList.set_ColWidth(7, 300 * 12)

        Me.m_FaxChList.Rows = 1
        For i = 0 To m_nTotalCh - 1
            Dim nCheck As Int32 = SsmGetChType(i)
            If nCheck = -1 Then
                WriteLog("Fail to call SsmGetChType")
            ElseIf nCheck = ChType.FAX_CH Or nCheck = ChType.SOFTFAX_CH Then
                nIndex = nIndex + 1
                m_FaxChList.AddItem(i.ToString(), nIndex)

            End If
        Next i
    End Sub

    Public Sub InitTrunkChListCtrl()
        Dim i As Int32
        Dim nIndex As Int32
        Me.m_TrkChList.Cols = 6
        Me.m_TrkChList.Row = 0

        Me.m_TrkChList.Col = 0
        Me.m_TrkChList.Text = "Ch"

        Me.m_TrkChList.Col = 1
        Me.m_TrkChList.Text = "Channel State"

        Me.m_TrkChList.Col = 2
        Me.m_TrkChList.Text = "Faxing state"

        Me.m_TrkChList.Col = 3
        Me.m_TrkChList.Text = "Calling party number"

        Me.m_TrkChList.Col = 4
        Me.m_TrkChList.Text = "DTMF"

        Me.m_TrkChList.Col = 5
        Me.m_TrkChList.Text = "Error message"

        Me.m_TrkChList.set_ColWidth(0, 30 * 12)
        Me.m_TrkChList.set_ColWidth(1, 130 * 12)
        Me.m_TrkChList.set_ColWidth(2, 130 * 12)
        Me.m_TrkChList.set_ColWidth(3, 200 * 12)
        Me.m_TrkChList.set_ColWidth(4, 200 * 12)
        Me.m_TrkChList.set_ColWidth(5, 300 * 12)

        Me.m_TrkChList.Rows = 1
        For i = 0 To m_nTotalCh - 1
            If m_TrkCh(i).bEnCalled Then
                nIndex = nIndex + 1
                m_TrkChList.AddItem(i.ToString(), nIndex)
            End If
        Next i
    End Sub

    Public Sub UpdateFaxChListCtrl()
        Dim szNewStat As String = ""
        Dim szOldStat As String = ""
        Dim szStatemsg As String = ""
        Dim strbFaxId As System.Text.StringBuilder = New System.Text.StringBuilder(20)
        Dim i As Int32
        Dim nIndex As Int32 = 0
        Dim nCheck As Int32

        For i = 0 To m_nTotalCh - 1
            nCheck = SsmGetChType(i)
            If nCheck = -1 Then
                WriteLog("Fail to Call SsmGetChType")
            ElseIf (nCheck = ChType.FAX_CH Or nCheck = ChType.SOFTFAX_CH) Then

                Select Case (m_FaxCh(i).nStep)
                    Case FaxChStep.FAX_IDLE
                        szNewStat = "Idle"
                    Case FaxChStep.FAX_CHECK_END
                        If (m_FaxCh(i).nDirection = FaxDir.C_SEND_FAX) Then
                            szNewStat = "Sending:"
                        Else
                            szNewStat = "Receiving:"
                        End If
                        nCheck = SsmFaxGetChStateMsg(i, szStatemsg)
                        If (nCheck = -1) Then
                            WriteLog("Fail to call SsmFaxGetChStateMsg")
                        ElseIf (nCheck = 0) Then
                            szNewStat += szStatemsg
                        End If
                End Select
                szOldStat = m_FaxChList.get_TextMatrix(nIndex + 1, 1)
                If (szOldStat.Equals(szNewStat) = False) Then
                    m_FaxChList.set_TextMatrix(nIndex + 1, 1, szNewStat)
                End If
                ' display page number of fax
                szOldStat = m_FaxChList.get_TextMatrix(nIndex + 1, 2)
                If (szOldStat.Equals(m_FaxCh(i).szPage) = False) Then
                    m_FaxChList.set_TextMatrix(nIndex + 1, 2, m_FaxCh(i).szPage)
                End If
                'display ID of the receiver's fax machine
                m_FaxCh(i).szGetID = ""
                If (m_FaxCh(i).nStep = FaxChStep.FAX_CHECK_END) Then
                    If (SsmFaxGetID(i, strbFaxId) = -1) Then
                        WriteLog("Fail to call SsmFaxGetID")
                    End If
                End If
                m_FaxCh(i).szGetID = strbFaxId.ToString()
                szOldStat = m_FaxChList.get_TextMatrix(nIndex + 1, 3)
                If (szOldStat.Equals(m_FaxCh(i).szGetID) = False) Then
                    m_FaxChList.set_TextMatrix(nIndex + 1, 3, m_FaxCh(i).szGetID)
                End If
                If (m_FaxCh(i).nStep <> FaxChStep.FAX_IDLE) Then
                    ' display fax file name

                    If (m_FaxCh(i).nDirection = FaxDir.C_SEND_FAX) Then 'send
                        szNewStat = m_FaxCh(i).szSendFile
                    Else
                        szNewStat = m_FaxCh(i).szRcvPathFile
                    End If
                    szOldStat = m_FaxChList.get_TextMatrix(nIndex + 1, 4)
                    If (szOldStat.Equals(szNewStat) = False) Then
                        m_FaxChList.set_TextMatrix(nIndex + 1, 4, szNewStat)
                    End If

                    ' display number of bytes being sent or received
                    If (m_FaxCh(i).nDirection = FaxDir.C_SEND_FAX) Then

                        'get total number of bytes to be sent
                        m_FaxCh(i).nAllBytes = SsmFaxGetAllBytes(i)
                        'get number of bytes sent
                        m_FaxCh(i).nSendBytes = SsmFaxGetSendBytes(i)
                        szNewStat = m_FaxCh(i).nAllBytes.ToString() + ":" + m_FaxCh(i).nSendBytes.ToString()
                    Else

                        ' get number of bytes received
                        m_FaxCh(i).nRcvBytes = SsmFaxGetRcvBytes(i)
                        szNewStat = m_FaxCh(i).nRcvBytes.ToString()
                    End If
                    szOldStat = m_FaxChList.get_TextMatrix(nIndex + 1, 5)
                    If (szOldStat.Equals(szNewStat) = False) Then
                        m_FaxChList.set_TextMatrix(nIndex + 1, 5, szNewStat)

                    End If
                End If
                'display faxing state
                szNewStat = m_FaxCh(i).nCheckEnd.ToString()
                szOldStat = m_FaxChList.get_TextMatrix(nIndex + 1, 6)
                If (szOldStat.Equals(szNewStat) = False) Then
                    m_FaxChList.set_TextMatrix(nIndex + 1, 6, szNewStat)
                End If
                'display error message

                szNewStat = m_FaxCh(i).szChErrMsg
                szOldStat = m_FaxChList.get_TextMatrix(nIndex + 1, 7)
                If (szOldStat.Equals(szNewStat) = False) Then
                    m_FaxChList.set_TextMatrix(nIndex + 1, 7, szNewStat)
                End If
                nIndex = nIndex + 1
            End If
        Next i
    End Sub

    Public Sub UpdateTrunkChListCtrl()
        Dim szNewStat As String
        Dim szOldStat As String
        Dim i As Int32
        Dim nIndex As Int32
        Dim nChState As Int32
        nIndex = 0

        For i = 0 To m_nTotalCh - 1
            If (m_TrkCh(i).bEnCalled = False) Then
                Continue For
            End If

            nChState = SsmGetChState(i)
            Select Case (nChState)
                Case -1
                    szNewStat = "-1"
                Case ChState.S_CALL_STANDBY
                    szNewStat = "Idle"
                Case ChState.S_CALL_PICKUPED
                    szNewStat = "Off-hook"
                Case ChState.S_CALL_RINGING
                    szNewStat = "Ringing"
                Case ChState.S_CALL_TALKING
                    szNewStat = "Talking"
                Case ChState.S_CALL_ANALOG_WAITDIALTONE
                    szNewStat = "WtDT"
                Case ChState.S_CALL_ANALOG_TXPHONUM
                    szNewStat = "Dl.."
                Case ChState.S_CALL_ANALOG_WAITDIALRESULT
                    szNewStat = "WtDl"
                Case ChState.S_CALL_PENDING
                    szNewStat = "Pending"
                Case ChState.S_CALL_OFFLINE
                    szNewStat = "Off-line"
                Case ChState.S_CALL_WAIT_REMOTE_PICKUP
                    szNewStat = "Ringback tone"
                Case ChState.S_CALL_UNAVAILABLE
                    szNewStat = "Unavailable"
                Case ChState.S_CALL_LOCKED
                    szNewStat = "Outbound call locked"
                Case ChState.S_CALL_LocalBlock
                    szNewStat = "Local block"
                Case ChState.S_CALL_RemoteBlock
                    szNewStat = "Remote block"
                Case ChState.S_CALL_Ss1InWaitPhoNum
                    szNewStat = "Receiving called party number"
                Case ChState.S_CALL_Ss1InWaitFwdStop
                    szNewStat = "Waiting for forward signal"
                Case ChState.S_CALL_Ss1InWaitCallerID
                    szNewStat = "Receiving calling party number"
                Case ChState.S_CALL_Ss1InWaitKD
                    szNewStat = "Receiving KD"
                Case ChState.S_CALL_Ss1InWaitKDStop
                  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -