public bool Register(string username, string password, string email, string number) { bool result = false; using (SGEntities context = new SGEntities()) { try { User_statistics user_statistics = new User_statistics(); context.User_statistics.Add(user_statistics); User_info user_info = new User_info(email, number); context.User_info.Add(user_info); User user = new User(username, password); user.user_info = user_info.id; user.user_statistics = user_statistics.id; context.Users.Add(user); context.SaveChanges(); result = true; } catch (Exception) { } } return(result); }
// GET: User/Edit/5 public ActionResult Edit(int id) { var Info = new User_info(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.GetAsync("GetUser?id=" + id + ""); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <User_info>(); readTask.Wait(); Info = readTask.Result; Session["UserToEdit"] = Info; } } //use the session to capture the user for edit . then using the session in below just update the methods which needs update . then post in DB and call index which will refresh the list. ViewBag.SubmitValue = "Update"; //firstname = "test"; List <User_info> olist = (List <User_info>)Session["UserList"]; ViewData["oList"] = olist; ViewData["user"] = Info; return(View("Index")); }
public ActionResult SearchUser(string firstname) { ViewBag.SubmitValue = "Add"; List <User_info> oUserList = new List <User_info>(); List <User_info> SearchList = new List <User_info>(); oUserList = (List <User_info>)Session["UserList"]; foreach (User_info ouser in oUserList) { if (ouser.FirstName.Contains(firstname) || ouser.LastName.Contains(firstname)) { SearchList.Add(ouser); } } if (SearchList == null) { ModelState.AddModelError(string.Empty, "No user found with this name."); } User_info oTempUser = new User_info(); ViewData["user"] = oTempUser; ViewData["oList"] = SearchList; return(View("Index")); }
public MainWindowViewModel() { User = new User_info("ZZZZ", "18", "5.8", "65kg"); Phone = new Phone { DEVICE_NAME = "xxx", DEVICE_ID = "123456789" }; }
public IHttpActionResult PutUser_info(User_info user_info) { int id = user_info.User_ID; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user_info.User_ID) { return(BadRequest()); } db.Entry(user_info).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!User_infoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostUser_info(User_info user_info) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.User_info.Add(user_info); try { db.SaveChanges(); } catch (DbUpdateException) { if (User_infoExists(user_info.User_ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = user_info.User_ID }, user_info)); }
public void Delete(int id) { User_info user = this.context.User_info.SingleOrDefault(x => x.Id == id); this.context.User_info.Remove(user); this.context.SaveChanges(); }
public void Update(User_info user_info) { User_info user = this.context.User_info.SingleOrDefault(x => x.Id == user_info.Id); user.fullName = user_info.fullName; user.profilePicture = user_info.profilePicture; this.context.SaveChanges(); }
public bool create_player(string name, string hashed_password) { if (login_table.ContainsKey(name)) { return(false); } login_table[name] = new User_info(name, hashed_password); return(true); }
public IHttpActionResult GetUser_info(int id) { User_info user_info = db.User_info.Find(id); if (user_info == null) { return(NotFound()); } return(Ok(user_info)); }
public async Task <User_Info_Response> SaveAsync(User_info user_Info) { try{ await user_Info_Repository.AddAsync(user_Info); await unit_Of_Work.CompleteAsync(); return(new User_Info_Response(user_Info)); } catch (Exception ex) { return(new User_Info_Response($"Error while saving user info. Message:{ex.Message}")); } }
public ActionResult AddRegister(User_info user_info) { string pattern0 = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$'"; //密码验证 string pattern1 = "/ 0 ? (13 | 14 | 15 | 18)[0 - 9]{8}/"; //手机号码 string pattern2 = "/\\w[-\\w.+] *@@([A - Za - z0 - 9][-A - Za - z0 - 9] +\\.)+[A - Za - z]{ 2,14}/"; //邮箱 bool a = Regex.IsMatch(user_info.Password, pattern0); if (user_info.Password == null) { return(Json("密码不符合标准!", JsonRequestBehavior.AllowGet)); } if (user_info.PhoneNumber == null || Regex.IsMatch(user_info.PhoneNumber, pattern1)) { return(Json("手机号码不符合标准!", JsonRequestBehavior.AllowGet)); } if (user_info.Email == null || Regex.IsMatch(user_info.Email, pattern2)) { return(Json("邮箱不符合标准!", JsonRequestBehavior.AllowGet)); } if (db.User_info.Where(p => p.Email == user_info.Email).Count() != 1) { user_info.Password = GenerateMD5(user_info.Password); user_info.Date = DateTime.Now.ToString(); user_info.State = true; user_info.Role = "user"; try { db.User_info.Add(user_info); db.SaveChanges(); } catch (Exception) { return(Json("注册失败!", JsonRequestBehavior.AllowGet)); } //------------------可用来做邮箱验证使用--------------------------- //string key = GetRandomString(16, true, true, false, true, null); //Response.Cookies["test"].Value = key; //Response.Cookies["test"].Expires = DateTime.Now.AddMinutes(30); //SendEmail(user_info.Email,"邮箱激活!", "/User/yanzheng?info=" + key); //return Json("User/yanzheng?info="+ key, JsonRequestBehavior.AllowGet); //------------------可用来做邮箱验证使用end--------------------------- return(Json("注册成功!", JsonRequestBehavior.AllowGet)); } else { return(Json("账号已被注册!", JsonRequestBehavior.AllowGet)); } }
public IHttpActionResult DeleteUser_info(int id) { User_info user_info = db.User_info.Find(id); if (user_info == null) { return(NotFound()); } db.User_info.Remove(user_info); db.SaveChanges(); return(Ok(user_info)); }
public ActionResult UserStateHandle(User_info user) { try { User_info userDb = db.User_info.Where(p => p.ID == user.ID).FirstOrDefault(); userDb.State = user.State; db.SaveChanges(); } catch (Exception) { return(Json(false, JsonRequestBehavior.AllowGet)); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public ActionResult SortByEMPID() { ViewBag.SubmitValue = "Add"; List <User_info> oUserList = new List <User_info>(); oUserList = (List <User_info>)Session["UserList"]; User_info oTempUser = new User_info(); ViewData["user"] = oTempUser; ViewData["oList"] = oUserList.OrderBy(o => o.Employee_ID).ToList(); return(View("Index")); }
private User_info GetExamPagerModelByJuanZi(User_info juanZiGroup) { if (juanZiGroup == null) { return(null); } return(new User_info { Id = juanZiGroup.Id, UserID = juanZiGroup.UserID, User_Name = juanZiGroup.User_Name + 1, User_Pwd = juanZiGroup.User_Pwd + "测试" }); }
private void UpdateUser(User_info oUser) { oUser.Project = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP POST var postTask = client.PutAsJsonAsync <User_info>("PutUser", oUser); postTask.Wait(); var result = postTask.Result; } }
/// <summary> /// /// </summary> /// <returns></returns> private static IEnumerable <User_info> GetInsertDatas() { // 线程安全的list ConcurrentBag <User_info> datas = new ConcurrentBag <User_info>(); Parallel.For(0, 100000, (index, state) => { Random rand = new Random(); var newData = new User_info { UserID = rand.Next(1, 100).ToString(), User_Name = "batch", User_Pwd = "密码" + index.ToString() }; datas.Add(newData); }); return(datas); }
public ActionResult signUp(HttpPostedFileBase profilePicture) { if (Request.Form["signUP"] != null) { if (Request.Form["passtxt"] == Request.Form["rePasstxt"]) { User_info user = new User_info(); User_Authentication logged = new User_Authentication(); if (profilePicture != null && profilePicture.ContentLength > 0) { var filename = Path.GetFileName(profilePicture.FileName); var path = Path.Combine(Server.MapPath("~/images"), filename); profilePicture.SaveAs(path); user.userName = Request.Form["usernametxt"]; user.fullName = Request.Form["fullnametxt"]; user.email = Request.Form["emailtxt"]; user.Gender = Request.Form["genderSelect"]; user.DOB = Convert.ToDateTime(Request.Form["DOB"]); user.profilePicture = "~/images/" + filename.ToString(); logged.userName = Request.Form["usernametxt"]; logged.passWord = Request.Form["passtxt"]; users.Insert(user); logs.Insert(logged); return(RedirectToAction("Index")); } else { Session["signUpError"] = "Picture Is not Uploaded"; return(RedirectToAction("signUp")); } } else { Session["signUpError"] = "Passwords did not matched"; return(RedirectToAction("signUp")); } } return(RedirectToAction("Index", "Home")); }
public ActionResult LoginUser() { string username = string.Empty; if (Request.Cookies["username"] != null) { username = Server.HtmlEncode(Request.Cookies["userName"].Value); } else { return(RedirectToAction("Index", "login", new { ReturnCtrl = "supadmin", ReturnAction = "LoginUser" })); } DataSet ds = new DataSet(); StringBuilder str_sql = new StringBuilder(); str_sql.Append("EXEC USP_USER_SUM "); str_sql.Append("@fr_dt = N'2018-01-01',"); //.Append(usr_id).Append("',"); str_sql.Append("@to_dt = N'2018-05-31',"); //.Append(q_seq).Append("'"); str_sql.Append("@dept_cd = N'',"); str_sql.Append("@usr_id = N'").Append(username).Append("'"); ds = DbHelperSQL.Query(str_sql.ToString()); if (ds.Tables[0].Rows.Count > 0) { List <User_info> user_s = new List <User_info>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { User_info user_Info = new User_info(); user_Info.usr_id = ds.Tables[0].Rows[i]["usr_id"].ToString(); user_Info.dt_cnt = Convert.ToInt32(ds.Tables[0].Rows[i]["dt_cnt"].ToString()); user_Info.all_fen = Convert.ToInt32(ds.Tables[0].Rows[i]["all_fen"].ToString()); user_Info.pingjunfen = Convert.ToInt32(ds.Tables[0].Rows[i]["pingjun"].ToString()); user_Info.paihang = Convert.ToInt32(ds.Tables[0].Rows[i]["paihang"].ToString()); user_s.Add(user_Info); ViewData["user_s"] = user_s; } } return(View("Login")); }
public string AccountHandle() { string email = Session["UserEmail"].ToString(); if (email != null) { User_info user_Info = db.User_info.Where(p => p.Email == email).FirstOrDefault(); JavaScriptSerializer jss = new JavaScriptSerializer(); StringBuilder sb = new StringBuilder(); String json = jss.Serialize(user_Info).ToString(); return(json); } else { return(null); } }
public ActionResult Index() { if (Session["loggedOn"] != null) { int userId = Convert.ToInt32(Session["UserID"]); User_info user = users.GetSingle(userId); ViewBag.UserName = user.userName; ViewBag.FullName = user.fullName; ViewBag.Email = user.email; ViewBag.ProfilePicture = user.profilePicture; var date = user.DOB; ViewBag.DateOfBirth = date.ToString("ddd, MMM d, yyyy"); ViewBag.Gender = user.Gender; IEnumerable <User_Post> postList = posts.GetByUser(userId); List <BlogListModel> AllBlogList = new List <BlogListModel>(); foreach (User_Post up in postList) { BlogListModel blog = new BlogListModel(); blog.postID = up.Id; blog.postHeadline = up.postHeadline; blog.postContent = up.postContent; blog.postPicture = Url.Content(up.postPicture); blog.postDate = up.postDate; blog.postGivenUserID = up.userID; blog.postGivenUserName = users.GetSingle(up.userID).fullName; AllBlogList.Add(blog); } ViewBag.userName = Session["UserName"]; ViewBag.logged = Session["loggedOn"]; return(View(AllBlogList)); } else { return(View()); } }
private void oUser(string Userid, int ProjectID) { var Info = new User_info(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP GET var responseTask = client.GetAsync("GetUser?id=" + Userid + ""); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <User_info>(); readTask.Wait(); Info = readTask.Result; } } Info.Project_ID = ProjectID; Info.Task = null; //Call the Put Method string PostString = ""; using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); //HTTP POST var postTask = client.PutAsJsonAsync <User_info>("PutUser", Info); postTask.Wait(); var result = postTask.Result; PostString = result.StatusCode.ToString(); if (PostString.Contains("NoConte") == true) { PostString = "OK"; } } }
/// <summary> /// 通过Access_token和code获取userinfo /// </summary> /// <returns></returns> private static User_info GetUser_info() { string strUrl = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + AccessToken + "&code=" + Code; //string strUrl = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + AccessToken + "&code=9xn8L6r98AxEjpx7o3n794kU6rH4F5UiYZqnuqKnAuc"; User_info mode = new User_info(); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(strUrl); req.Method = "GET"; using (WebResponse wr = req.GetResponse()) { HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd();//在这里对 User_info 赋值 User_info user = new User_info(); user = JsonHelper.ParseFromJson <User_info>(content); mode.UserId = user.UserId; mode.DeviceId = user.DeviceId; } return(mode); }
public async Task <User_Info_Response> UpdateAsync(User_info user_Info) { var isExist = await user_Info_Repository.FindByIdAsync(user_Info.Id); if (isExist == null) { return(new User_Info_Response("User info not found!")); } try { user_Info_Repository.Update(user_Info); await unit_Of_Work.CompleteAsync(); return(new User_Info_Response(user_Info)); } catch (Exception ex) { return(new User_Info_Response($"Error when updating user info: {ex.Message}")); } }
public async Task <IActionResult> OnPost() { if (User.Email == null || User.Password == null) { return(Page()); } User user_entity = (from user in _db.User where user.Email == User.Email select user).FirstOrDefault(); if (user_entity == null) { Login_trouble = "Invalid Username"; return(RedirectToPage(new { Login_trouble })); } if (!Crypto.VerifyHashedPassword(user_entity.Password, User.Password)) { Login_trouble = "Invalid Password"; return(RedirectToPage(new { Login_trouble })); } if (user_entity.Active == false) { Login_trouble = "User disabled"; return(RedirectToPage(new { Login_trouble })); } else { var user_info = new User_info() { UserName = user_entity.Email, UserID = user_entity.Id, UserRole = user_entity.Role }; HttpContext.Session.SetString("SessionUser", JsonConvert.SerializeObject(user_info)); return(RedirectToPage("/Index")); } return(Page()); }
// GET: User public ActionResult Index() { Session["UserList"] = null; var UserInfo = new List <User_info>(); using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); //Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var responseTask = client.GetAsync("GetUsers"); responseTask.Wait(); //To store result of web api response. var result = responseTask.Result; //Checking the response is successful or not which is sent using HttpClient if (result.IsSuccessStatusCode) { //Storing the response details recieved from web api var Response = result.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Employee list UserInfo = JsonConvert.DeserializeObject <List <User_info> >(Response); ViewData["oList"] = UserInfo; User_info oTempUser = new User_info(); ViewData["user"] = oTempUser; Session["UserList"] = UserInfo; } } ViewBag.SubmitValue = "Add"; return(View(UserInfo)); }
public ActionResult LoginHandle(User_info user_Info) { string Email = user_Info.Email; string Password = GenerateMD5(user_Info.Password); JavaScriptSerializer serial = new JavaScriptSerializer(); if (db.User_info.Where(p => p.Email.Equals(Email) && p.Password.Equals(Password) && p.State == true).Count() == 1 ? true : false) { var userinfo = db.User_info.Where(p => p.Email.Equals(Email) && p.Password.Equals(Password) && p.State == true).Select(p => new { p.Name, p.Email, p.Role, p.ID }).FirstOrDefault(); Session["UserName"] = userinfo.Name; Session["UserEmail"] = userinfo.Email; Session["UserRole"] = userinfo.Role; Session["UserId"] = userinfo.ID; // FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( //1, //user_Info.Name, //DateTime.Now, //DateTime.Now.AddMinutes(30), //false, //serial.Serialize(userinfo) //); // //6. 加密 // string encryptedTicket = FormsAuthentication.Encrypt(authTicket); // //7. 响应到客户端 // System.Web.HttpCookie authCookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); // System.Web.HttpContext.Current.Response.Cookies.Add(authCookie); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public User_Info_Response(bool success, string message, User_info user_Info) : base(success, message) { this.user_Info = user_Info; }
public HttpResponseMessage LoginAuthen() // ByVal UserName As String, ByVal password As String : { // HttpResponseMessage // IHttpActionResult User_info user = new User_info(); Roles_info rolename = new Roles_info(); try { object Token_key = ""; Login login = new Login(); if (HttpContext.Current.Request.Form["UserName"].ToString() != null) { login.Username = HttpContext.Current.Request.Form["UserName"].ToString(); } if (HttpContext.Current.Request.Form["Password"].ToString() != null) { login.Password = HttpContext.Current.Request.Form["Password"].ToString(); } helpController result = new helpController(); //login.resultLogin = result.CheckLogin_XAF(login.Username, login.Password); //if (login.resultLogin != null) //{ // TokenController token = new TokenController(); // Token_key = token.Get(login.Username, login.Password); //} // XpoTypesInfoHelper.GetXpoTypeInfoSource(); user = result.CheckLogin_XAF(login.Username, login.Password); SqlParameter[] prm = new SqlParameter[9]; /// parameter นับได้เท่าไร ใส่เท่านั้น c# user.Description = "ระบบ login"; prm[0] = new SqlParameter("@Username", user.User_Name); ///แต่ array ต้องนับจาก 0 prm[1] = new SqlParameter("@DisplayName", user.DisplayName); prm[2] = new SqlParameter("@Organization", user.OrganizationNameTH); prm[3] = new SqlParameter("@Tel", user.Tel); prm[4] = new SqlParameter("@Email", user.Email); prm[5] = new SqlParameter("@LogID", "2"); prm[6] = new SqlParameter("@IPAddress", GetClientIp(Request)); prm[7] = new SqlParameter("@Description", user.Message); if (user.Status == 1) { user.Message = "เข้าสู่ระบบสำเร็จ"; prm[8] = new SqlParameter("@EventName", user.Description); SqlHelper.ExecuteNonQuery(scc, CommandType.StoredProcedure, "insert_EventLog", prm); return(Request.CreateResponse(HttpStatusCode.OK, user)); } else if (user.Status == 0 || user.Status == 6) { user.Message = "เข้าสู่ระบบไม่สำเร็จ"; prm[8] = new SqlParameter("@EventName", user.Description); SqlHelper.ExecuteNonQuery(scc, CommandType.StoredProcedure, "insert_EventLog", prm); return(Request.CreateResponse(HttpStatusCode.BadRequest, user)); } } catch (Exception ex) { //Error case เกิดข้อผิดพลาด user.Status = 6; user.Message = ex.Message; return(Request.CreateResponse(HttpStatusCode.BadRequest, user)); } finally { Dispose(); } return(Request.CreateResponse(HttpStatusCode.BadRequest, user)); }