public JObject AdminLogion(JObject json) { try { JObject ret = new JObject(); ret = logionService.GetVerificationLogion(json); if (ret["result"] != null && Convert.ToBoolean(ret["result"].ToString())) { CurrentLogin loginContent = (CurrentLogin)HttpContext.Current.Session["CurrentLogin"]; var tokenResult = WebApiHelper.GetSignToken(loginContent.User_Id); //获取token loginContent.token = tokenResult.Result; //放入token HttpContext.Current.Session["CurrentLogin"] = loginContent; //获取到tokenId重新放进去 if (tokenResult.StatusCode == (int)StatusCodeEnum.Success) //token找到成功 { ret["result"] = JToken.FromObject(true); loginContent.PassWord = "";//密码置空前端安全性 ret.Add("User", JToken.FromObject(loginContent)); } } return(ret); } catch (Exception ex) { throw new Exception(ex.Message); } }
// GET: Operador public ActionResult Index(int?id) { if (Session["cLogin"] == null) { return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole != 1 && cLogin.idRole != 2) { return(RedirectToAction("Index", "Bitacora")); } } CurrentLogin cLogin2 = (CurrentLogin)Session["cLogin"]; User usuarioss = db.Users.Find(cLogin2.idUser); ViewBag.Nombre = usuarioss.Nombre + " " + usuarioss.Apellidos; if (usuarioss == null) { return(HttpNotFound()); } return(View(usuarioss)); }
//Eliminar public ActionResult Delete(int?id) { if (Session["cLogin"] == null) { return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole != 1 && cLogin.idRole != 2) { return(RedirectToAction("Index", "Bitacora")); } } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Bitacora bitac = db.Bitacoras.Find(id); if (bitac == null) { return(HttpNotFound()); } return(View(bitac)); }
public ActionResult Create([Bind(Include = "Estado")] User usuario) { if (Session["cLogin"] == null) { return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole != 1 && cLogin.idRole != 2) { return(RedirectToAction("Index", "Bitacora")); } } CurrentLogin cLogin2 = (CurrentLogin)Session["cLogin"]; User usuarioss = db.Users.Find(cLogin2.idUser); if (usuarioss == null) { return(HttpNotFound()); } else { db.Entry(usuarioss).State = EntityState.Modified; usuarioss.Estado = "En Servicio"; db.SaveChanges(); } return(View()); }
public ActionResult Edit(int?id) { if (Session["cLogin"] == null) { return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole != 1) { return(RedirectToAction("Index", "Operador")); } } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User user = db.Users.Find(id); if (user == null) { return(HttpNotFound()); } return(View(user)); }
public override void OnActionExecuting(HttpActionContext actionContext) { ResultMsg resultMsg = null; var request = actionContext.Request; string method = request.Method.Method; string staffId = string.Empty, tokenId = string.Empty; DateTime expireTime = DateTime.MaxValue; if (request.Headers.Contains("staffid")) { staffId = HttpUtility.UrlDecode(request.Headers.GetValues("staffid").FirstOrDefault()); } if (request.Headers.Contains("TokenId")) { tokenId = HttpUtility.UrlDecode(request.Headers.GetValues("TokenId").FirstOrDefault()); } if (request.Headers.Contains("ExpireTime") && DateTime.TryParse(request.Headers.GetValues("ExpireTime").FirstOrDefault().ToString().Replace('T', ' ').Split('.')[0], out expireTime)) { ; } //GetToken方法不需要进行签名验证 if (actionContext.ActionDescriptor.ActionName == "GetToken") { if (string.IsNullOrEmpty(staffId) || string.IsNullOrEmpty(tokenId)) { resultMsg = new ResultMsg(); resultMsg.StatusCode = 1111; resultMsg.Info = "答案是错误的"; resultMsg.Data = null; //actionContext.Response = HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)); base.OnActionExecuting(actionContext); return; } else { base.OnActionExecuting(actionContext); return; } } CurrentLogin _current = (CurrentLogin)HttpContext.Current.Session["CurrentLogin"]; if (_current == null || _current.token.TokenId != tokenId || expireTime < DateTime.Now) { resultMsg = new ResultMsg(); resultMsg.StatusCode = (int)StatusCodeEnum.Error; resultMsg.Info = "Token验证不通过"; resultMsg.Data = ""; //验证不通过跳转到登录页面 actionContext.Response = HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)); return; } else { base.OnActionExecuting(actionContext); } }
/// <summary> /// 获取用户登录信息 /// </summary> /// <param name="json"></param> /// <returns></returns> public JObject GetVerificationLogion(JObject json) { repository = new RepositoryBase(DBFactory.oas); T_Pub_User t_pub_user = (T_Pub_User)JsonConvert.DeserializeObject(json.ToString(), typeof(T_Pub_User)); T_Pub_User user = repository.FindEntity <T_Pub_User>(a => a.User_ID == t_pub_user.User_ID); JObject result = new JObject(); if (user != null) { if (user.IsAvailab == 1) { string dbPassword = Md5.EncryptString(t_pub_user.User_PWD); if (dbPassword == user.User_PWD) { //数据库对象 //Admin_Sys_Login _login = new Admin_Sys_Login(); //_login.LoginId = new Guid().ToString(); //_login.LoginIp = Common.GetHostAddress(); //_login.LoginTime = DateTime.Now; //_login.UserName = _adminUser.UserName; //_login.Message = "登录成功"; CurrentLogin _currentLogin = new CurrentLogin(); _currentLogin.LoginIp = Common.GetHostAddress(); _currentLogin.LoginIpInt = Common.IpToInt(_currentLogin.LoginIp); _currentLogin.UserName = user.User_Name; _currentLogin.User_Id = user.User_ID; _currentLogin.User_Code = user.User_Code; _currentLogin.PassWord = user.User_PWD; _currentLogin.LoginTime = DateTime.Now; _currentLogin.Message = "登录成功"; var cont = System.Web.HttpContext.Current; cont.Session["CurrentLogin"] = _currentLogin; System.Web.HttpContext.Current.Session.Timeout = 720;//登录缓存720分钟过期 var dd = System.Web.HttpContext.Current.Session["CurrentLogin"] ?? new CurrentLogin(); result.Add(ResultInfo.Result, JToken.FromObject(true)); result.Add(ResultInfo.Content, JToken.FromObject(_currentLogin.Message)); } else { result.Add(ResultInfo.Result, JToken.FromObject(false)); result.Add(ResultInfo.Content, JToken.FromObject("密码错误,请重新尝试!")); } } else { result.Add(ResultInfo.Result, JToken.FromObject(false)); result.Add(ResultInfo.Content, JToken.FromObject("密码被禁用,请联系管理员!")); } } else { result.Add(ResultInfo.Result, JToken.FromObject(false)); result.Add(ResultInfo.Content, JToken.FromObject("账户不存在,请联系管理员!")); } return(result); }
public ActionResult Create([Bind(Include = "Id_Bitacora,idUser,Fecha,Compañia,Marca,Tipo,Año,Placas,Color,Serie,FechaContacto,Testigo")] Bitacora bitacora) { if (ModelState.IsValid) { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; bitacora.Fecha = DateTime.Now; bitacora.idUser = cLogin.idUser; db.Bitacoras.Add(bitacora); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bitacora)); }
public ActionResult Create2() { if (Session["cLogin"] == null) { return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole != 1) { return(RedirectToAction("Index", "Operador")); } } return(View()); }
public ActionResult Index() { if (Session["cLogin"] == null) { //return RedirectToAction("Login", "Users"); return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole != 1 && cLogin.idRole != 2) { return(RedirectToAction("Index", "Home")); } } return(View()); }
public ActionResult Disponibilidad() { if (Session["cLogin"] == null) { return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole == 2) { return(RedirectToAction("Index", "Operador")); } } List <User> ListUser = new List <User>(); CurrentLogin cLogin2 = (CurrentLogin)Session["cLogin"]; ListUser = db.Users.Where(x => x.idRole == 2).ToList(); Response.AddHeader("Refresh", "15");//Refresh pagina cada 15seg. return(View(ListUser)); }
public ActionResult SearchUser(string username, string password) { var user = db.Users.Where(x => x.UserName == username && x.Password == password).FirstOrDefault(); if (user != null) { CurrentLogin cLogin = new CurrentLogin(); cLogin.idUser = user.idUser; cLogin.UserName = user.UserName; cLogin.idRole = user.idRole.GetValueOrDefault(); System.Web.HttpContext.Current.Session["cLogin"] = cLogin; CurrentLogin cLg = (CurrentLogin)Session["cLogin"]; return(RedirectToAction("Disponibilidad", "Operador")); } else { TempData["msg"] = "<script>alert('Nombre de usuario y/o contraseña incorrectos');</script>"; return(RedirectToAction("Login", "Users")); } }
/// <summary> /// 获取导航菜单列表 /// </summary> /// <param name="menuId">默认状态0</param> /// <param name="currentUser">用户信息</param> /// <returns></returns> public ConcurrentDictionary <string, string> GetClientsDataJson(int menuId, CurrentLogin currentUser) { //SqlParameter[] prams = new SqlParameter[3]; //prams[0] = new SqlParameter("@MODULE_ID", 0001); //prams[1] = new SqlParameter("@USERID", currentUser.UserName); //prams[2] = new SqlParameter("@SysFlag", "GLXT"); //var ss = DBFactory.oas; using (oasEntities entity = new oasEntities()) { var list = entity.UP_GetUserMenu("0001", currentUser.User_Id, "GLXT").ToList(); var menuList = new List <MenuModel>(); foreach (var item in list.Where(it => it.ParentID == menuId)) { var menuModel = new MenuModel(); menuModel.Id = item.MenuID; menuModel.Name = item.MenuName; menuModel.SortCode = (int)item.SortID; menuModel.ChildNodes = list.Where(c => c.ParentID == item.MenuID) .Select( c => new ChildNodes { Id = c.MenuID, Name = c.MenuName, UrlAddress = c.Url, SortCode = (int)c.SortID }) .OrderBy(c => c.SortCode).ToList(); menuList.Add(menuModel); } menuList = menuList.OrderBy(c => c.SortCode).ToList(); var info = new ConcurrentDictionary <string, string>(); info.TryAdd("authorizeMenu", menuList.ToJson()); return(info); } }
public ActionResult Edit(int?id) { if (Session["cLogin"] == null) { return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole == 2) { return(RedirectToAction("Index", "Operador")); } } CurrentLogin cLogin2 = (CurrentLogin)Session["cLogin"]; User usuarioss = db.Users.Find(cLogin2.idUser); if (usuarioss == null) { return(HttpNotFound()); } return(View(usuarioss)); }
public JObject GetProcessList(JObject json) { json = json ?? new JObject(); Pagination page = json["Pagination"] == null?Pagination.GetDefaultPagination("GoodNo") : JsonConvert.DeserializeObject <Pagination>(json["Pagination"].ToString()); if (json["Param"]["SelectType"].ToString() == "good") { vw_MallGoodMainInfo goodInfo = JsonConvert.DeserializeObject <vw_MallGoodMainInfo>((json["Param"] ?? "").ToString()); return(service.GetGoodList(goodInfo, null, null, page));//获取商品信息 } else if (json["Param"]["SelectType"].ToString() == "order") { //思路:开发待处理视图。 //1.根据当前账号获取账号所有的权限(角色)。 //2.根据当前角色找到对应的虚拟账号。 //3.到最后取待处理的视图时候就是 Receiver in (‘虚拟账号1’,‘虚拟账号2 ’) v_framework_notify OrderInfo = JsonConvert.DeserializeObject <v_framework_notify>((json["Param"] ?? "").ToString()); CurrentLogin loginContent = (CurrentLogin)HttpContext.Current.Session["CurrentLogin"]; //获取处理人集合 string GetReceiverApi = AppSettingsConfig.GetBaseApi + "/api/Flow/GetReceivers"; Dictionary <string, string> parames = new Dictionary <string, string>(); parames.Add("userId", loginContent.User_Id); Tuple <string, string> parameters = WebApiHelper.GetQueryString(parames); var result = WebApiHelper.Get <dynamic>(GetReceiverApi, parameters.Item1, parameters.Item2, loginContent.User_Id); //拼接处理人的,in条件。(后续功能扩充,如果除了需要把公共账号相关表单带出来,还需要当前登录人带出来,就从session里面取UserID加到in的条件userStr里面。) string userStr = string.Empty; if ((bool)result["result"]) { List <dynamic> receives = JsonConvert.DeserializeObject <List <dynamic> >(result["content"].ToString()); foreach (var item in receives) { userStr += "," + item.ROLESERIAL; } } //把自身权限加入 userStr = userStr + "," + loginContent.User_Id; JObject ret = new JObject(); Expression <Func <v_framework_notify, bool> > expression = PredicateExtensions.True <v_framework_notify>(); if (OrderInfo != null) { if (!string.IsNullOrEmpty(OrderInfo.OrderNo)) { expression = expression.And(c => c.OrderNo.Contains(OrderInfo.OrderNo)); } if (!string.IsNullOrEmpty(OrderInfo.CURSTATUS_NAME)) { expression = expression.And(c => c.OrderNo.Contains(OrderInfo.CURSTATUS_NAME)); } if (!string.IsNullOrEmpty(OrderInfo.WFM_ID)) { expression = expression.And(c => c.WFM_ID.Contains(OrderInfo.WFM_ID)); } if (OrderInfo.Flow_ID > 0) { expression = expression.And(c => c.Flow_ID == OrderInfo.Flow_ID); } if (OrderInfo.CURSTATUS_ID > 0) { expression = expression.And(c => c.CURSTATUS_ID == OrderInfo.CURSTATUS_ID); } expression = expression.And(c => userStr.Contains(c.Receiver) && !c.IsWaster_ && c.IsFinish != 1); } //查询列表数据 ret = processService.GetList(expression, page); if ((bool)ret["result"]) { List <v_framework_notify> result_notify = JsonConvert.DeserializeObject <List <v_framework_notify> >(ret["content"].ToString()); foreach (var item in result_notify) { vw_MallGoodMainInfo good = service.FindList(c => c.GoodNo == item.GoodNo).FirstOrDefault(); item.GoodTitle = (good == null?"":good.GoodTitle); item.GameName = (good == null ? "" : good.GameName); item.GoodTypeName = (good == null ? "" : good.GoodTypeName); item.GoodKeyWord = (good == null ? "" : good.GoodKeyWord); } //插入进去。 ret["content"] = JToken.FromObject(result_notify); } return(ret); } else { return(null); } }
public ActionResult Index(Bitacora bitacora, [Bind(Include = "Estado")] User usuario, string searching, string opcion) { if (Session["cLogin"] == null) { return(RedirectToAction("Login", "Users")); } else { CurrentLogin cLogin = (CurrentLogin)Session["cLogin"]; if (cLogin.idRole != 1 && cLogin.idRole != 2) { return(RedirectToAction("Index", "Bitacora")); } } CurrentLogin cLogin2 = (CurrentLogin)Session["cLogin"]; User usuarioss = db.Users.Find(cLogin2.idUser); if (usuarioss == null) { return(HttpNotFound()); } else { db.Entry(usuarioss).State = EntityState.Modified; usuarioss.Estado = "Disponible"; db.SaveChanges(); } // Despliga todo los datos de la bitacora al admin if (cLogin2.idRole == 1) { if (opcion == "ID Bitacora") { try { int Id = Convert.ToInt32(searching); return(View(db.Bitacoras.Where(x => x.Id_Bitacora == Id || searching == null).ToList())); } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "ID Usuario") { try { int Id = Convert.ToInt32(searching); return(View(db.Bitacoras.Where(x => x.idUser == Id || searching == null).ToList())); } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "Compañia") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.ToList())); } else { return(View(db.Bitacoras.Where(x => x.Compañia == searching).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "Marca") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.ToList())); } else { return(View(db.Bitacoras.Where(x => x.Marca == searching).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "Tipo") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.ToList())); } else { return(View(db.Bitacoras.Where(x => x.Tipo == searching).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "Año") { try { int Id = Convert.ToInt32(searching); if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.ToList())); } else { return(View(db.Bitacoras.Where(x => x.Año == Id).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "Placas") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.ToList())); } else { return(View(db.Bitacoras.Where(x => x.Placas == searching).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "Color") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.ToList())); } else { return(View(db.Bitacoras.Where(x => x.Color == searching).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "Serie") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.ToList())); } else { return(View(db.Bitacoras.Where(x => x.Serie == searching).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else if (opcion == "Testigo") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.ToList())); } else { return(View(db.Bitacoras.Where(x => x.Testigo == searching).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.ToList())); } } else { return(View(db.Bitacoras.ToList())); } } // Despliega los datos de los operadores else { if (opcion == "ID Bitacora") { try { int Id = Convert.ToInt32(searching); return(View(db.Bitacoras.Where(x => x.Id_Bitacora == Id && x.idUser == cLogin2.idUser || searching == null).ToList())); } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "ID Usuario") { try { int Id = Convert.ToInt32(searching); return(View(db.Bitacoras.Where(x => x.idUser == Id && x.idUser == cLogin2.idUser || searching == null).ToList())); } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "Compañia") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } else { return(View(db.Bitacoras.Where(x => x.Compañia == searching && x.idUser == cLogin2.idUser).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "Marca") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } else { return(View(db.Bitacoras.Where(x => x.Marca == searching && x.idUser == cLogin2.idUser).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "Tipo") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } else { return(View(db.Bitacoras.Where(x => x.Tipo == searching && x.idUser == cLogin2.idUser).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "Año") { try { int Id = Convert.ToInt32(searching); if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } else { return(View(db.Bitacoras.Where(x => x.Año == Id && x.idUser == cLogin2.idUser).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "Placas") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } else { return(View(db.Bitacoras.Where(x => x.Placas == searching && x.idUser == cLogin2.idUser).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "Color") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } else { return(View(db.Bitacoras.Where(x => x.Color == searching && x.idUser == cLogin2.idUser).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "Serie") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } else { return(View(db.Bitacoras.Where(x => x.Serie == searching && x.idUser == cLogin2.idUser).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else if (opcion == "Testigo") { try { if (String.IsNullOrEmpty((searching))) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } else { return(View(db.Bitacoras.Where(x => x.Testigo == searching && x.idUser == cLogin2.idUser).ToList())); } } catch (FormatException) { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } else { return(View(db.Bitacoras.Where(x => x.idUser == cLogin2.idUser).ToList())); } } }