// [TODO] - we want to call out the "change" points very clearly (where a customer would extend)
        // In this sample we are assuming that certain properties are in the EventData.
        // You should provide your own implementation of this method if you need
        // to customize the serialization.
        private static byte[] GetBytesInEvent(EventData eData)
        {
            var eventToPersist = new ColdStorageEvent();

            eventToPersist.Offset      = eData.Offset;
            eventToPersist.MessageType = (string)eData.Properties[EventDataPropertyKeys.MessageType];
            eventToPersist.Payload     = Encoding.UTF8.GetString(eData.GetBytes());
            return(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(eventToPersist) + EventDelimiter));
        }
Esempio n. 2
0
        // [TODO] - we want to call out the "change" points very clearly (where a customer would extend)
        // In this sample we are assuming that certain properties are in the EventData.
        // You should provide your own implementation of this method if you need 
        // to customize the serialization.
        private static byte[] GetBytesInEvent(EventData eData)
        {
            var eventToPersist = new ColdStorageEvent();
            // eventToPersist.Offset = eData.Offset;
            StringBuilder msgProps = new StringBuilder();

            
            msgProps.Append("Location" + ":" + eData.Properties["Location"] + ",");
            msgProps.Append("Time" + ":" + eData.Properties["Time"] + ",");
            msgProps.Append("Motion" + ":" + eData.Properties["Motion"] + ",");
            msgProps.Append("Hostname" + ":" + eData.Properties["Hostname"] );
            
            /*
            foreach (KeyValuePair<string, object> prop in eData.Properties)
            {               
                msgProps.Append(prop.Key + ":" + prop.Value + ",");
            }
             */
            
             // eventToPersist.MessageType = "regEvent"; //(string)eData.Properties[EventDataPropertyKeys.MessageType];
            // eventToPersist.Payload = Encoding.UTF8.GetString(eData.GetBytes());
            
            eventToPersist.Propertires = msgProps.ToString();
            Console.WriteLine("Message: " + JsonConvert.SerializeObject(eventToPersist) + EventDelimiter);
            return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(eventToPersist) + EventDelimiter);
        }
 // [TODO] - we want to call out the "change" points very clearly (where a customer would extend)
 // In this sample we are assuming that certain properties are in the EventData.
 // You should provide your own implementation of this method if you need 
 // to customize the serialization.
 private static byte[] GetBytesInEvent(EventData eData)
 {
     var eventToPersist = new ColdStorageEvent();
     eventToPersist.Offset = eData.Offset;
     eventToPersist.MessageType = (string)eData.Properties[EventDataPropertyKeys.MessageType];
     eventToPersist.Payload = Encoding.UTF8.GetString(eData.GetBytes());
     return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(eventToPersist) + EventDelimiter);
 }