private void newInteractionHandler(object sender, InteractionEventArgs e) { ScreenPopOptions aniscreenpop = AgentScreenPop.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("ANIPop", StringComparison.OrdinalIgnoreCase)); ScreenPopOptions transaniscreenpop = AgentScreenPop.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("TranPop", StringComparison.OrdinalIgnoreCase)); // if ((e.Interaction as ICall).CallType == CallType.Inbound || ((e.Interaction as ICall).CallType == CallType.Consult)) if (InteractionProvider.CurrentInteraction != null && (((InteractionProvider.CurrentInteraction as ICall).CallType == CallType.Inbound) || ((InteractionProvider.CurrentInteraction as ICall).CallType == CallType.Consult && transaniscreenpop != null && transaniscreenpop.Description == "Y"))) { lock (_Imgrobject) { foreach (var handler in ScreenPopHandlers) { if (SynchronizationContext != null) { SynchronizationContext.Post(o => ((InvocationTarget)o).HandleInteraction(), new InvocationTarget { Interaction = e.Interaction, Handler = handler }); } else { handler.HandleInteraction(e.Interaction); } } Logger.Logger.Log.Info(string.Format("InteractionManager: Address {0}, UUI {1}, {2}", e.Interaction.Address, e.Interaction.InteractionData["UUI"], e.Interaction)); } } }
private AsyncObservableCollection <Entities> CombineEntity(string[] uui, List <ScreenPopOptions> UUI, string searchvalue) { int index = 3; AsyncObservableCollection <Entities> UUIs = new AsyncObservableCollection <Entities>(); foreach (string filter in uui) { if (!string.IsNullOrEmpty(filter)) { ScreenPopOptions val = UUI.SingleOrDefault(p => p.Name == ("UUI" + index) && p.Type == 0); int pos = val.Description.IndexOf('.'); if (pos > 0) { string workspace = val.Description.Substring(0, pos); Entities dup = UUIs.FirstOrDefault(p => p.Entity.Equals(workspace, StringComparison.OrdinalIgnoreCase)); if (dup != null) { dup.Predicate += " and " + string.Format(val.Description + "= '{0}'", filter); } else { Entities ent = new Entities(); ent.Entity = workspace; ent.Predicate = string.Format(val.Description + "= '{0}'", filter); ent.Expression = SEARCH_EXPRESSION[workspace.ToLower()].ToString(); UUIs.Add(ent); } } else if (string.Equals(val.Description, "ani", StringComparison.OrdinalIgnoreCase)) { Entities dup = UUIs.FirstOrDefault(p => p.Entity.Equals("Contact", StringComparison.OrdinalIgnoreCase)); Entities ent = new Entities(); ent.Entity = "Contact"; ent.Predicate = string.Format("Phones.RawNumber" + "= '{0}'", searchvalue); ent.Expression = SEARCH_EXPRESSION["Contact".ToLower()].ToString(); UUIs.Add(ent); } } index++; } return(UUIs); }
public ScreenPopConfig GetAgentScreenByProfile() { ScreenPopConfig conf = null; try { Logger.Logger.Log.Debug("RightNowConnectConfigurationProvider Getting ScreenPop "); conf = _objectProvider.GetScreenConfigByProfileId(Global.Context.ProfileId); if (conf.ScreenPopOptionsList == null) { conf = _objectProvider.GetScreenConfigByProfileId(0); } Logger.Logger.Log.DebugFormat("ScreenPopConfigModel <<< get-agent-configuration-by-profile."); if (conf.ScreenPopOptionsList != null && conf.ScreenPopOptionsList.Where(p => p.Type == 0).GroupBy(p => new { p.Type, p.Name }).Count() != conf.ScreenPopOptionsList.Where(p => p.Type == 0).Count()) { List <ScreenPopOptions> tempdefault = new List <ScreenPopOptions>(); foreach (ScreenPopOptions pop in conf.ScreenPopOptionsList.Where(p => p.Type == 0)) { ScreenPopOptions val = conf.ScreenPopOptionsList.FirstOrDefault(item => item.Type == 0 && item.Name == pop.Name); if (val == null) { tempdefault.Add(pop); } else if (!tempdefault.Contains(val)) { tempdefault.Add(val); } } conf.ScreenPopOptionsList.RemoveAll(rem => rem.Type == 0); tempdefault.ForEach((vap) => conf.ScreenPopOptionsList.Add(vap)); } if (conf.ScreenPopOptionsList != null && conf.ScreenPopOptionsList.Where(p => p.Type == 1).GroupBy(p => new { p.Type, p.Name }).Count() != conf.ScreenPopOptionsList.Where(p => p.Type == 1).Count()) { List <ScreenPopOptions> tempdefault = new List <ScreenPopOptions>(); foreach (ScreenPopOptions pop in conf.ScreenPopOptionsList.Where(item => item.Type == 1)) { ScreenPopOptions val = conf.ScreenPopOptionsList.FirstOrDefault(item => item.Type == 1 && item.Name == pop.Name); if (val == null) { tempdefault.Add(pop); } else if (!tempdefault.Contains(val)) { tempdefault.Add(val); } } conf.ScreenPopOptionsList.RemoveAll(rem => rem.Type == 1); tempdefault.ForEach((vap) => conf.ScreenPopOptionsList.Add(vap)); } if (conf.ScreenPopOptionsList != null && conf.ScreenPopOptionsList.Where(p => p.Type == 2).GroupBy(p => new { p.Type, p.Name }).Count() != conf.ScreenPopOptionsList.Where(p => p.Type == 2).Count()) { List <ScreenPopOptions> tempdefault = new List <ScreenPopOptions>(); foreach (ScreenPopOptions pop in conf.ScreenPopOptionsList.Where(p => p.Type == 2)) { ScreenPopOptions val = conf.ScreenPopOptionsList.FirstOrDefault(item => item.Type == 2 && item.Name == pop.Name); if (val == null) { tempdefault.Add(pop); } else if (!tempdefault.Contains(val)) { tempdefault.Add(val); } } conf.ScreenPopOptionsList.RemoveAll(rem => rem.Type == 2); tempdefault.ForEach((vap) => conf.ScreenPopOptionsList.Add(vap)); } if (conf.ScreenPopOptionsList != null && conf.ScreenPopOptionsList.Where(p => p.Type == 3).GroupBy(p => new { p.Type, p.Name }).Count() != conf.ScreenPopOptionsList.Where(p => p.Type == 3).Count()) { List <ScreenPopOptions> tempdefault = new List <ScreenPopOptions>(); foreach (ScreenPopOptions pop in conf.ScreenPopOptionsList.Where(p => p.Type == 3)) { ScreenPopOptions val = conf.ScreenPopOptionsList.FirstOrDefault(item => item.Type == 3 && item.Name == pop.Name); if (val == null) { tempdefault.Add(pop); } else if (!tempdefault.Contains(val)) { tempdefault.Add(val); } } conf.ScreenPopOptionsList.RemoveAll(rem => rem.Type == 3); tempdefault.ForEach((vap) => conf.ScreenPopOptionsList.Add(vap)); } } catch (Exception ex) { Logger.Logger.Log.Error(ex); return(conf); } finally { } return(conf); }
/// <summary> /// Handle the Screen Pop to the user. /// </summary> /// <param name="interaction"></param> public void HandleInteraction(IInteraction interaction) { Boolean isChat, isIncident, isVoice = false; switch (interaction.Type) { case MediaType.Voice: SynchronizationContext.Current.Post(scree => { try { AsyncObservableCollection <Entities> UUIs = new AsyncObservableCollection <Entities>(); ScreenPopConfig screenPopConfigs = interaction.ScreenPopConfiguration; if (screenPopConfigs.CanScreenPop) { string UUIvalue = interaction.InteractionData["UUI"]; ScreenPopOptions UUIstart = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUIStart", StringComparison.OrdinalIgnoreCase)); string start = UUIstart == null ? ";" : UUIstart.Description; ScreenPopOptions UUIstop = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUIStop", StringComparison.OrdinalIgnoreCase)); string stop = UUIstop == null ? ":" : UUIstop.Description; ScreenPopOptions UUIsep = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUISep", StringComparison.OrdinalIgnoreCase)); char seperator = UUIsep == null ? '!' : UUIsep.Description.ToCharArray()[0]; int startindex = UUIvalue.IndexOf(start, 0) + 1; int lastindex = UUIvalue.LastIndexOf(stop) == -1 ? UUIvalue.Length : UUIvalue.LastIndexOf(stop); int len = lastindex - startindex; string[] uuival = UUIvalue.Substring(startindex, len).Split(seperator); isChat = Array.IndexOf(uuival, InteractionIQAType.FEAT_IQA_ORACLE_CHAT.ToString()) >= 0; isIncident = Array.IndexOf(uuival, InteractionIQAType.FEAT_IQA_ORACLE_EMAIL.ToString()) >= 0; ArrayList uuiCI = new ArrayList(); //Namachi Regex UUICIRegex = new Regex("^UUI[1-2]", RegexOptions.IgnoreCase); List <ScreenPopOptions> UUICI = screenPopConfigs.ScreenPopOptionsList.Where(p => p.Type == 0 && UUICIRegex.Matches(p.Name).Count > 0).ToList(); Regex UUIRegex = new Regex("^UUI[3-7]", RegexOptions.IgnoreCase); List <ScreenPopOptions> UUI = screenPopConfigs.ScreenPopOptionsList.Where(p => p.Type == 0 && UUIRegex.Matches(p.Name).Count > 0).ToList(); //foreach (string filterval in uuival) { // if (filterval != UUICI[0].Description && filterval != UUICI[1].Description) uuiCI.Add(filterval); //} for (int i = 0; i < uuival.Length; i++) { if (i == 0 || i == 1) { if ((uuival[i] != UUICI[0].Description && uuival[i] != UUICI[1].Description) && (uuival[i] != null && uuival[i] != "")) { uuiCI.Add(uuival[i]); } } else if (uuival[i] != UUICI[0].Description && uuival[i] != UUICI[1].Description) { uuiCI.Add(uuival[i]); } } int index = 1; bool IsMatched = false; string searchvalue = ""; if ((interaction as ICall).CallType == CallType.Inbound) { searchvalue = interaction.Address; } else { string[] address = interaction.InteractionData["Consult"].Split('|'); searchvalue = address[0]; } AsyncObservableCollection <Entities> consolidatefilter = CombineEntity((string[])uuiCI.ToArray(typeof(string)), UUI, searchvalue); foreach (Entities filter in consolidatefilter) { string workspace = filter.Entity; bool found = false; Entities searchval = SearchEntites(filter); if (searchval.IDs.Count > 0) { Entities dup = UUIs.FirstOrDefault(p => p.Entity.Equals(searchval.Entity, StringComparison.OrdinalIgnoreCase)); if (dup != null) { searchval.IDs.ToList().ForEach(x => dup.IDs.Add(x.ToString())); } else { UUIs.Add(searchval); } found = true; } if (!IsMatched && found) { IsMatched = found; } } Open(UUIs); UUIs.Clear(); if ((interaction as ICall).CallType == CallType.Inbound) { ScreenPopOptions aniscreenpop = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("ANIPop", StringComparison.OrdinalIgnoreCase)); if (!IsMatched && aniscreenpop != null && aniscreenpop.Description == "Y") { bool found = false; // SearchAndPop("Contact", "Phones.RawNumber", "any_phone", searchvalue); Entities searchval = SearchEntites("Contact", "Phones.RawNumber", SEARCH_EXPRESSION["contact"].ToString(), searchvalue); //Entities searchval = SearchEntites("organization", "orgs.org_id", SEARCH_EXPRESSION["organization"].ToString(), searchvalue); if (searchval.IDs.Count > 0) { Entities dup = UUIs.FirstOrDefault(p => p.Entity.Equals(searchval.Entity, StringComparison.OrdinalIgnoreCase)); if (dup != null) { searchval.IDs.ToList().ForEach(x => dup.IDs.Add(x.ToString())); } else { UUIs.Add(searchval); } found = true; } if (!IsMatched && found) { IsMatched = found; } } //if (!(screenPopConfigs.CanOpen) && !IsMatched && aniscreenpop.Description == "Y") //{ //WorkspaceRecordType recordtype; //if (Enum.TryParse<WorkspaceRecordType>(screenPopConfigs.DefaultWorkSpace, out recordtype)) //{ // IsMatched = true; // RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype); //} //} WorkspaceRecordType recordtype; if (screenPopConfigs.ChatScreenPop) { if (isChat && !IsMatched) { if (screenPopConfigs.CanOpenChat == false) { if (Enum.TryParse <WorkspaceRecordType>(screenPopConfigs.ChatDefaultWorkspace, out recordtype)) { IsMatched = true; RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype); } } } } if (screenPopConfigs.IncidentScreenPop) { if (isIncident && !IsMatched) { if (screenPopConfigs.CanOpenIncident == false) { if (Enum.TryParse <WorkspaceRecordType>(screenPopConfigs.IncidentDefaultWorkspace, out recordtype)) { IsMatched = true; RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype); } } } } if (screenPopConfigs.VoiceScreenPop) { if (!isIncident && !isChat && !IsMatched) { if (screenPopConfigs.CanOpen == false) { if (Enum.TryParse <WorkspaceRecordType>(screenPopConfigs.DefaultWorkSpace, out recordtype)) { IsMatched = true; RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype); } } } } Logger.Logger.Log.Info(string.Format("ScreenPopHandler: Inbound ScreenPop Address {0}", searchvalue)); } else if ((interaction as ICall).CallType == CallType.Consult) { ScreenPopOptions aniscreenpop = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("TranPop", StringComparison.OrdinalIgnoreCase)); if (!IsMatched && aniscreenpop != null && (aniscreenpop.Description == "Y" || aniscreenpop.Description == "D")) { bool found = false; // SearchAndPop("Contact", "Phones.RawNumber", "any_phone", searchvalue); //"organization", "orgs.org_id" Entities searchval = SearchEntites("Contact", "Phones.RawNumber", SEARCH_EXPRESSION["contact"].ToString(), searchvalue); //Entities searchval = SearchEntites("organization", "organization.org_id", SEARCH_EXPRESSION["organization"].ToString(), searchvalue); if (searchval.IDs.Count > 0) { Entities dup = UUIs.FirstOrDefault(p => p.Entity.Equals(searchval.Entity, StringComparison.OrdinalIgnoreCase)); if (dup != null) { searchval.IDs.ToList().ForEach(x => dup.IDs.Add(x.ToString())); } else { UUIs.Add(searchval); } found = true; } if (!IsMatched && found) { IsMatched = found; } } if (!(screenPopConfigs.CanOpen) && !IsMatched && (aniscreenpop.Description == "Y" || aniscreenpop.Description == "D")) { WorkspaceRecordType recordtype; if (Enum.TryParse <WorkspaceRecordType>(screenPopConfigs.DefaultWorkSpace, out recordtype)) { IsMatched = true; RightNowGlobalContext.AutomationContext.CreateWorkspaceRecord(recordtype); } } Logger.Logger.Log.Info(string.Format("ScreenPopHandler: Consult ScreenPop Address {0} UUI = {1}", searchvalue, UUIvalue)); } Open(UUIs); UUIs.Clear(); } } catch (Exception ex) { Logger.Logger.Log.Error("ScreenPopHandler", ex); } }, null); break; case MediaType.Web: case MediaType.Email: RightNowGlobalContext.AutomationContext.EditWorkspaceRecord(WorkspaceRecordType.Incident, long.Parse(interaction.AdditionalIdentifiers["ReferenceId"])); break; default: return; } }
public ScreenPopConfig GetAgentConfigurationByProfile(int profileId) { Logger.Logger.Log.DebugFormat("ScreenPopConfigModel <<< get-agent-configuration-by-profile. ProfileId:{0}", profileId); try { ScreenPopConfig screepop = _screenConfigProvider.GetScreenPopConfigurationByProfile(profileId); if (screepop.ScreenPopOptionsList == null) { screepop.ScreenPopOptionsList = new List <ScreenPopOptions>(DefaultSearchOptions.ToList()); } else if (screepop.ScreenPopOptionsList != null && screepop.ScreenPopOptionsList.Where(p => p.Type == 0).Count() != DefaultSearchOptions.Count()) { List <ScreenPopOptions> tempdefault = new List <ScreenPopOptions>(); foreach (ScreenPopOptions pop in DefaultSearchOptions) { ScreenPopOptions val = screepop.ScreenPopOptionsList.FirstOrDefault(item => item.Type == 0 && item.Name == pop.Name); if (val == null) { tempdefault.Add(pop); } else if (!tempdefault.Contains(val)) { tempdefault.Add(val); } } screepop.ScreenPopOptionsList.RemoveAll(rem => rem.Type == 0); tempdefault.ForEach((vap) => screepop.ScreenPopOptionsList.Add(vap)); } if (screepop.ScreenPopOptionsList != null && screepop.ScreenPopOptionsList.Where(p => p.Type == 1).GroupBy(p => new { p.Type, p.Name }).Count() != screepop.ScreenPopOptionsList.Where(p => p.Type == 1).Count()) { List <ScreenPopOptions> tempdefault = new List <ScreenPopOptions>(); foreach (ScreenPopOptions pop in screepop.ScreenPopOptionsList.Where(item => item.Type == 1)) { ScreenPopOptions val = screepop.ScreenPopOptionsList.FirstOrDefault(item => item.Type == 1 && item.Name == pop.Name); if (val == null) { tempdefault.Add(pop); } else if (!tempdefault.Contains(val)) { tempdefault.Add(val); } } screepop.ScreenPopOptionsList.RemoveAll(rem => rem.Type == 1); tempdefault.ForEach((vap) => screepop.ScreenPopOptionsList.Add(vap)); } if (screepop.ScreenPopOptionsList != null && screepop.ScreenPopOptionsList.Where(p => p.Type == 2).GroupBy(p => new { p.Type, p.Name }).Count() != screepop.ScreenPopOptionsList.Where(p => p.Type == 2).Count()) { List <ScreenPopOptions> tempdefault = new List <ScreenPopOptions>(); foreach (ScreenPopOptions pop in screepop.ScreenPopOptionsList.Where(p => p.Type == 2)) { ScreenPopOptions val = screepop.ScreenPopOptionsList.FirstOrDefault(item => item.Type == 2 && item.Name == pop.Name); if (val == null) { tempdefault.Add(pop); } else if (!tempdefault.Contains(val)) { tempdefault.Add(val); } } screepop.ScreenPopOptionsList.RemoveAll(rem => rem.Type == 2); tempdefault.ForEach((vap) => screepop.ScreenPopOptionsList.Add(vap)); } if (screepop.ScreenPopOptionsList != null && screepop.ScreenPopOptionsList.Where(p => p.Type == 3).GroupBy(p => new { p.Type, p.Name }).Count() != screepop.ScreenPopOptionsList.Where(p => p.Type == 3).Count()) { List <ScreenPopOptions> tempdefault = new List <ScreenPopOptions>(); foreach (ScreenPopOptions pop in screepop.ScreenPopOptionsList.Where(p => p.Type == 3)) { ScreenPopOptions val = screepop.ScreenPopOptionsList.FirstOrDefault(item => item.Type == 3 && item.Name == pop.Name); if (val == null) { tempdefault.Add(pop); } else if (!tempdefault.Contains(val)) { tempdefault.Add(val); } } screepop.ScreenPopOptionsList.RemoveAll(rem => rem.Type == 3); tempdefault.ForEach((vap) => screepop.ScreenPopOptionsList.Add(vap)); } return(screepop); } catch (Exception ex) { Logger.Logger.Log.Error("ScreenPopConfigModel <<< get-agent-configuration failed.", ex); return(null); } }
public static MediaType cIInfoType(IInteraction interaction) { MediaType cInfoState = MediaType.Voice; try { //IInteraction cIInteraction = InteractionProvider.Interactions.FirstOrDefault(p => p.CallId == callIdNode.Value); if (interaction != null) { ScreenPopConfig screenPopConfigs = interaction.ScreenPopConfiguration; if (screenPopConfigs.CanScreenPop) { string UUIValue = interaction.InteractionData["UUI"]; ScreenPopOptions UUIstart = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUIStart", StringComparison.OrdinalIgnoreCase)); string start = UUIstart == null ? ";" : UUIstart.Description; ScreenPopOptions UUIstop = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUIStop", StringComparison.OrdinalIgnoreCase)); string stop = UUIstop == null ? ":" : UUIstop.Description; ScreenPopOptions UUIsep = screenPopConfigs.ScreenPopOptionsList.SingleOrDefault(p => p.Type == 0 && p.Name.Equals("UUISep", StringComparison.OrdinalIgnoreCase)); char seperator = UUIsep == null ? '!' : UUIsep.Description.ToCharArray()[0]; int startindex = UUIValue.IndexOf(start, 0) + 1; int lastindex = UUIValue.LastIndexOf(stop) == -1 ? UUIValue.Length : UUIValue.LastIndexOf(stop); int len = lastindex - startindex; string[] uui = UUIValue.Substring(startindex, len).Split(seperator); Regex chatIncidentRegex = new Regex("^UUI[1-2]", RegexOptions.IgnoreCase); List <ScreenPopOptions> cINotification = screenPopConfigs.ScreenPopOptionsList.Where(p => p.Type == 0 && chatIncidentRegex.Matches(p.Name).Count > 0).ToList(); try { if (uui.Length > 1) { Logger.Logger.Log.Debug(String.Format("AnswerHangupImage cINotifiction Details: {0} {1}: UUI Details: {2} {3} ", cINotification[0].Description, cINotification[1].Description, uui[0], uui[1])); if ((uui[0] == cINotification[0].Description || uui[1] == cINotification[0].Description) && (cINotification[0].Description != null && cINotification[0].Description != "")) { cInfoState = MediaType.Chat; } else if (uui[0] == cINotification[1].Description || uui[1] == cINotification[1].Description && (cINotification[1].Description != null && cINotification[1].Description != "")) { cInfoState = MediaType.Incident; } } else if (uui.Length == 1) { if (uui[0] == cINotification[0].Description && (cINotification[0].Description != null && cINotification[0].Description != "")) { cInfoState = MediaType.Chat; } else if (uui[0] == cINotification[1].Description && (cINotification[1].Description != null && cINotification[1].Description != "")) { cInfoState = MediaType.Incident; } } } catch (NullReferenceException ex) { Logger.Logger.Log.Error("Interaction null reference." + ex); } } } } catch (Exception ex) { Logger.Logger.Log.Debug("Interaction was null" + ex); } return(cInfoState); }