Chat: IDBoard to IDMessageBoard of string type
This commit is contained in:
@@ -11,15 +11,15 @@ namespace VAR.Focus.Web.Code.BusinessLogic
|
||||
private List<Message> _messages = new List<Message>();
|
||||
private int _lastIDMessage = 0;
|
||||
|
||||
private int _idBoard = 0;
|
||||
private string _idMessageBoard = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Life cycle
|
||||
|
||||
public MessageBoard(int idBoard)
|
||||
public MessageBoard(string idMessageBoard)
|
||||
{
|
||||
_idBoard = idBoard;
|
||||
_idMessageBoard = idMessageBoard;
|
||||
LoadData();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace VAR.Focus.Web.Code.BusinessLogic
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_messages = Persistence.LoadList<Message>(String.Format(PersistenceFile, _idBoard));
|
||||
_messages = Persistence.LoadList<Message>(String.Format(PersistenceFile, _idMessageBoard));
|
||||
_lastIDMessage = 0;
|
||||
if (_messages.Count > 0)
|
||||
{
|
||||
@@ -77,7 +77,7 @@ namespace VAR.Focus.Web.Code.BusinessLogic
|
||||
|
||||
private void SaveData()
|
||||
{
|
||||
Persistence.SaveList(String.Format(PersistenceFile, _idBoard), _messages);
|
||||
Persistence.SaveList(String.Format(PersistenceFile, _idMessageBoard), _messages);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace VAR.Focus.Web.Controls
|
||||
|
||||
private string _serviceUrl = "ChatHandler";
|
||||
|
||||
private int _idBoard = 0;
|
||||
private string _idMessageBoard = null;
|
||||
|
||||
private string _userName = string.Empty;
|
||||
|
||||
@@ -34,10 +34,10 @@ namespace VAR.Focus.Web.Controls
|
||||
set { _serviceUrl = value; }
|
||||
}
|
||||
|
||||
public int IDBoard
|
||||
public string IDMessageBoard
|
||||
{
|
||||
get { return _idBoard; }
|
||||
set { _idBoard = value; }
|
||||
get { return _idMessageBoard; }
|
||||
set { _idMessageBoard = value; }
|
||||
}
|
||||
|
||||
public string UserName
|
||||
@@ -140,7 +140,7 @@ namespace VAR.Focus.Web.Controls
|
||||
sbCfg.AppendFormat(" divChat: \"{0}\",\n", divChat.ClientID);
|
||||
sbCfg.AppendFormat(" txtText: \"{0}\",\n", txtText.ClientID);
|
||||
sbCfg.AppendFormat(" btnSend: \"{0}\",\n", btnSend.ClientID);
|
||||
sbCfg.AppendFormat(" IDBoard: {0},\n", _idBoard);
|
||||
sbCfg.AppendFormat(" IDMessageBoard: \"{0}\",\n", _idMessageBoard);
|
||||
sbCfg.AppendFormat(" UserName: \"{0}\",\n", _userName);
|
||||
sbCfg.AppendFormat(" IDMessage: {0},\n", 0);
|
||||
sbCfg.AppendFormat(" ServiceUrl: \"{0}\",\n", _serviceUrl);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace VAR.Focus.Web.Controls
|
||||
#region Declarations
|
||||
|
||||
private static object _monitor = new object();
|
||||
private static Dictionary<int, MessageBoard> _chatBoards = new Dictionary<int, MessageBoard>();
|
||||
private static Dictionary<string, MessageBoard> _chatBoards = new Dictionary<string, MessageBoard>();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace VAR.Focus.Web.Controls
|
||||
|
||||
private void ProcessReciver(HttpContext context)
|
||||
{
|
||||
int idBoard = Convert.ToInt32(GetRequestParm(context, "IDBoard"));
|
||||
string idMessageBoard = GetRequestParm(context, "IDMessageBoard");
|
||||
int idMessage = Convert.ToInt32(GetRequestParm(context, "IDMessage"));
|
||||
string strTimePoolData = GetRequestParm(context, "TimePoolData");
|
||||
int timePoolData = Convert.ToInt32(string.IsNullOrEmpty(strTimePoolData) ? "0" : strTimePoolData);
|
||||
@@ -51,21 +51,21 @@ namespace VAR.Focus.Web.Controls
|
||||
bool mustWait = (timePoolData > 0);
|
||||
do
|
||||
{
|
||||
if (_chatBoards.ContainsKey(idBoard) == false)
|
||||
if (_chatBoards.ContainsKey(idMessageBoard) == false)
|
||||
{
|
||||
lock (_chatBoards)
|
||||
{
|
||||
if (_chatBoards.ContainsKey(idBoard) == false)
|
||||
if (_chatBoards.ContainsKey(idMessageBoard) == false)
|
||||
{
|
||||
messageBoard = new MessageBoard(idBoard);
|
||||
_chatBoards[idBoard] = messageBoard;
|
||||
messageBoard = new MessageBoard(idMessageBoard);
|
||||
_chatBoards[idMessageBoard] = messageBoard;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_chatBoards.ContainsKey(idBoard))
|
||||
if (_chatBoards.ContainsKey(idMessageBoard))
|
||||
{
|
||||
messageBoard = _chatBoards[idBoard];
|
||||
messageBoard = _chatBoards[idMessageBoard];
|
||||
List<Message> listMessages = messageBoard.Messages_GetList(idMessage);
|
||||
if (listMessages.Count > 0)
|
||||
{
|
||||
@@ -85,8 +85,8 @@ namespace VAR.Focus.Web.Controls
|
||||
private void ProcessSender(HttpContext context)
|
||||
{
|
||||
string text = Convert.ToString(GetRequestParm(context, "Text"));
|
||||
string strIDBoard = GetRequestParm(context, "IDBoard");
|
||||
int idBoard = Convert.ToInt32(string.IsNullOrEmpty(strIDBoard) ? "0" : strIDBoard);
|
||||
string idMessageBoard = GetRequestParm(context, "IDMessageBoard");
|
||||
if (string.IsNullOrEmpty(idMessageBoard)) { idMessageBoard = "root"; }
|
||||
string userName = Convert.ToString(GetRequestParm(context, "UserName"));
|
||||
Session session = Sessions.Current.Session_GetCurrent(context);
|
||||
if (session.UserName.ToLower() != userName.ToLower())
|
||||
@@ -98,14 +98,14 @@ namespace VAR.Focus.Web.Controls
|
||||
lock (_chatBoards)
|
||||
{
|
||||
MessageBoard messageBoard;
|
||||
if (_chatBoards.ContainsKey(idBoard))
|
||||
if (_chatBoards.ContainsKey(idMessageBoard))
|
||||
{
|
||||
messageBoard = _chatBoards[idBoard];
|
||||
messageBoard = _chatBoards[idMessageBoard];
|
||||
}
|
||||
else
|
||||
{
|
||||
messageBoard = new MessageBoard(idBoard);
|
||||
_chatBoards[idBoard] = messageBoard;
|
||||
messageBoard = new MessageBoard(idMessageBoard);
|
||||
_chatBoards[idMessageBoard] = messageBoard;
|
||||
}
|
||||
messageBoard.Message_Add(userName, text);
|
||||
lock (_monitor) { Monitor.PulseAll(_monitor); }
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace VAR.Focus.Web.Pages
|
||||
private int _idBoard = 0;
|
||||
|
||||
private CTextBox _txtTitle = new CTextBox { ID = "txtTitle", CssClassExtra="width100pc" };
|
||||
private CTextBox _txtDescription = new CTextBox { ID = "txtDescription", CssClassExtra = "width100pc" };
|
||||
private CTextBox _txtDescription = new CTextBox { ID = "txtDescription", CssClassExtra = "width100pc", TextMode = TextBoxMode.MultiLine };
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace VAR.Focus.Web.Pages
|
||||
|
||||
ChatControl chatControl = new ChatControl();
|
||||
chatControl.ID = "ctrChat";
|
||||
chatControl.IDBoard = board.IDBoard;
|
||||
chatControl.IDMessageBoard = string.Format("CardBoard_{0}", board.IDBoard);
|
||||
chatControl.UserName = CurrentUser.Name;
|
||||
Controls.Add(chatControl);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
|
||||
// Pool data
|
||||
var data = {
|
||||
"IDBoard": cfg.IDBoard,
|
||||
"IDMessageBoard": cfg.IDMessageBoard,
|
||||
"IDMessage": cfg.IDMessage,
|
||||
"TimePoolData": ((cfg.FirstMessages || cfg.Connected == false) ? "0" : String(cfg.TimePoolData)),
|
||||
"TimeStamp": new Date().getTime()
|
||||
@@ -166,7 +166,7 @@ function SendChat(cfg) {
|
||||
// Send data
|
||||
var data = {
|
||||
"Text": cfg.txtText.value,
|
||||
"IDBoard": cfg.IDBoard,
|
||||
"IDMessageBoard": cfg.IDMessageBoard,
|
||||
"UserName": cfg.UserName,
|
||||
"TimeStamp": new Date().getTime()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user