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(dd); if (models != null) { DAL_LogInUser provider = new DAL_LogInUser(); PageInfo pageInfo = new PageInfo() { PageIndex = models.pageIndex, PageSize = models.pageSize }; List 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); } } }