示例#1
0
 private void EscribirDesdeCola()
 {
     try
     {
         DatosLog log;
         while (!_cancellationTokenEscribirLog.IsCancellationRequested)
         {
             if (!ColaLogs.TryDequeue(out log))
             {
                 Thread.Sleep(1000);
                 continue;
             }
             if (log == null)
             {
                 continue;
             }
             var newPath = CreatePathLog(DirectoryLog, FileName);
             var writer  = File.AppendText(newPath);
             writer.WriteLine($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff")};{log.fecha.ToString("yyyy/MM/dd HH:mm:ss.fff")};{log.logdata}");
             writer.Close();
         }
     }
     catch (Exception ex)
     {
         EventError?.Invoke(MethodBase.GetCurrentMethod().Name + ex);
     }
 }
 /// <summary>
 /// Popup SFDC Records on EventError Event
 /// </summary>
 /// <param name="eventError"></param>
 /// <param name="callType"></param>
 public void PopupRecords(EventError eventError, SFDCCallType callType)
 {
     try
     {
         this._logger.Info("EventError PopupRecords method Invoke");
         if (Settings.ClickToDialData.ContainsKey(eventError.ConnID.ToString()))
         {
             this._voiceEvents.GetClickToDialLogs(eventError, eventError.ConnID.ToString(),
                                                  callType, Settings.ClickToDialData[eventError.ConnID.ToString()], "error");
         }
         else if (Settings.SFDCOptions.EnablePopupDialedFromDesktop)
         {
             if (callType == SFDCCallType.OutboundVoiceFailure)
             {
                 _sfdcPopupData = this._voiceEvents.GetOutboundFailurePopupData(eventError, callType, "error");
                 if (_sfdcPopupData != null)
                 {
                     _sfdcPopupData.InteractionId = eventError.ConnID.ToString();
                     this._searchHandler.ProcessSearchData(eventError.ConnID.ToString(), _sfdcPopupData, callType);
                 }
                 else
                 {
                     this._logger.Info("Search data is empty");
                 }
             }
         }
     }
     catch (Exception generalException)
     {
         _logger.Info("CallEventError : Error Occurred  : " + generalException.ToString());
     }
 }
        public void CheckMessage(int code, string message)
        {
            var utc = DateTime.UtcNow;
            var err = new EventError((interfaces.EventError)(code), utc);

            Assert.AreEqual(err.Message, message);
        }
        /// <summary>
        /// Agents the logout.
        /// </summary>
        /// <param name="proxyId">The proxy identifier.</param>
        /// <returns></returns>
        public OutputValues AgentLogout(int proxyId)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestAgentLogout requestAgentlogout = RequestAgentLogout.Create();
                requestAgentlogout.ProxyClientId = proxyId;

                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestAgentlogout);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAgentLogout = (EventAck)message;
                            logger.Info("-------------AgentLogout----------------");
                            logger.Info("ProxyClientId    :" + proxyId);
                            logger.Info("Name    :" + eventAgentLogout.Name.ToString());
                            logger.Info("----------------------------------------");
                            logger.Trace(eventAgentLogout.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Agent Logout Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError            = (EventError)message;
                            string     LoginErrorCode        = Convert.ToString(eventError.ErrorCode);
                            string     LoginErrorDescription = Convert.ToString(eventError.ErrorDescription);
                            logger.Trace(eventError.ToString());
                            output.ErrorCode   = eventError.ErrorCode;
                            output.MessageCode = "2002";
                            output.Message     = "AgentLogout() : " + LoginErrorDescription;
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Agent Logout UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("AgentLogout() : Interaction Server Protocol is Null..");
                }
            }
            catch (Exception commonException)
            {
                logger.Error("Error occurred while Agent Logout request " + commonException.ToString());
                output.MessageCode = "2001";
                output.Message     = commonException.Message;
            }
            return(output);
        }
示例#5
0
 private void LiveConsume()
 {
     Receive <DataResponse>(c =>
     {
         for (var i = 0; i < c.Data.Count; i++)
         {
             var msgData      = c.Data.ElementAt(i);
             var msg          = msgData["__message_id__"].ToString().Trim('(', ')').Split(',').Select(int.Parse).ToArray();
             var messageId    = MessageIdUtils.GetOffset(new MessageId(msg[0], msg[1], msg[2]));
             var eventMessage = new EventEnvelope(msgData, messageId, _topicName.ToString());
             _buffer.Post(eventMessage);
             _currentOffset = messageId;
         }
         _buffer.Post(new EventStats(new StatsResponse(c.StatementStats)));
     });
     Receive <StatsResponse>(s =>
     {
         var stats = new EventStats(s);
         _buffer.Post(stats);
     });
     Receive <ErrorResponse>(s =>
     {
         var error = new EventError(s);
         _buffer.Post(error);
     });
     _queryCancelable = _scheduler.ScheduleOnceCancelable(TimeSpan.FromSeconds(60), Query);
 }
 private void Consume()
 {
     Receive<DataResponse>(c =>
     {
         for (var i = 0; i < c.Data.Count; i++)
         {
             var msgData = c.Data.ElementAt(i);
             var msg = msgData["__message_id__"].ToString().Trim('(', ')').Split(',').Select(int.Parse).ToArray();
             var messageId = MessageIdUtils.GetOffset(new MessageId(msg[0], msg[1], msg[2]));
             if (messageId <= _toMessageId) 
             { 
                 var eventMessage = new EventEnvelope(msgData, messageId, _topicName.ToString());
                 _buffer.Post(eventMessage);
                 _currentOffset = messageId;
             }
             else Self.GracefulStop(TimeSpan.FromSeconds(5));
         }
         _buffer.Post(new EventStats(new StatsResponse(c.StatementStats)));
     });
     Receive<StatsResponse>(s =>
     {
         var stats = new EventStats(s);
         _buffer.Post(stats);
     });
     Receive<ErrorResponse>(s =>
     {
         var error = new EventError(s);
         _buffer.Post(error);
     });
     Receive<ReceiveTimeout>(t => { Self.GracefulStop(TimeSpan.FromSeconds(5)); });
     //to track last sequence id for lagging player
     Context.SetReceiveTimeout(TimeSpan.FromSeconds(30));
 }
        public void InvalidCode()
        {
            var utc = DateTime.UtcNow;

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                var _ = new EventError((interfaces.EventError)(-1), utc);
            });
        }
        public void ValuesAreSaved()
        {
            var utc = DateTime.UtcNow;
            const interfaces.EventError code = interfaces.EventError.Aborted;
            var err = new EventError(code, utc);

            Assert.AreEqual(err.Code, code);
            Assert.AreEqual(err.DateTimeUtc, utc);
        }
示例#9
0
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        internal OutputValues AuthenticateUser(string userName, string password)
        {
            OutputValues output = new OutputValues();

            try
            {
                RequestAuthenticate requestAuthenticate = RequestAuthenticate.Create(userName, password);
                IMessage            response            = ProtocolManagers.Instance().ProtocolManager[ServerType.Configserver.ToString()].Request(requestAuthenticate);
                if (response != null)
                {
                    switch (response.Id)
                    {
                    case EventAuthenticated.MessageId:
                    {
                        output.MessageCode = "200";
                        output.Message     = "User " + userName + "  Authenticated ";
                        _logger.Info("User " + userName + "  Authenticated ");

                        CfgPersonQuery qPerson = new CfgPersonQuery();
                        qPerson.UserName = userName;

                        CfgPerson person = _configContainer.ConfServiceObject.RetrieveObject <CfgPerson>(qPerson);
                        if (person != null)
                        {
                            CfgTenant tenant = person.Tenant;
                            if (tenant != null)
                            {
                                _configContainer.TenantDbId = tenant.DBID;
                            }
                        }
                        break;
                    }

                    case EventError.MessageId:
                    {
                        EventError eventError = (EventError)response;
                        if (eventError.Description != null)
                        {
                            _logger.Warn("User " + userName + "  is not Authenticated   " + eventError.Description);
                        }
                        output.MessageCode = "2001";
                        output.Message     = "User " + userName + "  not Authenticated ";
                        _logger.Warn("User " + userName + "  is not Authenticated   ");
                        break;
                    }
                    }
                }
            }
            catch (Exception commonException)
            {
                _logger.Error("Error occurred while authenticating user " + userName + "  " + commonException.ToString());
            }
            return(output);
        }
