Example #1
0
    public string ListUserFavorites(string userCode, string type)
    {
        string            listf      = string.Empty;
        string            icon       = string.Empty;
        IList <Favorites> ifavorites = TheFavoritesMgr.GetFavorites(userCode, type);
        int count = int.Parse(TheEntityPreferenceMgr.LoadEntityPreference("HistoryNo").Value);

        count = count < ifavorites.Count ? count : ifavorites.Count;
        for (int i = 0; i < count; i++)
        {
            Favorites fav = ifavorites[i];
            icon = fav.PageImage;
            if (!File.Exists(Server.MapPath("~/Images/Nav/" + fav.PageImage + ".png")))
            {
                icon = "Default";
            }
            icon   = "<img src = 'Images/Nav/" + icon + ".png' />";
            listf += "<li class='div-favorite'><span onclick ='DeleteFavorite(" + fav.Id + ")'>XX</span>" + icon;
            listf += "<a href = 'Main.aspx" + fav.PageUrl + "' target = right title = " + fav.PageImage + ">" + fav.PageName + "</a></li>";
        }
        return(listf);
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Session["Current_User"] == null)
        {
            this.Response.Redirect("~/Logoff.aspx");
        }
        else
        {
            this.Title = TheEntityPreferenceMgr.LoadEntityPreference("CompanyName").Value;

            if (!Page.IsPostBack)
            {
                string ThemePage = string.Empty;

                HttpCookie cookieThemePage = new HttpCookie("ThemePage");
                if (this.CurrentUser.UserThemePage == null || this.CurrentUser.UserThemePage.Trim() == string.Empty)
                {
                    cookieThemePage.Value = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE).Value;
                    Response.Cookies.Add(cookieThemePage);

                    this.CurrentUser.UserThemePage = cookieThemePage.Value;

                    UserPreference usrpf = new UserPreference();
                    usrpf.User  = this.CurrentUser;
                    usrpf.Code  = BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE;
                    usrpf.Value = cookieThemePage.Value;
                    TheUserPreferenceMgr.CreateUserPreference(usrpf);
                }
                else
                {
                    UserPreference userPreferenceThemePage = TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, "ThemePage");
                    if (userPreferenceThemePage != null && userPreferenceThemePage.Value == BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE_RANDOM)
                    {
                        ThemePage = TheCodeMasterMgr.GetRandomTheme(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE);
                    }
                    else
                    {
                        ThemePage = userPreferenceThemePage.Value;
                    }
                    cookieThemePage.Value = ThemePage;
                    Response.Cookies.Add(cookieThemePage);
                }

                #region 随机框架主题
                HttpCookie cookieThemeFrame = new HttpCookie("ThemeFrame");
                if (this.CurrentUser.UserThemeFrame == null || this.CurrentUser.UserThemeFrame.Trim() == string.Empty)
                {
                    cookieThemeFrame.Value = string.Empty;
                    Response.Cookies.Add(cookieThemeFrame);

                    this.CurrentUser.UserThemeFrame = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME).Value;

                    UserPreference usrpf = new UserPreference();
                    usrpf.User  = this.CurrentUser;
                    usrpf.Code  = BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME;
                    usrpf.Value = this.CurrentUser.UserThemeFrame;
                    TheUserPreferenceMgr.CreateUserPreference(usrpf);
                }
                else
                {
                    string themeFrame = TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, "ThemeFrame").Value;
                    switch (themeFrame)
                    {
                    case "Picture":
                        cookieThemeFrame.Value = string.Empty;
                        Response.Cookies.Add(cookieThemeFrame);
                        break;

                    case "Random":
                        cookieThemeFrame.Value = TheCodeMasterMgr.GetRandomTheme("ThemeFrame");
                        Response.Cookies.Add(cookieThemeFrame);
                        break;

                    default:
                        cookieThemeFrame.Value = themeFrame;
                        Response.Cookies.Add(cookieThemeFrame);
                        break;
                    }
                }
                #endregion
            }

            //确定MainFrame的页面为退出前的页面
            if (Request.Params.Get("rightFrameUrl") == null)
            {
                IList <Favorites> listFavorites = TheFavoritesMgr.GetFavorites(this.CurrentUser.Code, "History");

                if (listFavorites.Count != 0)
                {
                    Favorites favorite = listFavorites[0];
                    url = "Main.aspx" + favorite.PageUrl;
                }
                else
                {
                    url = "Main.aspx?mid=Security.UserPreference";
                }
            }
            else
            {
                url = Request.Params.Get("rightFrameUrl");
            }
        }
    }