예제 #1
0
        void Component_OnNewEvent(object sender, QsysInternalEventsArgs e)
        {
            switch (e.Name)
            {
            case "call_offhook":
                if (e.Value == 1)
                {
                    hookState = true;
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerOffHook, cName, true, 1, "1", null));
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerCurrentlyCalling, cName, true, currentlyCalling.Length, currentlyCalling, null));

                    if (onOffHookEvent != null)
                    {
                        onOffHookEvent(1);
                    }

                    if (onCurrentlyCallingEvent != null)
                    {
                        onCurrentlyCallingEvent(currentlyCalling);
                    }
                }
                else if (e.Value == 0)
                {
                    hookState = false;
                    dialString.Remove(0, dialString.Length);
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerOffHook, cName, false, 0, "0", null));

                    if (onOffHookEvent != null)
                    {
                        onOffHookEvent(0);
                    }


                    lastCalled       = currentlyCalling;
                    currentlyCalling = string.Empty;
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerCurrentlyCalling, cName, false, currentlyCalling.Length, currentlyCalling, null));
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerDialString, cName, false, 0, dialString.ToString(), null));

                    if (onCurrentlyCallingEvent != null)
                    {
                        onCurrentlyCallingEvent(currentlyCalling);
                    }

                    if (onDialStringEvent != null)
                    {
                        onDialStringEvent(dialString.ToString());
                    }
                }
                break;

            case "call_ringing":
                if (e.Value == 1)
                {
                    ringingState = true;
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerIsRinging, cName, true, 1, "1", null));

                    if (onRingingEvent != null)
                    {
                        onRingingEvent(1);
                    }
                }
                else if (e.Value == 0)
                {
                    ringingState = false;
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerIsRinging, cName, false, 0, "0", null));

                    if (onRingingEvent != null)
                    {
                        onRingingEvent(0);
                    }
                }
                break;

            case "call_autoanswer":
                autoAnswer = Convert.ToBoolean(e.Value);
                //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerAutoAnswerChange, cName, autoAnswer, Convert.ToInt16(e.Value), Convert.ToString(Convert.ToInt16(e.Value)), null));

                if (onAutoAnswerEvent != null)
                {
                    onAutoAnswerEvent(Convert.ToUInt16(e.Value));
                }

                break;

            case "call_dnd":
                dnd = Convert.ToBoolean(e.Value);
                //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerDND_Change, cName, dnd, Convert.ToInt16(e.Value), Convert.ToString(Convert.ToInt16(e.Value)), null));

                if (onDndEvent != null)
                {
                    onDndEvent(Convert.ToUInt16(e.Value));
                }

                break;

            case "call_status":
                callStatus = e.SValue;
                //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerCallStatusChange, cName, true, e.SValue.Length, e.SValue, null));

                if (onCurrentCallStatusChange != null)
                {
                    onCurrentCallStatusChange(e.SValue);
                }

                if (callStatus.Contains("Dialing") && dialingState == false)
                {
                    dialingState = true;
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerDialing, cName, true, 1, "true", null));

                    if (onDialingEvent != null)
                    {
                        onDialingEvent(1);
                    }
                }
                else if (dialingState == true)
                {
                    dialingState = false;

                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerDialing, cName, false, 0, "false", null));

                    if (onDialingEvent != null)
                    {
                        onDialingEvent(0);
                    }
                }

                if (callStatus.Contains("Incoming Call"))
                {
                    incomingCall = true;
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerIncomingCall, cName, true, 1, "true", null));

                    if (onIncomingCallEvent != null)
                    {
                        onIncomingCallEvent(1);
                    }
                }
                else if (incomingCall == true)
                {
                    incomingCall = false;
                    //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerIncomingCall, cName, false, 0, "false", null));

                    if (onIncomingCallEvent != null)
                    {
                        onIncomingCallEvent(0);
                    }
                }
                break;

            case "recent_calls":
                recentCalls.Clear();
                foreach (var choice in e.Choices)
                {
                    var newChoice = JsonConvert.DeserializeObject <ListBoxChoice>(choice);
                    recentCalls.Add(newChoice);
                }
                //QsysPotsControllerEvent(this, new QsysEventsArgs(eQscEventIds.PotsControllerRecentCallsChange, cName, Convert.ToBoolean(recentCalls.Count), recentCalls.Count, recentCalls.Count.ToString(), recentCalls));

                if (onRecentCallsEvent != null)
                {
                    List <string> calls = new List <string>()
                    {
                        string.Empty, string.Empty, string.Empty, string.Empty, string.Empty
                    };

                    for (int i = 0; i <= 4; i++)
                    {
                        if (recentCalls.Count > i)
                        {
                            calls[i] = recentCalls[i].Text;
                        }
                        else
                        {
                            break;
                        }
                    }
                    onRecentCallsEvent(calls[0], calls[1], calls[2], calls[3], calls[4]);
                }
                if (onRecentCallListEvent != null)
                {
                    List <string> calls = new List <string>();

                    foreach (var call in calls)
                    {
                        var encodedBytes = XSig.GetBytes(calls.IndexOf(call), call);
                        onRecentCallListEvent(Encoding.GetEncoding(28591).GetString(encodedBytes, 0, encodedBytes.Length));
                    }
                }

                break;

            default:
                break;
            }
        }
