Beispiel #1
0
        private bool IsEventDrivenSubscribed(EventDrivenActivity eventDriven)
        {
            IEventActivity            eventActivity = StateMachineHelpers.GetEventActivity(eventDriven);
            EventActivitySubscription subscription  = GetSubscription(eventActivity);

            return(subscription != null);
        }
Beispiel #2
0
 public static Task <long> Track(
     this IEventActivity instance,
     string eventName,
     DateTime timestamp)
 {
     return(Track(instance, eventName, timestamp, false));
 }
Beispiel #3
0
        internal void UnsubscribeEventDriven(ActivityExecutionContext context, EventDrivenActivity eventDriven)
        {
            Debug.Assert(IsEventDrivenSubscribed(eventDriven));
            IEventActivity eventActivity = StateMachineHelpers.GetEventActivity(eventDriven);

            UnsubscribeEventActivity(context, eventActivity);
        }
Beispiel #4
0
 public static Task <long> Track(
     this IEventActivity instance,
     string eventName,
     bool publishable)
 {
     return(Track(instance, eventName, DateTime.UtcNow, publishable));
 }
Beispiel #5
0
        public virtual async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            // es wird geprüft, ob die ankommende Nachricht eine "Message" ist. Messages sind die Nachrichten, die von Chat-Diensten, wie z.B. Skype kommen.
            //Anschließend wird diese Nachricht an den Bot gegeben, um diese zu verarbeiten.
            if (activity.GetActivityType() == ActivityTypes.Message)
            {
                activity.Locale = "de-DE";
                await Conversation.SendAsync(activity, () => new SuperDialog());
            }//Ankommende "Event" Nachrichten, die von den externen Azure Functions an den Bot gesendet werden.
            else if (activity.Type == ActivityTypes.Event)
            {
                IEventActivity triggerEvent    = activity;
                var            message         = JsonConvert.DeserializeObject <Message>(((JObject)triggerEvent.Value).GetValue("Message").ToString());
                var            messageactivity = (Activity)message.RelatesTo.GetPostToBotMessage();

                var client       = new ConnectorClient(new Uri(messageactivity.ServiceUrl));
                var triggerReply = messageactivity.CreateReply();
                triggerReply.Text = $"{message.Text}";
                await client.Conversations.ReplyToActivityAsync(triggerReply);
            }
            else
            {//Verarbeitung von "Systemnachrichten"
                HandleSystemMessage(activity);
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.Accepted));
        }
        private async Task DigestActionInputAsync <T>(DialogContext dc, IEventActivity ev, CancellationToken cancellationToken)
            where T : ActionBaseInput
        {
            var state = await _stateAccessor.GetAsync(dc.Context, () => new PointOfInterestSkillState(), cancellationToken);

            state.IsAction = true;

            if (ev.Value is JObject eventValue)
            {
                T actionData = eventValue.ToObject <T>();
                actionData.DigestActionInput(state);

                if (!string.IsNullOrEmpty(actionData.Zipcode))
                {
                    var service = _serviceManager.InitAddressMapsService(_settings);
                    PointOfInterestModel model;
                    if (string.IsNullOrEmpty(actionData.CountrySet))
                    {
                        model = await service.GetZipcodeAsync(actionData.Zipcode);
                    }
                    else
                    {
                        model = await service.GetZipcodeAsync(actionData.Zipcode, actionData.CountrySet);
                    }

                    state.CurrentCoordinates = model?.Geolocation ?? state.CurrentCoordinates;
                }
            }
        }
Beispiel #7
0
        public virtual async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            // check if activity is of type message
            if (activity.GetActivityType() == ActivityTypes.Message)
            {
                await Conversation.SendAsync(activity, () => new BrainStormDialog());

                //await Conversation.SendAsync(activity, () => new ProactiveDialog());
            }
            else if (activity.Type == ActivityTypes.Event)
            {
                IEventActivity triggerEvent    = activity;
                var            message         = JsonConvert.DeserializeObject <Message>(((JObject)triggerEvent.Value).GetValue("Message").ToString());
                var            messageactivity = (Activity)message.RelatesTo.GetPostToBotMessage();

                var client = new ConnectorClient(new Uri(messageactivity.ServiceUrl));
                if (message.IsTrustedServiceUrl)
                {
                    MicrosoftAppCredentials.TrustServiceUrl(messageactivity.ServiceUrl);
                }
                var triggerReply = messageactivity.CreateReply();
                await client.Conversations.ReplyToActivityAsync(triggerReply);
            }
            else
            {
                HandleSystemMessage(activity);
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.Accepted));
        }
        internal void SubscribeEventDriven(ActivityExecutionContext context, EventDrivenActivity eventDriven)
        {
            IEventActivity eventActivity = StateMachineHelpers.GetEventActivity(eventDriven);
            Activity       activity1     = (Activity)eventActivity;

            GetQueueName(eventActivity);
            this.SubscribeEventActivity(context, eventActivity);
        }
