Exemple #1
0
        private void OnCallConnected(object sender, TapiEventArgs args)
        {
            MethodInvoker m = new MethodInvoker(() =>
            {
                try
                {
                    string str = $"{Environment.MachineName}%4%{args.Call.Address.Address}%{args.Call.CallerID}";
                    if (args.Line.Name == objLine1?.Name)
                    {
                        label1.BackColor = Color.Yellow;
                        label1.Text      = $"ANSWERED BY EXT { args.Call.Address.Address} AFTER  {RINGCOUNTER1} RINGS";
                        timer1.Stop();
                        line1Record.answered = true;
                    }
                    if (args.Line.Name == objLine2?.Name)
                    {
                        label2.BackColor = Color.Yellow;
                        label2.Text      = $"ANSWERED BY EXT { args.Call.Address.Address} AFTER  {RINGCOUNTER2} RINGS";
                        timer2.Stop();
                        line2Record.answered = true;
                    }
                    AddToLog($"{args.Line.Name} CONNECTED");
                    SyncBroadcastOut(str, udpBroadCastPort);
                }
                catch (Exception ex)
                {
                }
            });

            this.Invoke(m);
        }
Exemple #2
0
        void OnCallDisconnected(object sender, TapiEventArgs args)
        {
            string msg = String.Format("Disconnected call to {0} on line '{1}'",
                                       args.Call.CalledID, args.Line.Name);

            switch (args.Call.DisconnectMode)
            {
            case TapiDisconnectMode.Busy:
                msg += ", the number was busy";
                break;

            case TapiDisconnectMode.NoAnswer:
                msg += ", there was no answer";
                break;

            case TapiDisconnectMode.NoDialTone:
                msg += ", there was no dialtone";
                break;

            case TapiDisconnectMode.Error:
                msg += ", an error occurred";
                break;
            }

            AddToLog(msg);
            Application.Exit();
        }
Exemple #3
0
        void OnLineClosed(object sender, TapiEventArgs args)
        {
            string msg = String.Format("LineClosed event, line '{0}' was forcibly closed by Windows.",
                                       args.Line.Name);

            AddToLog(msg);
            UpdateLinesCombobox();
        }
Exemple #4
0
 private void OnOutgoingCall(object sender, TapiEventArgs args)
 {
     try
     {
     }
     catch (Exception)
     {
     }
 }
Exemple #5
0
        private void OnIncommingCall(object sender, TapiEventArgs args)
        {
            MethodInvoker m = new MethodInvoker(() =>
            {
                if (objLine1 != null)
                {
                    if (args.Line.Name == objLine1.Name)
                    {
                        line1Record      = new TelRecordClass();
                        RINGCOUNTER1     = 1;
                        label1.BackColor = Color.Red;
                        label1.Text      = $"RINGING {RINGCOUNTER1}";
                        timer1.Start();
                        line1Record.answered      = false;
                        line1Record.CallbeginTime = DateTime.Now;
                        line1Record.telNumber     = args.Call.CallerID;

                        AddToLog($"{Environment.NewLine} INCOMMING CALL {objLine1} {args.Call.CallerID}");
                    }
                }
                if (objLine2 != null)
                {
                    if (args.Line.Name == objLine2.Name)
                    {
                        line2Record      = new TelRecordClass();
                        RINGCOUNTER2     = 1;
                        label2.BackColor = Color.Red;
                        label2.Text      = $"RINGING {RINGCOUNTER2}";
                        timer2.Start();
                        line2Record.answered      = false;
                        line2Record.CallbeginTime = DateTime.Now;
                        line1Record.telNumber     = args.Call.CallerID;

                        AddToLog($"{Environment.NewLine} INCOMMING CALL {objLine2} {args.Call.CallerID}");
                    }
                }
            });

            this.Invoke(m);
        }
Exemple #6
0
 private void OnLineAdded(object sender, TapiEventArgs args)
 {
 }
Exemple #7
0
        public void OnCallDisconnected(object sender, TapiEventArgs args)
        {
            //called on worker thread so marshall on to ui thread

            MethodInvoker m = new MethodInvoker(() =>
            {
                int lineNumber = 0;
                try
                {
                    if (objLine1 != null)
                    {
                        if (args.Line.Name == objLine1.Name)
                        {
                            lineNumber = 1;
                            timer1.Stop();

                            label1.BackColor = Color.White;
                            label1.Text      = "IDLE";
                        }
                    }
                    if (objLine2 != null)
                    {
                        if (args.Line.Name == objLine2.Name)
                        {
                            lineNumber = 2;
                            timer2.Stop();
                            label2.BackColor = Color.White;
                            label2.Text      = "IDLE";
                        }
                    }
                    //AddToLog($"{args.Line.Name} is Disconnected");
                    //AddToLog($"");

                    SqlConnection conn = new SqlConnection(connStr);
                    SqlCommand cmd     = new SqlCommand
                    {
                        CommandType = System.Data.CommandType.Text,
                        CommandText = "INSERT INTO TELLOG (Timemark,rings,answered,callended,line,TelNumber) VALUES (@timemark,@rings,@answered,@callended,@line,@telnumber)"
                    };

                    lineNumber = 1;
                    if (lineNumber == 1)
                    {
                        cmd.Parameters.AddWithValue("@line", 1);
                        cmd.Parameters.AddWithValue("@rings", RINGCOUNTER1);
                        cmd.Parameters.AddWithValue("@timemark", DateTime.Now);
                        cmd.Parameters.AddWithValue("@callended", DateTime.Now);
                        cmd.Parameters.AddWithValue("@answered", line1Record.answered);
                        cmd.Parameters.AddWithValue("@telnumber", line1Record.telNumber);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@line", 2);
                        cmd.Parameters.AddWithValue("@rings", RINGCOUNTER2);
                        cmd.Parameters.AddWithValue("@timemark", DateTime.Now);
                        cmd.Parameters.AddWithValue("@callended", DateTime.Now);
                        cmd.Parameters.AddWithValue("@answered", line2Record.answered);
                        cmd.Parameters.AddWithValue("@telnumber", line2Record.telNumber);
                    }
                    conn.Open();
                    cmd.Connection = conn;
                    cmd.ExecuteNonQuery();
                    label4.Text = $"LINE {lineNumber}  SAVED";
                }
                catch (Exception ex)
                {
                    label4.Text = ex.Message;
                }
            });

            this.Invoke(m);
        }
Exemple #8
0
 void OnLineRemoved(object sender, TapiEventArgs args)
 {
     UpdateLinesCombobox();
 }