当前位置: 首页>>代码示例>>C#>>正文


C# EventData.GetBytes方法代码示例

本文整理汇总了C#中EventData.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# EventData.GetBytes方法的具体用法?C# EventData.GetBytes怎么用?C# EventData.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventData的用法示例。


在下文中一共展示了EventData.GetBytes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteJsonEntry

        private void WriteJsonEntry(EventData e)
        {
            _writer.WriteStartObject();

            _writer.WritePropertyName("index");

            // Write the batch "index" operation header
            _writer.WriteStartObject();
            // ES index names must be lower case and cannot contain whitespace or any of the following characters \/*?"<>|,
            WriteValue("_index", this.GetIndexName(e.EnqueuedTimeUtc));
            WriteValue("_type", _entryType);

            _writer.WriteEndObject();
            _writer.WriteEndObject();
            _writer.WriteRaw("\n");  //ES requires this \n separator

            var payload = JObject.Parse(Encoding.UTF8.GetString(e.GetBytes()));

            foreach (var property in e.Properties)
            {
                payload.Add("Properties-" + property.Key, new JValue(property.Value));
            }

            _writer.WriteRaw(payload.ToString(Formatting.None));
            
            _writer.WriteRaw("\n");
        }
开发者ID:carloserodriguez2000,项目名称:iot-journey,代码行数:27,代码来源:ElasticSearchEventDataSerializer.cs

示例2: EventHubMessage

 public EventHubMessage(string partitionId, EventData message)
 {
     PartitionId = partitionId;
     MessageBody = Encoding.UTF8.GetString(message.GetBytes());
     EnqueueTimeStamp = message.EnqueuedTimeUtc;
     Publisher = message.SystemProperties[EventDataSystemPropertyNames.Publisher] as string;
     Offset = message.Offset;
     SequenceNumber = message.SequenceNumber;
 }
开发者ID:spartyspartan,项目名称:EventHubber,代码行数:9,代码来源:EventHubMessage.cs

示例3: Deserialize

 private dynamic Deserialize(EventData raw)
 {
     try
     {
         var body = Encoding.UTF8.GetString(raw.GetBytes());
         return JsonConvert.DeserializeObject<dynamic>(body);
     }
     catch (Exception)
     {
         return null;
     }
     
 }
开发者ID:yvesgoeleven,项目名称:ServiceFabric.IoTSample,代码行数:13,代码来源:EventProcessor.cs

示例4: WriteJsonEntry

        private void WriteJsonEntry(EventData e)
        {
            _writer.WriteStartObject();

            _writer.WritePropertyName("index");

            // Write the batch "index" operation header
            _writer.WriteStartObject();
            // ES index names must be lower case and cannot contain whitespace or any of the following characters \/*?"<>|,
            WriteValue("_index", this.GetIndexName(e.EnqueuedTimeUtc));
            WriteValue("_type", _entryType);
            _writer.WriteEndObject();
            _writer.WriteEndObject();
            _writer.WriteRaw("\n");  //ES requires this \n separator
            
            _writer.WriteRaw(Encoding.UTF8.GetString(e.GetBytes()));
            
            _writer.WriteRaw("\n");
        }
开发者ID:sbidy,项目名称:iot-journey,代码行数:19,代码来源:ElasticSearchEventDataSerializer.cs

示例5: ConvertEventData2String

 // EventData --> String
 private static string ConvertEventData2String(EventData x)
 {
     return Encoding.UTF8.GetString(x.GetBytes());
 }
开发者ID:ConnorMcMahon,项目名称:azure-webjobs-sdk,代码行数:5,代码来源:EventHubConfiguration.cs

示例6: DeserializeEventData

 private static Alert DeserializeEventData(EventData eventData)
 {
     return JsonConvert.DeserializeObject<Alert>(Encoding.UTF8.GetString(eventData.GetBytes()));
 }
开发者ID:paolosalvatori,项目名称:servicefabriceventhubdemo,代码行数:4,代码来源:EventProcessor.cs

示例7: GetBytesInEvent

 // 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.Properties = GetStringDictionary(eData.Properties);
     try
     {
         //We are asuming serialization and encoding from the sender.
         eventToPersist.Payload = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(eData.GetBytes()));
     }
     catch (JsonReaderException)
     {
         eventToPersist.Payload = Encoding.UTF8.GetString(eData.GetBytes());
     }
     return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(eventToPersist) + EventDelimiter);
 }
开发者ID:niksacmsft,项目名称:iot-journey,代码行数:18,代码来源:ColdStorageProcessor.cs

