public static bool ProcessPersonalizedGreeting(WOSI.CallButler.Data.DataProviders.CallButlerDataProviderBase dataProvider, ref WOSI.IVR.IML.Classes.ScriptPage scriptPage, int customerID, string callerDisplayName, string callerPhoneNumber, string callerHost, string dialedPhoneNumber) { // Loop through our personalized greetings and see if we can find one that matches our caller WOSI.CallButler.Data.CallButlerDataset.PersonalizedGreetingsDataTable personalGreetings = dataProvider.GetPersonalizedGreetings(customerID); WOSI.CallButler.Data.CallButlerDataset.PersonalizedGreetingsRow personalizedGreeting = null; foreach (WOSI.CallButler.Data.CallButlerDataset.PersonalizedGreetingsRow pgRow in personalGreetings) { string matchExpression = ""; // Try our dialed number first if (pgRow.DialedUsername.Length > 0) { if (!pgRow.UseRegex) { matchExpression = pgRow.DialedUsername.Replace("*", ".*"); } else { matchExpression = pgRow.DialedUsername; } if (Regex.IsMatch(dialedPhoneNumber, matchExpression, RegexOptions.IgnoreCase)) { personalizedGreeting = pgRow; break; } } // Next try our caller username/phone number if (pgRow.CallerUsername.Length > 0) { if (!pgRow.UseRegex) { matchExpression = pgRow.CallerUsername.Replace("*", ".*"); } else { matchExpression = pgRow.CallerUsername; } // First find by the caller number if (Regex.IsMatch(callerPhoneNumber, matchExpression, RegexOptions.IgnoreCase)) { personalizedGreeting = pgRow; break; } } // Next try the host if (pgRow.CallerHost.Length > 0) { if (!pgRow.UseRegex) { matchExpression = pgRow.CallerHost.Replace("*", ".*"); } else { matchExpression = pgRow.CallerHost; } if (Regex.IsMatch(callerHost, matchExpression, RegexOptions.IgnoreCase)) { personalizedGreeting = pgRow; break; } } // Next try the caller id/name if (pgRow.CallerDisplayName.Length > 0) { if (!pgRow.UseRegex) { matchExpression = pgRow.CallerDisplayName.Replace("*", ".*"); } else { matchExpression = pgRow.CallerDisplayName; } if (Regex.IsMatch(callerDisplayName, matchExpression, RegexOptions.IgnoreCase)) { personalizedGreeting = pgRow; break; } } } // If we have a personalized greeting, tell the interpreter to play it if (personalizedGreeting != null && (!personalizedGreeting.PlayOnce || (personalizedGreeting.PlayOnce && !personalizedGreeting.HasPlayed))) { scriptPage.Actions.Add(ScriptUtils.CreateGreetingExternalAction(personalizedGreeting.PersonalizedGreetingID)); switch (personalizedGreeting.Type) { case (short)WOSI.CallButler.Data.PersonalizedGreetingType.CustomScript: GotoPage gotoCustomScript = new GotoPage(); gotoCustomScript.Location = personalizedGreeting.Data; scriptPage.Actions.Add(gotoCustomScript); break; case (short)WOSI.CallButler.Data.PersonalizedGreetingType.Hangup: scriptPage.Actions.Add(new HangupCall()); break; case (short)WOSI.CallButler.Data.PersonalizedGreetingType.SendToExtension: // Get the proper extension WOSI.CallButler.Data.CallButlerDataset.ExtensionsRow extension = dataProvider.GetExtension(customerID, new Guid(personalizedGreeting.Data)); if (extension != null) { TransferCall transferCall = new TransferCall(); transferCall.TransferTo = extension.ExtensionNumber.ToString(); transferCall.IsExtension = true; scriptPage.Actions.Add(transferCall); } break; case (short)WOSI.CallButler.Data.PersonalizedGreetingType.Module: ExternalAction moduleAction = new ExternalAction(); moduleAction.Async = false; moduleAction.Action = BaseExternalCommands.CALLBUTLERINTERNAL_StartAddonModule.ToString(); moduleAction.ParameterData = personalizedGreeting.Data; scriptPage.Actions.Add(moduleAction); break; } if (personalizedGreeting.PlayOnce) { personalizedGreeting.HasPlayed = true; dataProvider.PersistPersonalizedGreeting(personalizedGreeting); } return(true); } else { return(false); } }