private static string Replace(string message, DataPoint dp, SingleMeasurement m)
        {
            string precision;
            string accuracy;
            var    body = message.Replace("$value", dp.Value.ToString(CultureInfo.InvariantCulture));

            body = body.Replace("$unit", dp.Unit);

            precision = dp.Precision != null?dp.Precision.Value.ToString(CultureInfo.InvariantCulture) : "";

            accuracy = dp.Accuracy != null?dp.Accuracy.Value.ToString(CultureInfo.InvariantCulture) : "";

            var lon = m.Location.Coordinates.Longitude.ToString(CultureInfo.InvariantCulture);
            var lat = m.Location.Coordinates.Latitude.ToString(CultureInfo.InvariantCulture);

            body = body.Replace("$timestamp", m.Timestamp.ToString("O"));
            body = body.Replace("$precision", precision);
            body = body.Replace("$accuracy", accuracy);
            body = body.Replace("$lon", lon);
            body = body.Replace("$lat", lat);

            return(body);
        }
        private static async Task <List <TriggerEvent> > ExecuteActionsAsync(ITriggerActionExecutionService exec, IEnumerable <TriggerAction> actions, DataPoint dp, SingleMeasurement m)
        {
            var tasks  = new List <Task>();
            var events = new List <TriggerEvent>();

            foreach (var action in actions)
            {
                var result = Replace(action.Message, dp, m);

                tasks.Add(exec.ExecuteAsync(action, result));
                events.Add(TriggerActionEventConverter.Convert(action));
            }

            await Task.WhenAll(tasks).ConfigureAwait(false);

            return(events);
        }