void manager_UnhandledEvent(object sender, ManagerEvent e) { log.Debug("New unhandled event received: " + e.GetType().Name); LineControl lc = null; //StateServer switch (e.GetType().Name) { case "AGIExecEvent": AGIExecEvent agievent = e as AGIExecEvent; break; case "AlarmClearEvent": AlarmClearEvent alarmclear = e as AlarmClearEvent; break; case "AlarmEvent": AlarmEvent alarmevent = e as AlarmEvent; break; case "AsyncAGIEvent": AsyncAGIEvent asyncagievent = e as AsyncAGIEvent; break; case "BridgeEvent": BridgeEvent bridgeevent = e as BridgeEvent; break; case "CdrEvent": CdrEvent cdrevent = e as CdrEvent; break; case "ChannelReloadEvent": ChannelReloadEvent channelreload = e as ChannelReloadEvent; break; case "ChannelUpdateEvent": ChannelUpdateEvent channelupdate = e as ChannelUpdateEvent; break; case "ConnectEvent": ConnectEvent connectevent = e as ConnectEvent; break; case "ConnectionStateEvent": ConnectionStateEvent connectionstate = e as ConnectionStateEvent; break; case "DBGetResponseEvent": DBGetResponseEvent dbget = e as DBGetResponseEvent; log.Debug("DBGet response: " + dbget.ToString()); switch (dbget.Family) { case "DND": ss.SetLineControl(setLineControlDND(dbget.Key, true)); break; case "CF": ss.SetLineControl(setLineControlForward(dbget.Key, dbget.Val)); break; } break; case "DialEvent": DialEvent dial = e as DialEvent; log.Debug("Dial event: " + dial.ToString()); break; case "DisconnectEvent": DisconnectEvent disconnect = e as DisconnectEvent; log.Debug("Disconnect event: " + disconnect.ToString()); break; case "DNDStateEvent": DNDStateEvent dndstate = e as DNDStateEvent; log.Debug("DND state event: " + dndstate.ToString()); break; case "ExtensionStatusEvent": ExtensionStatusEvent extensionstatus = e as ExtensionStatusEvent; log.Debug("Extension status event: " + extensionstatus.ToString() + ", status: " + extensionstatus.Status + ", hint: " + extensionstatus.Hint); ss.SetLineControl(getLineControlFromExtensionStatusEvent(extensionstatus)); break; case "FaxReceivedEvent": FaxReceivedEvent faxreceived = e as FaxReceivedEvent; break; case "HangupEvent": HangupEvent hangup = e as HangupEvent; log.Debug("Hangup event: " + hangup.ToString() + " callerid: " + hangup.CallerId + " calleridnum: " + hangup.CallerIdNum); //line control if (channels.Contains(hangup.Channel)) { lc = getLineControl((string)channels[hangup.Channel]); int hi = 0; LineControlConnection[] newLCC = null; if (lc.lineControlConnection.Length > 1) { newLCC = new LineControlConnection[lc.lineControlConnection.Length - 1]; foreach (LineControlConnection hlcc in lc.lineControlConnection) { if (hlcc.callid != hangup.Channel) { newLCC[hi] = hlcc; hi++; } } } lc.lineControlConnection = newLCC; ss.SetLineControl(lc); channels.Remove(hangup.Channel); } //missed calls callToFind = hangup.UniqueId.Substring(0, 6) + "," + hangup.UniqueId.Substring(6); Call mCall = missedCalls.Find(FindCall); if (mCall != null) { log.Debug("Missed call finded for callid: " + hangup.UniqueId); AddCallLogs(mCall.callee, mCall); if (missedCalls.Remove(mCall)) { log.Debug("Call " + mCall.callId + " successfully removed from missedcall cache"); } else { log.Debug("Call " + mCall.callId + " cannot be removed from missedcall cache"); } } break; case "HoldedCallEvent": HoldedCallEvent holdedcall = e as HoldedCallEvent; break; case "HoldEvent": HoldEvent holdevent = e as HoldEvent; break; case "JabberEvent": JabberEvent jabberevent = e as JabberEvent; break; case "JitterBufStatsEvent": JitterBufStatsEvent jitter = e as JitterBufStatsEvent; break; case "JoinEvent": JoinEvent join = e as JoinEvent; break; case "LeaveEvent": LeaveEvent leave = e as LeaveEvent; break; case "LinkEvent": LinkEvent link = e as LinkEvent; log.Debug("Link event: " + link.ToString()); lc = getLineControl(link.CallerId1); if (lc != null) { foreach (LineControlConnection linklcc in lc.lineControlConnection) { if (linklcc.callid == link.Channel1) { linklcc.contact = link.CallerId2; ss.SetLineControl(lc); break; } } } lc = getLineControl(link.CallerId2); if (lc != null) { foreach (LineControlConnection linklcc in lc.lineControlConnection) { if (linklcc.callid == link.Channel2) { linklcc.contact = link.CallerId1; ss.SetLineControl(lc); break; } } } break; case "LogChannelEvent": LogChannelEvent logchannel = e as LogChannelEvent; break; case "ManagerEvent": ManagerEvent managerevent = e; break; case "MeetmeEndEvent": MeetmeEndEvent meetmeend = e as MeetmeEndEvent; break; case "MeetmeJoinEvent": MeetmeJoinEvent meetmejoin = e as MeetmeJoinEvent; break; case "MeetmeLeaveEvent": MeetmeLeaveEvent meetmeleave = e as MeetmeLeaveEvent; break; case "MeetmeMuteEvent": MeetmeMuteEvent meetmemute = e as MeetmeMuteEvent; break; case "MeetmeStopTalkingEvent": MeetmeStopTalkingEvent meetmestoptalking = e as MeetmeStopTalkingEvent; break; case "MeetmeTalkingEvent": MeetmeTalkingEvent meetmetalking = e as MeetmeTalkingEvent; break; case "MeetmeTalkRequestEvent": MeetmeTalkRequestEvent meetmetalkrequest = e as MeetmeTalkRequestEvent; break; case "MessageWaitingEvent": MessageWaitingEvent messagewaiting = e as MessageWaitingEvent; log.Debug("Message waiting event: " + messagewaiting.ToString()); lc = getLineControl(messagewaiting.Mailbox.Substring(0, messagewaiting.Mailbox.IndexOf("@"))); if (lc != null) { if (messagewaiting.Waiting > 0) { lc.mwiOn = true; } else { lc.mwiOn = false; } ss.SetLineControl(lc); } break; case "MobileStatusEvent": MobileStatusEvent mobilestatus = e as MobileStatusEvent; break; case "ModuleLoadReportEvent": ModuleLoadReportEvent moduleload = e as ModuleLoadReportEvent; break; case "MonitorStartEvent": MonitorStartEvent monitorstart = e as MonitorStartEvent; break; case "MonitorStopEvent": MonitorStopEvent monitorstop = e as MonitorStopEvent; break; case "NewAccountCodeEvent": NewAccountCodeEvent newaccountcode = e as NewAccountCodeEvent; break; case "NewCallerIdEvent": NewCallerIdEvent newcallerid = e as NewCallerIdEvent; log.Debug("New caller id envent: " + newcallerid.ToString()); break; case "NewChannelEvent": NewChannelEvent newchannel = e as NewChannelEvent; log.Debug("New Channel event: " + newchannel.ToString()); CommandAction ca = new CommandAction("core show channel " + newchannel.Channel); CommandResponse cr = (CommandResponse)manager.SendAction(ca, 10000); log.Debug("Channel info: " + cr.ToString()); string dn = newchannel.CallerIdNum; log.Debug("Retreive call information..."); bool callerIdUnknown = true; if (newchannel.CallerIdNum != "<unknown>") { callerIdUnknown = false; } else { foreach (string s in cr.Result) { if (s.Contains("Caller ID:")) { dn = s.Substring(s.LastIndexOf(" ")); break; } } } Call newOutboundCall = getOutboundCallFromChannelInfo(cr.Result, callerIdUnknown); if (newOutboundCall != null) { Call missedCall = newOutboundCall; AddCallLogs(dn, newOutboundCall); dnToFind = newOutboundCall.callee; if (linecontrols.Find(FindLineControl) != null) { log.Debug("This call will be put in missedcall cache: " + missedCall.callId); missedCall.type = CallType.missed; missedCalls.Add(missedCall); } } break; case "NewExtenEvent": NewExtenEvent newexten = e as NewExtenEvent; log.Debug("New exten event: " + newexten.ToString()); string channel = ""; char[] splitter = { '/' }; string[] splitchannel = newexten.Channel.Split(splitter); splitter[0] = '-'; splitchannel = splitchannel[1].Split(splitter); channel = splitchannel[0]; //DND? if (newexten.Extension == Properties.Settings.Default.FeatureCodeDNDToggle && newexten.Application == "Playback") { switch (newexten.AppData) { case "do-not-disturb&activated": log.Debug("Successfully activate dnd for channel: " + channel); ss.SetLineControl(setLineControlDND(channel, true)); break; case "do-not-disturb&de-activated": log.Debug("Successfully deactivate dnd for channel: " + channel); ss.SetLineControl(setLineControlDND(channel, false)); break; } } //Forward all? else if (newexten.Extension.Contains(Properties.Settings.Default.FeatureCodeCallForwardAllActivate) && newexten.Application == "Playback" && newexten.AppData == "call-fwd-unconditional&for&extension") { string forward = newexten.Extension.Substring(Properties.Settings.Default.FeatureCodeCallForwardAllActivate.Length); log.Debug("Call forward all from channel: " + channel + " to " + forward); ss.SetLineControl(setLineControlForward(channel, forward)); } // UnForwardAll else if (newexten.Extension == Properties.Settings.Default.FeatureCodeCallForwardAllDeactivate && newexten.Application == "Playback" && newexten.AppData == "call-fwd-unconditional&de-activated") { log.Debug("Call unforward all from channel: " + channel); ss.SetLineControl(setLineControlForward(channel, "")); } break; case "NewStateEvent": NewStateEvent newstate = e as NewStateEvent; log.Debug("New State event: " + newstate.ToString()); LineControl newstateLc = getLineControl(newstate.CallerId); LineControlConnection[] newStateLccs = null; int i = 0; if (newstateLc.lineControlConnection != null) { bool isContained = false; foreach (LineControlConnection elcc in newstateLc.lineControlConnection) { if (elcc.callid == newstate.Channel) { isContained = true; newStateLccs = newstateLc.lineControlConnection; break; } i++; } if (!isContained) { i = 0; newStateLccs = new LineControlConnection[newstateLc.lineControlConnection.Length + 1]; foreach (LineControlConnection newstateLcc in newstateLc.lineControlConnection) { newStateLccs[i] = newstateLcc; i++; } } } else { newStateLccs = new LineControlConnection[1]; newStateLccs[0] = new LineControlConnection(); } try { switch (newstate.State) { case "Up": //received call? callToFind = newstate.UniqueId; Call rCall = missedCalls.Find(FindCall); if (rCall != null) { log.Debug("Missed call finded: " + callToFind + ", this call will be received"); rCall.type = CallType.received; AddCallLogs(rCall.callee, rCall); missedCalls.Remove(rCall); } if (newStateLccs != null) { if (!channels.Contains(newstate.Channel)) { channels.Add(newstate.Channel, newstate.CallerId); } newStateLccs[i].callid = newstate.Channel; newStateLccs[i].remoteState = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.established; newStateLccs[i].state = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.established; newStateLccs[i].terminalState = TerminalState.talking; } break; case "Ringing": if (newStateLccs != null) { if (!channels.Contains(newstate.Channel)) { channels.Add(newstate.Channel, newstate.CallerId); } newStateLccs[i].callid = newstate.Channel; newStateLccs[i].remoteState = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.established; newStateLccs[i].state = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.alerting; newStateLccs[i].terminalState = TerminalState.ringing; } break; case "Ring": if (newStateLccs != null) { if (!channels.Contains(newstate.Channel)) { channels.Add(newstate.Channel, newstate.CallerId); } newStateLccs[i].callid = newstate.Channel; newStateLccs[i].remoteState = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.alerting; newStateLccs[i].state = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.dialing; newStateLccs[i].terminalState = TerminalState.inuse; } break; } } catch (Exception stateException) { log.Debug("NewState exception: " + stateException.Message); } if (newstateLc != null) { newstateLc.lineControlConnection = newStateLccs; ss.SetLineControl(newstateLc); } break; case "OriginateResponseEvent": OriginateResponseEvent originateresponse = e as OriginateResponseEvent; break; case "ParkedCallEvent": ParkedCallEvent parkedcall = e as ParkedCallEvent; break; case "ParkedCallGiveUpEvent": ParkedCallGiveUpEvent parkedcallgiveup = e as ParkedCallGiveUpEvent; break; case "ParkedCallsCompleteEvent": ParkedCallsCompleteEvent parkedcallscomplete = e as ParkedCallsCompleteEvent; break; case "ParkedCallTimeOutEvent": ParkedCallTimeOutEvent parkedcalltimeout = e as ParkedCallTimeOutEvent; break; case "PeerEntryEvent": log.Debug("SipAction: one peer entry event received, " + e.ToString()); PeerEntryEvent peerentry = e as PeerEntryEvent; peers.Add(peerentry); ss.SetLineControl(getLineControlFromPeerEntry(peerentry)); break; case "PeerlistCompleteEvent": log.Debug("SipAction: peer list completed " + e.ToString()); PeerlistCompleteEvent peerlistcomplete = e as PeerlistCompleteEvent; acs.setPeers(peers); break; case "PeerStatusEvent": PeerStatusEvent peerstatus = e as PeerStatusEvent; log.Debug("Peer status: " + peerstatus.ToString()); break; case "PRIEvent": PRIEvent pri = e as PRIEvent; break; case "RegistryEvent": RegistryEvent registry = e as RegistryEvent; break; case "ReloadEvent": ReloadEvent reload = e as ReloadEvent; break; case "RenameEvent": RenameEvent rename = e as RenameEvent; break; case "ResponseEvent": ResponseEvent response = e as ResponseEvent; break; case "RTCPReceivedEvent": RTCPReceivedEvent rtcpreceived = e as RTCPReceivedEvent; break; case "RTCPSentEvent": RTCPSentEvent rtcpsent = e as RTCPSentEvent; break; case "RTPReceiverStatEvent": RTPReceiverStatEvent rtpreceiver = e as RTPReceiverStatEvent; break; case "RTPSenderStatEvent": RTPSenderStatEvent rtpsender = e as RTPSenderStatEvent; break; case "ShowDialPlanCompleteEvent": ShowDialPlanCompleteEvent showdialplan = e as ShowDialPlanCompleteEvent; break; case "ShutdownEvent": ShutdownEvent shutdown = e as ShutdownEvent; break; case "StatusCompleteEvent": StatusCompleteEvent statuscomplete = e as StatusCompleteEvent; break; case "StatusEvent": StatusEvent status = e as StatusEvent; break; case "TransferEvent": TransferEvent transfer = e as TransferEvent; break; case "UnholdEvent": UnholdEvent unhold = e as UnholdEvent; break; case "UnknownEvent": UnknownEvent unknown = e as UnknownEvent; break; case "UnlinkEvent": UnlinkEvent unlink = e as UnlinkEvent; log.Debug("Unlink event : " + unlink.ToString()); LineControlConnection[] lccs = null; i = 0; lc = getLineControl(unlink.CallerId1); if (lc != null) { if (lc.lineControlConnection.Length > 1) { lccs = new LineControlConnection[lc.lineControlConnection.Length - 1]; foreach (LineControlConnection linklcc in lc.lineControlConnection) { if (linklcc.callid != unlink.Channel1) { lccs[i] = linklcc; i++; break; } } } else { lc.lineControlConnection = null; } ss.SetLineControl(lc); } i = 0; lc = getLineControl(unlink.CallerId2); if (lc != null) { if (lc.lineControlConnection.Length > 1) { lccs = new LineControlConnection[lc.lineControlConnection.Length - 1]; foreach (LineControlConnection linklcc in lc.lineControlConnection) { if (linklcc.callid != unlink.Channel2) { lccs[i] = linklcc; i++; break; } } } else { lc.lineControlConnection = null; } ss.SetLineControl(lc); } break; case "UnparkedCallEvent": UnparkedCallEvent unparked = e as UnparkedCallEvent; break; case "UserEvent": UserEvent user = e as UserEvent; break; case "VarSetEvent": VarSetEvent varset = e as VarSetEvent; break; case "ZapShowChannelsCompleteEvent": ZapShowChannelsCompleteEvent zapshowchannelscomplete = e as ZapShowChannelsCompleteEvent; break; case "ZapShowChannelsEvent": ZapShowChannelsEvent zapshowchannels = e as ZapShowChannelsEvent; break; } //ACDConnector switch (e.GetType().Name) { case "AgentCallbackLoginEvent": AgentCallbackLoginEvent agentcallbacklogin = e as AgentCallbackLoginEvent; break; case "AgentCallbackLogoffEvent": AgentCallbackLogoffEvent agentcallbacklogoff = e as AgentCallbackLogoffEvent; break; case "AgentCalledEvent": AgentCalledEvent agentcalled = e as AgentCalledEvent; break; case "AgentCompleteEvent": AgentCompleteEvent agentcomplete = e as AgentCompleteEvent; break; case "AgentConnectEvent": AgentConnectEvent agentconnect = e as AgentConnectEvent; break; case "AgentDumpEvent": AgentDumpEvent agentdump = e as AgentDumpEvent; break; case "AgentLoginEvent": AgentLoginEvent agentlogin = e as AgentLoginEvent; break; case "AgentLogoffEvent": AgentLogoffEvent agentlogoff = e as AgentLogoffEvent; break; case "AgentsCompleteEvent": AgentsCompleteEvent agentscomplete = e as AgentsCompleteEvent; break; case "AgentsEvent": AgentsEvent agentevent = e as AgentsEvent; break; case "QueueCallerAbandonEvent": QueueCallerAbandonEvent queuecallerabandon = e as QueueCallerAbandonEvent; break; case "QueueEntryEvent": QueueEntryEvent queueentry = e as QueueEntryEvent; break; case "QueueEvent": QueueEvent queue = e as QueueEvent; break; case "QueueMemberEvent": QueueMemberEvent queuemember = e as QueueMemberEvent; break; case "QueueMemberPausedEvent": QueueMemberPausedEvent queuememberpaused = e as QueueMemberPausedEvent; break; case "QueueMemberPenaltyEvent": QueueMemberPenaltyEvent queuememberpenalty = e as QueueMemberPenaltyEvent; break; case "QueueMemberRemovedEvent": QueueMemberRemovedEvent queuememberremoved = e as QueueMemberRemovedEvent; break; case "QueueMemberStatusEvent": QueueMemberStatusEvent queuememberstatus = e as QueueMemberStatusEvent; break; case "QueueParamsEvent": QueueParamsEvent queueparams = e as QueueParamsEvent; break; case "QueueStatusCompleteEvent": QueueStatusCompleteEvent queuestatuscomplete = e as QueueStatusCompleteEvent; break; } }
private void QueueStatusCompleteEventHandler(object sender, QueueStatusCompleteEvent e) { UpdateQueueStatusRequestStateIndicator("RX OK"); SyncDataSourceWithCache(queueParamsData, _queueParamsDataCache); SyncDataSourceWithCache(queueEntriesData, _queueEntriesDataCache); }