示例#10
0
        private void Parse(string s)
        {
            // КОМАНДА=ЗНАЧЕНИЕ (LOGIN=Иван)
            char[] sep = { '=' };
            var    cd  = s.Split(sep, 2);

            switch (cd[0])
            {
            case "LOGIN":
            {
                LoginCmdReceived?.Invoke(cd[0], cd[1]);
                break;
            }

            case "LOGIN1":
            {
                EventError?.Invoke(0);
                break;
            }

            case "MESSAGE":
            {
                MessageCmdReceived?.Invoke(cd[0], cd[1]);
                break;
            }

            case "MESSAGE1":
            {
                PrivateMessage?.Invoke(cd[0], cd[1]);
                break;
            }

            case "USERLIST":
            {
                UserListCmdReceived?.Invoke(cd[0], cd[1]);
                break;
            }

            case "START":
            {
                StartCmdReceived?.Invoke(cd[0], cd[1]);
                break;
            }

            case "ERROR":
            {
                EventComment?.Invoke("Нет пользователя");
                break;
            }
            }
        }
示例#11
0
        /// <summary>
        /// Funcion que escribe los datos en una linea de un archivo de texto.
        /// </summary>
        /// <param name="logdata"></param>
        /// <param name="estacion"></param>
        /// <param name="carril"></param>
        private void Escribir(string logdata, string carril)
        {
            lock (_writeAsync)
            {
                try
                {
                    var time    = DateTime.Now;
                    var newpath = CreatePathLog(DirectoryLog, FileName);

                    var writer = File.AppendText(newpath);
                    writer.WriteLine(time.ToString("yyyy/MM/dd HH:mm:ss.fff") + ";" + logdata);
                    writer.Close();
                }
                catch (Exception ex)
                {
                    EventError?.Invoke(MethodBase.GetCurrentMethod().Name + ex);
                }
            }
        }
示例#12
0
        internal static bool AuthenticateUser(string userName, string password)
        {
            bool output = false;

            try
            {
                RequestAuthenticate requestAuthenticate = RequestAuthenticate.Create(userName, password);
                IMessage            response            = _configContainer.ConfServiceObject.Protocol.Request(requestAuthenticate);
                if (response != null)
                {
                    switch (response.Id)
                    {
                    case EventAuthenticated.MessageId:
                    {
                        output = true;
                        _logger.Info("User " + userName + "  Authenticated ");
                        break;
                    }

                    case EventError.MessageId:
                    {
                        EventError eventError = (EventError)response;
                        if (eventError.Description != null)
                        {
                            _logger.Warn("User " + userName + "  is not Authenticated   " + eventError.Description);
                        }
                        output = false;
                        _logger.Warn("User " + userName + "  is not Authenticated   ");
                        break;
                    }
                    }
                }
            }
            catch (Exception commonException)
            {
                _logger.Error("Error occurred while authenticating user " + userName + "  " + commonException.ToString());
            }
            return(output);
        }
        public static void CloseStatistics(int referenceId)
        {
            try
            {
                RequestCloseStatistic closeStatistics = RequestCloseStatistic.Create(referenceId);
                if (referenceId >= 5000)
                {
                    IMessage response = ((StatServerProtocol)ProtocolManagers.Instance().ProtocolManager[ServerType.Statisticsserver.ToString()]).Request(closeStatistics);

                    if (response != null)
                    {
                        switch (response.Id)
                        {
                        case EventStatisticOpened.MessageId:
                            EventStatisticOpened info = (EventStatisticOpened)response;
                            _logger.Trace("RequestStatistics Method : EventStatisticsOpened : " + info.Name);
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)response;
                            _logger.Trace("RequestStatistics Method : EventError : " + eventError.StringValue);
                            break;

                        case EventStatisticClosed.MessageId:
                            EventStatisticClosed statisticClosed = (EventStatisticClosed)response;
                            _logger.Trace("StatisticClosed : EventStatisticClosed : " + statisticClosed.ReferenceId);
                            break;
                        }
                    }
                }
            }
            catch (Exception generalException)
            {
                _logger.Error("Error occurred while closing the statistics with Ref Id : " + referenceId + " " +
                              (generalException.InnerException == null ? generalException.Message : generalException.InnerException.ToString()));
            }
        }
