public static ExternalAction CreateExternalAction(string command, string commandData) { ExternalAction externalAction = new ExternalAction(); externalAction.Action = command; externalAction.ParameterData = commandData; externalAction.Async = false; return(externalAction); }
public static ExternalAction CreateExternalAction(string command, string commandData) { ExternalAction externalAction = new ExternalAction(); externalAction.Action = command; externalAction.ParameterData = commandData; externalAction.Async = false; return externalAction; }
public void ShouldNotGarbageCollectDelegateReferenceWhenUsingKeepAlive() { var CompositePresentationEvent = new TestableCompositePresentationEvent <string>(); var externalAction = new ExternalAction(); CompositePresentationEvent.Subscribe(externalAction.ExecuteAction, ThreadOption.PublisherThread, true); WeakReference actionEventReference = new WeakReference(externalAction); externalAction = null; GC.Collect(); GC.Collect(); Assert.IsTrue(actionEventReference.IsAlive); CompositePresentationEvent.Publish("testPayload"); Assert.AreEqual("testPayload", ((ExternalAction)actionEventReference.Target).PassedValue); }
public void ShouldNotExecuteOnGarbageCollectedDelegateReferenceWhenNotKeepAlive() { var CompositePresentationEvent = new TestableCompositePresentationEvent <string>(); ExternalAction externalAction = new ExternalAction(); CompositePresentationEvent.Subscribe(externalAction.ExecuteAction); CompositePresentationEvent.Publish("testPayload"); Assert.AreEqual("testPayload", externalAction.PassedValue); WeakReference actionEventReference = new WeakReference(externalAction); externalAction = null; GC.Collect(); Assert.IsFalse(actionEventReference.IsAlive); CompositePresentationEvent.Publish("testPayload"); }
public void ShouldNotGarbageCollectDelegateReferenceWhenUsingKeepAliveNonGeneric() { var pubSubEvent = new TestablePubSubEvent(); var externalAction = new ExternalAction(); pubSubEvent.Subscribe(externalAction.ExecuteAction, ThreadOption.PublisherThread, true); WeakReference actionEventReference = new WeakReference(externalAction); externalAction = null; GC.Collect(); GC.Collect(); Assert.IsTrue(actionEventReference.IsAlive); pubSubEvent.Publish(); Assert.IsTrue(((ExternalAction)actionEventReference.Target).Executed); }
public void ShouldNotExecuteOnGarbageCollectedDelegateReferenceWhenNotKeepAliveNonGeneric() { var pubSubEvent = new TestablePubSubEvent(); var externalAction = new ExternalAction(); pubSubEvent.Subscribe(externalAction.ExecuteAction); pubSubEvent.Publish(); Assert.IsTrue(externalAction.Executed); var actionEventReference = new WeakReference(externalAction); externalAction = null; GC.Collect(); Assert.IsFalse(actionEventReference.IsAlive); pubSubEvent.Publish(); }
public async Task ShouldNotExecuteOnGarbageCollectedDelegateReferenceWhenNotKeepAlive() { var PubSubEvent = new TestablePubSubEvent <string>(); ExternalAction externalAction = new ExternalAction(); PubSubEvent.Subscribe(externalAction.ExecuteAction); PubSubEvent.Publish("testPayload"); Assert.Equal("testPayload", externalAction.PassedValue); WeakReference actionEventReference = new WeakReference(externalAction); externalAction = null; await Task.Delay(100); GC.Collect(); Assert.False(actionEventReference.IsAlive); PubSubEvent.Publish("testPayload"); }
public void RemoveExternalAction(ExternalAction externalAction) { action -= externalAction; }
public void AddExternalAction(ExternalAction externalAction) { action += externalAction; }
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); } }
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; }