public static IServiceCollection AddSMTPImpostorWorker( this IServiceCollection services, ISMTPImpostorWorkerSettings settings) { services.TryAddSingleton(settings); services.TryAddSingleton <SMTPImpostorSerialization>(); services.AddHostedService <SMTPImpostorWorkerService>(); return(services); }
public static void SendStartupMessage( ToastNotifier notifier, ISMTPImpostorWorkerSettings settings) { var content = new ToastContent { Actions = new ToastActionsCustom { Buttons = { new ToastButtonDismiss(), new ToastButton("Open UI", OPEN_UI_ACTION) } }, Visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = "Worker is running" }, new AdaptiveText { Text = settings.StartupMessageLink } } } } }; var doc = new XmlDocument(); doc.LoadXml(content.GetContent()); var notification = new ToastNotification(doc); notification.Tag = START_NOTIFICATION_ID; notification.ExpiresOnReboot = true; notification.ExpirationTime = DateTimeOffset.Now.AddMinutes(1); notification.Activated += async(_, o) => { var args = o as ToastActivatedEventArgs; if (args.Arguments == OPEN_UI_ACTION) { await LaunchLink(settings.StartupMessageLink); } }; notifier.Show(notification); //Schedule(notifier, doc); }
public SMTPImpostorWorkerService( ILogger <SMTPImpostorWorkerService> logger, ISMTPImpostorWorkerSettings settings, SMTPImpostor impostor, SMTPImpostorHubService hub, IActionExecutor executor, ISMTPImpostorHostSettingsStore hostsSettings) { _logger = logger; _settings = settings; _impostor = impostor; _hub = hub; _executor = executor; _hostsSettings = hostsSettings; }