Пример #1
0
 public void UpdateRecords(EventInvite eventInvite, SFDCCallType callType, string callDuration, string chatContent)
 {
     try
     {
         if (Settings.SFDCOptions.SFDCPopupPages != null)
         {
             if (callType == SFDCCallType.InboundChat || callType == SFDCCallType.ConsultChatReceived)
             {
                 this.logger.Info("UpdateRecords : Update SFDC Logs for Inbound ");
                 sfdcPopupData = this.chatEvents.GetInboundUpdateData(eventInvite, callType, callDuration, chatContent, "datachanged");
                 if (sfdcPopupData != null)
                 {
                     sfdcPopupData.InteractionId = eventInvite.Interaction.InteractionId;
                     this.chatEvents.SendUpdateLogData(eventInvite.Interaction.InteractionId, sfdcPopupData);
                 }
                 else
                 {
                     this.logger.Info("UpdateRecords : Search data is empty");
                 }
             }
         }
     }
     catch (Exception generalException)
     {
         this.logger.Error("UpdateRecords : Error Occurred in Updating sfdc data : " + generalException.ToString());
     }
 }
Пример #2
0
        public async Task <bool> SaveStatus(EventInvite invite)
        {
            _context.Entry(invite).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(true);
        }
        public async Task <RepositoryActionResult <EventInvite> > AddInviteAsync(EventInvite invite)
        {
            var sender = await _context.Users.FirstOrDefaultAsync(u => u.Id == invite.SenderId);

            var invited = await _context.Users.FirstOrDefaultAsync(u => u.Id == invite.InvitedId);

            var @event = await _context.Events.FirstOrDefaultAsync(e => e.EventId == invite.EventId);

            if (sender == null || invited == null || @event == null)
            {
                return(new RepositoryActionResult <EventInvite>(invite, RepositoryStatus.NotFound));
            }

            var existingInvite = await _context.EventInvites.FirstOrDefaultAsync(
                i => i.EventId == invite.EventId && i.InvitedId == invite.InvitedId);

            if (existingInvite != null)
            {
                return(new RepositoryActionResult <EventInvite>(existingInvite, RepositoryStatus.BadRequest));
            }

            try
            {
                var result = _context.EventInvites.Add(invite);
                await _context.SaveChangesAsync();

//                new InviteSender().SendEventInvite(invite);
                return(new RepositoryActionResult <EventInvite>(result, RepositoryStatus.Created));
            }
            catch (Exception e)
            {
                return(new RepositoryActionResult <EventInvite>(invite, RepositoryStatus.Error));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InboundUserControl"/> class.
 /// </summary>
 /// <param name="_eventInvite">The _event invite.</param>
 /// <param name="eventGetInteractionContent">Content of the event get interaction.</param>
 public InboundUserControl(EventInvite _eventInvite, EventGetInteractionContent eventGetInteractionContent)
 {
     try
     {
         InitializeComponent();
         dockCc.Visibility  = Visibility.Collapsed;
         dockBcc.Visibility = Visibility.Collapsed;
         if (_eventInvite.Interaction.InteractionUserData.Contains("Subject") &&
             !string.IsNullOrEmpty(_eventInvite.Interaction.InteractionUserData["Subject"].ToString()))
         {
             txtInboundSubject.ToolTip = txtInboundSubject.Text = _eventInvite.Interaction.InteractionUserData["Subject"].ToString();
         }
         else
         {
             txtInboundSubject.ToolTip = txtInboundSubject.Text = "(No Subject)";
         }
         if (_eventInvite.Interaction.InteractionUserData.Contains("To"))
         {
             txtInboundTo.Text = Pointel.Interactions.Email.Helper.EmailAddressValidation.GetEmailAddress(_eventInvite.Interaction.InteractionUserData["To"].ToString());
         }
         if (_eventInvite.Interaction.InteractionUserData.Contains("FromAddress"))
         {
             txtInboundFrom.Text = Pointel.Interactions.Email.Helper.EmailAddressValidation.GetEmailAddress(_eventInvite.Interaction.InteractionUserData["FromAddress"].ToString());
         }
         BindContent(eventGetInteractionContent);
     }
     catch (Exception ex)
     {
         logger.Error("Error occurred at InboundUserControl constructor" + ex.ToString());
     }
 }
Пример #5
0
        private void GetChatData(string ixnId, IXNCustomData chatData)
        {
            try
            {
                this._logger.Info("Retrieving UCS data for the InteractionId : " + ixnId + "\t EventName : " + chatData.EventName);
                EventGetInteractionContent chatContent = Settings.SFDCListener.GetOpenMediaInteractionContent(ixnId, false);
                if (chatContent != null)
                {
                    if (chatContent.InteractionAttributes.TypeId == "Inbound")
                    {
                        chatData.InteractionType = SFDCCallType.InboundChat;
                    }
                    else if (chatContent.InteractionAttributes.TypeId == "Consult")
                    {
                        chatData.InteractionType = SFDCCallType.ConsultChatReceived;
                    }

                    EventInvite currentEvent = null;
                    _chatIXNCollection.TryGetValue(ixnId, out currentEvent);
                    chatData.InteractionEvent    = currentEvent;
                    chatData.IXN_Attributes      = chatContent.InteractionAttributes;
                    chatData.EntityAttributes    = chatContent.EntityAttributes;
                    chatData.AttachmentLists     = chatContent.Attachments;
                    chatData.InteractionContents = chatContent.InteractionContent;
                    if (chatData.UserData == null)
                    {
                        chatData.UserData = chatContent.InteractionAttributes.AllAttributes;
                    }

                    if (chatData.InteractionNotes == null && chatContent.InteractionAttributes != null)
                    {
                        chatData.InteractionNotes = chatContent.InteractionAttributes.TheComment;
                    }

                    if (!Settings.SFDCOptions.CanUseGenesysCallDuration || string.IsNullOrWhiteSpace(chatData.Duration))
                    {
                        if (_callDurationData.ContainsKey(chatData.InteractionId))
                        {
                            TimeSpan ts = System.DateTime.Now.Subtract(_callDurationData[chatData.InteractionId]);
                            chatData.Duration = ts.Hours + "Hr " + ts.Minutes + " Mins " + ts.Seconds + "Secs";
                        }
                    }
                }
                else
                {
                    this._logger.Info("GetChatData: Null is returned from UCS for the  interaction id : " + chatData.InteractionId);
                }
            }
            catch (Exception generalException)
            {
                this._logger.Info("GetChatData: Error occurred, Exception : " + generalException.ToString());
            }
        }
Пример #6
0
        public MailMessage GenerateEventInviteMessage(EventInvite invite)
        {
            var message = new MailMessage();

            message.To.Add(invite.Invited.Email);
            // message.From = new MailAddress(ConfigurationManager.AppSettings["email-address"]);
            message.Subject    = EventInviteTitle;
            message.IsBodyHtml = true;
            var template =
                File.ReadAllText(EventInviteViewPath);
            var view = Engine.Razor.RunCompile(template, "templateKey", typeof(EventInvite), invite);

            message.Body = view;

            return(message);
        }
        public async Task <RepositoryActionResult <EventInvite> > AddInviteEmailAsync(int eventId, string senderId, string email)
        {
            var sender = await _context.Users.FirstOrDefaultAsync(u => u.Id == senderId);

            var invited = await _context.Users.FirstOrDefaultAsync(u => u.Email == email);

            var @event = await _context.Events.FirstOrDefaultAsync(e => e.EventId == eventId);

            if (sender == null || invited == null || @event == null)
            {
                return(new RepositoryActionResult <EventInvite>(null, RepositoryStatus.NotFound));
            }

            var existingInvite = await _context.EventInvites.FirstOrDefaultAsync(
                i => i.EventId == eventId && i.Invited.Email == email);

            if (existingInvite != null)
            {
                return(new RepositoryActionResult <EventInvite>(existingInvite, RepositoryStatus.BadRequest));
            }

            try
            {
                var invite = new EventInvite {
                    EventId = eventId, SenderId = senderId, InvitedId = invited.Id
                };
                var result = _context.EventInvites.Add(invite);
                await _context.SaveChangesAsync();

                //new InviteSender().SendEventInvite(invite);
                return(new RepositoryActionResult <EventInvite>(result, RepositoryStatus.Created));
            }
            catch (Exception e)
            {
                var ex = new ExceptionWrapper
                {
                    ExceptionMessage    = e.Message,
                    ExceptionStackTrace = e.StackTrace,
                    LogTime             = DateTime.Now
                };
                _context.Exception.Add(ex);
                await _context.SaveChangesAsync();

                return(new RepositoryActionResult <EventInvite>(null, RepositoryStatus.Error));
            }
        }
Пример #8
0
        public void SendEventInvite(EventInvite invite)
        {
            var message = _messageGenerator.GenerateEventInviteMessage(invite);

            using (var smtp = new SmtpClient())
            {
                var credentials = new NetworkCredential
                {
                    UserName = ConfigurationManager.AppSettings["email-address"],
                    Password = ConfigurationManager.AppSettings["email-password"]
                };
                smtp.Credentials = credentials;
                smtp.Host        = "smtp.gmail.com";
                smtp.Port        = 587;
                smtp.EnableSsl   = true;
                smtp.Send(message);
            }
        }
 /// <summary>
 /// Shows the email notifier.
 /// </summary>
 /// <param name="message">The message.</param>
 public void ShowEmailNotifier(EventInvite message)
 {
     System.Windows.Application.Current.Dispatcher.Invoke((Action)(delegate
     {
         try
         {
             _taskbarNotifier.PlayTone();
             _taskbarNotifier.BindInfo(message);
             _taskbarNotifier.SetInitialLocations(false);
             _taskbarNotifier.Notify(0, false);
             EmailDataContext.GetInstance().isNotifyShowing = true;
         }
         catch (Exception ex)
         {
             logger.Error("Error occurred as " + ex.Message);
         }
     }));
 }
        public async Task <MessagingResponse> PostComment(EventInvite invite, SmsRequest incomingMessage)
        {
            var messagingResponse = new MessagingResponse();

            string eventComment = incomingMessage.Body;
            string cleanPhone   = incomingMessage.From.Remove(0, 2);
            var    user         = await repository.GetUserByPhone(cleanPhone);

            var comment = new EventComment
            {
                Comment = eventComment,
                UserId  = user.Id,
                EventId = invite.EventId
            };

            await repository.SaveComment(comment);

            messagingResponse.Message($"You have asked {invite.Event.EventHost} \"{eventComment}\" for the {invite.Event.EventName} event. We'll let you know as soon as the event is updated.");
            return(messagingResponse);
        }
Пример #11
0
        /// <summary>
        /// Binds the information.
        /// </summary>
        /// <param name="eventInvite">The event invite.</param>
        public void BindInfo(EventInvite eventInvite)
        {
            this.eventInvite = eventInvite;
            ReadContactName();
            KeyValueCollection keyValue = eventInvite.Interaction.InteractionUserData;

            if (emailDetails.EmailCaseData != null)
            {
                emailDetails.EmailCaseData.Clear();
            }
            if (eventInvite.Interaction.InteractionUserData != null)
            {
                foreach (string key in eventInvite.Interaction.InteractionUserData.AllKeys)
                {
                    emailDetails.EmailCaseData.Add(new EmailCaseData()
                    {
                        Key = key, Value = eventInvite.Interaction.InteractionUserData[key].ToString()
                    });
                }
            }
        }
        public async Task <RepositoryActionResult <EventInvite> > AddGroupInviteAsync(string senderId, int groupId, int eventId)
        {
            var group = await _context.Groups.FirstOrDefaultAsync(g => g.GroupId == groupId);

            if (@group == null)
            {
                return(new RepositoryActionResult <EventInvite>(null, RepositoryStatus.Error));
            }
            var users = @group.Users;

            foreach (var user in users)
            {
                var existingInvite = await _context.EventInvites.FirstOrDefaultAsync(
                    i => i.EventId == eventId && i.InvitedId == user.ApplicationUserId);

                if (existingInvite != null)
                {
                    return(new RepositoryActionResult <EventInvite>(existingInvite, RepositoryStatus.BadRequest));
                }

                try
                {
                    var invite = new EventInvite {
                        SenderId = senderId, InvitedId = user.ApplicationUserId, EventId = eventId
                    };
                    var result = _context.EventInvites.Add(invite);
                    await _context.SaveChangesAsync();

                    new InviteSender().SendEventInvite(invite);
                    return(new RepositoryActionResult <EventInvite>(result, RepositoryStatus.Created));
                }
                catch (Exception e)
                {
                    return(new RepositoryActionResult <EventInvite>(null, RepositoryStatus.Error));
                }
            }
            return(new RepositoryActionResult <EventInvite>(null, RepositoryStatus.Error));
        }
Пример #13
0
 public void PopupRecords(EventInvite eventInvite, SFDCCallType callType)
 {
     try
     {
         if (callType == SFDCCallType.InboundChat)
         {
             this.logger.Info("PopupRecords : Popup SFDC for Inbound on EventInvite Event ");
             sfdcPopupData = this.chatEvents.GetInboundPopupData(eventInvite, callType, "invite");
             if (sfdcPopupData != null)
             {
                 sfdcPopupData.InteractionId = eventInvite.Interaction.InteractionId.ToString();
                 //Settings.SFDCPopupData.Add(eventInvite.Interaction.InteractionId.ToString()+"invite", sfdcPopupData);
             }
             else
             {
                 this.logger.Info("PopupRecords ; Search data is empty");
             }
         }
         else if (callType == SFDCCallType.ConsultChatReceived)
         {
             this.logger.Info("PopupRecords : Popup SFDC for Consult on EventInvite Event ");
             sfdcPopupData = this.chatEvents.GetConsultReceivedPopupData(eventInvite, callType, "invite");
             if (sfdcPopupData != null)
             {
                 sfdcPopupData.InteractionId = eventInvite.Interaction.InteractionId.ToString();
                 //Settings.SFDCPopupData.Add(eventInvite.Interaction.InteractionId.ToString() + "invite", sfdcPopupData);
             }
             else
             {
                 this.logger.Info("PopupRecords : Search data is empty");
             }
         }
     }
     catch (Exception generalException)
     {
         logger.Error("PopupRecords : Error Occurred while collecting Log data : " + generalException.ToString());
     }
 }
 /// <summary>
 /// Gets Updated Disposition Code Change
 /// </summary>
 /// <param name="ixnId"></param>
 /// <param name="key"></param>
 /// <param name="code"></param>
 public void UpdateDispositionCodeChange(string ixnId, string key, string code)
 {
     try
     {
         logger.Info("Updating activity log");
         if (ChatIXNCollection.ContainsKey(ixnId))
         {
             if (key.Contains("."))
             {
                 key = key.Substring(key.LastIndexOf("."));
             }
             EventInvite updateData = ChatIXNCollection[ixnId];
             if (updateData != null)
             {
                 if (updateData.Interaction.InteractionUserData.ContainsKey(key))
                 {
                     updateData.Interaction.InteractionUserData[key] = code;
                 }
                 else
                 {
                     updateData.Interaction.InteractionUserData.Add(key, code);
                 }
                 if (CallDurationData.ContainsKey(updateData.Interaction.InteractionId))
                 {
                     TimeSpan ts = System.DateTime.Now.Subtract(CallDurationData[updateData.Interaction.InteractionId]);
                     callDuration = ts.Hours + "Hr " + ts.Minutes + " mins " + ts.Seconds + "secs";
                 }
                 InboundChatInvite.GetInstance().UpdateRecords(eventInvite, SFDCCallType.InboundChat, callDuration, GetChatInteractionContent(updateData.Interaction.InteractionId).Replace('&', ' '));
             }
         }
     }
     catch (Exception generalException)
     {
         this.logger.Error("UpdateDispositionCodeChange : Error at updating disposition code Changed : " + generalException.ToString());
     }
 }
Пример #15
0
 /// <summary>
 /// Popup SFDC on EventInvite Event
 /// </summary>
 /// <param name="eventInvite"></param>
 /// <param name="callType"></param>
 public void PopupRecords(EventInvite eventInvite, SFDCCallType callType)
 {
     try
     {
         if (callType == SFDCCallType.InboundChat)
         {
             this.logger.Info("PopupRecords : Popup SFDC for Inbound on ChatConnected Event ");
             sfdcPopupData = this.chatEvents.GetInboundPopupData(eventInvite, callType, "established");
             if (sfdcPopupData != null)
             {
                 sfdcPopupData.InteractionId = eventInvite.Interaction.InteractionId;
                 this.chatEvents.SendPopupData(eventInvite.Interaction.InteractionId + "estab", sfdcPopupData);
             }
             else
             {
                 this.logger.Info("PopupRecords : Search data is empty");
             }
         }
     }
     catch (Exception generalException)
     {
         this.logger.Error("PopupRecords : Error Occurred at ChatConnected : " + generalException.ToString());
     }
 }
Пример #16
0
        /// <summary>
        /// Popup SFDC on Chat Connected
        /// </summary>
        /// <param name="eventInvite"></param>
        /// <param name="callType"></param>
        /// <param name="callDuration"></param>
        /// <param name="chatContent"></param>
        public void PopupRecords(EventInvite eventInvite, SFDCCallType callType, string callDuration, string chatContent)
        {
            try
            {
                if (callType == SFDCCallType.InboundChat)
                {
                    this.logger.Info("PopupRecords : Popup SFDC for Inbound on ChatSessionEnded ");
                    sfdcPopupData = this.chatEvents.GetInboundPopupData(eventInvite, callType, "released");
                    if (sfdcPopupData != null)
                    {
                        sfdcPopupData.InteractionId = eventInvite.Interaction.InteractionId;
                        this.chatEvents.SendPopupData(eventInvite.Interaction.InteractionId + "release", sfdcPopupData);
                    }
                    else
                    {
                        this.logger.Info(" PopupRecords : Search data is empty");
                    }

                    //Update Data
                    this.logger.Info("PopupRecords : Update SFDC Logs for Inbound on ChatSessionEnded ");
                    sfdcPopupData = this.chatEvents.GetInboundUpdateData(eventInvite, callType, callDuration, chatContent, "released");
                    if (sfdcPopupData != null)
                    {
                        sfdcPopupData.InteractionId = eventInvite.Interaction.InteractionId;
                        this.chatEvents.SendUpdateLogData(eventInvite.Interaction.InteractionId, sfdcPopupData);
                    }
                    else
                    {
                        this.logger.Info("PopupRecords : Search data is empty");
                    }
                }
                else if (callType == SFDCCallType.ConsultChatReceived)
                {
                    this.logger.Info("PopupRecords : Popup SFDC for Inbound on ChatSessionEnded ");
                    sfdcPopupData = this.chatEvents.GetConsultReceivedPopupData(eventInvite, callType, "released");
                    if (sfdcPopupData != null)
                    {
                        sfdcPopupData.InteractionId = eventInvite.Interaction.InteractionId;
                        this.chatEvents.SendPopupData(eventInvite.Interaction.InteractionId + "release", sfdcPopupData);
                    }
                    else
                    {
                        this.logger.Info("PopupRecords : Search data is empty");
                    }

                    //Update Data
                    this.logger.Info("PopupRecords : Update SFDC Logs for Inbound on ChatSessionEnded ");
                    sfdcPopupData = this.chatEvents.GetConsultUpdateData(eventInvite, callType, callDuration, chatContent, "released");
                    if (sfdcPopupData != null)
                    {
                        sfdcPopupData.InteractionId = eventInvite.Interaction.InteractionId;
                        this.chatEvents.SendUpdateLogData(eventInvite.Interaction.InteractionId, sfdcPopupData);
                    }
                    else
                    {
                        this.logger.Info("PopupRecords : Search data is empty");
                    }
                }
            }
            catch (Exception generalException)
            {
                this.logger.Error("PopupRecords : Error Occurred While collecting log data : " + generalException.ToString());
            }
        }
        /// <summary>
        ///  Receives Chat Events
        /// </summary>
        /// <param name="events"></param>
        public void ReceiveChatEvents(IMessage events)
        {
            try
            {
                if (Settings.SFDCOptions.SFDCPopupPages != null)
                {
                    if (events != null)
                    {
                        logger.Info("Agent Chat Event : " + events.Name);
                        switch (events.Id)
                        {
                        case EventInvite.MessageId:
                            eventInvite = (EventInvite)events;
                            if (eventInvite.Interaction.InteractionType == "Inbound")
                            {
                                if (eventInvite.VisibilityMode.ToString() != "Coach" && eventInvite.VisibilityMode.ToString() != "Conference")
                                {
                                    IsConsultReceived = false;
                                    InboundChatInvite.GetInstance().PopupRecords(eventInvite, SFDCCallType.InboundChat);
                                }
                                else
                                {
                                    IsConsultReceived = true;
                                    InboundChatInvite.GetInstance().PopupRecords(eventInvite, SFDCCallType.ConsultChatReceived);
                                }
                            }
                            else if (eventInvite.Interaction.InteractionType == "Consult")
                            {
                                IsConsultReceived = true;
                                InboundChatInvite.GetInstance().PopupRecords(eventInvite, SFDCCallType.ConsultChatReceived);
                            }
                            break;

                        case EventSessionInfo.MessageId:
                            sessionInfo = (EventSessionInfo)events;
                            try
                            {
                                if (LastSessionId != eventInvite.Interaction.InteractionId)
                                {
                                    LastSessionId = eventInvite.Interaction.InteractionId;

                                    if (!ChatIXNCollection.ContainsKey(eventInvite.Interaction.InteractionId))
                                    {
                                        ChatIXNCollection.Add(eventInvite.Interaction.InteractionId, eventInvite);
                                    }

                                    if (!CallDurationData.ContainsKey(eventInvite.Interaction.InteractionId))
                                    {
                                        CallDurationData.Add(eventInvite.Interaction.InteractionId, System.DateTime.Now);
                                    }
                                    ChatSessionConnected.GetInstance().PopupRecords(eventInvite, SFDCCallType.InboundChat);
                                }
                                if (sessionInfo.SessionStatus == SessionStatus.Over)
                                {
                                    if (CallDurationData.ContainsKey(sessionInfo.ChatTranscript.SessionId))
                                    {
                                        TimeSpan ts = System.DateTime.Now.Subtract(CallDurationData[sessionInfo.ChatTranscript.SessionId]);
                                        callDuration = ts.Hours + "Hr " + ts.Minutes + " mins " + ts.Seconds + "secs";
                                        if (!FinishedCallDuration.ContainsKey(sessionInfo.ChatTranscript.SessionId))
                                        {
                                            FinishedCallDuration.Add(sessionInfo.ChatTranscript.SessionId, callDuration);
                                        }
                                        else
                                        {
                                            FinishedCallDuration[sessionInfo.ChatTranscript.SessionId] = callDuration;
                                        }
                                    }
                                    if (IsConsultReceived)
                                    {
                                        ChatSessionEnded.GetInstance().PopupRecords(eventInvite, SFDCCallType.ConsultChatReceived, callDuration, GetChatInteractionContent(sessionInfo.ChatTranscript.SessionId).Replace('&', ' '));
                                    }
                                    else
                                    {
                                        ChatSessionEnded.GetInstance().PopupRecords(eventInvite, SFDCCallType.InboundChat, callDuration, GetChatInteractionContent(sessionInfo.ChatTranscript.SessionId).Replace('&', ' '));
                                    }
                                }
                            }
                            catch (Exception generalException)
                            {
                                this.logger.Error(generalException.ToString());
                            }
                            break;

                        default:
                            logger.Info("Unhandled Event " + events.Name);
                            break;
                        }
                    }
                }
            }
            catch (Exception generalException)
            {
                logger.Error("ReceiveChatEvents : Error occured while receiving Chat events " + generalException.ToString());
            }
        }
Пример #18
0
        /// <summary>
        /// Receives Chat Events
        /// </summary>
        /// <param name="events"></param>
        public void ReceiveChatEvents(IMessage events)
        {
            try
            {
                if (Settings.SFDCOptions.SFDCPopupPages != null)
                {
                    if (events != null)
                    {
                        _logger.Info("Agent Chat Event : " + events.Name);
                        switch (events.Id)
                        {
                        case EventInvite.MessageId:
                            _eventInvite = (EventInvite)events;
                            Settings.ChatProxyClientId = _eventInvite.ProxyClientId;
                            IXNCustomData ixnData = new IXNCustomData();
                            ixnData.InteractionId    = _eventInvite.Interaction.InteractionId;
                            ixnData.InteractionEvent = _eventInvite;
                            if (!_chatIXNCollection.ContainsKey(_eventInvite.Interaction.InteractionId))
                            {
                                _chatIXNCollection.Add(_eventInvite.Interaction.InteractionId, _eventInvite);
                            }
                            GetChatData(_eventInvite.Interaction.InteractionId, ixnData);
                            if (_eventInvite.Interaction.InteractionType == "Inbound")
                            {
                                if (_eventInvite.VisibilityMode.ToString() != "Coach" && _eventInvite.VisibilityMode.ToString() != "Conference")
                                {
                                    ChatInvite.GetInstance().PopupRecords(ixnData, SFDCCallType.InboundChat);
                                }
                                else
                                {
                                    ChatInvite.GetInstance().PopupRecords(ixnData, SFDCCallType.ConsultChatReceived);
                                }
                            }
                            else if (_eventInvite.Interaction.InteractionType == "Consult")
                            {
                                ChatInvite.GetInstance().PopupRecords(ixnData, SFDCCallType.ConsultChatReceived);
                            }
                            break;

                        case EventSessionInfo.MessageId:
                            _sessionInfo = (EventSessionInfo)events;
                            try
                            {
                                if (Settings.SFDCOptions.ChatAttachActivityId && Settings.SFDCListener.ChatActivityIdCollection.Keys.Contains(_sessionInfo.ChatTranscript.SessionId.ToString()) && _sessionInfo.SessionStatus == SessionStatus.Alive)
                                {
                                    Settings.SFDCListener.SetAttachedData(_sessionInfo.ChatTranscript.SessionId.ToString(), Settings.SFDCOptions.ChatAttachActivityIdKeyname, Settings.SFDCListener.ChatActivityIdCollection[_sessionInfo.ChatTranscript.SessionId.ToString()], Settings.ChatProxyClientId);
                                    Settings.SFDCListener.ChatActivityIdCollection.Remove(_sessionInfo.ChatTranscript.SessionId.ToString());
                                }
                                if (_lastSessionId != _eventInvite.Interaction.InteractionId)
                                {
                                    _lastSessionId = _eventInvite.Interaction.InteractionId;

                                    if (!_callDurationData.ContainsKey(_eventInvite.Interaction.InteractionId))
                                    {
                                        _callDurationData.Add(_eventInvite.Interaction.InteractionId, System.DateTime.Now);
                                    }
                                }
                                if (_sessionInfo.SessionStatus == SessionStatus.Over)
                                {
                                    if (_callDurationData.ContainsKey(_sessionInfo.ChatTranscript.SessionId))
                                    {
                                        TimeSpan ts = System.DateTime.Now.Subtract(_callDurationData[_sessionInfo.ChatTranscript.SessionId]);
                                        _callDuration = ts.Hours + "Hr " + ts.Minutes + " mins " + ts.Seconds + "secs";
                                        if (!FinishedCallDuration.ContainsKey(_sessionInfo.ChatTranscript.SessionId))
                                        {
                                            FinishedCallDuration.Add(_sessionInfo.ChatTranscript.SessionId, _callDuration);
                                        }
                                        else
                                        {
                                            FinishedCallDuration[_sessionInfo.ChatTranscript.SessionId] = _callDuration;
                                        }
                                    }
                                }
                            }
                            catch (Exception generalException)
                            {
                                this._logger.Error(generalException.ToString());
                            }
                            break;

                        default:
                            _logger.Info("Unhandled Event " + events.Name);
                            break;
                        }
                    }
                }
            }
            catch (Exception generalException)
            {
                _logger.Error("ReceiveChatEvents : Error occured while receiving Chat events " + generalException.ToString());
            }
        }
        public void ReceiveEmailEvents(IMessage events)
        {
            try
            {
                if ((Settings.SFDCOptions.SFDCPopupPages != null) && (events != null))
                {
                    this._logger.Info("Agent Email Event : " + events.Name);
                    switch (events.Id)
                    {
                    case EventInvite.MessageId:
                        this._eventInvite           = (EventInvite)events;
                        Settings.EmailProxyClientId = _eventInvite.ProxyClientId;
                        IXNCustomData emailInviteData = new IXNCustomData();
                        emailInviteData.InteractionId        = this._eventInvite.Interaction.InteractionId;
                        emailInviteData.OpenMediaInteraction = this._eventInvite.Interaction;
                        emailInviteData.UserData             = this._eventInvite.Interaction.InteractionUserData;
                        GetEmailData(emailInviteData.InteractionId, emailInviteData);
                        EmailInvite.GetInstance().PopupRecords(emailInviteData, emailInviteData.InteractionType);

                        if ((this._eventInvite.VisibilityMode.ToString() != "Coach") && (this._eventInvite.VisibilityMode.ToString() != "Conference"))
                        {
                        }

                        break;

                    case EventPulledInteractions.MessageId:
                        this._eventPulledInteractions = (EventPulledInteractions)events;
                        if (this._eventPulledInteractions.Interactions.Count == 1)
                        {
                            string             str             = this._eventPulledInteractions.Interactions.AllKeys.GetValue(0).ToString();
                            object[]           kvc             = this._eventPulledInteractions.Interactions.GetValues(str);
                            KeyValueCollection collection      = (KeyValueCollection)kvc[0];
                            IXNCustomData      emailPulledData = new IXNCustomData();
                            emailPulledData.InteractionId = collection["InteractionId"].ToString();
                            GetEmailData(emailPulledData.InteractionId, emailPulledData);
                            if (emailPulledData.IXN_Attributes.TypeId == "Inbound")
                            {
                                emailPulledData.InteractionType = SFDCCallType.InboundEmailPulled;
                            }
                            else if (emailPulledData.IXN_Attributes.TypeId == "Outbound")
                            {
                                emailPulledData.InteractionType = SFDCCallType.OutboundEmailPulled;
                            }
                            EmailPulled.GetInstance().PopupRecords(emailPulledData, emailPulledData.InteractionType);
                        }
                        break;

                    case EventAck.MessageId:
                        this._eventAck = (EventAck)events;
                        if (_eventAck.Extension != null && _eventAck.Extension.ContainsKey("InteractionId") && _eventAck.Extension["InteractionId"] != null)
                        {
                            string type = GetEmailInteractionContent(_eventAck.Extension["InteractionId"].ToString(), "type");
                            if (type.Equals("OutboundNew"))
                            {
                                string ToAddress = GetEmailInteractionContent(_eventAck.Extension["InteractionId"].ToString(), "to");
                                if (!String.IsNullOrEmpty(ToAddress))
                                {
                                    IXNCustomData emailAckData = new IXNCustomData();
                                    emailAckData.InteractionType = SFDCCallType.OutboundEmailSuccess;
                                    emailAckData.InteractionId   = _eventAck.Extension["InteractionId"].ToString();
                                    GetEmailData(emailAckData.InteractionId, emailAckData);
                                    if (IsClick2Email && SFDCHttpServer._emailData.ContainsKey(ToAddress))
                                    {
                                        Settings.ClickToEmailData.Add(_eventAck.Extension["InteractionId"].ToString(), SFDCHttpServer._emailData[ToAddress]);
                                        EmailManager.GetInstance().GetClickToEmailLogs(emailAckData, _eventAck.Extension["InteractionId"].ToString(), SFDCCallType.OutboundEmailSuccess, SFDCHttpServer._emailData[ToAddress], "create");
                                        IsClick2Email = false;
                                    }
                                    else
                                    {
                                        EmailCreate.GetInstance().PopupRecords(emailAckData, SFDCCallType.OutboundEmailSuccess);
                                    }
                                }
                                else
                                {
                                    this._logger.Warn("ReceiveEmailEvents : ToAddress is not found in EventAck");
                                }
                            }
                            else if (type.Equals("OutboundReply"))
                            {
                                string ToAddress = GetEmailInteractionContent(_eventAck.Extension["InteractionId"].ToString(), "to");
                                if (!String.IsNullOrEmpty(ToAddress))
                                {
                                    IXNCustomData outEmailData = new IXNCustomData();
                                    outEmailData.InteractionType = SFDCCallType.OutboundEmailSuccess;
                                    outEmailData.InteractionId   = _eventAck.Extension["InteractionId"].ToString();
                                    GetEmailData(outEmailData.InteractionId, outEmailData);
                                    if (IsClick2Email && SFDCHttpServer._emailData.ContainsKey(ToAddress))
                                    {
                                        Settings.ClickToEmailData.Add(_eventAck.Extension["InteractionId"].ToString(), SFDCHttpServer._emailData[ToAddress]);
                                        EmailManager.GetInstance().GetClickToEmailLogs(outEmailData, _eventAck.Extension["InteractionId"].ToString(), SFDCCallType.OutboundEmailSuccess, SFDCHttpServer._emailData[ToAddress], "create");
                                        IsClick2Email = false;
                                    }
                                    else
                                    {
                                        EmailCreate.GetInstance().PopupRecords(outEmailData, SFDCCallType.OutboundEmailSuccess);
                                    }
                                }
                                else
                                {
                                    this._logger.Warn("ReceiveEmailEvents : ToAddress is not found in EventAck");
                                }
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                this._logger.Error("ReceiveEmailEvents : Error occured while receiving Email events " + exception.ToString());
            }
        }
Пример #20
0
 public static EventInvite CreateEventInvite(int eventInviteID, string gUID, int eventID, string emailAddress, bool inviteEmailSent, bool inviteAccepted, bool inviteDeclined, bool deleted, global::System.DateTime createdDate, string createdByFullName, global::System.DateTime lastUpdatedDate, string lastUpdatedByFullName)
 {
     EventInvite eventInvite = new EventInvite();
     eventInvite.EventInviteID = eventInviteID;
     eventInvite.GUID = gUID;
     eventInvite.EventID = eventID;
     eventInvite.EmailAddress = emailAddress;
     eventInvite.InviteEmailSent = inviteEmailSent;
     eventInvite.InviteAccepted = inviteAccepted;
     eventInvite.InviteDeclined = inviteDeclined;
     eventInvite.Deleted = deleted;
     eventInvite.CreatedDate = createdDate;
     eventInvite.CreatedByFullName = createdByFullName;
     eventInvite.LastUpdatedDate = lastUpdatedDate;
     eventInvite.LastUpdatedByFullName = lastUpdatedByFullName;
     return eventInvite;
 }
Пример #21
0
 public void AddToEventInvites(EventInvite eventInvite)
 {
     base.AddObject("EventInvites", eventInvite);
 }
Пример #22
0
        public void SendInvites(Event @event)
        {
            _phone      = Configuration["Twilio:phone"];
            _accountSid = Configuration["Twilio:accountSid"];
            _authToken  = Configuration["Twilio:authToken"];

            if (String.IsNullOrEmpty(_phone))
            {
                throw new NullTwilioPhoneException();
            }

            if (String.IsNullOrEmpty(_accountSid))
            {
                throw new NullTwilioSidException();
            }

            if (String.IsNullOrEmpty(_authToken))
            {
                throw new NullTwilioTokenException();
            }

            TwilioClient.Init(_accountSid, _authToken);

            foreach (var group in @event.InvitedGroups)
            {
                var currGroup = _context.Groups
                                .Include(g => g.GroupUsers)
                                .ThenInclude(gu => gu.User)
                                .ThenInclude(u => u.Invites)
                                .FirstOrDefault(g => g.GroupId == group.GroupId);

                foreach (var user in currGroup.GroupUsers)
                {
                    if (String.IsNullOrEmpty(user.User.PhoneNumber))
                    {
                        continue;
                    }

                    try
                    {
                        MessageResource.Create(
                            body: $"You've been invited to {@event.EventName}! Please reply with your RSVP - 1 for Yes, 2 for No, 3 for Maybe, 4 to get more Details, 5 for event description, or 6 to ask a question. Your response will apply to your most recent invitation without a response.",
                            from: new Twilio.Types.PhoneNumber($"+1{_phone}"),
                            to: new Twilio.Types.PhoneNumber($"+1{user.User.PhoneNumber}")
                            );
                    }

                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }

                    var invitation = new EventInvite
                    {
                        Event   = @event,
                        EventId = @event.EventId,
                        UserId  = user.UserId,
                        Status  = RSVPStatus.Pending,
                        User    = user.User
                    };

                    user.User.Invites.Add(invitation);
                    _context.Entry(user.User).State = EntityState.Modified;
                }
            }
            _context.SaveChanges();
        }
        public void CheckAutoAnswer(EventInvite eventInvite)
        {
            try
            {
                // Check if it is Autoanswer or not
                if (ConfigContainer.Instance().AllKeys.Contains("email.enable.auto-answer") &&
                    ((string)ConfigContainer.Instance().GetValue("email.enable.auto-answer")).ToLower().Equals("true"))
                {
                    //Get auto answer timer value from CME and show notifier when timer > 0
                    int seconds = 0;
                    int.TryParse(ConfigContainer.Instance().AllKeys.Contains("email.auto-answer.timer") ?
                                 ((string)ConfigContainer.Instance().GetValue("email.auto-answer.timer")) : "0", out seconds);

                    if (seconds > 0)
                    {
                        // Show or Hide reject button when email.auto-answer is set to true and the value of email.auto-answer.timer > 0
                        if (ConfigContainer.Instance().AllKeys.Contains("email.enable.auto-answer-reject") && ((string)ConfigContainer.Instance().GetValue("email.enable.auto-answer-reject")).ToLower().Equals("true"))
                        {
                            _taskbarNotifier.btnReject.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            _taskbarNotifier.btnReject.Visibility = Visibility.Collapsed;
                        }

                        _taskbarNotifier.objiNotifier      = (TaskbarNotifier.INotifier)_taskbarNotifier;
                        _taskbarNotifier.isAutoAnswerTimer = true;
                        //Converting seconds to milliseconds
                        _taskbarNotifier.StayOpenMilliseconds = seconds * 1000;
                        _taskbarNotifier.OpeningMilliseconds  = 1000;
                        _taskbarNotifier.HidingMilliseconds   = 500;

                        ShowEmailNotifier(eventInvite);
                    }
                    else
                    {
                        _taskbarNotifier.objiNotifier         = null;
                        _taskbarNotifier.isAutoAnswerTimer    = false;
                        _taskbarNotifier.StayOpenMilliseconds = 1000000000;
                        _taskbarNotifier.OpeningMilliseconds  = 1000;
                        _taskbarNotifier.HidingMilliseconds   = 500;
                        _taskbarNotifier.btnReject.Visibility = Visibility.Visible;
                        //Auto Answer
                        _taskbarNotifier.eventInvite = eventInvite;
                        _taskbarNotifier.ReadContactName();
                        _taskbarNotifier.DoEmailAccept();
                    }
                }
                else
                {
                    _taskbarNotifier.StayOpenMilliseconds = 1000000000;
                    _taskbarNotifier.OpeningMilliseconds  = 1000;
                    _taskbarNotifier.HidingMilliseconds   = 500;
                    _taskbarNotifier.btnReject.Visibility = Visibility.Visible;
                    ShowEmailNotifier(eventInvite);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error in CheckAutoAnswer " + ex.Message);
            }
        }