CY_ZZJY.Web/login.ashx.cs

(完整代码) 2KB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using CY_ZZJY.Service.Sys;
using System.Data;
using CY_ZZJY.Web.models;
using CY_ZZJY.Model.Sys;

namespace CY_ZZJY.Web
{
    /// <summary>
    /// 系统登录
    /// </summary>
    public class login : IHttpHandler, IRequiresSessionState
    {
        private SYS_USER_Service _T_USER_Service = new SYS_USER_Service();
        private SYS_ORGANIZATION_Service _SYS_ORGANIZATION_Service = new SYS_ORGANIZATION_Service();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string result = string.Empty;;
            string name = string.Empty;
            string password = string.Empty;
            if (!string.IsNullOrEmpty(context.Request.Params["name"].ToString()))
                name = context.Request.Params["name"].ToString().Trim();
            if (!string.IsNullOrEmpty(context.Request.Params["password"].ToString()))
                password = context.Request.Params["password"].ToString().Trim();
            DataTable dt = _T_USER_Service.LoginToDataTable(name, password);
            if (dt == null || dt.Rows.Count == 0)
                result = "{\"isSucess\":\"false\",\"message\":\"用户名不存在\",\"value\":null}";
            else if (string.IsNullOrEmpty(dt.Rows[0]["IS_ENABLED"].ToString()) || dt.Rows[0]["IS_ENABLED"].ToString() == "N")
                result = "{\"isSucess\":\"false\",\"message\":\"此用户已被锁定,无法登陆!\",\"value\":null}";
            else
            {
                #region 登录用户session信息
                UserSession userSession = new UserSession();
                Mdl_SYS_USER _Mdl_SYS_USER = _T_USER_Service.LoginToModel(name, password);
                Mdl_SYS_ORGANIZATION _Mdl_SYS_ORGANIZATION = this._SYS_ORGANIZATION_Service.GetEntity(_Mdl_SYS_USER.ORG_ID);
                userSession.Mdl_SYS_USER = _Mdl_SYS_USER;
                userSession.Mdl_SYS_ORGANIZATION = _Mdl_SYS_ORGANIZATION;
                context.Session["CurrentUser"] = userSession;
                #endregion
                result = "{\"isSucess\":\"true\",\"message\":\"ok\",\"UserID\":'" + _Mdl_SYS_USER.USER_ID + "'}";
            }
            context.Response.Write(result);
        }
        public bool IsReusable
        {
            get { return false; }
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。