public static void SetCurrentChatID(int chatID) { ChatUserSetting setting = ChatUserSettings.GetSetting(UserSession.LoginUser, UserSession.LoginUser.UserID); setting.CurrentChatID = chatID; setting.Collection.Save(); }
public static bool ToggleAvailable() { ChatUserSetting setting = ChatUserSettings.GetSetting(UserSession.LoginUser, UserSession.LoginUser.UserID); setting.IsAvailable = !setting.IsAvailable; setting.Collection.Save(); return(setting.IsAvailable); }
public static string GetChatUserSetting(RestCommand command, int userID) { ChatUserSetting chatUserSetting = ChatUserSettings.GetChatUserSetting(command.LoginUser, userID); if (chatUserSetting.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } return(chatUserSetting.GetXml("ChatUserSetting", true)); }
public ChatUserSettingProxy GetCurrentUserChatSettings() { LoginUser loginUser = TSAuthentication.GetLoginUser(); ChatUserSetting setting = ChatUserSettings.GetChatUserSetting(loginUser, TSAuthentication.UserID); if (setting == null) { setting = (new ChatUserSettings(loginUser)).AddNewChatUserSetting(); setting.UserID = TSAuthentication.UserID; } return(setting.GetProxy()); }
public static string[] GetChatHtml(UserInfoProxy userInfo, int chatID, int lastMessageID) { LoginUser loginUser = new LoginUser(userInfo.UserID, userInfo.OrganizationID, null); ChatUserSetting setting = ChatUserSettings.GetSetting(loginUser, loginUser.UserID); setting.CurrentChatID = chatID; setting.Collection.Save(); Chat chat = Chats.GetChat(loginUser, chatID); if (chat == null || chat.OrganizationID != loginUser.OrganizationID) { return(null); } ChatMessages messages = new ChatMessages(loginUser); int i = messages.GetLastMessageID(chatID); string chatHtml = ""; if (i > -1 && i != lastMessageID) { ChatParticipants.UpdateLastMessageID(loginUser, loginUser.UserID, ChatParticipantType.User, chatID, i); chatHtml = chat.GetHtml(true, loginUser.CultureInfo); } // load typers ChatParticipants participants = new ChatParticipants(loginUser); participants.LoadTypers(loginUser.UserID, ChatParticipantType.User, chatID, 2); StringBuilder typers = new StringBuilder(); foreach (ChatParticipant item in participants) { if (typers.Length > 0) { typers.Append(", "); } typers.Append(item.FirstName); } if (typers.Length > 0) { typers.Append(" is typing a message."); } return(new string[] { chatID.ToString(), i.ToString(), chatHtml, typers.ToString() }); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (UserSession.CurrentUser.ProductType == ProductType.Express || UserSession.CurrentUser.ProductType == ProductType.BugTracking) { tbChat.FindItemByValue("opencustomer").Visible = false; } ChatUserSetting setting = ChatUserSettings.GetSetting(UserSession.LoginUser, UserSession.LoginUser.UserID); if (!setting.IsAvailable) { RadToolBarButton button = (RadToolBarButton)tbChat.FindItemByValue("available"); button.ImageUrl = "../images/icons/chat_d.png"; button.Text = "I am not available"; } }
public ChatUser CreateChatUser(Models.Chat chat, ChatUserSetting chatUserSetting, long joinedAt) { var chatUser = new ChatUser() { Chat = chat, User = chatUserSetting.User, Address = chatUserSetting.User.Address, Rank = chatUserSetting.Rank, PrivateKey = chatUserSetting.PrivateKey, JoinedAt = DateTimeOffset.FromUnixTimeMilliseconds(joinedAt).DateTime, CreatedAt = DateTime.UtcNow, }; ChatUsers.Add(chatUser); return(chatUser); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //Session.Clear(); //Session.Abandon(); Response.Cache.SetAllowResponseInBrowserHistory(false); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); Response.Expires = 0; fieldSID.Value = TSAuthentication.SessionID; Evergage.Value = SystemSettings.GetEverageDataset(); ChatUserSetting setting = ChatUserSettings.GetSetting(UserSession.LoginUser, UserSession.LoginUser.UserID); setting.CurrentChatID = -1; setting.Collection.Save(); }