public static void Action() { try { log.Info("Delivery check timer elapsed"); log.Info($"Authentication exists: {configurationService.AuthenticationExists()}"); if (configurationService.AuthenticationExists()) { LastCheck = DateTime.Now.ToString(); var settings = configurationService.GetSettings(); var deliveries = barboraService.GetAvailableDeliveries(); TotalDeliveriesFound = deliveries.TotalDeliveries; if (!deliveries.AvailableDeliveries.Any()) { return; } AvailableDeliveriesFound = deliveries.AvailableDeliveries.Count; var deliveryText = new StringBuilder(); deliveryText.AppendLine("Available delivery times:"); foreach (var delivery in deliveries.AvailableDeliveries) { if (settings.PushNotifications) { deliveryText.AppendLine($"Available delivery time: {delivery.deliveryTime}"); notificationManager.Show(new NotificationContent { Title = "Delivery time found", Message = $"Found delivery time: {delivery.deliveryTime}", Type = NotificationType.Information }, expirationTime: System.TimeSpan.FromMinutes(60)); } } if (settings.EmailNotifications) { emailService.SendEmail("Delivery", deliveryText.ToString()); } } } catch (Exception ex) { log.Error("Exeption while running timer action.", ex); } }
private void InitializeWindow() { var configurationService = new SettingsService(); if (configurationService.AuthenticationExists()) { var mainWindow = new MainWindow(); mainWindow.Show(); } else { var loginWindow = new LoginWindow(); loginWindow.Show(); } }