Beispiel #1
0
        public void UpdateInfo(ChanState info)
        {
            Extension       = info.Extension;
            AgentID         = info.AgentID;
            LoginState      = info.LoginState;
            CallState       = info.CallState;
            RecordState     = info.RecordState;
            RecordReference = info.RecordReference;
            DirectionFlag   = info.DirectionFlag;
            CallerID        = info.CallerID;
            CalledID        = info.CalledID;
            StartRecordTime = info.StartRecordTime;
            StopRecordTime  = info.StopRecordTime;
            RecordLength    = info.RecordLength;

            StrLoginState      = LoginState.ToString();
            StrCallState       = CallState.ToString();
            StrRecordState     = RecordState.ToString();
            StrDirection       = DirectionFlag.ToString();
            StrStartRecordTime = StartRecordTime.ToString("yyyy-MM-dd HH:mm:ss");
            StrStopRecordTime  = StopRecordTime.ToString("yyyy-MM-dd HH:mm:ss");
            StrRecordLength    = RecordLength.ToString();

            Info = info;
        }
 public object Convert(object value, Type targetType, object parameter, string language)
 {
     if (value is CallState)
     {
         CallState state = (CallState)value;
         return(state.ToString());
         //switch (state)
         //{
         //    case CallState.ActiveTalking:
         //        return "\uE717";
         //    case CallState.Dialing:
         //        return "\uF715";
         //    case CallState.Disconnected:
         //        return "\uE778";
         //    case CallState.Incoming:
         //        return "\uE77E";
         //    case CallState.OnHold:
         //        return "\uE769";
         //    case CallState.Transfering:
         //        return "\uE7F2";
         //    case CallState.Count:
         //        return "\uE80B";
         //    case CallState.Indeterminate:
         //    default:
         //        return "";
         //}
     }
     else
     {
         throw new ArgumentException();
     }
 }
Beispiel #3
0
 private void HandleCallStateUpdate(VoipCall call, CallState newState)
 {
     this.UpdatedItemProprertyDetected(this, new UpdatedPropertyInItemeventArgs()
     {
         ParsedItem       = GetCall(call),
         PropertyChanged  = typeof(VoipCall).GetProperty("CallState"),
         NewPropertyValue = newState.ToString()
     });
 }
        private void CallStateChangedHandler(object sender, VoIPEventArgs <CallState> e)
        {
            CallState callState = e.Item;

            _log.Debug("State change to " + callState.ToString());
            if (callState == CallState.InCall)
            {
                CallAnswered();
            }
            else if (callState == CallState.Completed)
            {
                CallEnded();
            }
            else
            {
                _log.Debug("Unhandled call state " + callState.ToString());
            }
        }
        public override void OnCallStateChanged(CallState state, string incomingNumber)
        {
            _stateChangedHandler?.Invoke(this, new CallStateChangedEventArgs
            {
                CallState   = state.ToString(),
                PhoneNumber = incomingNumber
            });

            base.OnCallStateChanged(state, incomingNumber);
        }
