コード例 #1
0
    public virtual void Page_Load(object sender, EventArgs e)
    {
        //链接字符非法字符的检查,防止被网络攻击
        if (Common.SafetyCheck(this.Page))
        {
            Response.End();
        }

        //如果收到退出请求
        if (Request["exit"] != null)
        {
            Session.Abandon(); Request.Cookies.Clear();
        }

        //设置页面的标题
        this.Title = IOBase.WebTitle + (string.IsNullOrEmpty(this.Title) ? "" : "-" + this.Title);

        //查找页头控件,依据登陆状态,并向其传递参数
        //Control WebHead = this.FindControl("WebHead");

        //add by andre @ 08/22/16
        HttpCookie cookieloggedIn = Request.Cookies["ioc_loggedin"];

        if (cookieloggedIn != null)
        {
            string username     = cookieloggedIn.Value;
            string url_userinfo = Base_API_URI + "api/IO_Users?loginName=" + username;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url_userinfo);

                string jsonStr = null;
                using (WebResponse response = request.GetResponse())
                {
                    using (Stream stream = response.GetResponseStream())
                    {
                        StreamReader reader = new StreamReader(stream);
                        jsonStr = reader.ReadToEnd();
                    }
                }

                if (jsonStr != null)
                {
                    Dictionary <string, string> dict =
                        JsonConvert.DeserializeObject <Dictionary <string, string> >(jsonStr);
                    if (dict["UserId"] != null)
                    {
                        int     uid  = Int32.Parse(dict["UserId"]);
                        WebUser user = new WebUser(uid);
                        user.GetCompanyInformation();
                        Session["User"] = user;
                    }
                }
            }
            catch (WebException)
            {}
        }
        //add by andre end

        //获取当前登陆的用户信息
        if (Session["User"] != null)
        {
            this.Overtime = false; this.CurrentUser = (WebUser)Session["User"];
        }
        else
        {
            this.Overtime = true; Response.Redirect("../Default.aspx"); Response.End();
        }

        //数据索引值
        this.DataIndex = this.Form.Attributes["Data"];
        //如果长度大于10位,说明这个数据没有解密取回
        if (this.DataIndex != null && this.DataIndex.ToString().Length > 10)
        {
            this.DataIndex = Common.DecryptID(this.DataIndex);
        }
        else
        {
            this.DataIndex = null;
        }

        //其他索引值
        this.OtherIndex = this.Form.Attributes["Other"];
        //如果长度大于10位,说明这个数据没有解密取回
        if (this.OtherIndex != null && this.OtherIndex.ToString().Length > 10)
        {
            this.OtherIndex = Common.DecryptID(this.OtherIndex);
        }
        else
        {
            this.OtherIndex = null;
        }

        //备份索引值
        this.BackIndex = this.Form.Attributes["Back"];
        //如果长度大于10位,说明这个数据没有解密取回
        if (this.BackIndex != null && this.BackIndex.ToString().Length > 10)
        {
            this.BackIndex = Common.DecryptID(this.BackIndex);
        }
        else
        {
            this.BackIndex = null;
        }

        //最后索引值
        this.LastId = this.Form.Attributes["Last"];
        //如果长度大于10位,说明这个数据没有解密取回
        if (this.LastId != null && this.LastId.ToString().Length > 10)
        {
            this.LastId = Common.DecryptID(this.LastId);
        }
        else
        {
            this.LastId = null;
        }


        OutputSettings();
    }