public ResponseMessageWrap <int> Insert([FromBody] LoginLog loginLog) { return(new ResponseMessageWrap <int> { Body = LoginLogService.Insert(loginLog) }); }
/// <summary> /// 获取客户端当前登录状态是否失效 /// </summary> /// <param name="uCode"></param> /// <param name="token"></param> /// <returns></returns> public dynamic GetUserLoginStatus(string uCode, string token) { //******************************************************************************************* //延时 30 秒 返回结果 LoginLogService service = new LoginLogService(); for (int i = 0; i < 30; i++) { if (service.GetTokenByUCode(uCode).Equals(token)) { Thread.Sleep(1000 * 1); } else { return(new { Result = false, Msg = @"当前账户已在其他客户端登录!" }); } } return(new { Result = true }); }
// // POST: /LoginLog/Edit/5 public ActionResult Edit(string user_name, string logout_time) { logout_time = DateTime.Now.ToString(); bool bResult = LoginLogService.UpdateLoginLog(user_name, logout_time); return(Json(bResult, JsonRequestBehavior.AllowGet)); }
public ResponseMessageWrap <int> Update([FromBody] LoginLog loginLog) { return(new ResponseMessageWrap <int> { Body = LoginLogService.Update(loginLog) }); }
// post api/loginlogapi/postlist public HttpResponseMessage PostList([FromBody] Page page) { try { FileLog.WriteLog("InfoApiTime:" + DateTime.Now.ToString() + ",调用:Angel.ControllersApi/ControllerApi/LoginlogApiController/PostList()方法"); int pagenumber = page.offset;//从多少行开始查询 int pSize = page.pageSize; UtilFunction utf1 = new UtilFunction(); LoginLogService loginbll = new LoginLogService(); string total = loginbll.counttotal().ToString(); // 返回查询结果 List <Model.LoginLogModel> listmodel = loginbll.SelectLoginLOG(null, pagenumber, pSize); Dictionary <string, object> objectlist = new Dictionary <string, object>(); if (total == null) { objectlist.Add("total", 0); } else { objectlist.Add("total", total); } objectlist.Add("rows", listmodel); string listmsg = utf1.ToJson(objectlist); return(GetJSONMessage(listmsg)); } catch (Exception er) { FileLog.WriteLog("Error:调用Angel.ControllersApi/ControllerApi/LoginlogApiController/PostList()方法," + er.ToString()); return(GetJSONMessage("")); } }
public ResponseMessageWrap <int> DeleteById(long id) { return(new ResponseMessageWrap <int> { Body = LoginLogService.DeleteById(id) }); }
// // GET: /LoginLog/Details/5 public ActionResult Details(int page, int rows, FormCollection collection) { string userName = collection["UserName"] ?? ""; string systemName = collection["SystemName"] ?? ""; var users = LoginLogService.GetDetails(page, rows, userName, systemName); return(Json(users, "text", JsonRequestBehavior.AllowGet)); }
// // POST: /LoginLog/Create/ public ActionResult Create(string login_time, string user_name, string system_ID) { string localip = this.ControllerContext.HttpContext.Request.UserHostAddress; login_time = DateTime.Now.ToString(); bool bResult = LoginLogService.CreateLoginLog(login_time, user_name, Guid.Parse(system_ID), localip); return(Json(bResult, JsonRequestBehavior.AllowGet)); }
public ActionResult Emptys() { string strResult = string.Empty; bool bResult = false; bResult = LoginLogService.Emptys(out strResult); string msg = bResult ? "清空成功" : "清空失败"; return(Json(JsonMessageHelper.getJsonMessage(bResult, msg, strResult), "text", JsonRequestBehavior.AllowGet)); }
// // POST: /LoginLog/Delete/ public ActionResult Delete(string loginLogId) { string strResult = string.Empty; bool bResult = false; bResult = LoginLogService.Delete(loginLogId, out strResult); string msg = bResult ? "删除成功" : "删除失败"; return(Json(JsonMessageHelper.getJsonMessage(bResult, msg, strResult), "text", JsonRequestBehavior.AllowGet)); }
public AccountService(IOptions <JwtSettings> _jwtSettingsAccesser, ILoginInfo loginInfo, LoginLogService loginLogService, LoginLogRepository loginLogRepository, AccountRepository accountRepository, AccountRoleRepository accountRoleRepository, IMapper mapper) { _jwtSettings = _jwtSettingsAccesser.Value; _loginLogService = loginLogService; _loginLogRepository = loginLogRepository; _accountRepository = accountRepository; _accountRoleRepository = accountRoleRepository; _loginInfo = loginInfo; _mapper = mapper; }
// /LoginLog/CreateExcelToClient/ public FileStreamResult CreateExcelToClient() { int page = 0, rows = 0; string loginPC = Request.QueryString["loginPC"]; string loginTime = Request.QueryString["loginTime"]; string logoutTime = Request.QueryString["logoutTime"]; ExportParam ep = new ExportParam(); ep.DT1 = LoginLogService.GetLoginLog(page, rows, loginPC, loginTime, logoutTime); ep.HeadTitle1 = "登录日志信息"; return(PrintService.Print(ep)); }
private void AjaxLogin(string xname, string xpassword, HttpContext context) { try { var server = new MemberService(); string password = DESEncrypt.Encrypt(xpassword, xname); var member = server.FirstOrDefault(m => m.UserName == xname && m.Password == password && m.IsDelete == false); if (member != null) { if (member.IsUsing == false) { _response = "{\"result\" :\"" + 0 + "\",\"returnval\" :\"" + "用户已锁定,请联系管理员!" + "\"}"; return; } member.sys_MemberExtend.IsOnline = true; member.sys_MemberExtend.LastLoginIP = GetIP; member.sys_MemberExtend.LastLoginTime = DateTime.Now; var ipserver = new ForbidIpService(); var ipList = ipserver.Where(i => i.IsUsing && i.IsDelete == false).ToList().Select(q => q.IP); if (member.UserName != "admin" && ipList.Contains(member.sys_MemberExtend.LastLoginIP)) { _response = "{\"result\" :\"" + 0 + "\",\"returnval\" :\"" + "您的IP地址已锁定,请联系管理员!" + "\"}"; return; } CreateFormsAuthenticationTicket(context, member, false, DateTime.Now.AddMinutes(120)); server.SaveChanges(); var loginlogservice = new LoginLogService(); var loginlog = new sys_LoginLog { Uid = member.id, RealName = member.RealName, Ip = GetIP, Address = "", Mac = "", LoginTime = DateTime.Now }; loginlogservice.Add(loginlog); _response = "{\"result\" :\"" + 1 + "\",\"returnval\" :\"" + "登录成功,正在转到主页..." + "\"}"; } else _response = "{\"result\" :\"" + 0 + "\",\"returnval\" :\"" + "用户名或者密码不正确!" + "\"}"; } catch (Exception ex) { _response = "{\"result\" :\"" + 0 + "\",\"returnval\" :\"" + ex.Message + "\"}"; } }
public void login(object sender, EventArgs e) { if (UserService.doLogin(username.Value, password.Value)) { User user = UserService.getUserByUserName(username.Value); Session["username"] = username.Value; Session["password"] = password.Value; Session["id"] = user.id; Session["privilege"] = user.privilege; LoginLog login_log = new LoginLog(); login_log.user_id = user.id; login_log.ip = Request.UserHostAddress; login_log.time = DateTime.Now; LoginLogService.insert(login_log); Response.Redirect("Index.aspx"); } else { msg = "alert('用户名或者密码错误')"; } }
/// <summary> /// 通过时间段查询所有的登录日志信息 /// </summary> /// <param name="beginTime"></param> /// <param name="endTime"></param> /// <returns></returns> public static IList <LoginLog> GetAllLoginLogsByTime(string beginTime, string endTime) { return(LoginLogService.GetAllLoginLogsByTime(beginTime, endTime)); }
public AccountController(UserService userService, LoginLogService loginLogService) { _userService = userService; _loginLogService = loginLogService; }
public LoginLogController(LoginLogService service) { _service = service; }
// post api/loginapi/postLogin /// <summary> /// 用户登录 /// </summary> /// <param name="value">实体信息</param> /// <returns></returns> public HttpResponseMessage postLogin([FromBody] UserInfos value) { IEnumerable <KeyValuePair <string, string> > list = ControllerContext.Request.GetQueryNameValuePairs(); JObject obj = new JObject(); try { FileLog.WriteLog("InfoApiTime:" + DateTime.Now.ToString() + ",调用:Angel.ControllersApi/ControllerAPI/LoginApiController/Get()方法"); string mycode = value.mycode; string username = value.username; obj.Add("username", value.username); obj.Add("password", value.password); obj.Add("mycode", value.mycode); obj.Add("url", value.url); // 1. 验证码检查 string a = HttpContext.Current.Session["checkcode"].ToString(); if (HttpContext.Current.Session["checkcode"] == null) { return(GetJSONMessage("{\"code\":{\"id\":2,\"msg\":\"验证码错误\"}}")); } if (mycode == "" || mycode == null) { return(GetJSONMessage("{\"code\":{\"id\":2,\"msg\":\"输入验证码错误\"}}")); } string b = mycode.ToUpper(); if (String.Compare(a, b, true) != 0) { return(GetJSONMessage("{\"code\":{\"id\":2,\"msg\":\"验证码错误\"}}")); } string msg = QueryService.GetDataBefor(obj, "1_6"); if (msg.IndexOf("成功") != -1) { JObject model = JObject.FromObject(JsonConvert.DeserializeObject(msg)); JToken UserId = model["user"][0]["id"]; JToken UserName = model["user"][0]["username"]; JToken CityId = model["user"][0]["cityid"]; JToken RoleId = model["role"][0]["roleid"]; JToken RoleName = model["role"][0]["rolename"]; JToken Level = model["role"][0]["level"]; int Rid = Convert.ToInt32(RoleId.ToString()); int Uid = int.Parse(UserId.ToString()); string UName = UserName.ToString(); UtilFunction.WriteCookie("uid", Uid.ToString(), 14400); // 用户ID UtilFunction.WriteCookie("roleid", Rid.ToString(), 14400); //角色ID UtilFunction.WriteCookie("rolename", HttpUtility.UrlEncode(RoleName.ToString()), 14400); //角色名字 UtilFunction.WriteCookie("uname", UName, 14400); //用户名字 UtilFunction.WriteCookie("cityid", HttpUtility.UrlEncode(CityId.ToString()), 14400); //城市id UtilFunction.WriteCookie("level", Level.ToString(), 14400); //级别ID LoginLogService loginbll = new LoginLogService(); string clientip = UtilFunction.GetIPAddress(); loginbll.SaveLog(Uid, UName, Rid, RoleName.ToString(), clientip, UName); } return(GetJSONMessage(msg)); } catch (Exception er) { FileLog.WriteLog("Error:调用Angel.ControllersApi/ControllerAPI/LoginApiController/Get()方法," + er.ToString()); return(GetJSONMessage("")); } }
public LoginLogController(LoginLogService loginLogService) { _loginLogService = loginLogService; }
public LoginLogController(LoginLogService loginLogService, ILoginLogRepository loginLogRepository) { LoginLogService = loginLogService; LoginLogRepository = loginLogRepository; }
/// <summary> /// 通过Id删除登陆日志信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static int DeleteLoginLogById(int id) { return(LoginLogService.DeleteLoginLogById(id)); }