public AlertActionResult Action(Alert Alert, ScreenshotResult ScreenshotResult, string Message) { try { List <WebhookItem> Webhooks = WebhookItem.ParseWebhookInfo(Alert.WebhookURL, Alert.WebhookMessage, Alert.WebhookJSON); foreach (WebhookItem wh in Webhooks) { if (wh.IsJSON) { Task.Run(() => WebRequest.POST(wh.URL, "", true, wh.Message)); } else { Task.Run(() => WebRequest.POST(wh.URL, wh.Message)); } } AlertActionResult AAR = new AlertActionResult(); AAR.Succeeded = true; AAR.ErrorMessage = ""; return(AAR); } catch (Exception ex) { return(new AlertActionResult()); } }
public async Task <AlertActionResult> ExecuteActionAsync(AlertActionDefinition actionDefinition, AlertDefinition alertDefinition, Miner miner, AlertMetadata metadata, CancellationToken token) { var client = _clientFactory.Create(miner); await client.RestartMinerAsync(); return(AlertActionResult.Complete(actionDefinition.Name, $"Restarting miner {miner.Name}")); }
public async Task <AlertActionResult> ExecuteActionAsync(AlertActionDefinition actionDefinition, AlertDefinition alertDefinition, Miner miner, AlertMetadata metadata, CancellationToken token) { var action = (WebHookAlertActionDefinition)actionDefinition; var client = _clientFactory(); if (action.Body == null) { await client.PostAsync(action.Url, null, token); } else { await client.PostAsync(action.Url, new StringContent(action.Body, Encoding.UTF8, "application/json"), token); } return(AlertActionResult.Complete(actionDefinition.Name, "Sent Web Hook")); }
public async Task <AlertActionResult> ExecuteActionAsync(AlertActionDefinition actionDefinition, AlertDefinition alertDefinition, Miner miner, AlertMetadata metadata, CancellationToken token) { var action = (DisableGpuAlertActionDefinition)actionDefinition; var client = _clientFactory.Create(miner); if (action.DisableAll) { await client.SetGpuModeAsync(GpuMode.Disabled); return(AlertActionResult.Complete(action.Name, $"Sent control message to disabled GPUs on miner {miner.Name}")); } if (action.DisableAffected && metadata?.GpuIndex != null) { await client.SetGpuModeAsync((int)metadata.GpuIndex, GpuMode.Disabled); return(AlertActionResult.Complete(action.Name, $"Sent control message to disable GPU {metadata.GpuIndex + 1} on miner {miner.Name}")); } return(AlertActionResult.Skip(action.Name, "Unable to determine which GPU to disable")); }
public AlertActionResult Action(Alert Alert, ScreenshotResult ScreenshotResult, string Message) { // TODO: figure out how to have custom HTML, titles, tags/categories, etc... // TODO: have it actually post try { if (Properties.Settings.Default.WordPressAlertsUseScreenshot) { if (ScreenshotResult != null) { if (ScreenshotResult.Succeeded) { //Task.Run(() => WordPress.SendFile(ScreenshotResult.ImageFilePath, Message, Properties.Settings.Default.WordPressAlertTagHere, Properties.Settings.Default.WordPressAlertTagEveryone)); } else { //still send message here //Task.Run(() => WordPress.SendMessage(Message, Properties.Settings.Default.WordPressAlertTagHere, Properties.Settings.Default.WordPressAlertTagEveryone)); } } else { //still send message here //Task.Run(() => WordPress.SendMessage(Message, Properties.Settings.Default.WordPressAlertTagHere, Properties.Settings.Default.WordPressAlertTagEveryone)); } } else { //still send message here //Task.Run(() => WordPress.SendMessage(Message, Properties.Settings.Default.WordPressAlertTagHere, Properties.Settings.Default.WordPressAlertTagEveryone)); } AlertActionResult AAR = new AlertActionResult(); AAR.Succeeded = true; AAR.ErrorMessage = ""; return(AAR); } catch (Exception ex) { return(new AlertActionResult()); } }
public AlertActionResult Action(Alert Alert, ScreenshotResult ScreenshotResult, string Message) { try { if (Properties.Settings.Default.TwitterAlertsUseScreenshot) { if (ScreenshotResult != null) { if (ScreenshotResult.Succeeded) { Task.Run(() => Twitter.TweetWithPngImage(Message, ScreenshotResult.ImageFilePath)); } else { //still send message here Task.Run(() => Twitter.Tweet(Message)); } } else { //still send message here Task.Run(() => Twitter.Tweet(Message)); } } else { //still send message here Task.Run(() => Twitter.Tweet(Message)); } AlertActionResult AAR = new AlertActionResult(); AAR.Succeeded = true; AAR.ErrorMessage = ""; return(AAR); } catch (Exception ex) { return(new AlertActionResult()); } }
public AlertActionResult Action(Alert Alert, ScreenshotResult ScreenshotResult, string Message) { try { if (Properties.Settings.Default.DiscordAlertsUseScreenshot) { if (ScreenshotResult != null) { if (ScreenshotResult.Succeeded) { Task.Run(() => Discord.SendFile(ScreenshotResult.ImageFilePath, Message, Properties.Settings.Default.DiscordAlertTagHere, Properties.Settings.Default.DiscordAlertTagEveryone)); } else { //still send message here Task.Run(() => Discord.SendMessage(Message, Properties.Settings.Default.DiscordAlertTagHere, Properties.Settings.Default.DiscordAlertTagEveryone)); } } else { //still send message here Task.Run(() => Discord.SendMessage(Message, Properties.Settings.Default.DiscordAlertTagHere, Properties.Settings.Default.DiscordAlertTagEveryone)); } } else { //still send message here Task.Run(() => Discord.SendMessage(Message, Properties.Settings.Default.DiscordAlertTagHere, Properties.Settings.Default.DiscordAlertTagEveryone)); } AlertActionResult AAR = new AlertActionResult(); AAR.Succeeded = true; AAR.ErrorMessage = ""; return(AAR); } catch (Exception ex) { return(new AlertActionResult()); } }