public ActionResult Add(PcAndRole model) { Utility.ReturnData <string> returnData = new Utility.ReturnData <string>(); long count = bll.GetQueryCount(x => x.UserName == model.UserName && x.Status != 1); UserBasic ubModel = new UserBasic(); ubModel.NickName = model.UserName; ubModel.UserType = 1; ubModel.AddTime = DateTime.Now; ubModel.EnterpriseID = LoginUser.UserBasic.EnterpriseID; long id = ubBll.AddAndGetId(ubModel); UserPC upModel = new UserPC(); upModel.UserName = model.UserName; upModel.UserBasicID = id; upModel.RoleID = model.RoleID; upModel.PCType = 1; upModel.AddTime = DateTime.Now; upModel.PassWord = SimpleEncrypt.SaltMD5(model.PassWord.Replace(" ", "")); upModel.AddUserBasicID = LoginUser.UserBasicID; upModel.Status = 0; returnData = bll.AddUserPc(upModel); if (returnData.Status == false) { ubBll.Delete(s => s.ID == id); return(Content(returnData.Message)); } return(Content(returnData.Message)); }
public ActionResult FirstLogin(string name, string pwd, string num) { ReturnData <string> ret = new ReturnData <string>(); AgentBll aBll = new AgentBll(); UserBasicBll uBll = new UserBasicBll(); UserPCBll pcBll = new UserPCBll(); Agent aModel = aBll.GetModelByPhone(num); UserBasic uModel = new UserBasic(); UserPC pcModel = new UserPC(); uModel.NickName = name; uModel.UserType = 1; uModel.EnterpriseID = aModel.EnterpriseID; uModel.AddTime = DateTime.Now; long id = uBll.AddAndGetId(uModel); pcModel.UserBasicID = id; pcModel.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", "")); pcModel.PCType = 2; pcModel.RoleID = aModel.ID; pcModel.Status = 0; pcModel.UserName = name; pcModel.AddTime = DateTime.Now; pcModel.AddUserBasicID = 0; ret = pcBll.AddUserPc(pcModel); if (ret.Status == true) { aModel.Status = 0; aBll.EditAgent(aModel); return(Content(ret.Message)); } return(Content(ret.Message)); }
public static string _host = ".kerlaii.com";//从数据库动态获取 public void OnActionExecuting(ActionExecutingContext filterContext) { bool isajax = filterContext.HttpContext.Request.IsAjaxRequest(); UserPC user = filterContext.HttpContext.Session["user"] as UserPC; string host = filterContext.HttpContext.Request.Url.Host; string key = host.Replace(_host, ""); //本地调试,模拟e0001企业 opera if (host.ToLower() == "localhost") { key = "e0001"; } EnterpriseBll bll = new EnterpriseBll(); string[] keys = bll.GetAllEnteriseKey(); if (key != "opera" && !keys.Contains(key)) { filterContext.Result = new HttpNotFoundResult(); return; //没有该企业 } filterContext.HttpContext.Session["enterpriseKey"] = key; if (check) { if (user == null) { ReturnData <string> ret = new ReturnData <string>(); if (isajax) { ret.Status = false; Dictionary <string, object> Identify = new Dictionary <string, object>(); Identify.Add("expired", true); ret.Identify = Identify; filterContext.Result = new ContentResult() { Content = ret.GetJson() }; return; } //跳转页面 filterContext.Result = new ContentResult() { Content = "<script>window.top.location.href ='/';</script>" }; return; } LogAdapter.Write(user.UserBasic.EnterpriseID + " " + key, LogAdapter.LogMode.ERROR); //当前用户不是当前企业 if (user.UserBasic.EnterpriseID != key) { filterContext.HttpContext.Response.Redirect("/Login"); } } }
/// <summary> /// /// </summary> /// <param name="filterContext"></param> public void OnActionExecuting(ActionExecutingContext filterContext) { return; ReturnData <string> returndata = new ReturnData <string>(); UserPC user = filterContext.HttpContext.Session["user"] as UserPC; //string controllerName = (string)filterContext.RouteData.Values["controller"]; //control //string actionName = (string)filterContext.RouteData.Values["action"]; //action if (check) { if (user == null) { //跳转页面 filterContext.HttpContext.Response.Redirect("/Login/index"); return; } //权限验证! bool hasCount = false; if (Autorizs == null) { returndata.Status = false; returndata.Message = "没有该权限!"; filterContext.Result = new ContentResult() { Content = returndata.GetJson() }; return; } foreach (var val in Autorizs) { if (user.RolePowerList != null && user.RolePowerList.Where(x => x.PowerID == val.GetDescriptionN(0)).Count() > 0) { hasCount = true; break; } } if (!hasCount) { //验证失败后 调 用 returndata.Message = "没有该权限!"; filterContext.Result = new ContentResult() { Content = returndata.GetJson() }; return; } } }
public ActionResult Login(UserPC model, bool isAuto = false) { ReturnData <string> ret = new ReturnData <string>(); //Bll实例化放action里面 为了不让每次都实例化 产生废代码 UserPCBll bll = new UserPCBll(); //只要找得到记住的密码就去匹配记住的密码 if (Request.Cookies["remember"] != null) { if (Request.Cookies["remember"]["uname"] != "" && model.PassWord == "********") { model.Status = 99; model.PassWord = Request.Cookies["remember"]["pwd"]; } } //ReturnData 是值类型 不需要ref来赋值传递 当传入方法里时返回时还是带有值的 var user = bll.Login(ret, model, EnterpriseKey); if (user != null) { //登录成功了 才记住用户名和密码 if (isAuto) { Response.Cookies["remember"]["uname"] = user.UserName; Response.Cookies["remember"]["pwd"] = Convert.ToBase64String(YYYCommon.Encryption.SymmetricEncryption.Encrypt(user.PassWord + "\r" + DateTime.Now.ToString())); Response.Cookies["remember"].Expires = DateTime.Now.AddDays(7); } else { Response.Cookies["remember"]["uname"] = ""; } //保存登录信息 Session["user"] = user; //设置跳转路径 Dictionary <string, object> Identify = new Dictionary <string, object>(); if (EnterpriseKey.ToLower() == "opera") { Identify.Add("url", "/Operate/Areas/Index"); } else { //return RedirectToAction("WellCome"); Identify.Add("url", "/Login/Welcome"); } ret.Identify = Identify; } return(Content(ret.GetJson())); }
public ActionResult Login(UserPC model, bool isAuto = false) { ReturnData<string> ret = new ReturnData<string>(); //Bll实例化放action里面 为了不让每次都实例化 产生废代码 UserPCBll bll = new UserPCBll(); //只要找得到记住的密码就去匹配记住的密码 if (Request.Cookies["remember"] != null) { if (Request.Cookies["remember"]["uname"] != "" && model.PassWord == "********") { model.Status = 99; model.PassWord = Request.Cookies["remember"]["pwd"]; } } //ReturnData 是值类型 不需要ref来赋值传递 当传入方法里时返回时还是带有值的 var user = bll.Login(ret, model, EnterpriseKey); if (user != null) { //登录成功了 才记住用户名和密码 if (isAuto) { Response.Cookies["remember"]["uname"] = user.UserName; Response.Cookies["remember"]["pwd"] = Convert.ToBase64String(YYYCommon.Encryption.SymmetricEncryption.Encrypt(user.PassWord + "\r" + DateTime.Now.ToString())); Response.Cookies["remember"].Expires = DateTime.Now.AddDays(7); } else { Response.Cookies["remember"]["uname"] = ""; } //保存登录信息 Session["user"] = user; //设置跳转路径 Dictionary<string, object> Identify = new Dictionary<string, object>(); if (EnterpriseKey.ToLower() == "opera") { Identify.Add("url", "/Operate/Areas/Index"); } else { //return RedirectToAction("WellCome"); Identify.Add("url", "/Login/Welcome"); } ret.Identify = Identify; } return Content(ret.GetJson()); }
public ActionResult ChangePwd(string pwd, int id) { Utility.ReturnData <string> returnData = new Utility.ReturnData <string>(); UserPC model = bll.GetModelById(id); model.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", "")); returnData = bll.UpdateUserPc(model); if (returnData.Message == "编辑成功!") { return(Content("重置成功!")); } else { return(Content(returnData.Message)); } }
public ActionResult EditPwd(string oldpwd, string pwd) { Utility.ReturnData <string> ret = new Utility.ReturnData <string>(); long id = LoginUser.UserBasicID; UserPC model = bll.GetModelById(id); string checkpwd = SimpleEncrypt.SaltMD5(oldpwd.Replace(" ", "")); if (model.PassWord != checkpwd) { return(Content("原始密码不正确!")); } model.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", "")); bll.Update(model); return(Content("修改成功!")); }
public ActionResult Delete(int id) { Utility.ReturnData <string> returnData = new Utility.ReturnData <string>(); UserPC model = bll.GetModelById(id); ubBll.Delete(s => s.ID == id); model.Status = 1; returnData = bll.UpdateUserPc(model); if (returnData.Message == "编辑成功!") { return(Content("删除成功!")); } else { return(Content(returnData.Message)); } }
public ActionResult Index() { var model = new UserPC(); if (Request.Cookies["remember"] != null) { if (Request.Cookies["remember"]["uname"] != "") { model.UserName = Request.Cookies["remember"]["uname"]; model.PassWord = "******"; } } //获取企业信息 用来显示logo等信息 EnterpriseBll objEnterpriseBll = new EnterpriseBll(); var enterprise = objEnterpriseBll.GetObjectById(o => o.ID == EnterpriseKey); if (enterprise == null) return HttpNotFound(); ViewBag.Enterprise = enterprise; return View(model); }
public ActionResult Update(UserPC model) { Utility.ReturnData <string> returnData = new Utility.ReturnData <string>(); UserPC ucModel = bll.GetModelById(model.UserBasicID); ucModel.RoleID = model.RoleID; ucModel.UserName = model.UserName; ucModel.AddTime = DateTime.Now; ucModel.AddUserBasicID = LoginUser.UserBasicID; returnData = bll.UpdateUserPc(ucModel); if (returnData.Message == "编辑成功!") { return(Content(returnData.Message)); } else { return(Content(returnData.Message)); } }
public ActionResult UpdateList(string id, int roleid) { Utility.ReturnData <string> returnData = new Utility.ReturnData <string>(); string[] ids = id.Substring(0, id.Length - 1).Split(','); UserPC model = new UserPC(); for (int i = 0; i < ids.Length; i++) { model = bll.GetModelById(Convert.ToInt32(ids[i])); model.RoleID = roleid; returnData = bll.UpdateUserPc(model); } if (returnData.Message == "编辑成功!") { return(Content("关联成功!")); } return(Content(returnData.Message)); }
public ActionResult Index() { var model = new UserPC(); if (Request.Cookies["remember"] != null) { if (Request.Cookies["remember"]["uname"] != "") { model.UserName = Request.Cookies["remember"]["uname"]; model.PassWord = "******"; } } //获取企业信息 用来显示logo等信息 EnterpriseBll objEnterpriseBll = new EnterpriseBll(); var enterprise = objEnterpriseBll.GetObjectById(o => o.ID == EnterpriseKey); if (enterprise == null) { return(HttpNotFound()); } ViewBag.Enterprise = enterprise; return(View(model)); }
public JsonResult CreateAfter(ShopInfo model) { Utility.ReturnData <string> returnData = new Utility.ReturnData <string>(); ShopInfoBll shopBll = new ShopInfoBll(); UserPC _model = CacheHelp.Get("user") as UserPC; model.Relation = 1; model.ContactPhone = ""; model.Address = ""; model.Range = ""; model.shopIMG = ""; model.WeixinMPID = 0; model.Remarks = ""; model.AgentID = 0; model.ContactTEL = ""; model.Status = 2; model.ProvinceID = model.ProvinceID; model.CityID = model.CityID; model.CountyID = model.CountyID; model.EnterpriseID = LoginUser.UserBasic.EnterpriseID; returnData = shopBll.Create(model); return(Json(returnData)); }
public ActionResult DeleteList(string id) { Utility.ReturnData <string> returnData = new Utility.ReturnData <string>(); string[] ids = id.Substring(0, id.Length - 1).Split(','); UserPC model = new UserPC(); for (int i = 0; i < ids.Length; i++) { int j = Convert.ToInt32(ids[i]); ubBll.Delete(s => s.ID == j); model = bll.GetModelById(Convert.ToInt32(ids[i])); model.Status = 1; returnData = bll.UpdateUserPc(model); } if (returnData.Message == "编辑成功!") { return(Content("删除成功!")); } return(Content(returnData.Message)); }
public ActionResult Add(PcAndRole model) { Utility.ReturnData<string> returnData = new Utility.ReturnData<string>(); long count = bll.GetQueryCount(x => x.UserName == model.UserName && x.Status != 1); UserBasic ubModel = new UserBasic(); ubModel.NickName = model.UserName; ubModel.UserType = 1; ubModel.AddTime = DateTime.Now; ubModel.EnterpriseID = LoginUser.UserBasic.EnterpriseID; long id = ubBll.AddAndGetId(ubModel); UserPC upModel = new UserPC(); upModel.UserName = model.UserName; upModel.UserBasicID = id; upModel.RoleID = model.RoleID; upModel.PCType = 1; upModel.AddTime = DateTime.Now; upModel.PassWord = SimpleEncrypt.SaltMD5(model.PassWord.Replace(" ", "")); upModel.AddUserBasicID = LoginUser.UserBasicID; upModel.Status = 0; returnData = bll.AddUserPc(upModel); if (returnData.Status == false) { ubBll.Delete(s => s.ID == id); return Content(returnData.Message); } return Content(returnData.Message); }
public ActionResult DeleteList(string id) { Utility.ReturnData<string> returnData = new Utility.ReturnData<string>(); string[] ids = id.Substring(0, id.Length - 1).Split(','); UserPC model = new UserPC(); for (int i = 0; i < ids.Length; i++) { int j = Convert.ToInt32(ids[i]); ubBll.Delete(s => s.ID == j); model = bll.GetModelById(Convert.ToInt32(ids[i])); model.Status = 1; returnData = bll.UpdateUserPc(model); } if (returnData.Message == "编辑成功!") { return Content("删除成功!"); } return Content(returnData.Message); }
public ActionResult UpdateList(string id, int roleid) { Utility.ReturnData<string> returnData = new Utility.ReturnData<string>(); string[] ids = id.Substring(0, id.Length - 1).Split(','); UserPC model = new UserPC(); for (int i = 0; i < ids.Length; i++) { model = bll.GetModelById(Convert.ToInt32(ids[i])); model.RoleID = roleid; returnData = bll.UpdateUserPc(model); } if (returnData.Message == "编辑成功!") { return Content("关联成功!"); } return Content(returnData.Message); }
public ActionResult FirstLogin(string name, string pwd, string num) { ReturnData<string> ret = new ReturnData<string>(); AgentBll aBll = new AgentBll(); UserBasicBll uBll = new UserBasicBll(); UserPCBll pcBll = new UserPCBll(); Agent aModel = aBll.GetModelByPhone(num); UserBasic uModel = new UserBasic(); UserPC pcModel = new UserPC(); uModel.NickName = name; uModel.UserType = 1; uModel.EnterpriseID = aModel.EnterpriseID; uModel.AddTime = DateTime.Now; long id = uBll.AddAndGetId(uModel); pcModel.UserBasicID = id; pcModel.PassWord = SimpleEncrypt.SaltMD5(pwd.Replace(" ", "")); pcModel.PCType = 2; pcModel.RoleID = aModel.ID; pcModel.Status = 0; pcModel.UserName = name; pcModel.AddTime = DateTime.Now; pcModel.AddUserBasicID = 0; ret = pcBll.AddUserPc(pcModel); if (ret.Status == true) { aModel.Status = 0; aBll.EditAgent(aModel); return Content(ret.Message); } return Content(ret.Message); }
public ActionResult Update(UserPC model) { Utility.ReturnData<string> returnData = new Utility.ReturnData<string>(); UserPC ucModel = bll.GetModelById(model.UserBasicID); ucModel.RoleID = model.RoleID; ucModel.UserName = model.UserName; ucModel.AddTime = DateTime.Now; ucModel.AddUserBasicID = LoginUser.UserBasicID; returnData = bll.UpdateUserPc(ucModel); if (returnData.Message == "编辑成功!") { return Content(returnData.Message); } else { return Content(returnData.Message); } }