예제 #2
0
        void softphone_QsysPotsControllerEvent(object sender, QsysEventsArgs e)
        {
            switch (e.EventID)
            {
            case eQscEventIds.NewCommand:
                break;

            case eQscEventIds.GainChange:
                break;

            case eQscEventIds.MuteChange:
                break;

            case eQscEventIds.NewMaxGain:
                break;

            case eQscEventIds.NewMinGain:
                break;

            case eQscEventIds.CameraStreamChange:
                break;

            case eQscEventIds.PotsControllerOffHook:
                if (onOffHookEvent != null)
                {
                    onOffHookEvent(Convert.ToUInt16(e.IntegerValue));
                }
                break;

            case eQscEventIds.PotsControllerIsRinging:
                if (onRingingEvent != null)
                {
                    onRingingEvent(Convert.ToUInt16(e.IntegerValue));
                }
                break;

            case eQscEventIds.PotsControllerDialString:
                if (onDialStringEvent != null)
                {
                    onDialStringEvent(e.StringValue);
                }
                break;

            case eQscEventIds.PotsControllerCurrentlyCalling:
                if (onCurrentlyCallingEvent != null)
                {
                    onCurrentlyCallingEvent(e.StringValue);
                }
                break;

            case eQscEventIds.RouterInputSelected:
                break;

            case eQscEventIds.PotsControllerAutoAnswerChange:
                if (onAutoAnswerEvent != null)
                {
                    onAutoAnswerEvent(Convert.ToUInt16(e.BooleanValue));
                }
                break;

            case eQscEventIds.PotsControllerDND_Change:
                if (onDndEvent != null)
                {
                    onDndEvent(Convert.ToUInt16(e.BooleanValue));
                }
                break;

            case eQscEventIds.PotsControllerCallStatusChange:
                if (onCurrentCallStatusChange != null)
                {
                    onCurrentCallStatusChange(e.StringValue);
                }
                break;

            case eQscEventIds.PotsControllerRecentCallsChange:
                if (onRecentCallsEvent != null)
                {
                    List <string> calls = new List <string>();

                    foreach (var call in e.ListValue)
                    {
                        fullRecentCallList.Add(call.Text);
                    }

                    if (e.ListValue.Count > 0)
                    {
                        calls.Add(e.ListValue[0].Text);
                    }
                    else
                    {
                        calls.Add(string.Empty);
                    }

                    if (e.ListValue.Count > 1)
                    {
                        calls.Add(e.ListValue[1].Text);
                    }
                    else
                    {
                        calls.Add(string.Empty);
                    }

                    if (e.ListValue.Count > 2)
                    {
                        calls.Add(e.ListValue[2].Text);
                    }
                    else
                    {
                        calls.Add(string.Empty);
                    }

                    if (e.ListValue.Count > 3)
                    {
                        calls.Add(e.ListValue[3].Text);
                    }
                    else
                    {
                        calls.Add(string.Empty);
                    }

                    if (e.ListValue.Count > 4)
                    {
                        calls.Add(e.ListValue[4].Text);
                    }
                    else
                    {
                        calls.Add(string.Empty);
                    }

                    onRecentCallsEvent(calls[0], calls[1], calls[2], calls[3], calls[4]);
                }
                if (onRecentCallListEvent != null)
                {
                    List <string> calls = new List <string>();

                    foreach (var call in calls)
                    {
                        var encodedBytes = XSig.GetBytes(calls.IndexOf(call), call);
                        onRecentCallListEvent(Encoding.GetEncoding(28591).GetString(encodedBytes, 0, encodedBytes.Length));
                    }
                }
                break;

            case eQscEventIds.PotsControllerDialing:
                if (e.BooleanValue && onDialingEvent != null)
                {
                    onDialingEvent(1);
                }
                else if (onDialingEvent != null)
                {
                    onDialingEvent(0);
                }
                break;

            case eQscEventIds.PotsControllerIncomingCall:
                if (e.BooleanValue && onIncomingCallEvent != null)
                {
                    onIncomingCallEvent(1);
                }
                else if (onIncomingCallEvent != null)
                {
                    onIncomingCallEvent(0);
                }
                break;

            default:
                break;
            }
        }