Beispiel #9
0
        internal void SubscribeEventDriven(ActivityExecutionContext context, EventDrivenActivity eventDriven)
        {
            IEventActivity eventActivity = StateMachineHelpers.GetEventActivity(eventDriven);
            Activity       activity      = (Activity)eventActivity;
            IComparable    queueName     = GetQueueName(eventActivity);

            Debug.Assert(!this.Subscriptions.ContainsKey(queueName));
            SubscribeEventActivity(context, eventActivity);
        }
Beispiel #10
0
        static internal IEventActivity GetEventActivity(EventDrivenActivity eventDriven)
        {
            CompositeActivity sequenceActivity = eventDriven as CompositeActivity;

            Debug.Assert(eventDriven.EnabledActivities.Count > 0);
            IEventActivity eventActivity = sequenceActivity.EnabledActivities[0] as IEventActivity;

            Debug.Assert(eventActivity != null);
            return(eventActivity);
        }
        private static bool ValidateMultipleIEventActivity(EventDrivenActivity eventDriven, ValidationErrorCollection validationErrors)
        {
            IEventActivity firstEventActivity = null;

            if (eventDriven.EnabledActivities.Count > 0)
            {
                firstEventActivity = eventDriven.EnabledActivities[0] as IEventActivity;
            }
            return(ValidateMultipleIEventActivityInCompositeActivity(eventDriven, firstEventActivity, eventDriven, validationErrors));
        }
 internal void Subscribe(ActivityExecutionContext context, StateActivity state, IEventActivity eventActivity)
 {
     eventActivity.Subscribe(context, this);
     Activity activity = (Activity) eventActivity;
     this._queueName = eventActivity.QueueName;
     this._eventActivityName = activity.QualifiedName;
     this._stateName = state.QualifiedName;
     base.SubscriptionId = Guid.NewGuid();
     EventDrivenActivity parentEventDriven = StateMachineHelpers.GetParentEventDriven(eventActivity);
     this._eventDrivenName = parentEventDriven.QualifiedName;
 }
 internal static EventDrivenActivity GetParentEventDriven(IEventActivity eventActivity)
 {
     for (Activity activity = ((Activity)eventActivity).Parent; activity != null; activity = activity.Parent)
     {
         EventDrivenActivity activity2 = activity as EventDrivenActivity;
         if (activity2 != null)
         {
             return(activity2);
         }
     }
     return(null);
 }
        private EventActivitySubscription GetSubscription(IEventActivity eventActivity)
        {
            IComparable queueName = GetQueueName(eventActivity);

            if ((queueName != null) && this.Subscriptions.ContainsKey(queueName))
            {
                EventActivitySubscription subscription = this.Subscriptions[queueName] as EventActivitySubscription;
                Activity activity = (Activity)eventActivity;
                if ((subscription != null) && !(subscription.EventActivityName != activity.QualifiedName))
                {
                    return(subscription);
                }
            }
            return(null);
        }
        internal void Subscribe(ActivityExecutionContext context,
                                StateActivity state,
                                IEventActivity eventActivity)
        {
            eventActivity.Subscribe(context, this);
            Activity activity = (Activity)eventActivity;

            this._queueName         = eventActivity.QueueName;
            this._eventActivityName = activity.QualifiedName;
            this._stateName         = state.QualifiedName;
            this.SubscriptionId     = Guid.NewGuid();
            EventDrivenActivity eventDriven = StateMachineHelpers.GetParentEventDriven(eventActivity);

            this._eventDrivenName = eventDriven.QualifiedName;
        }
