public ActionResult Login(LoginViewModel model) { if (ModelState.IsValid) { var userSvc = new SysUserService(); var permissionSvc = new SysPermissionService(); //判断登录 if (userSvc.Login(model.LoginName, model.LoginPwd)) { Session[CommonSession.SysUserName] = model.LoginName; //当前登录用户名 Session[CommonSession.SysUserRealName] = userSvc.SysUser.RealName; //当前登录用户名 Session[CommonSession.SysUserId] = userSvc.UserId; //当前登录用户编号 Session[CommonSession.SysDepartId] = userSvc.SysDepartId; //当前登录用户所属部门 Session[CommonSession.SysDepartName] = userSvc.SysDepartName; //当前登录用户所属部门名称 Session[CommonSession.SysDepartType] = userSvc.SysDepartType; //当前登录用户所属部门类型 Session[CommonSession.RegionCity] = userSvc.RegionCity; //当前登录用户所属城市 Session[CommonSession.RegionCounty] = userSvc.RegionCounty; //当前登录用户所属县区 Session[CommonSession.CurrentUser] = userSvc.SysUser; //当前登录的用户实体 Session[CommonSession.SysRoles] = userSvc.SysRole; //当前登录用户角色 model.LoginName = userSvc.SysUser.RealName; return(RedirectToAction(nameof(Success))); //跳转 } else { ModelState.AddModelError("", @"您的账号密码有误"); } } return(View(model)); }
public JsonResult UserLogOn_Pad(FormCollection collection) { Language lang; var service = new SysUserService(); SysUser user = service.Login(collection["UserName"], collection["Password"]); if (user == null || string.Compare(user.Pwd, collection["Password"], false) != 0) { return(Json(new { success = false, msg = "<=PwdorNameError>" })); } else { DateTime dt = DateTime.Today; if (!(user.ValidDateFrom <= dt && user.ValidDateTo >= dt) || !user.Active) { return(Json(new { success = false, msg = "<=UserExpireError>" })); } //密码过期修改 if (!user.PasswordDate.HasValue) { string errorMsg = string.Empty; user.PasswordDate = DateTime.Now.Date; bool success = service.Save(user, out errorMsg); if (!success) { return(Json(new { success = false, msg = errorMsg })); } } else { if (user.PasswordDate.Value.AddDays(30).Date <= DateTime.Now.Date) { lang = (Language)int.Parse(collection["Lang"]); Response.Cookies["Lang"].Value = lang == Language.English ? "English" : "SimplifiedChinese"; Response.Cookies["Lang"].Expires = DateTime.Now.AddDays(365); return(Json(new { success = false, msg = "expired" })); } } FormsService.SignIn(collection["UserName"], false); lang = (Language)int.Parse(collection["Lang"]); Response.Cookies["Lang"].Value = lang == Language.English ? "English" : "SimplifiedChinese"; Response.Cookies["Lang"].Expires = DateTime.Now.AddDays(365); string s = "FrogDashboard.Service.Services.MasterData.SysManagement.SysFunctionService"; ISysFunction <SysFunction> service_ = (ISysFunction <SysFunction>)Assembly.Load("FrogDashboard.Service").CreateInstance(s); var userRoleId = user.RoleId; if (service_.GetUserFunction(userRoleId).Where(c => c.ControllerName == "OrderManagement" && c.ActionName == "TmsForPad").Count() > 0) { return(Json(new { success = true, msg = "<LoginSuccess>", URL = "Pad" })); } else { return(Json(new { success = true, msg = "<LoginSuccess>", URL = "Index" })); } } }
public SysUser Login(string username, string pwd, out string msg) { #if NEWLOGIN return(Sus.Login(username, pwd, out msg)); #else msg = ""; return(Sus.GetSysUserInfo(username, pwd)); #endif }
public JsonResult ChangePasswordPost(FormCollection collection) { var service = new SysUserService(); SysUser user = service.Login(collection["UserCode"], collection["OldPwd"]); if (user == null || string.Compare(user.Pwd, collection["OldPwd"], false) != 0) { return(Json(new { success = false, msg = "<=OldPwdNotMatched>" })); } else { if (string.Compare(collection["NewPwd"], collection["ConfirmPwd"], false) != 0) { return(Json(new { success = false, msg = "<=NewPwdNotMatched>" })); } if (string.Compare(collection["NewPwd"], user.Pwd, false) == 0) { return(Json(new { success = false, msg = "<=ForbidMatchOldPwd>" })); } string errorMsg = string.Empty; user.PasswordDate = DateTime.Now.Date; user.Pwd = collection["NewPwd"]; TryUpdateModel <SysUser>(user); //判断新密码规则,Operator不受密码规则控制 var _sysUserRoleService = new SysUserRoleService(); var _sysRoleService = new SysRoleService(); var sysUserRole = _sysUserRoleService.GetList().Where(o => o.SysUserId == user.SysUserId).Select(o => o.SysRoleId).Distinct().ToList(); var sysRole = _sysRoleService.GetList().Where(o => sysUserRole.Contains(o.SysRoleId) || o.SysRoleId == user.RoleId).ToList(); if (sysRole.Count() > 0 && (sysRole.Count() != 1 || sysRole.Where(o => o.RoleCode.Contains("Operator")).Count() <= 0)) { if (!this.PassWordIsValid(user.Pwd)) { return(Json(new { success = false, msg = "<=PasswordError>" }, JsonRequestBehavior.AllowGet)); } } if (!ModelState.IsValid) { List <string> errorList = ModelStateExtension.GetModelError(ViewData); string str = string.Join(",", errorList.ToArray()); return(Json(new { success = false, msg = str }, JsonRequestBehavior.AllowGet)); } bool success = service.Save(user, out errorMsg); if (!success) { return(Json(new { success = false, msg = errorMsg })); } FormsService.SignIn(collection["UserCode"], false); return(Json(new { success = true, msg = "<=ModifySuccess>" })); } }
public ActionResult Login(UserLogin user) { if (!ModelState.IsValid) { return(View(user)); } var obj = SysUserService.Login(user.UserName, user.UserPwd); if (obj == null) { ViewBag.msg = "帐户或密码输入不正确!"; return(View(user)); } new CurrentUser().Login(obj, user.RememberMe); LogService.WriteLogin(string.Format("用户({0},{1})成功登录系统!", obj.LoginName, obj.FullName), LogModule.其他); return(Redirect(Url.Action("Index", "Home"))); }
public ActionResult Login(LoginViewModel model) { var userService = new SysUserService(); sys_user user = userService.Login(model.Username, model.Password); if (user != null) { System.Web.HttpContext.Current.Session.Clear(); // 登录成功 FormsAuthentication.SetAuthCookie(user.UserCode, true); // 缓存用户信息 System.Web.HttpContext.Current.Session["sys_user"] = user; userService.OnLogined(user); return(Json(new { success = true, url = Url.Action("Index", "Home") })); } else { return(Json(new { success = false })); } }
public JsonResult UserLogForWinCE(FormCollection collection) { //Language lang; var service = new SysUserService(); SysUser user = service.Login(collection["UserName"], collection["Password"]); if (user == null || string.Compare(user.Pwd, collection["Password"], false) != 0) { return(Json(new { success = false, msg = "<=PwdorNameError>" })); } else { DateTime dt = DateTime.Today; if (!(user.ValidDateFrom <= dt && user.ValidDateTo >= dt) || !user.Active) { return(Json(new { success = false, msg = "<=UserExpireError>" })); } FormsService.SignIn(collection["UserName"], false); //lang = (Language)int.Parse(collection["Lang"]); //Response.Cookies["Lang"].Value = lang == Language.English ? "English" : "SimplifiedChinese"; //Response.Cookies["Lang"].Expires = DateTime.Now.AddDays(365); return(Json(new { success = true, msg = "<=LoginSuccess>" })); } }
public ResponseResult Login(LoginParam loginParam) { var r = SysUserService.Login(loginParam); return(r); }
public JsonResult UserLogOn(FormCollection collection) { Language lang; var service = new SysUserService(); SysUser user = service.Login(collection["UserName"], collection["Password"]); #region authentication for exterior user //if (!string.IsNullOrEmpty(collection["KeyCode"])) //NameValueCollection appSettings = ConfigurationManager.AppSettings; //string strUrl = appSettings["ExteriorUrl"]; //if (Request.ServerVariables["server_name"].ToLower() == strUrl.ToLower()) //{ // string strkey = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString(); // strkey = collection["UserName"].ToLower() + strkey; // MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider(); // UTF8Encoding encoder = new UTF8Encoding(); // byte[] hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(strkey)); // string strResult = BitConverter.ToString(hashedDataBytes).Replace("-", string.Empty); // if (strResult.ToLower() != collection["KeyCode"].ToLower()) // return Json(new { success = false, msg = "<=KeyCodeError>" }); //} #endregion if (user == null || string.Compare(user.Pwd, collection["Password"], false) != 0) { return(Json(new { success = false, msg = "<=PwdorNameError>" })); } else { DateTime dt = DateTime.Today; if (!(user.ValidDateFrom <= dt && user.ValidDateTo >= dt) || !user.Active) { return(Json(new { success = false, msg = "<=UserExpireError>" })); } //密码过期修改 if (!user.PasswordDate.HasValue) { string errorMsg = string.Empty; user.PasswordDate = DateTime.Now.Date; bool success = service.Save(user, out errorMsg); if (!success) { return(Json(new { success = false, msg = errorMsg })); } } else { if (user.PasswordDate.Value.AddDays(30).Date <= DateTime.Now.Date) { lang = (Language)int.Parse(collection["Lang"]); Response.Cookies["Lang"].Value = lang == Language.English ? "English" : "SimplifiedChinese"; Response.Cookies["Lang"].Expires = DateTime.Now.AddDays(365); return(Json(new { success = false, msg = "expired" })); } } FormsService.SignIn(collection["UserName"], false); lang = (Language)int.Parse(collection["Lang"]); Response.Cookies["Lang"].Value = lang == Language.English ? "English" : "SimplifiedChinese"; Response.Cookies["Lang"].Expires = DateTime.Now.AddDays(365); return(Json(new { success = true, msg = "<LoginSuccess>" })); } }
private void button1_Click(object sender, EventArgs e) { PackageService service = new PackageService(); //service.GetAllOrder(1); //List<T_PRODUCE_POKE> list = TaskService.getList(1, 1); //String list = AtsCellInService.getCellNoCode("1111111"); List <MainBeltInfo> list = new List <MainBeltInfo>(); MainBeltInfo info = new MainBeltInfo(); info.SortNum = 72345; info.Quantity = 20; info.GroupNO = 1; info.mainbelt = "1"; list.Add(info); List <decimal> list1 = new List <decimal>(); list1.Add(72370); list1.Add(72369); list1.Add(72362); list1.Add(72361); list1.Add(72360); list1.Add(72355); list1.Add(72352); list1.Add(72352); List <decimal> list2 = new List <decimal>(); list2.Add(0); list2.Add(0); list2.Add(0); list2.Add(0); list2.Add(0); list2.Add(0); list2.Add(10); list2.Add(0); info.SortNumList = list1; info.QuantityList = list2; MainBeltInfoService.GetMainBeltInfo(list); // String str = "1203".Substring(0,2); List <MainBeltInfo> infolist = new List <MainBeltInfo>(); MainBeltInfo info1 = new MainBeltInfo(); info1.SortNum = 71069; // info.GroupNO = 1; info1.Quantity = 1; info1.mainbelt = "2"; infolist.Add(info); MainBeltInfoService.GetMainBeltInfo(infolist); // OpenSerialPort(); // OpenSerialPort1(); if (info1.Quantity == 1) { return; } try { // throw(new Exception()); string ls_pass; ls_pass = textBox2.Text; ls_pass = Security.MD5Encrypt(ls_pass).ToLower(); if (ls_pass == "") { MessageBox.Show("请输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (SysUserService.Login(txtUserName.Text, ls_pass)) { Constant.userName = txtUserName.Text.Trim(); DialogResult = DialogResult.OK; } else { MessageBox.Show("用户名密码不对,请重新输入!"); return; } } catch (Exception ex) { MessageBox.Show("错误" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }