private void TriggerVoiceChainOfCommands(IInteractionVoice ixnVoice, String commandName)
        {
            try
            {
                IDictionary <string, object> parameters = new Dictionary <string, object>();

                parameters.Add("CommandParameter", ixnVoice);
                // parameters.Add("OtherKey", "OtherValue");

                IChainOfCommand voiceCallCommand = commandManager.GetChainOfCommandByName(commandName);

                if (voiceCallCommand != null)
                {
                    voiceCallCommand.Execute(parameters);

                    // Async way

                    /*
                     * voiceCallCommand.BeginExecute(parameters,
                     *      delegate(IAsyncResult ar)
                     *      {
                     *          voiceCallCommand.EndExecute(ar);
                     *      }, null);
                     */
                }
            }
            catch (Exception exp)
            {
                log.Error("Exception in TriggerVoiceChainOfCommands", exp);
            }
        }
        public void RequestMakeCall(String destination, String location)
        {
            // To go to the main thread
            if (Application.Current.Dispatcher != null && !Application.Current.Dispatcher.CheckAccess())
            {
                object result = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send,
                                                                      new RequestMakeCallDelegate(RequestMakeCall), destination, location);
            }
            else
            {
                log.Info("Execute RequestMakeCall");
                try
                {
                    IDictionary <string, object> parameters = new Dictionary <string, object>();

                    parameters.Add("CommandParameter", agent.FirstMediaVoice);
                    parameters.Add("Destination", destination);
                    if (location == null)
                    {
                        location = "";
                    }
                    parameters.Add("Location", location);
                    parameters.Add("MakeCallType", Genesyslab.Enterprise.Model.Interaction.MakeCallType.Regular);

                    IChainOfCommand voiceCallCommand = commandManager.GetChainOfCommandByName("MediaVoiceMakeCall");

                    if (voiceCallCommand != null)
                    {
                        voiceCallCommand.Execute(parameters);

                        // Async way

                        /*
                         * voiceCallCommand.BeginExecute(parameters,
                         *      delegate(IAsyncResult ar)
                         *      {
                         *          voiceCallCommand.EndExecute(ar);
                         *      }, null);
                         */
                    }
                }
                catch (Exception exp)
                {
                    log.Error("Exception in RequestMakeCall", exp);
                }
            }
        }
