void BtnStartNMon_Click(object sender, RoutedEventArgs e) { try { var item = ListViewExtState.SelectedItem as ExtStateItem; if (item == null) { return; } mNMonItem = item; if (mNMonClient != null) { mNMonClient.Stop(); mNMonClient = null; } mNMonClient = new NetClient(); mNMonClient.Debug += (mode, cat, msg) => AppendMessage(string.Format("[NMonClient]{0}\t{1}", cat, msg)); mNMonClient.ConnectionEvent += NMonClient_ConnectionEvent; mNMonClient.ReturnMessageReceived += NMonClient_ReturnMessageReceived; mNMonClient.NotifyMessageReceived += NMonClient_NotifyMessageReceived; mNMonClient.IsSSL = true; mNMonClient.Host = "192.168.6.63"; mNMonClient.Port = 8081 - 10; mNMonClient.Connect(); } catch (Exception ex) { ShowException(ex.Message); } }
private void InitExtStateItems() { try { mListExtStateItems.Clear(); ExtStateItem item = new ExtStateItem(); item.Extension = "1130"; mListExtStateItems.Add(item); item = new ExtStateItem(); item.Extension = "3002"; mListExtStateItems.Add(item); } catch (Exception ex) { ShowException(ex.Message); } }
private void UpdateExtItemState(ExtStateItem item) { try { ExtensionInfo extInfo = item.ExtensionInfo; if (extInfo == null) { return; } var stateInfo = extInfo.ListStateInfos.FirstOrDefault(s => s.StateType == Service10Consts.STATE_TYPE_LOGIN); if (stateInfo != null) { item.StrLoginState = ((LoginState)stateInfo.State).ToString(); item.AgentID = extInfo.AgentID; } stateInfo = extInfo.ListStateInfos.FirstOrDefault(s => s.StateType == Service10Consts.STATE_TYPE_CALL); if (stateInfo != null) { item.StrCallState = ((CallState)stateInfo.State).ToString(); } stateInfo = extInfo.ListStateInfos.FirstOrDefault(s => s.StateType == Service10Consts.STATE_TYPE_RECORD); if (stateInfo != null) { item.StrRecordState = ((RecordState)stateInfo.State).ToString(); if (stateInfo.State == (int)RecordState.All) { item.RecordReference = string.Format("V:{0} S:{1}", extInfo.VocRecordReference, extInfo.ScrRecordReference); item.StartRecordTime = string.Format("V:{0} S:{1}", extInfo.VocStartRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), extInfo.ScrStartRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")); item.StopRecordTime = string.Empty; item.RecordLength = string.Format("V:{0} S:{1}", extInfo.VocRecordLength, extInfo.ScrRecordLength); } else if (stateInfo.State == (int)RecordState.Voice) { item.RecordReference = extInfo.VocRecordReference; item.StartRecordTime = extInfo.VocStartRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); item.StopRecordTime = string.Empty; item.RecordLength = extInfo.VocRecordLength.ToString(); } else if (stateInfo.State == (int)RecordState.Screen) { item.RecordReference = extInfo.ScrRecordReference; item.StartRecordTime = extInfo.ScrStartRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); item.StopRecordTime = string.Empty; item.RecordLength = extInfo.ScrRecordLength.ToString(); } else { item.RecordReference = string.Empty; item.StartRecordTime = string.Empty; if (extInfo.VocStopRecordTime > DateTime.Parse("2014/1/1") && extInfo.ScrStopRecordTime > DateTime.Parse("2014/1/1")) { item.StopRecordTime = string.Format("V:{0} S:{1}", extInfo.VocStopRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), extInfo.ScrStopRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")); } else if (extInfo.VocStopRecordTime > DateTime.Parse("2014/1/1")) { item.StopRecordTime = extInfo.VocStopRecordTime.ToLocalTime() .ToString("yyyy-MM-dd HH:mm:ss"); } else if (extInfo.ScrStopRecordTime > DateTime.Parse("2014/1/1")) { item.StopRecordTime = extInfo.ScrStopRecordTime.ToLocalTime() .ToString("yyyy-MM-dd HH:mm:ss"); } else { item.StopRecordTime = string.Empty; } item.RecordLength = string.Empty; } } stateInfo = extInfo.ListStateInfos.FirstOrDefault(s => s.StateType == Service10Consts.STATE_TYPE_DIRECTION); if (stateInfo != null) { item.StrDirectionState = ((DirectionState)stateInfo.State).ToString(); item.CallerID = extInfo.CallerID; item.CalledID = extInfo.CalledID; } stateInfo = extInfo.ListStateInfos.FirstOrDefault(s => s.StateType == Service10Consts.STATE_TYPE_AGENT); if (stateInfo != null) { item.StrAgentState = ((AgentState)stateInfo.State).ToString(); } } catch (Exception ex) { AppendMessage(ex.Message); } }