UpdateRoom() public method

public UpdateRoom ( Room r ) : void
r Room
return void
コード例 #1
0
ファイル: Edit.ascx.cs プロジェクト: joaocalmeida/dnnCHAT
        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());
        }
コード例 #2
0
ファイル: View.ascx.cs プロジェクト: ChrisHammond/dnnCHAT
        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);
            }
        }