public List <UserInfoItem> GetAllData() { List <UserInfoItem> LItem = new List <UserInfoItem>(); try { StreamReader sr = new StreamReader(HostingEnvironment.MapPath(ConfigurationManager.AppSettings["LOG_PATH"])); while (!sr.EndOfStream) { UserInfoItem oItem = new UserInfoItem(); string i = sr.ReadLine(); string[] splitetext = i.Split(','); oItem.FirstName = splitetext[0]; oItem.LastName = splitetext[1]; oItem.FatherName = splitetext[2]; oItem.NCode = splitetext[3]; oItem.Address = splitetext[4]; oItem.Tell = splitetext[5]; oItem.Email = splitetext[6]; oItem.Major = splitetext[7]; oItem.Education = splitetext[8]; oItem.Birthday = splitetext[9]; oItem.Gender = splitetext[10]; oItem.Extention = splitetext[11]; LItem.Add(oItem); } sr.Close(); } catch { } return(LItem); }
public async Task <IActionResult> PutUserInfoItem(Guid id, UserInfoItem userInfoItem) { if (id != userInfoItem.Id) { return(BadRequest()); } _context.Entry(userInfoItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserInfoItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async void ChangeUserInfo(UserInfoItem userInfoItem) { var filter = Builders <BsonDocument> .Filter.Eq("userId", userInfoItem.UserId); var collection = Db.GetCollection <BsonDocument>("UsersInfo"); await collection.ReplaceOneAsync(filter, userInfoItem.ToBsonDocument()); }
public JsonResult ChangeUser([FromBody] UserInfoItem userInfoItem) { if (userInfoItem != null) { var filter = Builders <UserInfoItem> .Filter.Eq("userId", userInfoItem.UserId); var userInfo = _databaseService.GetItemsByFilter("UsersInfo", filter); if (userInfo == null) { try { _databaseService.Add("UsersInfo", userInfoItem); } catch (Exception e) { return(new JsonResult(new { message = "Ошибка при добавлении информации о пользователе!" + " Попробуйте позже", status = 502 })); } return(new JsonResult(new { message = "Информация успешно добавлена", status = 200 })); } else { try { _databaseService.ChangeUserInfo(userInfoItem); } catch (Exception e) { return(new JsonResult(new { message = "Ошибка при изменении информации о пользователе! " + "Попробуйте позже", status = 502 })); } return(new JsonResult(new { message = "Информация успешно изменена", status = 200 })); } } return(new JsonResult(new { status = 404 })); }
public void SetMenberList(List <User> userList) { this.memberList = userList; for (int i = 0; i < userList.Count; i++) { var userItem = userList[i]; this.SP_MenberList.Children.Add(UserInfoItem.GotyeUserToUserInfoItem(userItem)); } }
protected void btnEnter_Click(object sender, EventArgs e) { if (username.Text == "admin" && password.Text == "admin") { Session["loggedin"] = true; Session["IsAdmin"] = true; Response.Redirect("Default.aspx"); } else { string j = username.Text; string k = password.Text; UserInfoLogic objUserInfo = new UserInfoLogic(); UserInfoItem n = objUserInfo.GetUserInfoByEmailAndNCode(j, k); //if (n.IsFill == true) if (string.IsNullOrEmpty(n.FirstName) == false) { Session["loggedin"] = true; Session["IsAdmin"] = false; Session["nam"] = n.FirstName; Session["lastnam"] = n.LastName; Session["imagecode"] = n.NCode; Session["pasvandpic"] = n.Extention; Response.Redirect("Default.aspx"); } else { //نام کاربری یا کلمه عبور صحیح نیست //لطفا دوباره تلاش کنید } // StreamReader sr = new StreamReader(Server.MapPath(ConfigurationManager.AppSettings["LOG_PATH"])); // while (!sr.EndOfStream) // { // string i = sr.ReadLine(); // if (i.IndexOf(username.Text) >= 0 && i.IndexOf(password.Text)>=0) // { // Session["loggedin"] = true; // Session["IsAdmin"] = false; // string[] splitetext = i.Split(','); // Session["nam"] = splitetext[0]; // Session["lastnam"] = splitetext[1]; // Session["imagecode"] = splitetext[3]; // Session["pasvandpic"] = splitetext[11]; // Response.Redirect("Default.aspx"); // } // else // { // Session["loggedin"] = false; // lbl_show.Text = "enter correct username and password"; // } // } // sr.Close(); } }
public void UserInfoItemInsertOne(UserInfoItem userInfoItem) { IList <iBatisStatement> il = new List <iBatisStatement>(); il.Add(new iBatisStatement { StatementName = "UserInfoItem.insert_UserInfoItem", ParameterObject = userInfoItem, Type = SqlExecuteType.INSERT }); BuilderFactory.Default().ExecuteBatch(il); //SqlAdapter.ExecuteBatch(il); }
protected void Page_Load(object sender, EventArgs e) { //if (Session["loggedin"] == null) //{ // Response.Redirect("pagelogin.aspx"); //} //else //{ string searchm = Request.QueryString["meli"]; if (string.IsNullOrEmpty(searchm)) { Response.Redirect("~/searchpage.aspx"); } else { //StreamReader sr = new StreamReader(Server.MapPath(ConfigurationManager.AppSettings["LOG_PATH"])); //while (!sr.EndOfStream) //{ // string i = sr.ReadLine(); // if (i.IndexOf(searchm) >= 0) // { // string[] splitetext = i.Split(','); // txt_name2.Text = splitetext[0]; // txt_lastname2.Text = splitetext[1]; // txt_codemeli2.Text = splitetext[2]; // txt_father.Text = splitetext[3]; // tex_mail2.Text = splitetext[4]; // txt_reshte2.Text = splitetext[5]; // txt_madrak2.Text = splitetext[6]; // imageperson.ImageUrl = ConfigurationManager.AppSettings["PHOTO_UPLOAD_PATH"] + searchm + ".jpg"; // } //} //sr.Close(); //بجای استفاده از کد های بالا ،حالا می خواهیم از کلاس استفاده نماییم UserInfoLogic objUserInfo = new UserInfoLogic(); UserInfoItem z = objUserInfo.GetUserInfoByNCode(searchm); if (z.IsFill == true) { txt_name2.Text = z.FirstName; txt_lastname2.Text = z.LastName; txt_codemeli2.Text = z.NCode; txt_father.Text = z.FatherName; tex_mail2.Text = z.Email; txt_reshte2.Text = z.Major; txt_madrak2.Text = z.Education; imageperson.ImageUrl = ConfigurationManager.AppSettings["PHOTO_UPLOAD_PATH"] + z.NCode + z.Extention; } } //} }
protected void gvPerson2_SelectedIndexChanged(object sender, EventArgs e) { string x = gvPerson2.SelectedValue.ToString(); UserInfoLogic usersList = new UserInfoLogic(); List <UserInfoItem> AllUsers = new List <UserInfoItem>(); UserInfoItem y = usersList.GetUserInfoByNCode(x); AllUsers.Add(y); FV2.DataSource = AllUsers; FV2.DataBind(); }
public static int GetRemainedDays(UserInfoItem userInfo, HomeworkItem homework, ScheduleItem schedule) { int currentWeek = Utils.GetCurrentWeek(userInfo.StartDate); SubjectCoords coords = GetSubjectCoords(homework, schedule); int days = 0; int today = (Convert.ToInt32(DateTime.Now.DayOfWeek) + 6) % 7; days = (homework.Week - currentWeek) * 7 + (coords.DayOfWeek - today); return(days); }
//Post request to Web Api with the given user credentials public async void SendUserLogin(String[] userCredentials, long sessionId, Guid guid) { HttpClient client = new HttpClient(); Console.WriteLine("Main project GUID -> " + guid); var postUser = new UserInfoItem { Id = guid, Usermail = userCredentials[0], Userpassword = userCredentials[1] }; var postResponse = await client.PostAsJsonAsync("https://localhost:44316/api/UserInfoItems", postUser); postResponse.EnsureSuccessStatusCode(); }
private void SetFriendItemAction(object sender, System.Timers.ElapsedEventArgs e) { for (int i = 0; i < friendList.Count; i++) { Thread.Sleep(100); this.Dispatcher.Invoke(DispatcherPriority.Send, new Action( delegate { var item = UserInfoItem.GotyeUserToUserInfoItem(friendList[i]); this.SL_FriendList.AddItem(item); })); } }
private void AddUserSessions(UserInfoItem userInfoItem) { String connection = "Server=DESKTOP-II1M7LK;Database=AccountDb;Trusted_Connection=True;MultipleActiveResultSets=true"; using (SqlConnection sqlconn = new SqlConnection(connection)) { DateTime thisDay = DateTime.Now; //Date format is 30/3/2020 12:00 AM string sqlQuerySession = "insert into AccountSessions(UserId, SessionID, LoginDate) values ('" + userInfoItem.UserID + "', '" + userInfoItem.Id + "', '" + thisDay + "' )"; using (SqlCommand sqlcommCookie = new SqlCommand(sqlQuerySession, sqlconn)) { sqlconn.Open(); sqlcommCookie.ExecuteNonQuery(); } } }
// 创建用户 public async Task CreateAsync(IdentityModel user) { UserInfo empBL = new UserInfo(); UserInfoItem model = new UserInfoItem(); model.UserName = user.LogonName; model.LogonName = user.UserName; model.Password = user.PasswordHash; model.StrStatus = user.StrStatus; model.RoleId = user.RoleId; model.UserCompanyValue = user.UserCompangValue; model.UserGasStationValue = user.UserGasStationValue; model.DomainAccount = user.DomainAccount; model.EmailAddress = user.EmailAddress; model.UserGasStationName = user.UserGasStationName; model.CreatedBy = user.CreateBy; await Task.Run(() => empBL.Create(model)); }
public async Task <ActionResult <UserInfoItem> > PostUserInfoItem(UserInfoItem userInfoItem) { String connection = "Server=DESKTOP-II1M7LK;Database=AccountDb;Trusted_Connection=True;MultipleActiveResultSets=true"; using (SqlConnection sqlconn = new SqlConnection(connection)) { string sqlquery = "select AI.Userpassword, AI.UserID, AI.Username, UR.Roleid from AccountInfo AI, UserRoles UR where AI.UserID = UR.UserID AND AI.Usermail = '" + userInfoItem.Usermail + "' "; using (SqlCommand sqlcomm = new SqlCommand(sqlquery, sqlconn)) { sqlconn.Open(); SqlDataReader reader = sqlcomm.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { // Password correct - Successful Login if (reader.GetString(0).Equals(userInfoItem.Userpassword)) { userInfoItem.UserID = reader.GetInt32(1); userInfoItem.Username = reader.GetString(2); userInfoItem.UserRole = reader.GetInt32(3); DateTime thisDay = DateTime.Now; userInfoItem.LoginDate = thisDay; // Add the user session for logging AddUserSessions(userInfoItem); } } } reader.Close(); } } _context.UserInfoItems.Add(userInfoItem); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetUserInfoItem), new { id = userInfoItem.Id }, userInfoItem)); }
public UserInfoItem GetUserInfoByEmailAndNCode(string emailaddress, string nationalCode) { UserInfoItem oItem = new UserInfoItem(); try { StreamReader sr = new StreamReader(HostingEnvironment.MapPath(ConfigurationManager.AppSettings["LOG_PATH"])); while (!sr.EndOfStream) { string i = sr.ReadLine(); string[] splitetext = i.Split(','); if (nationalCode == splitetext[3] && emailaddress == splitetext[6]) { oItem.FirstName = splitetext[0]; oItem.LastName = splitetext[1]; oItem.FatherName = splitetext[2]; oItem.NCode = splitetext[3]; oItem.Address = splitetext[4]; oItem.Tell = splitetext[5]; oItem.Email = splitetext[6]; oItem.Major = splitetext[7]; oItem.Education = splitetext[8]; oItem.Birthday = splitetext[9]; oItem.Gender = splitetext[10]; oItem.Extention = splitetext[11]; oItem.IsFill = true; break; } } sr.Close(); } catch (Exception) { } return(oItem); }
public void ShowResult(bool result, Object resultUI) { this.SP_Result.Children.Clear(); if (result == false) { TextBlock textBlock = new TextBlock(); textBlock.Text = "未找到"; this.SP_Result.Children.Add(textBlock); } else { this.current = resultUI; if (resultUI.GetType() == typeof(User)) { this.SP_Result.Children.Add(UserInfoItem.GotyeUserToUserInfoItem(resultUI as User)); } else { this.SP_Result.Children.Add(GroupInfoItem.GroupToUserInfoItem(resultUI as Group)); } } }
public async Task <ActionResult> UserRests(string Email, string UserName) { BL.Login empBL = new BL.Login(); if (empBL.ValiableEmail(Email, UserName) == "true") { return(Json("validateEmail", JsonRequestBehavior.AllowGet)); } else if (empBL.ValiableEmail(Email, UserName) == "error") { return(Json("error", JsonRequestBehavior.AllowGet)); } UserInfo userBL = new UserInfo(); IPasswordPolicy Password = new RandomPassword(); string orginalPassword = Password.GeneratePassword(); string md5Password = HashEncrypt.MD5(orginalPassword); UserInfoItem model = new UserInfoItem(); model = userBL.GetItemByName(UserName); IdentityModel user = await UserManager.FindByNameAsync(UserName); string password = UserManager.PasswordHasher.HashPassword(md5Password); UserStore store = new UserStore(); var set = store.SetPasswordHashAsync(user, password); var results = store.UpdateAsync(user); if (results != null) { userBL.SendEmail(model, orginalPassword, "User_ResetPassword"); return(Json("true", JsonRequestBehavior.AllowGet)); } else { return(Json("false", JsonRequestBehavior.AllowGet)); } }
public int Insert(UserInfoItem k) { int retval = 0; if (k.FirstName == "" || k.LastName == "" || k.FatherName == "" || k.NCode == "" || k.Address == "" || k.Tell == "" || k.Email == "" || k.Major == "" || k.Education == "" || k.Birthday == "" || k.Gender == "") { retval = -1; } if (retval == 0) { try { StreamWriter sw = new StreamWriter(HostingEnvironment.MapPath(ConfigurationManager.AppSettings["LOG_PATH"]), true); sw.WriteLine(k.FirstName + "," + k.LastName + "," + k.FatherName + "," + k.NCode + "," + k.Address + "," + k.Tell + "," + k.Email + "," + k.Major + "," + k.Education + "," + k.Birthday + "," + k.Gender + "," + k.Extention); sw.Close(); } catch (Exception ex) { retval = -2; } } return(retval); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { User user = null; try { if (string.IsNullOrEmpty(this.targetScreenName)) { user = await TwitterUtil.GetUserAsync(this.account.TokensData, this.targetId); } else { user = await TwitterUtil.GetUserAsync(this.account.TokensData, this.targetScreenName); } } catch (TwitterException tex) { MessageBox.Show(tex.Message, "Twitter Exception.", MessageBoxButton.OK, MessageBoxImage.Warning); this.Close(); return; } if (user == null) { this.Close(); return; } UserInfoItem item = new UserInfoItem(this.account.TokensData, user); this.userInfo = item; this.DataContext = this.userInfo; try { this.timeLineViewer_Tweet.Initialize(this, this.account, TimeLineMode.UserTweet); await this.timeLineViewer_Tweet.SetUserStatusesAsync(this.userInfo.Id); this.userListViewer_Follow.Initialize(this, this.account, UserListMode.Follow); await this.userListViewer_Follow.SetFollowsAsync(this.userInfo.Id); this.userListViewer_Follower.Initialize(this, this.account, UserListMode.Follower); await this.userListViewer_Follower.SetFollowersAsync(this.userInfo.Id); } catch (TwitterException tex) { MessageBox.Show(tex.Message, "Twitter Exception.", MessageBoxButton.OK, MessageBoxImage.Warning); } this.title = new TitleTextItem(string.Format("User Information - @{0}", user.ScreenName)); this.textBlock_Title.DataContext = this.title; this.Activate(); }
public List <UserInfoItem> FilterByNameLastnameEmail(string name, string lastname, string email) { List <UserInfoItem> LItemFilter = new List <UserInfoItem>(); bool nameIsFound = false; bool lastnameIsFound = false; bool emailIsFound = false; bool isFound = false; try { StreamReader sr = new StreamReader(HostingEnvironment.MapPath(ConfigurationManager.AppSettings["LOG_PATH"])); while (!sr.EndOfStream) { UserInfoItem oItem = new UserInfoItem(); string i = sr.ReadLine(); string[] splitetext = i.Split(','); //if ((name == splitetext[0]&&(lastname==splitetext[1]||lastname==""))||(lastname == splitetext[1] && name == "") ||((email== splitetext[6]|| email == "") && (lastname == splitetext[1] || lastname == "")&& (name == splitetext[0] || name == ""))) //if (string.IsNullOrEmpty(name) || splitetext[0] == name) // nameIsFound = true; //else // nameIsFound = false; //if (string.IsNullOrEmpty(lastname) || splitetext[1] == lastname) // lastnameIsFound = true; //else // lastnameIsFound = false; //if (string.IsNullOrEmpty(email) || splitetext[6] == email) // emailIsFound = true; //else // emailIsFound = false; //ایندکس را بررسی کردیم که اگر بخشی از یک کلمه سرچ شد هم بتواند پیدا کند. if ((string.IsNullOrEmpty(name) || splitetext[0].IndexOf(name) >= 0) && (string.IsNullOrEmpty(lastname) || splitetext[1].IndexOf(lastname) >= 0) && (string.IsNullOrEmpty(email) || splitetext[6].IndexOf(email) >= 0)) { isFound = true; } else { isFound = false; } //if (nameIsFound && lastnameIsFound && emailIsFound) if (isFound) { oItem.FirstName = splitetext[0]; oItem.LastName = splitetext[1]; oItem.FatherName = splitetext[2]; oItem.NCode = splitetext[3]; oItem.Address = splitetext[4]; oItem.Tell = splitetext[5]; oItem.Email = splitetext[6]; oItem.Major = splitetext[7]; oItem.Education = splitetext[8]; oItem.Birthday = splitetext[9]; oItem.Gender = splitetext[10]; oItem.Extention = splitetext[11]; LItemFilter.Add(oItem); } } sr.Close(); } catch { LItemFilter = null; } return(LItemFilter); }
public void AddNewFriend(User user) { var item = UserInfoItem.GotyeUserToUserInfoItem(user); this.SL_FriendList.AddItem(item); }
protected void btn_save_Click(object sender, EventArgs e) { string fileExtPhoto = ""; string fileExtAllowForPhoto = ""; long fileSizePhoto = 0; int fileSizeMaxForPhoto = 0; int indexFound = 0; bool uploadPhotoSuccess = false; if (fuPhoto.FileName.Length != 0) { fileExtPhoto = Path.GetExtension(fuPhoto.FileName); fileExtAllowForPhoto = ConfigurationManager.AppSettings["PHOTO_TYPE_ALLOW"]; fileSizePhoto = fuPhoto.FileContent.Length; fileSizeMaxForPhoto = Convert.ToInt32(ConfigurationManager.AppSettings["PHOTO_MAX_LENGTH"]); indexFound = fileExtAllowForPhoto.IndexOf(fileExtPhoto); if (indexFound >= 0) { if (fileSizePhoto <= fileSizeMaxForPhoto) { try { //اجرای عملیات آپلود fuPhoto.SaveAs(Server.MapPath(ConfigurationManager.AppSettings["PHOTO_UPLOAD_PATH"]) + txt_codemeli.Text + fileExtPhoto); uploadPhotoSuccess = true; } catch (Exception) { lblMessage.Text = "Sorry, There was a problem on saving photo to server!"; } } else { lblMessage.Text = "Upload status: File not uploaded, Please choose corect size!"; } } else { //نمایش پیغام به کاربر lblMessage.Text = "Upload status: File not uploaded, Please choose corect format!"; } } else { lblMessage.Text = "Upload status: you should select photo to upload !"; } if (uploadPhotoSuccess == true) { //StreamWriter sw = new StreamWriter(Server.MapPath(ConfigurationManager.AppSettings["LOG_PATH"]), true); //sw.WriteLine(txt_name.Text + "," + txt_lastname.Text + "," + txt_codemeli.Text + "," + txt_father.Text + "," + txt_address.Text + "," + txt_tell.Text + "," + txt_mail.Text + "," + year.Text + "/" + month.Text + "/" + day.Text + "," + reshte.SelectedValue + "," + madrak.SelectedValue + "," + fileExtPhoto); //sw.Close(); //استفاده از مبحث کلاس ها UserInfoItem objUserInfo = new UserInfoItem(); objUserInfo.FirstName = txt_name.Text; objUserInfo.LastName = txt_lastname.Text; objUserInfo.FatherName = txt_father.Text; objUserInfo.NCode = txt_codemeli.Text; objUserInfo.Tell = txt_tell.Text; objUserInfo.Email = txt_mail.Text; objUserInfo.Major = reshte.SelectedValue; objUserInfo.Education = madrak.SelectedValue; objUserInfo.Gender = rblGender.SelectedValue; objUserInfo.Birthday = year.Text + "/" + month.Text + "/" + day.Text; objUserInfo.Address = txt_address.Text; objUserInfo.Extention = fileExtPhoto; UserInfoLogic l = new UserInfoLogic(); l.Insert(objUserInfo); //در آخرین خط کد یعنی خط بالا ،متد اینزرت را در کلاس یوزر اینفو صدا زدیم و چون فاقد ورودی است داخل پرانتزش خالی است. } StreamReader n = new StreamReader(Server.MapPath("~/emailpage.html")); string m = ""; while (n.Peek() > 0) { m = m + n.ReadLine(); } m = m.Replace("{name}", txt_name.Text); m = m.Replace("{lastname}", txt_lastname.Text); m = m.Replace("{codemeli}", txt_codemeli.Text); string tvl = day.Text + "/" + month.Text + "/" + year.Text; m = m.Replace("{tavalod}", tvl); m = m.Replace("{email}", txt_mail.Text); m = m.Replace("{reshte}", reshte.Text); m = m.Replace("{madrak}", madrak.Text); MailMessage mail = new MailMessage(); mail.To.Add(txt_mail.Text); //mail.To.Add(txtmail.Text); mail.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["SENDER_ID"]); mail.Subject = "اطلاعات فردی"; mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Body = m; mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; mail.Priority = MailPriority.High; SmtpClient aryavandidadsmtpc = new SmtpClient(); try { aryavandidadsmtpc.Send(mail); lblshow.Text = "Successfully Send..."; } catch (Exception ex) { lblshow.Text = "Sending Failed..."; } }