public async Task EnableArchiveRoom(ChatHubRoom room) { try { if (room.Status == ChatHubRoomStatus.Archived.ToString()) { room.Status = ChatHubRoomStatus.Enabled.ToString(); } else if (room.Status == ChatHubRoomStatus.Enabled.ToString()) { room.Status = ChatHubRoomStatus.Archived.ToString(); } await ChatHubService.UpdateChatHubRoomAsync(room); await logger.LogInformation("Room Archived {ChatHubRoom}", room); NavigationManager.NavigateTo(NavigateUrl()); } catch (Exception ex) { await logger.LogError(ex, "Error Archiving Room {ChatHubRoom} {Error}", room, ex.Message); ModuleInstance.AddModuleMessage("Error Archiving Room", MessageType.Error); } }
protected override async Task OnInitializedAsync() { try { this.BlazorColorPickerSelectionItems.Add(BlazorColorPickerType.HTML5ColorPicker.ToString()); this.BlazorColorPickerSelectionItems.Add(BlazorColorPickerType.CustomColorPicker.ToString()); this.BlazorColorPickerActiveType = BlazorColorPickerType.CustomColorPicker; this.SelectionItems.Add(ChatHubRoomType.Public.ToString()); this.SelectionItems.Add(ChatHubRoomType.Protected.ToString()); this.SelectionItems.Add(ChatHubRoomType.Private.ToString()); this.type = ChatHubRoomType.Public.ToString(); this.BlazorColorPickerService.OnBlazorColorPickerContextColorChangedEvent += OnBlazorColorPickerContextColorChangedExecute; this.ChatHubService.OnUpdateUI += (object sender, EventArgs e) => UpdateUIStateHasChanged(); await this.InitContextRoomAsync(); } catch (Exception ex) { await logger.LogError(ex, "Error Loading Room {ChatHubRoomId} {Error}", roomId, ex.Message); ModuleInstance.AddModuleMessage("Error Loading Room", MessageType.Error); } }
private async Task InitContextRoomAsync() { try { if (PageState.QueryString.ContainsKey("roomid")) { this.roomId = Int32.Parse(PageState.QueryString["roomid"]); ChatHubRoom room = await this.ChatHubService.GetChatHubRoomAsync(roomId, ModuleState.ModuleId); if (room != null) { this.title = room.Title; this.content = room.Content; this.type = room.Type; this.imageUrl = room.ImageUrl; this.createdby = room.CreatedBy; this.createdon = room.CreatedOn; this.modifiedby = room.ModifiedBy; this.modifiedon = room.ModifiedOn; } else { await logger.LogError("Error Loading Room {ChatHubRoomId} {Error}", roomId); ModuleInstance.AddModuleMessage("Error Loading ChatHub", MessageType.Error); } } } catch (Exception ex) { await logger.LogError(ex, "Error Loading Room {ChatHubRoomId} {Error}", roomId, ex.Message); ModuleInstance.AddModuleMessage("Error Loading Room", MessageType.Error); } }
protected override async Task OnParametersSetAsync() { try { this.ChatHubService.ModuleId = ModuleState.ModuleId; this.settings = await this.SettingService.GetModuleSettingsAsync(ModuleState.ModuleId); maxUserNameCharacters = int.Parse(this.SettingService.GetSetting(settings, "MaxUserNameCharacters", "500")); if (PageState.QueryString.ContainsKey("moduleid") && PageState.QueryString.ContainsKey("roomid") && int.Parse(PageState.QueryString["moduleid"]) == ModuleState.ModuleId) { this.contextRoom = await this.ChatHubService.GetChatHubRoomAsync(int.Parse(PageState.QueryString["roomid"]), ModuleState.ModuleId); } else { await this.ChatHubService.GetLobbyRooms(ModuleState.ModuleId); } } catch (Exception ex) { await logger.LogError(ex, "Error Loading Rooms {Error}", ex.Message); ModuleInstance.AddModuleMessage("Error Loading Rooms", MessageType.Error); } await base.OnParametersSetAsync(); }
private async Task SetDataAsync() { try { _moduleData.TodoLists = await TodoApi.TodoLists.GetAllByRouteAsync($"{sites}/{PageState.Site.SiteId}"); foreach (var list in _moduleData.TodoLists) { list.TodoTasks = await TodoApi.TodoTasks.GetAllByRouteAsync($"{todolists}/{list.Id}"); } _moduleData.TodoList = new TodoList(); var foundTodoList = await CheckSetTodoList(); if (UrlParameterState.Paramerters.ContainsKey(parameter0)) { switch (UrlParameterState.Paramerters[parameter0]) { case AddTodoList: _moduleData.TodoList.Id = -1; _moduleData.ModuleAction = AddTodoList; break; case AddTodoTask: _moduleData.TodoTask = new TodoTask { Id = -1 }; _moduleData.ModuleAction = AddTodoTask; break; default: break; } } else if (await CheckSetTodoTask()) { _moduleData.ModuleAction = AddTodoTask; } else if (foundTodoList) //Edit Todo List { _moduleData.ModuleAction = EditTodoList; } else { if (await IsNotNullError(todolists)) { _moduleData.ModuleAction = ManageTodoLists; } } OnCustomModuleStateChange?.Invoke(_moduleData); } catch (Exception ex) { await logger.LogError(ex, "Error Loading Todo Lists {Error}", ex.Message); ModuleInstance.AddModuleMessage($"Error Loading Todo Lists {ex}", MessageType.Error); } }
protected virtual async Task <bool> IsNotNullError(object obj) { if (obj == null) { await logger.LogError($"Error Loading Object {obj}"); ModuleInstance.AddModuleMessage($"Error Loading Object {obj}", MessageType.Error); return(false); } return(true); }
public async Task SaveRoom() { try { if (roomId == -1) { ChatHubRoom room = new ChatHubRoom() { ModuleId = ModuleState.ModuleId, Title = this.title, Content = this.content, BackgroundColor = this.backgroundcolor, Type = this.type, Status = ChatHubRoomStatus.Enabled.ToString(), ImageUrl = string.Empty, OneVsOneId = string.Empty, CreatorId = ChatHubService.ConnectedUser.UserId, }; room = await this.ChatHubService.AddChatHubRoomAsync(room); await logger.LogInformation("Room Added {ChatHubRoom}", room); NavigationManager.NavigateTo(NavigateUrl()); } else { ChatHubRoom room = await this.ChatHubService.GetChatHubRoomAsync(roomId, ModuleState.ModuleId); if (room != null) { room.Title = this.title; room.Content = this.content; room.BackgroundColor = this.backgroundcolor; room.Type = this.type; await this.ChatHubService.UpdateChatHubRoomAsync(room); await logger.LogInformation("Room Updated {ChatHubRoom}", room); NavigationManager.NavigateTo(NavigateUrl()); } } } catch (Exception ex) { await logger.LogError(ex, "Error Saving Room {ChatHubRoomId} {Error}", roomId, ex.Message); ModuleInstance.AddModuleMessage("Error Saving Room", MessageType.Error); } }
protected override async Task OnInitializedAsync() { try { Dictionary <string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId); _eavApp = SettingService.GetSetting(settings, SxcSettings.ModuleSettingApp, ""); _eavContentGroup = SettingService.GetSetting(settings, SxcSettings.ModuleSettingContentGroup, ""); _eavPreview = SettingService.GetSetting(settings, SxcSettings.ModuleSettingsPreview, ""); } catch (Exception ex) { ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error); } }
public string HighlightOwnUsername(string message, string username) { try { string pattern = username; string replacement = string.Format("<strong>{0}</strong>", "$0"); message = Regex.Replace(message, pattern, replacement); } catch (Exception ex) { ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error); } return(message); }
public async Task UpdateSettings() { try { Dictionary <string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId); SettingService.SetSetting(settings, SxcSettings.ModuleSettingApp, _eavApp); SettingService.SetSetting(settings, SxcSettings.ModuleSettingContentGroup, _eavContentGroup); SettingService.SetSetting(settings, SxcSettings.ModuleSettingsPreview, _eavPreview); await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId); } catch (Exception ex) { ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error); } }
protected override async Task OnInitializedAsync() { try { this.ChatHubService = new ChatHubService(HttpClient, SiteState, NavigationManager, JsRuntime, ModuleState.ModuleId); this.ChatHubService.UpdateUI += UpdateUIStateHasChanged; await this.InitContextRoomAsync(); } catch (Exception ex) { await logger.LogError(ex, "Error Loading Room {ChatHubRoomId} {Error}", roomId, ex.Message); ModuleInstance.AddModuleMessage("Error Loading Room", MessageType.Error); } }
public async Task SaveRoom() { try { if (roomId == -1) { ChatHubRoom room = new ChatHubRoom() { ModuleId = ModuleState.ModuleId, Title = title, Content = content, Type = Enum.GetName(typeof(ChatHubRoomType), ChatHubRoomType.Public), Status = Enum.GetName(typeof(ChatHubRoomStatus), ChatHubRoomStatus.Active), ImageUrl = string.Empty, OneVsOneId = string.Empty, }; room = await this.ChatHubService.AddChatHubRoomAsync(room); await logger.LogInformation("Room Added {ChatHubRoom}", room); NavigationManager.NavigateTo(NavigateUrl()); } else { ChatHubRoom room = await this.ChatHubService.GetChatHubRoomAsync(roomId, ModuleState.ModuleId); if (room != null) { room.Title = title; room.Content = content; await this.ChatHubService.UpdateChatHubRoomAsync(room); await logger.LogInformation("Room Updated {ChatHubRoom}", room); NavigationManager.NavigateTo(NavigateUrl()); } } } catch (Exception ex) { await logger.LogError(ex, "Error Saving Room {ChatHubRoomId} {Error}", roomId, ex.Message); ModuleInstance.AddModuleMessage("Error Saving Room", MessageType.Error); } }
private async Task Delete(int formId) { try { await TodoApi.TodoLists.DeleteAsync(formId); await logger.LogInformation("Form Deleted {Id}", formId); NavigationManager.NavigateTo(EditUrl(TodoListsPage)); } catch (Exception ex) { await logger.LogError(ex, "Error Deleting Form {Id} {Error}", formId, ex.Message); ModuleInstance.AddModuleMessage("Error Deleting Form", MessageType.Error); } }
public async Task DeleteRoom(int id) { try { await ChatHubService.DeleteChatHubRoomAsync(id, ModuleState.ModuleId); await logger.LogInformation("Room Deleted {ChatHubRoomId}", id); NavigationManager.NavigateTo(NavigateUrl()); } catch (Exception ex) { await logger.LogError(ex, "Error Deleting Room {ChatHubRoomId} {Error}", id, ex.Message); ModuleInstance.AddModuleMessage("Error Deleting Room", MessageType.Error); } }
private async Task BrowserHasResized() { try { InnerHeight = await this.BrowserResizeService.GetInnerHeight(); InnerWidth = await this.BrowserResizeService.GetInnerWidth(); SetChatTabElementsHeight(); this.UpdateUIStateHasChanged(); } catch (Exception ex) { await logger.LogError(ex, "Error On Browser Resize {Error}", ex.Message); ModuleInstance.AddModuleMessage("Error On Browser Resize", MessageType.Error); } }
public string ReplaceYoutubeLinksAsync(string message) { try { //var youtubeRegex = @"(?:http?s?:\/\/)?(?:www.)?(?:m.)?(?:music.)?youtu(?:\.?be)(?:\.com)?(?:(?:\w*.?:\/\/)?\w*.?\w*-?.?\w*\/(?:embed|e|v|watch|.*\/)?\??(?:feature=\w*\.?\w*)?&?(?:v=)?\/?)([\w\d_-]{11})(?:\S+)?"; List <string> regularExpressions = this.SettingService.GetSetting(this.settings, "RegularExpression", "").Split(";delimiter;", StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (var regularExpression in regularExpressions) { string pattern = regularExpression; string replacement = string.Format("<a href=\"{0}\" target=\"_blank\" title=\"{0}\">{0}</a>", "$0"); message = Regex.Replace(message, pattern, replacement); } } catch (Exception ex) { ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error); } return(message); }
private async Task BrowserHasResized() { try { await InvokeAsync(async() => { this.InnerHeight = await this.BrowserResizeService.GetInnerHeight(); this.InnerWidth = await this.BrowserResizeService.GetInnerWidth(); this.MessageWindowHeight = 520; this.UserlistWindowHeight = 570; StateHasChanged(); }); } catch (Exception ex) { await logger.LogError(ex, "Error On Browser Resize {Error}", ex.Message); ModuleInstance.AddModuleMessage("Error On Browser Resize", MessageType.Error); } }
public async Task ConnectToChat() { try { if (this.ChatHubService.Connection?.State == HubConnectionState.Connected || this.ChatHubService.Connection?.State == HubConnectionState.Connecting || this.ChatHubService.Connection?.State == HubConnectionState.Reconnecting) { this.BlazorAlertsService.NewBlazorAlert("The client is already connected."); } this.ChatHubService.BuildGuestConnection(GuestUsername, ModuleState.ModuleId); this.ChatHubService.RegisterHubConnectionHandlers(); await this.ChatHubService.ConnectAsync(); } catch (Exception ex) { await logger.LogError(ex, "Error Connecting To ChatHub: {Error}", ex.Message); ModuleInstance.AddModuleMessage("Error Connecting To ChatHub", MessageType.Error); } }
private async Task InitContextRoomAsync() { try { this.ChatHubService = new ChatHubService(HttpClient, SiteState, NavigationManager, JsRuntime, ModuleState.ModuleId); this.ChatHubService.UpdateUI += UpdateUIStateHasChanged; if (PageState.QueryString.ContainsKey("roomid")) { this.roomId = Int32.Parse(PageState.QueryString["roomid"]); ChatHubRoom room = await this.ChatHubService.GetChatHubRoomAsync(roomId, ModuleState.ModuleId); if (room != null) { title = room.Title; content = room.Content; imageUrl = room.ImageUrl; createdby = room.CreatedBy; createdon = room.CreatedOn; modifiedby = room.ModifiedBy; modifiedon = room.ModifiedOn; } else { await logger.LogError("Error Loading Room {ChatHubRoomId} {Error}", roomId); ModuleInstance.AddModuleMessage("Error Loading ChatHub", MessageType.Error); } } } catch (Exception ex) { await logger.LogError(ex, "Error Loading Room {ChatHubRoomId} {Error}", roomId, ex.Message); ModuleInstance.AddModuleMessage("Error Loading Room", MessageType.Error); } }
// user feedback methods public void AddModuleMessage(string message, MessageType type) { ModuleInstance.AddModuleMessage(message, type); }
public void ClearModuleMessage() { ModuleInstance.AddModuleMessage("", MessageType.Undefined); }