コード例 #1
0
        public UserOnlineInfo MyUser; //= UserManage.UserInfo;

        #region 初始化 在OnInit执行
        /// <summary>
        /// 设置当前登录人的信息
        /// 设置元数据的数据库的实例
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            var debugInfo = new NatureDebugInfo {
                Title = "[Nature.Service.Ashx.BaseAshx]判断Url参数"
            };

            base.OnInit(e);

            //验证是否已经登录
            //如果已经登录了,加载登录人员的信息,
            var manageUser = new ManageUser {
                Dal = Dal
            };

            UserWebappInfo userWebappInfo = AppManage.UserWebappInfoByCookies(debugInfo.DetailList);

            if (userWebappInfo.State != UserState.NormalAccess)
            {
                //没有登录。
                Response.Write("您还没有登录,请到<a href='/default.aspx' target='_top'>这里</a>登录");
                Response.End();
            }

            MyUser = manageUser.CreateUser(Convert.ToString(userWebappInfo.UserWebappID), null);

            //保存访问日志
            //SaveViewLog();
        }
コード例 #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string userCode = txtUserCode.Value; // Request.Form["userCode"];
            string userPsw  = txtUserPsw.Value;

            //实现登录

            userCode = userCode.Replace("'", "''");
            userPsw  = Functions.ToMD5(userPsw);

            var dal = CommonClass.SetMetadataDal();

            const string sql = "SELECT TOP 1 userID from Person_User_Info where UserCode='{0}' and LoginPsw ='{1}'";

            string userId = dal.DalUser.ExecuteString(string.Format(sql, userCode, userPsw));

            if (dal.DalUser.ErrorMessage.Length > 2)
            {
                //debugInfo.Remark = "到数据库验证登录账户和密码,出现异常!";
                Response.Write("<br>" + dal.DalUser.ErrorMessage);
            }

            if (dal.DalUser.ErrorMessage.Length > 2)
            {
                //debugInfo.Remark = "到数据库验证登录账户和密码,出现异常!";
                Response.Write("\"msg\":\"" + dal.DalUser.ErrorMessage + "\"");
                return;
            }

            if (string.IsNullOrEmpty(userId))
            {
                Response.Write("\"msg\":\"用户名和密码不匹配!\"");
                return;
            }

            Response.Write("<br>" + userId);

            var mUser = new ManageUser {
                Dal = dal
            };

            var debugInfo2 = new NatureDebugInfo {
                Title = "判断访问权限"
            };

            UserOnlineInfo user = mUser.CreateUser(userId, debugInfo2.DetailList);

            Response.Write("<br>" + user.BaseUser.UserID);
            Functions.PageRegisterJavascript(Page, "isLogin();");
        }
コード例 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string userCode = txtUserCode.Value; // Request.Form["userCode"];
            string userPsw = txtUserPsw.Value;

            //实现登录

            userCode = userCode.Replace("'", "''");
            userPsw = Functions.ToMD5(userPsw);

            var dal = CommonClass.SetMetadataDal();

            const string sql = "SELECT TOP 1 userID from Person_User_Info where UserCode='{0}' and LoginPsw ='{1}'";

            string userId = dal.DalUser.ExecuteString(string.Format(sql, userCode, userPsw));
            if (dal.DalUser.ErrorMessage.Length > 2)
            {
                //debugInfo.Remark = "到数据库验证登录账户和密码,出现异常!";
                Response.Write("<br>" + dal.DalUser.ErrorMessage);
            }

            if (dal.DalUser.ErrorMessage.Length > 2)
            {
                //debugInfo.Remark = "到数据库验证登录账户和密码,出现异常!";
                Response.Write("\"msg\":\"" + dal.DalUser.ErrorMessage + "\"");
                return;
            }

            if (string.IsNullOrEmpty(userId))
            {
                Response.Write("\"msg\":\"用户名和密码不匹配!\"");
                return;
            }

            Response.Write("<br>" + userId);

            var mUser = new ManageUser {Dal = dal};

            var debugInfo2 = new NatureDebugInfo {Title = "判断访问权限"};

            UserOnlineInfo user = mUser.CreateUser(userId, debugInfo2.DetailList);

            Response.Write("<br>" + user.BaseUser.UserID);
            Functions.PageRegisterJavascript(Page,"isLogin();");


        }