Beispiel #3
0
        public void FireCallEvent(Dialog dialog)
        {
            try
            {
                if (Model.Dialog == null)
                {
                    Model.Dialog = Model.FinAgent.AgentInformation.SelectedDialog;
                }
                Dialog locatedDialog = null;
                if (Model.Dialog != null)
                {
                    locatedDialog = Model.FinAgent.FindDialog(Model.Dialog.ID);
                }
                if (locatedDialog == null)
                {
                    FinesseEventListener.Instance.CiscoVoices.Remove(_callId);
                    var interactionManager = container.Resolve <IInteractionManager>();
                    if (interactionManager != null)
                    {
                        //Call Terminate Event is fired and interaction will be closed. View will be unregistered now
                        var interaction = interactionManager.GetInteractionById(_interactionId);
                        if (interaction != null)
                        {
                            IChainOfCommand Command = container.Resolve <ICommandManager>().
                                                      GetChainOfCommandByName("CiscoVoiceStopProcessingCommand");
                            Utils.ExecuteAsynchronousCommand(Command,
                                                             new Dictionary <string, object>()
                            {
                                { "CommandParameter", interaction }
                            });
                            interactionManager.CloseInteraction(_interactionId);
                            interactionManager.CloseCase(_caseId);
                        }
                    }
                }
                else
                {
                    Model.ShowCallWaiting = false;
                }

                bool isCallStart = false;
                bool isCallEnd   = false;

                if (dialog.DialogEvent != null && dialog.State != null)
                {
                    if (dialog.DialogEvent.Equals("POST") && dialog.State.Equals("ALERTING")) // Call Ringing Event
                    {
                        Model.FinAgent.FireLogMessage("New Call started : Call From: " + dialog.FromAddress + " and Call To: " + dialog.ToAddress + " and dialog status is : " + dialog.State);
                        isCallStart = true;
                    }
                    else if (dialog.DialogEvent.Equals("DELETE") && dialog.State.Equals("ACTIVE")) // Call Terminated and call will be Transferred
                    {
                        Model.FinAgent.FireLogMessage("Call Termination event as you released the call : Call From: " + dialog.FromAddress + " and Call To: " + dialog.ToAddress);
                        isCallEnd = true;
                    }
                    else if (dialog.DialogEvent.Equals("DELETE") && dialog.State.Equals("DROPPED")) // Call Terminated and caller hangup
                    {
                        if (!dialog.MediaProperties.DNIS.Equals("8999") && !dialog.MediaProperties.DNIS.Equals("8999"))
                        {
                            Model.FinAgent.FireLogMessage("Call Termination event and caller dropped the call : Call From: " + dialog.FromAddress + " and Call To: " + dialog.ToAddress);
                            isCallEnd = true;
                        }
                    }
                    else if (dialog.DialogEvent.Equals("DELETE")) // Call Terminated and caller hangup for any other reason
                    {
                        if (!dialog.MediaProperties.DNIS.Equals("8999") && !dialog.MediaProperties.DNIS.Equals("8999"))
                        {
                            Model.FinAgent.FireLogMessage("Call Termination event  : Call From: " + dialog.FromAddress + " and Call To: " + dialog.ToAddress + ", Call State is: " + dialog.State);
                            isCallEnd = true;
                        }
                    }
                    else if (dialog.DialogEvent.Equals("RunningCall") && !dialog.State.Equals("DROPPED") && !dialog.State.Equals("FAILED")) // We found running call
                    {
                        if (!dialog.MediaProperties.DNIS.Equals("8999") && !dialog.MediaProperties.DNIS.Equals("8999"))
                        {
                            Model.FinAgent.FireLogMessage("Call running event and call still active : Call From: " + dialog.FromAddress + " and Call To: " + dialog.ToAddress);
                            isCallStart = true;
                        }
                    }
                }
                else
                {
                    foreach (Dialog.Participant participant in dialog.Participants)
                    {
                        if (participant.MediaAddress.Equals(Model.FinAgent.AgentInformation.Extension)) //Checking my status
                        {
                            if (participant.State.Equals("DROPPED"))                                    // call is not active , and this is call terminate event
                            {
                                Model.FinAgent.FireLogMessage("We received message event without event discription. Seems system just started while call was active, we will terminate the call without firing end event");
                            }
                            else if (participant.State.Equals("INITIATING"))
                            {
                                Model.FinAgent.FireLogMessage("We received message event without event discription. Seems system just started while call is active, your status is: " + participant.State);
                            }
                        }
                    }
                }

                if (isCallStart)
                {
                    try
                    {
                    }
                    catch (Exception e)
                    {
                        Model.FinAgent.FireErrorMessage("Application: Error in call initiation in fire call event" + e.Message);
                        Model.FinAgent.FireDebugLogMessage("Application: Error in call initiation in fire call event\n" + e.StackTrace);
                        return;
                    }
                }

                if (isCallEnd)
                {
                    try
                    {
                        FinesseEventListener.Instance.CiscoVoices.Remove(_callId);
                        var interactionManager = container.Resolve <IInteractionManager>();
                        if (interactionManager != null)
                        {
                            //Call Terminate Event is fired and interaction will be closed. View will be unregistered now
                            var interaction = interactionManager.GetInteractionById(_interactionId);
                            if (interaction != null)
                            {
                                IChainOfCommand Command = container.Resolve <ICommandManager>().
                                                          GetChainOfCommandByName("CiscoVoiceStopProcessingCommand");
                                Utils.ExecuteAsynchronousCommand(Command,
                                                                 new Dictionary <string, object>()
                                {
                                    { "CommandParameter", interaction }
                                });
                                interactionManager.CloseInteraction(_interactionId);
                                interactionManager.CloseCase(_caseId);
                            }
                        }


                        string CICFormatted = null;

                        //CIC Exist
                        if (((CallVariableClass)dialog.MediaProperties.CallVariables[3]).Value != null)
                        {
                            //check the CIC length is 16 digits
                            CICFormatted = ((CallVariableClass)dialog.MediaProperties.CallVariables[3]).Value;
                            string customerCIC = "123492";
                            CICFormatted = customerCIC;

                            while (CICFormatted.Length < 16)
                            {
                                CICFormatted = "0" + CICFormatted;
                            }
                        }
                        if (CICFormatted == null)
                        {
                            CICFormatted = "NA";
                        }


                        Dictionary <string, string> data = new Dictionary <string, string>();
                        data.Add("CallVar4", CICFormatted);
                        data.Add("InetractionID", dialog.ID);
                        data.Add("CaseID", "NA");
                        data.Add("AgentID", FinesseEventListener.Instance.FinAgent.AgentInformation.AgentID);
                        data.Add("AgentExt", FinesseEventListener.Instance.FinAgent.AgentInformation.Extension);
                        data.Add("FromAddress", dialog.FromAddress);
                        data.Add("ToAddress", dialog.ToAddress);
                        // data.Add("DialNumber", dialog.MediaProperties.DialedNumber);
                        data.Add("DialNumber", "8016");

                        //We should popup interaction ID now
                        WSEventListener.Instance.FireWSEvent(data, EventType.CALL, EventDirection.END);
                    }
                    catch (Exception e)
                    {
                        Model.FinAgent.FireErrorMessage("Application: Error in call termination during fire call event" + e.Message);
                        Model.FinAgent.FireDebugLogMessage("Application: Error in call termination in fire call event\n" + e.StackTrace);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Model.FinAgent.FireLogMessage("Application Error during fire call event, ex:" + ex.Message + "\nStack trace\n" + ex.StackTrace + "\nMore\n" + ex.ToString());
                Model.FinAgent.FireErrorMessage("Application Error during fire call event");
            }
        }