public static void SendWelcomeMessage(long webChatSessionNum) { //No need to check RemotingRole; no call to db. WebChatMessage welcomeMessage = new WebChatMessage(); welcomeMessage.WebChatSessionNum = webChatSessionNum; welcomeMessage.UserName = WebChatPrefs.GetString(WebChatPrefName.SystemName); welcomeMessage.MessageText = WebChatPrefs.GetString(WebChatPrefName.SystemWelcomeMessage); welcomeMessage.MessageType = WebChatMessageType.System; WebChatMessages.Insert(welcomeMessage); }
///<summary>Sets the DateTend field to now and inserts a message into the chat so all users can see the session has ended.</summary> public static void EndSession(long webChatSessionNum) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), webChatSessionNum); return; } WebChatMisc.DbAction(delegate() { string command = "UPDATE webchatsession SET DateTend=NOW() WHERE WebChatSessionNum=" + POut.Long(webChatSessionNum); DataCore.NonQ(command); //Last message just after session ended, in case someone types another message into the thread just as the thread is ending. //This way the end session message is guaranteed to be last, since the timestamp on it is after the session technically ended. WebChatMessage endSessionMessage = new WebChatMessage(); endSessionMessage.WebChatSessionNum = webChatSessionNum; endSessionMessage.UserName = WebChatPrefs.GetString(WebChatPrefName.SystemName); endSessionMessage.MessageText = WebChatPrefs.GetString(WebChatPrefName.SystemSessionEndMessage); endSessionMessage.MessageType = WebChatMessageType.EndSession; WebChatMessages.Insert(endSessionMessage); }); }