private void UpdateNooshEvent(SiteInfo site) { if (site != null) { var url = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_configuratorSettingKey}"); var ruleName = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_ruleNameSettingKey}"); if (!string.IsNullOrWhiteSpace(url) && !string.IsNullOrWhiteSpace(ruleName)) { var nooshRule = new RuleDto { RuleName = ruleName, Rate = SettingsKeyInfoProvider.GetIntValue($"{site.SiteName}.{_rateSettingKey}"), TargetId = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_targetIdSettingKey}") }; var nooshSettings = new NooshDto { WorkgroupName = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_workgroupNameSettingKey}"), NooshUrl = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_nooshApiSettingKey}"), NooshToken = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_nooshTokenSettingKey}") }; nooshRule.Enabled = nooshRule.Rate > 0 && !string.IsNullOrWhiteSpace(nooshRule.TargetId) && !string.IsNullOrWhiteSpace(nooshSettings.WorkgroupName) && !string.IsNullOrWhiteSpace(nooshSettings.NooshToken) && !string.IsNullOrWhiteSpace(nooshSettings.NooshUrl); try { var client = DIContainer.Resolve <ICloudEventConfiguratorClient>(); var result = client.UpdateNooshRule(nooshRule, nooshSettings).Result; if (!result.Success) { throw new InvalidOperationException(result.ErrorMessages); } else { EventLogProvider.LogInformation("UPDATE - NOOSH EVENT SETTINGS", "MICROREQUEST", result.Payload); } } catch (Exception e) { EventLogProvider.LogException("UPDATE - NOOSH EVENT SETTINGS", "EXCEPTION", e, site.SiteID); } } } }
public async Task <BaseResponseDto <string> > UpdateNooshRule(RuleDto rule, NooshDto noosh) { var url = _properties.GetServiceUrl(_serviceUrlSettingKey); url = $"{url}/cloudwatch"; var body = new { RuleName = rule.RuleName, Rate = rule.Rate, Enabled = rule.Enabled, TargetId = rule.TargetId, TargetType = TargetType.Noosh, InputParameters = new { WorkGroups = new string[] { noosh.WorkgroupName }, NooshUrl = noosh.NooshUrl, NooshToken = noosh.NooshToken } }; return(await Put <string>(url, body).ConfigureAwait(false)); }