示例8: DeserializeEventData

 MetricEvent DeserializeEventData(EventData eventData)
 {
     return JsonConvert.DeserializeObject<MetricEvent>(Encoding.UTF8.GetString(eventData.GetBytes()));
 }
开发者ID:techieshravan,项目名称:internet-of-things,代码行数:4,代码来源:SimpleEventProcessor.cs

示例9: GetBytesInEvent

 // [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);
 }
开发者ID:smartpcr,项目名称:data-pipeline,代码行数:12,代码来源:ColdStorageProcessor.cs

示例10: ProcessMessage

        public static async Task ProcessMessage(EventData eventData, string partition, CancellationToken cancelToken, TextWriter log)
        {
            var data = Encoding.UTF8.GetString(eventData.GetBytes());
            log.WriteLine("Message received. Partition: {0} Data: '{1}'", partition, data);

            var request = JsonConvert.DeserializeObject<PostRequest>(data);

            await SaveToTableStorage(eventData, cancelToken, request);
            await SaveToDatabase(cancelToken, request);
        }
开发者ID:HouseOfTheFuture,项目名称:API-App,代码行数:10,代码来源:Program.cs

示例11: ProcessAsync

        /// <summary>
        /// Process the message contained in the event data object, 
        /// handling timeouts, errors and telemetry
        /// </summary>
        private async Task ProcessAsync(EventData msg, string partitionId)
        {
            var context = new ProcessingContext(_eventHubName, partitionId, msg.Offset);

            Exception ex = null;
            string handlerName = "[handler not yet resolved]";
            byte[] content = EmptyContent;
            Dictionary<string, string> props = null;

            try
            {
                // The message stream can only be read once, extract the body up front
                content = msg.GetBytes();

                // if only some properties are used in the happy path but all are needed in some cases.
                props = msg.Properties.ToDictionary(
                    k => k.Key,
                    v => v.Value.ToString());

                // Promote standard EventHub properties into the property collection (for logging)
                var msgId = String.Concat(_eventHubName, "/", msg.PartitionKey, "/", msg.Offset);
                props.Add(Constants.ID, msgId);
                props.Add(Constants.MSG_OFFSET, msg.Offset);
                props.Add(Constants.PARTITION, msg.PartitionKey);

                // Look up the message type handler, using the payload and 
                // associated properties
                var handler = _handlerResolver.GetHandler(props, msgId);
                handlerName = handler.Name;

                // Create a task to track timeout
                var sw = Stopwatch.StartNew();
                var timeoutTask = Task.Delay(handler.Timeout);

                // Invoke the handler, using the continuation token to handle exceptions and
                // elapsed time logging.  Note: if this method throws synchronously (a misbehaving
                // handler) then we handle it in the catch statement below

                var handlerTask = handler
                    .ExecuteAsync(context, content, props)
                    .ContinueWith(async t => await HandleCompletionAsync(t, sw, handlerName, content, props, context).ConfigureAwait(false));

                _instrumentationPublisher.TaskStarted();
                _circuitBreaker.Increment();

                // Wait for either the timeout task or the handler to complete
                await Task.WhenAny(handlerTask, timeoutTask).ConfigureAwait(false);

                // If the message did not complete before the timeout, flag for further review
                if (handlerTask.Status != TaskStatus.RanToCompletion)
                {
                    props.Add("timeoutDuration", handler.Timeout.ToString());

                    _instrumentationPublisher.TimeoutOccured();
                    await Logger.LogHandlerTimeout(handler, context, content, props);
                }
            }
            catch (Exception ex0)
            {
                ex = ex0;
            }

            // Misbehaving handler threw a synchronous exception
            if (ex != null)
            {
                // We can't await in a catch block
                await Logger.HandlerThrewException(
                    handlerName,
                    context,
                    content,
                    props ?? new Dictionary<string, string>(),
                    ex);
            }
        }
开发者ID:smartpcr,项目名称:data-pipeline,代码行数:78,代码来源:EventProcessor.cs

示例12: Handle

 public void Handle(EventData eventData, string partitionId)
 {
     var store = GetEventStore(eventData, partitionId);
     var bytes = eventData.GetBytes();
     store.Write(bytes);
 }
开发者ID:smartpcr,项目名称:bigdata2,代码行数:6,代码来源:DeepStorageEventHandler.cs

示例13: GetEventDataString

 protected string GetEventDataString(EventData eventData)
 {
     var result = Encoding.UTF8.GetString(eventData.GetBytes());
     return result;
 }
开发者ID:pdlg-spotlight,项目名称:lambda-architecture,代码行数:5,代码来源:LambdaEventProcessorBase.cs


注:本文中的EventData.GetBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。