Esempio n. 1
0
        public static ExternalAction CreateExternalAction(string command, string commandData)
        {
            ExternalAction externalAction = new ExternalAction();

            externalAction.Action        = command;
            externalAction.ParameterData = commandData;
            externalAction.Async         = false;

            return(externalAction);
        }
Esempio n. 2
0
        public static ExternalAction CreateExternalAction(string command, string commandData)
        {
            ExternalAction externalAction = new ExternalAction();

            externalAction.Action = command;
            externalAction.ParameterData = commandData;
            externalAction.Async = false;

            return externalAction;
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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");
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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");
        }
Esempio n. 8
0
 public void RemoveExternalAction(ExternalAction externalAction)
 {
     action -= externalAction;
 }
Esempio n. 9
0
 public void AddExternalAction(ExternalAction externalAction)
 {
     action += externalAction;
 }
Esempio n. 10
0
        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);
            }
        }
Esempio n. 11
0
        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;
        }