ResultCode IPointInputAdapter.EnqueueEvent(WcfPointEvent wcfPointEvent)
        {
            lock (sync)
            {
                switch (AdapterState)
                {
                case AdapterState.Created:
                case AdapterState.Suspended:
                    return(ResultCode.Suspended);

                case AdapterState.Stopping:
                case AdapterState.Stopped:
                    return(ResultCode.Stopped);
                }

                if (wcfPointEvent.IsInsert)
                {
                    return(EnqueueInsert(wcfPointEvent.StartTime, wcfPointEvent.Payload));
                }
                else
                {
                    return(EnqueueCti(wcfPointEvent.StartTime));
                }
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string key = cboEventMessages.Text;
            string val = evtMessages[key];
        

            WSHttpBinding myBinding = new WSHttpBinding();
//            EndpointAddress addr = new EndpointAddress("http://localhost/StreamInsightv12/RSEROTER/InputAdapter");
            EndpointAddress addr = new EndpointAddress("http://localhost/StreamInsight/Default/InputAdapter");

            ChannelFactory<IPointInputAdapter> factory = new ChannelFactory<IPointInputAdapter>(myBinding, addr);

            IPointInputAdapter client = factory.CreateChannel();

            WcfPointEvent evt = new WcfPointEvent();
            evt.StartTime = DateTime.Now;
            evt.IsInsert = true;
            evt.Payload = new Dictionary<string, object>();
            evt.Payload.Add("Category", val);
            evt.Payload.Add("EventMessage", key);
            
            client.EnqueueEvent(evt);

            lblStatus.Text = "Status: Submitted at " + DateTime.Now.ToString();
        }
示例#3
0
 public bool TryEnqueueCtiEvent(DateTimeOffset startTime)
 {
     this.currentEvent = new WcfPointEvent
     {
         StartTime = startTime,
     };
     return(RunTask());
 }
示例#4
0
 /// <summary>
 /// Enqueues an insert event. Returns false if the adapter has stopped.
 /// </summary>
 public bool TryEnqueueInsertEvent(DateTimeOffset startTime, Dictionary <string, object> payload)
 {
     // The event stored in the "currentEvent" field is used within the TryRunTask
     // method.
     this.currentEvent = new WcfPointEvent
     {
         IsInsert  = true,
         StartTime = startTime,
         Payload   = payload,
     };
     return(RunTask());
 }
示例#5
0
 /// <summary>
 /// Dequeues an event. Returns false if the adapter has stopped.
 /// </summary>
 public bool TryDequeueEvent(out WcfPointEvent wcfPointEvent)
 {
     // The result of the dequeue task is stored in the "currentEvent"
     // field by the "TryRunTask" method.
     if (RunTask())
     {
         wcfPointEvent = this.currentEvent;
         return(true);
     }
     wcfPointEvent = default(WcfPointEvent);
     return(false);
 }
示例#6
0
        ResultCode IPointOutputAdapter.DequeueEvent(out WcfPointEvent result)
        {
            lock (sync)
            {
                result = default(WcfPointEvent);
                switch (AdapterState)
                {
                case AdapterState.Created:
                case AdapterState.Suspended:
                    return(ResultCode.Suspended);

                case AdapterState.Stopping:
                case AdapterState.Stopped:
                    return(ResultCode.Stopped);
                }

                PointEvent pointEvent = null;
                try
                {
                    if (Dequeue(out pointEvent) == DequeueOperationResult.Empty)
                    {
                        Ready();
                        return(ResultCode.Suspended);
                    }
                    else
                    {
                        result = new WcfPointEvent
                        {
                            IsInsert  = pointEvent.EventKind == EventKind.Insert,
                            StartTime = pointEvent.StartTime,
                        };
                        if (result.IsInsert)
                        {
                            // Extract all field values to generate the payload.
                            result.Payload = this.eventType.Fields.Values.ToDictionary(
                                f => f.Name,
                                f => pointEvent.GetField(f.Ordinal));
                        }
                        return(ResultCode.Success);
                    }
                }
                finally
                {
                    if (null != pointEvent)
                    {
                        ReleaseEvent(ref pointEvent);
                    }
                }
            }
        }
        ResultCode IPointOutputAdapter.DequeueEvent(out WcfPointEvent result)
        {
            lock (sync)
            {
                result = default(WcfPointEvent);
                switch (AdapterState)
                {
                    case AdapterState.Created:
                    case AdapterState.Suspended:
                        return ResultCode.Suspended;
                    case AdapterState.Stopping:
                    case AdapterState.Stopped:
                        return ResultCode.Stopped;
                }

                PointEvent pointEvent = null;
                try
                {
                    if (Dequeue(out pointEvent) == DequeueOperationResult.Empty)
                    {
                        Ready();
                        return ResultCode.Suspended;
                    }
                    else
                    {
                        result = new WcfPointEvent
                        {
                            IsInsert = pointEvent.EventKind == EventKind.Insert,
                            StartTime = pointEvent.StartTime,
                        };
                        if (result.IsInsert)
                        {
                            // Extract all field values to generate the payload.
                            result.Payload = this.eventType.Fields.Values.ToDictionary(
                                f => f.Name,
                                f => pointEvent.GetField(f.Ordinal));
                        }
                        return ResultCode.Success;
                    }
                }
                finally
                {
                    if (null != pointEvent)
                    {
                        ReleaseEvent(ref pointEvent);
                    }
                }
            }
        }
	//implement the operation included in interface definition
	public ResultCode PublishEvent(WcfPointEvent result)
	{
		//get category from key/value payload
		string cat = result.Payload["Category"].ToString();
		//get message from key/value payload
		string msg = result.Payload["EventMessage"].ToString();

		//get SignalR connection manager
		IConnectionManager mgr = AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
		//retrieve list of all connected clients
		dynamic clients = mgr.GetClients<BizEventController>();

		//send message to all clients for given category
		clients[cat].addEventMsg(msg);
		//also send message to anyone subscribed to all events
		clients["All"].addEventMsg(msg);

		return ResultCode.Success;
	}
示例#9
0
        private void btnSendWebHits_Click(object sender, EventArgs e)
        {
            WSHttpBinding myBinding = new WSHttpBinding();
//            EndpointAddress addr = new EndpointAddress("http://localhost/StreamInsightv12/RSEROTER/InputAdapter");
            EndpointAddress addr = new EndpointAddress("http://localhost/StreamInsight/Default/InputAdapter");

            ChannelFactory<IPointInputAdapter> factory = new ChannelFactory<IPointInputAdapter>(myBinding, addr);

            IPointInputAdapter client = factory.CreateChannel();

            for (int i = 0; i < Convert.ToInt32(txtWebHits.Text.ToString()); i++)
            {
                WcfPointEvent evt = new WcfPointEvent();
                evt.StartTime = DateTime.Now;
                evt.IsInsert = true;
                evt.Payload = new Dictionary<string, object>();
                evt.Payload.Add("Category", "Web");
                evt.Payload.Add("EventMessage", "Web Hit");

                client.EnqueueEvent(evt);
            }
            lblStatus.Text = "Status: Submitted at " + DateTime.Now.ToString();
        }
        ResultCode IPointInputAdapter.EnqueueEvent(WcfPointEvent wcfPointEvent)
        {
            lock (sync)
            {
                switch (AdapterState)
                {
                    case AdapterState.Created:
                    case AdapterState.Suspended:
                        return ResultCode.Suspended;
                    case AdapterState.Stopping:
                    case AdapterState.Stopped:
                        return ResultCode.Stopped;
                }

                if (wcfPointEvent.IsInsert)
                {
                    return EnqueueInsert(wcfPointEvent.StartTime, wcfPointEvent.Payload);
                }
                else
                {
                    return EnqueueCti(wcfPointEvent.StartTime);
                }
            }
        }
示例#11
0
        void DequeueEvent()
        {
            lock (sync)
            {
                PointEvent currentEvent = default(PointEvent);
                //switch (AdapterState)
                //{
                //    case AdapterState.Created:
                //    case AdapterState.Suspended:
                //        return ResultCode.Suspended;
                //    case AdapterState.Stopping:
                //    case AdapterState.Stopped:
                //        return ResultCode.Stopped;
                //}

                WcfPointEvent       result;
                IPointEventReceiver client = null;
                try
                {
                    while (true)
                    {
                        if (AdapterState.Stopping == AdapterState)
                        {
                            Stopped();

                            return;
                        }

                        if (DequeueOperationResult.Empty == Dequeue(out currentEvent))
                        {
                            Ready();
                            return;
                        }


                        result = new WcfPointEvent
                        {
                            IsInsert  = currentEvent.EventKind == EventKind.Insert,
                            StartTime = currentEvent.StartTime,
                        };
                        if (result.IsInsert)
                        {
                            // Extract all field values to generate the payload.
                            result.Payload = this.eventType.Fields.Values.ToDictionary(
                                f => f.Name,
                                f => currentEvent.GetField(f.Ordinal));

                            //publish message to service
                            client = factory.CreateChannel();
                            client.PublishEvent(result);
                            ((IClientChannel)client).Close();
                        }
                        //return ResultCode.Success;
                    }
                }
                finally
                {
                    if (null != client)
                    {
                        ((IClientChannel)client).Close();
                    }

                    if (null != currentEvent)
                    {
                        ReleaseEvent(ref currentEvent);
                    }
                }
            }
        }
        void DequeueEvent()
        {
            lock (sync)
            {
                PointEvent currentEvent = default(PointEvent);
                //switch (AdapterState)
                //{
                //    case AdapterState.Created:
                //    case AdapterState.Suspended:
                //        return ResultCode.Suspended;
                //    case AdapterState.Stopping:
                //    case AdapterState.Stopped:
                //        return ResultCode.Stopped;
                //}

                WcfPointEvent result;
                IPointEventReceiver client = null;
                try
                {
                    while (true)
                    {
                        if (AdapterState.Stopping == AdapterState)
                        {
                            Stopped();

                            return;
                        }

                        if (DequeueOperationResult.Empty == Dequeue(out currentEvent))
                        {
                            Ready();
                            return;
                        }

                       
                            result = new WcfPointEvent
                            {
                                IsInsert = currentEvent.EventKind == EventKind.Insert,
                                StartTime = currentEvent.StartTime,
                            };
                            if (result.IsInsert)
                            {
                                // Extract all field values to generate the payload.
                                result.Payload = this.eventType.Fields.Values.ToDictionary(
                                    f => f.Name,
                                    f => currentEvent.GetField(f.Ordinal));

                                //publish message to service
                                client = factory.CreateChannel();
                                client.PublishEvent(result);
                                ((IClientChannel)client).Close();
                            }
                            //return ResultCode.Success;
                        }
                }
                finally
                {
                    if (null != client)
                    {
                        ((IClientChannel)client).Close();
                    }

                    if (null != currentEvent)
                    {
                        ReleaseEvent(ref currentEvent);
                    }
                }
            }
        }