Beispiel #16
0
        static internal EventDrivenActivity GetParentEventDriven(IEventActivity eventActivity)
        {
            Activity activity = ((Activity)eventActivity).Parent;

            while (activity != null)
            {
                EventDrivenActivity eventDriven = activity as EventDrivenActivity;
                if (eventDriven != null)
                {
                    return(eventDriven);
                }

                activity = activity.Parent;
            }
            return(null);
        }
Beispiel #17
0
        internal static void ChangeEventDrivenQueueState(ActivityExecutionContext context, EventDrivenActivity eventDriven, bool enabled)
        {
            IEventActivity eventActivity = StateMachineHelpers.GetEventActivity(eventDriven);
            IComparable    queueName     = GetQueueName(eventActivity);

            if (queueName == null)
            {
                return; // skip unitialized follower
            }
            WorkflowQueue workflowQueue = GetWorkflowQueue(context, queueName);

            if (workflowQueue != null)
            {
                workflowQueue.Enabled = enabled;
            }
        }
Beispiel #18
0
        public static Task <long[]> Counts(
            this IEventActivity instance,
            string eventName,
            DateTime startTimestamp,
            DateTime endTimestamp)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            return(instance.Counts(
                       eventName,
                       startTimestamp,
                       endTimestamp,
                       instance.Settings.Drilldown));
        }
Beispiel #19
0
        public static Task <long> Track(
            this IEventActivity instance,
            string eventName,
            DateTime timestamp,
            bool publishable)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            return(instance.Track(
                       eventName,
                       instance.Settings.Drilldown,
                       timestamp,
                       publishable));
        }
        private ReadOnlyCollection <string> GetPossibleStateTransitions()
        {
            List <string> targetStates = new List <string>();
            ReadOnlyCollection <WorkflowQueueInfo> workflowQueuedInfos  = this.WorkflowInstance.GetWorkflowQueueData();
            StateMachineWorkflowActivity           stateMachineWorkflow = this.StateMachineWorkflow;

            foreach (WorkflowQueueInfo queueInfo in workflowQueuedInfos)
            {
                foreach (string subscribedActivityName in queueInfo.SubscribedActivityNames)
                {
                    Activity       subscribedActivity = StateMachineHelpers.FindActivityByName(stateMachineWorkflow, subscribedActivityName);
                    IEventActivity eventActivity      = subscribedActivity as IEventActivity;
                    if (eventActivity == null)
                    {
                        continue;
                    }

                    EventDrivenActivity eventDriven = StateMachineHelpers.GetParentEventDriven(eventActivity);
                    Debug.Assert(eventDriven != null);
                    Queue <Activity> activities = new Queue <Activity>();
                    activities.Enqueue(eventDriven);
                    while (activities.Count > 0)
                    {
                        Activity         activity = activities.Dequeue();
                        SetStateActivity setState = activity as SetStateActivity;
                        if (setState != null)
                        {
                            targetStates.Add(setState.TargetStateName);
                        }
                        else
                        {
                            CompositeActivity compositeActivity = activity as CompositeActivity;
                            if (compositeActivity != null)
                            {
                                foreach (Activity childActivity in compositeActivity.EnabledActivities)
                                {
                                    activities.Enqueue(childActivity);
                                }
                            }
                        }
                    }
                }
            }
            return(targetStates.AsReadOnly());
        }
Beispiel #21
0
        public static Task <long> Count(
            this IEventActivity instance,
            string eventName,
            DateTime startTimestamp,
            DateTime endTimestamp)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            return(Count(
                       instance,
                       eventName,
                       startTimestamp,
                       endTimestamp,
                       instance.Settings.Timeframe));
        }
 private void UnsubscribeEventActivity(ActivityExecutionContext context, IEventActivity eventActivity, EventActivitySubscription subscription)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (eventActivity == null)
     {
         throw new ArgumentNullException("eventActivity");
     }
     if (subscription == null)
     {
         throw new ArgumentNullException("subscription");
     }
     subscription.Unsubscribe(context, eventActivity);
     this.RemoveFromQueue(subscription.SubscriptionId);
     this.Subscriptions.Remove(subscription.QueueName);
 }
        private void UnsubscribeEventActivity(ActivityExecutionContext context, IEventActivity eventActivity)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (eventActivity == null)
            {
                throw new ArgumentNullException("eventActivity");
            }
            EventActivitySubscription subscription  = this.GetSubscription(eventActivity);
            WorkflowQueue             workflowQueue = GetWorkflowQueue(context, subscription.QueueName);

            if (workflowQueue != null)
            {
                workflowQueue.Enabled = false;
            }
            this.UnsubscribeEventActivity(context, eventActivity, subscription);
        }
