Exemplo n.º 1
0
        public void RecordState_ToString_1()
        {
            RecordState state = new RecordState();

            Assert.AreEqual("0:0:0", state.ToString());

            state = _GetState();
            Assert.AreEqual("234:32:345", state.ToString());
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
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 {}
        }