private ConnectionRecord SetupConnectionRecord() { string username = Clients.Caller.username; //if (string.IsNullOrEmpty(username)) //{ // Clients.Caller.newMessageNoParse(new Message { AuthorName = Localization.GetString("SystemName.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), ConnectionId = "0", MessageDate = DateTime.UtcNow, MessageId = -1, MessageText = string.Format(Localization.GetString("BadConnection.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), "phantom") }); // return new ConnectionRecord(); //} if (username.Trim() == "phantom" || username.Trim() == string.Empty) { username = string.Format(Localization.GetString("AnonymousUser.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), (Users.Count + 1)); } Clients.Caller.username = username; var userId = -1; if (Convert.ToInt32(Clients.Caller.userid) > 0) { userId = Convert.ToInt32(Clients.Caller.userid); } //check if the connectionrecord is already in the DB var crc = new ConnectionRecordController(); var c = crc.GetConnectionRecordByConnectionId(Context.ConnectionId); if (c != null) { c.UserName = username; crc.UpdateConnectionRecord(c); } else { c = new ConnectionRecord { ConnectionId = Context.ConnectionId, ConnectedDate = DateTime.UtcNow, ModuleId = Convert.ToInt32(Clients.Caller.moduleid), UserName = username, UserId = userId, IpAddress = GetIpAddress() }; //Users.Add(c); crc.CreateConnectionRecord(c); } //store the record for the connection return(c); }