private void FillMessageThread() { List <WebChatMessage> listWebChatMessages = WebChatMessages.GetAllForSessions(_webChatSession.WebChatSessionNum); List <SmsThreadMessage> listThreadMessages = new List <SmsThreadMessage>(); foreach (WebChatMessage webChatMessage in listWebChatMessages) { string strMsg = webChatMessage.MessageText; if (webChatMessage.MessageType == WebChatMessageType.EndSession) { strMsg = MarkupEdit.ConvertToPlainText(strMsg); } SmsThreadMessage msg = new SmsThreadMessage(webChatMessage.DateT, strMsg, (webChatMessage.MessageType == WebChatMessageType.Customer), false, false, webChatMessage.UserName ); listThreadMessages.Add(msg); } webChatThread.ListSmsThreadMessages = listThreadMessages; }
///<summary>Only for ODHQ triage.</summary> private void FillGridWebChats() { gridWebChatSessions.BeginUpdate(); gridWebChatSessions.ListGridRows.Clear(); if (gridWebChatSessions.ListGridColumns.Count == 0) { gridWebChatSessions.ListGridColumns.Add(new GridColumn("DateTime", 80, HorizontalAlignment.Center)); gridWebChatSessions.ListGridColumns.Add(new GridColumn("IsEnded", 60, HorizontalAlignment.Center)); gridWebChatSessions.ListGridColumns.Add(new GridColumn("Owner", 80, HorizontalAlignment.Left)); gridWebChatSessions.ListGridColumns.Add(new GridColumn("PatNum", 80, HorizontalAlignment.Right)); gridWebChatSessions.ListGridColumns.Add(new GridColumn("SessionNum", 90, HorizontalAlignment.Right)); gridWebChatSessions.ListGridColumns.Add(new GridColumn("Question", 0, HorizontalAlignment.Left)); } List <WebChatSession> listChatSessions = null; List <WebChatMessage> listChatMessages = null; //If connection to webchat is lost or not visible from a specific network location, then continue, in order to keep the call center operational. ODException.SwallowAnyException(() => { listChatSessions = WebChatSessions.GetSessions(checkShowEndedSessions.Checked, dateRangeWebChat.GetDateTimeFrom(), dateRangeWebChat.GetDateTimeTo()); listChatMessages = WebChatMessages.GetAllForSessions(listChatSessions.Select(x => x.WebChatSessionNum).ToArray()); }); if (listChatSessions != null) //Will only be null if connection to webchat database failed. { List <Userod> listSelectedUsers = comboUsers.SelectedTags <Userod>(); List <string> listSelectedUsernames = listSelectedUsers.Select(x => x.UserName).ToList(); string searchText = textChatTextContains.Text.ToLower(); foreach (WebChatSession webChatSession in listChatSessions) { bool isRelevantSession = false; if (string.IsNullOrEmpty(webChatSession.TechName)) { isRelevantSession = true; //Unclaimed web chat sessions are visible to all technicians, so they can consider taking ownership. } else if (listSelectedUsernames.Count == 0) { isRelevantSession = true; //Filter for usernames is empty. Show chat sessions for all users. } else if (listSelectedUsernames.Contains(webChatSession.TechName)) { isRelevantSession = true; } else if (listChatMessages.Exists(x => x.WebChatSessionNum == webChatSession.WebChatSessionNum && listSelectedUsernames.Contains(x.UserName))) { isRelevantSession = true; } if (!isRelevantSession) { continue; } List <string> listMessagesForSession = listChatMessages .Where(x => x.WebChatSessionNum == webChatSession.WebChatSessionNum) .Select(x => x.MessageText.ToLower()) .ToList(); if (!string.IsNullOrEmpty(textSessionNum.Text) && !webChatSession.WebChatSessionNum.ToString().Contains(textSessionNum.Text)) { continue; } if (!string.IsNullOrEmpty(searchText) && !webChatSession.QuestionText.ToLower().Contains(searchText) && !listMessagesForSession.Exists(x => x.Contains(searchText))) { continue; } GridRow row = new GridRow(); row.Tag = webChatSession; row.Cells.Add(webChatSession.DateTcreated.ToString()); row.Cells.Add((webChatSession.DateTend.Year > 1880)?"X":""); TimeSpan spanWebChatAge = new TimeSpan(DateTime.Now.Ticks - webChatSession.DateTcreated.Ticks); Color backgroundColor = Color.FromArgb(247, 110, 110); //Changing this color will also need to change color in FormTasks.cs if (spanWebChatAge.TotalMinutes > 2) { //Change the color to red if the time since it was created is greater than 2 minutes. backgroundColor = Color.Red; } if (string.IsNullOrEmpty(webChatSession.TechName)) { row.Cells.Add("NEEDS TECH"); row.Bold = true; row.ColorBackG = backgroundColor; row.ColorText = Color.White; } else { row.Cells.Add(webChatSession.TechName); } row.Cells.Add((webChatSession.PatNum == 0)?"":webChatSession.PatNum.ToString()); row.Cells.Add(webChatSession.WebChatSessionNum.ToString()); row.Cells.Add(webChatSession.QuestionText); gridWebChatSessions.ListGridRows.Add(row); } } gridWebChatSessions.EndUpdate(); }