public static T ThreadSafeFirstOrDefault <T>(this AsyncObservableCollection <T> source) { lock (source.LockList) { return(source.FirstOrDefault()); } }
public static T ThreadSafeFirstOrDefault <T>(this AsyncObservableCollection <T> source, Func <T, bool> predicate) { lock (source.LockList) { return(source.FirstOrDefault(predicate)); } }
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); }
private void ExecuteVoiceCheckBoxChecked(object parameter) { if (parameter.ToString() == "False") { SelectedWorkSpaceList = ""; } else { WorkSpaceList = new AsyncObservableCollection <string>(ScreenPopConfigModel.Instance.GetStandardWorkSpace().ToList()); SelectedWorkSpaceList = WorkSpaceList.FirstOrDefault(p => p.ToString() == screenpopConfigs.DefaultWorkSpace); } }
private void UpdateTabItem(int index) { if (index == 1) { AgentStates.Clear(); tempAgents.ToList().ForEach(x => { if (!x.DefaultName.Equals("Buttons")) { AgentStates.Add(x); } }); Hide = tempAgents.FirstOrDefault(p => p.DefaultName == "Buttons"); HideOrDisable = Hide.Name.Equals("true", StringComparison.OrdinalIgnoreCase) ? true : false; } }
private bool canDelete(object Param) { bool toReturn = true; if (Param == null) { return(false); } ListBox bx = Param as ListBox; AsyncObservableCollection <FileItem> Files = (AsyncObservableCollection <FileItem>)bx.ItemsSource; if (Files == null) { return(false); } toReturn = Files.FirstOrDefault(p => p.IsChecked) != null; return(toReturn); }
/// <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; } }