private async Task OnCreateTenantValidSubmitAsync(EditContext editContext) { try { await TenantService.CreateTenantAsync(createTenantForm.Model.Map <CreateTenantRequest>(afterMap => { afterMap.ControlClientBaseUri = RouteBindingLogic.GetBaseUri(); })); createTenantDone = true; createTenantReceipt.Add("Tenant created."); createTenantReceipt.Add("Master track with user repository created."); createTenantReceipt.Add("Master track default login up-party created."); createTenantReceipt.Add("First master track administrator user created."); createTenantReceipt.Add("Master track FoxIDs Control API down-party created."); createTenantReceipt.Add("Master track FoxIDs Control client down-party created."); createTenantReceipt.Add("Test track with user repository created."); createTenantReceipt.Add("Production track with user repository created."); await NotificationLogic.TenantUpdatedAsync(); } catch (FoxIDsApiException ex) { if (ex.StatusCode == System.Net.HttpStatusCode.Conflict) { createTenantForm.SetFieldError(nameof(createTenantForm.Model.Name), ex.Message); } else { throw; } } }
public void CheckForStreamerLiveStatus() { Notification notification = NotificationLogic.CreateNotification("checkForLiveStreamStatus", Severity.Info, Position.General, "Checking for live streamers..."); Logger.Info("Checking for live streams to download..."); List <Streamer> listOfStreamers = new List <Streamer>(); using (var context = new MainDataContext()) { listOfStreamers = context.Streamers.ToList(); //.Where(item => item.getLive).ToList(); } if (listOfStreamers.Count > 100) { for (int i = 0; i < listOfStreamers.Count; i = i + 100) { UpdateLiveStatus(listOfStreamers.Skip(i).Take(100).ToList()); } } else { UpdateLiveStatus(listOfStreamers); } Logger.Info("Done!"); NotificationLogic.DeleteNotification("checkForLiveStreamStatus"); }
public ProfileController() { userLogic = new UtilisateurLogic(); companyLogic = new CompanyLogic(); roleLogic = new RoleLogic(); passwordResetTokenLogic = new PasswordResetTokenLogic(); notificationLogic = new NotificationLogic(); }
public AccountController() { utilisateurLogic = new UtilisateurLogic(); passwordResetTokenLogic = new PasswordResetTokenLogic(); roleLogic = new RoleLogic(); notifLogic = new NotificationLogic(); mailLogic = new MailLogic(); }
public UtilisateurController() { userLogic = new UtilisateurLogic(); companyLogic = new CompanyLogic(); roleLogic = new RoleLogic(); notifLogic = new NotificationLogic(); mailLogic = new MailLogic(); }
public NotificationController() { notifLogic = new NotificationLogic(); userLogic = new UtilisateurLogic(); addressLogic = new AdressLogic(); bookingLogic = new BookingLogic(); requestBookingLogic = new RequestBookingLogic(); }
public void CheckForUpdates() { Notification notification = NotificationLogic.CreateNotification("softwareUpdate", Severity.Info, Position.General, "Checking for software updates..."); Logger.Info("Checking for application updates..."); new UpdateLogic().CheckForApplicationUpdates(); Logger.Info("Checking for yt-dlp updates..."); new UpdateYtDlp().CheckForYtDlpUpdates(); NotificationLogic.DeleteNotification("softwareUpdate"); }
public IActionResult UpdateYtDlp() { if (!String.IsNullOrEmpty(Update.UpdateYtDlp.DownloadYtDlp())) { NotificationLogic.DeleteNotification("yt-dlpUpdate"); GlobalConfig.SetGlobalConfig("yt-dlpUpdate", "False"); return(Ok()); } return(NotFound()); }
public Task DownloadStream(StreamExtended stream, string title, string streamDirectory, string formatId, string url, long duration, CancellationToken cancellationToken) { StreamDownload streamDownload = new StreamDownload(new DirectoryInfo(streamDirectory), false); _logger.Info("Getting vod m3u8.."); streamDownload.GetVodM3U8(url); _logger.Info("Got vod m3u8."); try { _logger.Info("Getting vod parts..."); streamDownload.GetVodParts(cancellationToken); _logger.Info("Got vod parts."); } catch (TsFileNotFound e) { // test if the stream has gone down. try { streamDownload.GetVodM3U8(url); } catch (Exception exception) { if (!exception.Message.Contains("is offline")) { // stream is offline, must have finished, so is not an error. // stream has not finished, throw _logger.Error($"Error occured while downloading a live stream. {exception.Message}"); Streamer streamer; using (var mainDataContext = new MainDataContext()) { streamer = mainDataContext.Streamers.FirstOrDefault(item => item.streamerId == stream.streamerId); } if (streamer != null) { NotificationLogic.CreateNotification($"StreamDownloadJob{stream.streamId}", Severity.Error, Position.Top, $"Could not download VOD for {streamer.username}.", $"/streamer/{streamer.id}"); } streamDownload.CleanUpFiles(); throw; } } } _logger.Info("Combining ts files..."); streamDownload.CombineTsFiles(title, stream.streamId); _logger.Info("Combined ts files."); _logger.Info("Cleaning up files..."); streamDownload.CleanUpFiles(); _logger.Info("Cleaned up files."); File.Move($"{streamDownload._rootDirectory.FullName}/stream.mp4", $"{streamDownload._rootDirectory.FullName}/{title}.{stream.streamId}.mp4"); _logger.Info("Moved file."); StreamHelpers.SetDownloadToFinished(stream.streamId, false); return(Task.CompletedTask); //await _hubContext.Clients.All.SendAsync("ReceiveMessage", CheckForDownloadingStreams()); }
public RequestBookingController() { requestBookingLogic = new RequestBookingLogic(); bookingLogic = new BookingLogic(); statusLogic = new StatusLogic(); addressLogic = new AdressLogic(); utilisateurLogic = new UtilisateurLogic(); userBookingLogic = new UserBookingLogic(); stopOverAddressLogic = new StopOverAddressLogic(); stopOverLogic = new StopOverLogic(); notificationLogic = new NotificationLogic(); roleLogic = new RoleLogic(); }
private void BtnSendNotify_Click(object sender, RoutedEventArgs e) { bool r = NotificationLogic.SaveNotifications(_sqlConn, _notifications); if (r) { MessageBox.Show($"Notifikace byly uloženy do DB", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show($"Notifikace se nepodařilo uložit do DB.", "Varování", MessageBoxButton.OK, MessageBoxImage.Warning); } Refresh(); }
public BookingController() { bookingLogic = new BookingLogic(); requestBookingLogic = new RequestBookingLogic(); stopOverAddressLogic = new StopOverAddressLogic(); userBookingLogic = new UserBookingLogic(); carLogic = new CarLogic(); carModelLogic = new CarModelLogic(); carMakeLogic = new CarMakeLogic(); stopOverLogic = new StopOverLogic(); addressLogic = new AdressLogic(); utilisateurLogic = new UtilisateurLogic(); statusLogic = new StatusLogic(); notificationLogic = new NotificationLogic(); }
public CarController() { companyLogic = new CompanyLogic(); carLogic = new CarLogic(); carModelLogic = new CarModelLogic(); carMakeLogic = new CarMakeLogic(); bookingLogic = new BookingLogic(); requestBookingLogic = new RequestBookingLogic(); eventLogic = new EventLogic(); addressLogic = new AdressLogic(); utilisateurLogic = new UtilisateurLogic(); statusLogic = new StatusLogic(); stopOverLogic = new StopOverLogic(); stopOverAddressLogic = new StopOverAddressLogic(); notificationLogic = new NotificationLogic(); }
public Task Execute(IJobExecutionContext context) { JobDataMap jobDataMap = context.JobDetail.JobDataMap; StreamDownload streamDownload = new StreamDownload(new DirectoryInfo(jobDataMap.GetString("streamDirectory")), true); streamDownload.GetVodM3U8(jobDataMap.GetString("url")); try { streamDownload.GetVodParts(context.CancellationToken); } catch (TsFileNotFound e) { // test if the stream has gone down. try { streamDownload.GetVodM3U8(jobDataMap.GetString("url")); } catch (Exception exception) { if (!exception.Message.Contains("is offline")) { // stream is offline, must have finished, so is not an error. // stream has not finished, throw _logger.Error($"Error occured while downloading a live stream. {exception.Message}"); Streamer streamer; using (var mainDataContext = new MainDataContext()) { streamer = mainDataContext.Streamers.FirstOrDefault(item => item.streamerId == jobDataMap.GetIntValue("streamerId")); } if (streamer != null) { NotificationLogic.CreateNotification($"LiveStreamDownloadJob{jobDataMap.GetLongValue("streamId")}", Severity.Error, Position.Top, $"Could not download VOD for {streamer.username}.", $"/streamer/{streamer.id}"); } streamDownload.CleanUpFiles(); throw; } } } streamDownload.CombineTsFiles(jobDataMap.GetString("title"), jobDataMap.GetLongValue("streamId")); streamDownload.CleanUpFiles(); // need to rename file as ffmpeg does not work with special characters. File.Move($"{streamDownload._rootDirectory.FullName}/stream.mp4", $"{streamDownload._rootDirectory.FullName}/{jobDataMap.GetString("title")}.{jobDataMap.GetLongValue("streamId")}.mp4"); StreamHelpers.SetDownloadToFinished(jobDataMap.GetLongValue("streamId"), true); return(Task.CompletedTask); }
public Task CheckForYtDlpUpdates() { Version?currentVersion = null; string? dbVersion = GlobalConfig.GetGlobalConfig("yt-dlpVersion"); if (dbVersion == null) { // current yt-dlp (if it exists) does not have the version number in the db. string?ytDlpInstallLocation = GlobalConfig.GetGlobalConfig("yt-dlp"); if (ytDlpInstallLocation != null) { // yt-dlp is installed, need to get the current version. try { currentVersion = GetCurrentYtDlpVersion(ytDlpInstallLocation); } catch (Exception e) { // ignored, probably an error due to yt-dlp not existing. } if (currentVersion is not null) { GlobalConfig.SetGlobalConfig("yt-dlpVersion", currentVersion.ToString()); } } } else { currentVersion = Version.Parse(dbVersion); } Version latestVersion = GetLatestYtDlpVersion(); if (currentVersion != null && currentVersion >= latestVersion) { return(Task.CompletedTask); } NotificationLogic.CreateNotification("yt-dlpUpdate", Severity.Info, Position.Top, $"New yt-dlp update! Current version: {(currentVersion != null ? currentVersion : "unknown")}; latest: {latestVersion}.", "/settings/setup"); GlobalConfig.SetGlobalConfig("yt-dlpUpdate", true.ToString()); return(Task.CompletedTask); }
public void DatabaseBackup(string database) { Logger.Info($"Backing up {database} database..."); Notification notification = NotificationLogic.CreateNotification("databaseBackup", Severity.Info, Position.General, "Backing up database..."); int backupCount; using (var context = new MainDataContext()) { backupCount = context.Backups.Count(item => item.type == database); } if (backupCount > 5) { // trim database backups using (var context = new MainDataContext()) { Backup oldestBackup = context.Backups.Where(item => item.type == database) .OrderBy(item => item.datetime).First(); FileInfo backupFile = new FileInfo(oldestBackup.location); if (backupFile.Exists) { backupFile.Delete(); } context.Remove(oldestBackup); context.SaveChanges(); } } DatabaseBackupLogic databaseBackupLogic = new DatabaseBackupLogic(); if (database == "chatDb") { databaseBackupLogic.BackupChatDatabase(); } else { databaseBackupLogic.BackupDatabase("mainDb"); } Logger.Info($"Backed up {database} database."); NotificationLogic.DeleteNotification("databaseBackup"); }
public void StreamerCheckForUpdates() { Notification notification = NotificationLogic.CreateNotification("streamerCheckForUpdates", Severity.Info, Position.General, "Checking for streamer updates..."); List <Streamer> listOfStreamers = new List <Streamer>(); using (var context = new MainDataContext()) { listOfStreamers = context.Streamers.ToList(); } if (listOfStreamers.Count > 100) { for (int i = 0; i < listOfStreamers.Count; i = i + 100) { UpdateStreamerDetails(listOfStreamers.Skip(i).Take(100).ToList()); } } else { UpdateStreamerDetails(listOfStreamers); } NotificationLogic.DeleteNotification("streamerCheckForUpdates"); }
public ConfigurationController() { roleLogic = new RoleLogic(); actionLogic = new ActionLogic(); notificationLogic = new NotificationLogic(); }
public HomeController() { notifLogic = new NotificationLogic(); }
public void Refresh() { _notifications = NotificationLogic.GetNotifications(_sqlConn, 30); DgNotifications.ItemsSource = _notifications; }
/// <summary> /// Listens for input from admin /// </summary> private static void ServerInput() { while (true) { Console.WriteLine("Enter command to interact with the game: "); string s = Console.ReadLine(); if (s != null && s.StartsWith("notific")) { var newNotification = new NotificationModel(0, 0, "", "", DateTime.Now); Console.WriteLine( "Enter recipient for new Notification(Group number for one specific, 0 if send to all): "); s = Console.ReadLine(); int toId; if (!int.TryParse(s, out toId)) { Console.WriteLine("Invalid input!"); } else if (!_client.GroupNumberTaken(toId) && toId == 0) { Console.WriteLine("Group " + toId + " does not exist!"); } else { newNotification.NotificTo = toId; Console.WriteLine("Enter notification subject: "); newNotification.Subject = Console.ReadLine(); Console.WriteLine("Enter notification text: "); newNotification.Text = Console.ReadLine(); newNotification.Time = Clock.GameTime; var listOfNotifications = new List <NotificationModel>(); if (newNotification.NotificTo == 0) { foreach (HandleClinet recipient in _client.GetClients()) { newNotification.NotificTo = recipient.Groupnumber; listOfNotifications.Add(NotificationLogic.NewNotific(newNotification)); } } else { listOfNotifications.Add(NotificationLogic.NewNotific(newNotification)); } foreach (HandleClinet recipient in _client.GetClients()) { foreach (NotificationModel n in listOfNotifications) { if (n.NotificTo == recipient.Groupnumber) { recipient.SendNotification(n); } } } } } else if (s != null && s.StartsWith("pause")) { Pause = true; Console.WriteLine(" >> " + "Game is paused!"); Time = Clock.GameTime; foreach (HandleClinet recipient in _client.GetClients()) { recipient.SendPauseState(Pause); } } else if (s != null && s.StartsWith("start")) { Pause = false; Console.WriteLine(" >> " + "Game is started!"); Clock.SetDate(Time, Speed); foreach (HandleClinet recipient in _client.GetClients()) { recipient.SendPauseState(Pause); } } else if (s != null && s.StartsWith("set date")) { Console.WriteLine("Enter the new date: (dd.MM.yyyy)"); try { DateTime date = DateTime.Parse(Console.ReadLine()); Clock.SetDate(date, Speed); } catch (FormatException) { Console.WriteLine("Not a valid date, enter a new date in this format(dd.MM.yyyy)"); } } else if (s != null && s.StartsWith("set item price")) { Console.WriteLine("Enter item id:"); s = Console.ReadLine(); int itemId; double price; ItemModel item; if (!int.TryParse(s, out itemId)) { Console.WriteLine("Invalid input!"); } else { item = InventoryLogic.GetItemById(itemId); if (item == null) { Console.WriteLine("Invalid item id!"); } else { Console.WriteLine("Enter new price:"); s = Console.ReadLine(); if (!double.TryParse(s, out price)) { Console.WriteLine("Invalid input!"); } else { ValueLogic.EditItemPrice(itemId, price); var notification = new NotificationModel { Subject = item.Name + " price changed!", Text = "The price is now " + price + ", previously " + item.Price + ".", Time = Clock.GameTime }; item = InventoryLogic.GetItemById(itemId); foreach (HandleClinet cl in _client.GetClients()) { cl.SendItem(item); notification.NotificTo = cl.Groupnumber; notification = NotificationLogic.NewNotific(notification); cl.SendNotification(notification); } } } } } else { Console.WriteLine("Not a valid command, enter another command"); } } }
public ReservationController() { notificationLogic = new NotificationLogic(); }