コード例 #1
0
        public async Task TriggerIFTTT(ActivatedGeoFence geoFence)
        {
            var content = JObject.Parse("{" + $"'value1':'{geoFence.VehicleId}', 'value2': '{geoFence.GeoFenceStatus}'" + "}");

            _log.LogInformation($"Calling IFTTT webhook for {geoFence.VehicleId}");
            //_log.LogDebug("POST: " + content.ToString());
            var stringContent = new StringContent(JsonConvert.SerializeObject(content, Formatting.None), Encoding.UTF8, "application/json");
            var iftttResult   = await _client.PostAsync(_IFTTTUrl, stringContent);

            iftttResult.EnsureSuccessStatusCode();

            _log.LogInformation($"[{geoFence.VehicleId}/{geoFence.DirectionId}/{geoFence.GeoFenceId}] WebHook called successfully");
        }
コード例 #2
0
        public async Task TriggerLogicApp(ActivatedGeoFence geoFence)
        {
            var content = JObject.Parse("{" + $"'value1':'{geoFence.VehicleId}', 'value2': '{geoFence.GeoFenceStatus}'" + "}");

            _log.LogInformation($"Calling Logic App webhook for {geoFence.VehicleId}");

            var stringContent  = new StringContent(JsonConvert.SerializeObject(content, Formatting.None), Encoding.UTF8, "application/json");
            var logicAppResult = await _client.PostAsync(LOGIC_APP_URL, stringContent);

            logicAppResult.EnsureSuccessStatusCode();

            _log.LogInformation($"[{geoFence.VehicleId}/{geoFence.DirectionId}/{geoFence.GeoFenceId}] WebHook called successfully");
        }