示例#14
0
        public override async Task ExecuteAsync(ICommandInsertUDSData command)
        {
            _logger.WriteInfo(new LogMessage(string.Concat(command.CommandName, " is arrived")), LogCategories);

            Guid?  collaborationUniqueId;
            string collaborationTemplateName;
            int?   collaborationId;

            try
            {
                _logger.WriteInfo(new LogMessage(string.Concat(command.ContentType.Id, " model evaluating ... ")), LogCategories);
                UDSEntityModel udsEntityModel = await InsertDataAsync(command.ContentType.ContentTypeValue, command.Identity.User, command.CreationTime);

                command.ContentType.ContentTypeValue.UniqueId = udsEntityModel.IdUDS;
                ResetModelXML(command.ContentType.ContentTypeValue);

                collaborationId           = udsEntityModel.Relations.Collaborations.FirstOrDefault()?.IdCollaboration;
                collaborationUniqueId     = udsEntityModel.Relations.Collaborations.FirstOrDefault()?.CollaborationUniqueId;
                collaborationTemplateName = udsEntityModel.Relations.Collaborations.FirstOrDefault()?.CollaborationTemplateName;

                IEventInsertUDSData evt = new EventInsertUDSData(command.CorrelationId, command.TenantName, command.TenantId, command.TenantAOOId, command.Identity,
                                                                 command.ContentType.ContentTypeValue);
                evt.CorrelatedMessages.Add(command);
                if (!await PushEventAsync(evt))
                {
                    throw new Exception("EventInsertUDSData not sent");
                }

                UDSBuildModel    udsBuildModel    = MapUDSModel(command.ContentType.ContentTypeValue, udsEntityModel);
                CategoryFascicle categoryFascicle = await GetPeriodicCategoryFascicleByEnvironment(udsEntityModel.IdCategory.Value, command.ContentType.ContentTypeValue.UDSRepository.DSWEnvironment);

                if (categoryFascicle == null)
                {
                    categoryFascicle = await GetDefaultCategoryFascicle(udsEntityModel.IdCategory.Value);
                }
                ICommandCQRSCreateUDSData commandCQRS = new CommandCQRSCreateUDSData(command.TenantName, command.TenantId, command.TenantAOOId, command.Identity, udsBuildModel, categoryFascicle, null,
                                                                                     collaborationUniqueId, collaborationId, collaborationTemplateName);
                if (command.CorrelationId.HasValue)
                {
                    commandCQRS = new CommandCQRSCreateUDSData(command.CorrelationId.Value, command.TenantName, command.TenantId, command.TenantAOOId, command.Identity, udsBuildModel, categoryFascicle, null,
                                                               collaborationUniqueId, collaborationId, collaborationTemplateName);
                }
                if (udsBuildModel.WorkflowActions != null)
                {
                    foreach (IWorkflowAction workflowAction in udsBuildModel.WorkflowActions)
                    {
                        commandCQRS.WorkflowActions.Add(workflowAction);
                    }
                }
                if (!await PushCommandAsync(commandCQRS))
                {
                    throw new Exception("CommandCQRSCreateUDSData not sent");
                }
                #region [ EventCompleteUDSBuild ]
                IEventCompleteUDSBuild eventCompleteUDSBuild = new EventCompleteUDSBuild(Guid.NewGuid(), command.CorrelationId, command.TenantName, command.TenantId, command.TenantAOOId,
                                                                                         command.Identity, udsBuildModel, null);
                if (!await PushEventAsync(eventCompleteUDSBuild))
                {
                    _logger.WriteError(new LogMessage($"EventCompleteUDSBuild {udsBuildModel.UniqueId} has not been sended"), LogCategories);
                    throw new Exception("IEventCompleteUDSBuild not sended");
                }
                _logger.WriteInfo(new LogMessage($"EventCompleteUDSBuild {udsBuildModel.UniqueId} has been sended"), LogCategories);
                #endregion
            }
            catch (Exception ex)
            {
                ResetModelXML(command.ContentType.ContentTypeValue);
                IEventError evt = new EventError(command.CorrelationId, command.TenantName, command.TenantId, command.TenantAOOId, command.Identity,
                                                 new ContentTypeString($"Errore in fase di inserimento nell'archivio [{ex.Message}]"), null);
                evt.CorrelatedMessages.Add(command);
                if (!await PushEventAsync(evt))
                {
                    throw new Exception("EventError not sent");
                }
                throw ex;
            }

            _logger.WriteInfo(new LogMessage("message completed."), LogCategories);
        }
        public string SubmitNewInteraction(int tenantId, int proxyClientId, string queuename, KeyValueCollection userdata)
        {
            string interactionID = string.Empty;

            try
            {
                RequestSubmit requestSumbit = RequestSubmit.Create();
                requestSumbit.TenantId           = tenantId;
                requestSumbit.ProxyClientId      = proxyClientId;
                requestSumbit.Queue              = queuename;
                requestSumbit.InteractionType    = "Outbound";
                requestSumbit.InteractionSubtype = "OutboundNew";
                requestSumbit.MediaType          = "email";
                requestSumbit.UserData           = userdata;

                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestSumbit);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAck = (EventAck)message;
                            logger.Info("------------Submit New Email Interaction-------------");
                            logger.Info("TenantID  :" + requestSumbit.TenantId);
                            logger.Info("ProxyClientId  :" + requestSumbit.ProxyClientId);
                            logger.Info("Queue  :" + requestSumbit.Queue);
                            logger.Info("InteractionType        :" + requestSumbit.InteractionType);
                            logger.Info("InteractionSubtype        :" + requestSumbit.InteractionSubtype);
                            logger.Info("MediaType        :" + requestSumbit.MediaType);
                            logger.Info("UserData        :" + requestSumbit.UserData.ToString());
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventAck.ToString());
                            if (eventAck.Extension.ContainsKey("InteractionId"))
                            {
                                interactionID = eventAck.Extension["InteractionId"].ToString();
                            }
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Info("------------Error on Submitting new  Interaction-------------");
                            logger.Info("TenantID  :" + requestSumbit.TenantId);
                            logger.Info("ProxyClientId  :" + requestSumbit.ProxyClientId);
                            logger.Info("Queue  :" + requestSumbit.Queue);
                            logger.Info("InteractionType        :" + requestSumbit.InteractionType);
                            logger.Info("InteractionSubtype        :" + requestSumbit.InteractionSubtype);
                            logger.Info("MediaType        :" + requestSumbit.MediaType);
                            logger.Info("UserData        :" + requestSumbit.UserData.ToString());
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventError.ToString());
                            interactionID = string.Empty;
                            logger.Error("Error occurred while submittting new interaction : " + Convert.ToString(eventError.ErrorDescription));
                            break;
                        }
                    }
                    else
                    {
                        interactionID = string.Empty;
                    }
                }
                else
                {
                    logger.Warn("PlaceInWorkbin() : Interaction Server protocol is Null..");
                    interactionID = string.Empty;
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while submit the new email interaction" + generalException.ToString());
                interactionID = string.Empty;
            }
            return(interactionID);
        }
        /// <summary>
        /// Agents the ready.
        /// </summary>
        /// <param name="proxyClientId">The proxy client identifier.</param>
        /// <param name="mediaType">Type of the media.</param>
        /// <returns></returns>
        public OutputValues AgentNotReadyWithReason(int proxyClientId, string mediaType, string reason, string code)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                KeyValueCollection ReasonCode = new KeyValueCollection();
                if (!string.IsNullOrEmpty(reason))
                {
                    ReasonCode.Add("Name", reason);
                    ReasonCode.Add("Code", code);
                }
                RequestChangeMediaStateReason requestChangeMediaStateReason = RequestChangeMediaStateReason.Create(proxyClientId, ReasonCode, mediaType, ReasonInfo.Create(mediaType, reason, Convert.ToInt32(code)));
                //requestChangeMediaStateReason.ProxyClientId = proxyClientId;
                //requestChangeMediaStateReason.MediaTypeName = mediaType;

                //requestChangeMediaStateReason.Extension = ReasonCode;
                //requestChangeMediaStateReason.Reason = ReasonInfo.Create(mediaType, reason, Convert.ToInt32(code));

                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestChangeMediaStateReason);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAgentNotReady = (EventAck)message;
                            logger.Info("----------------AgentNotReadyWithReason-------------");
                            logger.Info("ProxyClientId    :" + proxyClientId);
                            logger.Info("MediaTypeName    :" + mediaType);
                            logger.Info("Name    :" + eventAgentNotReady.Name.ToString());
                            logger.Info("Reason Name    :" + reason);
                            logger.Info("Reason Code    :" + code);
                            logger.Info("----------------------------------------------------");
                            logger.Trace(eventAgentNotReady.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Agent Not Ready with reason Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError            = (EventError)message;
                            string     LoginErrorCode        = Convert.ToString(eventError.ErrorCode);
                            string     LoginErrorDescription = Convert.ToString(eventError.ErrorDescription);
                            logger.Trace(eventError.ToString());
                            output.ErrorCode   = eventError.ErrorCode;
                            output.MessageCode = "2002";
                            output.Message     = "AgentNotReadyWithReason() : " + LoginErrorDescription;
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Agent Not Ready with reason UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("AgentNotReadyWithReason() : Interaction Server Protocol is Null..");
                }
            }
            catch (Exception commonException)
            {
                logger.Error("Error occurred while Agent Not Ready with reason request " + commonException.ToString());
                output.MessageCode = "2001";
                output.Message     = commonException.Message;
            }
            return(output);
        }
        public OutputValues NotifyWorbin(int proxyClientId, string workbinType, string worbinEmpId, string workbinGroupId = null, string WorkbinPlaceId = null, string workbinPlaceGroupId = null)
        {
            OutputValues outPutValues = new OutputValues();

            outPutValues.Message     = string.Empty;
            outPutValues.MessageCode = string.Empty;
            outPutValues.ErrorCode   = 0;
            KeyValueCollection keyVC = new KeyValueCollection();

            keyVC.Add("event_processing_stopped", 1);
            try
            {
                RequestWorkbinNotifications reqWorkbinNotifications = RequestWorkbinNotifications.Create();
                reqWorkbinNotifications.Workbin = WorkbinInfo.Create(workbinType);
                reqWorkbinNotifications.Workbin.WorkbinAgentId = worbinEmpId;
                if (!string.IsNullOrEmpty(workbinGroupId))
                {
                    reqWorkbinNotifications.Workbin.WorkbinGroupId = workbinGroupId;
                }
                if (!string.IsNullOrEmpty(workbinPlaceGroupId))
                {
                    reqWorkbinNotifications.Workbin.WorkbinPlaceGroupId = workbinPlaceGroupId;
                }
                if (!string.IsNullOrEmpty(WorkbinPlaceId))
                {
                    reqWorkbinNotifications.Workbin.WorkbinPlaceId = WorkbinPlaceId;
                }
                reqWorkbinNotifications.Reason                = ReasonInfo.Create();
                reqWorkbinNotifications.ProxyClientId         = proxyClientId;
                reqWorkbinNotifications.NotifyPropertyChanges = 1;
                reqWorkbinNotifications.Extension             = keyVC;
                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(reqWorkbinNotifications);

                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck _requestWorkbinNotifications = (EventAck)message;
                            logger.Info("------------Request Workbin Notifications-------------");
                            logger.Trace(_requestWorkbinNotifications.ToString());
                            outPutValues.MessageCode = "200";
                            logger.Trace(_requestWorkbinNotifications.ProxyClientId);
                            outPutValues.Message = "Request Workbin Notifications Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Trace(eventError.ToString());
                            outPutValues.MessageCode = "2001";
                            outPutValues.Message     = "NotifyWorbin() : " + Convert.ToString(eventError.ErrorDescription);
                            break;
                        }
                    }
                }
            }
            catch (Exception error)
            {
                logger.Error(error.Message.ToString());
                outPutValues.MessageCode = "2001";
                outPutValues.Message     = "NotifyWorbin() : " + error.Message.ToString();
            }

            return(outPutValues);
        }