Beispiel #6
0
        void Process_ROUTEREQUEST()
        {
            // this.parent.SleepMS(200);      //  before send next command , wait 200 ms

            CallState randomBar = (CallState)MyLib.Rand.RandomInt(1, 3);

            //Console.WriteLine("callID is {0} and random is {1}", Paras[0], randomBar.ToString());
            Log.Write("callID is {0} and random is {1}", this.CallID, randomBar.ToString());


            switch (randomBar)
            {
            case (CallState.FullFail):
            {
                for (int j = 0; j < this.routeList.Count; j++)
                {
                    string sTrySend = (new CMD_OUTGOINGTRYFAIL(
                                           this.CallID
                                           , this.routeList[j].SRC
                                           , this.routeList[j].DST
                                           , this.routeList[j].NAPName
                                           , this.routeList[j].IP
                                           , DateTime.Now
                                           , DateTime.Now
                                           , DateTime.Now
                                           )).Encode();

                    //Console.WriteLine(sTrySend);
                    Log.Write(sTrySend);

                    byte[] bData = Encoding.ASCII.GetBytes(sTrySend);
                    this.parent.client.Send(bData);
                    //this.parent.SleepMS(200);
                }

                //loctl.Remove(octl);
            }
            break;

            case (CallState.Success):
            {
                // make a randome number , decide which time trying will success
                Random r    = new Random();
                int    rInt = r.Next(0, this.routeList.Count - 1);

                if (rInt == 0)           // mean success from the first trying
                {
                    string sTrySend = (new CMD_OUTGOINGTRYSUCCESS(
                                           this.CallID
                                           , this.routeList[0].SRC
                                           , this.routeList[0].DST
                                           , this.routeList[0].NAPName
                                           , this.routeList[0].IP
                                           , DateTime.Now
                                           , DateTime.Now
                                           )).Encode();

                    //Console.WriteLine(sTrySend);
                    Log.Write(sTrySend);
                    byte[] bData = Encoding.ASCII.GetBytes(sTrySend);
                    this.routeList[0].IfSuccess   = true;
                    this.routeList[0].SuccessTime = DateTime.Now;

                    this.parent.client.Send(bData);
                }
                else
                {
                    for (int j = 0; j < rInt; j++)
                    {
                        string sTrySend = (new CMD_OUTGOINGTRYFAIL(
                                               this.CallID
                                               , this.routeList[j].SRC
                                               , this.routeList[j].DST
                                               , this.routeList[j].NAPName
                                               , this.routeList[j].IP
                                               , DateTime.Now
                                               , DateTime.Now
                                               , DateTime.Now
                                               )).Encode();
                        //Console.WriteLine(sTrySend);
                        Log.Write(sTrySend);
                        byte[] bData = Encoding.ASCII.GetBytes(sTrySend);
                        this.parent.client.Send(bData);
                        this.parent.SleepMS(200);
                    }

                    string sTrySendFinal = (new CMD_OUTGOINGTRYSUCCESS(
                                                this.CallID
                                                , this.routeList[rInt].SRC
                                                , this.routeList[rInt].DST
                                                , this.routeList[rInt].NAPName
                                                , this.routeList[rInt].IP
                                                , DateTime.Now
                                                , DateTime.Now
                                                )).Encode();

                    //Console.WriteLine(sTrySendFinal);
                    Log.Write(sTrySendFinal);

                    byte[] bDataFinal = Encoding.ASCII.GetBytes(sTrySendFinal);

                    this.routeList[rInt].IfSuccess   = true;
                    this.routeList[rInt].SuccessTime = DateTime.Now;

                    this.parent.client.Send(bDataFinal);
                }
            }
            break;

            case (CallState.FailCozInterrupt):
            {
                Random r    = new Random();
                int    rInt = r.Next(0, this.routeList.Count - 1);

                for (int j = 0; j < rInt; j++)
                {
                    string sTrySend = (new CMD_OUTGOINGTRYFAIL(
                                           this.CallID
                                           , this.routeList[j].SRC
                                           , this.routeList[j].DST
                                           , this.routeList[j].NAPName
                                           , this.routeList[j].IP
                                           , DateTime.Now
                                           , DateTime.Now
                                           , DateTime.Now
                                           )).Encode();

                    //Console.WriteLine(sTrySend);
                    Log.Write(sTrySend);
                    byte[] bData = Encoding.ASCII.GetBytes(sTrySend);
                    this.parent.client.Send(bData);
                    //this.parent.SleepMS(200);
                }
            }
            break;
            }    //  end switch
        }
