using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Spaces;
using System.Xml;
public partial class dllayoutsettings : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Account == null || Account == string.Empty)
        {
            Response.Write("请登陆后再更改页面设置！");
            Response.End();
        }
        UserLayout ul = new UserLayout();
        UserConfig uc = Cacher.GetUserConfig(Account);
        Theme theme = Globals.GetThemes().FindTheme(uc.Theme);
 
        string layout = Request.Form["homePageLayout"];
 
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(layout);
        ul.Style = string.Empty;
        XmlNode ts = doc.SelectSingleNode("L");
        ul.Rows.Clear();
        foreach (XmlNode n in ts["Rs"])
        {
    
            ThemeRow tr = new ThemeRow();

 

            foreach (XmlNode c in n["Ps"])
            {
                ThemeCell tc = new ThemeCell();
                tc.ModuleName = c.Attributes["T"].Value;
                tc.Parameter = string.Empty;
                if (tc.ModuleName.ToLower() != "twealui")
                {
                    tr.Add(tc);
                }
            }
            ul.Rows.Add(tr);
        }
        uc.Layout = ul;
        uc.Layout.Theme = Request.Form["rColor"];
        uc.Layout.Layout = Request.Form["rLayout"];
       
        Users.UpdateUserConfig(uc);
 
        Response.Redirect(Globals.GetSiteUrls().Default(uc.Account));

    }
    string Account
    {
        get { return SpacesContext.Current.Context.User.Identity.Name; }
    }
}