示例#18
0
        public void ReceiveCalls(IMessage events, TimeSpan?callDuration = null)
        {
            try
            {
                if (Settings.SFDCOptions.SFDCPopupPages != null)
                {
                    if (events != null)
                    {
                        try
                        {
                            this._logger.Info("ReceiveCalls: Voice Event Received : " + events.ToString());
                        }
                        catch
                        {
                            this._logger.Error("Error occurred while printing Voice Event in Log");
                        }
                        switch (events.Id)
                        {
                            #region EventRinging

                        case EventRinging.MessageId:
                            _eventRinging    = (EventRinging)events;
                            IsCallTransfered = false;
                            ConsultText      = string.Empty;
                            if (_eventRinging.UserData != null && _eventRinging.UserData.ContainsKey(Settings.SFDCOptions.ConsultAttachDataKey))
                            {
                                IsCallTransfered = true;
                                ConsultText      = _eventRinging.UserData.GetAsString(Settings.SFDCOptions.ConsultAttachDataKey);
                                this._logger.Info("EventRinging : Consult Attach data key found for the ConnId :" + _eventRinging.ConnID.ToString() + " value : " + ConsultText);
                            }

                            if (_eventRinging.CallType == CallType.Inbound)
                            {
                                if (!IsCallTransfered)
                                {
                                    _isConsultCallReceived = false;
                                    CallRinging.GetInstance().PopupRecords(_eventRinging, SFDCCallType.InboundVoice);
                                }
                                else
                                {
                                    _isConsultCallReceived = true;
                                    this._consultConnId    = _eventRinging.ConnID.ToString();
                                    CallRinging.GetInstance().PopupRecords(_eventRinging, SFDCCallType.ConsultVoiceReceived);
                                }
                            }
                            else if (_eventRinging.CallType == CallType.Consult)
                            {
                                _isConsultCallReceived = true;
                                CallRinging.GetInstance().PopupRecords(_eventRinging, SFDCCallType.ConsultVoiceReceived);
                            }
                            else if (_eventRinging.CallType == CallType.Outbound)
                            {
                                if (IsCallTransfered)
                                {
                                    _isConsultCallReceived = true;
                                    this._consultConnId    = _eventRinging.ConnID.ToString();
                                    CallRinging.GetInstance().PopupRecords(_eventRinging, SFDCCallType.ConsultVoiceReceived);
                                }
                            }
                            break;

                            #endregion EventRinging

                            #region EventPartyChanged

                        case EventPartyChanged.MessageId:
                            EventPartyChanged partyChanged = (EventPartyChanged)events;
                            _isConsultCallReceived = true;
                            if (_callDurationData.ContainsKey(partyChanged.PreviousConnID.ToString()) && !_callDurationData.ContainsKey(partyChanged.ConnID.ToString()))
                            {
                                _callDurationData.Add(partyChanged.ConnID.ToString(), _callDurationData[partyChanged.PreviousConnID.ToString()]);
                            }
                            if (Settings.UpdateSFDCLog.ContainsKey(partyChanged.PreviousConnID.ToString()))
                            {
                                if (!Settings.UpdateSFDCLog.ContainsKey(partyChanged.ConnID.ToString()))
                                {
                                    Settings.UpdateSFDCLog.Add(partyChanged.ConnID.ToString(), Settings.UpdateSFDCLog[partyChanged.PreviousConnID.ToString()]);
                                }
                                else
                                {
                                    Settings.UpdateSFDCLog[partyChanged.ConnID.ToString()] = Settings.UpdateSFDCLog[partyChanged.PreviousConnID.ToString()];
                                }
                            }
                            this._consultConnId = partyChanged.ConnID.ToString();

                            if (partyChanged.UserData != null && partyChanged.UserData.ContainsKey(Settings.SFDCOptions.ConsultAttachDataKey))
                            {
                                IsCallTransfered = true;
                                ConsultText      = partyChanged.UserData.GetAsString(Settings.SFDCOptions.ConsultAttachDataKey);
                                this._logger.Info("PartyChanged : Consult Attach data key found for the ConnId :" + partyChanged.ConnID.ToString() + " value : " + ConsultText);
                            }

                            string duration = "0 Hr 0 Mins 0 Secs";
                            if (_callDurationData.ContainsKey(partyChanged.ConnID.ToString()))
                            {
                                TimeSpan ts = System.DateTime.Now.Subtract(_callDurationData[partyChanged.ConnID.ToString()]);
                                duration = ts.Hours + " Hr " + ts.Minutes + " Mins " + ts.Seconds + " Secs";
                            }
                            CallPartyChanged.GetInstance().PopupRecords(partyChanged, SFDCCallType.ConsultVoiceReceived, duration);
                            break;

                            #endregion EventPartyChanged

                            #region EventDialing

                        case EventDialing.MessageId:
                            _eventDialing = (EventDialing)events;
                            if (Settings.SFDCListener.Click2EmailData.ContainsKey("ClickToDial"))
                            {
                                //Settings.ClickToDialData.Add(_eventDialing.ConnID.ToString(), _eventDialing.Reasons.GetAsString("ClickToDial"));
                                Settings.ClickToDialData.Add(_eventDialing.ConnID.ToString(), Settings.SFDCListener.Click2EmailData["ClickToDial"]);
                                Settings.SFDCListener.Click2EmailData.Clear();
                            }
                            if (_eventDialing.CallType == CallType.Unknown || _eventDialing.CallType == CallType.Outbound)
                            {
                                CallDialing.GetInstance().PopupRecords(_eventDialing, SFDCCallType.OutboundVoiceSuccess);
                            }

                            break;

                            #endregion EventDialing

                            #region EventEstablished

                        case EventEstablished.MessageId:

                            eventEstablished = (EventEstablished)events;
                            if (!_callDurationData.ContainsKey(eventEstablished.ConnID.ToString()))
                            {
                                _callDurationData.Add(eventEstablished.ConnID.ToString(), System.DateTime.Now);
                            }
                            if (eventEstablished.CallType == CallType.Inbound)
                            {
                                if (_isConsultCallReceived)
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.ConsultVoiceReceived);
                                }
                                else
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.InboundVoice);
                                }
                            }
                            else if (eventEstablished.CallType == CallType.Unknown || eventEstablished.CallType == CallType.Outbound)
                            {
                                if (_isConsultCallReceived)
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.ConsultVoiceReceived);
                                }
                                else
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.OutboundVoiceSuccess);
                                }
                            }
                            else if (eventEstablished.CallType == CallType.Consult)
                            {
                                if (_isConsultCallReceived)
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.ConsultVoiceReceived);
                                }
                            }
                            break;

                            #endregion EventEstablished

                            #region EventReleased

                        case EventReleased.MessageId:

                            _eventReleased = (EventReleased)events;
                            this._logger.Info("Event Release Call State: " + _eventReleased.CallState.ToString());
                            if (_eventReleased.CallState != 22)
                            {
                                if (Settings.SFDCOptions.CanUseGenesysCallDuration && callDuration != null)
                                {
                                    _callDuration = callDuration.Value.Hours + " Hr " + callDuration.Value.Minutes + " Mins " + callDuration.Value.Seconds + " Secs";;
                                    this._logger.Info("ConnectionId : " + _eventReleased.ConnID.ToString() + " Call duration is " + _callDuration);
                                }
                                else if (_callDurationData.ContainsKey(_eventReleased.ConnID.ToString()))
                                {
                                    TimeSpan ts = System.DateTime.Now.Subtract(_callDurationData[_eventReleased.ConnID.ToString()]);
                                    _callDuration = ts.Hours + " Hr " + ts.Minutes + " Mins " + ts.Seconds + " Secs";
                                    this._logger.Info("ConnectionId : " + _eventReleased.ConnID.ToString() + " Call duration is " + _callDuration);

                                    if (!FinishedCallDuration.ContainsKey(_eventReleased.ConnID.ToString()))
                                    {
                                        FinishedCallDuration.Add(_eventReleased.ConnID.ToString(), _callDuration);
                                    }
                                    else
                                    {
                                        FinishedCallDuration[_eventReleased.ConnID.ToString()] = _callDuration;
                                    }
                                }
                                else
                                {
                                    _callDuration = "0 Hr 0 Mins 0 Secs";
                                    this._logger.Info("Call duration not found for the connection Id : " + _eventReleased.ConnID.ToString());
                                }
                                HandleReleaseEvent(_eventReleased, _callDuration);
                            }
                            else
                            {
                                this._logger.Info("The call has been rejected for the connectionId : " + _eventReleased.ConnID.ToString());
                                HandleCallRejected(_eventReleased, "0 Hr 0 Mins 0 Secs");
                            }

                            break;

                            #endregion EventReleased

                            #region EventError

                        case EventError.MessageId:
                            EventError eventError = (EventError)events;
                            this._logger.Info("EventError occurred for the connectionId : " + eventError.ConnID.ToString());
                            if (eventError.CallType == CallType.Outbound)
                            {
                                CallEventError.GetInstance().PopupRecords(eventError, SFDCCallType.OutboundVoiceFailure);
                            }

                            break;

                            #endregion EventError

                            #region EventAbandoned

                        case EventAbandoned.MessageId:
                            EventAbandoned eventAbandoned = (EventAbandoned)events;
                            this._logger.Info("EventAbandoned occurred for the connectionId : " + eventAbandoned.ConnID.ToString());
                            if (eventAbandoned.CallType == CallType.Outbound)
                            {
                                CallEventAbandoned.GetInstance().PopupRecords(eventAbandoned, SFDCCallType.OutboundVoiceFailure);
                            }

                            break;

                            #endregion EventAbandoned

                            #region EventDestinationBusy

                        case EventDestinationBusy.MessageId:
                            EventDestinationBusy destinationBusyEvent = (EventDestinationBusy)events;
                            this._logger.Info("EventDestinationBusy occurred for the connectionId : " + destinationBusyEvent.ConnID.ToString());
                            if (destinationBusyEvent.CallType == CallType.Outbound)
                            {
                                CallEventDestinationBusy.GetInstance().PopupRecords(destinationBusyEvent, SFDCCallType.OutboundVoiceFailure);
                            }

                            break;

                            #endregion EventDestinationBusy

                        default:
                            _logger.Info("ReceiveCalls: Unhandled Event " + events.Name);
                            break;
                        }
                    }
                }
            }
            catch (Exception generalException)
            {
                _logger.Error("ReceiveCalls: Error occurred while receiving voice events " + generalException.ToString());
            }
        }
 private void OnConfEventError(IMessage theMessage)
 {
     EventError eventError = theMessage as EventError;
 }
        public OutputValues GetInteractionProperties(int proxyClientId, string interactionId)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestGetInteractionProperties requestGetInteractionProperties = RequestGetInteractionProperties.Create();
                requestGetInteractionProperties.InteractionId = interactionId;
                requestGetInteractionProperties.ProxyClientId = proxyClientId;


                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestGetInteractionProperties);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventInteractionProperties.MessageId:
                            EventInteractionProperties eventInteractionProperties = (EventInteractionProperties)message;
                            logger.Info("------------Get Interaction Properties-------------");
                            logger.Info("InteractionID  :" + interactionId);
                            logger.Info("ProxyID        :" + proxyClientId);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventInteractionProperties.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Place in Queue Successful";
                            output.IMessage    = message;
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Info("------------Error on getting interaction properties-------------");
                            logger.Info("InteractionID  :" + interactionId);
                            logger.Info("ProxyID        :" + proxyClientId);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = Convert.ToString(eventError.ErrorDescription);
                            logger.Warn("Error occurred while getting interaction properties : " + Convert.ToString(eventError.ErrorDescription));
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Get Interaction Properties UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("GetInteractionProperties() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while getting interaction properties " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
示例#21
0
 private void ActiveEventError(string message)
 {
     EventError?.Invoke(message);
 }
        /// <summary>
        /// Accepts the interaction.
        /// </summary>
        /// <param name="ticketID">The ticket identifier.</param>
        /// <param name="interactionID">The interaction identifier.</param>
        /// <param name="proxyID">The proxy identifier.</param>
        /// <returns></returns>
        public OutputValues AcceptInteraction(int ticketID, string interactionID, int proxyID)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestAccept requestAccept = RequestAccept.Create();
                requestAccept.TicketId      = ticketID;
                requestAccept.InteractionId = interactionID;
                requestAccept.ProxyClientId = Convert.ToInt32(proxyID);
                //added 27-02-2015
                requestAccept.InitialInFocusState = true;
                //end
                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestAccept);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAck = (EventAck)message;
                            logger.Info("------------Accepted  Interaction-------------");
                            logger.Info("TicketID  :" + ticketID);
                            logger.Info("InteractionID  :" + interactionID);
                            logger.Info("ProxyID        :" + proxyID);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventAck.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Accept Interaction Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Info("------------Error on Email Interaction-------------");
                            logger.Info("TicketID  :" + ticketID);
                            logger.Info("InteractionID  :" + interactionID);
                            logger.Info("ProxyID        :" + proxyID);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = Convert.ToString(eventError.ErrorDescription);
                            logger.Error("Error occurred while accepting the interaction : " + Convert.ToString(eventError.ErrorDescription));
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Agent Not Ready UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("AcceptChatInteraction() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Accept the request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
示例#23
0
 private void EVSdkWrapper_EventError(EVErrorCli error)
 {
     WorkerThreadManager.Instance.EVSdkWorkDispatcher.InvokeAsync(() => {
         EventError?.Invoke(error);
     });
 }
        public OutputValues RequestPlaceWorkbin(string interactionId, string agentId,
                                                //string placeId,
                                                string workbin, int proxyId)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                WorkbinInfo workbinInfo = WorkbinInfo.Create();
                workbinInfo.WorkbinAgentId = agentId;
                //  workbinInfo.WorkbinPlaceId = placeId;
                workbinInfo.WorkbinTypeId = workbin;

                RequestPlaceInWorkbin requestPlaceInWorkbin = RequestPlaceInWorkbin.Create();
                requestPlaceInWorkbin.InteractionId = interactionId;
                requestPlaceInWorkbin.ProxyClientId = proxyId;

                requestPlaceInWorkbin.Workbin = workbinInfo;

                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestPlaceInWorkbin);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAck = (EventAck)message;
                            logger.Info("------------PlaceInWorkbin-------------");
                            logger.Info("AgentID  :" + agentId);
                            logger.Info("InteractionID  :" + interactionId);
                            // logger.Info("PlaceID  :" + placeId);
                            logger.Info("ProxyID        :" + proxyId);
                            logger.Info("Workbin        :" + workbin);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventAck.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Place in Workbin Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Info("------------Error on Email Interaction-------------");
                            logger.Info("AgentID  :" + agentId);
                            logger.Info("InteractionID  :" + interactionId);
                            // logger.Info("PlaceID  :" + placeId);
                            logger.Info("ProxyID        :" + proxyId);
                            logger.Info("Workbin        :" + workbin);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = Convert.ToString(eventError.ErrorDescription);
                            logger.Error("Error occurred while placeinworkbin : " + Convert.ToString(eventError.ErrorDescription));
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Place in Workbin UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("PlaceInWorkbin() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Accept the request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
示例#25
0
        /// <summary>
        /// Rejects the interaction.
        /// </summary>
        /// <param name="ticketID">The ticket identifier.</param>
        /// <param name="interactionID">The interaction identifier.</param>
        /// <param name="proxyID">The proxy identifier.</param>
        /// <returns></returns>
        public OutputValues RejectInteraction(int ticketID, string interactionID, int proxyID, KeyValueCollection data)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestReject requestReject = RequestReject.Create();
                requestReject.TicketId      = ticketID;
                requestReject.InteractionId = interactionID;
                requestReject.ProxyClientId = proxyID;
                requestReject.Extension     = data;
                ReasonInfo reasonInfo = ReasonInfo.Create();
                reasonInfo.ReasonDescription = "Agent has reject this interaction";
                requestReject.Reason         = reasonInfo;
                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestReject);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventInteractionReject = (EventAck)message;
                            logger.Info("------------RejectInteraction-------------");
                            logger.Info("InteractionId  :" + interactionID);
                            logger.Info("ProxyClientId    :" + proxyID);
                            logger.Info("---------------------------------------------");
                            logger.Trace(eventInteractionReject.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Reject Interaction Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError            = (EventError)message;
                            string     LoginErrorCode        = Convert.ToString(eventError.ErrorCode);
                            string     LoginErrorDescription = Convert.ToString(eventError.ErrorDescription);
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = "RejectInteraction() : " + LoginErrorDescription;
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Agent Reject Interaction UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("RejectInteraction() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Reject Interaction request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
        public void ReceiveCalls(IMessage events)
        {
            try
            {
                if (Settings.SFDCOptions.SFDCPopupPages != null)
                {
                    if (events != null)
                    {
                        logger.Info("ReceiveCalls : Agent Voice Event " + events.ToString());
                        switch (events.Id)
                        {
                            #region EventRinging
                        case EventRinging.MessageId:
                            eventRinging = (EventRinging)events;

                            if (eventRinging.CallType == CallType.Inbound)
                            {
                                IsConsultCallReceived = false;
                                CallRinging.GetInstance().PopupRecords(eventRinging, SFDCCallType.Inbound);
                                if (!Settings.UserEventData.ContainsKey(eventRinging.ConnID.ToString()))
                                {
                                    Settings.UserEventData.Add(eventRinging.ConnID.ToString(), SFDCCallType.Inbound);
                                }
                            }
                            else if (eventRinging.CallType == CallType.Consult)
                            {
                                IsConsultCallReceived = true;
                                CallRinging.GetInstance().PopupRecords(eventRinging, SFDCCallType.ConsultReceived);
                                if (!Settings.UserEventData.ContainsKey(eventRinging.ConnID.ToString()))
                                {
                                    Settings.UserEventData.Add(eventRinging.ConnID.ToString(), SFDCCallType.ConsultReceived);
                                }
                            }
                            break;
                            #endregion

                            #region EventPartyChanged
                        case EventPartyChanged.MessageId:
                            EventPartyChanged partyChanged = (EventPartyChanged)events;
                            IsConsultCallReceived = true;
                            if (CallDurationData.ContainsKey(partyChanged.PreviousConnID.ToString()) && !CallDurationData.ContainsKey(partyChanged.ConnID.ToString()))
                            {
                                CallDurationData.Add(partyChanged.ConnID.ToString(), CallDurationData[partyChanged.PreviousConnID.ToString()]);
                            }
                            if (Settings.UpdateSFDCLog.ContainsKey(partyChanged.PreviousConnID.ToString()))
                            {
                                Settings.UpdateSFDCLog.Add(partyChanged.ConnID.ToString(), Settings.UpdateSFDCLog[partyChanged.PreviousConnID.ToString()]);
                            }
                            this.consultConnId = partyChanged.PreviousConnID.ToString();
                            break;
                            #endregion

                            #region EventDialing
                        case EventDialing.MessageId:
                            eventDialing = (EventDialing)events;

                            if (eventDialing.Reasons != null && eventDialing.Reasons.ContainsKey("ClickToDial"))
                            {
                                Settings.ClickToDialData.Add(eventDialing.ConnID.ToString(), eventDialing.Reasons.GetAsString("ClickToDial"));
                            }
                            if (eventDialing.CallType == CallType.Unknown || eventDialing.CallType == CallType.Outbound)
                            {
                                CallDialing.GetInstance().PopupRecords(eventDialing, SFDCCallType.OutboundSuccess);

                                if (!Settings.UserEventData.ContainsKey(eventDialing.ConnID.ToString()))
                                {
                                    Settings.UserEventData.Add(eventDialing.ConnID.ToString(), SFDCCallType.OutboundSuccess);
                                }
                            }
                            else if (eventDialing.CallType == CallType.Consult)
                            {
                                CallDialing.GetInstance().PopupRecords(eventDialing, SFDCCallType.ConsultSuccess);

                                if (!Settings.UserEventData.ContainsKey(eventDialing.ConnID.ToString()))
                                {
                                    Settings.UserEventData.Add(eventDialing.ConnID.ToString(), SFDCCallType.ConsultSuccess);
                                }
                            }
                            break;
                            #endregion

                            #region EventEstablished
                        case EventEstablished.MessageId:

                            eventEstablished = (EventEstablished)events;

                            if (!CallDurationData.ContainsKey(eventEstablished.ConnID.ToString()))
                            {
                                CallDurationData.Add(eventEstablished.ConnID.ToString(), System.DateTime.Now);
                            }
                            if (eventEstablished.CallType == CallType.Inbound)
                            {
                                if (IsConsultCallReceived)
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.ConsultReceived);
                                }
                                else
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.Inbound);
                                }
                            }
                            else if (eventEstablished.CallType == CallType.Unknown || eventEstablished.CallType == CallType.Outbound)
                            {
                                if (IsConsultCallReceived)
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.ConsultReceived);
                                }
                                else
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.OutboundSuccess);
                                }
                            }
                            else if (eventEstablished.CallType == CallType.Consult)
                            {
                                if (IsConsultCallReceived)
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.ConsultReceived);
                                }
                                else
                                {
                                    CallConnected.GetInstance().PopupRecords(eventEstablished, SFDCCallType.ConsultSuccess);
                                }
                            }


                            break;
                            #endregion

                            #region EventReleased
                        case EventReleased.MessageId:

                            eventReleased = (EventReleased)events;

                            if (eventReleased.CallState != 22)
                            {
                                string callDuration = string.Empty;
                                if (CallDurationData.ContainsKey(eventReleased.ConnID.ToString()))
                                {
                                    TimeSpan ts = System.DateTime.Now.Subtract(CallDurationData[eventReleased.ConnID.ToString()]);
                                    callDuration = ts.Hours + "Hr " + ts.Minutes + " mins " + ts.Seconds + "secs";
                                    if (!FinishedCallDuration.ContainsKey(eventReleased.ConnID.ToString()))
                                    {
                                        FinishedCallDuration.Add(eventReleased.ConnID.ToString(), callDuration);
                                    }
                                    else
                                    {
                                        FinishedCallDuration[eventReleased.ConnID.ToString()] = callDuration;
                                    }
                                }
                                if (eventReleased.CallType == CallType.Inbound)
                                {
                                    if (!IsConsultCallReceived)
                                    {
                                        CallReleased.GetInstance().PopupRecords(eventReleased, SFDCCallType.Inbound, callDuration);
                                    }
                                    else
                                    {
                                        IsConsultCallReceived = false;
                                        CallReleased.GetInstance().PopupRecords(eventReleased, SFDCCallType.ConsultReceived, callDuration);
                                    }
                                }
                                else if (eventReleased.CallType == CallType.Unknown || eventReleased.CallType == CallType.Outbound)
                                {
                                    if (IsConsultCallReceived)
                                    {
                                        CallReleased.GetInstance().PopupRecords(eventReleased, SFDCCallType.ConsultReceived, callDuration);
                                        IsConsultCallReceived = false;
                                    }
                                    else
                                    {
                                        CallReleased.GetInstance().PopupRecords(eventReleased, SFDCCallType.OutboundSuccess, callDuration);
                                    }
                                }
                                else if (eventReleased.CallType == CallType.Consult)
                                {
                                    if (IsConsultCallReceived)
                                    {
                                        CallReleased.GetInstance().PopupRecords(eventReleased, SFDCCallType.ConsultReceived, callDuration);
                                        IsConsultCallReceived = false;
                                    }
                                    else
                                    {
                                        CallReleased.GetInstance().PopupRecords(eventReleased, SFDCCallType.ConsultSuccess, callDuration);
                                    }
                                }
                            }

                            break;
                            #endregion

                            #region EventUserEvent
                        case EventUserEvent.MessageId:
                            EventUserEvent userEvent = (EventUserEvent)events;

                            if (userEvent.ConnID != null)
                            {
                                if (Settings.UserEventData.ContainsKey(userEvent.ConnID.ToString()))
                                {
                                    if (FinishedCallDuration.ContainsKey(userEvent.ConnID.ToString()))
                                    {
                                        CallUserEvent.GetInstance().UpdateRecords(userEvent, Settings.UserEventData[userEvent.ConnID.ToString()], FinishedCallDuration[userEvent.ConnID.ToString()]);
                                    }
                                    else
                                    {
                                        CallUserEvent.GetInstance().UpdateRecords(userEvent, Settings.UserEventData[userEvent.ConnID.ToString()], "");
                                    }
                                }
                            }

                            break;
                            #endregion

                            #region EventError
                        case EventError.MessageId:
                            EventError eventError = (EventError)events;
                            if (eventError.CallType == CallType.Outbound)
                            {
                                CallEventError.GetInstance().PopupRecords(eventError, SFDCCallType.OutboundFailure);
                            }
                            else if (eventError.CallType == CallType.Consult)
                            {
                                CallEventError.GetInstance().PopupRecords(eventError, SFDCCallType.ConsultFailure);
                            }
                            break;
                            #endregion

                            #region EventAbandoned
                        case EventAbandoned.MessageId:
                            EventAbandoned eventAbandoned = (EventAbandoned)events;
                            if (eventAbandoned.CallType == CallType.Outbound)
                            {
                                CallEventAbandoned.GetInstance().PopupRecords(eventAbandoned, SFDCCallType.OutboundFailure);
                            }
                            else if (eventAbandoned.CallType == CallType.Consult)
                            {
                                CallEventAbandoned.GetInstance().PopupRecords(eventAbandoned, SFDCCallType.ConsultFailure);
                            }
                            break;
                            #endregion

                            #region EventDestinationBusy
                        case EventDestinationBusy.MessageId:

                            EventDestinationBusy destinationBusyEvent = (EventDestinationBusy)events;
                            if (destinationBusyEvent.CallType == CallType.Outbound)
                            {
                                CallEventDestinationBusy.GetInstance().PopupRecords(destinationBusyEvent, SFDCCallType.OutboundFailure);
                            }
                            else if (destinationBusyEvent.CallType == CallType.Consult)
                            {
                                CallEventDestinationBusy.GetInstance().PopupRecords(destinationBusyEvent, SFDCCallType.ConsultFailure);
                            }
                            break;
                            #endregion

                        default:
                            logger.Info("ReceiveCalls : Unhandled Event " + events.Name);
                            break;
                        }
                    }
                }
            }
            catch (Exception generalException)
            {
                logger.Error("ReceiveCalls : Error occured while receiving voice events " + generalException.ToString());
            }
        }
        /// <summary>
        /// Called when [next].
        /// </summary>
        /// <param name="value">The value.</param>
        public void OnNext(IStatisticsCollection value)
        {
            Request       statreq = new Request();
            List <string> tempThresholdValues;
            List <Color>  tempThresholdColors;

            try
            {
                logger.Debug("AgentStatisticsSubscriber : OnNext Method : Entry");
                if (value != null)
                {
                    if (value.AgentStatistics != null && value.AgentStatistics.Count != 0)
                    {
                        try
                        {
                            foreach (IAgentStatistics agentstat in value.AgentStatistics)
                            {
                                string[] configuredstat = value.StatisticsCommon.AgentStatistics.Split(',');
                                {
                                    foreach (string configstat in configuredstat)
                                    {
                                        if (configstat == agentstat.TempStatName)
                                        {
                                            string statName   = agentstat.StatisticsName.ToString();
                                            string filter     = agentstat.FilterName.ToString();
                                            string serverName = agentstat.ServerName.ToString();
                                            string format     = agentstat.StatisticsFormat.ToString();

                                            logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : ReferenceId - " + agentstat.ReferenceID);
                                            logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : StatName - " + statName);
                                            logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : ServerName - " + serverName);

                                            IMessage response;
                                            if (!StatisticsSetting.GetInstance().isAdmin)
                                            {
                                                if (agentstat.ReferenceID < StatisticsSetting.GetInstance().BAttributeReferenceId)
                                                {
                                                    logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : AgentEmpId - " + StatisticsSetting.GetInstance().AgentEmpId);
                                                    response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().AgentEmpId,
                                                                                   StatisticObjectType.Agent, statName, value.StatisticsCommon.NotifySeconds,
                                                                                   filter, value.StatisticsCommon.Insensitivity, agentstat.ReferenceID, serverName);
                                                }
                                                else
                                                {
                                                    //logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : AgentEmpId - " + StatisticsSetting.GetInstance().AgentEmpId);
                                                    response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().AgentEmpId,
                                                                                   StatisticObjectType.Agent, value.StatisticsCommon.NotifySeconds,
                                                                                   filter, configstat, agentstat.ReferenceID, serverName);
                                                }
                                            }
                                            else
                                            {
                                                if (!StatisticsSetting.GetInstance().RequestIds.Contains(agentstat.ReferenceID))
                                                {
                                                    StatisticsSetting.GetInstance().RequestIds.Add(agentstat.ReferenceID);
                                                }
                                                response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().IndividualAgent,
                                                                               StatisticObjectType.Agent, statName, value.StatisticsCommon.NotifySeconds,
                                                                               filter, value.StatisticsCommon.Insensitivity, agentstat.ReferenceID, serverName);
                                            }

                                            if (response != null)
                                            {
                                                statVariables = new StatVariables();
                                                switch (response.Id)
                                                {
                                                case EventStatisticOpened.MessageId:
                                                    EventStatisticOpened info;
                                                    info = (EventStatisticOpened)response;
                                                    statVariables.Statfilter  = filter;
                                                    statVariables.StatType    = StatisticObjectType.Agent.ToString();
                                                    statVariables.DisplayName = agentstat.DisplayName;
                                                    statVariables.Tooltip     = agentstat.ToolTipName;
                                                    statVariables.Statformat  = format;
                                                    statVariables.ObjectType  = agentstat.TempStatName;
                                                    statVariables.ObjectID    = StatisticsSetting.GetInstance().AgentEmpId;
                                                    statVariables.ReferenceId = info.ReferenceId.ToString();

                                                    tempThresholdValues = new List <string>();
                                                    tempThresholdValues.Add(agentstat.ThresholdLevelOne);
                                                    tempThresholdValues.Add(agentstat.ThresholdLevelTwo);

                                                    tempThresholdColors = new List <Color>();
                                                    tempThresholdColors.Add(agentstat.StatColor);
                                                    tempThresholdColors.Add(agentstat.ThresholdColorOne);
                                                    tempThresholdColors.Add(agentstat.ThresholdColorTwo);

                                                    StatisticsBase.GetInstance().IsMyStats = true;

                                                    if (!StatisticsSetting.GetInstance().ListRequestIds.Contains(agentstat.ReferenceID))
                                                    {
                                                        StatisticsSetting.GetInstance().ListRequestIds.Add(agentstat.ReferenceID);
                                                    }

                                                    if (!StatisticsSetting.GetInstance().ThresholdValues.ContainsKey(agentstat.ReferenceID.ToString()))
                                                    {
                                                        StatisticsSetting.GetInstance().ThresholdValues.Add(agentstat.ReferenceID.ToString(), tempThresholdValues);
                                                    }

                                                    if (!StatisticsSetting.GetInstance().ThresholdColors.ContainsKey(agentstat.ReferenceID.ToString()))
                                                    {
                                                        StatisticsSetting.GetInstance().ThresholdColors.Add(agentstat.ReferenceID.ToString(), tempThresholdColors);
                                                    }

                                                    if (!StatisticsSetting.GetInstance().DictAllStats.ContainsKey(info.ReferenceId.ToString()))
                                                    {
                                                        StatisticsSetting.GetInstance().DictAllStats.Add(info.ReferenceId.ToString(), agentstat.TempStatName);
                                                    }

                                                    if (!StatisticsSetting.GetInstance().agentStatisticsPluginHolder.ContainsKey(info.ReferenceId))
                                                    {
                                                        StatisticsSetting.GetInstance().agentStatisticsPluginHolder.Add(info.ReferenceId, statVariables);
                                                    }

                                                    StatisticsSetting.GetInstance().FinalAgentPackageID.Add(agentstat.ReferenceID);
                                                    break;

                                                case EventError.MessageId:
                                                    EventError eventError = (EventError)response;
                                                    logger.Error("AgentStatisticsSubscriber : OnNext Method : " + eventError.StringValue);
                                                    break;
                                                }
                                                statVariables = null;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception generalException)
                        {
                            logger.Error("AgentStatisticsSubscriber : OnNext Method : " + generalException.Message);
                        }
                        finally
                        {
                            GC.Collect();
                        }
                    }
                }
            }
            catch (Exception GeneralException)
            {
                logger.Error("AgentStatisticsSubscriber : OnNext Method : " + GeneralException.Message);
            }
            finally
            {
                logger.Debug("AgentStatisticsSubscriber : OnNext Method : Exit");
                statreq = null;
            }
        }
示例#28
0
        public OutputValues RequestPlaceQueue(string interactionId, int proxyId, string queueName)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestPlaceInQueue requestPlaceInQueue = RequestPlaceInQueue.Create();
                requestPlaceInQueue.InteractionId = interactionId;
                requestPlaceInQueue.Queue         = queueName;
                requestPlaceInQueue.ProxyClientId = proxyId;

                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestPlaceInQueue);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAck = (EventAck)message;
                            logger.Info("------------PlaceInQueue-------------");
                            logger.Info("InteractionID  :" + interactionId);
                            logger.Info("ProxyID        :" + proxyId);
                            logger.Info("Queue Name        :" + queueName);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventAck.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Place in Queue Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Info("------------Error on Place In Queue-------------");
                            logger.Info("InteractionID  :" + interactionId);
                            logger.Info("ProxyID        :" + proxyId);
                            logger.Info("Queue Name        :" + queueName);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = Convert.ToString(eventError.ErrorDescription);
                            logger.Error("Error occurred while placeinqueue : " + Convert.ToString(eventError.ErrorDescription));
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Place in Queue UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("PlaceInQueue() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Accept the request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
示例#29
0
        /// <summary>
        /// Agents the register.
        /// </summary>
        /// <param name="clientName">Name of the client.</param>
        /// <returns></returns>
        public OutputValues AgentRegister(string clientName)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestRegisterClient requestRegisterClient = RequestRegisterClient.Create();
                requestRegisterClient.ClientName    = clientName;
                requestRegisterClient.ClientType    = InteractionClient.AgentApplication;
                requestRegisterClient.ProxyClientId = 0;
                requestRegisterClient.Extension     = null;
                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestRegisterClient);

                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAgentRegister = (EventAck)message;
                            logger.Info("------------AgentRegister-------------");
                            logger.Info("ClientName    :" + clientName);
                            logger.Info("--------------------------------------");
                            logger.Trace(eventAgentRegister.ToString());
                            output.MessageCode = "200";
                            output.ProxyID     = eventAgentRegister.ProxyClientId;
                            output.Message     = "Agent Register Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError            = (EventError)message;
                            string     LoginErrorCode        = Convert.ToString(eventError.ErrorCode);
                            string     LoginErrorDescription = Convert.ToString(eventError.ErrorDescription);
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = "AgentRegister() : " + LoginErrorDescription;
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Agent Register UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("AgentRegister() : Interaction Server Protocol is Null..");
                }
            }
            catch (Exception commonException)
            {
                logger.Error("Error occurred while Register request " + commonException.ToString());
                output.MessageCode = "2001";
                output.Message     = commonException.Message;
            }
            return(output);
        }
示例#30
0
 internal void OnErrorOccurred(string err) => EventError?.Invoke(this, new ErrorEventArgs()
 {
     Error = err
 });