public static async Task <string> Run( [IoTHubTrigger("events/messages", Connection = "IoTHub")] EventData message, [Blob("incoming", FileAccess.Write, Connection = "MLOps")] CloudBlobContainer outputContainer, ILogger log) { var uuid = $"p-{message.SystemProperties.PartitionKey}-o-{message.SystemProperties.Offset}"; var apiUrl = Environment.GetEnvironmentVariable("ApiUrl"); string body = Encoding.UTF8.GetString(message.Body.Array); JObject jsonContent = JsonConvert.DeserializeObject <JObject>(body); List <decimal> properties = jsonContent .Properties() .Where(property => IgnoredProperties.All(ignoredProperty => !ignoredProperty.Equals(property.Name, StringComparison.OrdinalIgnoreCase))) .Select(property => decimal.Parse(property.Value.ToString().Replace(",", "."))) .ToList(); var scoringValue = await GetScore(properties, apiUrl); jsonContent.Add("% Silica Concentrate", scoringValue); var jsonContentStringified = await UploadToColdPath(outputContainer, uuid, jsonContent); log.Log(LogLevel.Debug, $"Uploaded file {uuid} with content {jsonContentStringified}"); message.Dispose(); return(jsonContentStringified); }
public override void OnGUIFamily(ShaderGUITreeView treeView) { if (!this.isVisible) { return; } using (var dis = new EditorGUI.DisabledGroupScope(this.isDisabled)) { if (!this.hasChildren) { return; } using (var chk = new EditorGUI.ChangeCheckScope()) { foreach (var it in this.children) { it.OnGUIFamily(treeView); } var data = new EventData(this, chk.changed); afterCallback.Invoke(data); data.Dispose(); } } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_lastEventDataInFrame != null) { _lastEventDataInFrame.Dispose(); } } }
public void Disconnect() { if (eventData != null) { eventData.PassingContainer.NotifyHandlers = null; eventData.AuxEventContainer.NotifyHandlers = null; eventData.UnsubscribeFromEventData(MTAEVENTDATA.mtaPassing); eventData.UnsubscribeFromEventData(MTAEVENTDATA.mtaAuxEvent); eventData.Dispose(); eventData = null; } }
protected virtual void Dispose(bool disposing) { Trace.WriteLine("EventListLoader was disposed, disposing = {0}", disposing.ToString()); if (!_disposed) { if (disposing) { if (_eventData != null) { _eventData.Dispose(); } } _disposed = true; } }
/// <summary> /// </summary> /// <param name="bypassCache"> </param> /// <returns> </returns> public virtual DataSet LoadEventList(bool bypassCache) { if (_reader != null) { _reader = GetItem(_reader); } if ((bypassCache) || (_reader == null)) { using (_reader) { _reader = LoadContentFromXml(); } base.InsertItem(_reader); } _eventData = GetItem(_eventData); if ((bypassCache) || (_eventData == null)) { using (_eventData = new EventData()) { try { _eventData.ReadXml(_reader); base.InsertItem(_eventData); } finally { _eventData.Dispose(); } } } return(_eventData); }
///// <summary> ///// This method can be used to send an event data to an event hub. ///// </summary> ///// <param name="eventHubClient">A EventHubClient object used to send messages.</param> ///// <param name="eventDataList">The list of messages to send.</param> ///// <param name="messageNumberList">The list of message numbers.</param> ///// <param name="taskId">The sender task id.</param> ///// <param name="logging">Indicates whether logging of message content and properties is enabled.</param> ///// <param name="verbose">Indicates whether verbose logging is enabled.</param> ///// <returns>Elapsed milliseconds.</returns> //public async Task<long> SendEventDataBatch(EventHubClient eventHubClient, // List<EventData> eventDataList, // List<long> messageNumberList, // int taskId, // bool logging, // bool verbose) //{ // long elapsedMilliseconds = 0; // if (eventHubClient == null) // { // throw new ArgumentNullException(EventHubClientCannotBeNull); // } // if (eventDataList == null || eventDataList.Count == 0) // { // return elapsedMilliseconds; // } // List<Stream> eventDataPayloadList = null; // var stopwatch = new Stopwatch(); // var builder = new StringBuilder(); // try // { // stopwatch.Start(); // if (logging && verbose) // { // eventDataPayloadList = eventDataList.Select(e => e.Clone().GetBodyStream()).ToList(); // } // //await eventHubClient.SendBatchAsync(eventDataList); // } // finally // { // stopwatch.Stop(); // } // elapsedMilliseconds = stopwatch.ElapsedMilliseconds; // if (logging) // { // for (var i = 0; i < eventDataList.Count; i++) // { // try // { // builder.AppendLine(string.Format(CultureInfo.CurrentCulture, // EventDataSuccessfullySent, // taskId, // messageNumberList[i], // string.IsNullOrWhiteSpace(eventDataList[i].PartitionKey) // ? NullValue // : eventDataList[i].PartitionKey)); // if (verbose) // { // builder.AppendLine(SentMessagePayloadHeader); // builder.AppendLine(string.Format(MessageTextFormat, GetMessageText(eventDataPayloadList[i]))); // builder.AppendLine(SentMessagePropertiesHeader); // foreach (var p in eventDataList[i].Properties) // { // builder.AppendLine(string.Format(MessagePropertyFormat, // p.Key, // p.Value)); // } // } // } // finally // { // eventDataList[i].Dispose(); // } // } // var traceMessage = builder.ToString(); // WriteToLog(traceMessage.Substring(0, traceMessage.Length - 1)); // } // return elapsedMilliseconds; //} /// <summary> /// This method can be used to send an event data to an event hub. /// </summary> /// <param name="eventHubClient">A MessageSender object used to send event datas.</param> /// <param name="eventData">The event data to send.</param> /// <param name="messageNumber">The message number.</param> /// <param name="taskId">The sender task id.</param> /// <param name="logging">Indicates whether logging of event data content and properties is enabled.</param> /// <param name="verbose">Indicates whether verbose logging is enabled.</param> /// <returns>Elapsed milliseconds.</returns> public async Task<long> SendEventData(EventHubClient eventHubClient, EventData eventData, long messageNumber, int taskId, bool logging, bool verbose) { long elapsedMilliseconds; if (eventHubClient == null) { throw new ArgumentNullException(MessageSenderCannotBeNull); } if (eventData == null) { throw new ArgumentNullException(BrokeredMessageCannotBeNull); } var stopwatch = new Stopwatch(); Stream bodyStream = null; try { var builder = new StringBuilder(); try { if (logging && verbose) { bodyStream = eventData.Clone().GetBodyStream(); } stopwatch.Start(); await eventHubClient.SendAsync(eventData); } finally { stopwatch.Stop(); } elapsedMilliseconds = stopwatch.ElapsedMilliseconds; if (logging) { builder.AppendLine(string.Format(CultureInfo.CurrentCulture, EventDataSuccessfullySent, taskId, messageNumber, string.IsNullOrWhiteSpace(eventData.PartitionKey) ? NullValue : eventData.PartitionKey)); if (verbose) { builder.AppendLine(SentMessagePayloadHeader); builder.AppendLine(string.Format(MessageTextFormat, GetMessageText(bodyStream))); if (eventData.Properties.Any()) { builder.AppendLine(SentMessagePropertiesHeader); foreach (var p in eventData.Properties) { builder.AppendLine(string.Format(MessagePropertyFormat, p.Key, p.Value)); } } } var traceMessage = builder.ToString(); WriteToLog(traceMessage.Substring(0, traceMessage.Length - 1)); } } finally { eventData.Dispose(); } return elapsedMilliseconds; }
public void Dispose() => _event.Dispose();