Beispiel #7
0
        /// <summary>
        /// 更新状态信息
        /// </summary>
        public void UpdateState()
        {
            if (Info == null)
            {
                return;
            }
            switch (ObjType)
            {
            case ConstValue.RESOURCE_AGENT:
            case ConstValue.RESOURCE_EXTENSION:
                if (Info.ChanObjID <= 0)
                {
                    LoginState  = LoginState.LogOff;
                    CallState   = CallState.Idle;
                    RecordState = RecordState.None;
                }
                else
                {
                    if (ChanState != null)
                    {
                        Extension       = ChanState.Extension;
                        AgentID         = ChanState.AgentID;
                        LoginState      = ChanState.LoginState;
                        CallState       = ChanState.CallState;
                        RecordState     = ChanState.RecordState;
                        RecordReference = ChanState.RecordReference;
                        DirectionFlag   = ChanState.DirectionFlag;
                        CallerID        = ChanState.CallerID;
                        CalledID        = ChanState.CalledID;
                        StartRecordTime = ChanState.StartRecordTime;
                        StopRecordTime  = ChanState.StopRecordTime;
                        DealRecordLength(ChanState);
                    }
                }
                break;
            }
            StrIcon       = Icon;
            StrLoginState = LoginState == LoginState.LogOff
                ? string.Empty
                : App.GetLanguageInfo(
                string.Format("BID{0}{1}", S2102Consts.BID_LOGSTATE, ((int)LoginState).ToString("000")),
                LoginState.ToString());
            StrCallState = CallState == CallState.Idle ? string.Empty : App.GetLanguageInfo(
                string.Format("BID{0}{1}", S2102Consts.BID_CALLSTATE, ((int)CallState).ToString("000")),
                CallState.ToString());
            StrRecordState = RecordState == RecordState.None ? string.Empty : App.GetLanguageInfo(
                string.Format("BID{0}{1}", S2102Consts.BID_RECORDSTATE, ((int)RecordState).ToString("000")),
                RecordState.ToString());
            StrDirection = DirectionFlag == 1
                ? App.GetLanguageInfo("2102014", "Callin")
                : App.GetLanguageInfo("2102015", "Callout");
            StrStartRecordTime = StartRecordTime > DateTime.Parse("2014/1/1")
                ? StartRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")
                : string.Empty;
            StrStopRecordTime = StopRecordTime > DateTime.Parse("2014/1/1")
                ? StopRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")
                : string.Empty;
            StrRecordLength = RecordLength > 0 ? Converter.Second2Time(RecordLength) : "00:00:00";

            Background = Brushes.Transparent;
            if (LoginState == LoginState.LogOn)
            {
                Background = Brushes.Wheat;
                if (ListUserParams != null)
                {
                    var userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_COLOR_VOCLOGINSTATE);
                    if (userParam != null)
                    {
                        try
                        {
                            Color color = Utils.GetColorFromRgbString(userParam.ParamValue);
                            Background = new SolidColorBrush(color);
                        }
                        catch { }
                    }
                }
            }
            if (RecordState == RecordState.Recoding)
            {
                Background = Brushes.Thistle;
                if (DirectionFlag == 1)
                {
                    Background = Brushes.Thistle;
                }
                else
                {
                    Background = Brushes.Violet;
                }
                if (ListUserParams != null)
                {
                    var userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_COLOR_VOCRECORDSTATE);
                    if (userParam != null)
                    {
                        try
                        {
                            Color color = Utils.GetColorFromRgbString(userParam.ParamValue);
                            Background = new SolidColorBrush(color);
                        }
                        catch { }
                    }
                    if (DirectionFlag == 1)
                    {
                        userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_COLOR_CALLINSTATE);
                        if (userParam != null)
                        {
                            try
                            {
                                Color color = Utils.GetColorFromRgbString(userParam.ParamValue);
                                Background = new SolidColorBrush(color);
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_COLOR_CALLOUTSTATE);
                        if (userParam != null)
                        {
                            try
                            {
                                Color color = Utils.GetColorFromRgbString(userParam.ParamValue);
                                Background = new SolidColorBrush(color);
                            }
                            catch { }
                        }
                    }
                }
            }

            IsLogged    = LoginState == LoginState.LogOn;
            IsRecording = RecordState == RecordState.Recoding;

            if (IsRecording)
            {
                try
                {
                    StrRecordLength = Converter.Second2Time(RecordLength);
                }catch {}
            }
            else
            {
                StrRecordLength = string.Empty;
            }

            try
            {
                StrVoiceFormat = ((EVLVoiceFormat)VoiceFormat).ToString();
            }catch {}
        }