Ejemplo n.º 1
0
        /// <summary>
        /// Build a CSV line for output from the given event.
        /// </summary>
        /// <param name="evt">The event to output.</param>
        /// <returns>A string representing the CSV form of the event.</returns>
        private string BuildOutputLine(PointEvent evt)
        {
            StringBuilder line = new StringBuilder();

            line.Append(evt.StartTime);

            foreach (var i in this.fieldOrdinals)
            {
                line.Append(',');
                line.Append(evt.GetField(i));
            }

            return(line.ToString());
        }
Ejemplo n.º 2
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);
                    }
                }
            }
        }
        public string CreateString(PointEvent currEvent)
        {

            if (EventKind.Cti == currEvent.EventKind)
            {
                return currEvent.StartTime.ToString();
            }
            else
            {
                return currEvent.GetField(1).ToString();
            }

        }
Ejemplo n.º 4
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);
                    }
                }
            }
        }
        /// <summary>
        /// Build a CSV line for output from the given event.
        /// </summary>
        /// <param name="evt">The event to output.</param>
        /// <returns>A string representing the CSV form of the event.</returns>
        private string BuildOutputLine(PointEvent evt)
        {
            StringBuilder line = new StringBuilder();
            line.Append(evt.StartTime);

            foreach (var i in this.fieldOrdinals)
            {
                line.Append(',');
                line.Append(evt.GetField(i));
            }

            return line.ToString();
        }