Esempio n. 1
0
        /// <summary>
        /// 用户登录成功,将ID等相关重要信息写入cookie中
        /// </summary>
        private void LoginConfirm(tblUserInfo model, HttpResponseBase Response)
        {
            CryptManage crypt  = new CryptManage();
            HttpCookie  cookie = new HttpCookie("LoginUser");

            cookie.Expires = DateTime.Now.AddMinutes(30);

            DepartmentInfoDataTreeManage tree   = new DepartmentInfoDataTreeManage();
            tblDepartmentInfo            parent = tree.GetFirstParent(Convert.ToInt64(model.UserIDepartmentIID));

            cookie.Values.Add("ID", crypt.Encrypto(model.ID.ToString()));
            cookie.Values.Add("UserName", HttpUtility.UrlEncode(model.Name));
            cookie.Values.Add("RegisterName", HttpUtility.UrlEncode(model.UserICode));
            cookie.Values.Add("UserDuty", HttpUtility.UrlEncode(model.DutyInfo.Name));
            cookie.Values.Add("DepartmentID", crypt.Encrypto(model.UserIDepartmentIID.ToString()));
            if (parent != null)
            {
                cookie.Values.Add("ParentDepartmentID", crypt.Encrypto(parent.ID.ToString()));
                cookie.Values.Add("UserGxID", crypt.Encrypto(parent.GxID.ToString()));
            }
            else
            {
                cookie.Values.Add("ParentDepartmentID", crypt.Encrypto("0"));
                cookie.Values.Add("UserGxID", crypt.Encrypto("0"));
            }
            string sUserRoles     = string.Join(CosValue.SPLITOPERATOR2.ToString(), model.authorRelations.Select(x => x.author.ID).ToArray());
            string sUserRoleNames = HttpUtility.UrlEncode(string.Join(CosValue.SPLITOPERATOR1.ToString(), model.authorRelations.Select(x => x.author.Name).ToArray()));

            cookie.Values.Add("UserRoles", crypt.Encrypto(sUserRoles));
            cookie.Values.Add("UserRoleNames", sUserRoleNames);

            Response.Cookies.Add(cookie);
        }
Esempio n. 2
0
        /// <summary>
        /// 对密码进行加密
        /// </summary>
        /// <param name="sPass"></param>
        /// <returns></returns>
        public string GetSecretPass(string sPass)
        {
            CryptManage crypt = new CryptManage();

            return(crypt.Encrypto(sPass));
        }