Beispiel #24
0
        private StateMachineSubscription SubscribeEventActivity(ActivityExecutionContext context,
                                                                IEventActivity eventActivity)
        {
            EventActivitySubscription subscription = new EventActivitySubscription();
            StateActivity             state        = (StateActivity)context.Activity;

            subscription.Subscribe(context, state, eventActivity);
            WorkflowQueue workflowQueue = GetWorkflowQueue(context, subscription.QueueName);

            if (workflowQueue != null)
            {
                workflowQueue.Enabled = true;
            }

            Debug.Assert(subscription.QueueName != null);
            this.Subscriptions[subscription.QueueName] = subscription;

            return(subscription);
        }
Beispiel #25
0
        private ReadOnlyCollection <string> GetPossibleStateTransitions()
        {
            List <string> list = new List <string>();
            ReadOnlyCollection <WorkflowQueueInfo> workflowQueueData    = this.WorkflowInstance.GetWorkflowQueueData();
            StateMachineWorkflowActivity           stateMachineWorkflow = this.StateMachineWorkflow;

            foreach (WorkflowQueueInfo info in workflowQueueData)
            {
                foreach (string str in info.SubscribedActivityNames)
                {
                    IEventActivity eventActivity = StateMachineHelpers.FindActivityByName(stateMachineWorkflow, str) as IEventActivity;
                    if (eventActivity != null)
                    {
                        EventDrivenActivity parentEventDriven = StateMachineHelpers.GetParentEventDriven(eventActivity);
                        Queue <Activity>    queue             = new Queue <Activity>();
                        queue.Enqueue(parentEventDriven);
                        while (queue.Count > 0)
                        {
                            Activity         activity5 = queue.Dequeue();
                            SetStateActivity activity6 = activity5 as SetStateActivity;
                            if (activity6 != null)
                            {
                                list.Add(activity6.TargetStateName);
                            }
                            else
                            {
                                CompositeActivity activity7 = activity5 as CompositeActivity;
                                if (activity7 != null)
                                {
                                    foreach (Activity activity8 in activity7.EnabledActivities)
                                    {
                                        queue.Enqueue(activity8);
                                    }
                                    continue;
                                }
                            }
                        }
                    }
                }
            }
            return(list.AsReadOnly());
        }
Beispiel #26
0
        public static async Task <long> Count(
            this IEventActivity instance,
            string eventName,
            DateTime startTimestamp,
            DateTime endTimestamp,
            ActivityDrilldown drilldown)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            var result = await instance.Counts(
                eventName,
                startTimestamp,
                endTimestamp,
                drilldown);

            return(result.First());
        }
