GetRoom() 공개 메소드

public GetRoom ( System.Guid roomId, int moduleId ) : Room
roomId System.Guid
moduleId int
리턴 Room
예제 #1
0
 protected void ddlRooms_OnSelectedIndexChanged(object sender, EventArgs e)
 {
     divRoomSettings.Visible = true;
     //TODO: load the room into the edit interface.
     var rc = new RoomController();
     if (ddlRooms.SelectedValue != "-1")
     {
         var r = rc.GetRoom(new Guid(ddlRooms.SelectedValue), ModuleId);
         if (r != null)
         {
             txtRoomId.Text = r.RoomId.ToString();
             txtRoomName.Text = r.RoomName;
             txtRoomDescription.Text = r.RoomDescription;
             txtRoomPassword.Text = r.RoomPassword;
             txtRoomWelcome.Text = r.RoomWelcome;
             chkPrivateRoom.Checked = r.Private;
             chkEnabled.Checked = r.Enabled;
         }
     }
 }
예제 #2
0
        protected void lbSubmit_Click(object sender, EventArgs e)
        {
            //save the room
            var rc = new RoomController();
            if (txtRoomId.Text.Any())
            {
                var r = rc.GetRoom(new Guid(txtRoomId.Text), ModuleId);
                r.RoomName = txtRoomName.Text.Trim();
                r.RoomDescription = txtRoomDescription.Text.Trim();
                r.RoomPassword = txtRoomPassword.Text.Trim();
                r.RoomWelcome = txtRoomWelcome.Text.Trim();
                r.Private = chkPrivateRoom.Checked;
                r.Enabled = chkEnabled.Checked;
                r.LastUpdatedByUserId = UserId;
                r.LastUpdatedDate = DateTime.UtcNow;

                rc.UpdateRoom(r);

            }
            else
            {
                var r = new Room
                {
                    RoomId = Guid.NewGuid(),
                    RoomName = txtRoomName.Text.Trim(),
                    RoomDescription = txtRoomDescription.Text.Trim(),
                    RoomPassword = txtRoomPassword.Text.Trim(),
                    RoomWelcome = txtRoomWelcome.Text.Trim(),
                    Private = chkPrivateRoom.Checked,
                    Enabled = chkEnabled.Checked,
                    CreatedByUserId = UserId,
                    CreatedDate =  DateTime.UtcNow,
                    LastUpdatedByUserId = UserId,
                    LastUpdatedDate =  DateTime.UtcNow,
                    ModuleId =  ModuleId

                };
                rc.CreateRoom(r);
            }
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

                //TODO: be sure to check for permissions when enabled
                if (!Page.IsPostBack)
                {
                    var sd = Request.QueryString["sd"];
                    var ed = Request.QueryString["ed"];

                    var startDate = DateTime.UtcNow.Date;
                    var endDate = DateTime.UtcNow;
                    if (sd != null)
                    {
                        startDate = Convert.ToDateTime(sd);
                    }
                    if (ed != null)
                    {
                        endDate = Convert.ToDateTime(ed);
                    }

                    txtStartDate.Text = startDate.ToString(CultureInfo.InvariantCulture);
                    txtEndDate.Text = endDate.ToString(CultureInfo.InvariantCulture);
                    var mc = new MessageController();
                    rptMessages.DataSource = mc.GetMessagesByDate(ModuleId, startDate, endDate, RoomId);
                    rptMessages.DataBind();

                    //if we have any items, don't display the "no results found" message
                    if (rptMessages.Items.Count > 0)
                    {
                        lblNoResults.Visible = false;
                    }
                    BuildArchiveLinks(RoomId);

                    var rc = new RoomController();
                    var r = rc.GetRoom(RoomId, ModuleId);
                    var tp = (CDefault)Page;
                    var t = new TabController().GetTab(TabId, PortalId, false);
                    tp.Title += string.Format(Localization.GetString("ChatArchiveTitle.Text", LocalResourceFile), t.TabName, r.RoomName, startDate.ToShortDateString(), endDate.ToShortDateString());
                    lblArchiveTitle.Text = string.Format(Localization.GetString("ChatArchiveContentTitle.Text", LocalResourceFile), r.RoomName, startDate.ToShortDateString(), endDate.ToShortDateString());
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
예제 #4
0
        //check to see if there is a string in the message that is too many characters put together
        private string ParseMessage(string message, Guid roomId)
        {
            //not using REGEX for now, maybe in the future
            //Regex nameChangeRegex = new Regex(@"/nick[^/]+", RegexOptions.IgnoreCase);

            //var nameChangeMatch = nameChangeRegex.Match(message);
            ////clean out all "scope" parameters from DNN Forum urls
            //if (nameChangeMatch.Success)
            //{
            //    //change the name
            //    string newName = message.Split(':')[1];
            //    message = UpdateName(newName.Trim());
            //}

            //TODO: allow command for Updating room description/properties
            //http://www.irchelp.org/irchelp/changuide.html

            //allow for Room creation/joining
            if (message.ToLower().StartsWith("/join"))
            {
                var userId = -1;
                if (Convert.ToInt32(Clients.Caller.userid) > 0)
                {
                    userId = Convert.ToInt32(Clients.Caller.userid);
                }

                if (userId > 0)
                {
                    string roomName = message.Remove(0, 5).Trim();
                    if (roomName.Length > 25)
                    {
                        Clients.Caller.newMessageNoParse(new Message {
                            AuthorName = Localization.GetString("SystemName.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), ConnectionId = "0", MessageDate = DateTime.UtcNow, MessageId = -1, MessageText = Localization.GetString("RoomNameTooLong.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), AuthorUserId = -1, RoomId = roomId
                        });
                        return(string.Empty);
                    }
                    //create room
                    else
                    {
                        var rc = new RoomController();
                        //Lookup existing Rooms
                        var r = rc.GetRoom(roomName);
                        //int.TryParse(Clients.Caller.moduleid, out moduleId);
                        int moduleId = Convert.ToInt32(Clients.Caller.moduleid);

                        if (r != null)
                        {
                            //todo: anything to do here? the room exists already
                            if (r.Enabled == false)
                            {
                                //what if the room has been disabled?
                            }
                        }
                        else
                        {
                            r = new Room
                            {
                                RoomId      = Guid.NewGuid(),
                                RoomName    = roomName,
                                RoomWelcome = Localization.GetString("DefaultRoomWelcome.Text", "~/desktopmodules/DnnChat/app_localresources/" +
                                                                     Localization.LocalSharedResourceFile),
                                RoomDescription = Localization.GetString("DefaultRoomDescription.Text",
                                                                         "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile),
                                ModuleId            = moduleId,
                                CreatedDate         = DateTime.UtcNow,
                                CreatedByUserId     = userId,
                                LastUpdatedByUserId = userId,
                                LastUpdatedDate     = DateTime.UtcNow,
                                Enabled             = true
                            };
                            rc.CreateRoom(r);
                        }

                        //make a call to the client to add the room to their model, and join
                        Clients.Caller.messageJoin(r);
                    }
                }
                else
                {
                    // if there is no username for the user don't let them post
                    var m = new Message
                    {
                        ConnectionId = Context.ConnectionId,
                        MessageDate  = DateTime.UtcNow,
                        MessageText  = Localization.GetString("AnonymousJoinDenied.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile),
                        AuthorName   = Localization.GetString("SystemName.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile),
                        AuthorUserId = -1,
                        RoomId       = roomId
                    };
                    Clients.Caller.newMessage(m);
                }
                message = string.Empty;
            }

            message = message.Replace(" ", " ").Replace("&nbsp", " ").Trim();

            //for name change, using starts with to see if they typed /nick in
            if (message.ToLower().StartsWith("/nick"))
            {
                string newName = message.Remove(0, 5);
                if (newName.Length > 25)
                {
                    Clients.Caller.newMessageNoParse(new Message {
                        AuthorName = Localization.GetString("SystemName.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), ConnectionId = "0", MessageDate = DateTime.UtcNow, MessageId = -1, MessageText = Localization.GetString("NameToolong.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), AuthorUserId = -1, RoomId = roomId
                    });
                    newName = newName.Remove(25);
                }

                if (newName.Trim().Length > 0)
                {
                    message = UpdateName(newName.Trim());
                }
            }

            if (message.ToLower().Trim() == Localization.GetString("Test.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile))
            {
                message = Localization.GetString("Test.Response", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile);
            }

            return(message);
        }
예제 #5
0
        /*
         * When a user connects we need to populate their user information, we default the username to be Anonymous + a #
         */

        //This method is to populate/join room
        public Task JoinRoom(Guid roomId, int moduleId)
        {
            //TODO: don't allow connecting to the same room twice
            var crc  = new ConnectionRecordController();
            var crrc = new ConnectionRecordRoomController();
            var rc   = new RoomController();

            var r = rc.GetRoom(roomId, moduleId);

            if (r.Enabled)
            {
                if (r.Private)
                {
                    //check the password
                }

                var c  = crc.GetConnectionRecordByConnectionId(Context.ConnectionId) ?? SetupConnectionRecord();
                var cr = crrc.GetConnectionRecordRoomByConnectionRecordId(c.ConnectionRecordId, roomId);



                if (cr == null)
                {
                    var crr = new ConnectionRecordRoom
                    {
                        ConnectionRecordId = c.ConnectionRecordId,
                        JoinDate           = DateTime.UtcNow,
                        DepartedDate       = null,
                        RoomId             = roomId
                    };

                    //join the room
                    crrc.CreateConnectionRecordRoom(crr);

                    var ulr = new UserListRecords(c, crr);

                    //add the user to the List of users that will be later filtered by RoomId
                    Users.Add(ulr);
                }

                Groups.Add(Context.ConnectionId, roomId.ToString());

                //populate history for all previous rooms
                RestoreHistory(roomId);

                //lookup the Room to get the Welcome Message
                Clients.Caller.newMessageNoParse(new Message
                {
                    AuthorName   = Localization.GetString("SystemName.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile),
                    ConnectionId = "0",
                    MessageDate  = DateTime.UtcNow,
                    MessageId    = -1,
                    MessageText  = r.RoomWelcome,
                    AuthorUserId = -1,
                    RoomId       = roomId
                });
                Clients.Group(roomId.ToString()).newMessageNoParse(new Message
                {
                    AuthorName = Localization.GetString("SystemName.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile)
                    ,
                    AuthorUserId = -1
                    ,
                    ConnectionId = "0",
                    MessageDate  = DateTime.UtcNow,
                    MessageId    = -1,
                    MessageText  = string.Format(Localization.GetString("Connected.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), c.UserName),
                    RoomId       = roomId
                });

                Clients.Caller.scrollBottom(r.RoomId);

                return(Clients.Group(roomId.ToString()).updateUserList(Users.FindAll(uc => (uc.RoomId == r.RoomId)), roomId));
            }
            else
            {
                //if the room was no longer enabled, return nothing
                return(null);
            }
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //link for the Chat Archives
                //hlArchive.NavigateUrl = EditUrl("Archive",);

                StartMessage = Settings.Contains("StartMessage") ? Settings["StartMessage"].ToString() : Localization.GetString("DefaultStartMessage", LocalResourceFile);

                DefaultAvatarUrl = Settings.Contains("DefaultAvatarUrl") ? Settings["DefaultAvatarUrl"].ToString() : Localization.GetString("DefaultAvatarUrl", LocalResourceFile);

                var directRoom = string.Empty;

                var qs = Request.QueryString["rmid"];
                if (qs != null)
                {
                    directRoom = qs.ToString();}

                if (Settings.Contains("DefaultRoomId") && directRoom == string.Empty)
                {
                    DefaultRoomId = Settings["DefaultRoomId"].ToString();
                }
                else if (directRoom != string.Empty)
                { //if a guid came in, let's put the user in that room.
                    DefaultRoomId = directRoom;
                }
                else
                {
                    //if we don't have a setting. go get the default room from the database.
                    var rc = new RoomController();
                    var r = rc.GetRoom("Lobby");
                    if (r == null || (r.ModuleId > 0 && r.ModuleId != ModuleId))
                    {
                        //todo: if there isn't a room we need display a message about creating one
                    }
                    else
                    {
                        //if the default room doesn't have a moduleid on it, set the module id
                        if (r.ModuleId < 0)
                        {
                            r.ModuleId = ModuleId;
                        }
                        rc.UpdateRoom(r);
                    }
                    if (r != null) DefaultRoomId = r.RoomId.ToString();
                }

                //encrypt the user's roles so we can ensure security
                var curRoles = UserInfo.Roles;

                var section = (MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey");

                var pc = new PortalSecurity();
                foreach (var c in curRoles)
                {
                    EncryptedRoles += pc.Encrypt(section.ValidationKey, c) + ",";
                }
                if (UserInfo.IsSuperUser)
                {
                    EncryptedRoles += pc.Encrypt(section.ValidationKey, "SuperUser");
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }