bklLiudl
2024-07-23 277bbae216debe7e6c04e8cc6ee6e1ba9763e14b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using BLL;
using Model;
using Common;
using Lib;
using System.Web.Mvc;
using System.Collections.Generic;
using BLL.DAL;
using Json;
using System.Web.Script.Serialization;
using System.Linq;
 
namespace wms
{
    public class LoginController : MainPage
    {
        AjaxPage ajaxPage = new AjaxPage();
        public ActionResult Login(string returnurl)
        {
            ViewBag.ReferrerUrl = returnurl;
            return View();
        }
 
 
        [HttpGet]
        public ActionResult GetAuthCode()
        {
            return File(new VerifyCode().GetVerifyCode(), @"image/Gif");
        }
 
        [HttpPost]
 
        public ActionResult CheckLogin(string username, string password, string code)
        {
            IDALUserInfo user_idao = new DALUserInfo();
 
            try
            {
                //string VerifyCode = WebHelper.GetSession("wms_session_verifycode").ToString();
                //if (VerifyCode.IsEmpty() || Md5Helper.Md5(code.ToLower(), 16) != VerifyCode)
                //{
                //    // liudl 注释 验证码不启用
                //    //throw new Exception("验证码错误,请重新输入");
                //}
                UserInfo dtlogin = user_idao.GetModel(username.Trim(), password.Trim());
                if (dtlogin != null)
                {
                    this.LoginUser = dtlogin;
                    LoginLog lg = new LoginLog()
                    {
                        Usercode = dtlogin.UserCode,
                        Username = dtlogin.Username,
                        RealName = dtlogin.RealName,
                        RoleName = dtlogin.RoleName,
                        DepartName = dtlogin.DepartName,
                        DepartNum = dtlogin.DepartNum,
                        LoginIp = Net.Ip,
                        LoginTime = "GETDATE()",
                        guid = "NEWID()",
                        Dome = ""
                    };
                    IDALUserLoginLog user_Log = new DALLoginLog();
                    user_Log.Add(lg);
 
                    return Content(JsonHelper.ObjectToJson(new AjaxResult { state = ResultType.success.ToString(), message = "登录成功。" }));
 
                }
 
                else
                    return Content(JsonHelper.ObjectToJson(new AjaxResult { state = ResultType.info.ToString(), message = "用户名或密码错误。" }));
            }
            catch (Exception ex)
            {
                return Content(JsonHelper.ObjectToJson(new AjaxResult { state = ResultType.error.ToString(), message = ex.Message }));
            }
        }
 
        [HttpPost]
        public ActionResult GetLogInUserRecordList(string username, string password, string code)
        {
            var dd = Request["ajaxdata"];
            var models = new JavaScriptSerializer().Deserialize<AjaxLogInUserList>(dd);
 
            if (models != null)
            {
                DAL_LogInUser provider = new DAL_LogInUser();
                PageInfo pageInfo = new PageInfo() { PageIndex = models.pageIndex, PageSize = models.pageSize };
                List<WCSLogInUser> entity = provider.GetList(models, ref pageInfo).ToList();
 
                string json = JsonHelper.IListToJson(entity, "List");
                string pjson = ConvertJson.Serializer(pageInfo);
 
                ajaxPage.ReturnJson.AddProperty("Result", new JsonObject(json));
                ajaxPage.ReturnJson.AddProperty("PageInfo", new JsonObject(pjson));
                ajaxPage.ReturnJson.AddProperty("Code", 1);
                ajaxPage.ReturnJson.AddProperty("Message", "响应成功");
 
                return Content(this.ajaxPage.ReturnJson.ToString());
            }
            return Content(null);
        }
 
 
    }
}