Beispiel #27
0
        internal override void Execute(ActivityExecutionContext context)
        {
            base.Execute(context);

            StateActivity         state     = this.State;
            StateActivity         rootState = StateMachineHelpers.GetRootState(state);
            Queue <StateActivity> states    = new Queue <StateActivity>();

            states.Enqueue(rootState);
            while (states.Count > 0)
            {
                state = states.Dequeue();
                foreach (Activity activity in state.EnabledActivities)
                {
                    EventDrivenActivity eventDriven = activity as EventDrivenActivity;
                    if (eventDriven != null)
                    {
                        IEventActivity eventActivity = StateMachineHelpers.GetEventActivity(eventDriven);
                        IComparable    queueName     = eventActivity.QueueName;
                        if (queueName != null)
                        {
                            WorkflowQueue queue = StateMachineSubscriptionManager.GetWorkflowQueue(context, queueName);
                            if (queue != null)
                            {
                                queue.Enabled = this.SubscriptionManager.Subscriptions.ContainsKey(queueName);
                            }
                        }
                    }
                    else
                    {
                        StateActivity childState = activity as StateActivity;
                        if (childState != null)
                        {
                            states.Enqueue(childState);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                if (IsSpellCorrectionEnabled)
                {
                    try
                    {
                        activity.Text = await this.spellService.GetCorrectedTextAsync(activity.Text);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }
                }

                //await Conversation.SendAsync(activity, () => new RootLuisDialog());
                await Conversation.SendAsync(activity, () => new RootDialog());
            }
            else if (activity.Type == ActivityTypes.Event)
            {
                IEventActivity triggerEvent    = activity;
                var            message         = JsonConvert.DeserializeObject <Message>(((JObject)triggerEvent.Value).GetValue("Message").ToString());
                var            messageactivity = (Activity)message.RelatesTo.GetPostToBotMessage();

                var client       = new ConnectorClient(new Uri(messageactivity.ServiceUrl));
                var triggerReply = messageactivity.CreateReply();
                triggerReply.Text = "Sorry to interupt but I thought I would let you know that your build has finished! Great success!";
                await client.Conversations.ReplyToActivityAsync(triggerReply);
            }
            else
            {
                this.HandleSystemMessage(activity);
            }

            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
        public virtual async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            // check if activity is of type message
            if (activity.GetActivityType() == ActivityTypes.Message)
            {
                await Conversation.SendAsync(activity, () => new SuperDialog());
            }
            else if (activity.Type == ActivityTypes.Event)
            {
                IEventActivity triggerEvent    = activity;
                var            message         = JsonConvert.DeserializeObject <Message>(((JObject)triggerEvent.Value).GetValue("Message").ToString());
                var            messageactivity = (Activity)message.RelatesTo.GetPostToBotMessage();

                var client       = new ConnectorClient(new Uri(messageactivity.ServiceUrl));
                var triggerReply = messageactivity.CreateReply();
                triggerReply.Text = $"This is coming back from the trigger! {message.Text}";
                await client.Conversations.ReplyToActivityAsync(triggerReply);
            }
            else
            {
                HandleSystemMessage(activity);
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.Accepted));
        }
        private void UnsubscribeEventActivity(ActivityExecutionContext context,
            IEventActivity eventActivity)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            if (eventActivity == null)
                throw new ArgumentNullException("eventActivity");

            EventActivitySubscription subscription = GetSubscription(eventActivity);
            WorkflowQueue workflowQueue = GetWorkflowQueue(context, subscription.QueueName);
            if (workflowQueue != null)
                workflowQueue.Enabled = false;
            UnsubscribeEventActivity(context, eventActivity, subscription);
        }
        private StateMachineSubscription SubscribeEventActivity(ActivityExecutionContext context,
            IEventActivity eventActivity)
        {
            EventActivitySubscription subscription = new EventActivitySubscription();
            StateActivity state = (StateActivity)context.Activity;
            subscription.Subscribe(context, state, eventActivity);
            WorkflowQueue workflowQueue = GetWorkflowQueue(context, subscription.QueueName);
            if (workflowQueue != null)
                workflowQueue.Enabled = true;

            Debug.Assert(subscription.QueueName != null);
            this.Subscriptions[subscription.QueueName] = subscription;

            return subscription;
        }
Beispiel #32
0
 internal void Unsubscribe(ActivityExecutionContext context, IEventActivity eventActivity)
 {
     eventActivity.Unsubscribe(context, this);
 }
 internal void Unsubscribe(ActivityExecutionContext context, IEventActivity eventActivity)
 {
     eventActivity.Unsubscribe(context, this);
 }
 internal static EventDrivenActivity GetParentEventDriven(IEventActivity eventActivity)
 {
     for (Activity activity = ((Activity) eventActivity).Parent; activity != null; activity = activity.Parent)
     {
         EventDrivenActivity activity2 = activity as EventDrivenActivity;
         if (activity2 != null)
         {
             return activity2;
         }
     }
     return null;
 }
 private static bool ValidateMultipleIEventActivityInCompositeActivity(EventDrivenActivity eventDriven, IEventActivity firstEventActivity, CompositeActivity parent, ValidationErrorCollection validationErrors)
 {
     foreach (Activity activity in parent.Activities)
     {
         if (activity.Enabled && (activity != firstEventActivity))
         {
             if (activity is IEventActivity)
             {
                 validationErrors.Add(new ValidationError(SR.GetString("Error_EventDrivenMultipleEventActivity", new object[] { eventDriven.Name, typeof(IEventActivity).FullName, typeof(EventDrivenActivity).Name }), 0x524));
                 return false;
             }
             CompositeActivity activity2 = activity as CompositeActivity;
             if ((activity2 != null) && !ValidateMultipleIEventActivityInCompositeActivity(eventDriven, firstEventActivity, activity2, validationErrors))
             {
                 return false;
             }
         }
     }
     return true;
 }
 private static IComparable GetQueueName(IEventActivity eventActivity)
 {
     return eventActivity.QueueName;
 }
        private void UnsubscribeEventActivity(ActivityExecutionContext context,
            IEventActivity eventActivity,
            EventActivitySubscription subscription)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            if (eventActivity == null)
                throw new ArgumentNullException("eventActivity");
            if (subscription == null)
                throw new ArgumentNullException("subscription");

            subscription.Unsubscribe(context, eventActivity);
            RemoveFromQueue(subscription.SubscriptionId);

            Debug.Assert(subscription.QueueName != null);
            this.Subscriptions.Remove(subscription.QueueName);
        }
        static internal EventDrivenActivity GetParentEventDriven(IEventActivity eventActivity)
        {
            Activity activity = ((Activity)eventActivity).Parent;
            while (activity != null)
            {
                EventDrivenActivity eventDriven = activity as EventDrivenActivity;
                if (eventDriven != null)
                    return eventDriven;

                activity = activity.Parent;
            }
            return null;
        }
        private static bool ValidateMultipleIEventActivityInCompositeActivity(EventDrivenActivity eventDriven, IEventActivity firstEventActivity, CompositeActivity parent, ValidationErrorCollection validationErrors)
        {
            foreach (Activity activity in parent.Activities)
            {
                // Skip disabled activities or the first IEventActivity
                // Note that we don't use EnabledActivities because we want to 
                // enforce this rule inside Cancellation and Exception Handlers.
                if (!activity.Enabled || activity == firstEventActivity)
                    continue;

                if (activity is IEventActivity)
                {
                    validationErrors.Add(new ValidationError(
                        SR.GetString(SR.Error_EventDrivenMultipleEventActivity, eventDriven.Name, typeof(IEventActivity).FullName, typeof(EventDrivenActivity).Name),
                        ErrorNumbers.Error_EventDrivenMultipleEventActivity));
                    return false;
                }
                else
                {
                    CompositeActivity compositeActivity = activity as CompositeActivity;
                    if (compositeActivity != null)
                    {
                        bool result = ValidateMultipleIEventActivityInCompositeActivity(eventDriven, firstEventActivity, compositeActivity, validationErrors);
                        if (!result)
                            return false;
                    }
                }
            }
            return true;
        }
        private EventActivitySubscription GetSubscription(IEventActivity eventActivity)
        {
            IComparable queueName = GetQueueName(eventActivity);
            if ((queueName == null) || (!this.Subscriptions.ContainsKey(queueName)))
                return null;

            EventActivitySubscription subscription = this.Subscriptions[queueName] as EventActivitySubscription;

            Activity activity = (Activity)eventActivity;
            if (subscription == null ||
                subscription.EventActivityName != activity.QualifiedName)
                return null;

            return subscription;
        }
 private static IComparable GetQueueName(IEventActivity eventActivity)
 {
     IComparable queueName = eventActivity.QueueName;
     return queueName;
 }
        private Task <LivePersonConversationRecord> Escalate(ITurnContext turnContext, IEventActivity handoffEvent)
        {
            var account      = _creds.LpAccount;
            var clientId     = _creds.LpAppId;
            var clientSecret = _creds.LpAppSecret;

            return(LivePersonConnector.EscalateToAgenAsync(turnContext, handoffEvent, account, clientId, clientSecret, _conversationMap));
        }
 private EventActivitySubscription GetSubscription(IEventActivity eventActivity)
 {
     IComparable queueName = GetQueueName(eventActivity);
     if ((queueName != null) && this.Subscriptions.ContainsKey(queueName))
     {
         EventActivitySubscription subscription = this.Subscriptions[queueName] as EventActivitySubscription;
         Activity activity = (Activity) eventActivity;
         if ((subscription != null) && !(subscription.EventActivityName != activity.QualifiedName))
         {
             return subscription;
         }
     }
     return null;
 }